19 static const char version1[] =
20 "ne-h8300.c:v1.00 2004/04/11 ysato\n";
22 #include <linux/module.h>
23 #include <linux/kernel.h>
24 #include <linux/errno.h>
28 #include <linux/netdevice.h>
35 #define EI_SHIFT(x) (ei_local->reg_offset[x])
39 #define DRV_NAME "ne-h8300"
61 #define NE_BASE (dev->base_addr)
63 #define NE_DATAPORT (ei_status.word16?0x20:0x10)
64 #define NE_RESET (ei_status.word16?0x3f:0x1f)
65 #define NE_IO_EXTENT (ei_status.word16?0x40:0x20)
67 #define NESM_START_PG 0x40
68 #define NESM_STOP_PG 0x80
81 const unsigned char *
buf,
const int start_page);
84 static u32 reg_offset[16];
88 struct ei_device *ei_local = netdev_priv(dev);
92 bus_width = *(
volatile unsigned char *)ABWCR;
93 bus_width &= 1 << ((base_addr >> 21) & 7);
106 #ifdef CONFIG_H8300H_H8MAX
107 static unsigned long __initdata h8300_ne_base[] = { 0x800600 };
108 static int h8300_ne_irq[] = {EXT_IRQ4};
110 #ifdef CONFIG_H8300H_AKI3068NET
111 static unsigned long __initdata h8300_ne_base[] = { 0x200000 };
112 static int h8300_ne_irq[] = {EXT_IRQ5};
115 static inline int init_dev(
struct net_device *dev)
117 if (h8300_ne_count <
ARRAY_SIZE(h8300_ne_base)) {
118 dev->
base_addr = h8300_ne_base[h8300_ne_count];
119 dev->
irq = h8300_ne_irq[h8300_ne_count];
152 if (base_addr > 0x1ff)
153 return ne_probe1(dev, base_addr);
154 else if (base_addr != 0)
160 static void cleanup_card(
struct net_device *dev)
181 err = init_reg_offset(dev, dev->
base_addr);
185 err = do_ne_probe(dev);
197 .ndo_stop = ne_close,
206 #ifdef CONFIG_NET_POLL_CONTROLLER
214 unsigned char SA_prom[16];
217 int start_page, stop_page;
219 static unsigned version_printed;
220 struct ei_device *ei_local = netdev_priv(dev);
226 reg0 =
inb_p(ioaddr);
248 if (
ei_debug && version_printed++ == 0)
258 struct {
unsigned char value,
offset; } program_seq[] =
279 bus_width = *(
volatile unsigned char *)ABWCR;
280 bus_width &= 1 << ((ioaddr >> 21) & 7);
282 for(i = 0; i < 16 ; i++) {
296 name = (wordlength == 2) ?
"NE2000" :
"NE1000";
299 printk(
" failed to detect IRQ line.\n");
308 printk (
" unable to get IRQ %d (errno=%d).\n", dev->
irq, ret);
318 printk(
"%s: %s found at %#x, using IRQ %d.\n",
319 dev->
name, name, ioaddr, dev->
irq);
327 #ifdef PACKETBUF_MEMSIZE
334 ei_status.block_output = &ne_block_output;
335 ei_status.get_8390_hdr = &ne_get_8390_hdr;
370 static void ne_reset_8390(
struct net_device *dev)
372 unsigned long reset_start_time =
jiffies;
373 struct ei_device *ei_local = netdev_priv(dev);
399 struct ei_device *ei_local = netdev_priv(dev);
405 "[DMAstat:%d][irqlock:%d].\n",
420 unsigned short *
p = (
unsigned short *)hdr;
439 struct ei_device *ei_local = netdev_priv(dev);
440 #ifdef NE_SANITY_CHECK
441 int xfer_count =
count;
449 "[DMAstat:%d][irqlock:%d].\n",
463 unsigned short *p = (
unsigned short *)buf;
464 for (len = count>>1; len > 0; len--)
469 #ifdef NE_SANITY_CHECK
477 #ifdef NE_SANITY_CHECK
486 int addr, tries = 20;
492 addr = (high << 8) + low;
493 if (((ring_offset + xfer_count) & 0xff) ==
low)
495 }
while (--tries > 0);
498 "%#4.4x (expected) vs. %#4.4x (actual).\n",
499 dev->
name, ring_offset + xfer_count, addr);
506 static void ne_block_output(
struct net_device *dev,
int count,
507 const unsigned char *buf,
const int start_page)
509 struct ei_device *ei_local = netdev_priv(dev);
511 #ifdef NE_SANITY_CHECK
526 "[DMAstat:%d][irqlock:%d]\n",
534 #ifdef NE_SANITY_CHECK
538 #ifdef NE8390_RW_BUGFIX
564 unsigned short *p = (
unsigned short *)buf;
565 for (len = count>>1; len > 0; len--)
573 #ifdef NE_SANITY_CHECK
580 int addr, tries = 20;
584 addr = (high << 8) + low;
585 if ((start_page << 8) + count ==
addr)
587 }
while (--tries > 0);
592 "%#4.4x (expected) vs. %#4.4x (actual).\n",
593 dev->
name, (start_page << 8) + count, addr);
614 #define MAX_NE_CARDS 1
635 int this_dev, found = 0;
638 for (this_dev = 0; this_dev <
MAX_NE_CARDS; this_dev++) {
643 dev->
irq = irq[this_dev];
647 dev->
base_addr = h8300_ne_base[this_dev];
648 dev->
irq = h8300_ne_irq[this_dev];
650 err = init_reg_offset(dev, dev->
base_addr);
652 if (do_ne_probe(dev) == 0) {
653 dev_ne[found++] =
dev;
660 if (io[this_dev] != 0)
663 printk(
KERN_NOTICE "ne.c: You must supply \"io=0xNNN\" value(s) for ISA cards.\n");
675 for (this_dev = 0; this_dev <
MAX_NE_CARDS; this_dev++) {