root/drivers/net/at1700.c

/* [previous][next][first][last][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. at1700_probe
  2. at1700_probe1
  3. read_eeprom
  4. net_open
  5. net_send_packet
  6. net_interrupt
  7. net_rx
  8. net_close
  9. net_get_stats
  10. set_multicast_list

   1 /* at1700.c: A network device driver for  the Allied Telesis AT1700.
   2 
   3         Written 1993-94 by Donald Becker.
   4 
   5         Copyright 1993 United States Government as represented by the
   6         Director, National Security Agency.
   7 
   8         This software may be used and distributed according to the terms
   9         of the GNU Public License, incorporated herein by reference.
  10 
  11         The author may be reached as becker@CESDIS.gsfc.nasa.gov, or C/O
  12         Center of Excellence in Space Data and Information Sciences
  13            Code 930.5, Goddard Space Flight Center, Greenbelt MD 20771
  14 
  15         This is a device driver for the Allied Telesis AT1700, which is a
  16         straight-forward Fujitsu MB86965 implementation.
  17 
  18   Sources:
  19     The Fujitsu MB86695 datasheet.
  20 
  21         After the initial version of this driver was written Gerry Sockins of
  22         ATI provided their EEPROM configurationcode header file.
  23     Thanks to NIIBE Yutaka <gniibe@mri.co.jp> for bug fixes.
  24 
  25   Bugs:
  26         The MB86695 has a design flaw that makes all probes unreliable.  Not
  27         only is it difficult to detect, it also moves around in I/O space in
  28         response to inb()s from other device probes!
  29 */
  30 
  31 static char *version =
  32         "at1700.c:v1.10 9/24/94  Donald Becker (becker@cesdis.gsfc.nasa.gov)\n";
  33 
  34 #include <linux/config.h>
  35 
  36 #include <linux/kernel.h>
  37 #include <linux/sched.h>
  38 #include <linux/types.h>
  39 #include <linux/fcntl.h>
  40 #include <linux/interrupt.h>
  41 #include <linux/ptrace.h>
  42 #include <linux/ioport.h>
  43 #include <linux/in.h>
  44 #include <linux/malloc.h>
  45 #include <linux/string.h>
  46 #include <asm/system.h>
  47 #include <asm/bitops.h>
  48 #include <asm/io.h>
  49 #include <asm/dma.h>
  50 #include <errno.h>
  51 
  52 #include <linux/netdevice.h>
  53 #include <linux/etherdevice.h>
  54 #include <linux/skbuff.h>
  55 extern struct device *init_etherdev(struct device *dev, int sizeof_private,
  56                                                                         unsigned long *mem_startp);
  57 
  58 /* This unusual address order is used to verify the CONFIG register. */
  59 static int at1700_probe_list[] =
  60 {0x260, 0x280, 0x2a0, 0x240, 0x340, 0x320, 0x380, 0x300, 0};
  61 
  62 /* use 0 for production, 1 for verification, >2 for debug */
  63 #ifndef NET_DEBUG
  64 #define NET_DEBUG 1
  65 #endif
  66 static unsigned int net_debug = NET_DEBUG;
  67 
  68 typedef unsigned char uchar;
  69 
  70 /* Information that need to be kept for each board. */
  71 struct net_local {
  72         struct enet_statistics stats;
  73         long open_time;                         /* Useless example local info. */
  74         uint tx_started:1;                      /* Number of packet on the Tx queue. */
  75         uchar tx_queue;                         /* Number of packet on the Tx queue. */
  76         ushort tx_queue_len;            /* Current length of the Tx queue. */
  77 };
  78 
  79 
  80 /* Offsets from the base address. */
  81 #define STATUS                  0
  82 #define TX_STATUS               0
  83 #define RX_STATUS               1
  84 #define TX_INTR                 2               /* Bit-mapped interrupt enable registers. */
  85 #define RX_INTR                 3
  86 #define TX_MODE                 4
  87 #define RX_MODE                 5
  88 #define CONFIG_0                6               /* Misc. configuration settings. */
  89 #define CONFIG_1                7
  90 /* Run-time register bank 2 definitions. */
  91 #define DATAPORT                8               /* Word-wide DMA or programmed-I/O dataport. */
  92 #define TX_START                10
  93 #define MODE13                  13
  94 #define EEPROM_Ctrl     16
  95 #define EEPROM_Data     17
  96 #define IOCONFIG                19
  97 #define RESET                   31              /* Write to reset some parts of the chip. */
  98 #define AT1700_IO_EXTENT        32
  99 
 100 /*  EEPROM_Ctrl bits. */
 101 #define EE_SHIFT_CLK    0x40    /* EEPROM shift clock, in reg. 16. */
 102 #define EE_CS                   0x20    /* EEPROM chip select, in reg. 16. */
 103 #define EE_DATA_WRITE   0x80    /* EEPROM chip data in, in reg. 17. */
 104 #define EE_DATA_READ    0x80    /* EEPROM chip data out, in reg. 17. */
 105 
 106 /* Delay between EEPROM clock transitions. */
 107 #define eeprom_delay()  do { int _i = 40; while (--_i > 0) { __SLOW_DOWN_IO; }} while (0)
 108 
 109 /* The EEPROM commands include the alway-set leading bit. */
 110 #define EE_WRITE_CMD    (5 << 6)
 111 #define EE_READ_CMD             (6 << 6)
 112 #define EE_ERASE_CMD    (7 << 6)
 113 
 114 
 115 /* Index to functions, as function prototypes. */
 116 
 117 extern int at1700_probe(struct device *dev);
 118 
 119 static int at1700_probe1(struct device *dev, short ioaddr);
 120 static int read_eeprom(int ioaddr, int location);
 121 static int net_open(struct device *dev);
 122 static int      net_send_packet(struct sk_buff *skb, struct device *dev);
 123 static void net_interrupt(int reg_ptr);
 124 static void net_rx(struct device *dev);
 125 static int net_close(struct device *dev);
 126 static struct enet_statistics *net_get_stats(struct device *dev);
 127 static void set_multicast_list(struct device *dev, int num_addrs, void *addrs);
 128 
 129 
 130 /* Check for a network adaptor of this type, and return '0' iff one exists.
 131    If dev->base_addr == 0, probe all likely locations.
 132    If dev->base_addr == 1, always return failure.
 133    If dev->base_addr == 2, allocate space for the device and return success
 134    (detachable devices only).
 135    */
 136 #ifdef HAVE_DEVLIST
 137 /* Support for a alternate probe manager, which will eliminate the
 138    boilerplate below. */
 139 struct netdev_entry at1700_drv =
 140 {"at1700", at1700_probe1, AT1700_IO_EXTENT, at1700_probe_list};
 141 #else
 142 int
 143 at1700_probe(struct device *dev)
     /* [previous][next][first][last][top][bottom][index][help] */
 144 {
 145         int i;
 146         int base_addr = dev ? dev->base_addr : 0;
 147 
 148         if (base_addr > 0x1ff)          /* Check a single specified location. */
 149                 return at1700_probe1(dev, base_addr);
 150         else if (base_addr != 0)        /* Don't probe at all. */
 151                 return ENXIO;
 152 
 153         for (i = 0; at1700_probe_list[i]; i++) {
 154                 int ioaddr = at1700_probe_list[i];
 155                 if (check_region(ioaddr, AT1700_IO_EXTENT))
 156                         continue;
 157                 if (at1700_probe1(dev, ioaddr) == 0)
 158                         return 0;
 159         }
 160 
 161         return ENODEV;
 162 }
 163 #endif
 164 
 165 /* The Fujitsu datasheet suggests that the NIC be probed for by checking its
 166    "signature", the default bit pattern after a reset.  This *doesn't* work --
 167    there is no way to reset the bus interface without a complete power-cycle!
 168 
 169    It turns out that ATI came to the same conclusion I did: the only thing
 170    that can be done is checking a few bits and then diving right into an
 171    EEPROM read. */
 172 
 173 int at1700_probe1(struct device *dev, short ioaddr)
     /* [previous][next][first][last][top][bottom][index][help] */
 174 {
 175         char irqmap[8] = {3, 4, 5, 9, 10, 11, 14, 15};
 176         unsigned int i, irq;
 177 
 178         /* Resetting the chip doesn't reset the ISA interface, so don't bother.
 179            That means we have to be careful with the register values we probe for.
 180            */
 181 #ifdef notdef
 182         printk("at1700 probe at %#x, eeprom is %4.4x %4.4x %4.4x ctrl %4.4x.\n",
 183                    ioaddr, read_eeprom(ioaddr, 4), read_eeprom(ioaddr, 5),
 184                    read_eeprom(ioaddr, 6), inw(ioaddr + EEPROM_Ctrl));
 185 #endif
 186         if (at1700_probe_list[inb(ioaddr + IOCONFIG) & 0x07] != ioaddr
 187                 || read_eeprom(ioaddr, 4) != 0x0000
 188                 || read_eeprom(ioaddr, 5) & 0xff00 != 0xF400)
 189                 return -ENODEV;
 190 
 191         /* Reset the internal state machines. */
 192         outb(0, ioaddr + RESET);
 193 
 194         irq = irqmap[(read_eeprom(ioaddr, 12)&0x04)
 195                                  | (read_eeprom(ioaddr, 0)>>14)];
 196 
 197         /* Snarf the interrupt vector now. */
 198         if (request_irq(irq, &net_interrupt, 0, "at1700")) {
 199                 printk ("AT1700 found at %#3x, but it's unusable due to a conflict on"
 200                                 "IRQ %d.\n", ioaddr, irq);
 201                 return EAGAIN;
 202         }
 203 
 204         /* Allocate a new 'dev' if needed. */
 205         if (dev == NULL)
 206                 dev = init_etherdev(0, sizeof(struct net_local), 0);
 207 
 208         /* Grab the region so that we can find another board if the IRQ request
 209            fails. */
 210         snarf_region(ioaddr, AT1700_IO_EXTENT);
 211 
 212         printk("%s: AT1700 found at %#3x, IRQ %d, address ", dev->name,
 213                    ioaddr, irq);
 214 
 215         dev->base_addr = ioaddr;
 216         dev->irq = irq;
 217         irq2dev_map[irq] = dev;
 218 
 219         for(i = 0; i < 3; i++) {
 220                 unsigned short eeprom_val = read_eeprom(ioaddr, 4+i);
 221                 printk("%04x", eeprom_val);
 222                 ((unsigned short *)dev->dev_addr)[i] = ntohs(eeprom_val);
 223         }
 224 
 225         /* The EEPROM word 12 bit 0x0400 means use regular 100 ohm 10baseT signals,
 226            rather than 150 ohm shielded twisted pair compensation.
 227            0x0000 == auto-sense the interface
 228            0x0800 == use TP interface
 229            0x1800 == use coax interface
 230            */
 231         {
 232                 char *porttype[] = {"auto-sense", "10baseT", "auto-sense", "10base2"};
 233                 ushort setup_value = read_eeprom(ioaddr, 12);
 234 
 235                 dev->if_port = setup_value >> 8;
 236                 printk(" %s interface.\n", porttype[(dev->if_port>>3) & 3]);
 237         }
 238 
 239         /* Set the station address in bank zero. */
 240         outb(0xe0, ioaddr + 7);
 241         for (i = 0; i < 6; i++)
 242                 outb(dev->dev_addr[i], ioaddr + 8 + i);
 243 
 244         /* Switch to bank 1 and set the multicast table to accept none. */
 245         outb(0xe4, ioaddr + 7);
 246         for (i = 0; i < 8; i++)
 247                 outb(0x00, ioaddr + 8 + i);
 248 
 249         /* Set the configuration register 0 to 32K 100ns. byte-wide memory, 16 bit
 250            bus access, two 4K Tx queues, and disabled Tx and Rx. */
 251         outb(0xda, ioaddr + CONFIG_0);
 252 
 253         /* Switch to bank 2 and lock our I/O address. */
 254         outb(0xe8, ioaddr + 7);
 255         outb(dev->if_port, MODE13);
 256 
 257         /* Power-down the chip.  Aren't we green! */
 258         outb(0x00, ioaddr + CONFIG_1);
 259 
 260         if (net_debug)
 261                 printk(version);
 262 
 263         /* Initialize the device structure. */
 264         if (dev->priv == NULL)
 265                 dev->priv = kmalloc(sizeof(struct net_local), GFP_KERNEL);
 266         memset(dev->priv, 0, sizeof(struct net_local));
 267 
 268         dev->open               = net_open;
 269         dev->stop               = net_close;
 270         dev->hard_start_xmit = net_send_packet;
 271         dev->get_stats  = net_get_stats;
 272         dev->set_multicast_list = &set_multicast_list;
 273 
 274         /* Fill in the fields of 'dev' with ethernet-generic values. */
 275            
 276         ether_setup(dev);
 277         return 0;
 278 }
 279 
 280 static int read_eeprom(int ioaddr, int location)
     /* [previous][next][first][last][top][bottom][index][help] */
 281 {
 282         int i;
 283         unsigned short retval = 0;
 284         short ee_addr = ioaddr + EEPROM_Ctrl;
 285         short ee_daddr = ioaddr + EEPROM_Data;
 286         int read_cmd = location | EE_READ_CMD;
 287         short ctrl_val = EE_CS;
 288         
 289         outb(ctrl_val, ee_addr);
 290         
 291         /* Shift the read command bits out. */
 292         for (i = 9; i >= 0; i--) {
 293                 short dataval = (read_cmd & (1 << i)) ? EE_DATA_WRITE : 0;
 294                 outb(dataval, ee_daddr);
 295                 outb(EE_CS | EE_SHIFT_CLK, ee_addr);    /* EEPROM clock tick. */
 296                 eeprom_delay();
 297                 outb(EE_CS, ee_addr);   /* Finish EEPROM a clock tick. */
 298                 eeprom_delay();
 299         }
 300         outb(EE_CS, ee_addr);
 301         
 302         for (i = 16; i > 0; i--) {
 303                 outb(EE_CS | EE_SHIFT_CLK, ee_addr);
 304                 eeprom_delay();
 305                 retval = (retval << 1) | ((inb(ee_daddr) & EE_DATA_READ) ? 1 : 0);
 306                 outb(EE_CS, ee_addr);
 307                 eeprom_delay();
 308         }
 309 
 310         /* Terminate the EEPROM access. */
 311         ctrl_val &= ~EE_CS;
 312         outb(ctrl_val | EE_SHIFT_CLK, ee_addr);
 313         eeprom_delay();
 314         outb(ctrl_val, ee_addr);
 315         eeprom_delay();
 316         return retval;
 317 }
 318 
 319 
 320 
 321 static int net_open(struct device *dev)
     /* [previous][next][first][last][top][bottom][index][help] */
 322 {
 323         struct net_local *lp = (struct net_local *)dev->priv;
 324         int ioaddr = dev->base_addr;
 325         int i;
 326 
 327         /* Powerup the chip, initialize config register 1, and select bank 0. */
 328         outb(0xe0, ioaddr + CONFIG_1);
 329 
 330         /* Set the station address in bank zero. */
 331         for (i = 0; i < 6; i++)
 332                 outb(dev->dev_addr[i], ioaddr + 8 + i);
 333 
 334         /* Switch to bank 1 and set the multicast table to accept none. */
 335         outb(0xe4, ioaddr + 7);
 336         for (i = 0; i < 8; i++)
 337                 outb(0x00, ioaddr + 8 + i);
 338 
 339         /* Set the configuration register 0 to 32K 100ns. byte-wide memory, 16 bit
 340            bus access, and two 4K Tx queues. */
 341         outb(0xda, ioaddr + CONFIG_0);
 342 
 343         /* Same config 0, except enable the Rx and Tx. */
 344         outb(0x5a, ioaddr + CONFIG_0);
 345         /* Switch to register bank 2 for the run-time registers. */
 346         outb(0xe8, ioaddr + CONFIG_1);
 347 
 348         /* Turn on Rx interrupts, leave Tx interrupts off until packet Tx. */
 349         outb(0x00, ioaddr + TX_INTR);
 350         outb(0x81, ioaddr + RX_INTR);
 351 
 352         lp->open_time = jiffies;
 353 
 354         dev->tbusy = 0;
 355         dev->interrupt = 0;
 356         dev->start = 1;
 357 
 358         return 0;
 359 }
 360 
 361 static int
 362 net_send_packet(struct sk_buff *skb, struct device *dev)
     /* [previous][next][first][last][top][bottom][index][help] */
 363 {
 364         struct net_local *lp = (struct net_local *)dev->priv;
 365         int ioaddr = dev->base_addr;
 366 
 367         if (dev->tbusy) {
 368                 /* If we get here, some higher level has decided we are broken.
 369                    There should really be a "kick me" function call instead. */
 370                 int tickssofar = jiffies - dev->trans_start;
 371                 if (tickssofar < 10)
 372                         return 1;
 373                 printk("%s: transmit timed out with status %04x, %s?\n", dev->name,
 374                            inw(ioaddr + STATUS), inb(ioaddr + TX_STATUS) & 0x80
 375                            ? "IRQ conflict" : "network cable problem");
 376                 printk("%s: timeout registers: %04x %04x %04x %04x %04x %04x %04x %04x.\n",
 377                            dev->name, inw(ioaddr + 0), inw(ioaddr + 2), inw(ioaddr + 4),
 378                            inw(ioaddr + 6), inw(ioaddr + 8), inw(ioaddr + 10),
 379                            inw(ioaddr + 12), inw(ioaddr + 14));
 380                 lp->stats.tx_errors++;
 381                 /* ToDo: We should try to restart the adaptor... */
 382                 outw(0xffff, ioaddr + 24);
 383                 outw(0xffff, ioaddr + TX_STATUS);
 384                 outw(0xe85a, ioaddr + CONFIG_0);
 385                 outw(0x8100, ioaddr + TX_INTR);
 386                 dev->tbusy=0;
 387                 dev->trans_start = jiffies;
 388         }
 389 
 390         /* If some higher layer thinks we've missed an tx-done interrupt
 391            we are passed NULL. Caution: dev_tint() handles the cli()/sti()
 392            itself. */
 393         if (skb == NULL) {
 394                 dev_tint(dev);
 395                 return 0;
 396         }
 397 
 398         /* Block a timer-based transmit from overlapping.  This could better be
 399            done with atomic_swap(1, dev->tbusy), but set_bit() works as well. */
 400         if (set_bit(0, (void*)&dev->tbusy) != 0)
 401                 printk("%s: Transmitter access conflict.\n", dev->name);
 402         else {
 403                 short length = ETH_ZLEN < skb->len ? skb->len : ETH_ZLEN;
 404                 unsigned char *buf = skb->data;
 405 
 406                 /* Turn off the possible Tx interrupts. */
 407                 outb(0x00, ioaddr + TX_INTR);
 408                 
 409                 outw(length, ioaddr + DATAPORT);
 410                 outsw(ioaddr + DATAPORT, buf, (length + 1) >> 1);
 411 
 412                 lp->tx_queue++;
 413                 lp->tx_queue_len += length + 2;
 414 
 415                 if (lp->tx_started == 0) {
 416                         /* If the Tx is idle, always trigger a transmit. */
 417                         outb(0x80 | lp->tx_queue, ioaddr + TX_START);
 418                         lp->tx_queue = 0;
 419                         lp->tx_queue_len = 0;
 420                         dev->trans_start = jiffies;
 421                         lp->tx_started = 1;
 422                         dev->tbusy = 0;
 423                 } else if (lp->tx_queue_len < 4096 - 1502)
 424                         /* Yes, there is room for one more packet. */
 425                         dev->tbusy = 0;
 426 
 427                 /* Turn on Tx interrupts back on. */
 428                 outb(0x82, ioaddr + TX_INTR);
 429         }
 430         dev_kfree_skb (skb, FREE_WRITE);
 431 
 432         return 0;
 433 }
 434 
 435 /* The typical workload of the driver:
 436    Handle the network interface interrupts. */
 437 static void
 438 net_interrupt(int reg_ptr)
     /* [previous][next][first][last][top][bottom][index][help] */
 439 {
 440         int irq = -(((struct pt_regs *)reg_ptr)->orig_eax+2);
 441         struct device *dev = (struct device *)(irq2dev_map[irq]);
 442         struct net_local *lp;
 443         int ioaddr, status;
 444 
 445         if (dev == NULL) {
 446                 printk ("at1700_interrupt(): irq %d for unknown device.\n", irq);
 447                 return;
 448         }
 449         dev->interrupt = 1;
 450 
 451         ioaddr = dev->base_addr;
 452         lp = (struct net_local *)dev->priv;
 453         status = inw(ioaddr + TX_STATUS);
 454         outw(status, ioaddr + TX_STATUS);
 455 
 456         if (net_debug > 4)
 457                 printk("%s: Interrupt with status %04x.\n", dev->name, status);
 458         if (status & 0xff00
 459                 ||  (inb(ioaddr + RX_MODE) & 0x40) == 0) {                      /* Got a packet(s). */
 460                 net_rx(dev);
 461         }
 462         if (status & 0x00ff) {
 463                 if (status & 0x80) {
 464                         lp->stats.tx_packets++;
 465                         if (lp->tx_queue) {
 466                                 outb(0x80 | lp->tx_queue, ioaddr + TX_START);
 467                                 lp->tx_queue = 0;
 468                                 lp->tx_queue_len = 0;
 469                                 dev->trans_start = jiffies;
 470                                 dev->tbusy = 0;
 471                                 mark_bh(NET_BH);        /* Inform upper layers. */
 472                         } else {
 473                                 lp->tx_started = 0;
 474                                 /* Turn on Tx interrupts off. */
 475                                 outb(0x00, ioaddr + TX_INTR);
 476                                 dev->tbusy = 0;
 477                                 mark_bh(NET_BH);        /* Inform upper layers. */
 478                         }
 479                 }
 480         }
 481 
 482         dev->interrupt = 0;
 483         return;
 484 }
 485 
 486 /* We have a good packet(s), get it/them out of the buffers. */
 487 static void
 488 net_rx(struct device *dev)
     /* [previous][next][first][last][top][bottom][index][help] */
 489 {
 490         struct net_local *lp = (struct net_local *)dev->priv;
 491         int ioaddr = dev->base_addr;
 492         int boguscount = 5;
 493 
 494         while ((inb(ioaddr + RX_MODE) & 0x40) == 0) {
 495                 ushort status = inw(ioaddr + DATAPORT);
 496 
 497                 if (net_debug > 4)
 498                         printk("%s: Rxing packet mode %02x status %04x.\n",
 499                                    dev->name, inb(ioaddr + RX_MODE), status);
 500 #ifndef final_version
 501                 if (status == 0) {
 502                         outb(0x05, ioaddr + 14);
 503                         break;
 504                 }
 505 #endif
 506 
 507                 if ((status & 0xF0) != 0x20) {  /* There was an error. */
 508                         lp->stats.rx_errors++;
 509                         if (status & 0x08) lp->stats.rx_length_errors++;
 510                         if (status & 0x04) lp->stats.rx_frame_errors++;
 511                         if (status & 0x02) lp->stats.rx_crc_errors++;
 512                         if (status & 0x01) lp->stats.rx_over_errors++;
 513                 } else {
 514                         ushort pkt_len = inw(ioaddr + DATAPORT);
 515                         /* Malloc up new buffer. */
 516                         struct sk_buff *skb;
 517 
 518                         if (pkt_len > 1550) {
 519                                 printk("%s: The AT1700 claimed a very large packet, size %d.\n",
 520                                            dev->name, pkt_len);
 521                                 outb(0x05, ioaddr + 14);
 522                                 lp->stats.rx_errors++;
 523                                 break;
 524                         }
 525                         skb = alloc_skb(pkt_len+1, GFP_ATOMIC);
 526                         if (skb == NULL) {
 527                                 printk("%s: Memory squeeze, dropping packet (len %d).\n",
 528                                            dev->name, pkt_len);
 529                                 outb(0x05, ioaddr + 14);
 530                                 lp->stats.rx_dropped++;
 531                                 break;
 532                         }
 533                         skb->len = pkt_len;
 534                         skb->dev = dev;
 535 
 536                         insw(ioaddr + DATAPORT, skb->data, (pkt_len + 1) >> 1);
 537 
 538                         if (net_debug > 5) {
 539                                 int i;
 540                                 printk("%s: Rxed packet of length %d: ", dev->name, pkt_len);
 541                                 for (i = 0; i < 14; i++)
 542                                         printk(" %02x", skb->data[i]);
 543                                 printk(".\n");
 544                         }
 545 
 546                         netif_rx(skb);
 547                         lp->stats.rx_packets++;
 548                 }
 549                 if (--boguscount <= 0)
 550                         break;
 551         }
 552 
 553         /* If any worth-while packets have been received, dev_rint()
 554            has done a mark_bh(NET_BH) for us and will work on them
 555            when we get to the bottom-half routine. */
 556         {
 557                 int i;
 558                 for (i = 0; i < 20; i++) {
 559                         if ((inb(ioaddr + RX_MODE) & 0x40) == 0x40)
 560                                 break;
 561                         inw(ioaddr + DATAPORT);                         /* dummy status read */
 562                         outb(0x05, ioaddr + 14);
 563                 }
 564 
 565                 if (net_debug > 5)
 566                         printk("%s: Exint Rx packet with mode %02x after %d ticks.\n", 
 567                                    dev->name, inb(ioaddr + RX_MODE), i);
 568         }
 569         return;
 570 }
 571 
 572 /* The inverse routine to net_open(). */
 573 static int net_close(struct device *dev)
     /* [previous][next][first][last][top][bottom][index][help] */
 574 {
 575         struct net_local *lp = (struct net_local *)dev->priv;
 576         int ioaddr = dev->base_addr;
 577 
 578         lp->open_time = 0;
 579 
 580         dev->tbusy = 1;
 581         dev->start = 0;
 582 
 583         /* Set configuration register 0 to disable Tx and Rx. */
 584         outb(0xda, ioaddr + CONFIG_0);
 585 
 586         /* Update the statistics -- ToDo. */
 587 
 588         /* Power-down the chip.  Green, green, green! */
 589         outb(0x00, ioaddr + CONFIG_1);
 590 
 591         return 0;
 592 }
 593 
 594 /* Get the current statistics.  This may be called with the card open or
 595    closed. */
 596 static struct enet_statistics *
 597 net_get_stats(struct device *dev)
     /* [previous][next][first][last][top][bottom][index][help] */
 598 {
 599         struct net_local *lp = (struct net_local *)dev->priv;
 600 
 601         cli();
 602         /* ToDo: Update the statistics from the device registers. */
 603         sti();
 604 
 605         return &lp->stats;
 606 }
 607 
 608 /* Set or clear the multicast filter for this adaptor.
 609    num_addrs == -1      Promiscuous mode, receive all packets
 610    num_addrs == 0       Normal mode, clear multicast list
 611    num_addrs > 0        Multicast mode, receive normal and MC packets, and do
 612                         best-effort filtering.
 613  */
 614 static void
 615 set_multicast_list(struct device *dev, int num_addrs, void *addrs)
     /* [previous][next][first][last][top][bottom][index][help] */
 616 {
 617         short ioaddr = dev->base_addr;
 618         if (num_addrs) {
 619                 outb(3, ioaddr + RX_MODE);      /* Enable promiscuous mode */
 620         } else
 621                 outb(2, ioaddr + RX_MODE);      /* Disable promiscuous, use normal mode */
 622 }
 623 
 624 /*
 625  * Local variables:
 626  *  compile-command: "gcc -D__KERNEL__ -I/usr/src/linux/net/inet -Wall -Wstrict-prototypes -O6 -m486 -c at1700.c"
 627  *  version-control: t
 628  *  kept-new-versions: 5
 629  *  tab-width: 4
 630  *  c-indent-level: 4
 631  * End:
 632  */

/* [previous][next][first][last][top][bottom][index][help] */