source: mainline/uspace/drv/nic/rtl8169/defs.h@ 9d653e3

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since 9d653e3 was 9d653e3, checked in by Agnieszka Tabaka <nufcia@…>, 11 years ago

Refactored interrupt handling routine to check interrupt status bits
in loop until all interrupt conditions are serviced.

  • Property mode set to 100644
File size: 12.5 KB
Line 
1/*
2 * Copyright (c) 2014 Agnieszka Tabaka
3 * Copyright (c) 2011 Jiri Michalec
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 *
10 * - Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * - Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * - The name of the author may not be used to endorse or promote products
16 * derived from this software without specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
19 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
20 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
22 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
23 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 */
29
30/** @file rtl8169_defs.h
31 *
32 * Registers, bit positions and masks definition
33 * of the RTL8169 network family cards
34 */
35
36#ifndef RTL8169_DEFS_H_
37#define RTL8169_DEFS_H_
38
39#include <sys/types.h>
40#include <ddi.h>
41
42/** Size of RTL8169 registers address space */
43#define RTL8169_IO_SIZE 256
44
45#define RTL8169_FRAME_MAX_LENGTH 1518
46
47/** Registers of RTL8169 family card offsets from the memory address base */
48enum rtl8169_registers {
49 IDR0 = 0x00, /**< First MAC address bit, 6 1b registres sequence */
50 MAC0 = IDR0, /**< Alias for IDR0 */
51 /* 0x06 - 0x07 reserved */
52 MAR0 = 0x08, /**< Multicast mask registers 8 1b registers sequence */
53 DTCCR = 0x10, /**< Dump Tally Counter Command Register */
54 TNPDS = 0x20, /**< Transmit Normal Priority Descriptors */
55 THPDS = 0x28, /**< Transmit High Priority Descriptors */
56 FLASH = 0x30, /**< Flash memory read/write register */
57 ERBCR = 0x34, /**< Early Receive Byte Count Register */
58 ERSR = 0x36, /**< Early Rx Status Register */
59 CR = 0x37, /**< Command register, 1b */
60 TPPOLL = 0x38, /**< Transmit Priority Polling Register */
61 CBA = 0x3a, /**< Current buffer address, 2b */
62 IMR = 0x3c, /**< Interrupt mask register, 2b */
63 ISR = 0x3e, /**< Interrupt status register, 2b */
64 TCR = 0x40, /**< Transmit (Tx) configuration register, 4b */
65 RCR = 0x44, /**< Receive (Rx) configuration register, 4b */
66 TCTR = 0x48, /**< Timer count register */
67 MPC = 0x4c, /**< Missed packet count */
68 CR9346 = 0x50, /**< 93C46 command register (locking of registers) */
69 CONFIG0 = 0x51, /**< Configuration register 0, 1b */
70 CONFIG1 = 0x52, /**< Configuration register 1, 1b */
71 CONFIG2 = 0x53, /**< Configuration register 2, 1b */
72 CONFIG3 = 0x54, /**< Configuration register 3, 1b */
73 CONFIG4 = 0x55, /**< Configuration register 4, 1b */
74 CONFIG5 = 0x56, /**< Configuration register 5, 1b */
75 /* 0x57 reserved */
76 TIMINT = 0x58, /**< Timer interrupt register, 4b */
77 MULINT = 0x58, /**< Multiple interrupt select, 4b */
78 /* 0x5e-0x5f reserved */
79 PHYAR = 0x60, /**< PHY Access Register, 4b */
80 TBICSR0 = 0x64, /**< TBI Control and Status Register, 4b */
81 TBI_ANAR = 0x58, /**< TBI Auto-Negotiation Advertisement Register, 2b */
82 TBI_LPAR = 0x6a, /**< TBI Auto-Negotiation Link Partner Ability Register, 2b */
83 PHYSTATUS = 0x6c, /**< PHY Status Register */
84 /* 0x6d-0x83 reserved */
85 WAKEUP0 = 0x84, /**< Power Management Wakeup frame0, 8b */
86 WAKEUP1 = 0x8c, /**< Power Management Wakeup frame1, 8b */
87 WAKEUP2LD = 0x94, /**< Power Management Wakeup frame2 low dword, 8b */
88 WAKEUP2HD = 0x9c, /**< Power Management Wakeup frame2 high dword, 8b */
89 WAKEUP3LD = 0xa4, /**< Power Management Wakeup frame3 low dword, 8b */
90 WAKEUP3HD = 0xac, /**< Power Management Wakeup frame3 high dword, 8b */
91 WAKEUP4LD = 0xb4, /**< Power Management Wakeup frame4 low dword, 8b */
92 WAKEUP4HD = 0xbc, /**< Power Management Wakeup frame4 high dword, 8b */
93 CRC0 = 0xc4, /**< 16-bit CRC of wakeup frame 0, 2b */
94 CRC1 = 0xc6, /**< 16-bit CRC of wakeup frame 1, 2b */
95 CRC2 = 0xc8, /**< 16-bit CRC of wakeup frame 2, 2b */
96 CRC3 = 0xca, /**< 16-bit CRC of wakeup frame 3, 2b */
97 CRC4 = 0xcc, /**< 16-bit CRC of wakeup frame 4, 2b */
98 /* 0xce - 0xd9 reserved */
99 RMS = 0xda, /**< Rx packet Maximum Size, 2b */
100 /* 0xdc - 0xdf reserved */
101 CCR = 0xe0, /**< C+ Command Register */
102 /* 0xe2 - 0xe3 reserved */
103 RDSAR = 0xe4, /**< Receive Descriptor Start Address Register, 8b */
104 ETTHR = 0xec, /**< Early Transmit Threshold Register, 1b */
105 /* 0xed - 0xef reserved */
106 FER = 0xf0, /**< Function Event Register, 4b */
107 FEMR = 0xf4, /**< Function Event Mask Register, 4b */
108 FPSR = 0xf8, /**< Function Preset State Register, 4b */
109 FFER = 0xfc, /**< Function Force Event Register, 4b */
110};
111
112/** Command register bits */
113enum rtl8169_cr {
114 CR_TE = (1 << 2), /**< Transmitter enable bit */
115 CR_RE = (1 << 3), /**< Receiver enable bit */
116 CR_RST = (1 << 4), /**< Reset - set to 1 to force software reset */
117};
118
119/** Config1 register bits */
120enum rtl8169_config1 {
121 CONFIG1_LEDS_SHIFT = 6, /**< Shift of CONFIG1_LEDS bits */
122 CONFIG1_LEDS_SIZE = 2, /**< Size of CONFIG1_LEDS bits */
123 CONFIG1_DVRLOAD = (1 << 5), /**< Driver load */
124 CONFIG1_LWACT = (1 << 4), /**< LWAKE active mode */
125 CONFIG1_MEMMAP = (1 << 3), /**< Memory mapping */
126 CONFIG1_IOMAP = (1 << 2), /**< I/O space mapping */
127 CONFIG1_VPD = (1 << 1), /**< Set to enable Vital Product Data */
128 CONFIG1_PMEn = (1 << 0) /**< Power management enabled */
129};
130
131enum rtl8169_config2 {
132 CONFIG2_AUXSTATUS = (1 << 4), /**< Auxiliary Power Present Status */
133 CONFIG2_PCIBUSWIDTH = (1 << 3), /**< PCI Bus Width */
134 CONFIG2_PCICLKF_SHIFT = 0,
135 CONFIG2_PCICLKF_SIZE = 2
136};
137
138enum rtl8169_config3 {
139 CONFIG3_GNT_SELECT = (1 << 7), /**< Gnt select */
140 CONFIG3_PARM_EN = (1 << 6), /**< Parameter enabled (100MBit mode) */
141 CONFIG3_MAGIC = (1 << 5), /**< WoL Magic frame enable */
142 CONFIG3_LINK_UP = (1 << 4), /**< Wakeup if link is reestablished */
143 CONFIG3_CLKRUN_EN = (1 << 2), /**< CLKRUN enabled */ /* TODO: check what does it mean */
144 CONFIG3_FBTBEN = (1 << 0), /**< Fast back to back enabled */
145};
146
147enum rtl8169_config4 {
148 CONFIG4_RxFIFOAutoClr = (1 << 7), /**< Automatic RxFIFO owerflow clear */
149 CONFIG4_AnaOff = (1 << 6), /**< Analog poweroff */
150 CONFIG4_LongWF = (1 << 5), /**< Long wakeup frame */
151 CONFIG4_LWPME = (1 << 4), /**< LWAKE and PMEB assertion */
152 CONFIG4_LWPTN = (1 << 2), /**< LWake pattern */
153 CONFIG4_PBWakeup = (1 << 0), /**< Preboot wakeup */
154};
155
156enum rtl8169_config5 {
157 CONFIG5_BROADCAST_WAKEUP = (1 << 6), /**< Broadcast wakeup frame enable */
158 CONFIG5_MULTICAST_WAKEUP = (1 << 5), /**< Multicast wakeup frame enable */
159 CONFIG5_UNICAST_WAKEUP = (1 << 4), /**< Unicast wakeup frame enable */
160 /* Bits 3-2 reserved */
161 CONFIG5_LAN_WAKE = (1 << 1), /**< LANWake signal enabled */
162 CONFIG5_PME_STATUS = (1 << 0), /**< PMEn change: 0 = SW, 1 = SW+PCI */
163};
164
165/** Interrupt_masks
166 *
167 * The masks are the same for both IMR and ISR
168 */
169enum rtl8169_interrupts {
170 INT_SERR = (1 << 15), /**< System error interrupt */
171 INT_TIME_OUT = (1 << 14), /**< Time out interrupt */
172 /* Bits 9 - 13 reserved */
173 INT_SW = (1 << 8), /**< Software Interrupt */
174 INT_TDU = (1 << 7), /**< Tx Descriptor Unvailable */
175 INT_FIFOOVW = (1 << 6), /**< Receiver FIFO overflow interrupt */
176 INT_PUN = (1 << 5), /**< Packet Underrun/Link Change Interrupt */
177 INT_RXOVW = (1 << 4), /**< Receiver buffer overflow */
178 INT_TER = (1 << 3), /**< Transmit error interrupt */
179 INT_TOK = (1 << 2), /**< Transmit OK interrupt */
180 INT_RER = (1 << 1), /**< Receive error interrupt */
181 INT_ROK = (1 << 0), /**< Receive OK interrupt */
182 INT_KNOWN = (INT_SERR | INT_TIME_OUT | INT_SW | INT_TDU \
183 | INT_FIFOOVW | INT_PUN | INT_RXOVW | INT_TER \
184 | INT_TOK| INT_RER | INT_ROK),
185};
186
187/** Transmit status descriptor registers bits */
188enum rtl8169_tsd {
189 TSD_CRS = (1 << 31), /**< Carrier Sense Lost */
190 TSD_TABT = (1 << 30), /**< Transmit Abort */
191 TSD_OWC = (1 << 29), /**< Out of Window Collision */
192 TSD_CDH = (1 << 28), /**< CD Heart Beat */
193 TSD_NCC_SHIFT = 24, /**< Collision Count - bit shift */
194 TSD_NCC_SIZE = 4, /**< Collision Count - bit size */
195 TSD_NCC_MASK = (1 << 4)-1, /**< Collision Count - bit size */
196 TSD_ERTXTH_SHIFT = 16, /**< Early Tx Threshold - bit shift */
197 TSD_ERTXTH_SIZE = 6, /**< Early Tx Treshold - bit size */
198 TSD_TOK = (1 << 15), /**< Transmit OK */
199 TSD_TUN = (1 << 14), /**< Transmit FIFO Underrun */
200 TSD_OWN = (1 << 13), /**< OWN */
201 TSD_SIZE_SHIFT = 0, /**< Size - bit shift */
202 TSD_SIZE_SIZE = 13, /**< Size - bit size */
203 TSD_SIZE_MASK = 0x1fff, /**< Size - bit mask */
204};
205
206/** Receiver control register values */
207enum rtl8169_rcr {
208 RCR_MulERINT = 1 << 24, /**< Multiple early interrupt select */
209 /* Bits 23-17 reserved */
210 RCR_RER8 = 1 << 16,
211 RCR_RXFTH_SHIFT = 13, /**< Rx FIFO treshold part shitf */
212 RCR_RXFTH_SIZE = 3, /**< Rx FIFO treshold part size */
213 /* Bits 12-11 reserved */
214 RCR_MXDMA_SHIFT = 8, /**< Max DMA Burst Size part shift */
215 RCR_MXDMA_SIZE = 3, /**< Max DMA Burst Size part size */
216 /* Bit 7 reserved */
217 RCR_ACCEPT_ERROR = 1 << 5, /**< Accept error frame */
218 RCR_ACCEPT_RUNT = 1 << 4, /**< Accept Runt (8-64 bytes) frames */
219 RCR_ACCEPT_BROADCAST = 1 << 3, /**< Accept broadcast */
220 RCR_ACCEPT_MULTICAST = 1 << 2, /**< Accept multicast */
221 RCR_ACCEPT_PHYS_MATCH = 1 << 1, /**< Accept device MAC address match */
222 RCR_ACCEPT_ALL_PHYS = 1 << 0, /**< Accept all frames with phys. desticnation */
223 RCR_ACCEPT_MASK = (1 << 6) - 1 /**< Mask of accept part */
224};
225
226enum rtl8169_cr9346 {
227 CR9346EEM1_SHIFT = 6, /**< RTL8169 operating mode shift */
228 CR9346EEM1_SIZE = 2, /**< RTL8169 operating mode mask */
229 /* Bits 5-4 reserved */
230 EECS = (1 << 3), /**< EECS pin of 93C46 */
231 EESK = (1 << 2), /**< EESK pin of 93C46 */
232 EEDI = (1 << 1), /**< EEDI pin of 93C46 */
233 EEDO = (1 << 0), /**< EEDO pin of 93C46 */
234};
235
236/** Auto-negotiation advertisement register */
237enum rtl8169_anar {
238 ANAR_NEXT_PAGE = (1 << 15), /**< Next page bit, 0 - primary capability */
239 ANAR_ACK = (1 << 14), /**< Capability reception acknowledge */
240 ANAR_REMOTE_FAULT = (1 << 13), /**< Remote fault detection capability */
241 ANAR_PAUSE = (1 << 10), /**< Symetric pause frame capability */
242 ANAR_100T4 = (1 << 9), /**< T4, not supported by the device */
243 ANAR_100TX_FD = (1 << 8), /**< 100BASE_TX full duplex */
244 ANAR_100TX_HD = (1 << 7), /**< 100BASE_TX half duplex */
245 ANAR_10_FD = (1 << 6), /**< 10BASE_T full duplex */
246 ANAR_10_HD = (1 << 5), /**< 10BASE_T half duplex */
247 ANAR_SELECTOR = 0x1, /**< Selector */
248};
249
250enum rtl8169_phystatus {
251 PHYSTATUS_TBIEN = (1 << 7), /**< TBI enabled */
252 PHYSTATUS_TXFLOW = (1 << 6), /**< TX flow control enabled */
253 PHYSTATUS_RXFLOW = (1 << 5), /**< RX flow control enabled */
254 PHYSTATUS_1000M = (1 << 4), /**< Link speed is 1000Mbit/s */
255 PHYSTATUS_100M = (1 << 3), /**< Link speed is 100Mbit/s */
256 PHYSTATUS_10M = (1 << 2), /**< Link speed is 10Mbit/s */
257 PHYSTATUS_LINK = (1 << 1), /**< Link up */
258 PHYSTATUS_FDX = (1 << 0), /**< Link is full duplex */
259};
260
261enum rtl8169_tppoll {
262 TPPOLL_HPQ = (1 << 7), /**< Start transmit on high priority queue */
263 TPPOLL_NPQ = (1 << 6), /**< Start transmit on normal queue */
264 /* Bits 5-1 reserved */
265 TPPOLL_FSWINT = (1 << 0), /** < Generate software interrupt */
266};
267
268enum rtl8169_descr_control {
269 CONTROL_OWN = (1 << 31), /**< Descriptor ownership */
270 CONTROL_EOR = (1 << 30), /**< End Of Ring marker */
271 CONTROL_FS = (1 << 29), /**< First Segment marker */
272 CONTROL_LS = (1 << 28), /**< Last Segment marker */
273 CONTROL_LGSEN = (1 << 27), /**< Large send enable */
274 CONTROL_MSS_SHIFT = 16,
275 CONTROL_MSS_MASK = 10,
276 CONTROL_FRAMELEN_MASK = 0xffff
277};
278
279enum rtl8169_descr_txstatus {
280 TXSTATUS_UNDERRUN = (1 << 25),
281 TXSTATUS_TXERRSUM = (1 << 23),
282 TXSTATUS_OWINCOL = (1 << 22),
283 TXSTATUS_LINKFAIL = (1 << 21),
284 TXSTATUS_EXCESSCOL = (1 << 20)
285};
286
287enum rtl8169_descr_rxstatus {
288 RXSTATUS_MAR = (1 << 27),
289 RXSTATUS_PAM = (1 << 26),
290 RXSTATUS_BAR = (1 << 25),
291 RXSTATUS_BOVF = (1 << 24),
292 RXSTATUS_FOVF = (1 << 23),
293 RXSTATUS_RWT = (1 << 22),
294 RXSTATUS_RES = (1 << 21),
295 RXSTATUS_RUNT = (1 << 20),
296 RXSTATUS_CRC = (1 << 19),
297 RXSTATUS_PID1 = (1 << 18),
298 RXSTATUS_PID0 = (1 << 17),
299 RXSTATUS_IPF = (1 << 16),
300 RXSTATUS_UDPF = (1 << 15),
301 RXSTATUS_TCPF = (1 << 14)
302};
303
304typedef struct rtl8169_descr {
305 uint32_t control;
306 uint32_t vlan;
307 uint32_t buf_low;
308 uint32_t buf_high;
309} rtl8169_descr_t;
310
311#endif
Note: See TracBrowser for help on using the repository browser.