Skip to content

Commit

Permalink
[ARM] Convert EBSA110 network driver to a platform driver
Browse files Browse the repository at this point in the history
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
  • Loading branch information
Russell King authored and Russell King committed Oct 31, 2005
1 parent 1be7228 commit 37bb30e
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 12 deletions.
26 changes: 25 additions & 1 deletion arch/arm/mach-ebsa110/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
41 changes: 32 additions & 9 deletions drivers/net/arm/am79c961a.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@
#include <linux/init.h>
#include <linux/crc32.h>
#include <linux/bitops.h>
#include <linux/platform_device.h>

#include <asm/system.h>
#include <asm/irq.h>
#include <asm/hardware.h>
#include <asm/io.h>
#include <asm/system.h>

#define TX_BUFFERS 15
#define RX_BUFFERS 25
Expand Down Expand Up @@ -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));
}
Expand Down Expand Up @@ -665,26 +668,34 @@ 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);

/*
* Fixed address and IRQ lines here.
* 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))
Expand All @@ -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;
Expand All @@ -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]);

Expand All @@ -746,4 +758,15 @@ static int __init am79c961_init(void)
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);
2 changes: 0 additions & 2 deletions drivers/net/arm/am79c961a.h
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,4 @@ struct dev_priv {
struct timer_list timer;
};

extern int am79c961_probe (struct net_device *dev);

#endif

0 comments on commit 37bb30e

Please sign in to comment.