if_enetreg.h revision 1.1
1/*	$NetBSD: if_enetreg.h,v 1.1 2014/09/25 05:05:28 ryo Exp $	*/
2
3/*-
4 * Copyright (c) 2014 Ryo Shimizu <ryo@nerv.org>
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 *    notice, this list of conditions and the following disclaimer.
12 * 2. 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 *
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
17 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
20 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
22 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
24 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
25 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26 * POSSIBILITY OF SUCH DAMAGE.
27 */
28
29/*
30 * i.MX6 10/100/1000-Mbps ethernet MAC (ENET)
31 */
32
33#ifndef _ARM_IMX_IF_ENETREG_H_
34#define _ARM_IMX_IF_ENETREG_H_
35
36#include <sys/cdefs.h>
37
38#define ENET_EIR			0x00000004
39# define ENET_EIR_BABR			__BIT(30)
40# define ENET_EIR_BABT			__BIT(29)
41# define ENET_EIR_GRA			__BIT(28)
42# define ENET_EIR_TXF			__BIT(27)
43# define ENET_EIR_TXB			__BIT(26)
44# define ENET_EIR_RXF			__BIT(25)
45# define ENET_EIR_RXB			__BIT(24)
46# define ENET_EIR_MII			__BIT(23)
47# define ENET_EIR_EBERR			__BIT(22)
48# define ENET_EIR_LC			__BIT(21)
49# define ENET_EIR_RL			__BIT(20)
50# define ENET_EIR_UN			__BIT(19)
51# define ENET_EIR_PLR			__BIT(18)
52# define ENET_EIR_WAKEUP		__BIT(17)
53# define ENET_EIR_TS_AVAIL		__BIT(16)
54# define ENET_EIR_TS_TIMER		__BIT(15)
55#define ENET_EIMR			0x00000008
56#define ENET_RDAR			0x00000010
57# define ENET_RDAR_ACTIVE		__BIT(24)
58#define ENET_TDAR			0x00000014
59# define ENET_TDAR_ACTIVE		__BIT(24)
60
61#define ENET_ECR			0x00000024
62# define ENET_ECR_DBSWP			__BIT(8)
63# define ENET_ECR_STOPEN		__BIT(7)
64# define ENET_ECR_DBGEN			__BIT(6)
65# define ENET_ECR_SPEED			__BIT(5)
66# define ENET_ECR_EN1588		__BIT(4)
67# define ENET_ECR_SLEEP			__BIT(3)
68# define ENET_ECR_MAGICEN		__BIT(2)
69# define ENET_ECR_ETHEREN		__BIT(1)
70# define ENET_ECR_RESET			__BIT(0)
71#define ENET_MMFR			0x00000040
72# define ENET_MMFR_ST			0x40000000
73# define ENET_MMFR_OP_FORCEWRITE	0x00000000
74# define ENET_MMFR_OP_WRITE		0x10000000
75# define ENET_MMFR_OP_READ		0x20000000
76# define ENET_MMFR_OP_FORCEREAD		0x30000000
77# define ENET_MMFR_TA			0x00020000
78# define ENET_MMFR_PHY_ADDR(phy)	__SHIFTIN(phy, __BITS(27, 23))
79# define ENET_MMFR_PHY_REG(reg)		__SHIFTIN(reg, __BITS(22, 18))
80# define ENET_MMFR_DATAMASK		0x0000ffff
81#define ENET_MSCR			0x00000044
82# define ENET_MSCR_HOLDTIME_1CLK	0x00000000
83# define ENET_MSCR_HOLDTIME_2CLK	0x00000100
84# define ENET_MSCR_HOLDTIME_3CLK	0x00000200
85# define ENET_MSCR_HOLDTIME_8CLK	0x00000700
86# define ENET_MSCR_DIS_PRE		__BIT(7)
87# define ENET_MSCR_MII_SPEED_25MHZ	__SHIFTIN(4, __BITS(6, 1))
88# define ENET_MSCR_MII_SPEED_33MHZ	__SHIFTIN(6, __BITS(6, 1))
89# define ENET_MSCR_MII_SPEED_40MHZ	__SHIFTIN(7, __BITS(6, 1))
90# define ENET_MSCR_MII_SPEED_50MHZ	__SHIFTIN(9, __BITS(6, 1))
91# define ENET_MSCR_MII_SPEED_66MHZ	__SHIFTIN(13, __BITS(6, 1))
92
93#define ENET_MIBC			0x00000064
94# define ENET_MIBC_MIB_DIS		__BIT(31)
95# define ENET_MIBC_MIB_IDLE		__BIT(30)
96# define ENET_MIBC_MIB_CLEAR		__BIT(29)
97
98#define ENET_RCR			0x00000084
99# define ENET_RCR_GRS			__BIT(31)
100# define ENET_RCR_NLC			__BIT(30)
101# define ENET_RCR_MAX_FL(n)		__SHIFTIN(n, __BITS(29, 16))
102# define ENET_RCR_CFEN			__BIT(15)
103# define ENET_RCR_CRCFWD		__BIT(14)
104# define ENET_RCR_PAUFWD		__BIT(13)
105# define ENET_RCR_PADEN			__BIT(12)
106# define ENET_RCR_RMII_10T		__BIT(9)
107# define ENET_RCR_RGMII_EN		__BIT(6)
108# define ENET_RCR_FCE			__BIT(5)
109# define ENET_RCR_PROM			__BIT(3)
110# define ENET_RCR_DRT			__BIT(1)
111
112#define ENET_TCR			0x000000c4
113# define ENET_TCR_FDEN			__BIT(2)
114
115#define ENET_PALR			0x000000e4
116#define ENET_PAUR			0x000000e8
117#define ENET_OPD			0x000000ec
118#define ENET_IAUR			0x00000118
119#define ENET_IALR			0x0000011c
120#define ENET_GAUR			0x00000120
121#define ENET_GALR			0x00000124
122#define ENET_TFWR			0x00000144
123# define ENET_TFWR_STRFWD		__BIT(8)
124# define ENET_TFWR_FIFO(n)		__SHIFTIN(((n) / 64), __BITS(5, 0))
125#define ENET_RDSR			0x00000180
126#define ENET_TDSR			0x00000184
127#define ENET_MRBR			0x00000188
128#define ENET_RSFL			0x00000190
129#define ENET_RSEM			0x00000194
130#define ENET_RAEM			0x00000198
131#define ENET_RAFL			0x0000019c
132#define ENET_TSEM			0x000001a0
133#define ENET_TAEM			0x000001a4
134#define ENET_TAFL			0x000001a8
135#define ENET_TIPG			0x000001ac
136#define ENET_FTRL			0x000001b0
137#define ENET_TACC			0x000001c0
138# define ENET_TACC_PROCHK		__BIT(4)
139# define ENET_TACC_IPCHK		__BIT(3)
140# define ENET_TACC_SHIFT16		__BIT(0)
141#define ENET_RACC			0x000001c4
142# define ENET_RACC_SHIFT16		__BIT(7)
143# define ENET_RACC_LINEDIS		__BIT(6)
144# define ENET_RACC_PRODIS		__BIT(2)
145# define ENET_RACC_IPDIS		__BIT(1)
146# define ENET_RACC_PADREM		__BIT(0)
147
148/* Statistics counters */
149#define ENET_RMON_T_DROP		0x00000200
150#define ENET_RMON_T_PACKETS		0x00000204
151#define ENET_RMON_T_BC_PKT		0x00000208
152#define ENET_RMON_T_MC_PKT		0x0000020c
153#define ENET_RMON_T_CRC_ALIGN		0x00000210
154#define ENET_RMON_T_UNDERSIZE		0x00000214
155#define ENET_RMON_T_OVERSIZE		0x00000218
156#define ENET_RMON_T_FRAG		0x0000021c
157#define ENET_RMON_T_JAB			0x00000220
158#define ENET_RMON_T_COL			0x00000224
159#define ENET_RMON_T_P64			0x00000228
160#define ENET_RMON_T_P65TO127N		0x0000022c
161#define ENET_RMON_T_P128TO255N		0x00000230
162#define ENET_RMON_T_P256TO511		0x00000234
163#define ENET_RMON_T_P512TO1023		0x00000238
164#define ENET_RMON_T_P1024TO2047		0x0000023c
165#define ENET_RMON_T_P_GTE2048		0x00000240
166#define ENET_RMON_T_OCTETS		0x00000244
167#define ENET_IEEE_T_DROP		0x00000248
168#define ENET_IEEE_T_FRAME_OK		0x0000024c
169#define ENET_IEEE_T_1COL		0x00000250
170#define ENET_IEEE_T_MCOL		0x00000254
171#define ENET_IEEE_T_DEF			0x00000258
172#define ENET_IEEE_T_LCOL		0x0000025c
173#define ENET_IEEE_T_EXCOL		0x00000260
174#define ENET_IEEE_T_MACERR		0x00000264
175#define ENET_IEEE_T_CSERR		0x00000268
176#define ENET_IEEE_T_SQE			0x0000026c
177#define ENET_IEEE_T_FDXFC		0x00000270
178#define ENET_IEEE_T_OCTETS_OK		0x00000274
179#define ENET_RMON_R_PACKETS		0x00000284
180#define ENET_RMON_R_BC_PKT		0x00000288
181#define ENET_RMON_R_MC_PKT		0x0000028c
182#define ENET_RMON_R_CRC_ALIGN		0x00000290
183#define ENET_RMON_R_UNDERSIZE		0x00000294
184#define ENET_RMON_R_OVERSIZE		0x00000298
185#define ENET_RMON_R_FRAG		0x0000029c
186#define ENET_RMON_R_JAB			0x000002a0
187#define ENET_RMON_R_RESVD_0		0x000002a4
188#define ENET_RMON_R_P64			0x000002a8
189#define ENET_RMON_R_P65TO127		0x000002ac
190#define ENET_RMON_R_P128TO255		0x000002b0
191#define ENET_RMON_R_P256TO511		0x000002b4
192#define ENET_RMON_R_P512TO1023		0x000002b8
193#define ENET_RMON_R_P1024TO2047		0x000002bc
194#define ENET_RMON_R_P_GTE2048		0x000002c0
195#define ENET_RMON_R_OCTETS		0x000002c4
196#define ENET_IEEE_R_DROP		0x000002c8
197#define ENET_IEEE_R_FRAME_OK		0x000002cc
198#define ENET_IEEE_R_CRC			0x000002d0
199#define ENET_IEEE_R_ALIGN		0x000002d4
200#define ENET_IEEE_R_MACERR		0x000002d8
201#define ENET_IEEE_R_FDXFC		0x000002dc
202#define ENET_IEEE_R_OCTETS_OK		0x000002e0
203
204/* IEEE1588 control */
205#define ENET_ATCR			0x00000400
206#define ENET_ATVR			0x00000404
207#define ENET_ATOFF			0x00000408
208#define ENET_ATPER			0x0000040c
209#define ENET_ATCOR			0x00000410
210#define ENET_ATINC			0x00000414
211#define ENET_ATSTMP			0x00000418
212
213/* Capture/compare block */
214#define ENET_TGSR			0x00000604
215#define ENET_TCSR0			0x00000608
216#define ENET_TCCR0			0x0000060c
217#define ENET_TCSR1			0x00000610
218#define ENET_TCCR1			0x00000614
219#define ENET_TCSR2			0x00000618
220#define ENET_TCCR2			0x0000061c
221#define ENET_TCSR3			0x00000620
222#define ENET_TCCR3			0x00000624
223
224/* enhanced transmit buffer descriptor */
225struct enet_txdesc {
226	uint32_t tx_flags1_len;
227#define TXFLAGS1_R			__BIT(31)	/* Ready */
228#define TXFLAGS1_T1			__BIT(30)	/* TX software owner1 */
229#define TXFLAGS1_W			__BIT(29)	/* Wrap */
230#define TXFLAGS1_T2			__BIT(28)	/* TX software owner2 */
231#define TXFLAGS1_L			__BIT(27)	/* Last in frame */
232#define TXFLAGS1_TC			__BIT(26)	/* Transmit CRC */
233#define TXFLAGS1_ABC			__BIT(25)	/* Append bad CRC */
234#define TXFLAGS1_LEN(n)			((n) & 0xffff)
235	uint32_t tx_databuf;
236	uint32_t tx_flags2;
237#define TXFLAGS2_INT			__BIT(30)	/* Interrupt */
238#define TXFLAGS2_TS			__BIT(29)	/* Timestamp */
239#define TXFLAGS2_PINS			__BIT(28)	/* Insert Proto csum */
240#define TXFLAGS2_IINS			__BIT(27)	/* Insert IP csum */
241#define TXFLAGS2_TXE			__BIT(15)	/* Transmit error */
242#define TXFLAGS2_UE			__BIT(13)	/* Underflow error */
243#define TXFLAGS2_EE			__BIT(12)	/* Excess colls Err */
244#define TXFLAGS2_FE			__BIT(11)	/* Frame Error */
245#define TXFLAGS2_LCE			__BIT(10)	/* Late collision Err */
246#define TXFLAGS2_OE			__BIT(9)	/* Overfow Error */
247#define TXFLAGS2_TSE			__BIT(8)	/* Timestamp Error */
248	uint32_t tx__reserved1;
249	uint32_t tx_flags3;
250#define TXFLAGS3_BDU			__BIT(31)
251	uint32_t tx_1588timestamp;
252	uint32_t tx__reserved2;
253	uint32_t tx__reserved3;
254} __packed;
255
256/* enhanced receive buffer descriptor */
257struct enet_rxdesc {
258	uint32_t rx_flags1_len;
259#define RXFLAGS1_E			__BIT(31)	/* Empty */
260#define RXFLAGS1_R1			__BIT(30)	/* RX software owner1 */
261#define RXFLAGS1_W			__BIT(29)	/* Wrap */
262#define RXFLAGS1_R2			__BIT(28)	/* RX software owner2 */
263#define RXFLAGS1_L			__BIT(27)	/* Last in frame */
264#define RXFLAGS1_M			__BIT(24)	/* Miss */
265#define RXFLAGS1_BC			__BIT(23)	/* Broadcast */
266#define RXFLAGS1_MC			__BIT(22)	/* Multicast */
267#define RXFLAGS1_LG			__BIT(21)	/* Length Violation */
268#define RXFLAGS1_NO			__BIT(20)	/* Non-Octet aligned  */
269#define RXFLAGS1_CR			__BIT(18)	/* CRC or frame error */
270#define RXFLAGS1_OV			__BIT(17)	/* Overrun */
271#define RXFLAGS1_TR			__BIT(16)	/* Truncated */
272#define RXFLAGS1_LEN(n)			((n) & 0xffff)
273	uint32_t rx_databuf;
274	uint32_t rx_flags2;
275#define RXFLAGS2_ME			__BIT(31)	/* MAC error */
276#define RXFLAGS2_PE			__BIT(26)	/* PHY error */
277#define RXFLAGS2_CE			__BIT(25)	/* Collision */
278#define RXFLAGS2_UC			__BIT(24)	/* Unicast */
279#define RXFLAGS2_INT			__BIT(23)	/* RXB/RXF interrupt */
280#define RXFLAGS2_ICE			__BIT(5)	/* IP csum error */
281#define RXFLAGS2_PCR			__BIT(4)	/* Proto csum error */
282#define RXFLAGS2_VLAN			__BIT(2)	/* VLAN */
283#define RXFLAGS2_IPV6			__BIT(1)	/* IPv6 frame */
284#define RXFLAGS2_FRAG			__BIT(0)	/* IPv4 fragment */
285#if _BYTE_ORDER == _LITTLE_ENDIAN
286	uint16_t rx_cksum;
287	uint8_t rx_proto;
288	uint8_t rx_hl;
289#else
290	uint8_t rx_hl;
291	uint8_t rx_proto;
292	uint16_t rx_cksum;
293#endif
294	uint32_t rx_flags3;
295#define RXFLAGS3_BDU			__BIT(31)
296	uint32_t rx_1588timestamp;
297	uint32_t rx__reserved2;
298	uint32_t rx__reserved3;
299} __packed;
300
301#endif /* _ARM_IMX_IF_ENETREG_H_ */
302