4 * check xcvr10Base2 still works (is GlobalReset necessary?).
7 #include "../port/lib.h"
12 #include "../port/error.h"
13 #include "../port/netif.h"
17 enum { /* all windows */
24 SelectRegisterWindow = 0x0001,
27 AcknowledgeInterrupt = 0x000D,
30 enum { /* IntStatus bits */
31 commandInProgress = 0x1000,
34 #define COMMAND(port, cmd, a) outs((port)+CommandR, ((cmd)<<11)|(a))
35 #define STATUS(port) ins((port)+IntStatusR)
37 enum { /* Window 0 - setup */
40 ManufacturerID = 0x0000, /* 3C5[08]*, 3C59[27] */
41 ProductID = 0x0002, /* 3C5[08]*, 3C59[27] */
42 ConfigControl = 0x0004, /* 3C5[08]*, 3C59[27] */
43 AddressConfig = 0x0006, /* 3C5[08]*, 3C59[27] */
44 ResourceConfig = 0x0008, /* 3C5[08]*, 3C59[27] */
45 EepromCommand = 0x000A,
47 /* AddressConfig Bits */
50 /* ConfigControl bits */
52 base10TAvailable9 = 0x0200,
53 coaxAvailable9 = 0x1000,
54 auiAvailable9 = 0x2000,
55 /* EepromCommand bits */
56 EepromReadRegister = 0x0080,
60 enum { /* Window 1 - operating set */
64 enum { /* Window 3 - FIFO management */
67 InternalConfig = 0x0000, /* 3C509B, 3C589, 3C59[0257] */
68 /* InternalConfig bits */
69 xcvr10BaseT = 0x00000000,
70 xcvr10Base2 = 0x00300000,
73 enum { /* Window 4 - diagnostic */
77 /* MediaStatus bits */
78 linkBeatDetect = 0x0800,
81 extern int etherelnk3reset(Ether*);
83 static char *tcmpcmcia[] = {
84 "3C589", /* 3COM 589[ABCD] */
85 "3C562", /* 3COM 562 */
86 "589E", /* 3COM Megahertz 589E */
91 configASIC(Ether* ether, int port, int xcvr)
95 /* set Window 0 configuration registers */
96 COMMAND(port, SelectRegisterWindow, Wsetup);
97 outs(port+ConfigControl, Ena);
99 /* IRQ must be 3 on 3C589/3C562 */
100 outs(port + ResourceConfig, 0x3F00);
102 x = ins(port+AddressConfig) & ~xcvrMask9;
104 outs(port+AddressConfig, x);
106 COMMAND(port, TxReset, 0);
107 while(STATUS(port) & commandInProgress)
109 COMMAND(port, RxReset, 0);
110 while(STATUS(port) & commandInProgress)
113 return etherelnk3reset(ether);
122 enum { WantAny, Want10BT, Want10B2 };
133 if(ioalloc(port, 0x10, 0, "3C589") < 0)
138 for(i = 0; tcmpcmcia[i] != nil; i++){
140 if((slot = pcmspecial(type, ether)) >= 0)
143 ether->type = type; /* must be set before calling configASIC */
150 * Read Ethernet address from card memory
151 * on 3C562, but only if the user has not
154 memset(ea, 0, sizeof ea);
155 if(memcmp(ea, ether->ea, 6) == 0 && strcmp(type, "3C562") == 0) {
156 if(pcmcistuple(slot, 0x88, -1, ea, 6) == 6) {
157 for(i = 0; i < 6; i += 2){
162 memmove(ether->ea, ea, 6);
166 * Allow user to specify desired media in plan9.ini
169 for(i = 0; i < ether->nopt; i++){
170 if(cistrncmp(ether->opt[i], "media=", 6) != 0)
173 if(cistrcmp(p, "10base2") == 0)
175 else if(cistrcmp(p, "10baseT") == 0)
179 /* try configuring as a 10BaseT */
180 if(want==WantAny || want==Want10BT){
181 if(configASIC(ether, port, xcvr10BaseT) < 0){
182 pcmspecialclose(slot);
187 COMMAND(port, SelectRegisterWindow, Wdiagnostic);
188 if((ins(port+MediaStatus)&linkBeatDetect) || want==Want10BT){
189 COMMAND(port, SelectRegisterWindow, Wop);
190 print("#l%d: xcvr10BaseT %s\n", ether->ctlrno, type);
195 /* try configuring as a 10base2 */
196 if(want==WantAny || want==Want10B2){
197 COMMAND(port, GlobalReset, 0);
198 if(configASIC(ether, port, xcvr10Base2) < 0){
199 pcmspecialclose(slot);
203 print("#l%d: xcvr10Base2 %s\n", ether->ctlrno, type);
206 return -1; /* not reached */
212 addethercard("3C589", reset);
213 addethercard("3C562", reset);
214 addethercard("589E", reset);