xref: /openbmc/u-boot/arch/arm/mach-at91/include/mach/at91_emac.h (revision 83d290c56fab2d38cd1ab4c4cc7099559c1d5046)
1*83d290c5STom Rini /* SPDX-License-Identifier: GPL-2.0+ */
2af930827SMasahiro Yamada /*
3af930827SMasahiro Yamada  * Copyright (C) 2009 Jens Scharsig (js_at_ng@scharsoft.de)
4af930827SMasahiro Yamada  *
5af930827SMasahiro Yamada  * based on AT91RM9200 datasheet revision I (36. Ethernet MAC (EMAC))
6af930827SMasahiro Yamada  */
7af930827SMasahiro Yamada 
8af930827SMasahiro Yamada #ifndef AT91_H
9af930827SMasahiro Yamada #define AT91_H
10af930827SMasahiro Yamada 
11af930827SMasahiro Yamada typedef struct at91_emac {
12af930827SMasahiro Yamada 	u32	 ctl;
13af930827SMasahiro Yamada 	u32	 cfg;
14af930827SMasahiro Yamada 	u32	 sr;
15af930827SMasahiro Yamada 	u32	 tar;
16af930827SMasahiro Yamada 	u32	 tcr;
17af930827SMasahiro Yamada 	u32	 tsr;
18af930827SMasahiro Yamada 	u32	 rbqp;
19af930827SMasahiro Yamada 	u32	 reserved0;
20af930827SMasahiro Yamada 	u32	 rsr;
21af930827SMasahiro Yamada 	u32	 isr;
22af930827SMasahiro Yamada 	u32	 ier;
23af930827SMasahiro Yamada 	u32	 idr;
24af930827SMasahiro Yamada 	u32	 imr;
25af930827SMasahiro Yamada 	u32	 man;
26af930827SMasahiro Yamada 	u32	 reserved1[2];
27af930827SMasahiro Yamada 	u32	 fra;
28af930827SMasahiro Yamada 	u32	 scol;
29af930827SMasahiro Yamada 	u32	 mocl;
30af930827SMasahiro Yamada 	u32	 ok;
31af930827SMasahiro Yamada 	u32	 seqe;
32af930827SMasahiro Yamada 	u32	 ale;
33af930827SMasahiro Yamada 	u32	 dte;
34af930827SMasahiro Yamada 	u32	 lcol;
35af930827SMasahiro Yamada 	u32	 ecol;
36af930827SMasahiro Yamada 	u32	 cse;
37af930827SMasahiro Yamada 	u32	 tue;
38af930827SMasahiro Yamada 	u32	 cde;
39af930827SMasahiro Yamada 	u32	 elr;
40af930827SMasahiro Yamada 	u32	 rjb;
41af930827SMasahiro Yamada 	u32	 usf;
42af930827SMasahiro Yamada 	u32	 sqee;
43af930827SMasahiro Yamada 	u32	 drfc;
44af930827SMasahiro Yamada 	u32	 reserved2[3];
45af930827SMasahiro Yamada 	u32	 hsh;
46af930827SMasahiro Yamada 	u32	 hsl;
47af930827SMasahiro Yamada 	u32	 sa1l;
48af930827SMasahiro Yamada 	u32	 sa1h;
49af930827SMasahiro Yamada 	u32	 sa2l;
50af930827SMasahiro Yamada 	u32	 sa2h;
51af930827SMasahiro Yamada 	u32	 sa3l;
52af930827SMasahiro Yamada 	u32	 sa3h;
53af930827SMasahiro Yamada 	u32	 sa4l;
54af930827SMasahiro Yamada 	u32	 sa4h;
55af930827SMasahiro Yamada } at91_emac_t;
56af930827SMasahiro Yamada 
57af930827SMasahiro Yamada #define AT91_EMAC_CTL_LB	0x0001
58af930827SMasahiro Yamada #define AT91_EMAC_CTL_LBL	0x0002
59af930827SMasahiro Yamada #define AT91_EMAC_CTL_RE	0x0004
60af930827SMasahiro Yamada #define AT91_EMAC_CTL_TE	0x0008
61af930827SMasahiro Yamada #define AT91_EMAC_CTL_MPE	0x0010
62af930827SMasahiro Yamada #define AT91_EMAC_CTL_CSR	0x0020
63af930827SMasahiro Yamada #define AT91_EMAC_CTL_ISR	0x0040
64af930827SMasahiro Yamada #define AT91_EMAC_CTL_WES	0x0080
65af930827SMasahiro Yamada #define AT91_EMAC_CTL_BP	0x1000
66af930827SMasahiro Yamada 
67af930827SMasahiro Yamada #define AT91_EMAC_CFG_SPD	0x0001
68af930827SMasahiro Yamada #define AT91_EMAC_CFG_FD	0x0002
69af930827SMasahiro Yamada #define AT91_EMAC_CFG_BR	0x0004
70af930827SMasahiro Yamada #define AT91_EMAC_CFG_CAF	0x0010
71af930827SMasahiro Yamada #define AT91_EMAC_CFG_NBC	0x0020
72af930827SMasahiro Yamada #define AT91_EMAC_CFG_MTI	0x0040
73af930827SMasahiro Yamada #define AT91_EMAC_CFG_UNI	0x0080
74af930827SMasahiro Yamada #define AT91_EMAC_CFG_BIG	0x0100
75af930827SMasahiro Yamada #define AT91_EMAC_CFG_EAE	0x0200
76af930827SMasahiro Yamada #define AT91_EMAC_CFG_CLK_MASK	0xFFFFF3FF
77af930827SMasahiro Yamada #define AT91_EMAC_CFG_MCLK_8	0x0000
78af930827SMasahiro Yamada #define AT91_EMAC_CFG_MCLK_16	0x0400
79af930827SMasahiro Yamada #define AT91_EMAC_CFG_MCLK_32	0x0800
80af930827SMasahiro Yamada #define AT91_EMAC_CFG_MCLK_64	0x0C00
81af930827SMasahiro Yamada #define AT91_EMAC_CFG_RTY	0x1000
82af930827SMasahiro Yamada #define AT91_EMAC_CFG_RMII	0x2000
83af930827SMasahiro Yamada 
84af930827SMasahiro Yamada #define AT91_EMAC_SR_LINK	0x0001
85af930827SMasahiro Yamada #define AT91_EMAC_SR_MDIO	0x0002
86af930827SMasahiro Yamada #define AT91_EMAC_SR_IDLE	0x0004
87af930827SMasahiro Yamada 
88af930827SMasahiro Yamada #define AT91_EMAC_TCR_LEN(x)	(x & 0x7FF)
89af930827SMasahiro Yamada #define AT91_EMAC_TCR_NCRC	0x8000
90af930827SMasahiro Yamada 
91af930827SMasahiro Yamada #define AT91_EMAC_TSR_OVR	0x0001
92af930827SMasahiro Yamada #define AT91_EMAC_TSR_COL	0x0002
93af930827SMasahiro Yamada #define AT91_EMAC_TSR_RLE	0x0004
94af930827SMasahiro Yamada #define AT91_EMAC_TSR_TXIDLE	0x0008
95af930827SMasahiro Yamada #define AT91_EMAC_TSR_BNQ	0x0010
96af930827SMasahiro Yamada #define AT91_EMAC_TSR_COMP	0x0020
97af930827SMasahiro Yamada #define AT91_EMAC_TSR_UND	0x0040
98af930827SMasahiro Yamada 
99af930827SMasahiro Yamada #define AT91_EMAC_RSR_BNA	0x0001
100af930827SMasahiro Yamada #define AT91_EMAC_RSR_REC	0x0002
101af930827SMasahiro Yamada #define AT91_EMAC_RSR_OVR	0x0004
102af930827SMasahiro Yamada 
103af930827SMasahiro Yamada /*  ISR, IER, IDR, IMR use the same bits */
104af930827SMasahiro Yamada #define AT91_EMAC_IxR_DONE	0x0001
105af930827SMasahiro Yamada #define AT91_EMAC_IxR_RCOM	0x0002
106af930827SMasahiro Yamada #define AT91_EMAC_IxR_RBNA	0x0004
107af930827SMasahiro Yamada #define AT91_EMAC_IxR_TOVR	0x0008
108af930827SMasahiro Yamada #define AT91_EMAC_IxR_TUND	0x0010
109af930827SMasahiro Yamada #define AT91_EMAC_IxR_RTRY	0x0020
110af930827SMasahiro Yamada #define AT91_EMAC_IxR_TBRE	0x0040
111af930827SMasahiro Yamada #define AT91_EMAC_IxR_TCOM	0x0080
112af930827SMasahiro Yamada #define AT91_EMAC_IxR_TIDLE	0x0100
113af930827SMasahiro Yamada #define AT91_EMAC_IxR_LINK	0x0200
114af930827SMasahiro Yamada #define AT91_EMAC_IxR_ROVR	0x0400
115af930827SMasahiro Yamada #define AT91_EMAC_IxR_HRESP	0x0800
116af930827SMasahiro Yamada 
117af930827SMasahiro Yamada #define AT91_EMAC_MAN_DATA_MASK		0xFFFF
118af930827SMasahiro Yamada #define AT91_EMAC_MAN_CODE_802_3	0x00020000
119af930827SMasahiro Yamada #define AT91_EMAC_MAN_REGA(reg)		((reg & 0x1F) << 18)
120af930827SMasahiro Yamada #define AT91_EMAC_MAN_PHYA(phy)		((phy & 0x1F) << 23)
121af930827SMasahiro Yamada #define AT91_EMAC_MAN_RW_R		0x20000000
122af930827SMasahiro Yamada #define AT91_EMAC_MAN_RW_W		0x10000000
123af930827SMasahiro Yamada #define AT91_EMAC_MAN_HIGH		0x40000000
124af930827SMasahiro Yamada #define AT91_EMAC_MAN_LOW		0x80000000
125af930827SMasahiro Yamada 
126af930827SMasahiro Yamada #endif
127