2 * drivers/net/ibm_emac/ibm_emac.h
4 * Register definitions for PowerPC 4xx on-chip ethernet contoller
6 * Copyright (c) 2004, 2005 Zultys Technologies.
7 * Eugene Surovegin <eugene.surovegin@zultys.com> or <ebs@ebshome.net>
9 * Based on original work by
10 * Matt Porter <mporter@kernel.crashing.org>
11 * Armin Kuster <akuster@mvista.com>
12 * Copyright 2002-2004 MontaVista Software Inc.
14 * This program is free software; you can redistribute it and/or modify it
15 * under the terms of the GNU General Public License as published by the
16 * Free Software Foundation; either version 2 of the License, or (at your
17 * option) any later version.
23 #include <linux/config.h>
24 #include <linux/types.h>
26 /* This is a simple check to prevent use of this driver on non-tested SoCs */
27 #if !defined(CONFIG_405GP) && !defined(CONFIG_405GPR) && !defined(CONFIG_405EP) && \
28 !defined(CONFIG_440GP) && !defined(CONFIG_440GX) && !defined(CONFIG_440SP) && \
29 !defined(CONFIG_440EP) && !defined(CONFIG_NP405H) && !defined(CONFIG_440SPE) && \
30 !defined(CONFIG_440GR)
31 #error "Unknown SoC. Please, check chip user manual and make sure EMAC defines are OK"
34 /* EMAC registers Write Access rules */
36 u32 mr0
; /* special */
38 u32 tmr0
; /* special */
39 u32 tmr1
; /* special */
43 u32 iahr
; /* Reset, R, T */
44 u32 ialr
; /* Reset, R, T */
45 u32 vtpid
; /* Reset, R, T */
46 u32 vtci
; /* Reset, R, T */
47 u32 ptr
; /* Reset, T */
48 u32 iaht1
; /* Reset, R */
49 u32 iaht2
; /* Reset, R */
50 u32 iaht3
; /* Reset, R */
51 u32 iaht4
; /* Reset, R */
52 u32 gaht1
; /* Reset, R */
53 u32 gaht2
; /* Reset, R */
54 u32 gaht3
; /* Reset, R */
55 u32 gaht4
; /* Reset, R */
58 u32 ipgvr
; /* Reset, T */
59 u32 stacr
; /* special */
60 u32 trtr
; /* special */
67 #if !defined(CONFIG_IBM_EMAC4)
68 #define EMAC_ETHTOOL_REGS_VER 0
69 #define EMAC_ETHTOOL_REGS_SIZE (sizeof(struct emac_regs) - sizeof(u32))
71 #define EMAC_ETHTOOL_REGS_VER 1
72 #define EMAC_ETHTOOL_REGS_SIZE sizeof(struct emac_regs)
76 #define EMAC_MR0_RXI 0x80000000
77 #define EMAC_MR0_TXI 0x40000000
78 #define EMAC_MR0_SRST 0x20000000
79 #define EMAC_MR0_TXE 0x10000000
80 #define EMAC_MR0_RXE 0x08000000
81 #define EMAC_MR0_WKE 0x04000000
84 #define EMAC_MR1_FDE 0x80000000
85 #define EMAC_MR1_ILE 0x40000000
86 #define EMAC_MR1_VLE 0x20000000
87 #define EMAC_MR1_EIFC 0x10000000
88 #define EMAC_MR1_APP 0x08000000
89 #define EMAC_MR1_IST 0x01000000
91 #define EMAC_MR1_MF_MASK 0x00c00000
92 #define EMAC_MR1_MF_10 0x00000000
93 #define EMAC_MR1_MF_100 0x00400000
94 #if !defined(CONFIG_IBM_EMAC4)
95 #define EMAC_MR1_MF_1000 0x00000000
96 #define EMAC_MR1_MF_1000GPCS 0x00000000
97 #define EMAC_MR1_MF_IPPA(id) 0x00000000
99 #define EMAC_MR1_MF_1000 0x00800000
100 #define EMAC_MR1_MF_1000GPCS 0x00c00000
101 #define EMAC_MR1_MF_IPPA(id) (((id) & 0x1f) << 6)
104 #define EMAC_TX_FIFO_SIZE 2048
106 #if !defined(CONFIG_IBM_EMAC4)
107 #define EMAC_MR1_RFS_4K 0x00300000
108 #define EMAC_MR1_RFS_16K 0x00000000
109 #define EMAC_RX_FIFO_SIZE(gige) 4096
110 #define EMAC_MR1_TFS_2K 0x00080000
111 #define EMAC_MR1_TR0_MULT 0x00008000
112 #define EMAC_MR1_JPSM 0x00000000
113 #define EMAC_MR1_MWSW_001 0x00000000
114 #define EMAC_MR1_BASE(opb) (EMAC_MR1_TFS_2K | EMAC_MR1_TR0_MULT)
116 #define EMAC_MR1_RFS_4K 0x00180000
117 #define EMAC_MR1_RFS_16K 0x00280000
118 #define EMAC_RX_FIFO_SIZE(gige) ((gige) ? 16384 : 4096)
119 #define EMAC_MR1_TFS_2K 0x00020000
120 #define EMAC_MR1_TR 0x00008000
121 #define EMAC_MR1_MWSW_001 0x00001000
122 #define EMAC_MR1_JPSM 0x00000800
123 #define EMAC_MR1_OBCI_MASK 0x00000038
124 #define EMAC_MR1_OBCI_50 0x00000000
125 #define EMAC_MR1_OBCI_66 0x00000008
126 #define EMAC_MR1_OBCI_83 0x00000010
127 #define EMAC_MR1_OBCI_100 0x00000018
128 #define EMAC_MR1_OBCI_100P 0x00000020
129 #define EMAC_MR1_OBCI(freq) ((freq) <= 50 ? EMAC_MR1_OBCI_50 : \
130 (freq) <= 66 ? EMAC_MR1_OBCI_66 : \
131 (freq) <= 83 ? EMAC_MR1_OBCI_83 : \
132 (freq) <= 100 ? EMAC_MR1_OBCI_100 : EMAC_MR1_OBCI_100P)
133 #define EMAC_MR1_BASE(opb) (EMAC_MR1_TFS_2K | EMAC_MR1_TR | \
138 #define EMAC_TMR0_GNP 0x80000000
139 #if !defined(CONFIG_IBM_EMAC4)
140 #define EMAC_TMR0_DEFAULT 0x00000000
142 #define EMAC_TMR0_TFAE_2_32 0x00000001
143 #define EMAC_TMR0_TFAE_4_64 0x00000002
144 #define EMAC_TMR0_TFAE_8_128 0x00000003
145 #define EMAC_TMR0_TFAE_16_256 0x00000004
146 #define EMAC_TMR0_TFAE_32_512 0x00000005
147 #define EMAC_TMR0_TFAE_64_1024 0x00000006
148 #define EMAC_TMR0_TFAE_128_2048 0x00000007
149 #define EMAC_TMR0_DEFAULT EMAC_TMR0_TFAE_2_32
151 #define EMAC_TMR0_XMIT (EMAC_TMR0_GNP | EMAC_TMR0_DEFAULT)
155 /* IBM manuals are not very clear here.
156 * This is my interpretation of how things are. --ebs
158 #if defined(CONFIG_40x)
159 #define EMAC_FIFO_ENTRY_SIZE 8
160 #define EMAC_MAL_BURST_SIZE (16 * 4)
162 #define EMAC_FIFO_ENTRY_SIZE 16
163 #define EMAC_MAL_BURST_SIZE (64 * 4)
166 #if !defined(CONFIG_IBM_EMAC4)
167 #define EMAC_TMR1(l,h) (((l) << 27) | (((h) & 0xff) << 16))
169 #define EMAC_TMR1(l,h) (((l) << 27) | (((h) & 0x3ff) << 14))
173 #define EMAC_RMR_SP 0x80000000
174 #define EMAC_RMR_SFCS 0x40000000
175 #define EMAC_RMR_RRP 0x20000000
176 #define EMAC_RMR_RFP 0x10000000
177 #define EMAC_RMR_ROP 0x08000000
178 #define EMAC_RMR_RPIR 0x04000000
179 #define EMAC_RMR_PPP 0x02000000
180 #define EMAC_RMR_PME 0x01000000
181 #define EMAC_RMR_PMME 0x00800000
182 #define EMAC_RMR_IAE 0x00400000
183 #define EMAC_RMR_MIAE 0x00200000
184 #define EMAC_RMR_BAE 0x00100000
185 #define EMAC_RMR_MAE 0x00080000
186 #if !defined(CONFIG_IBM_EMAC4)
187 #define EMAC_RMR_BASE 0x00000000
189 #define EMAC_RMR_RFAF_2_32 0x00000001
190 #define EMAC_RMR_RFAF_4_64 0x00000002
191 #define EMAC_RMR_RFAF_8_128 0x00000003
192 #define EMAC_RMR_RFAF_16_256 0x00000004
193 #define EMAC_RMR_RFAF_32_512 0x00000005
194 #define EMAC_RMR_RFAF_64_1024 0x00000006
195 #define EMAC_RMR_RFAF_128_2048 0x00000007
196 #define EMAC_RMR_BASE EMAC_RMR_RFAF_128_2048
199 /* EMACx_ISR & EMACx_ISER */
200 #if !defined(CONFIG_IBM_EMAC4)
201 #define EMAC_ISR_TXPE 0x00000000
202 #define EMAC_ISR_RXPE 0x00000000
203 #define EMAC_ISR_TXUE 0x00000000
204 #define EMAC_ISR_RXOE 0x00000000
206 #define EMAC_ISR_TXPE 0x20000000
207 #define EMAC_ISR_RXPE 0x10000000
208 #define EMAC_ISR_TXUE 0x08000000
209 #define EMAC_ISR_RXOE 0x04000000
211 #define EMAC_ISR_OVR 0x02000000
212 #define EMAC_ISR_PP 0x01000000
213 #define EMAC_ISR_BP 0x00800000
214 #define EMAC_ISR_RP 0x00400000
215 #define EMAC_ISR_SE 0x00200000
216 #define EMAC_ISR_ALE 0x00100000
217 #define EMAC_ISR_BFCS 0x00080000
218 #define EMAC_ISR_PTLE 0x00040000
219 #define EMAC_ISR_ORE 0x00020000
220 #define EMAC_ISR_IRE 0x00010000
221 #define EMAC_ISR_SQE 0x00000080
222 #define EMAC_ISR_TE 0x00000040
223 #define EMAC_ISR_MOS 0x00000002
224 #define EMAC_ISR_MOF 0x00000001
227 #define EMAC_STACR_PHYD_MASK 0xffff
228 #define EMAC_STACR_PHYD_SHIFT 16
229 #define EMAC_STACR_OC 0x00008000
230 #define EMAC_STACR_PHYE 0x00004000
231 #define EMAC_STACR_STAC_MASK 0x00003000
232 #define EMAC_STACR_STAC_READ 0x00001000
233 #define EMAC_STACR_STAC_WRITE 0x00002000
234 #if !defined(CONFIG_IBM_EMAC4)
235 #define EMAC_STACR_OPBC_MASK 0x00000C00
236 #define EMAC_STACR_OPBC_50 0x00000000
237 #define EMAC_STACR_OPBC_66 0x00000400
238 #define EMAC_STACR_OPBC_83 0x00000800
239 #define EMAC_STACR_OPBC_100 0x00000C00
240 #define EMAC_STACR_OPBC(freq) ((freq) <= 50 ? EMAC_STACR_OPBC_50 : \
241 (freq) <= 66 ? EMAC_STACR_OPBC_66 : \
242 (freq) <= 83 ? EMAC_STACR_OPBC_83 : EMAC_STACR_OPBC_100)
243 #define EMAC_STACR_BASE(opb) EMAC_STACR_OPBC(opb)
245 #define EMAC_STACR_BASE(opb) 0x00000000
247 #define EMAC_STACR_PCDA_MASK 0x1f
248 #define EMAC_STACR_PCDA_SHIFT 5
249 #define EMAC_STACR_PRA_MASK 0x1f
252 * For the 440SPe, AMCC inexplicably changed the polarity of
253 * the "operation complete" bit in the MII control register.
255 #if defined(CONFIG_440SPE)
256 static inline int emac_phy_done(u32 stacr
)
258 return !(stacr
& EMAC_STACR_OC
);
260 #define EMAC_STACR_START EMAC_STACR_OC
262 #else /* CONFIG_440SPE */
263 static inline int emac_phy_done(u32 stacr
)
265 return stacr
& EMAC_STACR_OC
;
267 #define EMAC_STACR_START 0
268 #endif /* !CONFIG_440SPE */
271 #if !defined(CONFIG_IBM_EMAC4)
272 #define EMAC_TRTR_SHIFT 27
274 #define EMAC_TRTR_SHIFT 24
276 #define EMAC_TRTR(size) ((((size) >> 6) - 1) << EMAC_TRTR_SHIFT)
279 #if !defined(CONFIG_IBM_EMAC4)
280 #define EMAC_RWMR(l,h) (((l) << 23) | ( ((h) & 0x1ff) << 7))
282 #define EMAC_RWMR(l,h) (((l) << 22) | ( ((h) & 0x3ff) << 6))
285 /* EMAC specific TX descriptor control fields (write access) */
286 #define EMAC_TX_CTRL_GFCS 0x0200
287 #define EMAC_TX_CTRL_GP 0x0100
288 #define EMAC_TX_CTRL_ISA 0x0080
289 #define EMAC_TX_CTRL_RSA 0x0040
290 #define EMAC_TX_CTRL_IVT 0x0020
291 #define EMAC_TX_CTRL_RVT 0x0010
292 #define EMAC_TX_CTRL_TAH_CSUM 0x000e
294 /* EMAC specific TX descriptor status fields (read access) */
295 #define EMAC_TX_ST_BFCS 0x0200
296 #define EMAC_TX_ST_LCS 0x0080
297 #define EMAC_TX_ST_ED 0x0040
298 #define EMAC_TX_ST_EC 0x0020
299 #define EMAC_TX_ST_LC 0x0010
300 #define EMAC_TX_ST_MC 0x0008
301 #define EMAC_TX_ST_SC 0x0004
302 #define EMAC_TX_ST_UR 0x0002
303 #define EMAC_TX_ST_SQE 0x0001
304 #if !defined(CONFIG_IBM_EMAC_TAH)
305 #define EMAC_IS_BAD_TX(v) ((v) & (EMAC_TX_ST_LCS | EMAC_TX_ST_ED | \
306 EMAC_TX_ST_EC | EMAC_TX_ST_LC | \
307 EMAC_TX_ST_MC | EMAC_TX_ST_UR))
309 #define EMAC_IS_BAD_TX(v) ((v) & (EMAC_TX_ST_LCS | EMAC_TX_ST_ED | \
310 EMAC_TX_ST_EC | EMAC_TX_ST_LC))
313 /* EMAC specific RX descriptor status fields (read access) */
314 #define EMAC_RX_ST_OE 0x0200
315 #define EMAC_RX_ST_PP 0x0100
316 #define EMAC_RX_ST_BP 0x0080
317 #define EMAC_RX_ST_RP 0x0040
318 #define EMAC_RX_ST_SE 0x0020
319 #define EMAC_RX_ST_AE 0x0010
320 #define EMAC_RX_ST_BFCS 0x0008
321 #define EMAC_RX_ST_PTL 0x0004
322 #define EMAC_RX_ST_ORE 0x0002
323 #define EMAC_RX_ST_IRE 0x0001
324 #define EMAC_RX_TAH_BAD_CSUM 0x0003
325 #define EMAC_BAD_RX_MASK (EMAC_RX_ST_OE | EMAC_RX_ST_BP | \
326 EMAC_RX_ST_RP | EMAC_RX_ST_SE | \
327 EMAC_RX_ST_AE | EMAC_RX_ST_BFCS | \
328 EMAC_RX_ST_PTL | EMAC_RX_ST_ORE | \
330 #endif /* __IBM_EMAC_H_ */