diff options
author | Russell King <rmk@dyn-67.arm.linux.org.uk> | 2005-10-31 12:14:57 -0500 |
---|---|---|
committer | Russell King <rmk+kernel@arm.linux.org.uk> | 2005-10-31 12:14:57 -0500 |
commit | 37bb30e86bc2e48d9affb25f6ce9eb3d8e65b2ac (patch) | |
tree | d1419f0393effa0f4fd175cf0c65080e1f4626c6 /drivers/net | |
parent | 1be7228da280252167150346dcec4e7c50a79eb4 (diff) |
[ARM] Convert EBSA110 network driver to a platform driver
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Diffstat (limited to 'drivers/net')
-rw-r--r-- | drivers/net/arm/am79c961a.c | 41 | ||||
-rw-r--r-- | drivers/net/arm/am79c961a.h | 2 |
2 files changed, 32 insertions, 11 deletions
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 @@ | |||
26 | #include <linux/init.h> | 26 | #include <linux/init.h> |
27 | #include <linux/crc32.h> | 27 | #include <linux/crc32.h> |
28 | #include <linux/bitops.h> | 28 | #include <linux/bitops.h> |
29 | #include <linux/platform_device.h> | ||
29 | 30 | ||
30 | #include <asm/system.h> | ||
31 | #include <asm/irq.h> | ||
32 | #include <asm/hardware.h> | 31 | #include <asm/hardware.h> |
33 | #include <asm/io.h> | 32 | #include <asm/io.h> |
33 | #include <asm/system.h> | ||
34 | 34 | ||
35 | #define TX_BUFFERS 15 | 35 | #define TX_BUFFERS 15 |
36 | #define RX_BUFFERS 25 | 36 | #define RX_BUFFERS 25 |
@@ -280,10 +280,13 @@ static void am79c961_timer(unsigned long data) | |||
280 | lnkstat = read_ireg(dev->base_addr, ISALED0) & ISALED0_LNKST; | 280 | lnkstat = read_ireg(dev->base_addr, ISALED0) & ISALED0_LNKST; |
281 | carrier = netif_carrier_ok(dev); | 281 | carrier = netif_carrier_ok(dev); |
282 | 282 | ||
283 | if (lnkstat && !carrier) | 283 | if (lnkstat && !carrier) { |
284 | netif_carrier_on(dev); | 284 | netif_carrier_on(dev); |
285 | else if (!lnkstat && carrier) | 285 | printk("%s: link up\n", dev->name); |
286 | } else if (!lnkstat && carrier) { | ||
286 | netif_carrier_off(dev); | 287 | netif_carrier_off(dev); |
288 | printk("%s: link down\n", dev->name); | ||
289 | } | ||
287 | 290 | ||
288 | mod_timer(&priv->timer, jiffies + msecs_to_jiffies(500)); | 291 | mod_timer(&priv->timer, jiffies + msecs_to_jiffies(500)); |
289 | } | 292 | } |
@@ -665,17 +668,25 @@ static void __init am79c961_banner(void) | |||
665 | printk(KERN_INFO "%s", version); | 668 | printk(KERN_INFO "%s", version); |
666 | } | 669 | } |
667 | 670 | ||
668 | static int __init am79c961_init(void) | 671 | static int __init am79c961_probe(struct device *_dev) |
669 | { | 672 | { |
673 | struct platform_device *pdev = to_platform_device(_dev); | ||
674 | struct resource *res; | ||
670 | struct net_device *dev; | 675 | struct net_device *dev; |
671 | struct dev_priv *priv; | 676 | struct dev_priv *priv; |
672 | int i, ret; | 677 | int i, ret; |
673 | 678 | ||
679 | res = platform_get_resource(pdev, IORESOURCE_IO, 0); | ||
680 | if (!res) | ||
681 | return -ENODEV; | ||
682 | |||
674 | dev = alloc_etherdev(sizeof(struct dev_priv)); | 683 | dev = alloc_etherdev(sizeof(struct dev_priv)); |
675 | ret = -ENOMEM; | 684 | ret = -ENOMEM; |
676 | if (!dev) | 685 | if (!dev) |
677 | goto out; | 686 | goto out; |
678 | 687 | ||
688 | SET_NETDEV_DEV(dev, &pdev->dev); | ||
689 | |||
679 | priv = netdev_priv(dev); | 690 | priv = netdev_priv(dev); |
680 | 691 | ||
681 | /* | 692 | /* |
@@ -683,8 +694,8 @@ static int __init am79c961_init(void) | |||
683 | * The PNP initialisation should have been | 694 | * The PNP initialisation should have been |
684 | * done by the ether bootp loader. | 695 | * done by the ether bootp loader. |
685 | */ | 696 | */ |
686 | dev->base_addr = 0x220; | 697 | dev->base_addr = res->start; |
687 | dev->irq = IRQ_EBSA110_ETHERNET; | 698 | dev->irq = platform_get_irq(pdev, 0); |
688 | 699 | ||
689 | ret = -ENODEV; | 700 | ret = -ENODEV; |
690 | if (!request_region(dev->base_addr, 0x18, dev->name)) | 701 | if (!request_region(dev->base_addr, 0x18, dev->name)) |
@@ -705,11 +716,11 @@ static int __init am79c961_init(void) | |||
705 | inb(dev->base_addr + 4) != 0x2b) | 716 | inb(dev->base_addr + 4) != 0x2b) |
706 | goto release; | 717 | goto release; |
707 | 718 | ||
708 | am79c961_banner(); | ||
709 | |||
710 | for (i = 0; i < 6; i++) | 719 | for (i = 0; i < 6; i++) |
711 | dev->dev_addr[i] = inb(dev->base_addr + i * 2) & 0xff; | 720 | dev->dev_addr[i] = inb(dev->base_addr + i * 2) & 0xff; |
712 | 721 | ||
722 | am79c961_banner(); | ||
723 | |||
713 | spin_lock_init(&priv->chip_lock); | 724 | spin_lock_init(&priv->chip_lock); |
714 | init_timer(&priv->timer); | 725 | init_timer(&priv->timer); |
715 | priv->timer.data = (unsigned long)dev; | 726 | priv->timer.data = (unsigned long)dev; |
@@ -732,6 +743,7 @@ static int __init am79c961_init(void) | |||
732 | if (ret == 0) { | 743 | if (ret == 0) { |
733 | printk(KERN_INFO "%s: ether address ", dev->name); | 744 | printk(KERN_INFO "%s: ether address ", dev->name); |
734 | 745 | ||
746 | /* Retrive and print the ethernet address. */ | ||
735 | for (i = 0; i < 6; i++) | 747 | for (i = 0; i < 6; i++) |
736 | printk (i == 5 ? "%02x\n" : "%02x:", dev->dev_addr[i]); | 748 | printk (i == 5 ? "%02x\n" : "%02x:", dev->dev_addr[i]); |
737 | 749 | ||
@@ -746,4 +758,15 @@ out: | |||
746 | return ret; | 758 | return ret; |
747 | } | 759 | } |
748 | 760 | ||
761 | static struct device_driver am79c961_driver = { | ||
762 | .name = "am79c961", | ||
763 | .bus = &platform_bus_type, | ||
764 | .probe = am79c961_probe, | ||
765 | }; | ||
766 | |||
767 | static int __init am79c961_init(void) | ||
768 | { | ||
769 | return driver_register(&am79c961_driver); | ||
770 | } | ||
771 | |||
749 | __initcall(am79c961_init); | 772 | __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 { | |||
143 | struct timer_list timer; | 143 | struct timer_list timer; |
144 | }; | 144 | }; |
145 | 145 | ||
146 | extern int am79c961_probe (struct net_device *dev); | ||
147 | |||
148 | #endif | 146 | #endif |