31 #include <linux/module.h>
32 #include <linux/kernel.h>
33 #include <linux/errno.h>
34 #include <linux/pci.h>
37 #include <linux/netdevice.h>
43 #include <asm/setup.h>
53 #define DRV_NAME "apne"
55 #define NE_BASE (dev->base_addr)
57 #define NE_DATAPORT 0x10
59 #define NE_IO_EXTENT 0x20
61 #define NE_EN0_ISR 0x07
62 #define NE_EN0_DCFG 0x0e
64 #define NE_EN0_RSARLO 0x08
65 #define NE_EN0_RSARHI 0x09
66 #define NE_EN0_RCNTLO 0x0a
67 #define NE_EN0_RXCR 0x0c
68 #define NE_EN0_TXCR 0x0d
69 #define NE_EN0_RCNTHI 0x0b
70 #define NE_EN0_IMR 0x0f
72 #define NE1SM_START_PG 0x20
73 #define NE1SM_STOP_PG 0x40
74 #define NESM_START_PG 0x40
75 #define NESM_STOP_PG 0x80
87 const unsigned char *
buf,
const int start_page);
90 static int init_pcmcia(
void);
117 static int apne_owned;
122 #ifndef MANUAL_CONFIG
136 printk(
"Looking for PCMCIA ethernet card : ");
140 printk(
"NO PCMCIA card inserted\n");
144 dev = alloc_ei_netdev();
153 pcmcia_disable_irq();
155 #ifndef MANUAL_CONFIG
158 printk(
"not an ethernet card\n");
165 printk(
"ethernet PCMCIA card inserted\n");
167 if (!init_pcmcia()) {
175 return ERR_PTR(-
EBUSY);
178 err = apne_probe1(dev,
IOBASE);
188 pcmcia_disable_irq();
199 unsigned char SA_prom[32];
202 int start_page, stop_page;
203 #ifndef MANUAL_HWADDR0
206 static unsigned version_printed;
208 if (
ei_debug && version_printed++ == 0)
211 printk(
"PCMCIA NE*000 ethercard probe");
214 {
unsigned long reset_start_time =
jiffies;
220 printk(
" not found (no reset ack).\n");
227 #ifndef MANUAL_HWADDR0
234 struct {
unsigned long value,
offset; } program_seq[] = {
249 for (i = 0; i <
ARRAY_SIZE(program_seq); i++) {
254 for(i = 0; i < 32 ; i+=2) {
257 if (SA_prom[i] != SA_prom[i+1])
267 for (i = 0; i < 16; i++)
268 SA_prom[i] = SA_prom[i+i];
270 if (wordlength == 2) {
280 neX000 = (SA_prom[14] == 0x57 && SA_prom[15] == 0x57);
281 ctron = (SA_prom[0] == 0x00 && SA_prom[1] == 0x00 && SA_prom[2] == 0x1d);
285 name = (wordlength == 2) ?
"NE2000" :
"NE1000";
287 name = (wordlength == 2) ?
"Ctron-8" :
"Ctron-16";
289 stop_page = (wordlength == 2) ? 0x40 : 0x20;
303 SA_prom[0] = MANUAL_HWADDR0;
304 SA_prom[1] = MANUAL_HWADDR1;
305 SA_prom[2] = MANUAL_HWADDR2;
306 SA_prom[3] = MANUAL_HWADDR3;
307 SA_prom[4] = MANUAL_HWADDR4;
308 SA_prom[5] = MANUAL_HWADDR5;
335 ei_status.block_input = &apne_block_input;
336 ei_status.block_output = &apne_block_output;
337 ei_status.get_8390_hdr = &apne_get_8390_hdr;
341 pcmcia_ack_int(pcmcia_get_intreq());
354 unsigned long reset_start_time =
jiffies;
368 printk(
"%s: ne_reset_8390() did not complete.\n", dev->
name);
389 printk(
"%s: DMAing conflict in ne_get_8390_hdr "
390 "[DMAstat:%d][irqlock:%d][intr:%d].\n",
406 for(cnt = 0; cnt < (sizeof(struct e8390_pkt_hdr)>>1); cnt++)
436 printk(
"%s: DMAing conflict in ne_block_input "
437 "[DMAstat:%d][irqlock:%d][intr:%d].\n",
451 for (cnt = 0; cnt < (count>>1); cnt++)
458 for (cnt = 0; cnt <
count; cnt++)
467 apne_block_output(
struct net_device *dev,
int count,
468 const unsigned char *buf,
const int start_page)
484 printk(
"%s: DMAing conflict in ne_block_output."
485 "[DMAstat:%d][irqlock:%d][intr:%d]\n",
504 for (cnt = 0; cnt < count>>1; cnt++)
508 for (cnt = 0; cnt <
count; cnt++)
516 printk(
"%s: timeout waiting for Tx RDC.\n", dev->
name);
517 apne_reset_8390(dev);
528 unsigned char pcmcia_intreq;
533 pcmcia_intreq = pcmcia_get_intreq();
536 pcmcia_ack_int(pcmcia_intreq);
540 printk(
"pcmcia intreq = %x\n", pcmcia_intreq);
541 pcmcia_disable_irq();
543 pcmcia_ack_int(pcmcia_get_intreq());
551 static int __init apne_module_init(
void)
554 if (IS_ERR(apne_dev))
555 return PTR_ERR(apne_dev);
559 static void __exit apne_module_exit(
void)
563 pcmcia_disable_irq();
577 static int init_pcmcia(
void)
580 #ifndef MANUAL_CONFIG
592 config = MANUAL_CONFIG;
599 config = tuple[2] & 0x3f;
602 offset = MANUAL_OFFSET;
607 offset_len = (tuple[2] & 0x3) + 1;
609 while(offset_len--) {
610 offset = (offset << 8) | tuple[4+offset_len];