Commit 37bb30e8 authored by Russell King's avatar Russell King Committed by Russell King

[ARM] Convert EBSA110 network driver to a platform driver

Signed-off-by: default avatarRussell King <rmk+kernel@arm.linux.org.uk>
parent 1be7228d
...@@ -251,9 +251,33 @@ static struct platform_device serial_device = { ...@@ -251,9 +251,33 @@ static struct platform_device serial_device = {
}, },
}; };
static struct resource am79c961_resources[] = {
{
.start = 0x220,
.end = 0x238,
.flags = IORESOURCE_IO,
}, {
.start = IRQ_EBSA110_ETHERNET,
.end = IRQ_EBSA110_ETHERNET,
.flags = IORESOURCE_IRQ,
},
};
static struct platform_device am79c961_device = {
.name = "am79c961",
.id = -1,
.num_resources = ARRAY_SIZE(am79c961_resources),
.resource = am79c961_resources,
};
static struct platform_device *ebsa110_devices[] = {
&serial_device,
&am79c961_device,
};
static int __init ebsa110_init(void) static int __init ebsa110_init(void)
{ {
return platform_device_register(&serial_device); return platform_add_devices(ebsa110_devices, ARRAY_SIZE(ebsa110_devices));
} }
arch_initcall(ebsa110_init); arch_initcall(ebsa110_init);
......
...@@ -26,11 +26,11 @@ ...@@ -26,11 +26,11 @@
#include <linux/init.h> #include <linux/init.h>
#include <linux/crc32.h> #include <linux/crc32.h>
#include <linux/bitops.h> #include <linux/bitops.h>
#include <linux/platform_device.h>
#include <asm/system.h>
#include <asm/irq.h>
#include <asm/hardware.h> #include <asm/hardware.h>
#include <asm/io.h> #include <asm/io.h>
#include <asm/system.h>
#define TX_BUFFERS 15 #define TX_BUFFERS 15
#define RX_BUFFERS 25 #define RX_BUFFERS 25
...@@ -280,10 +280,13 @@ static void am79c961_timer(unsigned long data) ...@@ -280,10 +280,13 @@ static void am79c961_timer(unsigned long data)
lnkstat = read_ireg(dev->base_addr, ISALED0) & ISALED0_LNKST; lnkstat = read_ireg(dev->base_addr, ISALED0) & ISALED0_LNKST;
carrier = netif_carrier_ok(dev); carrier = netif_carrier_ok(dev);
if (lnkstat && !carrier) if (lnkstat && !carrier) {
netif_carrier_on(dev); netif_carrier_on(dev);
else if (!lnkstat && carrier) printk("%s: link up\n", dev->name);
} else if (!lnkstat && carrier) {
netif_carrier_off(dev); netif_carrier_off(dev);
printk("%s: link down\n", dev->name);
}
mod_timer(&priv->timer, jiffies + msecs_to_jiffies(500)); mod_timer(&priv->timer, jiffies + msecs_to_jiffies(500));
} }
...@@ -665,17 +668,25 @@ static void __init am79c961_banner(void) ...@@ -665,17 +668,25 @@ static void __init am79c961_banner(void)
printk(KERN_INFO "%s", version); printk(KERN_INFO "%s", version);
} }
static int __init am79c961_init(void) static int __init am79c961_probe(struct device *_dev)
{ {
struct platform_device *pdev = to_platform_device(_dev);
struct resource *res;
struct net_device *dev; struct net_device *dev;
struct dev_priv *priv; struct dev_priv *priv;
int i, ret; int i, ret;
res = platform_get_resource(pdev, IORESOURCE_IO, 0);
if (!res)
return -ENODEV;
dev = alloc_etherdev(sizeof(struct dev_priv)); dev = alloc_etherdev(sizeof(struct dev_priv));
ret = -ENOMEM; ret = -ENOMEM;
if (!dev) if (!dev)
goto out; goto out;
SET_NETDEV_DEV(dev, &pdev->dev);
priv = netdev_priv(dev); priv = netdev_priv(dev);
/* /*
...@@ -683,8 +694,8 @@ static int __init am79c961_init(void) ...@@ -683,8 +694,8 @@ static int __init am79c961_init(void)
* The PNP initialisation should have been * The PNP initialisation should have been
* done by the ether bootp loader. * done by the ether bootp loader.
*/ */
dev->base_addr = 0x220; dev->base_addr = res->start;
dev->irq = IRQ_EBSA110_ETHERNET; dev->irq = platform_get_irq(pdev, 0);
ret = -ENODEV; ret = -ENODEV;
if (!request_region(dev->base_addr, 0x18, dev->name)) if (!request_region(dev->base_addr, 0x18, dev->name))
...@@ -705,11 +716,11 @@ static int __init am79c961_init(void) ...@@ -705,11 +716,11 @@ static int __init am79c961_init(void)
inb(dev->base_addr + 4) != 0x2b) inb(dev->base_addr + 4) != 0x2b)
goto release; goto release;
am79c961_banner();
for (i = 0; i < 6; i++) for (i = 0; i < 6; i++)
dev->dev_addr[i] = inb(dev->base_addr + i * 2) & 0xff; dev->dev_addr[i] = inb(dev->base_addr + i * 2) & 0xff;
am79c961_banner();
spin_lock_init(&priv->chip_lock); spin_lock_init(&priv->chip_lock);
init_timer(&priv->timer); init_timer(&priv->timer);
priv->timer.data = (unsigned long)dev; priv->timer.data = (unsigned long)dev;
...@@ -732,6 +743,7 @@ static int __init am79c961_init(void) ...@@ -732,6 +743,7 @@ static int __init am79c961_init(void)
if (ret == 0) { if (ret == 0) {
printk(KERN_INFO "%s: ether address ", dev->name); printk(KERN_INFO "%s: ether address ", dev->name);
/* Retrive and print the ethernet address. */
for (i = 0; i < 6; i++) for (i = 0; i < 6; i++)
printk (i == 5 ? "%02x\n" : "%02x:", dev->dev_addr[i]); printk (i == 5 ? "%02x\n" : "%02x:", dev->dev_addr[i]);
...@@ -746,4 +758,15 @@ static int __init am79c961_init(void) ...@@ -746,4 +758,15 @@ static int __init am79c961_init(void)
return ret; return ret;
} }
static struct device_driver am79c961_driver = {
.name = "am79c961",
.bus = &platform_bus_type,
.probe = am79c961_probe,
};
static int __init am79c961_init(void)
{
return driver_register(&am79c961_driver);
}
__initcall(am79c961_init); __initcall(am79c961_init);
...@@ -143,6 +143,4 @@ struct dev_priv { ...@@ -143,6 +143,4 @@ struct dev_priv {
struct timer_list timer; struct timer_list timer;
}; };
extern int am79c961_probe (struct net_device *dev);
#endif #endif
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment