2 * 3c515.c -- 3COM 3C515 Fast Etherlink ISA 10/100BASE-TX driver for etherboot
3 * Copyright (C) 2002 Timothy Legge <tlegge@rogers.com>
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 * Portions of this code:
20 * Copyright (C) 1997-2002 Donald Becker 3c515.c: A 3Com ISA EtherLink XL "Corkscrew" ethernet driver for linux.
21 * Copyright (C) 2001 P.J.H.Fox (fox@roestock.demon.co.uk) ISAPNP Tools
22 * Copyright (c) 2002 Jaroslav Kysela <perex@suse.cz> ISA Plug & Play support Linux Kernel
23 * Copyright (C) 2000 Shusuke Nisiyama <shu@athena.qe.eng.hokudai.ac.jp> etherboot-5.0.5 3c595.c
24 * Coptright (C) 1995 Martin Renters etherboot-5.0.5 3c509.c
25 * Copyright (C) 1999 LightSys Technology Services, Inc. etherboot-5.0.5 3c90x.c
26 * Portions Copyright (C) 1999 Steve Smith etherboot-5.0.5 3c90x.c
28 * The probe and reset functions and defines are direct copies from the
29 * Becker code modified where necessary to make it work for etherboot
31 * The poll and transmit functions either contain code from or were written by referencing
32 * the above referenced etherboot drivers. This driver would not have been
33 * possible without this prior work
37 * v0.10 4-17-2002 TJL Initial implementation.
38 * v0.11 4-17-2002 TJL Cleanup of the code
39 * v0.12 4-26-2002 TJL Added ISA Plug and Play for Non-PNP Bioses
40 * v0.13 6-10-2002 TJL Fixed ISA_PNP MAC Address problem
41 * v0.14 9-23-2003 TJL Replaced delay with currticks
43 * Indent Options: indent -kr -i8
44 * *********************************************************/
47 /* to get some global routines like printf */
48 #include "etherboot.h"
49 /* to get the interface to the body of the program */
52 #include "isa.h" /* for ISA_ROM */
55 static void t3c515_wait(unsigned int nticks)
57 unsigned int to = currticks() + nticks;
58 while (currticks() < to)
64 #define u16 unsigned short
65 #define u32 unsigned long
66 #define s16 signed short
67 #define s32 signed long
69 struct corkscrew_private *vp;
70 /* Brought directly from 3c515.c by Becker */
73 /* Maximum events (Rx packets, etc.) to handle at each interrupt.
74 static int max_interrupt_work = 20;
77 /* Enable the automatic media selection code -- usually set. */
80 /* Allow the use of fragment bus master transfers instead of only
81 programmed-I/O for Vortex cards. Full-bus-master transfers are always
82 enabled by default on Boomerang cards. If VORTEX_BUS_MASTER is defined,
83 the feature may be turned on using 'options'. */
84 #define VORTEX_BUS_MASTER
86 /* A few values that may be tweaked. */
87 /* Keep the ring sizes a power of two for efficiency. */
88 #define TX_RING_SIZE 16
89 #define RX_RING_SIZE 16
90 #define PKT_BUF_SZ 1536 /* Size of each temporary Rx buffer. */
92 /* "Knobs" for adjusting internal parameters. */
93 /* Put out somewhat more debugging messages. (0 - no msg, 1 minimal msgs). */
94 #define DRIVER_DEBUG 1
95 /* Some values here only for performance evaluation and path-coverage
97 static int rx_nocopy, rx_copy, queued_packet;
100 #define CORKSCREW_ID 10
102 #define EL3WINDOW(win_num) \
103 outw(SelectWindow + (win_num), nic->ioaddr + EL3_CMD)
105 #define EL3_STATUS 0x0e
106 #define RX_BYTES_MASK (unsigned short) (0x07ff)
109 TotalReset = 0 << 11, SelectWindow = 1 << 11, StartCoax = 2 << 11,
110 RxDisable = 3 << 11, RxEnable = 4 << 11, RxReset = 5 << 11,
111 UpStall = 6 << 11, UpUnstall = (6 << 11) + 1,
112 DownStall = (6 << 11) + 2, DownUnstall = (6 << 11) + 3,
113 RxDiscard = 8 << 11, TxEnable = 9 << 11, TxDisable =
114 10 << 11, TxReset = 11 << 11,
115 FakeIntr = 12 << 11, AckIntr = 13 << 11, SetIntrEnb = 14 << 11,
116 SetStatusEnb = 15 << 11, SetRxFilter = 16 << 11, SetRxThreshold =
118 SetTxThreshold = 18 << 11, SetTxStart = 19 << 11,
119 StartDMAUp = 20 << 11, StartDMADown = (20 << 11) + 1, StatsEnable =
121 StatsDisable = 22 << 11, StopCoax = 23 << 11,
124 /* The SetRxFilter command accepts the following classes: */
126 RxStation = 1, RxMulticast = 2, RxBroadcast = 4, RxProm = 8
129 /* Bits in the general status register. */
130 enum corkscrew_status {
131 IntLatch = 0x0001, AdapterFailure = 0x0002, TxComplete = 0x0004,
132 TxAvailable = 0x0008, RxComplete = 0x0010, RxEarly = 0x0020,
133 IntReq = 0x0040, StatsFull = 0x0080,
134 DMADone = 1 << 8, DownComplete = 1 << 9, UpComplete = 1 << 10,
135 DMAInProgress = 1 << 11, /* DMA controller is still busy. */
136 CmdInProgress = 1 << 12, /* EL3_CMD is still busy. */
139 /* Register window 1 offsets, the window used in normal operation.
140 On the Corkscrew this window is always mapped at offsets 0x10-0x1f. */
142 TX_FIFO = 0x10, RX_FIFO = 0x10, RxErrors = 0x14,
143 RxStatus = 0x18, Timer = 0x1A, TxStatus = 0x1B,
144 TxFree = 0x1C, /* Remaining free bytes in Tx buffer. */
148 #if defined(CORKSCREW)
149 Wn0EepromCmd = 0x200A, /* Corkscrew EEPROM command register. */
150 Wn0EepromData = 0x200C, /* Corkscrew EEPROM results register. */
152 Wn0EepromCmd = 10, /* Window 0: EEPROM command register. */
153 Wn0EepromData = 12, /* Window 0: EEPROM results register. */
156 enum Win0_EEPROM_bits {
157 EEPROM_Read = 0x80, EEPROM_WRITE = 0x40, EEPROM_ERASE = 0xC0,
158 EEPROM_EWENB = 0x30, /* Enable erasing/writing for 10 msec. */
159 EEPROM_EWDIS = 0x00, /* Disable EWENB before 10 msec timeout. */
162 enum Window3 { /* Window 3: MAC/config bits. */
163 Wn3_Config = 0, Wn3_MAC_Ctrl = 6, Wn3_Options = 8,
167 struct w3_config_fields {
168 unsigned int ram_size:3, ram_width:1, ram_speed:2,
171 unsigned int ram_split:2, pad18:2, xcvr:3, pad21:1,
178 Wn4_NetDiag = 6, Wn4_Media = 10, /* Window 4: Xcvr/media bits. */
180 enum Win4_Media_bits {
181 Media_SQE = 0x0008, /* Enable SQE error counting for AUI. */
182 Media_10TP = 0x00C0, /* Enable link beat and jabber for 10baseT. */
183 Media_Lnk = 0x0080, /* Enable just link beat for 100TX/100FX. */
184 Media_LnkBeat = 0x0800,
186 enum Window7 { /* Window 7: Bus Master control. */
187 Wn7_MasterAddr = 0, Wn7_MasterLen = 6, Wn7_MasterStatus = 12,
190 /* Boomerang-style bus master control registers. Note ISA aliases! */
192 PktStatus = 0x400, DownListPtr = 0x404, FragAddr = 0x408, FragLen =
194 TxFreeThreshold = 0x40f, UpPktStatus = 0x410, UpListPtr = 0x418,
197 /* The Rx and Tx descriptor lists.
198 Caution Alpha hackers: these types are 32 bits! Note also the 8 byte
199 alignment contraint on tx_ring[] and rx_ring[]. */
200 struct boom_rx_desc {
207 /* Values for the Rx status entry. */
208 enum rx_desc_status {
209 RxDComplete = 0x00008000, RxDError = 0x4000,
210 /* See boomerang_rx() for actual error bits */
213 struct boom_tx_desc {
220 struct corkscrew_private {
221 const char *product_name;
222 struct net_device *next_module;
223 /* The Rx and Tx rings are here to keep them quad-word-aligned. */
224 struct boom_rx_desc rx_ring[RX_RING_SIZE];
225 struct boom_tx_desc tx_ring[TX_RING_SIZE];
226 /* The addresses of transmit- and receive-in-place skbuffs. */
227 struct sk_buff *rx_skbuff[RX_RING_SIZE];
228 struct sk_buff *tx_skbuff[TX_RING_SIZE];
229 unsigned int cur_rx, cur_tx; /* The next free ring entry */
230 unsigned int dirty_rx, dirty_tx; /* The ring entries to be free()ed. */
231 struct sk_buff *tx_skb; /* Packet being eaten by bus master ctrl. */
232 int capabilities; /* Adapter capabilities word. */
233 int options; /* User-settable misc. driver options. */
234 int last_rx_packets; /* For media autoselection. */
235 unsigned int available_media:8, /* From Wn3_Options */
236 media_override:3, /* Passed-in media type. */
237 default_media:3, /* Read from the EEPROM. */
238 full_duplex:1, autoselect:1, bus_master:1, /* Vortex can only do a fragment bus-m. */
239 full_bus_master_tx:1, full_bus_master_rx:1, /* Boomerang */
243 /* The action to take with a media selection timer tick.
244 Note that we deviate from the 3Com order by checking 10base2 before AUI.
248 0, XCVR_AUI, XCVR_10baseTOnly, XCVR_10base2, XCVR_100baseTx,
249 XCVR_100baseFx, XCVR_MII = 6, XCVR_Default = 8,
252 static struct media_table {
254 unsigned int media_bits:16, /* Bits to set in Wn4_Media register. */
255 mask:8, /* The transceiver-present bit in Wn3_Config. */
256 next:8; /* The media type to try next. */
257 short wait; /* Time before we check media status. */
260 "10baseT", Media_10TP, 0x08, XCVR_10base2, (14 * HZ) / 10}
262 "10Mbs AUI", Media_SQE, 0x20, XCVR_Default, (1 * HZ) / 10}
264 "undefined", 0, 0x80, XCVR_10baseT, 10000}
266 "10base2", 0, 0x10, XCVR_AUI, (1 * HZ) / 10}
268 "100baseTX", Media_Lnk, 0x02, XCVR_100baseFx,
271 "100baseFX", Media_Lnk, 0x04, XCVR_MII, (14 * HZ) / 10}
273 "MII", 0, 0x40, XCVR_10baseT, 3 * HZ}
275 "undefined", 0, 0x01, XCVR_10baseT, 10000}
277 "Default", 0, 0xFF, XCVR_10baseT, 10000}
280 /* TILEG Modified to remove reference to dev */
281 static int corkscrew_found_device(int ioaddr, int irq, int product_index,
282 int options, struct nic *nic);
283 static int corkscrew_probe1(int ioaddr, int irq, int product_index,
286 /* This driver uses 'options' to pass the media type, full-duplex flag, etc. */
287 /* Note: this is the only limit on the number of cards supported!! */
288 static int options = -1;
290 /* End Brought directly from 3c515.c by Becker */
292 /**************************************************************************
293 RESET - Reset adapter
294 ***************************************************************************/
295 static void t515_reset(struct nic *nic)
297 union wn3_config config;
300 /* Before initializing select the active media port. */
303 outb(0x20, nic->ioaddr + Wn3_MAC_Ctrl); /* Set the full-duplex bit. */
304 config.i = inl(nic->ioaddr + Wn3_Config);
306 if (vp->media_override != 7) {
307 DBG ( "Media override to transceiver %d (%s).\n",
309 media_tbl[vp->media_override].name);
310 if_port = vp->media_override;
311 } else if (vp->autoselect) {
312 /* Find first available media type, starting with 100baseTx. */
314 while (!(vp->available_media & media_tbl[if_port].mask))
315 if_port = media_tbl[if_port].next;
317 DBG ( "Initial media type %s.\n",
318 media_tbl[if_port].name);
320 if_port = vp->default_media;
322 config.u.xcvr = if_port;
323 outl(config.i, nic->ioaddr + Wn3_Config);
325 DBG ( "corkscrew_open() InternalConfig 0x%hX.\n",
328 outw(TxReset, nic->ioaddr + EL3_CMD);
329 for (i = 20; i >= 0; i--)
330 if (!(inw(nic->ioaddr + EL3_STATUS) & CmdInProgress))
333 outw(RxReset, nic->ioaddr + EL3_CMD);
334 /* Wait a few ticks for the RxReset command to complete. */
335 for (i = 20; i >= 0; i--)
336 if (!(inw(nic->ioaddr + EL3_STATUS) & CmdInProgress))
339 outw(SetStatusEnb | 0x00, nic->ioaddr + EL3_CMD);
343 DBG ( "FIXME: fix print for irq, not 9" );
344 DBG ( "corkscrew_open() irq %d media status 0x%hX.\n",
345 9, inw(nic->ioaddr + Wn4_Media) );
348 /* Set the station address and mask in window 2 each time opened. */
350 for (i = 0; i < 6; i++)
351 outb(nic->node_addr[i], nic->ioaddr + i);
352 for (; i < 12; i += 2)
353 outw(0, nic->ioaddr + i);
356 /* Start the thinnet transceiver. We should really wait 50ms... */
357 outw(StartCoax, nic->ioaddr + EL3_CMD);
359 outw((inw(nic->ioaddr + Wn4_Media) & ~(Media_10TP | Media_SQE)) |
360 media_tbl[if_port].media_bits, nic->ioaddr + Wn4_Media);
362 /* Switch to the stats window, and clear all stats by reading. */
363 /* outw(StatsDisable, nic->ioaddr + EL3_CMD);*/
365 for (i = 0; i < 10; i++)
366 inb(nic->ioaddr + i);
367 inw(nic->ioaddr + 10);
368 inw(nic->ioaddr + 12);
369 /* New: On the Vortex we must also clear the BadSSD counter. */
371 inb(nic->ioaddr + 12);
372 /* ..and on the Boomerang we enable the extra statistics bits. */
373 outw(0x0040, nic->ioaddr + Wn4_NetDiag);
375 /* Switch to register set 7 for normal use. */
378 /* Temporarily left in place. If these FIXMEs are printed
379 it meand that special logic for that card may need to be added
380 see Becker's 3c515.c driver */
381 if (vp->full_bus_master_rx) { /* Boomerang bus master. */
382 printf("FIXME: Is this if necessary");
383 vp->cur_rx = vp->dirty_rx = 0;
384 DBG ( " Filling in the Rx ring.\n" );
385 for (i = 0; i < RX_RING_SIZE; i++) {
386 printf("FIXME: Is this if necessary");
389 if (vp->full_bus_master_tx) { /* Boomerang bus master Tx. */
390 vp->cur_tx = vp->dirty_tx = 0;
391 outb(PKT_BUF_SZ >> 8, nic->ioaddr + TxFreeThreshold); /* Room for a packet. */
392 /* Clear the Tx ring. */
393 for (i = 0; i < TX_RING_SIZE; i++)
394 vp->tx_skbuff[i] = 0;
395 outl(0, nic->ioaddr + DownListPtr);
397 /* Set receiver mode: presumably accept b-case and phys addr only. */
398 outw(SetRxFilter | RxStation | RxMulticast | RxBroadcast | RxProm,
399 nic->ioaddr + EL3_CMD);
401 outw(RxEnable, nic->ioaddr + EL3_CMD); /* Enable the receiver. */
402 outw(TxEnable, nic->ioaddr + EL3_CMD); /* Enable transmitter. */
403 /* Allow status bits to be seen. */
404 outw(SetStatusEnb | AdapterFailure | IntReq | StatsFull |
405 (vp->full_bus_master_tx ? DownComplete : TxAvailable) |
406 (vp->full_bus_master_rx ? UpComplete : RxComplete) |
407 (vp->bus_master ? DMADone : 0), nic->ioaddr + EL3_CMD);
408 /* Ack all pending events, and set active indicator mask. */
409 outw(AckIntr | IntLatch | TxAvailable | RxEarly | IntReq,
410 nic->ioaddr + EL3_CMD);
411 outw(SetIntrEnb | IntLatch | TxAvailable | RxComplete | StatsFull
412 | (vp->bus_master ? DMADone : 0) | UpComplete | DownComplete,
413 nic->ioaddr + EL3_CMD);
417 /**************************************************************************
418 POLL - Wait for a frame
419 ***************************************************************************/
420 static int t515_poll(struct nic *nic, int retrieve)
423 register short rx_fifo;
425 cst = inw(nic->ioaddr + EL3_STATUS);
427 if ((cst & RxComplete) == 0) {
428 /* Ack all pending events, and set active indicator mask. */
429 outw(AckIntr | IntLatch | TxAvailable | RxEarly | IntReq,
430 nic->ioaddr + EL3_CMD);
431 outw(SetIntrEnb | IntLatch | TxAvailable | RxComplete |
433 bus_master ? DMADone : 0) | UpComplete |
434 DownComplete, nic->ioaddr + EL3_CMD);
437 status = inw(nic->ioaddr + RxStatus);
439 if (status & RxDError) {
440 printf("RxDError\n");
441 outw(RxDiscard, nic->ioaddr + EL3_CMD);
445 rx_fifo = status & RX_BYTES_MASK;
449 if ( ! retrieve ) return 1;
451 DBG ( "[l=%d", rx_fifo );
452 insw(nic->ioaddr + RX_FIFO, nic->packet, rx_fifo / 2);
454 nic->packet[rx_fifo - 1] = inb(nic->ioaddr + RX_FIFO);
455 nic->packetlen = rx_fifo;
458 status = inw(nic->ioaddr + RxStatus);
459 DBG ( "0x%hX*", status );
460 rx_fifo = status & RX_BYTES_MASK;
463 insw(nic->ioaddr + RX_FIFO, nic->packet + nic->packetlen,
466 nic->packet[nic->packetlen + rx_fifo - 1] =
467 inb(nic->ioaddr + RX_FIFO);
468 nic->packetlen += rx_fifo;
469 DBG ( "+%d", rx_fifo );
471 if ((status & RxComplete) == 0) {
472 DBG ( "=%d", nic->packetlen );
478 /* acknowledge reception of packet */
479 outw(RxDiscard, nic->ioaddr + EL3_CMD);
480 while (inw(nic->ioaddr + EL3_STATUS) & CmdInProgress);
483 unsigned short type = 0;
484 type = (nic->packet[12] << 8) | nic->packet[13];
485 if (nic->packet[0] + nic->packet[1] + nic->packet[2] +
486 nic->packet[3] + nic->packet[4] + nic->packet[5] ==
488 DBG ( ",t=0x%hX,b]", type );
490 DBG ( ",t=0x%hX]", type );
497 /*************************************************************************
498 3Com 515 - specific routines
499 **************************************************************************/
500 static char padmap[] = {
503 /**************************************************************************
504 TRANSMIT - Transmit a frame
505 ***************************************************************************/
506 static void t515_transmit(struct nic *nic, const char *d, /* Destination */
507 unsigned int t, /* Type */
508 unsigned int s, /* size */
515 DBG ( "{l=%d,t=0x%hX}", s + ETH_HLEN, t );
517 /* swap bytes of type */
520 len = s + ETH_HLEN; /* actual length of packet */
521 pad = padmap[len & 3];
524 * The 3c515 automatically pads short packets to minimum ethernet length,
525 * but we drop packets that are too large. Perhaps we should truncate
527 Copied from 3c595. Is this true for the 3c515?
529 if (len + pad > ETH_FRAME_LEN) {
532 /* drop acknowledgements */
533 while ((status = inb(nic->ioaddr + TxStatus)) & TxComplete) {
534 /*if(status & (TXS_UNDERRUN|0x88|TXS_STATUS_OVERFLOW)) { */
535 outw(TxReset, nic->ioaddr + EL3_CMD);
536 outw(TxEnable, nic->ioaddr + EL3_CMD);
539 outb(0x0, nic->ioaddr + TxStatus);
542 while (inw(nic->ioaddr + TxFree) < len + pad + 4) {
543 /* no room in FIFO */
546 outw(len, nic->ioaddr + TX_FIFO);
547 outw(0x0, nic->ioaddr + TX_FIFO); /* Second dword meaningless */
550 outsw(nic->ioaddr + TX_FIFO, d, ETH_ALEN / 2);
551 outsw(nic->ioaddr + TX_FIFO, nic->node_addr, ETH_ALEN / 2);
552 outw(t, nic->ioaddr + TX_FIFO);
553 outsw(nic->ioaddr + TX_FIFO, p, s / 2);
556 outb(*(p + s - 1), nic->ioaddr + TX_FIFO);
559 outb(0, nic->ioaddr + TX_FIFO); /* Padding */
561 /* wait for Tx complete */
562 while ((inw(nic->ioaddr + EL3_STATUS) & CmdInProgress) != 0);
565 /**************************************************************************
566 DISABLE - Turn off ethernet interface
567 ***************************************************************************/
568 static void t515_disable ( struct nic *nic,
569 struct isapnp_device *isapnp ) {
573 /* merge reset an disable */
576 /* This is a hack. Since ltsp worked on my
577 system without any disable functionality I
578 have no way to determine if this works */
580 /* Disable the receiver and transmitter. */
581 outw(RxDisable, nic->ioaddr + EL3_CMD);
582 outw(TxDisable, nic->ioaddr + EL3_CMD);
584 if (if_port == XCVR_10base2)
585 /* Turn off thinnet power. Green! */
586 outw(StopCoax, nic->ioaddr + EL3_CMD);
589 outw(SetIntrEnb | 0x0000, nic->ioaddr + EL3_CMD);
591 deactivate_isapnp_device ( isapnp );
595 static void t515_irq(struct nic *nic __unused, irq_action_t action __unused)
607 static struct nic_operations t515_operations = {
608 .connect = dummy_connect,
610 .transmit = t515_transmit,
615 /**************************************************************************
616 PROBE - Look for an adapter, this routine's visible to the outside
617 You should omit the last argument struct pci_device * for a non-PCI NIC
618 ***************************************************************************/
619 static int t515_probe ( struct nic *nic, struct isapnp_device *isapnp ) {
621 /* Direct copy from Beckers 3c515.c removing any ISAPNP sections */
623 isapnp_fill_nic ( nic, isapnp );
625 nic->ioaddr = isapnp->ioaddr;
626 nic->irqno = isapnp->irqno;
627 activate_isapnp_device ( isapnp );
629 /* Check the resource configuration for a matching ioaddr. */
630 if ((unsigned)(inw(nic->ioaddr + 0x2002) & 0x1f0)
631 != (nic->ioaddr & 0x1f0)) {
632 DBG ( "3c515 ioaddr mismatch\n" );
636 /* Verify by reading the device ID from the EEPROM. */
639 outw(EEPROM_Read + 7, nic->ioaddr + Wn0EepromCmd);
640 /* Pause for at least 162 us. for the read to take place. */
641 for (timer = 4; timer >= 0; timer--) {
643 if ((inw(nic->ioaddr + Wn0EepromCmd) & 0x0200) == 0)
646 if (inw(nic->ioaddr + Wn0EepromData) != 0x6d50) {
647 DBG ( "3c515 read incorrect vendor ID from EEPROM" );
652 DBG ( "3c515 Resource configuration register 0x%hX, DCR 0x%hX.\n",
653 inl(nic->ioaddr + 0x2002), inw(nic->ioaddr + 0x2000) );
654 corkscrew_found_device(nic->ioaddr, nic->irqno, CORKSCREW_ID,
658 nic->nic_op = &t515_operations;
663 corkscrew_found_device(int ioaddr, int irq,
664 int product_index, int options, struct nic *nic)
666 /* Direct copy from Becker 3c515.c with unecessary parts removed */
667 vp->product_name = "3c515";
668 vp->options = options;
671 ((options & 7) == 2) ? 0 : options & 7;
672 vp->full_duplex = (options & 8) ? 1 : 0;
673 vp->bus_master = (options & 16) ? 1 : 0;
675 vp->media_override = 7;
680 corkscrew_probe1(ioaddr, irq, product_index, nic);
685 corkscrew_probe1(int ioaddr, int irq, int product_index __unused,
688 unsigned int eeprom[0x40], checksum = 0; /* EEPROM contents */
691 printf("3Com %s at 0x%hX, ", vp->product_name, ioaddr);
693 /* Read the station address from the EEPROM. */
695 for (i = 0; i < 0x18; i++) {
696 short *phys_addr = (short *) nic->node_addr;
698 outw(EEPROM_Read + i, ioaddr + Wn0EepromCmd);
699 /* Pause for at least 162 us. for the read to take place. */
700 for (timer = 4; timer >= 0; timer--) {
702 if ((inw(ioaddr + Wn0EepromCmd) & 0x0200) == 0)
705 eeprom[i] = inw(ioaddr + Wn0EepromData);
706 DBG ( "Value %d: %hX ", i, eeprom[i] );
707 checksum ^= eeprom[i];
709 phys_addr[i] = htons(eeprom[i]);
711 checksum = (checksum ^ (checksum >> 8)) & 0xff;
712 if (checksum != 0x00)
713 printf(" ***INVALID CHECKSUM 0x%hX*** ", checksum);
715 printf("%!", nic->node_addr);
716 if (eeprom[16] == 0x11c7) { /* Corkscrew */
719 printf(", IRQ %d\n", irq);
720 /* Tell them about an invalid IRQ. */
721 if ( (irq <= 0 || irq > 15) ) {
722 DBG (" *** Warning: this IRQ is unlikely to work! ***\n" );
726 char *ram_split[] = { "5:3", "3:1", "1:1", "3:5" };
727 union wn3_config config;
729 vp->available_media = inw(ioaddr + Wn3_Options);
730 config.i = inl(ioaddr + Wn3_Config);
731 DBG ( " Internal config register is %4.4x, "
732 "transceivers 0x%hX.\n",
733 config.i, inw(ioaddr + Wn3_Options) );
735 (" %dK %s-wide RAM %s Rx:Tx split, %s%s interface.\n",
736 8 << config.u.ram_size,
737 config.u.ram_width ? "word" : "byte",
738 ram_split[config.u.ram_split],
739 config.u.autoselect ? "autoselect/" : "",
740 media_tbl[config.u.xcvr].name);
741 if_port = config.u.xcvr;
742 vp->default_media = config.u.xcvr;
743 vp->autoselect = config.u.autoselect;
745 if (vp->media_override != 7) {
746 printf(" Media override to transceiver type %d (%s).\n",
748 media_tbl[vp->media_override].name);
749 if_port = vp->media_override;
752 vp->capabilities = eeprom[16];
753 vp->full_bus_master_tx = (vp->capabilities & 0x20) ? 1 : 0;
754 /* Rx is broken at 10mbps, so we always disable it. */
755 /* vp->full_bus_master_rx = 0; */
756 vp->full_bus_master_rx = (vp->capabilities & 0x20) ? 1 : 0;
761 static struct isapnp_id t515_adapters[] = {
762 { "3c515 (ISAPnP)", ISAPNP_VENDOR('T','C','M'), 0x5051 },
765 static struct isapnp_driver t515_driver =
766 ISAPNP_DRIVER ( t515_adapters );
768 DRIVER ( "3c515", nic_driver, isapnp_driver, t515_driver,
769 t515_probe, t515_disable );
771 ISA_ROM ( "3c515", "3c515 Fast EtherLink ISAPnP" );