38 static const char version1[] =
40 static const char version2[] =
41 "Last modified Nov 1, 2000 by Paul Gortmaker\n";
44 #include <linux/module.h>
45 #include <linux/kernel.h>
46 #include <linux/errno.h>
51 #include <linux/netdevice.h>
65 #define SUPPORT_NE_BAD_CLONES
69 #define MAX_NE_CARDS 4
99 #if !defined(MODULE) && (defined(CONFIG_ISA) || defined(CONFIG_M32R))
101 #define NEEDS_PORTLIST
105 #ifdef NEEDS_PORTLIST
106 static unsigned int netcard_portlist[]
__initdata = {
107 0x300, 0x280, 0x320, 0x340, 0x360, 0x380, 0
112 { ISAPNP_CARD_ID(
'A',
'X',
'E',0x2011),
114 (
long)
"NetGear EA201" },
117 (
long)
"NN NE2000" },
120 (
long)
"Generic PNP" },
126 #ifdef SUPPORT_NE_BAD_CLONES
129 bad_clone_list[] __initdata = {
130 {
"DE100",
"DE200", {0x00, 0xDE, 0x01,}},
131 {
"DE120",
"DE220", {0x00, 0x80, 0xc8,}},
132 {
"DFI1000",
"DFI2000", {
'D',
'F',
'I',}},
133 {
"EtherNext UTP8",
"EtherNext UTP16", {0x00, 0x00, 0x79}},
134 {
"NE1000",
"NE2000-invalid", {0x00, 0x00, 0xd8}},
135 {
"NN1000",
"NN2000", {0x08, 0x03, 0x08}},
136 {
"4-DIM8",
"4-DIM16", {0x00,0x00,0x4d,}},
137 {
"Con-Intl_8",
"Con-Intl_16", {0x00, 0x00, 0x24}},
138 {
"ET-100",
"ET-200", {0x00, 0x45, 0x54}},
139 {
"COMPEX",
"COMPEX16",{0x00,0x80,0x48}},
140 {
"E-LAN100",
"E-LAN200", {0x00, 0x00, 0x5d}},
141 {
"PCM-4823",
"PCM-4823", {0x00, 0xc0, 0x6c}},
142 {
"REALTEK",
"RTL8019", {0x00, 0x00, 0xe8}},
143 #ifdef CONFIG_MACH_TX49XX
144 {
"RBHMA4X00-RTL8019",
"RBHMA4X00-RTL8019", {0x00, 0x60, 0x0a}},
146 {
"LCS-8834",
"LCS-8836", {0x04, 0x04, 0x37}},
153 #define NE_BASE (dev->base_addr)
155 #define NE_DATAPORT 0x10
156 #define NE_RESET 0x1f
157 #define NE_IO_EXTENT 0x20
159 #define NE1SM_START_PG 0x20
160 #define NE1SM_STOP_PG 0x40
161 #define NESM_START_PG 0x40
162 #define NESM_STOP_PG 0x80
164 #if defined(CONFIG_PLAT_MAPPI)
165 # define DCR_VAL 0x4b
166 #elif defined(CONFIG_PLAT_OAKS32R) || \
167 defined(CONFIG_MACH_TX49XX)
168 # define DCR_VAL 0x48
170 # define DCR_VAL 0x49
173 static int ne_probe1(
struct net_device *
dev,
unsigned long ioaddr);
182 const unsigned char *
buf,
const int start_page);
208 unsigned long base_addr = dev->
base_addr;
209 #ifdef NEEDS_PORTLIST
210 int orig_irq = dev->
irq;
214 if (base_addr > 0x1ff) {
215 int ret = ne_probe1(dev, base_addr);
218 "i/o = %#lx\n", base_addr);
221 else if (base_addr != 0)
228 #ifdef NEEDS_PORTLIST
230 for (base_addr = 0; netcard_portlist[base_addr] != 0; base_addr++) {
231 int ioaddr = netcard_portlist[base_addr];
233 if (ne_probe1(dev, ioaddr) == 0)
245 for (i = 0; isapnp_clone_list[
i].vendor != 0; i++) {
249 isapnp_clone_list[i].
vendor,
250 isapnp_clone_list[i].
function,
260 if (!pnp_port_valid(idev, 0) || !pnp_irq_valid(idev, 0)) {
265 dev->
base_addr = pnp_port_start(idev, 0);
270 if (ne_probe1(dev, dev->
base_addr) != 0) {
289 unsigned char SA_prom[32];
292 int start_page, stop_page;
293 int neX000, ctron, copam, bad_card;
295 static unsigned version_printed;
300 reg0 =
inb_p(ioaddr);
310 regd =
inb_p(ioaddr + 0x0d);
311 outb_p(0xff, ioaddr + 0x0d);
316 outb_p(regd, ioaddr + 0x0d);
322 if (
ei_debug && version_printed++ == 0)
338 unsigned long reset_start_time =
jiffies;
346 printk(
" (warning: no reset ack)");
349 printk(
" not found (no reset ack).\n");
363 struct {
unsigned char value,
offset; } program_seq[] =
384 for(i = 0; i < 32 ; i+=2) {
387 if (SA_prom[i] != SA_prom[i+1])
393 for (i = 0; i < 16; i++)
394 SA_prom[i] = SA_prom[i+i];
416 #if defined(CONFIG_PLAT_MAPPI) || defined(CONFIG_PLAT_OAKS32R)
417 neX000 = ((SA_prom[14] == 0x57 && SA_prom[15] == 0x57)
418 || (SA_prom[14] == 0x42 && SA_prom[15] == 0x42));
420 neX000 = (SA_prom[14] == 0x57 && SA_prom[15] == 0x57);
422 ctron = (SA_prom[0] == 0x00 && SA_prom[1] == 0x00 && SA_prom[2] == 0x1d);
423 copam = (SA_prom[14] == 0x49 && SA_prom[15] == 0x00);
426 if (neX000 || bad_card || copam) {
427 name = (wordlength == 2) ?
"NE2000" :
"NE1000";
431 name = (wordlength == 2) ?
"Ctron-8" :
"Ctron-16";
433 stop_page = (wordlength == 2) ? 0x40 : 0x20;
437 #ifdef SUPPORT_NE_BAD_CLONES
440 for (i = 0; bad_clone_list[
i].name8; i++)
442 if (SA_prom[0] == bad_clone_list[i].
SAprefix[0] &&
443 SA_prom[1] == bad_clone_list[i].
SAprefix[1] &&
444 SA_prom[2] == bad_clone_list[i].
SAprefix[2])
448 name = bad_clone_list[
i].name16;
450 name = bad_clone_list[
i].name8;
457 printk(
" not found (invalid signature %2.2x %2.2x).\n",
458 SA_prom[14], SA_prom[15]);
481 }
else if (dev->
irq == 2)
487 printk(
" failed to detect IRQ line.\n");
496 printk (
" unable to get IRQ %d (errno=%d).\n", dev->
irq, ret);
502 #ifdef CONFIG_PLAT_MAPPI
525 #ifdef PACKETBUF_MEMSIZE
532 ei_status.block_output = &ne_block_output;
533 ei_status.get_8390_hdr = &ne_get_8390_hdr;
543 dev->
name, name, ioaddr, dev->
irq);
556 static void ne_reset_8390(
struct net_device *dev)
558 unsigned long reset_start_time =
jiffies;
591 "[DMAstat:%d][irqlock:%d].\n",
622 #ifdef NE_SANITY_CHECK
623 int xfer_count =
count;
632 "[DMAstat:%d][irqlock:%d].\n",
649 #ifdef NE_SANITY_CHECK
657 #ifdef NE_SANITY_CHECK
666 int addr, tries = 20;
672 addr = (high << 8) + low;
673 if (((ring_offset + xfer_count) & 0xff) ==
low)
675 }
while (--tries > 0);
678 "%#4.4x (expected) vs. %#4.4x (actual).\n",
679 dev->
name, ring_offset + xfer_count, addr);
686 static void ne_block_output(
struct net_device *dev,
int count,
687 const unsigned char *buf,
const int start_page)
691 #ifdef NE_SANITY_CHECK
706 "[DMAstat:%d][irqlock:%d]\n",
714 #ifdef NE_SANITY_CHECK
718 #ifdef NE8390_RW_BUGFIX
750 #ifdef NE_SANITY_CHECK
757 int addr, tries = 20;
761 addr = (high << 8) + low;
762 if ((start_page << 8) + count ==
addr)
764 }
while (--tries > 0);
769 "%#4.4x (expected) vs. %#4.4x (actual).\n",
770 dev->
name, (start_page << 8) + count, addr);
792 int err, this_dev = pdev->
id;
795 dev = alloc_eip_netdev();
813 dev->
irq = irq[this_dev];
817 err = do_ne_probe(dev);
822 platform_set_drvdata(pdev, dev);
829 irq[this_dev] = dev->
irq;
836 struct net_device *dev = platform_get_drvdata(pdev);
852 platform_set_drvdata(pdev,
NULL);
858 static void ne_loop_rm_unreg(
int all)
862 for (this_dev = 0; this_dev <
MAX_NE_CARDS; this_dev++) {
863 pdev = pdev_ne[this_dev];
865 if (pdev && (!platform_get_drvdata(pdev) || all)) {
868 pdev_ne[this_dev] =
NULL;
876 struct net_device *dev = platform_get_drvdata(pdev);
878 if (netif_running(dev)) {
889 struct net_device *dev = platform_get_drvdata(pdev);
891 if (netif_running(dev)) {
902 #define ne_drv_suspend NULL
903 #define ne_drv_resume NULL
907 .remove = ne_drv_remove,
916 static void __init ne_add_devices(
void)
921 for (this_dev = 0; this_dev <
MAX_NE_CARDS; this_dev++) {
922 if (pdev_ne[this_dev])
924 pdev = platform_device_register_simple(
928 pdev_ne[this_dev] = pdev;
941 " value(s) for ISA cards.\n");
951 static int __init ne_init(
void)
968 while ((pdev_ne[this_dev] && platform_get_drvdata(pdev_ne[this_dev])) ||
970 if (++this_dev == MAX_NE_CARDS)
975 dev = alloc_eip_netdev();
991 for (this_dev = 0; this_dev <
MAX_NE_CARDS; this_dev++) {
992 if (pdev_ne[this_dev]) {
993 dev = platform_get_drvdata(pdev_ne[this_dev]);
1003 static void __exit ne_exit(
void)
1006 ne_loop_rm_unreg(1);