dwc_gmac_reg.h revision 1.10 1 /* $NetBSD: dwc_gmac_reg.h,v 1.10 2014/10/20 20:10:05 jmcneill Exp $ */
2
3 /*-
4 * Copyright (c) 2013, 2014 The NetBSD Foundation, Inc.
5 * All rights reserved.
6 *
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Matt Thomas of 3am Software Foundry and Martin Husemann.
9 *
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
30 */
31
32 #define AWIN_GMAC_MAC_CONF 0x0000
33 #define AWIN_GMAC_MAC_FFILT 0x0004
34 #define AWIN_GMAC_MAC_HTHIGH 0x0008
35 #define AWIN_GMAC_MAC_HTLOW 0x000c
36 #define AWIN_GMAC_MAC_MIIADDR 0x0010
37 #define AWIN_GMAC_MAC_MIIDATA 0x0014
38 #define AWIN_GMAC_MAC_FLOWCTRL 0x0018
39 #define AWIN_GMAC_MAC_VLANTAG 0x001c
40 #define AWIN_GMAC_MAC_VERSION 0x0020 /* not always implemented? */
41 #define AWIN_GMAC_MAC_INTR 0x0038
42 #define AWIN_GMAC_MAC_INTMASK 0x003c
43 #define AWIN_GMAC_MAC_ADDR0HI 0x0040
44 #define AWIN_GMAC_MAC_ADDR0LO 0x0044
45 #define AWIN_GMAC_MII_STATUS 0x00D8
46
47 #define AWIN_GMAC_MAC_CONF_FRAMEBURST __BIT(21) /* allow TX frameburst when
48 in half duplex mode */
49 #define AWIN_GMAC_MAC_CONF_MIISEL __BIT(15) /* select MII phy */
50 #define AWIN_GMAC_MAC_CONF_FES100 __BIT(14) /* 100 mbit mode */
51 #define AWIN_GMAC_MAC_CONF_DISABLERXOWN __BIT(13) /* do not receive our own
52 TX frames in half duplex
53 mode */
54 #define AWIN_GMAC_MAC_CONF_FULLDPLX __BIT(11) /* select full duplex */
55 #define AWIN_GMAC_MAC_CONF_TXENABLE __BIT(3) /* enable TX dma engine */
56 #define AWIN_GMAC_MAC_CONF_RXENABLE __BIT(2) /* enable RX dma engine */
57
58 #define AWIN_GMAC_MAC_FFILT_PM __BIT(4) /* promiscious multicast */
59 #define AWIN_GMAC_MAC_FFILT_HMC __BIT(2) /* multicast hash compare */
60 #define AWIN_GMAC_MAC_FFILT_HUC __BIT(1) /* unicast hash compare */
61 #define AWIN_GMAC_MAC_FFILT_PR __BIT(0) /* promiscious mode */
62
63 #define AWIN_GMAC_MAC_INT_LPI __BIT(10)
64 #define AWIN_GMAC_MAC_INT_TSI __BIT(9)
65 #define AWIN_GMAC_MAC_INT_ANEG __BIT(2)
66 #define AWIN_GMAC_MAC_INT_LINKCHG __BIT(1)
67 #define AWIN_GMAC_MAC_INT_RGSMII __BIT(0)
68
69 #define AWIN_GMAC_DMA_BUSMODE 0x1000
70 #define AWIN_GMAC_DMA_TXPOLL 0x1004
71 #define AWIN_GMAC_DMA_RXPOLL 0x1008
72 #define AWIN_GMAC_DMA_RX_ADDR 0x100c
73 #define AWIN_GMAC_DMA_TX_ADDR 0x1010
74 #define AWIN_GMAC_DMA_STATUS 0x1014
75 #define AWIN_GMAC_DMA_OPMODE 0x1018
76 #define AWIN_GMAC_DMA_INTENABLE 0x101c
77 #define AWIN_GMAC_DMA_CUR_TX_DESC 0x1048
78 #define AWIN_GMAC_DMA_CUR_RX_DESC 0x104c
79 #define AWIN_GMAC_DMA_CUR_TX_BUFADDR 0x1050
80 #define AWIN_GMAC_DMA_CUR_RX_BUFADDR 0x1054
81 #define AWIN_GMAC_DMA_HWFEATURES 0x1058 /* not always implemented? */
82
83 #define GMAC_MII_PHY_SHIFT 11
84 #define GMAC_MII_PHY_MASK __BITS(15,11)
85 #define GMAC_MII_REG_SHIFT 6
86 #define GMAC_MII_REG_MASK __BITS(10,6)
87
88 #define GMAC_MII_BUSY __BIT(0)
89 #define GMAC_MII_WRITE __BIT(1)
90 #define GMAC_MII_CLK_60_100M_DIV42 0x0
91 #define GMAC_MII_CLK_100_150M_DIV62 0x1
92 #define GMAC_MII_CLK_25_35M_DIV16 0x2
93 #define GMAC_MII_CLK_35_60M_DIV26 0x3
94 #define GMAC_MII_CLK_150_250M_DIV102 0x4
95 #define GMAC_MII_CLK_250_300M_DIV124 0x5
96 #define GMAC_MII_CLK_DIV4 0x8
97 #define GMAC_MII_CLK_DIV6 0x9
98 #define GMAC_MII_CLK_DIV8 0xa
99 #define GMAC_MII_CLK_DIV10 0xb
100 #define GMAC_MII_CLK_DIV12 0xc
101 #define GMAC_MII_CLK_DIV14 0xd
102 #define GMAC_MII_CLK_DIV16 0xe
103 #define GMAC_MII_CLK_DIV18 0xf
104 #define GMAC_MII_CLKMASK __BITS(5,2)
105
106 #define GMAC_BUSMODE_FIXEDBURST __BIT(16)
107 #define GMAC_BUSMODE_PRIORXTX __BITS(15,14)
108 #define GMAC_BUSMODE_PRIORXTX_41 3
109 #define GMAC_BUSMODE_PRIORXTX_31 2
110 #define GMAC_BUSMODE_PRIORXTX_21 1
111 #define GMAC_BUSMODE_PRIORXTX_11 0
112 #define GMCA_BUSMODE_PBL __BITS(13,8) /* possible DMA
113 burst len */
114 #define GMAC_BUSMODE_RESET __BIT(0)
115
116 #define AWIN_GMAC_MII_IRQ __BIT(0)
117
118
119 #define GMAC_DMA_OP_STOREFORWARD __BIT(21) /* start TX with when a
120 full frame is available */
121 #define GMAC_DMA_OP_FLUSHTX __BIT(20) /* flush TX fifo */
122 #define GMAC_DMA_OP_TXSTART __BIT(13) /* start TX DMA engine */
123 #define GMAC_DMA_OP_RXSTART __BIT(1) /* start RX DMA engine */
124
125 #define GMAC_DMA_INT_NIE __BIT(16) /* Normal/Summary */
126 #define GMAC_DMA_INT_AIE __BIT(15) /* Abnormal/Summary */
127 #define GMAC_DMA_INT_ERE __BIT(14) /* Early receive */
128 #define GMAC_DMA_INT_FBE __BIT(13) /* Fatal bus error */
129 #define GMAC_DMA_INT_ETE __BIT(10) /* Early transmit */
130 #define GMAC_DMA_INT_RWE __BIT(9) /* Receive watchdog */
131 #define GMAC_DMA_INT_RSE __BIT(8) /* Receive stopped */
132 #define GMAC_DMA_INT_RUE __BIT(7) /* Receive buffer unavail. */
133 #define GMAC_DMA_INT_RIE __BIT(6) /* Receive interrupt */
134 #define GMAC_DMA_INT_UNE __BIT(5) /* Tx underflow */
135 #define GMAC_DMA_INT_OVE __BIT(4) /* Receive overflow */
136 #define GMAC_DMA_INT_TJE __BIT(3) /* Transmit jabber */
137 #define GMAC_DMA_INT_TUE __BIT(2) /* Transmit buffer unavail. */
138 #define GMAC_DMA_INT_TSE __BIT(1) /* Transmit stopped */
139 #define GMAC_DMA_INT_TIE __BIT(0) /* Transmit interrupt */
140
141 #define GMAC_DMA_INT_MASK __BITS(0,16) /* all possible intr bits */
142
143 struct dwc_gmac_dev_dmadesc {
144 uint32_t ddesc_status;
145 /* both: */
146 #define DDESC_STATUS_OWNEDBYDEV __BIT(31)
147
148 /* for RX descriptors */
149 #define DDESC_STATUS_DAFILTERFAIL __BIT(30)
150 #define DDESC_STATUS_FRMLENMSK __BITS(29,16)
151 #define DDESC_STATUS_FRMLENSHIFT 16
152 #define DDESC_STATUS_RXERROR __BIT(15)
153 #define DDESC_STATUS_RXTRUNCATED __BIT(14)
154 #define DDESC_STATUS_SAFILTERFAIL __BIT(13)
155 #define DDESC_STATUS_RXIPC_GIANTFRAME __BIT(12)
156 #define DDESC_STATUS_RXDAMAGED __BIT(11)
157 #define DDESC_STATUS_RXVLANTAG __BIT(10)
158 #define DDESC_STATUS_RXFIRST __BIT(9)
159 #define DDESC_STATUS_RXLAST __BIT(8)
160 #define DDESC_STATUS_RXIPC_GIANT __BIT(7)
161 #define DDESC_STATUS_RXCOLLISION __BIT(6)
162 #define DDESC_STATUS_RXFRAMEETHER __BIT(5)
163 #define DDESC_STATUS_RXWATCHDOG __BIT(4)
164 #define DDESC_STATUS_RXMIIERROR __BIT(3)
165 #define DDESC_STATUS_RXDRIBBLING __BIT(2)
166 #define DDESC_STATUS_RXCRC __BIT(1)
167
168 uint32_t ddesc_cntl;
169
170 /* for TX descriptors */
171 #define DDESC_CNTL_TXINT __BIT(31)
172 #define DDESC_CNTL_TXLAST __BIT(30)
173 #define DDESC_CNTL_TXFIRST __BIT(29)
174 #define DDESC_CNTL_TXCHECKINSCTRL __BIT(27)
175 #define DDESC_CNTL_TXCRCDIS __BIT(26)
176 #define DDESC_CNTL_TXRINGEND __BIT(25)
177 #define DDESC_CNTL_TXCHAIN __BIT(24)
178
179 /* for RX descriptors */
180 #define DDESC_CNTL_RXINTDIS __BIT(31)
181 #define DDESC_CNTL_RXRINGEND __BIT(25)
182 #define DDESC_CNTL_RXCHAIN __BIT(24)
183
184 /* both */
185 #define DDESC_CNTL_SIZE1MASK __BITS(10,0)
186 #define DDESC_CNTL_SIZE1SHIFT 0
187 #define DDESC_CNTL_SIZE2MASK __BITS(21,11)
188 #define DDESC_CNTL_SIZE2SHIFT 11
189
190 uint32_t ddesc_data; /* pointer to buffer data */
191 uint32_t ddesc_next; /* link to next descriptor */
192 };
193