This source file includes following definitions.
- de620_ready
 
- de620_send_command
 
- de620_put_byte
 
- de620_read_byte
 
- de620_write_block
 
- de620_read_block
 
- de620_set_delay
 
- de620_set_register
 
- de620_get_register
 
- de620_open
 
- de620_close
 
- get_stats
 
- de620_set_multicast_list
 
- de620_start_xmit
 
- de620_interrupt
 
- de620_rx_intr
 
- adapter_init
 
- de620_probe
 
- ReadAWord
 
- read_eeprom
 
- init_module
 
- cleanup_module
 
   1 
   2 
   3 
   4 
   5 
   6 
   7 
   8 
   9 
  10 
  11 
  12 
  13 
  14 
  15 
  16 
  17 
  18 
  19 
  20 
  21 
  22 
  23 
  24 
  25 
  26 
  27 
  28 
  29 
  30 
  31 
  32 
  33 
  34 
  35 
  36 
  37 
  38 
  39 
  40 
  41 static const char *version =
  42         "de620.c: $Revision: 1.40 $,  Bjorn Ekwall <bj0rn@blox.se>\n";
  43 
  44 
  45 
  46 
  47 
  48 
  49 
  50 
  51 
  52 
  53 
  54 
  55 
  56 
  57 
  58 
  59 
  60 
  61 
  62 
  63 
  64 
  65 
  66 
  67 
  68 
  69 
  70 
  71 
  72 
  73 #define DE620_CLONE 0
  74 
  75 
  76 
  77 
  78 
  79 
  80 
  81 
  82 
  83 
  84 #ifndef READ_DELAY
  85 #define READ_DELAY 100  
  86 #endif
  87 
  88 #ifndef WRITE_DELAY
  89 #define WRITE_DELAY 100 
  90 #endif
  91 
  92 
  93 
  94 
  95 
  96 
  97 
  98 
  99 
 100 
 101 
 102 
 103 
 104 
 105 
 106 
 107 
 108 
 109 
 110 
 111 #ifdef LOWSPEED
 112 
 113 
 114 
 115 
 116 
 117 
 118 #endif
 119 
 120 #include <linux/module.h>
 121 
 122 #include <linux/kernel.h>
 123 #include <linux/sched.h>
 124 #include <linux/types.h>
 125 #include <linux/fcntl.h>
 126 #include <linux/string.h>
 127 #include <linux/interrupt.h>
 128 #include <linux/ioport.h>
 129 #include <asm/io.h>
 130 #include <linux/in.h>
 131 #include <linux/ptrace.h>
 132 #include <asm/system.h>
 133 #include <linux/errno.h>
 134 
 135 #include <linux/inet.h>
 136 #include <linux/netdevice.h>
 137 #include <linux/etherdevice.h>
 138 #include <linux/skbuff.h>
 139 
 140 
 141 #include "de620.h"
 142 
 143 #define netstats enet_statistics
 144 typedef unsigned char byte;
 145 
 146 
 147 
 148 
 149 
 150 
 151 
 152 #ifndef DE620_IO 
 153 #define DE620_IO 0x378
 154 #endif
 155 
 156 #ifndef DE620_IRQ 
 157 #define DE620_IRQ       7
 158 #endif
 159 
 160 #define DATA_PORT       (dev->base_addr)
 161 #define STATUS_PORT     (dev->base_addr + 1)
 162 #define COMMAND_PORT    (dev->base_addr + 2)
 163 
 164 #define RUNT 60         
 165 #define GIANT 1514      
 166 
 167 #ifdef DE620_DEBUG 
 168 #define PRINTK(x) if (de620_debug >= 2) printk x
 169 #else
 170 #define DE620_DEBUG 0
 171 #define PRINTK(x) 
 172 #endif
 173 
 174 
 175 
 176 
 177 
 178 
 179 
 180 
 181 
 182 
 183 
 184 
 185 
 186 
 187 static int bnc = 0;
 188 static int utp = 0;
 189 static int io  = DE620_IO;
 190 static int irq = DE620_IRQ;
 191 static int clone = DE620_CLONE;
 192 
 193 static unsigned int de620_debug = DE620_DEBUG;
 194 
 195 
 196 
 197 
 198 
 199 
 200 
 201 
 202 
 203 
 204 
 205 
 206 static int      de620_open(struct device *);
 207 static int      de620_close(struct device *);
 208 static struct netstats *get_stats(struct device *);
 209 static void     de620_set_multicast_list(struct device *);
 210 static int      de620_start_xmit(struct sk_buff *, struct device *);
 211 
 212 
 213 static void     de620_interrupt(int, void *, struct pt_regs *);
 214 static int      de620_rx_intr(struct device *);
 215 
 216 
 217 static int      adapter_init(struct device *);
 218 int             de620_probe(struct device *);
 219 static int      read_eeprom(struct device *);
 220 
 221 
 222 
 223 
 224 
 225 #define SCR_DEF NIBBLEMODE |INTON | SLEEP | AUTOTX
 226 #define TCR_DEF RXPB                    
 227 #define DE620_RX_START_PAGE 12          
 228 #define DEF_NIC_CMD IRQEN | ICEN | DS1
 229 
 230 static volatile byte    NIC_Cmd;
 231 static volatile byte    next_rx_page;
 232 static byte             first_rx_page;
 233 static byte             last_rx_page;
 234 static byte             EIPRegister;
 235 
 236 static struct nic {
 237         byte    NodeID[6];
 238         byte    RAM_Size;
 239         byte    Model;
 240         byte    Media;
 241         byte    SCR;
 242 } nic_data;
 243 
 244 
 245 
 246 
 247 
 248 
 249 #define de620_tx_buffs(dd) (inb(STATUS_PORT) & (TXBF0 | TXBF1))
 250 #define de620_flip_ds(dd) NIC_Cmd ^= DS0 | DS1; outb(NIC_Cmd, COMMAND_PORT);
 251 
 252 
 253 #ifdef COUNT_LOOPS
 254 static int tot_cnt;
 255 #endif
 256 static inline byte
 257 de620_ready(struct device *dev)
     
 258 {
 259         byte value;
 260         register short int cnt = 0;
 261 
 262         while ((((value = inb(STATUS_PORT)) & READY) == 0) && (cnt <= 1000))
 263                 ++cnt;
 264 
 265 #ifdef COUNT_LOOPS
 266         tot_cnt += cnt;
 267 #endif
 268         return value & 0xf0; 
 269 }
 270 
 271 static inline void
 272 de620_send_command(struct device *dev, byte cmd)
     
 273 {
 274         de620_ready(dev);
 275         if (cmd == W_DUMMY)
 276                 outb(NIC_Cmd, COMMAND_PORT);
 277 
 278         outb(cmd, DATA_PORT);
 279 
 280         outb(NIC_Cmd ^ CS0, COMMAND_PORT);
 281         de620_ready(dev);
 282         outb(NIC_Cmd, COMMAND_PORT);
 283 }
 284 
 285 static inline void
 286 de620_put_byte(struct device *dev, byte value)
     
 287 {
 288         
 289         de620_ready(dev);
 290         outb(value, DATA_PORT);
 291         de620_flip_ds(dev);
 292 }
 293 
 294 static inline byte
 295 de620_read_byte(struct device *dev)
     
 296 {
 297         byte value;
 298 
 299         
 300         value = de620_ready(dev); 
 301         de620_flip_ds(dev);
 302         value |= de620_ready(dev) >> 4; 
 303         return value;
 304 }
 305 
 306 static inline void
 307 de620_write_block(struct device *dev, byte *buffer, int count)
     
 308 {
 309 #ifndef LOWSPEED
 310         byte uflip = NIC_Cmd ^ (DS0 | DS1);
 311         byte dflip = NIC_Cmd;
 312 #else 
 313 #ifdef COUNT_LOOPS
 314         int bytes = count;
 315 #endif 
 316 #endif 
 317 
 318 #ifdef LOWSPEED
 319 #ifdef COUNT_LOOPS
 320         tot_cnt = 0;
 321 #endif 
 322         
 323         for ( ; count > 0; --count, ++buffer) {
 324                 de620_put_byte(dev,*buffer);
 325         }
 326         de620_send_command(dev,W_DUMMY);
 327 #ifdef COUNT_LOOPS
 328         
 329         printk("WRITE(%d)\n", tot_cnt/((bytes?bytes:1)));
 330 #endif 
 331 #else 
 332         for ( ; count > 0; count -=2) {
 333                 outb(*buffer++, DATA_PORT);
 334                 outb(uflip, COMMAND_PORT);
 335                 outb(*buffer++, DATA_PORT);
 336                 outb(dflip, COMMAND_PORT);
 337         }
 338         de620_send_command(dev,W_DUMMY);
 339 #endif 
 340 }
 341 
 342 static inline void
 343 de620_read_block(struct device *dev, byte *data, int count)
     
 344 {
 345 #ifndef LOWSPEED
 346         byte value;
 347         byte uflip = NIC_Cmd ^ (DS0 | DS1);
 348         byte dflip = NIC_Cmd;
 349 #else 
 350 #ifdef COUNT_LOOPS
 351         int bytes = count;
 352 
 353         tot_cnt = 0;
 354 #endif 
 355 #endif 
 356 
 357 #ifdef LOWSPEED
 358         
 359         while (count-- > 0) {
 360                 *data++ = de620_read_byte(dev);
 361                 de620_flip_ds(dev);
 362         }
 363 #ifdef COUNT_LOOPS
 364         
 365         printk("READ(%d)\n", tot_cnt/(2*(bytes?bytes:1)));
 366 #endif 
 367 #else 
 368         while (count-- > 0) {
 369                 value = inb(STATUS_PORT) & 0xf0; 
 370                 outb(uflip, COMMAND_PORT);
 371                 *data++ = value | inb(STATUS_PORT) >> 4; 
 372                 outb(dflip , COMMAND_PORT);
 373         }
 374 #endif 
 375 }
 376 
 377 static inline void
 378 de620_set_delay(struct device *dev)
     
 379 {
 380         de620_ready(dev);
 381         outb(W_DFR, DATA_PORT);
 382         outb(NIC_Cmd ^ CS0, COMMAND_PORT);
 383 
 384         de620_ready(dev);
 385 #ifdef LOWSPEED
 386         outb(WRITE_DELAY, DATA_PORT);
 387 #else
 388         outb(0, DATA_PORT);
 389 #endif
 390         de620_flip_ds(dev);
 391 
 392         de620_ready(dev);
 393 #ifdef LOWSPEED
 394         outb(READ_DELAY, DATA_PORT);
 395 #else
 396         outb(0, DATA_PORT);
 397 #endif
 398         de620_flip_ds(dev);
 399 }
 400 
 401 static inline void
 402 de620_set_register(struct device *dev, byte reg, byte value)
     
 403 {
 404         de620_ready(dev);
 405         outb(reg, DATA_PORT);
 406         outb(NIC_Cmd ^ CS0, COMMAND_PORT);
 407 
 408         de620_put_byte(dev, value);
 409 }
 410 
 411 static inline byte
 412 de620_get_register(struct device *dev, byte reg)
     
 413 {
 414         byte value;
 415 
 416         de620_send_command(dev,reg);
 417         value = de620_read_byte(dev);
 418         de620_send_command(dev,W_DUMMY);
 419 
 420         return value;
 421 }
 422 
 423 
 424 
 425 
 426 
 427 
 428 
 429 
 430 
 431 
 432 static int
 433 de620_open(struct device *dev)
     
 434 {
 435         if (request_irq(dev->irq, de620_interrupt, 0, "de620", NULL)) {
 436                 printk ("%s: unable to get IRQ %d\n", dev->name, dev->irq);
 437                 return 1;
 438         }
 439         irq2dev_map[dev->irq] = dev;
 440 
 441         MOD_INC_USE_COUNT;
 442         if (adapter_init(dev)) {
 443                 return 1;
 444         }
 445         dev->start = 1;
 446         return 0;
 447 }
 448 
 449 
 450 
 451 
 452 
 453 
 454 static int
 455 de620_close(struct device *dev)
     
 456 {
 457         
 458         de620_set_register(dev, W_TCR, RXOFF);
 459 
 460         free_irq(dev->irq, NULL);
 461         irq2dev_map[dev->irq] = NULL;
 462 
 463         dev->start = 0;
 464         MOD_DEC_USE_COUNT;
 465         return 0;
 466 }
 467 
 468 
 469 
 470 
 471 
 472 
 473 static struct netstats *
 474 get_stats(struct device *dev)
     
 475 {
 476         return (struct netstats *)(dev->priv);
 477 }
 478 
 479 
 480 
 481 
 482 
 483 
 484 
 485 
 486 static void de620_set_multicast_list(struct device *dev)
     
 487 {
 488         if (dev->mc_count || dev->flags&(IFF_ALLMULTI|IFF_PROMISC)) 
 489         { 
 490                 
 491 
 492 
 493 
 494 
 495                 dev->flags|=IFF_PROMISC;                
 496         
 497                 de620_set_register(dev, W_TCR, (TCR_DEF & ~RXPBM) | RXALL);
 498         }
 499         else 
 500         { 
 501                 de620_set_register(dev, W_TCR, TCR_DEF);
 502         }
 503 }
 504 
 505 
 506 
 507 
 508 
 509 
 510 static int
 511 de620_start_xmit(struct sk_buff *skb, struct device *dev)
     
 512 {
 513         unsigned long flags;
 514         int len;
 515         int tickssofar;
 516         byte *buffer = skb->data;
 517         byte using_txbuf;
 518 
 519         
 520 
 521 
 522 
 523 
 524 
 525         if (skb == NULL) {
 526                 dev_tint(dev);
 527                 return 0;
 528         }
 529 
 530         using_txbuf = de620_tx_buffs(dev); 
 531         dev->tbusy = (using_txbuf == (TXBF0 | TXBF1)); 
 532 
 533         if (dev->tbusy) {       
 534                 tickssofar = jiffies - dev->trans_start;
 535 
 536                 if (tickssofar < 5)
 537                         return 1;
 538 
 539                 
 540                 printk("%s: transmit timed out (%d), %s?\n",
 541                         dev->name,
 542                         tickssofar,
 543                         "network cable problem"
 544                         );
 545                 
 546                 if (adapter_init(dev)) 
 547                         return 1;
 548         }
 549 
 550         if ((len = skb->len) < RUNT)
 551                 len = RUNT;
 552         if (len & 1) 
 553                 ++len;
 554 
 555         
 556         save_flags(flags);
 557         cli();
 558 
 559         PRINTK(("de620_start_xmit: len=%d, bufs 0x%02x\n",
 560                 (int)skb->len, using_txbuf));
 561 
 562         
 563         switch (using_txbuf) {
 564         default: 
 565         case TXBF1: 
 566                 de620_send_command(dev,W_CR | RW0);
 567                 using_txbuf |= TXBF0;
 568                 break;
 569 
 570         case TXBF0: 
 571                 de620_send_command(dev,W_CR | RW1);
 572                 using_txbuf |= TXBF1;
 573                 break;
 574 
 575         case (TXBF0 | TXBF1): 
 576                 printk("de620: Ouch! No tx-buffer available!\n");
 577                 restore_flags(flags);
 578                 return 1;
 579                 break;
 580         }
 581         de620_write_block(dev, buffer, len);
 582 
 583         dev->trans_start = jiffies;
 584         dev->tbusy = (using_txbuf == (TXBF0 | TXBF1)); 
 585 
 586         ((struct netstats *)(dev->priv))->tx_packets++;
 587         
 588         restore_flags(flags); 
 589         
 590         dev_kfree_skb (skb, FREE_WRITE);
 591 
 592         return 0;
 593 }
 594 
 595 
 596 
 597 
 598 
 599 
 600 static void
 601 de620_interrupt(int irq_in, void *dev_id, struct pt_regs *regs)
     
 602 {
 603         struct device *dev = irq2dev_map[irq_in];
 604         byte irq_status;
 605         int bogus_count = 0;
 606         int again = 0;
 607 
 608         
 609         if ((dev == NULL) || (irq != irq_in)) {
 610                 printk("%s: bogus interrupt %d\n", dev?dev->name:"de620", irq_in);
 611                 return;
 612         }
 613 
 614         cli();
 615         dev->interrupt = 1;
 616 
 617         
 618         irq_status = de620_get_register(dev, R_STS);
 619 
 620         PRINTK(("de620_interrupt (%2.2X)\n", irq_status));
 621 
 622         if (irq_status & RXGOOD) {
 623                 do {
 624                         again = de620_rx_intr(dev);
 625                         PRINTK(("again=%d\n", again));
 626                 }
 627                 while (again && (++bogus_count < 100));
 628         }
 629 
 630         dev->tbusy = (de620_tx_buffs(dev) == (TXBF0 | TXBF1)); 
 631 
 632         dev->interrupt = 0;
 633         sti();
 634         return;
 635 }
 636 
 637 
 638 
 639 
 640 
 641 
 642 
 643 
 644 static int
 645 de620_rx_intr(struct device *dev)
     
 646 {
 647         struct header_buf {
 648                 byte            status;
 649                 byte            Rx_NextPage;
 650                 unsigned short  Rx_ByteCount;
 651         } header_buf;
 652         struct sk_buff *skb;
 653         int size;
 654         byte *buffer;
 655         byte pagelink;
 656         byte curr_page;
 657 
 658         PRINTK(("de620_rx_intr: next_rx_page = %d\n", next_rx_page));
 659 
 660         
 661         de620_send_command(dev, W_CR | RRN);
 662         de620_set_register(dev, W_RSA1, next_rx_page);
 663         de620_set_register(dev, W_RSA0, 0);
 664 
 665         
 666         de620_read_block(dev, (byte *)&header_buf, sizeof(struct header_buf));
 667         PRINTK(("page status=0x%02x, nextpage=%d, packetsize=%d\n",
 668         header_buf.status, header_buf.Rx_NextPage, header_buf.Rx_ByteCount));
 669 
 670         
 671         pagelink = header_buf.Rx_NextPage;
 672         if ((pagelink < first_rx_page) || (last_rx_page < pagelink)) {
 673                 
 674                 printk("%s: Ring overrun? Restoring...\n", dev->name);
 675                 
 676                 adapter_init(dev);
 677                 ((struct netstats *)(dev->priv))->rx_over_errors++;
 678                 return 0;
 679         }
 680 
 681         
 682         
 683         pagelink = next_rx_page +
 684                 ((header_buf.Rx_ByteCount + (4 - 1 + 0x100)) >> 8);
 685 
 686         
 687         if (pagelink > last_rx_page)
 688                 pagelink -= (last_rx_page - first_rx_page + 1);
 689 
 690         
 691         if (pagelink != header_buf.Rx_NextPage) {
 692                 
 693                 printk("%s: Page link out of sync! Restoring...\n", dev->name);
 694                 next_rx_page = header_buf.Rx_NextPage; 
 695                 de620_send_command(dev, W_DUMMY);
 696                 de620_set_register(dev, W_NPRF, next_rx_page);
 697                 ((struct netstats *)(dev->priv))->rx_over_errors++;
 698                 return 0;
 699         }
 700         next_rx_page = pagelink;
 701 
 702         size = header_buf.Rx_ByteCount - 4;
 703         if ((size < RUNT) || (GIANT < size)) {
 704                 printk("%s: Illegal packet size: %d!\n", dev->name, size);
 705         }
 706         else { 
 707                 skb = dev_alloc_skb(size+2);
 708                 if (skb == NULL) { 
 709                         printk("%s: Couldn't allocate a sk_buff of size %d.\n",
 710                                 dev->name, size);
 711                         ((struct netstats *)(dev->priv))->rx_dropped++;
 712                 }
 713                 else { 
 714                         skb_reserve(skb,2);     
 715                         skb->dev = dev;
 716                         skb->free = 1;
 717                         
 718                         buffer = skb_put(skb,size);
 719                         
 720                         de620_read_block(dev, buffer, size);
 721                         PRINTK(("Read %d bytes\n", size));
 722                         skb->protocol=eth_type_trans(skb,dev);
 723                         netif_rx(skb); 
 724                         
 725                         ((struct netstats *)(dev->priv))->rx_packets++;
 726                 }
 727         }
 728 
 729         
 730         
 731         curr_page = de620_get_register(dev, R_CPR);
 732         de620_set_register(dev, W_NPRF, next_rx_page);
 733         PRINTK(("next_rx_page=%d CPR=%d\n", next_rx_page, curr_page));
 734 
 735         return (next_rx_page != curr_page); 
 736 }
 737 
 738 
 739 
 740 
 741 
 742 
 743 static int
 744 adapter_init(struct device *dev)
     
 745 {
 746         int i;
 747         static int was_down = 0;
 748 
 749         if ((nic_data.Model == 3) || (nic_data.Model == 0)) { 
 750                 EIPRegister = NCTL0;
 751                 if (nic_data.Media != 1)
 752                         EIPRegister |= NIS0;    
 753         }
 754         else if (nic_data.Model == 2) { 
 755                 EIPRegister = NCTL0 | NIS0;
 756         }
 757 
 758         if (utp)
 759                 EIPRegister = NCTL0 | NIS0;
 760         if (bnc)
 761                 EIPRegister = NCTL0;
 762 
 763         de620_send_command(dev, W_CR | RNOP | CLEAR);
 764         de620_send_command(dev, W_CR | RNOP);
 765 
 766         de620_set_register(dev, W_SCR, SCR_DEF);
 767         
 768         de620_set_register(dev, W_TCR, RXOFF);
 769 
 770         
 771         for (i = 0; i < 6; ++i) { 
 772                 de620_set_register(dev, W_PAR0 + i, dev->dev_addr[i]);
 773         }
 774 
 775         de620_set_register(dev, W_EIP, EIPRegister);
 776 
 777         next_rx_page = first_rx_page = DE620_RX_START_PAGE;
 778         if (nic_data.RAM_Size)
 779                 last_rx_page = nic_data.RAM_Size - 1;
 780         else 
 781                 last_rx_page = 255;
 782 
 783         de620_set_register(dev, W_SPR, first_rx_page); 
 784         de620_set_register(dev, W_EPR, last_rx_page);  
 785         de620_set_register(dev, W_CPR, first_rx_page);
 786         de620_send_command(dev, W_NPR | first_rx_page); 
 787         de620_send_command(dev, W_DUMMY);
 788         de620_set_delay(dev);
 789 
 790         
 791         
 792 #define CHECK_MASK (  0 | TXSUC |  T16  |  0  | RXCRC | RXSHORT |  0  |  0  )
 793 #define CHECK_OK   (  0 |   0   |  0    |  0  |   0   |   0     |  0  |  0  )
 794         
 795         
 796 
 797         if (((i = de620_get_register(dev, R_STS)) & CHECK_MASK) != CHECK_OK) {
 798                 printk("Something has happened to the DE-620!  Please check it"
 799 #ifdef SHUTDOWN_WHEN_LOST
 800                         " and do a new ifconfig"
 801 #endif
 802                         "! (%02x)\n", i);
 803 #ifdef SHUTDOWN_WHEN_LOST
 804                 
 805                 dev->flags &= ~IFF_UP;
 806                 de620_close(dev);
 807 #endif
 808                 was_down = 1;
 809                 return 1; 
 810         }
 811         if (was_down) {
 812                 printk("Thanks, I feel much better now!\n");
 813                 was_down = 0;
 814         }
 815 
 816         
 817         de620_set_register(dev, W_TCR, TCR_DEF);
 818 
 819         return 0; 
 820 }
 821 
 822 
 823 
 824 
 825 
 826 
 827 
 828 
 829 
 830 
 831 int
 832 de620_probe(struct device *dev)
     
 833 {
 834         static struct netstats de620_netstats;
 835         int i;
 836         byte checkbyte = 0xa5;
 837 
 838         
 839 
 840 
 841 
 842         dev->base_addr = io;
 843         dev->irq       = irq;
 844 
 845         if (de620_debug)
 846                 printk(version);
 847 
 848         printk("D-Link DE-620 pocket adapter");
 849 
 850         
 851         NIC_Cmd = DEF_NIC_CMD;
 852         de620_set_register(dev, W_EIP, EIPRegister);
 853 
 854         
 855         de620_set_register(dev, W_CPR, checkbyte);
 856         checkbyte = de620_get_register(dev, R_CPR);
 857 
 858         if ((checkbyte != 0xa5) || (read_eeprom(dev) != 0)) {
 859                 printk(" not identified in the printer port\n");
 860                 return ENODEV;
 861         }
 862 
 863 #if 0 
 864         if (check_region(dev->base_addr, 3)) {
 865                 printk(", port 0x%x busy\n", dev->base_addr);
 866                 return EBUSY;
 867         }
 868 #endif
 869         request_region(dev->base_addr, 3, "de620");
 870 
 871         
 872         printk(", Ethernet Address: %2.2X",
 873                 dev->dev_addr[0] = nic_data.NodeID[0]);
 874         for (i = 1; i < ETH_ALEN; i++) {
 875                 printk(":%2.2X", dev->dev_addr[i] = nic_data.NodeID[i]);
 876                 dev->broadcast[i] = 0xff;
 877         }
 878 
 879         printk(" (%dk RAM,",
 880                 (nic_data.RAM_Size) ? (nic_data.RAM_Size >> 2) : 64);
 881 
 882         if (nic_data.Media == 1)
 883                 printk(" BNC)\n");
 884         else
 885                 printk(" UTP)\n");
 886 
 887         
 888         
 889         dev->priv = &de620_netstats;
 890 
 891         memset(dev->priv, 0, sizeof(struct netstats));
 892         dev->get_stats = get_stats;
 893         dev->open = de620_open;
 894         dev->stop = de620_close;
 895         dev->hard_start_xmit = &de620_start_xmit;
 896         dev->set_multicast_list = &de620_set_multicast_list;
 897         
 898 
 899         ether_setup(dev);
 900         
 901         
 902         if (de620_debug) {
 903                 printk("\nEEPROM contents:\n");
 904                 printk("RAM_Size = 0x%02X\n", nic_data.RAM_Size);
 905                 printk("NodeID = %02X:%02X:%02X:%02X:%02X:%02X\n",
 906                         nic_data.NodeID[0], nic_data.NodeID[1],
 907                         nic_data.NodeID[2], nic_data.NodeID[3],
 908                         nic_data.NodeID[4], nic_data.NodeID[5]);
 909                 printk("Model = %d\n", nic_data.Model);
 910                 printk("Media = %d\n", nic_data.Media);
 911                 printk("SCR = 0x%02x\n", nic_data.SCR);
 912         }
 913 
 914         return 0;
 915 }
 916 
 917 
 918 
 919 
 920 
 921 
 922 
 923 #define sendit(dev,data) de620_set_register(dev, W_EIP, data | EIPRegister);
 924 
 925 static unsigned short
 926 ReadAWord(struct device *dev, int from)
     
 927 {
 928         unsigned short data;
 929         int nbits;
 930 
 931         
 932         
 933         
 934         sendit(dev, 0); sendit(dev, 1); sendit(dev, 5); sendit(dev, 4);
 935 
 936         
 937         for (nbits = 9; nbits > 0; --nbits, from <<= 1) {
 938                 if (from & 0x0100) { 
 939                         
 940                         
 941                         
 942                         sendit(dev, 6); sendit(dev, 7); sendit(dev, 7); sendit(dev, 6);
 943                 }
 944                 else {
 945                         
 946                         
 947                         
 948                         sendit(dev, 4); sendit(dev, 5); sendit(dev, 5); sendit(dev, 4);
 949                 }
 950         }
 951 
 952         
 953         for (data = 0, nbits = 16; nbits > 0; --nbits) {
 954                 
 955                 
 956                 
 957                 sendit(dev, 4); sendit(dev, 5); sendit(dev, 5); sendit(dev, 4);
 958                 data = (data << 1) | ((de620_get_register(dev, R_STS) & EEDI) >> 7);
 959         }
 960         
 961         
 962         
 963         sendit(dev, 0); sendit(dev, 1); sendit(dev, 1); sendit(dev, 0);
 964 
 965         return data;
 966 }
 967 
 968 static int
 969 read_eeprom(struct device *dev)
     
 970 {
 971         unsigned short wrd;
 972 
 973         
 974         wrd = ReadAWord(dev, 0x1aa);    
 975         if (!clone && (wrd != htons(0x0080))) 
 976                 return -1; 
 977         nic_data.NodeID[0] = wrd & 0xff;
 978         nic_data.NodeID[1] = wrd >> 8;
 979 
 980         wrd = ReadAWord(dev, 0x1ab);    
 981         if (!clone && ((wrd & 0xff) != 0xc8)) 
 982                 return -1; 
 983         nic_data.NodeID[2] = wrd & 0xff;
 984         nic_data.NodeID[3] = wrd >> 8;
 985 
 986         wrd = ReadAWord(dev, 0x1ac);    
 987         nic_data.NodeID[4] = wrd & 0xff;
 988         nic_data.NodeID[5] = wrd >> 8;
 989 
 990         wrd = ReadAWord(dev, 0x1ad);    
 991         nic_data.RAM_Size = (wrd >> 8);
 992 
 993         wrd = ReadAWord(dev, 0x1ae);    
 994         nic_data.Model = (wrd & 0xff);
 995 
 996         wrd = ReadAWord(dev, 0x1af); 
 997         nic_data.Media = (wrd & 0xff);
 998 
 999         wrd = ReadAWord(dev, 0x1a8); 
1000         nic_data.SCR = (wrd >> 8);
1001 
1002         return 0; 
1003 }
1004 
1005 
1006 
1007 
1008 
1009 
1010 #ifdef MODULE
1011 static char nullname[8] = "";
1012 static struct device de620_dev = {
1013         nullname, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, de620_probe };
1014 
1015 int
1016 init_module(void)
     
1017 {
1018         if (register_netdev(&de620_dev) != 0)
1019                 return -EIO;
1020         return 0;
1021 }
1022 
1023 void
1024 cleanup_module(void)
     
1025 {
1026         unregister_netdev(&de620_dev);
1027         release_region(de620_dev.base_addr, 3);
1028 }
1029 #endif 
1030 
1031 
1032 
1033 
1034 
1035 
1036 
1037 
1038 
1039 
1040 
1041 
1042 
1043 
1044 
1045