60 #include <linux/module.h>
61 #include <linux/kernel.h>
62 #include <linux/errno.h>
63 #include <linux/string.h>
67 #include <linux/netdevice.h>
75 #define DRV_NAME "smc-ultra"
78 static unsigned int ultra_portlist[]
__initdata =
79 {0x200, 0x220, 0x240, 0x280, 0x300, 0x340, 0x380, 0};
94 const unsigned char *
buf,
const int start_page);
100 const unsigned char *
buf,
const int start_page);
107 (
long)
"SMC EtherEZ (8416)" },
115 #define START_PG 0x00
117 #define ULTRA_CMDREG 0
118 #define ULTRA_RESET 0x80
119 #define ULTRA_MEMENB 0x40
122 #define ULTRA_NIC_OFFSET 16
123 #define ULTRA_IO_EXTENT 32
124 #define EN0_ERWCNT 0x08
126 #ifdef CONFIG_NET_POLL_CONTROLLER
145 if (base_addr > 0x1ff)
146 return ultra_probe1(dev, base_addr);
147 else if (base_addr != 0)
156 for (i = 0; ultra_portlist[
i]; i++) {
158 if (ultra_probe1(dev, ultra_portlist[i]) == 0)
177 err = do_ultra_probe(dev);
188 .ndo_open = ultra_open,
189 .ndo_stop = ultra_close_card,
198 #ifdef CONFIG_NET_POLL_CONTROLLER
199 .ndo_poll_controller = ultra_poll,
207 const char *model_name;
208 unsigned char eeprom_irq = 0;
209 static unsigned version_printed;
212 unsigned char idreg =
inb(ioaddr + 7);
213 unsigned char reg4 =
inb(ioaddr + 4) & 0x7f;
219 if ((idreg & 0xF0) != 0x20
220 && (idreg & 0xF0) != 0x40) {
226 outb(reg4, ioaddr + 4);
228 for (i = 0; i < 8; i++)
229 checksum +=
inb(ioaddr + 8 + i);
230 if ((checksum & 0xff) != 0xFF) {
235 if (
ei_debug && version_printed++ == 0)
238 model_name = (idreg & 0xF0) == 0x20 ?
"SMC Ultra" :
"SMC EtherEZ";
240 for (i = 0; i < 6; i++)
243 printk(
"%s: %s at %#3x, %pM", dev->
name, model_name,
248 outb(0x80 | reg4, ioaddr + 4);
251 outb(0x80 |
inb(ioaddr + 0x0c), ioaddr + 0x0c);
252 piomode =
inb(ioaddr + 0x8);
253 addr =
inb(ioaddr + 0
xb);
254 irqreg =
inb(ioaddr + 0xd);
258 outb(reg4, ioaddr + 4);
261 unsigned char irqmap[] = {0, 9, 3, 5, 7, 10, 11, 15};
265 irq = irqmap[((irqreg & 0x40) >> 4) + ((irqreg & 0x0c) >> 2)];
268 printk(
", failed to detect IRQ line.\n");
280 static const int addr_tbl[4] = {
281 0x0C0000, 0x0E0000, 0xFC0000, 0xFE0000
283 static const short num_pages_tbl[4] = {
284 0x20, 0x40, 0x80, 0xff
287 dev->
mem_start = ((addr & 0x0f) << 13) + addr_tbl[(addr >> 6) & 3] ;
288 num_pages = num_pages_tbl[(addr >> 4) & 3];
299 printk(
", failed to ioremap.\n");
307 printk(
",%s IRQ %d programmed-I/O mode.\n",
308 eeprom_irq ?
"EEPROM" :
"assigned ", dev->
irq);
309 ei_status.block_input = &ultra_pio_input;
310 ei_status.block_output = &ultra_pio_output;
311 ei_status.get_8390_hdr = &ultra_pio_get_hdr;
313 printk(
",%s IRQ %d memory %#lx-%#lx.\n", eeprom_irq ?
"" :
"assigned ",
315 ei_status.block_input = &ultra_block_input;
316 ei_status.block_output = &ultra_block_output;
317 ei_status.get_8390_hdr = &ultra_get_8390_hdr;
319 ei_status.reset_8390 = &ultra_reset_8390;
338 for (i = 0; ultra_device_ids[
i].vendor != 0; i++) {
342 ultra_device_ids[i].
vendor,
343 ultra_device_ids[i].
function,
354 if (!pnp_port_valid(idev, 0) || !pnp_irq_valid(idev, 0))
357 dev->
base_addr = pnp_port_start(idev, 0);
359 printk(
KERN_INFO "smc-ultra.c: ISAPnP reports %s at i/o %#lx, irq %d.\n",
362 if (ultra_probe1(dev, dev->
base_addr) != 0) {
384 unsigned char irq2reg[] = {0, 0, 0x04, 0x08, 0, 0x0C, 0, 0x40,
385 0, 0x04, 0x44, 0x48, 0, 0, 0, 0x4C, };
392 outb(0x80, ioaddr + 5);
394 outb(
inb(ioaddr + 4) | 0x80, ioaddr + 4);
395 outb((
inb(ioaddr + 13) & ~0x4C) | irq2reg[dev->
irq], ioaddr + 13);
396 outb(
inb(ioaddr + 4) & 0x7f, ioaddr + 4);
398 if (
ei_status.block_input == &ultra_pio_input) {
399 outb(0x11, ioaddr + 6);
400 outb(0x01, ioaddr + 0x19);
402 outb(0x01, ioaddr + 6);
420 outb(0x00, cmd_port);
421 outb(0x80, cmd_port + 5);
422 if (
ei_status.block_input == &ultra_pio_input)
423 outb(0x11, cmd_port + 6);
425 outb(0x01, cmd_port + 6);
446 ((
unsigned int*)hdr)[0] =
readl(hdr_start);
462 if (ring_offset + count >
ei_status.stop_page*256) {
476 ultra_block_output(
struct net_device *dev,
int count,
const unsigned char *
buf,
506 static void ultra_pio_input(
struct net_device *dev,
int count,
507 struct sk_buff *skb,
int ring_offset)
514 outb(ring_offset >> 8, ioaddr +
IOPA);
516 insw(ioaddr +
IOPD, buf, (count+1)>>1);
519 static void ultra_pio_output(
struct net_device *dev,
int count,
520 const unsigned char *buf,
const int start_page)
534 netif_stop_queue(dev);
537 printk(
"%s: Shutting down ethercard.\n", dev->
name);
539 outb(0x00, ioaddr + 6);
552 #define MAX_ULTRA_CARDS 4
553 static struct net_device *dev_ultra[MAX_ULTRA_CARDS];
554 static int io[MAX_ULTRA_CARDS];
555 static int irq[MAX_ULTRA_CARDS];
570 int this_dev, found = 0;
572 for (this_dev = 0; this_dev < MAX_ULTRA_CARDS; this_dev++) {
573 if (io[this_dev] == 0) {
574 if (this_dev != 0)
break;
575 printk(
KERN_NOTICE "smc-ultra.c: Presently autoprobing (not recommended) for a single card.\n");
577 dev = alloc_ei_netdev();
580 dev->
irq = irq[this_dev];
582 if (do_ultra_probe(dev) == 0) {
583 dev_ultra[found++] =
dev;
587 printk(
KERN_WARNING "smc-ultra.c: No SMC Ultra card found (i/o = 0x%x).\n", io[this_dev]);
595 static void cleanup_card(
struct net_device *dev)
612 for (this_dev = 0; this_dev < MAX_ULTRA_CARDS; this_dev++) {