]>
Commit | Line | Data |
---|---|---|
748534f4 JP |
1 | /* |
2 | * 3c90x.c -- This file implements the 3c90x driver for etherboot. Written | |
3 | * by Greg Beeley, Greg.Beeley@LightSys.org. Modified by Steve Smith, | |
4 | * Steve.Smith@Juno.Com. Alignment bug fix Neil Newell (nn@icenoir.net). | |
5 | * | |
6 | * This program Copyright (C) 1999 LightSys Technology Services, Inc. | |
7 | * Portions Copyright (C) 1999 Steve Smith | |
8 | * | |
9 | * This program may be re-distributed in source or binary form, modified, | |
10 | * sold, or copied for any purpose, provided that the above copyright message | |
11 | * and this text are included with all source copies or derivative works, and | |
12 | * provided that the above copyright message and this text are included in the | |
13 | * documentation of any binary-only distributions. This program is distributed | |
14 | * WITHOUT ANY WARRANTY, without even the warranty of FITNESS FOR A PARTICULAR | |
15 | * PURPOSE or MERCHANTABILITY. Please read the associated documentation | |
16 | * "3c90x.txt" before compiling and using this driver. | |
17 | * | |
18 | * -------- | |
19 | * | |
20 | * Program written with the assistance of the 3com documentation for | |
21 | * the 3c905B-TX card, as well as with some assistance from the 3c59x | |
22 | * driver Donald Becker wrote for the Linux kernel, and with some assistance | |
23 | * from the remainder of the Etherboot distribution. | |
24 | * | |
25 | * REVISION HISTORY: | |
26 | * | |
27 | * v0.10 1-26-1998 GRB Initial implementation. | |
28 | * v0.90 1-27-1998 GRB System works. | |
29 | * v1.00pre1 2-11-1998 GRB Got prom boot issue fixed. | |
30 | * v2.0 9-24-1999 SCS Modified for 3c905 (from 3c905b code) | |
31 | * Re-wrote poll and transmit for | |
32 | * better error recovery and heavy | |
33 | * network traffic operation | |
34 | * v2.01 5-26-2003 NN Fixed driver alignment issue which | |
35 | * caused system lockups if driver structures | |
36 | * not 8-byte aligned. | |
37 | * | |
38 | */ | |
39 | ||
40 | #include "etherboot-compat.h" | |
42125f27 | 41 | #include "net.h" |
748534f4 JP |
42 | #include <timer.h> |
43 | #include <io.h> | |
44 | #include <pci.h> | |
7a914840 | 45 | #include <pci-bother.h> |
748534f4 JP |
46 | #include <minilib.h> |
47 | #include <output.h> | |
68beefa8 | 48 | #include <paging.h> |
748534f4 JP |
49 | |
50 | #define XCVR_MAGIC (0x5A00) | |
51 | /** any single transmission fails after 16 collisions or other errors | |
52 | ** this is the number of times to retry the transmission -- this should | |
53 | ** be plenty | |
54 | **/ | |
c25f3f39 | 55 | #define XMIT_RETRIES 5 |
748534f4 JP |
56 | |
57 | /*** Register definitions for the 3c905 ***/ | |
58 | enum Registers | |
59 | { | |
60 | regPowerMgmtCtrl_w = 0x7c, /** 905B Revision Only **/ | |
61 | regUpMaxBurst_w = 0x7a, /** 905B Revision Only **/ | |
62 | regDnMaxBurst_w = 0x78, /** 905B Revision Only **/ | |
63 | regDebugControl_w = 0x74, /** 905B Revision Only **/ | |
64 | regDebugData_l = 0x70, /** 905B Revision Only **/ | |
65 | regRealTimeCnt_l = 0x40, /** Universal **/ | |
66 | regUpBurstThresh_b = 0x3e, /** 905B Revision Only **/ | |
67 | regUpPoll_b = 0x3d, /** 905B Revision Only **/ | |
68 | regUpPriorityThresh_b = 0x3c, /** 905B Revision Only **/ | |
69 | regUpListPtr_l = 0x38, /** Universal **/ | |
70 | regCountdown_w = 0x36, /** Universal **/ | |
71 | regFreeTimer_w = 0x34, /** Universal **/ | |
72 | regUpPktStatus_l = 0x30, /** Universal with Exception, pg 130 **/ | |
73 | regTxFreeThresh_b = 0x2f, /** 90X Revision Only **/ | |
74 | regDnPoll_b = 0x2d, /** 905B Revision Only **/ | |
75 | regDnPriorityThresh_b = 0x2c, /** 905B Revision Only **/ | |
76 | regDnBurstThresh_b = 0x2a, /** 905B Revision Only **/ | |
77 | regDnListPtr_l = 0x24, /** Universal with Exception, pg 107 **/ | |
78 | regDmaCtrl_l = 0x20, /** Universal with Exception, pg 106 **/ | |
79 | /** **/ | |
80 | regIntStatusAuto_w = 0x1e, /** 905B Revision Only **/ | |
81 | regTxStatus_b = 0x1b, /** Universal with Exception, pg 113 **/ | |
82 | regTimer_b = 0x1a, /** Universal **/ | |
83 | regTxPktId_b = 0x18, /** 905B Revision Only **/ | |
84 | regCommandIntStatus_w = 0x0e, /** Universal (Command Variations) **/ | |
85 | }; | |
86 | ||
87 | /** following are windowed registers **/ | |
88 | enum Registers7 | |
89 | { | |
90 | regPowerMgmtEvent_7_w = 0x0c, /** 905B Revision Only **/ | |
91 | regVlanEtherType_7_w = 0x04, /** 905B Revision Only **/ | |
92 | regVlanMask_7_w = 0x00, /** 905B Revision Only **/ | |
93 | }; | |
94 | ||
95 | enum Registers6 | |
96 | { | |
97 | regBytesXmittedOk_6_w = 0x0c, /** Universal **/ | |
98 | regBytesRcvdOk_6_w = 0x0a, /** Universal **/ | |
99 | regUpperFramesOk_6_b = 0x09, /** Universal **/ | |
100 | regFramesDeferred_6_b = 0x08, /** Universal **/ | |
101 | regFramesRecdOk_6_b = 0x07, /** Universal with Exceptions, pg 142 **/ | |
102 | regFramesXmittedOk_6_b = 0x06, /** Universal **/ | |
103 | regRxOverruns_6_b = 0x05, /** Universal **/ | |
104 | regLateCollisions_6_b = 0x04, /** Universal **/ | |
105 | regSingleCollisions_6_b = 0x03, /** Universal **/ | |
106 | regMultipleCollisions_6_b = 0x02, /** Universal **/ | |
107 | regSqeErrors_6_b = 0x01, /** Universal **/ | |
108 | regCarrierLost_6_b = 0x00, /** Universal **/ | |
109 | }; | |
110 | ||
111 | enum Registers5 | |
112 | { | |
113 | regIndicationEnable_5_w = 0x0c, /** Universal **/ | |
114 | regInterruptEnable_5_w = 0x0a, /** Universal **/ | |
115 | regTxReclaimThresh_5_b = 0x09, /** 905B Revision Only **/ | |
116 | regRxFilter_5_b = 0x08, /** Universal **/ | |
117 | regRxEarlyThresh_5_w = 0x06, /** Universal **/ | |
118 | regTxStartThresh_5_w = 0x00, /** Universal **/ | |
119 | }; | |
120 | ||
121 | enum Registers4 | |
122 | { | |
123 | regUpperBytesOk_4_b = 0x0d, /** Universal **/ | |
124 | regBadSSD_4_b = 0x0c, /** Universal **/ | |
125 | regMediaStatus_4_w = 0x0a, /** Universal with Exceptions, pg 201 **/ | |
126 | regPhysicalMgmt_4_w = 0x08, /** Universal **/ | |
127 | regNetworkDiagnostic_4_w = 0x06, /** Universal with Exceptions, pg 203 **/ | |
128 | regFifoDiagnostic_4_w = 0x04, /** Universal with Exceptions, pg 196 **/ | |
129 | regVcoDiagnostic_4_w = 0x02, /** Undocumented? **/ | |
130 | }; | |
131 | ||
132 | enum Registers3 | |
133 | { | |
134 | regTxFree_3_w = 0x0c, /** Universal **/ | |
135 | regRxFree_3_w = 0x0a, /** Universal with Exceptions, pg 125 **/ | |
136 | regResetMediaOptions_3_w = 0x08, /** Media Options on B Revision, **/ | |
137 | /** Reset Options on Non-B Revision **/ | |
138 | regMacControl_3_w = 0x06, /** Universal with Exceptions, pg 199 **/ | |
139 | regMaxPktSize_3_w = 0x04, /** 905B Revision Only **/ | |
140 | regInternalConfig_3_l = 0x00, /** Universal, different bit **/ | |
141 | /** definitions, pg 59 **/ | |
142 | }; | |
143 | ||
144 | enum Registers2 | |
145 | { | |
146 | regResetOptions_2_w = 0x0c, /** 905B Revision Only **/ | |
147 | regStationMask_2_3w = 0x06, /** Universal with Exceptions, pg 127 **/ | |
148 | regStationAddress_2_3w = 0x00, /** Universal with Exceptions, pg 127 **/ | |
149 | }; | |
150 | ||
151 | enum Registers1 | |
152 | { | |
153 | regRxStatus_1_w = 0x0a, /** 90X Revision Only, Pg 126 **/ | |
154 | }; | |
155 | ||
156 | enum Registers0 | |
157 | { | |
158 | regEepromData_0_w = 0x0c, /** Universal **/ | |
159 | regEepromCommand_0_w = 0x0a, /** Universal **/ | |
160 | regBiosRomData_0_b = 0x08, /** 905B Revision Only **/ | |
161 | regBiosRomAddr_0_l = 0x04, /** 905B Revision Only **/ | |
162 | }; | |
163 | ||
164 | ||
165 | /*** The names for the eight register windows ***/ | |
166 | enum Windows | |
167 | { | |
168 | winPowerVlan7 = 0x07, | |
169 | winStatistics6 = 0x06, | |
170 | winTxRxControl5 = 0x05, | |
171 | winDiagnostics4 = 0x04, | |
172 | winTxRxOptions3 = 0x03, | |
173 | winAddressing2 = 0x02, | |
174 | winUnused1 = 0x01, | |
175 | winEepromBios0 = 0x00, | |
176 | }; | |
177 | ||
178 | ||
179 | /*** Command definitions for the 3c90X ***/ | |
180 | enum Commands | |
181 | { | |
182 | cmdGlobalReset = 0x00, /** Universal with Exceptions, pg 151 **/ | |
183 | cmdSelectRegisterWindow = 0x01, /** Universal **/ | |
184 | cmdEnableDcConverter = 0x02, /** **/ | |
185 | cmdRxDisable = 0x03, /** **/ | |
186 | cmdRxEnable = 0x04, /** Universal **/ | |
187 | cmdRxReset = 0x05, /** Universal **/ | |
188 | cmdStallCtl = 0x06, /** Universal **/ | |
189 | cmdTxEnable = 0x09, /** Universal **/ | |
190 | cmdTxDisable = 0x0A, /** **/ | |
191 | cmdTxReset = 0x0B, /** Universal **/ | |
192 | cmdRequestInterrupt = 0x0C, /** **/ | |
193 | cmdAcknowledgeInterrupt = 0x0D, /** Universal **/ | |
194 | cmdSetInterruptEnable = 0x0E, /** Universal **/ | |
195 | cmdSetIndicationEnable = 0x0F, /** Universal **/ | |
196 | cmdSetRxFilter = 0x10, /** Universal **/ | |
197 | cmdSetRxEarlyThresh = 0x11, /** **/ | |
198 | cmdSetTxStartThresh = 0x13, /** **/ | |
199 | cmdStatisticsEnable = 0x15, /** **/ | |
200 | cmdStatisticsDisable = 0x16, /** **/ | |
201 | cmdDisableDcConverter = 0x17, /** **/ | |
202 | cmdSetTxReclaimThresh = 0x18, /** **/ | |
203 | cmdSetHashFilterBit = 0x19, /** **/ | |
204 | }; | |
205 | ||
206 | ||
207 | /*** Values for int status register bitmask **/ | |
208 | #define INT_INTERRUPTLATCH (1<<0) | |
209 | #define INT_HOSTERROR (1<<1) | |
210 | #define INT_TXCOMPLETE (1<<2) | |
211 | #define INT_RXCOMPLETE (1<<4) | |
212 | #define INT_RXEARLY (1<<5) | |
213 | #define INT_INTREQUESTED (1<<6) | |
214 | #define INT_UPDATESTATS (1<<7) | |
215 | #define INT_LINKEVENT (1<<8) | |
216 | #define INT_DNCOMPLETE (1<<9) | |
217 | #define INT_UPCOMPLETE (1<<10) | |
218 | #define INT_CMDINPROGRESS (1<<12) | |
219 | #define INT_WINDOWNUMBER (7<<13) | |
220 | ||
9c86d6da JW |
221 | /* These structures are all 64-bit aligned, as needed for bus-mastering I/O. */ |
222 | typedef struct { | |
223 | unsigned int addr; | |
224 | unsigned int len; | |
225 | } segment_t __attribute__ ((aligned(8))); | |
226 | ||
227 | typedef struct { | |
228 | unsigned int next; | |
229 | unsigned int hdr; | |
230 | segment_t segments[64 /* XXX magic */]; | |
231 | } txdesc_t __attribute__ ((aligned(8))); | |
748534f4 JP |
232 | |
233 | /*** RX descriptor ***/ | |
9c86d6da JW |
234 | typedef struct { |
235 | unsigned int next; | |
236 | unsigned int status; | |
237 | segment_t segments[64]; | |
238 | } rxdesc_t __attribute__ ((aligned(8))); | |
748534f4 JP |
239 | |
240 | /*** Global variables ***/ | |
241 | static struct | |
242 | { | |
243 | unsigned int is3c556; | |
244 | unsigned char isBrev; | |
245 | unsigned char CurrentWindow; | |
246 | unsigned int IOAddr; | |
247 | unsigned char HWAddr[ETH_ALEN]; | |
748534f4 JP |
248 | } |
249 | INF_3C90X; | |
9c86d6da | 250 | |
7a914840 | 251 | static struct nic nic; |
9c86d6da | 252 | static txdesc_t txdesc; |
748534f4 | 253 | |
c2e34447 JW |
254 | #define _outl(v,a) outl((a),(v)) |
255 | #define _outw(v,a) outw((a),(v)) | |
256 | #define _outb(v,a) outb((a),(v)) | |
748534f4 | 257 | |
31ddf9b3 JW |
258 | static int _issue_command(int ioaddr, int cmd, int param) |
259 | { | |
260 | outw(ioaddr + regCommandIntStatus_w, (cmd << 11) | param); | |
748534f4 | 261 | |
31ddf9b3 JW |
262 | while (inw(ioaddr + regCommandIntStatus_w) & INT_CMDINPROGRESS) |
263 | ; | |
748534f4 | 264 | |
31ddf9b3 JW |
265 | return 0; |
266 | } | |
748534f4 JP |
267 | |
268 | ||
269 | /*** a3c90x_internal_SetWindow: selects a register window set. | |
270 | ***/ | |
31ddf9b3 JW |
271 | static int _set_window(int ioaddr, int window) |
272 | { | |
273 | if (INF_3C90X.CurrentWindow == window) | |
274 | return 0; | |
748534f4 | 275 | |
31ddf9b3 | 276 | _issue_command(ioaddr, cmdSelectRegisterWindow, window); |
748534f4 JP |
277 | INF_3C90X.CurrentWindow = window; |
278 | ||
31ddf9b3 JW |
279 | return 0; |
280 | } | |
748534f4 JP |
281 | |
282 | ||
283 | /*** a3c90x_internal_ReadEeprom - read data from the serial eeprom. | |
284 | ***/ | |
285 | static unsigned short | |
286 | a3c90x_internal_ReadEeprom(int ioaddr, int address) | |
c2e34447 JW |
287 | { |
288 | unsigned short val; | |
748534f4 JP |
289 | |
290 | /** Select correct window **/ | |
31ddf9b3 | 291 | _set_window(INF_3C90X.IOAddr, winEepromBios0); |
748534f4 JP |
292 | |
293 | /** Make sure the eeprom isn't busy **/ | |
c2e34447 JW |
294 | do |
295 | { | |
296 | int i; | |
297 | for (i = 0; i < 165; i++) | |
298 | inb(0x80); /* wait 165 usec */ | |
299 | } | |
300 | while(0x8000 & inw(ioaddr + regEepromCommand_0_w)); | |
748534f4 JP |
301 | |
302 | /** Read the value. **/ | |
303 | if (INF_3C90X.is3c556) | |
c2e34447 | 304 | _outw(address + (0x230), ioaddr + regEepromCommand_0_w); |
748534f4 | 305 | else |
c2e34447 | 306 | _outw(address + 0x80, ioaddr + regEepromCommand_0_w); |
748534f4 | 307 | |
c2e34447 JW |
308 | do |
309 | { | |
310 | int i; | |
311 | for (i = 0; i < 165; i++) | |
312 | inb(0x80); /* wait 165 usec */ | |
313 | } | |
314 | while(0x8000 & inw(ioaddr + regEepromCommand_0_w)); | |
315 | val = inw(ioaddr + regEepromData_0_w); | |
316 | ||
317 | return val; | |
318 | } | |
748534f4 JP |
319 | |
320 | ||
321 | #ifdef CFG_3C90X_BOOTROM_FIX | |
322 | /*** a3c90x_internal_WriteEepromWord - write a physical word of | |
323 | *** data to the onboard serial eeprom (not the BIOS prom, but the | |
324 | *** nvram in the card that stores, among other things, the MAC | |
325 | *** address). | |
326 | ***/ | |
327 | static int | |
328 | a3c90x_internal_WriteEepromWord(int ioaddr, int address, unsigned short value) | |
329 | { | |
330 | /** Select register window **/ | |
31ddf9b3 | 331 | _set_window(ioaddr, winEepromBios0); |
748534f4 JP |
332 | |
333 | /** Verify Eeprom not busy **/ | |
334 | while((1<<15) & inw(ioaddr + regEepromCommand_0_w)); | |
335 | ||
336 | /** Issue WriteEnable, and wait for completion. **/ | |
c2e34447 | 337 | _outw(0x30, ioaddr + regEepromCommand_0_w); |
748534f4 JP |
338 | while((1<<15) & inw(ioaddr + regEepromCommand_0_w)); |
339 | ||
340 | /** Issue EraseRegister, and wait for completion. **/ | |
c2e34447 | 341 | _outw(address + ((0x03)<<6), ioaddr + regEepromCommand_0_w); |
748534f4 JP |
342 | while((1<<15) & inw(ioaddr + regEepromCommand_0_w)); |
343 | ||
344 | /** Send the new data to the eeprom, and wait for completion. **/ | |
c2e34447 JW |
345 | _outw(value, ioaddr + regEepromData_0_w); |
346 | _outw(0x30, ioaddr + regEepromCommand_0_w); | |
748534f4 JP |
347 | while((1<<15) & inw(ioaddr + regEepromCommand_0_w)); |
348 | ||
349 | /** Burn the new data into the eeprom, and wait for completion. **/ | |
c2e34447 | 350 | _outw(address + ((0x01)<<6), ioaddr + regEepromCommand_0_w); |
748534f4 JP |
351 | while((1<<15) & inw(ioaddr + regEepromCommand_0_w)); |
352 | ||
353 | return 0; | |
354 | } | |
355 | #endif | |
356 | ||
357 | #ifdef CFG_3C90X_BOOTROM_FIX | |
358 | /*** a3c90x_internal_WriteEeprom - write data to the serial eeprom, | |
359 | *** and re-compute the eeprom checksum. | |
360 | ***/ | |
361 | static int | |
362 | a3c90x_internal_WriteEeprom(int ioaddr, int address, unsigned short value) | |
363 | { | |
364 | int cksum = 0,v; | |
365 | int i; | |
366 | int maxAddress, cksumAddress; | |
367 | ||
368 | if (INF_3C90X.isBrev) | |
369 | { | |
370 | maxAddress=0x1f; | |
371 | cksumAddress=0x20; | |
372 | } | |
373 | else | |
374 | { | |
375 | maxAddress=0x16; | |
376 | cksumAddress=0x17; | |
377 | } | |
378 | ||
379 | /** Write the value. **/ | |
380 | if (a3c90x_internal_WriteEepromWord(ioaddr, address, value) == -1) | |
381 | return -1; | |
382 | ||
383 | /** Recompute the checksum. **/ | |
384 | for(i=0;i<=maxAddress;i++) | |
385 | { | |
386 | v = a3c90x_internal_ReadEeprom(ioaddr, i); | |
387 | cksum ^= (v & 0xFF); | |
388 | cksum ^= ((v>>8) & 0xFF); | |
389 | } | |
390 | /** Write the checksum to the location in the eeprom **/ | |
391 | if (a3c90x_internal_WriteEepromWord(ioaddr, cksumAddress, cksum) == -1) | |
392 | return -1; | |
393 | ||
394 | return 0; | |
395 | } | |
396 | #endif | |
397 | ||
398 | /*** a3c90x_reset: exported function that resets the card to its default | |
399 | *** state. This is so the Linux driver can re-set the card up the way | |
400 | *** it wants to. If CFG_3C90X_PRESERVE_XCVR is defined, then the reset will | |
401 | *** not alter the selected transceiver that we used to download the boot | |
402 | *** image. | |
403 | ***/ | |
404 | static void a3c90x_reset(void) | |
405 | { | |
748534f4 | 406 | /** Send the reset command to the card **/ |
99182958 | 407 | outputf("3c90x: issuing RESET"); |
31ddf9b3 | 408 | _issue_command(INF_3C90X.IOAddr, cmdGlobalReset, 0); |
748534f4 JP |
409 | |
410 | /** global reset command resets station mask, non-B revision cards | |
411 | ** require explicit reset of values | |
412 | **/ | |
31ddf9b3 | 413 | _set_window(INF_3C90X.IOAddr, winAddressing2); |
c2e34447 JW |
414 | _outw(0, INF_3C90X.IOAddr + regStationMask_2_3w+0); |
415 | _outw(0, INF_3C90X.IOAddr + regStationMask_2_3w+2); | |
416 | _outw(0, INF_3C90X.IOAddr + regStationMask_2_3w+4); | |
748534f4 | 417 | |
748534f4 | 418 | /** Issue transmit reset, wait for command completion **/ |
31ddf9b3 | 419 | _issue_command(INF_3C90X.IOAddr, cmdTxReset, 0); |
748534f4 | 420 | if (! INF_3C90X.isBrev) |
c2e34447 | 421 | _outb(0x01, INF_3C90X.IOAddr + regTxFreeThresh_b); |
31ddf9b3 | 422 | _issue_command(INF_3C90X.IOAddr, cmdTxEnable, 0); |
748534f4 JP |
423 | |
424 | /** | |
425 | ** reset of the receiver on B-revision cards re-negotiates the link | |
426 | ** takes several seconds (a computer eternity) | |
427 | **/ | |
428 | if (INF_3C90X.isBrev) | |
31ddf9b3 | 429 | _issue_command(INF_3C90X.IOAddr, cmdRxReset, 0x04); |
748534f4 | 430 | else |
31ddf9b3 JW |
431 | _issue_command(INF_3C90X.IOAddr, cmdRxReset, 0x00); |
432 | while (inw(INF_3C90X.IOAddr + regCommandIntStatus_w) & INT_CMDINPROGRESS) | |
433 | ; | |
434 | _issue_command(INF_3C90X.IOAddr, cmdRxEnable, 0); | |
748534f4 | 435 | |
31ddf9b3 | 436 | _issue_command(INF_3C90X.IOAddr, cmdSetInterruptEnable, 0); |
748534f4 | 437 | /** enable rxComplete and txComplete **/ |
31ddf9b3 | 438 | _issue_command(INF_3C90X.IOAddr, cmdSetIndicationEnable, 0x0014); |
748534f4 | 439 | /** acknowledge any pending status flags **/ |
31ddf9b3 | 440 | _issue_command(INF_3C90X.IOAddr, cmdAcknowledgeInterrupt, 0x661); |
748534f4 JP |
441 | |
442 | return; | |
443 | } | |
444 | ||
445 | ||
446 | ||
447 | /*** a3c90x_transmit: exported function that transmits a packet. Does not | |
448 | *** return any particular status. Parameters are: | |
449 | *** dest_addr[6] - destination address, ethernet; | |
450 | *** proto - protocol type (ARP, IP, etc); | |
451 | *** size - size of the non-header part of the packet that needs transmitted; | |
452 | *** pkt - the pointer to the packet data itself. | |
453 | ***/ | |
bc9e1044 | 454 | static void _transmit(struct pbuf *p) |
31ddf9b3 | 455 | { |
31ddf9b3 | 456 | unsigned char status; |
057f0bb9 | 457 | static struct pbuf *oldpbuf = NULL; |
54d4b877 | 458 | unsigned int n, len; |
f8903fdd | 459 | |
057f0bb9 | 460 | if (oldpbuf) |
f8903fdd | 461 | { |
bec09bd1 | 462 | int i = 0; |
f8903fdd | 463 | while (!(inw(INF_3C90X.IOAddr + regCommandIntStatus_w) & INT_TXCOMPLETE) && oneshot_running()) |
bec09bd1 JW |
464 | i++; |
465 | if (i) | |
466 | outputf("3c90x: had to wait %d loops to tx", i); | |
f8903fdd JW |
467 | if (!(inw(INF_3C90X.IOAddr + regCommandIntStatus_w) & INT_TXCOMPLETE)) |
468 | { | |
469 | outputf("3c90x: tx timeout? txstat %02x", inb(INF_3C90X.IOAddr + regTxStatus_b)); | |
470 | outputf("3c90x: Gen sts %04x", inw(INF_3C90X.IOAddr + regCommandIntStatus_w)); | |
471 | } | |
472 | status = inb(INF_3C90X.IOAddr + regTxStatus_b); | |
473 | outb(INF_3C90X.IOAddr + regTxStatus_b, 0x00); | |
057f0bb9 JW |
474 | pbuf_free(oldpbuf); |
475 | oldpbuf = NULL; | |
f8903fdd | 476 | } |
3dd054cf | 477 | |
037ce545 JW |
478 | _issue_command(INF_3C90X.IOAddr, cmdStallCtl, 2 /* Stall download */); |
479 | ||
480 | /** Setup the DPD (download descriptor) **/ | |
9c86d6da | 481 | txdesc.next = 0; |
54d4b877 JW |
482 | len = 0; |
483 | n = 0; | |
057f0bb9 | 484 | oldpbuf = p; |
54d4b877 JW |
485 | for (; p; p = p->next) |
486 | { | |
9c86d6da JW |
487 | txdesc.segments[n].addr = v2p(p->payload); |
488 | txdesc.segments[n].len = p->len | (p->next ? 0 : (1 << 31)); | |
54d4b877 | 489 | len += p->len; |
057f0bb9 | 490 | pbuf_ref(p); |
54d4b877 JW |
491 | n++; |
492 | } | |
037ce545 | 493 | /** set notification for transmission completion (bit 15) **/ |
9c86d6da | 494 | txdesc.hdr = (len) | 0x8000; |
037ce545 JW |
495 | |
496 | /** Send the packet **/ | |
9c86d6da | 497 | outl(INF_3C90X.IOAddr + regDnListPtr_l, v2p(&txdesc)); |
037ce545 | 498 | _issue_command(INF_3C90X.IOAddr, cmdStallCtl, 3 /* Unstall download */); |
31ddf9b3 | 499 | |
037ce545 JW |
500 | oneshot_start_ms(10); |
501 | while((inl(INF_3C90X.IOAddr + regDnListPtr_l) != 0) && oneshot_running()) | |
502 | ; | |
503 | if (!oneshot_running()) | |
504 | { | |
505 | outputf("3c90x: Download engine pointer timeout"); | |
506 | return; | |
507 | } | |
3dd054cf | 508 | |
3dd054cf | 509 | #if 0 |
037ce545 JW |
510 | /** successful completion (sans "interrupt Requested" bit) **/ |
511 | if ((status & 0xbf) == 0x80) | |
512 | return; | |
31ddf9b3 | 513 | |
037ce545 JW |
514 | outputf("3c90x: Status (%hhX)", status); |
515 | /** check error codes **/ | |
516 | if (status & 0x02) | |
517 | { | |
518 | outputf("3c90x: Tx Reclaim Error (%hhX)", status); | |
519 | a3c90x_reset(); | |
520 | } else if (status & 0x04) { | |
521 | outputf("3c90x: Tx Status Overflow (%hhX)", status); | |
522 | for (i=0; i<32; i++) | |
523 | _outb(0x00, INF_3C90X.IOAddr + regTxStatus_b); | |
524 | /** must re-enable after max collisions before re-issuing tx **/ | |
525 | _issue_command(INF_3C90X.IOAddr, cmdTxEnable, 0); | |
526 | } else if (status & 0x08) { | |
527 | outputf("3c90x: Tx Max Collisions (%hhX)", status); | |
528 | /** must re-enable after max collisions before re-issuing tx **/ | |
529 | _issue_command(INF_3C90X.IOAddr, cmdTxEnable, 0); | |
530 | } else if (status & 0x10) { | |
531 | outputf("3c90x: Tx Underrun (%hhX)", status); | |
532 | a3c90x_reset(); | |
533 | } else if (status & 0x20) { | |
534 | outputf("3c90x: Tx Jabber (%hhX)", status); | |
535 | a3c90x_reset(); | |
536 | } else if ((status & 0x80) != 0x80) { | |
537 | outputf("3c90x: Internal Error - Incomplete Transmission (%hhX)", status); | |
538 | a3c90x_reset(); | |
748534f4 | 539 | } |
037ce545 | 540 | #endif |
31ddf9b3 | 541 | } |
748534f4 | 542 | |
bec09bd1 JW |
543 | /***************************** Receive routines *****************************/ |
544 | #define MAX_RECV_SIZE 1536 | |
545 | #define RECV_BUFS 4 | |
546 | ||
547 | static rxdesc_t rxdescs[RECV_BUFS]; | |
548 | static struct pbuf *pbufs[RECV_BUFS] = {0,}; | |
549 | ||
550 | /* rxcons is the pointer to the receive descriptor that the ethernet card will | |
551 | * write into next. | |
552 | */ | |
553 | static int rxcons = 0; | |
554 | ||
555 | /* rxprod is the pointer to the receive descriptor that the driver will | |
556 | * allocate next. | |
80c7c8bf | 557 | */ |
bec09bd1 JW |
558 | static int rxprod = 0; |
559 | ||
560 | /* _recv_prepare fills the 3c90x's ring buffer with fresh pbufs from lwIP. | |
561 | * The upload engine need not be stalled. | |
562 | */ | |
563 | static void _recv_prepare(struct nic *nic) | |
9c86d6da | 564 | { |
bec09bd1 JW |
565 | int oldprod; |
566 | ||
567 | oldprod = rxprod; | |
568 | while ((rxprod != rxcons) || !pbufs[rxprod]) | |
748534f4 | 569 | { |
bec09bd1 JW |
570 | int i; |
571 | struct pbuf *p; | |
572 | ||
573 | if (!pbufs[rxprod]) | |
574 | pbufs[rxprod] = p = pbuf_alloc(PBUF_RAW, MAX_RECV_SIZE, PBUF_POOL); | |
575 | else { | |
576 | outputf("WARNING: 3c90x has pbuf in slot %d", rxprod); | |
577 | p = pbufs[rxprod]; | |
578 | } | |
579 | ||
580 | if (!p) | |
581 | { | |
582 | outputf("3c90x: out of memory for rx pbuf?"); | |
583 | break; | |
584 | } | |
585 | ||
586 | rxdescs[rxprod].status = 0; | |
587 | rxdescs[rxprod].next = 0; | |
588 | for (i = 0; p; p = p->next, i++) | |
589 | { | |
590 | rxdescs[rxprod].segments[i].addr = v2p(p->payload); | |
591 | rxdescs[rxprod].segments[i].len = p->len | (p->next ? 0 : (1 << 31)); | |
592 | } | |
593 | ||
594 | /* Hook in the new one after and only after it's been fully set up. */ | |
595 | rxdescs[(rxprod + RECV_BUFS - 1) % RECV_BUFS].next = v2p(&(rxdescs[rxprod])); | |
596 | rxprod = (rxprod + 1) % RECV_BUFS; | |
748534f4 | 597 | } |
80c7c8bf | 598 | |
bec09bd1 | 599 | if (inl(INF_3C90X.IOAddr + regUpListPtr_l) == 0 && pbufs[oldprod]) /* Ran out of shit, and got new shit? */ |
748534f4 | 600 | { |
bec09bd1 JW |
601 | outl(INF_3C90X.IOAddr + regUpListPtr_l, v2p(&rxdescs[oldprod])); |
602 | outputf("3c90x: WARNING: Ran out of rx slots"); | |
748534f4 | 603 | } |
80c7c8bf | 604 | |
80c7c8bf | 605 | } |
748534f4 | 606 | |
bec09bd1 JW |
607 | /* _recv polls the ring buffer to see if any packets are available. If any |
608 | * are, then eth_recv is called for each available. _recv returns how many | |
609 | * packets it received successfully. Whether _recv got any packets or not, | |
610 | * _recv does not block, and reinitializes the ring buffer with fresh pbufs. | |
611 | */ | |
612 | static int _recv(struct nic *nic) | |
80c7c8bf | 613 | { |
bec09bd1 | 614 | int errcode, n = 0; |
80c7c8bf JW |
615 | struct pbuf *p; |
616 | ||
80c7c8bf | 617 | /* Nothing to do? */ |
bec09bd1 | 618 | while ((rxdescs[rxcons].status & ((1<<14) | (1<<15))) != 0) |
9c86d6da | 619 | { |
bec09bd1 JW |
620 | /** Check for Error (else we have good packet) **/ |
621 | if (rxdescs[rxcons].status & (1<<14)) | |
622 | { | |
623 | errcode = rxdescs[rxcons].status; | |
624 | if (errcode & (1<<16)) | |
625 | outputf("3C90X: Rx Overrun (%hX)",errcode>>16); | |
626 | else if (errcode & (1<<17)) | |
627 | outputf("3C90X: Runt Frame (%hX)",errcode>>16); | |
628 | else if (errcode & (1<<18)) | |
629 | outputf("3C90X: Alignment Error (%hX)",errcode>>16); | |
630 | else if (errcode & (1<<19)) | |
631 | outputf("3C90X: CRC Error (%hX)",errcode>>16); | |
632 | else if (errcode & (1<<20)) | |
633 | outputf("3C90X: Oversized Frame (%hX)",errcode>>16); | |
634 | else | |
635 | outputf("3C90X: Packet error (%hX)",errcode>>16); | |
80c7c8bf | 636 | |
bec09bd1 JW |
637 | p = NULL; |
638 | pbuf_free(pbufs[rxcons]); /* Bounce the old one before setting it up again. */ | |
639 | } else { | |
640 | p = pbufs[rxcons]; | |
641 | pbuf_realloc(p, rxdescs[rxcons].status & 0x1FFF); /* Resize the packet to how large it actually is. */ | |
642 | } | |
643 | ||
644 | pbufs[rxcons] = NULL; | |
645 | rxdescs[rxcons].status = 0; | |
646 | rxcons = (rxcons + 1) % RECV_BUFS; | |
647 | ||
648 | if (p) | |
649 | { | |
650 | eth_recv(nic, p); | |
651 | n++; | |
652 | } | |
9c86d6da | 653 | } |
748534f4 | 654 | |
bec09bd1 JW |
655 | _recv_prepare(nic); /* Light the NIC up again. */ |
656 | return n; | |
9c86d6da | 657 | } |
748534f4 JP |
658 | |
659 | /*** a3c90x_disable: exported routine to disable the card. What's this for? | |
660 | *** the eepro100.c driver didn't have one, so I just left this one empty too. | |
661 | *** Ideas anyone? | |
662 | *** Must turn off receiver at least so stray packets will not corrupt memory | |
663 | *** [Ken] | |
664 | ***/ | |
665 | void a3c90x_disable(struct dev *dev) | |
666 | { | |
667 | /* reset and disable merge */ | |
668 | a3c90x_reset(); | |
669 | /* Disable the receiver and transmitter. */ | |
c2e34447 JW |
670 | _outw(cmdRxDisable, INF_3C90X.IOAddr + regCommandIntStatus_w); |
671 | _outw(cmdTxDisable, INF_3C90X.IOAddr + regCommandIntStatus_w); | |
748534f4 JP |
672 | } |
673 | ||
674 | ||
675 | /*** a3c90x_probe: exported routine to probe for the 3c905 card and perform | |
676 | *** initialization. If this routine is called, the pci functions did find the | |
677 | *** card. We just have to init it here. | |
678 | ***/ | |
679 | static int a3c90x_probe(struct pci_dev * pci, void * data) | |
680 | { | |
748534f4 JP |
681 | INF_3C90X.is3c556 = (pci->did == 0x6055); |
682 | ||
683 | int i, c; | |
c2e34447 | 684 | unsigned short eeprom[0x100]; |
748534f4 JP |
685 | unsigned int cfg; |
686 | unsigned int mopt; | |
687 | unsigned int mstat; | |
688 | unsigned short linktype; | |
689 | #define HWADDR_OFFSET 10 | |
690 | ||
691 | unsigned long ioaddr = 0; | |
692 | for (i = 0; i < 6; i++) { | |
693 | if (pci->bars[i].type == PCI_BAR_IO) { | |
694 | ioaddr = pci->bars[i].addr; | |
695 | break; | |
696 | } | |
697 | } | |
698 | ||
699 | if (ioaddr == 0) | |
c2e34447 JW |
700 | { |
701 | outputf("3c90x: Unable to find I/O address"); | |
702 | return 0; | |
703 | } | |
704 | ||
705 | /* Power it on */ | |
706 | pci_write16(pci->bus, pci->dev, pci->fn, 0xE0, | |
707 | pci_read16(pci->bus, pci->dev, pci->fn, 0xE0) & ~0x3); | |
708 | ||
709 | outputf("3c90x: Picked I/O address %04x", ioaddr); | |
047916ed | 710 | pci_bother_add(pci); |
42125f27 JP |
711 | nic.ioaddr = ioaddr & ~3; |
712 | nic.irqno = 0; | |
748534f4 | 713 | |
c2e34447 | 714 | INF_3C90X.IOAddr = ioaddr; |
748534f4 JP |
715 | INF_3C90X.CurrentWindow = 255; |
716 | switch (a3c90x_internal_ReadEeprom(INF_3C90X.IOAddr, 0x03)) | |
717 | { | |
718 | case 0x9000: /** 10 Base TPO **/ | |
719 | case 0x9001: /** 10/100 T4 **/ | |
720 | case 0x9050: /** 10/100 TPO **/ | |
721 | case 0x9051: /** 10 Base Combo **/ | |
722 | INF_3C90X.isBrev = 0; | |
723 | break; | |
724 | ||
725 | case 0x9004: /** 10 Base TPO **/ | |
726 | case 0x9005: /** 10 Base Combo **/ | |
727 | case 0x9006: /** 10 Base TPO and Base2 **/ | |
728 | case 0x900A: /** 10 Base FL **/ | |
729 | case 0x9055: /** 10/100 TPO **/ | |
730 | case 0x9056: /** 10/100 T4 **/ | |
731 | case 0x905A: /** 10 Base FX **/ | |
732 | default: | |
733 | INF_3C90X.isBrev = 1; | |
734 | break; | |
735 | } | |
736 | ||
737 | /** Load the EEPROM contents **/ | |
738 | if (INF_3C90X.isBrev) | |
739 | { | |
c2e34447 | 740 | for(i=0;i<=/*0x20*/0x7F;i++) |
748534f4 JP |
741 | { |
742 | eeprom[i] = a3c90x_internal_ReadEeprom(INF_3C90X.IOAddr, i); | |
743 | } | |
744 | ||
745 | #ifdef CFG_3C90X_BOOTROM_FIX | |
746 | /** Set xcvrSelect in InternalConfig in eeprom. **/ | |
747 | /* only necessary for 3c905b revision cards with boot PROM bug!!! */ | |
748 | a3c90x_internal_WriteEeprom(INF_3C90X.IOAddr, 0x13, 0x0160); | |
749 | #endif | |
750 | ||
751 | #ifdef CFG_3C90X_XCVR | |
752 | if (CFG_3C90X_XCVR == 255) | |
753 | { | |
754 | /** Clear the LanWorks register **/ | |
755 | a3c90x_internal_WriteEeprom(INF_3C90X.IOAddr, 0x16, 0); | |
756 | } | |
757 | else | |
758 | { | |
759 | /** Set the selected permanent-xcvrSelect in the | |
760 | ** LanWorks register | |
761 | **/ | |
762 | a3c90x_internal_WriteEeprom(INF_3C90X.IOAddr, 0x16, | |
763 | XCVR_MAGIC + ((CFG_3C90X_XCVR) & 0x000F)); | |
764 | } | |
765 | #endif | |
766 | } | |
767 | else | |
768 | { | |
c2e34447 | 769 | for(i=0;i<=/*0x17*/0x7F;i++) |
748534f4 JP |
770 | { |
771 | eeprom[i] = a3c90x_internal_ReadEeprom(INF_3C90X.IOAddr, i); | |
772 | } | |
773 | } | |
774 | ||
775 | /** Print identification message **/ | |
776 | #ifdef CFG_3C90X_BOOTROM_FIX | |
777 | if (INF_3C90X.isBrev) | |
778 | { | |
779 | outputf("NOTE: 3c905b bootrom fix enabled; has side " | |
780 | "effects. See 3c90x.txt for info."); | |
781 | } | |
782 | #endif | |
783 | ||
784 | /** Retrieve the Hardware address and print it on the screen. **/ | |
785 | INF_3C90X.HWAddr[0] = eeprom[HWADDR_OFFSET + 0]>>8; | |
786 | INF_3C90X.HWAddr[1] = eeprom[HWADDR_OFFSET + 0]&0xFF; | |
787 | INF_3C90X.HWAddr[2] = eeprom[HWADDR_OFFSET + 1]>>8; | |
788 | INF_3C90X.HWAddr[3] = eeprom[HWADDR_OFFSET + 1]&0xFF; | |
789 | INF_3C90X.HWAddr[4] = eeprom[HWADDR_OFFSET + 2]>>8; | |
790 | INF_3C90X.HWAddr[5] = eeprom[HWADDR_OFFSET + 2]&0xFF; | |
c2e34447 JW |
791 | outputf("MAC Address = %02x:%02x:%02x:%02x:%02x:%02x", |
792 | INF_3C90X.HWAddr[0], | |
793 | INF_3C90X.HWAddr[1], | |
794 | INF_3C90X.HWAddr[2], | |
795 | INF_3C90X.HWAddr[3], | |
796 | INF_3C90X.HWAddr[4], | |
797 | INF_3C90X.HWAddr[5]); | |
748534f4 JP |
798 | |
799 | /** 3C556: Invert MII power **/ | |
800 | if (INF_3C90X.is3c556) { | |
801 | unsigned int tmp; | |
31ddf9b3 | 802 | _set_window(INF_3C90X.IOAddr, winAddressing2); |
748534f4 JP |
803 | tmp = inw(INF_3C90X.IOAddr + regResetOptions_2_w); |
804 | tmp |= 0x4000; | |
c2e34447 | 805 | _outw(tmp, INF_3C90X.IOAddr + regResetOptions_2_w); |
748534f4 JP |
806 | } |
807 | ||
808 | /* Test if the link is good, if not continue */ | |
31ddf9b3 | 809 | _set_window(INF_3C90X.IOAddr, winDiagnostics4); |
748534f4 JP |
810 | mstat = inw(INF_3C90X.IOAddr + regMediaStatus_4_w); |
811 | if((mstat & (1<<11)) == 0) { | |
812 | outputf("Valid link not established"); | |
813 | return 0; | |
814 | } | |
815 | ||
816 | /** Program the MAC address into the station address registers **/ | |
31ddf9b3 | 817 | _set_window(INF_3C90X.IOAddr, winAddressing2); |
c2e34447 JW |
818 | _outw(htons(eeprom[HWADDR_OFFSET + 0]), INF_3C90X.IOAddr + regStationAddress_2_3w); |
819 | _outw(htons(eeprom[HWADDR_OFFSET + 1]), INF_3C90X.IOAddr + regStationAddress_2_3w+2); | |
820 | _outw(htons(eeprom[HWADDR_OFFSET + 2]), INF_3C90X.IOAddr + regStationAddress_2_3w+4); | |
821 | _outw(0, INF_3C90X.IOAddr + regStationMask_2_3w+0); | |
822 | _outw(0, INF_3C90X.IOAddr + regStationMask_2_3w+2); | |
823 | _outw(0, INF_3C90X.IOAddr + regStationMask_2_3w+4); | |
748534f4 | 824 | |
748534f4 JP |
825 | /** Read the media options register, print a message and set default |
826 | ** xcvr. | |
827 | ** | |
828 | ** Uses Media Option command on B revision, Reset Option on non-B | |
829 | ** revision cards -- same register address | |
830 | **/ | |
31ddf9b3 | 831 | _set_window(INF_3C90X.IOAddr, winTxRxOptions3); |
748534f4 JP |
832 | mopt = inw(INF_3C90X.IOAddr + regResetMediaOptions_3_w); |
833 | ||
834 | /** mask out VCO bit that is defined as 10baseFL bit on B-rev cards **/ | |
835 | if (! INF_3C90X.isBrev) | |
836 | { | |
837 | mopt &= 0x7F; | |
838 | } | |
839 | ||
840 | outputf("Connectors present: "); | |
841 | c = 0; | |
842 | linktype = 0x0008; | |
843 | if (mopt & 0x01) | |
844 | { | |
80c7c8bf | 845 | outputf(" 100Base-T4"); |
748534f4 JP |
846 | linktype = 0x0006; |
847 | } | |
848 | if (mopt & 0x04) | |
849 | { | |
80c7c8bf | 850 | outputf(" 100Base-FX"); |
748534f4 JP |
851 | linktype = 0x0005; |
852 | } | |
853 | if (mopt & 0x10) | |
854 | { | |
80c7c8bf | 855 | outputf(" 10Base-2"); |
748534f4 JP |
856 | linktype = 0x0003; |
857 | } | |
858 | if (mopt & 0x20) | |
859 | { | |
80c7c8bf | 860 | outputf(" AUI"); |
748534f4 JP |
861 | linktype = 0x0001; |
862 | } | |
863 | if (mopt & 0x40) | |
864 | { | |
80c7c8bf | 865 | outputf(" MII"); |
748534f4 JP |
866 | linktype = 0x0006; |
867 | } | |
868 | if ((mopt & 0xA) == 0xA) | |
869 | { | |
80c7c8bf | 870 | outputf(" 10Base-T / 100Base-TX"); |
748534f4 JP |
871 | linktype = 0x0008; |
872 | } | |
873 | else if ((mopt & 0xA) == 0x2) | |
874 | { | |
80c7c8bf | 875 | outputf(" 100Base-TX"); |
748534f4 JP |
876 | linktype = 0x0008; |
877 | } | |
878 | else if ((mopt & 0xA) == 0x8) | |
879 | { | |
80c7c8bf | 880 | outputf(" 10Base-T"); |
748534f4 JP |
881 | linktype = 0x0008; |
882 | } | |
748534f4 JP |
883 | |
884 | /** Determine transceiver type to use, depending on value stored in | |
885 | ** eeprom 0x16 | |
886 | **/ | |
887 | if (INF_3C90X.isBrev) | |
888 | { | |
889 | if ((eeprom[0x16] & 0xFF00) == XCVR_MAGIC) | |
890 | { | |
891 | /** User-defined **/ | |
892 | linktype = eeprom[0x16] & 0x000F; | |
893 | } | |
894 | } | |
895 | else | |
896 | { | |
897 | #ifdef CFG_3C90X_XCVR | |
898 | if (CFG_3C90X_XCVR != 255) | |
899 | linktype = CFG_3C90X_XCVR; | |
900 | #endif /* CFG_3C90X_XCVR */ | |
901 | ||
902 | /** I don't know what MII MAC only mode is!!! **/ | |
903 | if (linktype == 0x0009) | |
904 | { | |
905 | if (INF_3C90X.isBrev) | |
906 | outputf("WARNING: MII External MAC Mode only supported on B-revision " | |
907 | "cards!!!!\nFalling Back to MII Mode\n"); | |
908 | linktype = 0x0006; | |
909 | } | |
910 | } | |
911 | ||
912 | /** enable DC converter for 10-Base-T **/ | |
913 | if (linktype == 0x0003) | |
914 | { | |
31ddf9b3 | 915 | _issue_command(INF_3C90X.IOAddr, cmdEnableDcConverter, 0); |
748534f4 JP |
916 | } |
917 | ||
918 | /** Set the link to the type we just determined. **/ | |
31ddf9b3 | 919 | _set_window(INF_3C90X.IOAddr, winTxRxOptions3); |
748534f4 JP |
920 | cfg = inl(INF_3C90X.IOAddr + regInternalConfig_3_l); |
921 | cfg &= ~(0xF<<20); | |
922 | cfg |= (linktype<<20); | |
c2e34447 | 923 | _outl(cfg, INF_3C90X.IOAddr + regInternalConfig_3_l); |
748534f4 JP |
924 | |
925 | /** Now that we set the xcvr type, reset the Tx and Rx, re-enable. **/ | |
31ddf9b3 | 926 | _issue_command(INF_3C90X.IOAddr, cmdTxReset, 0); |
748534f4 | 927 | if (!INF_3C90X.isBrev) |
c2e34447 | 928 | _outb(0x01, INF_3C90X.IOAddr + regTxFreeThresh_b); |
748534f4 | 929 | |
31ddf9b3 | 930 | _issue_command(INF_3C90X.IOAddr, cmdTxEnable, 0); |
748534f4 JP |
931 | |
932 | /** | |
933 | ** reset of the receiver on B-revision cards re-negotiates the link | |
934 | ** takes several seconds (a computer eternity) | |
935 | **/ | |
936 | if (INF_3C90X.isBrev) | |
31ddf9b3 | 937 | _issue_command(INF_3C90X.IOAddr, cmdRxReset, 0x04); |
748534f4 | 938 | else |
31ddf9b3 | 939 | _issue_command(INF_3C90X.IOAddr, cmdRxReset, 0x00); |
748534f4 JP |
940 | |
941 | /** Set the RX filter = receive only individual pkts & multicast & bcast. **/ | |
31ddf9b3 | 942 | _issue_command(INF_3C90X.IOAddr, cmdSetRxFilter, 0x01 + 0x02 + 0x04); |
80c7c8bf | 943 | |
bec09bd1 JW |
944 | /* Stick some packets in the queue. */ |
945 | _recv_prepare(&nic); | |
946 | ||
947 | /* And light up the RX engine. */ | |
948 | _issue_command(INF_3C90X.IOAddr, cmdRxEnable, 0); | |
748534f4 JP |
949 | |
950 | /** | |
951 | ** set Indication and Interrupt flags , acknowledge any IRQ's | |
952 | **/ | |
31ddf9b3 JW |
953 | _issue_command(INF_3C90X.IOAddr, cmdSetInterruptEnable, 0); |
954 | _issue_command(INF_3C90X.IOAddr, cmdSetIndicationEnable, 0x0014); | |
955 | _issue_command(INF_3C90X.IOAddr, cmdAcknowledgeInterrupt, 0x661); | |
748534f4 JP |
956 | |
957 | /* * Set our exported functions **/ | |
bc9e1044 JW |
958 | nic.recv = _recv; |
959 | nic.transmit = _transmit; | |
47c41031 | 960 | memcpy(nic.hwaddr, INF_3C90X.HWAddr, 6); |
c2e34447 | 961 | eth_register(&nic); |
748534f4 JP |
962 | |
963 | return 1; | |
964 | } | |
965 | ||
966 | static struct pci_id a3c90x_nics[] = { | |
967 | /* Original 90x revisions: */ | |
968 | PCI_ROM(0x10b7, 0x6055, "3c556", "3C556"), /* Huricane */ | |
969 | PCI_ROM(0x10b7, 0x9000, "3c905-tpo", "3Com900-TPO"), /* 10 Base TPO */ | |
970 | PCI_ROM(0x10b7, 0x9001, "3c905-t4", "3Com900-Combo"), /* 10/100 T4 */ | |
971 | PCI_ROM(0x10b7, 0x9050, "3c905-tpo100", "3Com905-TX"), /* 100 Base TX / 10/100 TPO */ | |
972 | PCI_ROM(0x10b7, 0x9051, "3c905-combo", "3Com905-T4"), /* 100 Base T4 / 10 Base Combo */ | |
973 | /* Newer 90xB revisions: */ | |
974 | PCI_ROM(0x10b7, 0x9004, "3c905b-tpo", "3Com900B-TPO"), /* 10 Base TPO */ | |
975 | PCI_ROM(0x10b7, 0x9005, "3c905b-combo", "3Com900B-Combo"), /* 10 Base Combo */ | |
976 | PCI_ROM(0x10b7, 0x9006, "3c905b-tpb2", "3Com900B-2/T"), /* 10 Base TP and Base2 */ | |
977 | PCI_ROM(0x10b7, 0x900a, "3c905b-fl", "3Com900B-FL"), /* 10 Base FL */ | |
978 | PCI_ROM(0x10b7, 0x9055, "3c905b-tpo100", "3Com905B-TX"), /* 10/100 TPO */ | |
979 | PCI_ROM(0x10b7, 0x9056, "3c905b-t4", "3Com905B-T4"), /* 10/100 T4 */ | |
980 | PCI_ROM(0x10b7, 0x9058, "3c905b-9058", "3Com905B-9058"), /* Cyclone 10/100/BNC */ | |
981 | PCI_ROM(0x10b7, 0x905a, "3c905b-fx", "3Com905B-FL"), /* 100 Base FX / 10 Base FX */ | |
982 | /* Newer 90xC revision: */ | |
983 | PCI_ROM(0x10b7, 0x9200, "3c905c-tpo", "3Com905C-TXM"), /* 10/100 TPO (3C905C-TXM) */ | |
984 | PCI_ROM(0x10b7, 0x9202, "3c920b-emb-ati", "3c920B-EMB-WNM (ATI Radeon 9100 IGP)"), /* 3c920B-EMB-WNM (ATI Radeon 9100 IGP) */ | |
985 | PCI_ROM(0x10b7, 0x9210, "3c920b-emb-wnm","3Com20B-EMB WNM"), | |
986 | PCI_ROM(0x10b7, 0x9800, "3c980", "3Com980-Cyclone"), /* Cyclone */ | |
987 | PCI_ROM(0x10b7, 0x9805, "3c9805", "3Com9805"), /* Dual Port Server Cyclone */ | |
988 | PCI_ROM(0x10b7, 0x7646, "3csoho100-tx", "3CSOHO100-TX"), /* Hurricane */ | |
989 | PCI_ROM(0x10b7, 0x4500, "3c450", "3Com450 HomePNA Tornado"), | |
990 | PCI_ROM(0x10b7, 0x1201, "3c982a", "3Com982A"), | |
991 | PCI_ROM(0x10b7, 0x1202, "3c982b", "3Com982B"), | |
992 | }; | |
993 | ||
994 | struct pci_driver a3c90x_driver = { | |
995 | .name = "3C90X", | |
996 | .probe = a3c90x_probe, | |
997 | .ids = a3c90x_nics, | |
998 | .id_count = sizeof(a3c90x_nics)/sizeof(a3c90x_nics[0]), | |
999 | }; |