]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - sys/dev/dwc/if_dwc.h
contrib/bsddialog: Import version 0.4
[FreeBSD/FreeBSD.git] / sys / dev / dwc / if_dwc.h
1 /*-
2  * Copyright (c) 2014 Ruslan Bukin <br@bsdpad.com>
3  * All rights reserved.
4  *
5  * This software was developed by SRI International and the University of
6  * Cambridge Computer Laboratory under DARPA/AFRL contract (FA8750-10-C-0237)
7  * ("CTSRD"), as part of the DARPA CRASH research programme.
8  *
9  * Redistribution and use in source and binary forms, with or without
10  * modification, are permitted provided that the following conditions
11  * are met:
12  * 1. Redistributions of source code must retain the above copyright
13  *    notice, this list of conditions and the following disclaimer.
14  * 2. Redistributions in binary form must reproduce the above copyright
15  *    notice, this list of conditions and the following disclaimer in the
16  *    documentation and/or other materials provided with the distribution.
17  *
18  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
19  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
22  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28  * SUCH DAMAGE.
29  *
30  * $FreeBSD$
31  */
32
33 /*
34  * Register names were taken almost as is from the documentation.
35  */
36
37 #ifndef __IF_DWC_H__
38 #define __IF_DWC_H__
39
40 #define PHY_MODE_UNKNOWN        0x0
41 #define PHY_MODE_RMII           0x1
42 #define PHY_MODE_RGMII          0x2
43 #define PHY_MODE_MII            0x3
44
45 #define MAC_CONFIGURATION       0x0
46 #define  CONF_JD                (1 << 22)       /* jabber timer disable */
47 #define  CONF_BE                (1 << 21)       /* Frame Burst Enable */
48 #define  CONF_PS                (1 << 15)       /* GMII/MII */
49 #define  CONF_FES               (1 << 14)       /* MII speed select */
50 #define  CONF_DM                (1 << 11)       /* Full Duplex Enable */
51 #define  CONF_IPC               (1 << 10)       /* IPC checksum offload */
52 #define  CONF_ACS               (1 << 7)
53 #define  CONF_TE                (1 << 3)
54 #define  CONF_RE                (1 << 2)
55 #define MAC_FRAME_FILTER        0x4
56 #define  FRAME_FILTER_RA        (1U << 31)      /* Receive All */
57 #define  FRAME_FILTER_HPF       (1 << 10)       /* Hash or Perfect Filter */
58 #define  FRAME_FILTER_PM        (1 << 4)        /* Pass multicast */
59 #define  FRAME_FILTER_HMC       (1 << 2)
60 #define  FRAME_FILTER_HUC       (1 << 1)
61 #define  FRAME_FILTER_PR        (1 << 0)        /* All Incoming Frames */
62 #define GMAC_MAC_HTHIGH         0x08
63 #define GMAC_MAC_HTLOW          0x0c
64 #define GMII_ADDRESS            0x10
65 #define  GMII_ADDRESS_PA_MASK   0x1f            /* Phy device */
66 #define  GMII_ADDRESS_PA_SHIFT  11
67 #define  GMII_ADDRESS_GR_MASK   0x1f            /* Phy register */
68 #define  GMII_ADDRESS_GR_SHIFT  6
69 #define  GMII_ADDRESS_CR_MASK   0xf
70 #define  GMII_ADDRESS_CR_SHIFT  2               /* Clock */
71 #define  GMII_ADDRESS_GW        (1 << 1)        /* Write operation */
72 #define  GMII_ADDRESS_GB        (1 << 0)        /* Busy */
73 #define GMII_DATA               0x14
74 #define FLOW_CONTROL            0x18
75 #define  FLOW_CONTROL_PT_SHIFT  16
76 #define  FLOW_CONTROL_UP        (1 << 3)        /* Unicast pause enable */
77 #define  FLOW_CONTROL_RX        (1 << 2)        /* RX Flow control enable */
78 #define  FLOW_CONTROL_TX        (1 << 1)        /* TX Flow control enable */
79 #define GMAC_VLAN_TAG           0x1C
80 #define VERSION                 0x20
81 #define DEBUG                   0x24
82 #define LPI_CONTROL_STATUS      0x30
83 #define LPI_TIMERS_CONTROL      0x34
84 #define INTERRUPT_STATUS        0x38
85 #define INTERRUPT_MASK          0x3C
86 #define MAC_ADDRESS_HIGH(n)     ((n > 15 ? 0x800 : 0x40) + 0x8 * n)
87 #define MAC_ADDRESS_LOW(n)      ((n > 15 ? 0x804 : 0x44) + 0x8 * n)
88
89 #define SGMII_RGMII_SMII_CTRL_STATUS    0xD8
90 #define MMC_CONTROL                     0x100
91 #define  MMC_CONTROL_CNTRST             (1 << 0)
92 #define MMC_RECEIVE_INTERRUPT           0x104
93 #define MMC_TRANSMIT_INTERRUPT          0x108
94 #define MMC_RECEIVE_INTERRUPT_MASK      0x10C
95 #define MMC_TRANSMIT_INTERRUPT_MASK     0x110
96 #define TXOCTETCOUNT_GB                 0x114
97 #define TXFRAMECOUNT_GB                 0x118
98 #define TXBROADCASTFRAMES_G             0x11C
99 #define TXMULTICASTFRAMES_G             0x120
100 #define TX64OCTETS_GB                   0x124
101 #define TX65TO127OCTETS_GB              0x128
102 #define TX128TO255OCTETS_GB             0x12C
103 #define TX256TO511OCTETS_GB             0x130
104 #define TX512TO1023OCTETS_GB            0x134
105 #define TX1024TOMAXOCTETS_GB            0x138
106 #define TXUNICASTFRAMES_GB              0x13C
107 #define TXMULTICASTFRAMES_GB            0x140
108 #define TXBROADCASTFRAMES_GB            0x144
109 #define TXUNDERFLOWERROR                0x148
110 #define TXSINGLECOL_G                   0x14C
111 #define TXMULTICOL_G                    0x150
112 #define TXDEFERRED                      0x154
113 #define TXLATECOL                       0x158
114 #define TXEXESSCOL                      0x15C
115 #define TXCARRIERERR                    0x160
116 #define TXOCTETCNT                      0x164
117 #define TXFRAMECOUNT_G                  0x168
118 #define TXEXCESSDEF                     0x16C
119 #define TXPAUSEFRAMES                   0x170
120 #define TXVLANFRAMES_G                  0x174
121 #define TXOVERSIZE_G                    0x178
122 #define RXFRAMECOUNT_GB                 0x180
123 #define RXOCTETCOUNT_GB                 0x184
124 #define RXOCTETCOUNT_G                  0x188
125 #define RXBROADCASTFRAMES_G             0x18C
126 #define RXMULTICASTFRAMES_G             0x190
127 #define RXCRCERROR                      0x194
128 #define RXALIGNMENTERROR                0x198
129 #define RXRUNTERROR                     0x19C
130 #define RXJABBERERROR                   0x1A0
131 #define RXUNDERSIZE_G                   0x1A4
132 #define RXOVERSIZE_G                    0x1A8
133 #define RX64OCTETS_GB                   0x1AC
134 #define RX65TO127OCTETS_GB              0x1B0
135 #define RX128TO255OCTETS_GB             0x1B4
136 #define RX256TO511OCTETS_GB             0x1B8
137 #define RX512TO1023OCTETS_GB            0x1BC
138 #define RX1024TOMAXOCTETS_GB            0x1C0
139 #define RXUNICASTFRAMES_G               0x1C4
140 #define RXLENGTHERROR                   0x1C8
141 #define RXOUTOFRANGETYPE                0x1CC
142 #define RXPAUSEFRAMES                   0x1D0
143 #define RXFIFOOVERFLOW                  0x1D4
144 #define RXVLANFRAMES_GB                 0x1D8
145 #define RXWATCHDOGERROR                 0x1DC
146 #define RXRCVERROR                      0x1E0
147 #define RXCTRLFRAMES_G                  0x1E4
148 #define MMC_IPC_RECEIVE_INT_MASK        0x200
149 #define MMC_IPC_RECEIVE_INT             0x208
150 #define RXIPV4_GD_FRMS                  0x210
151 #define RXIPV4_HDRERR_FRMS              0x214
152 #define RXIPV4_NOPAY_FRMS               0x218
153 #define RXIPV4_FRAG_FRMS                0x21C
154 #define RXIPV4_UDSBL_FRMS               0x220
155 #define RXIPV6_GD_FRMS                  0x224
156 #define RXIPV6_HDRERR_FRMS              0x228
157 #define RXIPV6_NOPAY_FRMS               0x22C
158 #define RXUDP_GD_FRMS                   0x230
159 #define RXUDP_ERR_FRMS                  0x234
160 #define RXTCP_GD_FRMS                   0x238
161 #define RXTCP_ERR_FRMS                  0x23C
162 #define RXICMP_GD_FRMS                  0x240
163 #define RXICMP_ERR_FRMS                 0x244
164 #define RXIPV4_GD_OCTETS                0x250
165 #define RXIPV4_HDRERR_OCTETS            0x254
166 #define RXIPV4_NOPAY_OCTETS             0x258
167 #define RXIPV4_FRAG_OCTETS              0x25C
168 #define RXIPV4_UDSBL_OCTETS             0x260
169 #define RXIPV6_GD_OCTETS                0x264
170 #define RXIPV6_HDRERR_OCTETS            0x268
171 #define RXIPV6_NOPAY_OCTETS             0x26C
172 #define RXUDP_GD_OCTETS                 0x270
173 #define RXUDP_ERR_OCTETS                0x274
174 #define RXTCP_GD_OCTETS                 0x278
175 #define RXTCPERROCTETS                  0x27C
176 #define RXICMP_GD_OCTETS                0x280
177 #define RXICMP_ERR_OCTETS               0x284
178 #define L3_L4_CONTROL0                  0x400
179 #define LAYER4_ADDRESS0                 0x404
180 #define LAYER3_ADDR0_REG0               0x410
181 #define LAYER3_ADDR1_REG0               0x414
182 #define LAYER3_ADDR2_REG0               0x418
183 #define LAYER3_ADDR3_REG0               0x41C
184 #define L3_L4_CONTROL1                  0x430
185 #define LAYER4_ADDRESS1                 0x434
186 #define LAYER3_ADDR0_REG1               0x440
187 #define LAYER3_ADDR1_REG1               0x444
188 #define LAYER3_ADDR2_REG1               0x448
189 #define LAYER3_ADDR3_REG1               0x44C
190 #define L3_L4_CONTROL2                  0x460
191 #define LAYER4_ADDRESS2                 0x464
192 #define LAYER3_ADDR0_REG2               0x470
193 #define LAYER3_ADDR1_REG2               0x474
194 #define LAYER3_ADDR2_REG2               0x478
195 #define LAYER3_ADDR3_REG2               0x47C
196 #define L3_L4_CONTROL3                  0x490
197 #define LAYER4_ADDRESS3                 0x494
198 #define LAYER3_ADDR0_REG3               0x4A0
199 #define LAYER3_ADDR1_REG3               0x4A4
200 #define LAYER3_ADDR2_REG3               0x4A8
201 #define LAYER3_ADDR3_REG3               0x4AC
202 #define HASH_TABLE_REG(n)               0x500 + (0x4 * n)
203 #define VLAN_INCL_REG                   0x584
204 #define VLAN_HASH_TABLE_REG             0x588
205 #define TIMESTAMP_CONTROL               0x700
206 #define SUB_SECOND_INCREMENT            0x704
207 #define SYSTEM_TIME_SECONDS             0x708
208 #define SYSTEM_TIME_NANOSECONDS         0x70C
209 #define SYSTEM_TIME_SECONDS_UPDATE      0x710
210 #define SYSTEM_TIME_NANOSECONDS_UPDATE  0x714
211 #define TIMESTAMP_ADDEND                0x718
212 #define TARGET_TIME_SECONDS             0x71C
213 #define TARGET_TIME_NANOSECONDS         0x720
214 #define SYSTEM_TIME_HIGHER_WORD_SECONDS 0x724
215 #define TIMESTAMP_STATUS                0x728
216 #define PPS_CONTROL                     0x72C
217 #define AUXILIARY_TIMESTAMP_NANOSECONDS 0x730
218 #define AUXILIARY_TIMESTAMP_SECONDS     0x734
219 #define PPS0_INTERVAL                   0x760
220 #define PPS0_WIDTH                      0x764
221
222 /* DMA */
223 #define BUS_MODE                0x1000
224 #define  BUS_MODE_EIGHTXPBL     (1 << 24) /* Multiplies PBL by 8 */
225 #define  BUS_MODE_USP           (1 << 23)
226 #define  BUS_MODE_RPBL_SHIFT    17 /* Single block transfer size */
227 #define  BUS_MODE_FIXEDBURST    (1 << 16)
228 #define  BUS_MODE_PRIORXTX_SHIFT        14
229 #define  BUS_MODE_PRIORXTX_41   3
230 #define  BUS_MODE_PRIORXTX_31   2
231 #define  BUS_MODE_PRIORXTX_21   1
232 #define  BUS_MODE_PRIORXTX_11   0
233 #define  BUS_MODE_PBL_SHIFT     8 /* Single block transfer size */
234 #define  BUS_MODE_SWR           (1 << 0) /* Reset */
235 #define  BUS_MODE_DEFAULT_PBL   8
236 #define TRANSMIT_POLL_DEMAND    0x1004
237 #define RECEIVE_POLL_DEMAND     0x1008
238 #define RX_DESCR_LIST_ADDR      0x100C
239 #define TX_DESCR_LIST_ADDR      0x1010
240 #define DMA_STATUS              0x1014
241 #define  DMA_STATUS_NIS         (1 << 16)
242 #define  DMA_STATUS_AIS         (1 << 15)
243 #define  DMA_STATUS_FBI         (1 << 13)
244 #define  DMA_STATUS_RI          (1 << 6)
245 #define  DMA_STATUS_TI          (1 << 0)
246 #define  DMA_STATUS_INTR_MASK   0x1ffff
247 #define OPERATION_MODE          0x1018
248 #define  MODE_RSF               (1 << 25) /* RX Full Frame */
249 #define  MODE_TSF               (1 << 21) /* TX Full Frame */
250 #define  MODE_FTF               (1 << 20) /* Flush TX FIFO */
251 #define  MODE_ST                (1 << 13) /* Start DMA TX */
252 #define  MODE_FUF               (1 << 6)  /* TX frames < 64bytes */
253 #define  MODE_RTC_LEV32         0x1
254 #define  MODE_RTC_SHIFT         3
255 #define  MODE_OSF               (1 << 2) /* Process Second frame */
256 #define  MODE_SR                (1 << 1) /* Start DMA RX */
257 #define INTERRUPT_ENABLE        0x101C
258 #define  INT_EN_NIE             (1 << 16) /* Normal/Summary */
259 #define  INT_EN_AIE             (1 << 15) /* Abnormal/Summary */
260 #define  INT_EN_ERE             (1 << 14) /* Early receive */
261 #define  INT_EN_FBE             (1 << 13) /* Fatal bus error */
262 #define  INT_EN_ETE             (1 << 10) /* Early transmit */
263 #define  INT_EN_RWE             (1 << 9)  /* Receive watchdog */
264 #define  INT_EN_RSE             (1 << 8)  /* Receive stopped */
265 #define  INT_EN_RUE             (1 << 7)  /* Recv buf unavailable */
266 #define  INT_EN_RIE             (1 << 6)  /* Receive interrupt */
267 #define  INT_EN_UNE             (1 << 5)  /* Tx underflow */
268 #define  INT_EN_OVE             (1 << 4)  /* Receive overflow */
269 #define  INT_EN_TJE             (1 << 3)  /* Transmit jabber */
270 #define  INT_EN_TUE             (1 << 2)  /* Tx. buf unavailable */
271 #define  INT_EN_TSE             (1 << 1)  /* Transmit stopped */
272 #define  INT_EN_TIE             (1 << 0)  /* Transmit interrupt */
273 #define  INT_EN_DEFAULT         (INT_EN_TIE|INT_EN_RIE| \
274             INT_EN_NIE|INT_EN_AIE|                      \
275             INT_EN_FBE|INT_EN_UNE)
276
277 #define MISSED_FRAMEBUF_OVERFLOW_CNTR   0x1020
278 #define RECEIVE_INT_WATCHDOG_TMR        0x1024
279 #define AXI_BUS_MODE                    0x1028
280 #define AHB_OR_AXI_STATUS               0x102C
281 #define CURRENT_HOST_TRANSMIT_DESCR     0x1048
282 #define CURRENT_HOST_RECEIVE_DESCR      0x104C
283 #define CURRENT_HOST_TRANSMIT_BUF_ADDR  0x1050
284 #define CURRENT_HOST_RECEIVE_BUF_ADDR   0x1054
285 #define HW_FEATURE                      0x1058
286
287 #define DWC_GMAC_NORMAL_DESC            0x1
288 #define DWC_GMAC_EXT_DESC               0x2
289
290 #define GMAC_MII_CLK_60_100M_DIV42      0x0
291 #define GMAC_MII_CLK_100_150M_DIV62     0x1
292 #define GMAC_MII_CLK_25_35M_DIV16       0x2
293 #define GMAC_MII_CLK_35_60M_DIV26       0x3
294 #define GMAC_MII_CLK_150_250M_DIV102    0x4
295 #define GMAC_MII_CLK_250_300M_DIV124    0x5
296 #define GMAC_MII_CLK_DIV4               0x8
297 #define GMAC_MII_CLK_DIV6               0x9
298 #define GMAC_MII_CLK_DIV8               0xa
299 #define GMAC_MII_CLK_DIV10              0xb
300 #define GMAC_MII_CLK_DIV12              0xc
301 #define GMAC_MII_CLK_DIV14              0xd
302 #define GMAC_MII_CLK_DIV16              0xe
303 #define GMAC_MII_CLK_DIV18              0xf
304
305 #endif  /* __IF_DWC_H__ */