diff options
Diffstat (limited to 'drivers/net/ne.c')
-rw-r--r-- | drivers/net/ne.c | 123 |
1 files changed, 104 insertions, 19 deletions
diff --git a/drivers/net/ne.c b/drivers/net/ne.c index a5c4199e2754..c9f74bf5f491 100644 --- a/drivers/net/ne.c +++ b/drivers/net/ne.c | |||
@@ -51,14 +51,11 @@ static const char version2[] = | |||
51 | #include <linux/netdevice.h> | 51 | #include <linux/netdevice.h> |
52 | #include <linux/etherdevice.h> | 52 | #include <linux/etherdevice.h> |
53 | #include <linux/jiffies.h> | 53 | #include <linux/jiffies.h> |
54 | #include <linux/platform_device.h> | ||
54 | 55 | ||
55 | #include <asm/system.h> | 56 | #include <asm/system.h> |
56 | #include <asm/io.h> | 57 | #include <asm/io.h> |
57 | 58 | ||
58 | #if defined(CONFIG_TOSHIBA_RBTX4927) || defined(CONFIG_TOSHIBA_RBTX4938) | ||
59 | #include <asm/tx4938/rbtx4938.h> | ||
60 | #endif | ||
61 | |||
62 | #include "8390.h" | 59 | #include "8390.h" |
63 | 60 | ||
64 | #define DRV_NAME "ne" | 61 | #define DRV_NAME "ne" |
@@ -77,8 +74,13 @@ static const char version2[] = | |||
77 | /* Do we have a non std. amount of memory? (in units of 256 byte pages) */ | 74 | /* Do we have a non std. amount of memory? (in units of 256 byte pages) */ |
78 | /* #define PACKETBUF_MEMSIZE 0x40 */ | 75 | /* #define PACKETBUF_MEMSIZE 0x40 */ |
79 | 76 | ||
77 | #if !defined(MODULE) && (defined(CONFIG_ISA) || defined(CONFIG_M32R)) | ||
78 | /* Do we need a portlist for the ISA auto-probe ? */ | ||
79 | #define NEEDS_PORTLIST | ||
80 | #endif | ||
81 | |||
80 | /* A zero-terminated list of I/O addresses to be probed at boot. */ | 82 | /* A zero-terminated list of I/O addresses to be probed at boot. */ |
81 | #ifndef MODULE | 83 | #ifdef NEEDS_PORTLIST |
82 | static unsigned int netcard_portlist[] __initdata = { | 84 | static unsigned int netcard_portlist[] __initdata = { |
83 | 0x300, 0x280, 0x320, 0x340, 0x360, 0x380, 0 | 85 | 0x300, 0x280, 0x320, 0x340, 0x360, 0x380, 0 |
84 | }; | 86 | }; |
@@ -146,7 +148,7 @@ bad_clone_list[] __initdata = { | |||
146 | # define DCR_VAL 0x49 | 148 | # define DCR_VAL 0x49 |
147 | #endif | 149 | #endif |
148 | 150 | ||
149 | static int ne_probe1(struct net_device *dev, int ioaddr); | 151 | static int ne_probe1(struct net_device *dev, unsigned long ioaddr); |
150 | static int ne_probe_isapnp(struct net_device *dev); | 152 | static int ne_probe_isapnp(struct net_device *dev); |
151 | 153 | ||
152 | static int ne_open(struct net_device *dev); | 154 | static int ne_open(struct net_device *dev); |
@@ -184,8 +186,8 @@ static void ne_block_output(struct net_device *dev, const int count, | |||
184 | 186 | ||
185 | static int __init do_ne_probe(struct net_device *dev) | 187 | static int __init do_ne_probe(struct net_device *dev) |
186 | { | 188 | { |
187 | unsigned int base_addr = dev->base_addr; | 189 | unsigned long base_addr = dev->base_addr; |
188 | #ifndef MODULE | 190 | #ifdef NEEDS_PORTLIST |
189 | int orig_irq = dev->irq; | 191 | int orig_irq = dev->irq; |
190 | #endif | 192 | #endif |
191 | 193 | ||
@@ -201,7 +203,7 @@ static int __init do_ne_probe(struct net_device *dev) | |||
201 | if (isapnp_present() && (ne_probe_isapnp(dev) == 0)) | 203 | if (isapnp_present() && (ne_probe_isapnp(dev) == 0)) |
202 | return 0; | 204 | return 0; |
203 | 205 | ||
204 | #ifndef MODULE | 206 | #ifdef NEEDS_PORTLIST |
205 | /* Last resort. The semi-risky ISA auto-probe. */ | 207 | /* Last resort. The semi-risky ISA auto-probe. */ |
206 | for (base_addr = 0; netcard_portlist[base_addr] != 0; base_addr++) { | 208 | for (base_addr = 0; netcard_portlist[base_addr] != 0; base_addr++) { |
207 | int ioaddr = netcard_portlist[base_addr]; | 209 | int ioaddr = netcard_portlist[base_addr]; |
@@ -226,10 +228,6 @@ struct net_device * __init ne_probe(int unit) | |||
226 | sprintf(dev->name, "eth%d", unit); | 228 | sprintf(dev->name, "eth%d", unit); |
227 | netdev_boot_setup_check(dev); | 229 | netdev_boot_setup_check(dev); |
228 | 230 | ||
229 | #ifdef CONFIG_TOSHIBA_RBTX4938 | ||
230 | dev->base_addr = RBTX4938_RTL_8019_BASE; | ||
231 | dev->irq = RBTX4938_RTL_8019_IRQ; | ||
232 | #endif | ||
233 | err = do_ne_probe(dev); | 231 | err = do_ne_probe(dev); |
234 | if (err) | 232 | if (err) |
235 | goto out; | 233 | goto out; |
@@ -285,7 +283,7 @@ static int __init ne_probe_isapnp(struct net_device *dev) | |||
285 | return -ENODEV; | 283 | return -ENODEV; |
286 | } | 284 | } |
287 | 285 | ||
288 | static int __init ne_probe1(struct net_device *dev, int ioaddr) | 286 | static int __init ne_probe1(struct net_device *dev, unsigned long ioaddr) |
289 | { | 287 | { |
290 | int i; | 288 | int i; |
291 | unsigned char SA_prom[32]; | 289 | unsigned char SA_prom[32]; |
@@ -324,7 +322,7 @@ static int __init ne_probe1(struct net_device *dev, int ioaddr) | |||
324 | if (ei_debug && version_printed++ == 0) | 322 | if (ei_debug && version_printed++ == 0) |
325 | printk(KERN_INFO "%s" KERN_INFO "%s", version1, version2); | 323 | printk(KERN_INFO "%s" KERN_INFO "%s", version1, version2); |
326 | 324 | ||
327 | printk(KERN_INFO "NE*000 ethercard probe at %#3x:", ioaddr); | 325 | printk(KERN_INFO "NE*000 ethercard probe at %#3lx:", ioaddr); |
328 | 326 | ||
329 | /* A user with a poor card that fails to ack the reset, or that | 327 | /* A user with a poor card that fails to ack the reset, or that |
330 | does not have a valid 0x57,0x57 signature can still use this | 328 | does not have a valid 0x57,0x57 signature can still use this |
@@ -516,8 +514,7 @@ static int __init ne_probe1(struct net_device *dev, int ioaddr) | |||
516 | } | 514 | } |
517 | #endif | 515 | #endif |
518 | 516 | ||
519 | printk("\n%s: %s found at %#x, using IRQ %d.\n", | 517 | printk("\n"); |
520 | dev->name, name, ioaddr, dev->irq); | ||
521 | 518 | ||
522 | ei_status.name = name; | 519 | ei_status.name = name; |
523 | ei_status.tx_start_page = start_page; | 520 | ei_status.tx_start_page = start_page; |
@@ -547,6 +544,8 @@ static int __init ne_probe1(struct net_device *dev, int ioaddr) | |||
547 | ret = register_netdev(dev); | 544 | ret = register_netdev(dev); |
548 | if (ret) | 545 | if (ret) |
549 | goto out_irq; | 546 | goto out_irq; |
547 | printk(KERN_INFO "%s: %s found at %#lx, using IRQ %d.\n", | ||
548 | dev->name, name, ioaddr, dev->irq); | ||
550 | return 0; | 549 | return 0; |
551 | 550 | ||
552 | out_irq: | 551 | out_irq: |
@@ -807,6 +806,87 @@ retry: | |||
807 | return; | 806 | return; |
808 | } | 807 | } |
809 | 808 | ||
809 | static int __init ne_drv_probe(struct platform_device *pdev) | ||
810 | { | ||
811 | struct net_device *dev; | ||
812 | struct resource *res; | ||
813 | int err, irq; | ||
814 | |||
815 | res = platform_get_resource(pdev, IORESOURCE_IO, 0); | ||
816 | irq = platform_get_irq(pdev, 0); | ||
817 | if (!res || irq < 0) | ||
818 | return -ENODEV; | ||
819 | |||
820 | dev = alloc_ei_netdev(); | ||
821 | if (!dev) | ||
822 | return -ENOMEM; | ||
823 | dev->irq = irq; | ||
824 | dev->base_addr = res->start; | ||
825 | err = do_ne_probe(dev); | ||
826 | if (err) { | ||
827 | free_netdev(dev); | ||
828 | return err; | ||
829 | } | ||
830 | platform_set_drvdata(pdev, dev); | ||
831 | return 0; | ||
832 | } | ||
833 | |||
834 | static int __exit ne_drv_remove(struct platform_device *pdev) | ||
835 | { | ||
836 | struct net_device *dev = platform_get_drvdata(pdev); | ||
837 | |||
838 | unregister_netdev(dev); | ||
839 | free_irq(dev->irq, dev); | ||
840 | release_region(dev->base_addr, NE_IO_EXTENT); | ||
841 | free_netdev(dev); | ||
842 | return 0; | ||
843 | } | ||
844 | |||
845 | #ifdef CONFIG_PM | ||
846 | static int ne_drv_suspend(struct platform_device *pdev, pm_message_t state) | ||
847 | { | ||
848 | struct net_device *dev = platform_get_drvdata(pdev); | ||
849 | |||
850 | if (netif_running(dev)) | ||
851 | netif_device_detach(dev); | ||
852 | return 0; | ||
853 | } | ||
854 | |||
855 | static int ne_drv_resume(struct platform_device *pdev) | ||
856 | { | ||
857 | struct net_device *dev = platform_get_drvdata(pdev); | ||
858 | |||
859 | if (netif_running(dev)) { | ||
860 | ne_reset_8390(dev); | ||
861 | NS8390_init(dev, 1); | ||
862 | netif_device_attach(dev); | ||
863 | } | ||
864 | return 0; | ||
865 | } | ||
866 | #else | ||
867 | #define ne_drv_suspend NULL | ||
868 | #define ne_drv_resume NULL | ||
869 | #endif | ||
870 | |||
871 | static struct platform_driver ne_driver = { | ||
872 | .remove = __exit_p(ne_drv_remove), | ||
873 | .suspend = ne_drv_suspend, | ||
874 | .resume = ne_drv_resume, | ||
875 | .driver = { | ||
876 | .name = DRV_NAME, | ||
877 | .owner = THIS_MODULE, | ||
878 | }, | ||
879 | }; | ||
880 | |||
881 | static int __init ne_init(void) | ||
882 | { | ||
883 | return platform_driver_probe(&ne_driver, ne_drv_probe); | ||
884 | } | ||
885 | |||
886 | static void __exit ne_exit(void) | ||
887 | { | ||
888 | platform_driver_unregister(&ne_driver); | ||
889 | } | ||
810 | 890 | ||
811 | #ifdef MODULE | 891 | #ifdef MODULE |
812 | #define MAX_NE_CARDS 4 /* Max number of NE cards per module */ | 892 | #define MAX_NE_CARDS 4 /* Max number of NE cards per module */ |
@@ -832,6 +912,7 @@ ISA device autoprobes on a running machine are not recommended anyway. */ | |||
832 | int __init init_module(void) | 912 | int __init init_module(void) |
833 | { | 913 | { |
834 | int this_dev, found = 0; | 914 | int this_dev, found = 0; |
915 | int plat_found = !ne_init(); | ||
835 | 916 | ||
836 | for (this_dev = 0; this_dev < MAX_NE_CARDS; this_dev++) { | 917 | for (this_dev = 0; this_dev < MAX_NE_CARDS; this_dev++) { |
837 | struct net_device *dev = alloc_ei_netdev(); | 918 | struct net_device *dev = alloc_ei_netdev(); |
@@ -845,7 +926,7 @@ int __init init_module(void) | |||
845 | continue; | 926 | continue; |
846 | } | 927 | } |
847 | free_netdev(dev); | 928 | free_netdev(dev); |
848 | if (found) | 929 | if (found || plat_found) |
849 | break; | 930 | break; |
850 | if (io[this_dev] != 0) | 931 | if (io[this_dev] != 0) |
851 | printk(KERN_WARNING "ne.c: No NE*000 card found at i/o = %#x\n", io[this_dev]); | 932 | printk(KERN_WARNING "ne.c: No NE*000 card found at i/o = %#x\n", io[this_dev]); |
@@ -853,7 +934,7 @@ int __init init_module(void) | |||
853 | printk(KERN_NOTICE "ne.c: You must supply \"io=0xNNN\" value(s) for ISA cards.\n"); | 934 | printk(KERN_NOTICE "ne.c: You must supply \"io=0xNNN\" value(s) for ISA cards.\n"); |
854 | return -ENXIO; | 935 | return -ENXIO; |
855 | } | 936 | } |
856 | if (found) | 937 | if (found || plat_found) |
857 | return 0; | 938 | return 0; |
858 | return -ENODEV; | 939 | return -ENODEV; |
859 | } | 940 | } |
@@ -871,6 +952,7 @@ void __exit cleanup_module(void) | |||
871 | { | 952 | { |
872 | int this_dev; | 953 | int this_dev; |
873 | 954 | ||
955 | ne_exit(); | ||
874 | for (this_dev = 0; this_dev < MAX_NE_CARDS; this_dev++) { | 956 | for (this_dev = 0; this_dev < MAX_NE_CARDS; this_dev++) { |
875 | struct net_device *dev = dev_ne[this_dev]; | 957 | struct net_device *dev = dev_ne[this_dev]; |
876 | if (dev) { | 958 | if (dev) { |
@@ -880,4 +962,7 @@ void __exit cleanup_module(void) | |||
880 | } | 962 | } |
881 | } | 963 | } |
882 | } | 964 | } |
965 | #else /* MODULE */ | ||
966 | module_init(ne_init); | ||
967 | module_exit(ne_exit); | ||
883 | #endif /* MODULE */ | 968 | #endif /* MODULE */ |