FreeBSD/Linux Kernel Cross Reference
sys/pci/if_alreg.h
1 /*
2 * Copyright (c) 1997, 1998, 1999
3 * Bill Paul <wpaul@ctr.columbia.edu>. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. All advertising materials mentioning features or use of this software
14 * must display the following acknowledgement:
15 * This product includes software developed by Bill Paul.
16 * 4. Neither the name of the author nor the names of any co-contributors
17 * may be used to endorse or promote products derived from this software
18 * without specific prior written permission.
19 *
20 * THIS SOFTWARE IS PROVIDED BY Bill Paul AND CONTRIBUTORS ``AS IS'' AND
21 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 * ARE DISCLAIMED. IN NO EVENT SHALL Bill Paul OR THE VOICES IN HIS HEAD
24 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
30 * THE POSSIBILITY OF SUCH DAMAGE.
31 *
32 * $FreeBSD$
33 */
34
35 /*
36 * COMET register definitions.
37 */
38
39 #define AL_BUSCTL 0x00 /* bus control */
40 #define AL_TXSTART 0x08 /* tx start demand */
41 #define AL_RXSTART 0x10 /* rx start demand */
42 #define AL_RXADDR 0x18 /* rx descriptor list start addr */
43 #define AL_TXADDR 0x20 /* tx descriptor list start addr */
44 #define AL_ISR 0x28 /* interrupt status register */
45 #define AL_NETCFG 0x30 /* network config register */
46 #define AL_IMR 0x38 /* interrupt mask */
47 #define AL_FRAMESDISCARDED 0x40 /* # of discarded frames */
48 #define AL_SIO 0x48 /* MII and ROM/EEPROM access */
49 #define AL_RESERVED 0x50
50 #define AL_GENTIMER 0x58 /* general timer */
51 #define AL_GENPORT 0x60 /* general purpose port */
52 #define AL_WAKEUP_CTL 0x68 /* wake-up control/status register */
53 #define AL_WAKEUP_PAT 0x70 /* wake-up pattern data register */
54 #define AL_WATCHDOG 0x78 /* watchdog timer */
55 #define AL_ISR2 0x80 /* ISR assist register */
56 #define AL_IMR2 0x84 /* IRM assist register */
57 #define AL_COMMAND 0x88 /* command register */
58 #define AL_PCIPERF 0x8C /* pci perf counter */
59 #define AL_PWRMGMT 0x90 /* pwr management command/status */
60 #define AL_TXBURST 0x9C /* tx burst counter/timeout */
61 #define AL_FLASHPROM 0xA0 /* flash(boot) PROM port */
62 #define AL_PAR0 0xA4 /* station address */
63 #define AL_PAR1 0xA8 /* station address */
64 #define AL_MAR0 0xAC /* multicast hash filter */
65 #define AL_MAR1 0xB0 /* multicast hash filter */
66 #define AL_BMCR 0xB4 /* built in PHY control */
67 #define AL_BMSR 0xB8 /* built in PHY status */
68 #define AL_VENID 0xBC /* built in PHY ID0 */
69 #define AL_DEVID 0xC0 /* built in PHY ID1 */
70 #define AL_ANAR 0xC4 /* built in PHY autoneg advert */
71 #define AL_LPAR 0xC8 /* bnilt in PHY link part. ability */
72 #define AL_ANER 0xCC /* built in PHY autoneg expansion */
73 #define AL_PHY_MODECTL 0xD0 /* mode control */
74 #define AL_PHY_CONFIG 0xD4 /* config info and inter status */
75 #define AL_PHY_INTEN 0xD8 /* interrupto enable */
76 #define AL_PHY_MODECTL_100TX 0xDC /* 100baseTX control/status */
77
78 /*
79 * Bus control bits.
80 */
81 #define AL_BUSCTL_RESET 0x00000001
82 #define AL_BUSCTL_ARBITRATION 0x00000002
83 #define AL_BUSCTL_SKIPLEN 0x0000007C
84 #define AL_BUSCTL_BIGENDIAN 0x00000080
85 #define AL_BUSCTL_BURSTLEN 0x00003F00
86 #define AL_BUSCTL_CACHEALIGN 0x0000C000
87 #define AL_BUSCTL_XMITPOLL 0x00060000
88 #define AL_BUSCTL_BUF_BIGENDIAN 0x00100000
89 #define AL_BUSCTL_READMULTI 0x00200000
90 #define AL_BUSCTL_READLINE 0x00800000
91 #define AL_BUSCTL_WRITEINVAL 0x01000000
92
93 #define AL_SKIPLEN_1LONG 0x00000004
94 #define AL_SKIPLEN_2LONG 0x00000008
95 #define AL_SKIPLEN_3LONG 0x00000010
96 #define AL_SKIPLEN_4LONG 0x00000020
97 #define AL_SKIPLEN_5LONG 0x00000040
98
99 #define AL_BURSTLEN_UNLIMIT 0x00000000
100 #define AL_BURSTLEN_1LONG 0x00000100
101 #define AL_BURSTLEN_2LONG 0x00000200
102 #define AL_BURSTLEN_4LONG 0x00000400
103 #define AL_BURSTLEN_8LONG 0x00000800
104 #define AL_BURSTLEN_16LONG 0x00001000
105 #define AL_BURSTLEN_32LONG 0x00002000
106
107 #define AL_CACHEALIGN_NONE 0x00000000
108 #define AL_CACHEALIGN_8LONG 0x00004000
109 #define AL_CACHEALIGN_16LONG 0x00008000
110 #define AL_CACHEALIGN_32LONG 0x0000C000
111
112 #define AL_TXPOLL_OFF 0x00000000
113 #define AL_TXPOLL_200U 0x00020000
114 #define AX_TXPOLL_800U 0x00040000
115 #define AL_TXPOLL_1600U 0x00060000
116
117 /*
118 * Interrupt status bits.
119 */
120 #define AL_ISR_TX_OK 0x00000001
121 #define AL_ISR_TX_IDLE 0x00000002
122 #define AL_ISR_TX_NOBUF 0x00000004
123 #define AL_ISR_TX_JABBERTIMEO 0x00000008
124 #define AL_ISR_TX_UNDERRUN 0x00000020
125 #define AL_ISR_RX_OK 0x00000040
126 #define AL_ISR_RX_NOBUF 0x00000080
127 #define AL_ISR_RX_IDLE 0x00000100
128 #define AL_ISR_RX_WATDOGTIMEO 0x00000200
129 #define AL_ISR_TIMER_EXPIRED 0x00000800
130 #define AL_ISR_BUS_ERR 0x00002000
131 #define AL_ISR_ABNORMAL 0x00008000
132 #define AL_ISR_NORMAL 0x00010000
133 #define AL_ISR_RX_STATE 0x000E0000
134 #define AL_ISR_TX_STATE 0x00700000
135 #define AL_ISR_BUSERRTYPE 0x03800000
136
137 #define AL_RXSTATE_STOPPED 0x00000000 /* 000 - Stopped */
138 #define AL_RXSTATE_FETCH 0x00020000 /* 001 - Fetching descriptor */
139 #define AL_RXSTATE_ENDCHECK 0x00040000 /* 010 - check for rx end */
140 #define AL_RXSTATE_WAIT 0x00060000 /* 011 - waiting for packet */
141 #define AL_RXSTATE_SUSPEND 0x00080000 /* 100 - suspend rx */
142 #define AL_RXSTATE_CLOSE 0x000A0000 /* 101 - close tx desc */
143 #define AL_RXSTATE_FLUSH 0x000C0000 /* 110 - flush from FIFO */
144 #define AL_RXSTATE_DEQUEUE 0x000E0000 /* 111 - dequeue from FIFO */
145
146 #define AL_TXSTATE_RESET 0x00000000 /* 000 - reset */
147 #define AL_TXSTATE_FETCH 0x00100000 /* 001 - fetching descriptor */
148 #define AL_TXSTATE_WAITEND 0x00200000 /* 010 - wait for tx end */
149 #define AL_TXSTATE_READING 0x00300000 /* 011 - read and enqueue */
150 #define AL_TXSTATE_RSVD 0x00400000 /* 100 - reserved */
151 #define AL_TXSTATE_SETUP 0x00500000 /* 101 - setup packet */
152 #define AL_TXSTATE_SUSPEND 0x00600000 /* 110 - suspend tx */
153 #define AL_TXSTATE_CLOSE 0x00700000 /* 111 - close tx desc */
154
155 /*
156 * Network config bits.
157 */
158 #define AL_NETCFG_RX_ON 0x00000002
159 #define AL_NETCFG_RX_BADFRAMES 0x00000008
160 #define AL_NETCFG_RX_BACKOFF 0x00000020
161 #define AL_NETCFG_RX_PROMISC 0x00000040
162 #define AL_NETCFG_RX_ALLMULTI 0x00000080
163 #define AL_NETCFG_OPMODE 0x00000C00
164 #define AL_NETCFG_FORCECOLL 0x00001000
165 #define AL_NETCFG_TX_ON 0x00002000
166 #define AL_NETCFG_TX_THRESH 0x0000C000
167 #define AL_NETCFG_HEARTBEAT 0x00080000 /* 0 == ON, 1 == OFF */
168 #define AL_NETCFG_STORENFWD 0x00200000
169
170 #define AL_OPMODE_NORM 0x00000000
171 #define AL_OPMODE_INTLOOP 0x00000400
172 #define AL_OPMODE_EXTLOOP 0x00000800
173
174 #define AL_TXTHRESH_72BYTES 0x00000000
175 #define AL_TXTHRESH_96BYTES 0x00004000
176 #define AL_TXTHRESH_128BYTES 0x00008000
177 #define AL_TXTHRESH_160BYTES 0x0000C000
178
179 /*
180 * Interrupt mask bits.
181 */
182 #define AL_IMR_TX_OK 0x00000001
183 #define AL_IMR_TX_IDLE 0x00000002
184 #define AL_IMR_TX_NOBUF 0x00000004
185 #define AL_IMR_TX_JABBERTIMEO 0x00000008
186 #define AL_IMR_TX_UNDERRUN 0x00000020
187 #define AL_IMR_RX_OK 0x00000040
188 #define AL_IMR_RX_NOBUF 0x00000080
189 #define AL_IMR_RX_IDLE 0x00000100
190 #define AL_IMR_RX_WATDOGTIMEO 0x00000200
191 #define AL_IMR_TIMER_EXPIRED 0x00000800
192 #define AL_IMR_BUS_ERR 0x00002000
193 #define AL_IMR_ABNORMAL 0x00008000
194 #define AL_IMR_NORMAL 0x00010000
195
196 #define AL_INTRS \
197 (AL_IMR_RX_OK|AL_IMR_TX_OK|AL_IMR_RX_NOBUF|AL_IMR_RX_WATDOGTIMEO|\
198 AL_IMR_TX_NOBUF|AL_IMR_TX_UNDERRUN|AL_IMR_BUS_ERR| \
199 AL_IMR_ABNORMAL|AL_IMR_NORMAL|AL_IMR_TX_IDLE|AL_IMR_RX_IDLE)
200
201 /*
202 * Missed packer register.
203 */
204 #define AL_MISSEDPKT_CNT 0x0000FFFF
205 #define AL_MISSEDPKT_OFLOW 0x00010000
206
207 /*
208 * Serial I/O (EEPROM/ROM) bits.
209 */
210 #define AL_SIO_EE_CS 0x00000001 /* EEPROM chip select */
211 #define AL_SIO_EE_CLK 0x00000002 /* EEPROM clock */
212 #define AL_SIO_EE_DATAIN 0x00000004 /* EEPROM data output */
213 #define AL_SIO_EE_DATAOUT 0x00000008 /* EEPROM data input */
214 #define AL_SIO_EESEL 0x00000800
215 #define AL_SIO_ROMCTL_WRITE 0x00002000
216 #define AL_SIO_ROMCTL_READ 0x00004000
217 #define AL_SIO_MII_CLK 0x00010000 /* MDIO clock */
218 #define AL_SIO_MII_DATAOUT 0x00020000 /* MDIO data out */
219 #define AL_SIO_MII_DIR 0x00040000 /* MDIO dir */
220 #define AL_SIO_MII_DATAIN 0x00080000 /* MDIO data in */
221
222 #define AL_EECMD_WRITE 0x140
223 #define AL_EECMD_READ 0x180
224 #define AL_EECMD_ERASE 0x1c0
225
226 #define AL_EE_NODEADDR_OFFSET 0x70
227 #define AL_EE_NODEADDR 4
228
229 /*
230 * General purpose timer register
231 */
232 #define AL_TIMER_VALUE 0x0000FFFF
233 #define AL_TIMER_CONTINUOUS 0x00010000
234
235 /*
236 * Wakeup control/status register.
237 */
238 #define AL_WU_LINKSTS 0x00000001 /* link status changed */
239 #define AL_WU_MAGICPKT 0x00000002 /* magic packet received */
240 #define AL_WU_WUPKT 0x00000004 /* wake up pkt received */
241 #define AL_WU_LINKSTS_ENB 0x00000100 /* enable linksts event */
242 #define AL_WU_MAGICPKT_ENB 0x00000200 /* enable magicpkt event */
243 #define AL_WU_WUPKT_ENB 0x00000400 /* enable wakeup pkt event */
244 #define AL_WU_LINKON_ENB 0x00010000 /* enable link on detect */
245 #define AL_WU_LINKOFF_ENB 0x00020000 /* enable link off detect */
246 #define AL_WU_WKUPMATCH_PAT5 0x02000000 /* enable wkup pat 5 match */
247 #define AL_WU_WKUPMATCH_PAT4 0x04000000 /* enable wkup pat 4 match */
248 #define AL_WU_WKUPMATCH_PAT3 0x08000000 /* enable wkup pat 3 match */
249 #define AL_WU_WKUPMATCH_PAT2 0x10000000 /* enable wkup pat 2 match */
250 #define AL_WU_WKUPMATCH_PAT1 0x20000000 /* enable wkup pat 1 match */
251 #define AL_WU_CRCTYPE 0x40000000 /* crc: 0=0000, 1=ffff */
252
253 /*
254 * Wakeup pattern structure.
255 */
256 struct al_wu_pattern {
257 u_int32_t al_wu_bits[4];
258 };
259
260 struct al_wakeup {
261 struct al_wu_pattern al_wu_pat;
262 u_int16_t al_wu_crc1;
263 u_int16_t al_wu_offset1;
264 };
265
266 struct al_wakup_record {
267 struct al_wakeup al_wakeup[5];
268 };
269
270 /*
271 * Watchdog timer register.
272 */
273 #define AL_WDOG_JABDISABLE 0x00000001
274 #define AL_WDOG_NONJABBER 0x00000002
275 #define AL_WDOG_JABCLK 0x00000004
276 #define AL_WDOG_RXWDOG_DIS 0x00000010
277 #define AL_WDOG_RXWDOG_REL 0x00000020
278
279 /*
280 * Assistant status register.
281 */
282 #define AL_ISR2_ABNORMAL 0x00008000
283 #define AL_ISR2_NORMAL 0x00010000
284 #define AL_ISR2_RX_STATE 0x000E0000
285 #define AL_ISR2_TX_STATE 0x00700000
286 #define AL_ISR2_BUSERRTYPE 0x03800000
287 #define AL_ISR2_PAUSE 0x04000000 /* PAUSE frame received */
288 #define AL_ISR2_TX_DEFER 0x10000000
289 #define AL_ISR2_XCVR_INT 0x20000000
290 #define AL_ISR2_RX_EARLY 0x40000000
291 #define AL_ISR2_TX_EARLY 0x80000000
292
293 /*
294 * Assistant mask register.
295 */
296 #define AL_IMR2_ABNORMAL 0x00008000
297 #define AL_IMR2_NORMAL 0x00010000
298 #define AL_IMR2_PAUSE 0x04000000 /* PAUSE frame received */
299 #define AL_IMR2_TX_DEFER 0x10000000
300 #define AL_IMR2_XCVR_INT 0x20000000
301 #define AL_IMR2_RX_EARLY 0x40000000
302 #define AL_IMR2_TX_EARLY 0x80000000
303
304 /*
305 * Command register, some bits loaded from EEPROM.
306 */
307 #define AL_CMD_TXURUN_REC 0x00000001 /* enable TX underflow recovery */
308 #define AL_CMD_SOFTWARE_INT 0x00000002 /* software interrupt */
309 #define AL_CMD_DRT 0x0000000C /* drain receive threshold */
310 #define AL_CMD_RXTHRESH_ENB 0x00000010 /* rx threshold enable */
311 #define AL_CMD_PAUSE 0x00000020
312 #define AL_CMD_RST_WU_PTR 0x00000040 /* reset wakeup pattern reg. */
313 /* Values below loaded from EEPROM. */
314 #define AL_CMD_WOL_ENB 0x00040000 /* WOL enable */
315 #define AL_CMD_PM_ENB 0x00080000 /* pwr mgmt enable */
316 #define AL_CMD_RX_FIFO 0x00300000
317 #define AL_CMD_LED_MODE 0x00400000
318 #define AL_CMD_CURRENT_MODE 0x70000000
319 #define AL_CMD_D3COLD 0x80000000
320
321 /*
322 * PCI performance counter.
323 */
324 #define AL_PCI_DW_CNT 0x000000FF
325 #define AL_PCI_CLK 0xFFFF0000
326
327 /*
328 * Power management command and status.
329 */
330 #define AL_PWRM_PWR_STATE 0x00000003
331 #define AL_PWRM_PME_EN 0x00000100
332 #define AL_PWRM_DSEL 0x00001E00
333 #define AL_PWRM_DSCALE 0x00006000
334 #define AL_PWRM_PME_STAT 0x00008000
335
336 /*
337 * TX burst count / timeout register.
338 */
339 #define AL_TXB_TIMEO 0x00000FFF
340 #define AL_TXB_BURSTCNT 0x0000F000
341
342 /*
343 * Flash PROM register.
344 */
345 #define AL_PROM_DATA 0x0000000F
346 #define AL_PROM_ADDR 0x01FFFFF0
347 #define AL_PROM_WR_ENB 0x04000000
348 #define AL_PROM_BRA16_ON 0x80000000
349
350 /*
351 * COMET TX/RX list structure.
352 */
353
354 struct al_desc {
355 volatile u_int32_t al_status;
356 volatile u_int32_t al_ctl;
357 volatile u_int32_t al_ptr1;
358 volatile u_int32_t al_ptr2;
359 };
360
361 #define al_data al_ptr1
362 #define al_next al_ptr2
363
364 #define AL_RXSTAT_FIFOOFLOW 0x00000001
365 #define AL_RXSTAT_CRCERR 0x00000002
366 #define AL_RXSTAT_DRIBBLE 0x00000004
367 #define AL_RXSTAT_WATCHDOG 0x00000010
368 #define AL_RXSTAT_FRAMETYPE 0x00000020 /* 0 == IEEE 802.3 */
369 #define AL_RXSTAT_COLLSEEN 0x00000040
370 #define AL_RXSTAT_GIANT 0x00000080
371 #define AL_RXSTAT_LASTFRAG 0x00000100
372 #define AL_RXSTAT_FIRSTFRAG 0x00000200
373 #define AL_RXSTAT_MULTICAST 0x00000400
374 #define AL_RXSTAT_RUNT 0x00000800
375 #define AL_RXSTAT_RXTYPE 0x00003000
376 #define AL_RXSTAT_RXERR 0x00008000
377 #define AL_RXSTAT_RXLEN 0x3FFF0000
378 #define AL_RXSTAT_OWN 0x80000000
379
380 #define AL_RXBYTES(x) ((x & AL_RXSTAT_RXLEN) >> 16)
381 #define AL_RXSTAT (AL_RXSTAT_FIRSTFRAG|AL_RXSTAT_LASTFRAG|AL_RXSTAT_OWN)
382
383 #define AL_RXCTL_BUFLEN1 0x00000FFF
384 #define AL_RXCTL_BUFLEN2 0x00FFF000
385 #define AL_RXCTL_RLAST 0x02000000
386
387 #define AL_TXSTAT_DEFER 0x00000001
388 #define AL_TXSTAT_UNDERRUN 0x00000002
389 #define AL_TXSTAT_LINKFAIL 0x00000003
390 #define AL_TXSTAT_COLLCNT 0x00000078
391 #define AL_TXSTAT_SQE 0x00000080
392 #define AL_TXSTAT_EXCESSCOLL 0x00000100
393 #define AL_TXSTAT_LATECOLL 0x00000200
394 #define AL_TXSTAT_NOCARRIER 0x00000400
395 #define AL_TXSTAT_CARRLOST 0x00000800
396 #define AL_TXSTAT_JABTIMEO 0x00004000
397 #define AL_TXSTAT_ERRSUM 0x00008000
398 #define AL_TXSTAT_OWN 0x80000000
399
400 #define AL_TXCTL_BUFLEN1 0x000007FF
401 #define AL_TXCTL_BUFLEN2 0x003FF800
402 #define AL_TXCTL_PAD 0x00800000
403 #define AL_TXCTL_TLINK 0x01000000
404 #define AL_TXCTL_TLAST 0x02000000
405 #define AL_TXCTL_NOCRC 0x04000000
406 #define AL_TXCTL_FIRSTFRAG 0x20000000
407 #define AL_TXCTL_LASTFRAG 0x40000000
408 #define AL_TXCTL_FINT 0x80000000
409
410 #define AL_MAXFRAGS 16
411 #define AL_RX_LIST_CNT 64
412 #define AL_TX_LIST_CNT 128
413 #define AL_MIN_FRAMELEN 60
414
415 /*
416 * A tx 'super descriptor' is actually 16 regular descriptors
417 * back to back.
418 */
419 struct al_txdesc {
420 volatile struct al_desc al_frag[AL_MAXFRAGS];
421 };
422
423 #define AL_TXNEXT(x) x->al_ptr->al_frag[x->al_lastdesc].al_next
424 #define AL_TXSTATUS(x) x->al_ptr->al_frag[x->al_lastdesc].al_status
425 #define AL_TXCTL(x) x->al_ptr->al_frag[x->al_lastdesc].al_ctl
426 #define AL_TXDATA(x) x->al_ptr->al_frag[x->al_lastdesc].al_data
427
428 #define AL_TXOWN(x) x->al_ptr->al_frag[0].al_status
429
430 #define AL_UNSENT 0x12341234
431
432 struct al_list_data {
433 volatile struct al_desc al_rx_list[AL_RX_LIST_CNT];
434 volatile struct al_txdesc al_tx_list[AL_TX_LIST_CNT];
435 };
436
437 struct al_chain {
438 volatile struct al_txdesc *al_ptr;
439 struct mbuf *al_mbuf;
440 struct al_chain *al_nextdesc;
441 u_int8_t al_lastdesc;
442 };
443
444 struct al_chain_onefrag {
445 volatile struct al_desc *al_ptr;
446 struct mbuf *al_mbuf;
447 struct al_chain_onefrag *al_nextdesc;
448 };
449
450 struct al_chain_data {
451 struct al_chain_onefrag al_rx_chain[AL_RX_LIST_CNT];
452 struct al_chain al_tx_chain[AL_TX_LIST_CNT];
453
454 struct al_chain_onefrag *al_rx_head;
455
456 struct al_chain *al_tx_head;
457 struct al_chain *al_tx_tail;
458 struct al_chain *al_tx_free;
459 };
460
461 struct al_type {
462 u_int16_t al_vid;
463 u_int16_t al_did;
464 char *al_name;
465 };
466
467 struct al_mii_frame {
468 u_int8_t mii_stdelim;
469 u_int8_t mii_opcode;
470 u_int8_t mii_phyaddr;
471 u_int8_t mii_regaddr;
472 u_int8_t mii_turnaround;
473 u_int16_t mii_data;
474 };
475
476 /*
477 * MII constants
478 */
479 #define AL_MII_STARTDELIM 0x01
480 #define AL_MII_READOP 0x02
481 #define AL_MII_WRITEOP 0x01
482 #define AL_MII_TURNAROUND 0x02
483
484 #define AL_FLAG_FORCEDELAY 1
485 #define AL_FLAG_SCHEDDELAY 2
486 #define AL_FLAG_DELAYTIMEO 3
487
488 struct al_softc {
489 struct arpcom arpcom; /* interface info */
490 struct ifmedia ifmedia; /* media info */
491 bus_space_handle_t al_bhandle; /* bus space handle */
492 bus_space_tag_t al_btag; /* bus space tag */
493 struct al_type *al_info; /* COMET adapter info */
494 struct al_type *al_pinfo; /* phy info */
495 u_int8_t al_unit; /* interface number */
496 u_int8_t al_type;
497 u_int8_t al_phy_addr; /* PHY address */
498 u_int8_t al_tx_pend; /* TX pending */
499 u_int8_t al_want_auto;
500 u_int8_t al_autoneg;
501 caddr_t al_ldata_ptr;
502 struct al_list_data *al_ldata;
503 struct al_chain_data al_cdata;
504 u_int8_t al_cachesize;
505 };
506
507 /*
508 * register space access macros
509 */
510 #define CSR_WRITE_4(sc, reg, val) \
511 bus_space_write_4(sc->al_btag, sc->al_bhandle, reg, val)
512 #define CSR_WRITE_2(sc, reg, val) \
513 bus_space_write_2(sc->al_btag, sc->al_bbhandle, reg, val)
514 #define CSR_WRITE_1(sc, reg, val) \
515 bus_space_write_1(sc->al_btag, sc->al_bhandle, reg, val)
516
517 #define CSR_READ_4(sc, reg) \
518 bus_space_read_4(sc->al_btag, sc->al_bhandle, reg)
519 #define CSR_READ_2(sc, reg) \
520 bus_space_read_2(sc->al_btag, sc->al_bhandle, reg)
521 #define CSR_READ_1(sc, reg) \
522 bus_space_read_1(sc->al_btag, sc->al_bhandle, reg)
523
524 #define AL_TIMEOUT 1000
525
526 /*
527 * General constants that are fun to know.
528 *
529 * ADMtek PCI vendor ID
530 */
531 #define AL_VENDORID 0x1317
532
533 /*
534 * AL981 device IDs.
535 */
536 #define AL_DEVICEID_AL981 0x0981
537
538 /*
539 * AN985 device ID.
540 */
541 #define AL_DEVICEID_AN985 0x0985
542
543 /*
544 * Texas Instruments PHY identifiers
545 */
546 #define TI_PHY_VENDORID 0x4000
547 #define TI_PHY_10BT 0x501F
548 #define TI_PHY_100VGPMI 0x502F
549
550 /*
551 * These ID values are for the NS DP83840A 10/100 PHY
552 */
553 #define NS_PHY_VENDORID 0x2000
554 #define NS_PHY_83840A 0x5C0F
555
556 /*
557 * Level 1 10/100 PHY
558 */
559 #define LEVEL1_PHY_VENDORID 0x7810
560 #define LEVEL1_PHY_LXT970 0x000F
561
562 /*
563 * Intel 82555 10/100 PHY
564 */
565 #define INTEL_PHY_VENDORID 0x0A28
566 #define INTEL_PHY_82555 0x015F
567
568 /*
569 * SEEQ 80220 10/100 PHY
570 */
571 #define SEEQ_PHY_VENDORID 0x0016
572 #define SEEQ_PHY_80220 0xF83F
573
574
575 /*
576 * PCI low memory base and low I/O base register, and
577 * other PCI registers.
578 */
579
580 #define AL_PCI_VENDOR_ID 0x00
581 #define AL_PCI_DEVICE_ID 0x02
582 #define AL_PCI_COMMAND 0x04
583 #define AL_PCI_STATUS 0x06
584 #define AL_PCI_REVID 0x08
585 #define AL_PCI_CLASSCODE 0x09
586 #define AL_PCI_CACHELEN 0x0C
587 #define AL_PCI_LATENCY_TIMER 0x0D
588 #define AL_PCI_HEADER_TYPE 0x0E
589 #define AL_PCI_LOIO 0x10
590 #define AL_PCI_LOMEM 0x14
591 #define AL_PCI_BIOSROM 0x30
592 #define AL_PCI_INTLINE 0x3C
593 #define AL_PCI_INTPIN 0x3D
594 #define AL_PCI_MINGNT 0x3E
595 #define AL_PCI_MINLAT 0x0F
596 #define AL_PCI_RESETOPT 0x48
597 #define AL_PCI_EEPROM_DATA 0x4C
598
599 /* power management registers */
600 #define AL_PCI_CAPID 0x44 /* 8 bits */
601 #define AL_PCI_NEXTPTR 0x45 /* 8 bits */
602 #define AL_PCI_PWRMGMTCAP 0x46 /* 16 bits */
603 #define AL_PCI_PWRMGMTCTRL 0x48 /* 16 bits */
604
605 #define AL_PSTATE_MASK 0x0003
606 #define AL_PSTATE_D0 0x0000
607 #define AL_PSTATE_D1 0x0001
608 #define AL_PSTATE_D2 0x0002
609 #define AL_PSTATE_D3 0x0003
610 #define AL_PME_EN 0x0010
611 #define AL_PME_STATUS 0x8000
612
613 #define PHY_UNKNOWN 6
614
615 #define AL_PHYADDR_MIN 0x00
616 #define AL_PHYADDR_MAL 0x1F
617
618 #define PHY_BMCR 0x00
619 #define PHY_BMSR 0x01
620 #define PHY_VENID 0x02
621 #define PHY_DEVID 0x03
622 #define PHY_ANAR 0x04
623 #define PHY_LPAR 0x05
624 #define PHY_ANEXP 0x06
625
626 #define PHY_ANAR_NEXTPAGE 0x8000
627 #define PHY_ANAR_RSVD0 0x4000
628 #define PHY_ANAR_TLRFLT 0x2000
629 #define PHY_ANAR_RSVD1 0x1000
630 #define PHY_ANAR_RSVD2 0x0800
631 #define PHY_ANAR_RSVD3 0x0400
632 #define PHY_ANAR_100BT4 0x0200
633 #define PHY_ANAR_100BTXFULL 0x0100
634 #define PHY_ANAR_100BTXHALF 0x0080
635 #define PHY_ANAR_10BTFULL 0x0040
636 #define PHY_ANAR_10BTHALF 0x0020
637 #define PHY_ANAR_PROTO4 0x0010
638 #define PHY_ANAR_PROTO3 0x0008
639 #define PHY_ANAR_PROTO2 0x0004
640 #define PHY_ANAR_PROTO1 0x0002
641 #define PHY_ANAR_PROTO0 0x0001
642
643 /*
644 * These are the register definitions for the PHY (physical layer
645 * interface chip).
646 */
647 /*
648 * PHY BMCR Basic Mode Control Register
649 */
650 #define PHY_BMCR_RESET 0x8000
651 #define PHY_BMCR_LOOPBK 0x4000
652 #define PHY_BMCR_SPEEDSEL 0x2000
653 #define PHY_BMCR_AUTONEGENBL 0x1000
654 #define PHY_BMCR_RSVD0 0x0800 /* write as zero */
655 #define PHY_BMCR_ISOLATE 0x0400
656 #define PHY_BMCR_AUTONEGRSTR 0x0200
657 #define PHY_BMCR_DUPLEX 0x0100
658 #define PHY_BMCR_COLLTEST 0x0080
659 #define PHY_BMCR_RSVD1 0x0040 /* write as zero, don't care */
660 #define PHY_BMCR_RSVD2 0x0020 /* write as zero, don't care */
661 #define PHY_BMCR_RSVD3 0x0010 /* write as zero, don't care */
662 #define PHY_BMCR_RSVD4 0x0008 /* write as zero, don't care */
663 #define PHY_BMCR_RSVD5 0x0004 /* write as zero, don't care */
664 #define PHY_BMCR_RSVD6 0x0002 /* write as zero, don't care */
665 #define PHY_BMCR_RSVD7 0x0001 /* write as zero, don't care */
666 /*
667 * RESET: 1 == software reset, 0 == normal operation
668 * Resets status and control registers to default values.
669 * Relatches all hardware config values.
670 *
671 * LOOPBK: 1 == loopback operation enabled, 0 == normal operation
672 *
673 * SPEEDSEL: 1 == 100Mb/s, 0 == 10Mb/s
674 * Link speed is selected byt his bit or if auto-negotiation if bit
675 * 12 (AUTONEGENBL) is set (in which case the value of this register
676 * is ignored).
677 *
678 * AUTONEGENBL: 1 == Autonegotiation enabled, 0 == Autonegotiation disabled
679 * Bits 8 and 13 are ignored when autoneg is set, otherwise bits 8 and 13
680 * determine speed and mode. Should be cleared and then set if PHY configured
681 * for no autoneg on startup.
682 *
683 * ISOLATE: 1 == isolate PHY from MII, 0 == normal operation
684 *
685 * AUTONEGRSTR: 1 == restart autonegotiation, 0 = normal operation
686 *
687 * DUPLEX: 1 == full duplex mode, 0 == half duplex mode
688 *
689 * COLLTEST: 1 == collision test enabled, 0 == normal operation
690 */
691
692 /*
693 * PHY, BMSR Basic Mode Status Register
694 */
695 #define PHY_BMSR_100BT4 0x8000
696 #define PHY_BMSR_100BTXFULL 0x4000
697 #define PHY_BMSR_100BTXHALF 0x2000
698 #define PHY_BMSR_10BTFULL 0x1000
699 #define PHY_BMSR_10BTHALF 0x0800
700 #define PHY_BMSR_RSVD1 0x0400 /* write as zero, don't care */
701 #define PHY_BMSR_RSVD2 0x0200 /* write as zero, don't care */
702 #define PHY_BMSR_RSVD3 0x0100 /* write as zero, don't care */
703 #define PHY_BMSR_RSVD4 0x0080 /* write as zero, don't care */
704 #define PHY_BMSR_MFPRESUP 0x0040
705 #define PHY_BMSR_AUTONEGCOMP 0x0020
706 #define PHY_BMSR_REMFAULT 0x0010
707 #define PHY_BMSR_CANAUTONEG 0x0008
708 #define PHY_BMSR_LINKSTAT 0x0004
709 #define PHY_BMSR_JABBER 0x0002
710 #define PHY_BMSR_EXTENDED 0x0001
711
712 #ifdef __alpha__
713 #undef vtophys
714 #define vtophys(va) (pmap_kextract(((vm_offset_t) (va))) \
715 + 1*1024*1024*1024)
716 #endif
Cache object: c98e53b1b3137c5990c18edc37d7b959
|