From 37bb30e86bc2e48d9affb25f6ce9eb3d8e65b2ac Mon Sep 17 00:00:00 2001 From: Russell King Date: Mon, 31 Oct 2005 17:14:57 +0000 Subject: [PATCH] [ARM] Convert EBSA110 network driver to a platform driver Signed-off-by: Russell King --- arch/arm/mach-ebsa110/core.c | 26 ++++++++++++++++++++++- drivers/net/arm/am79c961a.c | 41 ++++++++++++++++++++++++++++-------- drivers/net/arm/am79c961a.h | 2 -- 3 files changed, 57 insertions(+), 12 deletions(-) diff --git a/arch/arm/mach-ebsa110/core.c b/arch/arm/mach-ebsa110/core.c index 15261646dcdd..ed4614983adb 100644 --- a/arch/arm/mach-ebsa110/core.c +++ b/arch/arm/mach-ebsa110/core.c @@ -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) { - return platform_device_register(&serial_device); + return platform_add_devices(ebsa110_devices, ARRAY_SIZE(ebsa110_devices)); } arch_initcall(ebsa110_init); diff --git a/drivers/net/arm/am79c961a.c b/drivers/net/arm/am79c961a.c index 3d50e953faaa..877891a29aaa 100644 --- a/drivers/net/arm/am79c961a.c +++ b/drivers/net/arm/am79c961a.c @@ -26,11 +26,11 @@ #include #include #include +#include -#include -#include #include #include +#include #define TX_BUFFERS 15 #define RX_BUFFERS 25 @@ -280,10 +280,13 @@ static void am79c961_timer(unsigned long data) lnkstat = read_ireg(dev->base_addr, ISALED0) & ISALED0_LNKST; carrier = netif_carrier_ok(dev); - if (lnkstat && !carrier) + if (lnkstat && !carrier) { netif_carrier_on(dev); - else if (!lnkstat && carrier) + printk("%s: link up\n", dev->name); + } else if (!lnkstat && carrier) { netif_carrier_off(dev); + printk("%s: link down\n", dev->name); + } mod_timer(&priv->timer, jiffies + msecs_to_jiffies(500)); } @@ -665,17 +668,25 @@ static void __init am79c961_banner(void) 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 dev_priv *priv; int i, ret; + res = platform_get_resource(pdev, IORESOURCE_IO, 0); + if (!res) + return -ENODEV; + dev = alloc_etherdev(sizeof(struct dev_priv)); ret = -ENOMEM; if (!dev) goto out; + SET_NETDEV_DEV(dev, &pdev->dev); + priv = netdev_priv(dev); /* @@ -683,8 +694,8 @@ static int __init am79c961_init(void) * The PNP initialisation should have been * done by the ether bootp loader. */ - dev->base_addr = 0x220; - dev->irq = IRQ_EBSA110_ETHERNET; + dev->base_addr = res->start; + dev->irq = platform_get_irq(pdev, 0); ret = -ENODEV; if (!request_region(dev->base_addr, 0x18, dev->name)) @@ -705,11 +716,11 @@ static int __init am79c961_init(void) inb(dev->base_addr + 4) != 0x2b) goto release; - am79c961_banner(); - for (i = 0; i < 6; i++) dev->dev_addr[i] = inb(dev->base_addr + i * 2) & 0xff; + am79c961_banner(); + spin_lock_init(&priv->chip_lock); init_timer(&priv->timer); priv->timer.data = (unsigned long)dev; @@ -732,6 +743,7 @@ static int __init am79c961_init(void) if (ret == 0) { printk(KERN_INFO "%s: ether address ", dev->name); + /* Retrive and print the ethernet address. */ for (i = 0; i < 6; i++) printk (i == 5 ? "%02x\n" : "%02x:", dev->dev_addr[i]); @@ -746,4 +758,15 @@ out: 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); diff --git a/drivers/net/arm/am79c961a.h b/drivers/net/arm/am79c961a.h index 1e9b05050cbe..6a49ac7f6d46 100644 --- a/drivers/net/arm/am79c961a.h +++ b/drivers/net/arm/am79c961a.h @@ -143,6 +143,4 @@ struct dev_priv { struct timer_list timer; }; -extern int am79c961_probe (struct net_device *dev); - #endif -- 2.20.1