blob: d3166da753ef5c75ad49f96507847e4f59e4a258 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
Eugene Surovegin37448f72005-10-10 16:58:14 -07002 * drivers/net/ibm_emac/ibm_emac.h
Linus Torvalds1da177e2005-04-16 15:20:36 -07003 *
Eugene Surovegin37448f72005-10-10 16:58:14 -07004 * Register definitions for PowerPC 4xx on-chip ethernet contoller
Linus Torvalds1da177e2005-04-16 15:20:36 -07005 *
Eugene Surovegin37448f72005-10-10 16:58:14 -07006 * Copyright (c) 2004, 2005 Zultys Technologies.
7 * Eugene Surovegin <eugene.surovegin@zultys.com> or <ebs@ebshome.net>
Linus Torvalds1da177e2005-04-16 15:20:36 -07008 *
Eugene Surovegin37448f72005-10-10 16:58:14 -07009 * 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.
Linus Torvalds1da177e2005-04-16 15:20:36 -070013 *
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.
Eugene Surovegin37448f72005-10-10 16:58:14 -070018 *
Linus Torvalds1da177e2005-04-16 15:20:36 -070019 */
Eugene Surovegin37448f72005-10-10 16:58:14 -070020#ifndef __IBM_EMAC_H_
21#define __IBM_EMAC_H_
Linus Torvalds1da177e2005-04-16 15:20:36 -070022
Eugene Surovegin37448f72005-10-10 16:58:14 -070023#include <linux/config.h>
24#include <linux/types.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070025
Eugene Surovegin37448f72005-10-10 16:58:14 -070026/* 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) && \
Eugene Surovegin7ad8a892005-10-29 12:43:14 -070029 !defined(CONFIG_440EP) && !defined(CONFIG_NP405H) && !defined(CONFIG_440SPE)
Eugene Surovegin37448f72005-10-10 16:58:14 -070030#error "Unknown SoC. Please, check chip user manual and make sure EMAC defines are OK"
31#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -070032
Eugene Surovegin37448f72005-10-10 16:58:14 -070033/* EMAC registers Write Access rules */
34struct emac_regs {
35 u32 mr0; /* special */
36 u32 mr1; /* Reset */
37 u32 tmr0; /* special */
38 u32 tmr1; /* special */
39 u32 rmr; /* Reset */
40 u32 isr; /* Always */
41 u32 iser; /* Reset */
42 u32 iahr; /* Reset, R, T */
43 u32 ialr; /* Reset, R, T */
44 u32 vtpid; /* Reset, R, T */
45 u32 vtci; /* Reset, R, T */
46 u32 ptr; /* Reset, T */
47 u32 iaht1; /* Reset, R */
48 u32 iaht2; /* Reset, R */
49 u32 iaht3; /* Reset, R */
50 u32 iaht4; /* Reset, R */
51 u32 gaht1; /* Reset, R */
52 u32 gaht2; /* Reset, R */
53 u32 gaht3; /* Reset, R */
54 u32 gaht4; /* Reset, R */
55 u32 lsah;
56 u32 lsal;
57 u32 ipgvr; /* Reset, T */
58 u32 stacr; /* special */
59 u32 trtr; /* special */
60 u32 rwmr; /* Reset */
61 u32 octx;
62 u32 ocrx;
63 u32 ipcr;
64};
Linus Torvalds1da177e2005-04-16 15:20:36 -070065
Eugene Surovegin37448f72005-10-10 16:58:14 -070066#if !defined(CONFIG_IBM_EMAC4)
67#define EMAC_ETHTOOL_REGS_VER 0
68#define EMAC_ETHTOOL_REGS_SIZE (sizeof(struct emac_regs) - sizeof(u32))
69#else
70#define EMAC_ETHTOOL_REGS_VER 1
71#define EMAC_ETHTOOL_REGS_SIZE sizeof(struct emac_regs)
72#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -070073
Eugene Surovegin37448f72005-10-10 16:58:14 -070074/* EMACx_MR0 */
75#define EMAC_MR0_RXI 0x80000000
76#define EMAC_MR0_TXI 0x40000000
77#define EMAC_MR0_SRST 0x20000000
78#define EMAC_MR0_TXE 0x10000000
79#define EMAC_MR0_RXE 0x08000000
80#define EMAC_MR0_WKE 0x04000000
81
82/* EMACx_MR1 */
83#define EMAC_MR1_FDE 0x80000000
84#define EMAC_MR1_ILE 0x40000000
85#define EMAC_MR1_VLE 0x20000000
86#define EMAC_MR1_EIFC 0x10000000
87#define EMAC_MR1_APP 0x08000000
88#define EMAC_MR1_IST 0x01000000
89
90#define EMAC_MR1_MF_MASK 0x00c00000
91#define EMAC_MR1_MF_10 0x00000000
92#define EMAC_MR1_MF_100 0x00400000
93#if !defined(CONFIG_IBM_EMAC4)
94#define EMAC_MR1_MF_1000 0x00000000
95#define EMAC_MR1_MF_1000GPCS 0x00000000
96#define EMAC_MR1_MF_IPPA(id) 0x00000000
97#else
98#define EMAC_MR1_MF_1000 0x00800000
99#define EMAC_MR1_MF_1000GPCS 0x00c00000
100#define EMAC_MR1_MF_IPPA(id) (((id) & 0x1f) << 6)
101#endif
102
103#define EMAC_TX_FIFO_SIZE 2048
104
105#if !defined(CONFIG_IBM_EMAC4)
106#define EMAC_MR1_RFS_4K 0x00300000
107#define EMAC_MR1_RFS_16K 0x00000000
108#define EMAC_RX_FIFO_SIZE(gige) 4096
109#define EMAC_MR1_TFS_2K 0x00080000
110#define EMAC_MR1_TR0_MULT 0x00008000
111#define EMAC_MR1_JPSM 0x00000000
112#define EMAC_MR1_BASE(opb) (EMAC_MR1_TFS_2K | EMAC_MR1_TR0_MULT)
113#else
114#define EMAC_MR1_RFS_4K 0x00180000
115#define EMAC_MR1_RFS_16K 0x00280000
116#define EMAC_RX_FIFO_SIZE(gige) ((gige) ? 16384 : 4096)
117#define EMAC_MR1_TFS_2K 0x00020000
118#define EMAC_MR1_TR 0x00008000
119#define EMAC_MR1_MWSW_001 0x00001000
120#define EMAC_MR1_JPSM 0x00000800
121#define EMAC_MR1_OBCI_MASK 0x00000038
122#define EMAC_MR1_OBCI_50 0x00000000
123#define EMAC_MR1_OBCI_66 0x00000008
124#define EMAC_MR1_OBCI_83 0x00000010
125#define EMAC_MR1_OBCI_100 0x00000018
126#define EMAC_MR1_OBCI_100P 0x00000020
127#define EMAC_MR1_OBCI(freq) ((freq) <= 50 ? EMAC_MR1_OBCI_50 : \
128 (freq) <= 66 ? EMAC_MR1_OBCI_66 : \
129 (freq) <= 83 ? EMAC_MR1_OBCI_83 : \
130 (freq) <= 100 ? EMAC_MR1_OBCI_100 : EMAC_MR1_OBCI_100P)
131#define EMAC_MR1_BASE(opb) (EMAC_MR1_TFS_2K | EMAC_MR1_TR | \
132 EMAC_MR1_MWSW_001 | EMAC_MR1_OBCI(opb))
133#endif
134
135/* EMACx_TMR0 */
136#define EMAC_TMR0_GNP 0x80000000
137#if !defined(CONFIG_IBM_EMAC4)
138#define EMAC_TMR0_DEFAULT 0x00000000
139#else
Linus Torvalds1da177e2005-04-16 15:20:36 -0700140#define EMAC_TMR0_TFAE_2_32 0x00000001
141#define EMAC_TMR0_TFAE_4_64 0x00000002
142#define EMAC_TMR0_TFAE_8_128 0x00000003
143#define EMAC_TMR0_TFAE_16_256 0x00000004
144#define EMAC_TMR0_TFAE_32_512 0x00000005
145#define EMAC_TMR0_TFAE_64_1024 0x00000006
146#define EMAC_TMR0_TFAE_128_2048 0x00000007
Eugene Surovegin37448f72005-10-10 16:58:14 -0700147#define EMAC_TMR0_DEFAULT EMAC_TMR0_TFAE_2_32
148#endif
149#define EMAC_TMR0_XMIT (EMAC_TMR0_GNP | EMAC_TMR0_DEFAULT)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700150
Eugene Surovegin37448f72005-10-10 16:58:14 -0700151/* EMACx_TMR1 */
152
153/* IBM manuals are not very clear here.
154 * This is my interpretation of how things are. --ebs
155 */
156#if defined(CONFIG_40x)
157#define EMAC_FIFO_ENTRY_SIZE 8
158#define EMAC_MAL_BURST_SIZE (16 * 4)
159#else
160#define EMAC_FIFO_ENTRY_SIZE 16
161#define EMAC_MAL_BURST_SIZE (64 * 4)
162#endif
163
164#if !defined(CONFIG_IBM_EMAC4)
165#define EMAC_TMR1(l,h) (((l) << 27) | (((h) & 0xff) << 16))
166#else
167#define EMAC_TMR1(l,h) (((l) << 27) | (((h) & 0x3ff) << 14))
168#endif
169
170/* EMACx_RMR */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700171#define EMAC_RMR_SP 0x80000000
172#define EMAC_RMR_SFCS 0x40000000
Eugene Surovegin37448f72005-10-10 16:58:14 -0700173#define EMAC_RMR_RRP 0x20000000
174#define EMAC_RMR_RFP 0x10000000
175#define EMAC_RMR_ROP 0x08000000
176#define EMAC_RMR_RPIR 0x04000000
Linus Torvalds1da177e2005-04-16 15:20:36 -0700177#define EMAC_RMR_PPP 0x02000000
178#define EMAC_RMR_PME 0x01000000
179#define EMAC_RMR_PMME 0x00800000
180#define EMAC_RMR_IAE 0x00400000
181#define EMAC_RMR_MIAE 0x00200000
182#define EMAC_RMR_BAE 0x00100000
183#define EMAC_RMR_MAE 0x00080000
Eugene Surovegin37448f72005-10-10 16:58:14 -0700184#if !defined(CONFIG_IBM_EMAC4)
185#define EMAC_RMR_BASE 0x00000000
186#else
Linus Torvalds1da177e2005-04-16 15:20:36 -0700187#define EMAC_RMR_RFAF_2_32 0x00000001
188#define EMAC_RMR_RFAF_4_64 0x00000002
189#define EMAC_RMR_RFAF_8_128 0x00000003
190#define EMAC_RMR_RFAF_16_256 0x00000004
191#define EMAC_RMR_RFAF_32_512 0x00000005
192#define EMAC_RMR_RFAF_64_1024 0x00000006
193#define EMAC_RMR_RFAF_128_2048 0x00000007
Eugene Surovegin37448f72005-10-10 16:58:14 -0700194#define EMAC_RMR_BASE EMAC_RMR_RFAF_128_2048
195#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700196
Eugene Surovegin37448f72005-10-10 16:58:14 -0700197/* EMACx_ISR & EMACx_ISER */
198#if !defined(CONFIG_IBM_EMAC4)
199#define EMAC_ISR_TXPE 0x00000000
200#define EMAC_ISR_RXPE 0x00000000
201#define EMAC_ISR_TXUE 0x00000000
202#define EMAC_ISR_RXOE 0x00000000
203#else
204#define EMAC_ISR_TXPE 0x20000000
205#define EMAC_ISR_RXPE 0x10000000
206#define EMAC_ISR_TXUE 0x08000000
207#define EMAC_ISR_RXOE 0x04000000
208#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700209#define EMAC_ISR_OVR 0x02000000
210#define EMAC_ISR_PP 0x01000000
211#define EMAC_ISR_BP 0x00800000
212#define EMAC_ISR_RP 0x00400000
213#define EMAC_ISR_SE 0x00200000
214#define EMAC_ISR_ALE 0x00100000
215#define EMAC_ISR_BFCS 0x00080000
216#define EMAC_ISR_PTLE 0x00040000
217#define EMAC_ISR_ORE 0x00020000
218#define EMAC_ISR_IRE 0x00010000
Eugene Surovegin37448f72005-10-10 16:58:14 -0700219#define EMAC_ISR_SQE 0x00000080
220#define EMAC_ISR_TE 0x00000040
Linus Torvalds1da177e2005-04-16 15:20:36 -0700221#define EMAC_ISR_MOS 0x00000002
222#define EMAC_ISR_MOF 0x00000001
223
Eugene Surovegin37448f72005-10-10 16:58:14 -0700224/* EMACx_STACR */
225#define EMAC_STACR_PHYD_MASK 0xffff
226#define EMAC_STACR_PHYD_SHIFT 16
Linus Torvalds1da177e2005-04-16 15:20:36 -0700227#define EMAC_STACR_OC 0x00008000
228#define EMAC_STACR_PHYE 0x00004000
Eugene Surovegin37448f72005-10-10 16:58:14 -0700229#define EMAC_STACR_STAC_MASK 0x00003000
230#define EMAC_STACR_STAC_READ 0x00001000
231#define EMAC_STACR_STAC_WRITE 0x00002000
232#if !defined(CONFIG_IBM_EMAC4)
233#define EMAC_STACR_OPBC_MASK 0x00000C00
234#define EMAC_STACR_OPBC_50 0x00000000
235#define EMAC_STACR_OPBC_66 0x00000400
236#define EMAC_STACR_OPBC_83 0x00000800
237#define EMAC_STACR_OPBC_100 0x00000C00
238#define EMAC_STACR_OPBC(freq) ((freq) <= 50 ? EMAC_STACR_OPBC_50 : \
239 (freq) <= 66 ? EMAC_STACR_OPBC_66 : \
240 (freq) <= 83 ? EMAC_STACR_OPBC_83 : EMAC_STACR_OPBC_100)
241#define EMAC_STACR_BASE(opb) EMAC_STACR_OPBC(opb)
242#else
243#define EMAC_STACR_BASE(opb) 0x00000000
244#endif
245#define EMAC_STACR_PCDA_MASK 0x1f
246#define EMAC_STACR_PCDA_SHIFT 5
247#define EMAC_STACR_PRA_MASK 0x1f
Linus Torvalds1da177e2005-04-16 15:20:36 -0700248
Eugene Surovegin7ad8a892005-10-29 12:43:14 -0700249/*
250 * For the 440SPe, AMCC inexplicably changed the polarity of
251 * the "operation complete" bit in the MII control register.
252 */
253#if defined(CONFIG_440SPE)
254static inline int emac_phy_done(u32 stacr)
255{
256 return !(stacr & EMAC_STACR_OC);
257};
258#define EMAC_STACR_START EMAC_STACR_OC
259
260#else /* CONFIG_440SPE */
261static inline int emac_phy_done(u32 stacr)
262{
263 return stacr & EMAC_STACR_OC;
264};
265#define EMAC_STACR_START 0
266#endif /* !CONFIG_440SPE */
267
Eugene Surovegin37448f72005-10-10 16:58:14 -0700268/* EMACx_TRTR */
269#if !defined(CONFIG_IBM_EMAC4)
270#define EMAC_TRTR_SHIFT 27
271#else
272#define EMAC_TRTR_SHIFT 24
273#endif
274#define EMAC_TRTR(size) ((((size) >> 6) - 1) << EMAC_TRTR_SHIFT)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700275
Eugene Surovegin37448f72005-10-10 16:58:14 -0700276/* EMACx_RWMR */
277#if !defined(CONFIG_IBM_EMAC4)
278#define EMAC_RWMR(l,h) (((l) << 23) | ( ((h) & 0x1ff) << 7))
279#else
280#define EMAC_RWMR(l,h) (((l) << 22) | ( ((h) & 0x3ff) << 6))
281#endif
282
283/* EMAC specific TX descriptor control fields (write access) */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700284#define EMAC_TX_CTRL_GFCS 0x0200
285#define EMAC_TX_CTRL_GP 0x0100
286#define EMAC_TX_CTRL_ISA 0x0080
287#define EMAC_TX_CTRL_RSA 0x0040
288#define EMAC_TX_CTRL_IVT 0x0020
289#define EMAC_TX_CTRL_RVT 0x0010
Eugene Surovegin37448f72005-10-10 16:58:14 -0700290#define EMAC_TX_CTRL_TAH_CSUM 0x000e
Linus Torvalds1da177e2005-04-16 15:20:36 -0700291
Eugene Surovegin37448f72005-10-10 16:58:14 -0700292/* EMAC specific TX descriptor status fields (read access) */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700293#define EMAC_TX_ST_BFCS 0x0200
Linus Torvalds1da177e2005-04-16 15:20:36 -0700294#define EMAC_TX_ST_LCS 0x0080
295#define EMAC_TX_ST_ED 0x0040
296#define EMAC_TX_ST_EC 0x0020
297#define EMAC_TX_ST_LC 0x0010
298#define EMAC_TX_ST_MC 0x0008
299#define EMAC_TX_ST_SC 0x0004
300#define EMAC_TX_ST_UR 0x0002
301#define EMAC_TX_ST_SQE 0x0001
Eugene Surovegin37448f72005-10-10 16:58:14 -0700302#if !defined(CONFIG_IBM_EMAC_TAH)
303#define EMAC_IS_BAD_TX(v) ((v) & (EMAC_TX_ST_LCS | EMAC_TX_ST_ED | \
304 EMAC_TX_ST_EC | EMAC_TX_ST_LC | \
305 EMAC_TX_ST_MC | EMAC_TX_ST_UR))
306#else
307#define EMAC_IS_BAD_TX(v) ((v) & (EMAC_TX_ST_LCS | EMAC_TX_ST_ED | \
308 EMAC_TX_ST_EC | EMAC_TX_ST_LC))
309#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700310
Eugene Surovegin37448f72005-10-10 16:58:14 -0700311/* EMAC specific RX descriptor status fields (read access) */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700312#define EMAC_RX_ST_OE 0x0200
313#define EMAC_RX_ST_PP 0x0100
314#define EMAC_RX_ST_BP 0x0080
315#define EMAC_RX_ST_RP 0x0040
316#define EMAC_RX_ST_SE 0x0020
317#define EMAC_RX_ST_AE 0x0010
318#define EMAC_RX_ST_BFCS 0x0008
319#define EMAC_RX_ST_PTL 0x0004
320#define EMAC_RX_ST_ORE 0x0002
321#define EMAC_RX_ST_IRE 0x0001
Eugene Surovegin37448f72005-10-10 16:58:14 -0700322#define EMAC_RX_TAH_BAD_CSUM 0x0003
323#define EMAC_BAD_RX_MASK (EMAC_RX_ST_OE | EMAC_RX_ST_BP | \
324 EMAC_RX_ST_RP | EMAC_RX_ST_SE | \
325 EMAC_RX_ST_AE | EMAC_RX_ST_BFCS | \
326 EMAC_RX_ST_PTL | EMAC_RX_ST_ORE | \
327 EMAC_RX_ST_IRE )
328#endif /* __IBM_EMAC_H_ */