blob: ac5e45d4f90636b0505e3f852f51b145eb1158fc [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001/* SPDX-License-Identifier: GPL-2.0+ */
Jiandong Zhengc36e42e2014-08-01 20:37:16 -07002/*
3 * Copyright 2014 Broadcom Corporation.
Jiandong Zhengc36e42e2014-08-01 20:37:16 -07004 */
5
6#ifndef _BCM_SF2_ETH_GMAC_H_
7#define _BCM_SF2_ETH_GMAC_H_
8
9#define BCM_SF2_ETH_MAC_NAME "gmac"
10
11#ifndef ETHHW_PORT_INT
12#define ETHHW_PORT_INT 8
13#endif
14
15#define GMAC0_REG_BASE 0x18042000
16#define GMAC0_DEV_CTRL_ADDR GMAC0_REG_BASE
17#define GMAC0_INT_STATUS_ADDR (GMAC0_REG_BASE + 0x020)
18#define GMAC0_INTR_RECV_LAZY_ADDR (GMAC0_REG_BASE + 0x100)
19#define GMAC0_PHY_CTRL_ADDR (GMAC0_REG_BASE + 0x188)
20
Jiandong Zhengc36e42e2014-08-01 20:37:16 -070021#define GMAC_DMA_PTR_OFFSET 0x04
22#define GMAC_DMA_ADDR_LOW_OFFSET 0x08
23#define GMAC_DMA_ADDR_HIGH_OFFSET 0x0c
24#define GMAC_DMA_STATUS0_OFFSET 0x10
25#define GMAC_DMA_STATUS1_OFFSET 0x14
26
27#define GMAC0_DMA_TX_CTRL_ADDR (GMAC0_REG_BASE + 0x200)
28#define GMAC0_DMA_TX_PTR_ADDR \
29 (GMAC0_DMA_TX_CTRL_ADDR + GMAC_DMA_PTR_OFFSET)
30#define GMAC0_DMA_TX_ADDR_LOW_ADDR \
31 (GMAC0_DMA_TX_CTRL_ADDR + GMAC_DMA_ADDR_LOW_OFFSET)
32#define GMAC0_DMA_TX_ADDR_HIGH_ADDR \
33 (GMAC0_DMA_TX_CTRL_ADDR + GMAC_DMA_ADDR_HIGH_OFFSET)
34#define GMAC0_DMA_TX_STATUS0_ADDR \
35 (GMAC0_DMA_TX_CTRL_ADDR + GMAC_DMA_STATUS0_OFFSET)
36#define GMAC0_DMA_TX_STATUS1_ADDR \
37 (GMAC0_DMA_TX_CTRL_ADDR + GMAC_DMA_STATUS1_OFFSET)
38
39#define GMAC0_DMA_RX_CTRL_ADDR (GMAC0_REG_BASE + 0x220)
40#define GMAC0_DMA_RX_PTR_ADDR \
41 (GMAC0_DMA_RX_CTRL_ADDR + GMAC_DMA_PTR_OFFSET)
42#define GMAC0_DMA_RX_ADDR_LOW_ADDR \
43 (GMAC0_DMA_RX_CTRL_ADDR + GMAC_DMA_ADDR_LOW_OFFSET)
44#define GMAC0_DMA_RX_ADDR_HIGH_ADDR \
45 (GMAC0_DMA_RX_CTRL_ADDR + GMAC_DMA_ADDR_HIGH_OFFSET)
46#define GMAC0_DMA_RX_STATUS0_ADDR \
47 (GMAC0_DMA_RX_CTRL_ADDR + GMAC_DMA_STATUS0_OFFSET)
48#define GMAC0_DMA_RX_STATUS1_ADDR \
49 (GMAC0_DMA_RX_CTRL_ADDR + GMAC_DMA_STATUS1_OFFSET)
50
51#define UNIMAC0_CMD_CFG_ADDR (GMAC0_REG_BASE + 0x808)
52#define UNIMAC0_MAC_MSB_ADDR (GMAC0_REG_BASE + 0x80c)
53#define UNIMAC0_MAC_LSB_ADDR (GMAC0_REG_BASE + 0x810)
54#define UNIMAC0_FRM_LENGTH_ADDR (GMAC0_REG_BASE + 0x814)
55
56#define GMAC0_IRL_FRAMECOUNT_SHIFT 24
57
58/* transmit channel control */
59/* transmit enable */
60#define D64_XC_XE 0x00000001
61/* transmit suspend request */
62#define D64_XC_SE 0x00000002
63/* parity check disable */
64#define D64_XC_PD 0x00000800
65/* BurstLen bits */
66#define D64_XC_BL_MASK 0x001C0000
67#define D64_XC_BL_SHIFT 18
68
69/* transmit descriptor table pointer */
70/* last valid descriptor */
71#define D64_XP_LD_MASK 0x00001fff
72
73/* transmit channel status */
74/* transmit state */
75#define D64_XS0_XS_MASK 0xf0000000
76#define D64_XS0_XS_SHIFT 28
77#define D64_XS0_XS_DISABLED 0x00000000
78#define D64_XS0_XS_ACTIVE 0x10000000
79#define D64_XS0_XS_IDLE 0x20000000
80#define D64_XS0_XS_STOPPED 0x30000000
81#define D64_XS0_XS_SUSP 0x40000000
82
83/* receive channel control */
84/* receive enable */
85#define D64_RC_RE 0x00000001
86/* address extension bits */
87#define D64_RC_AE 0x00030000
88/* overflow continue */
89#define D64_RC_OC 0x00000400
90/* parity check disable */
91#define D64_RC_PD 0x00000800
92/* receive frame offset */
93#define D64_RC_RO_MASK 0x000000fe
94#define D64_RC_RO_SHIFT 1
95/* BurstLen bits */
96#define D64_RC_BL_MASK 0x001C0000
97#define D64_RC_BL_SHIFT 18
98
99/* flags for dma controller */
100/* partity enable */
101#define DMA_CTRL_PEN (1 << 0)
102/* rx overflow continue */
103#define DMA_CTRL_ROC (1 << 1)
104
105/* receive descriptor table pointer */
106/* last valid descriptor */
107#define D64_RP_LD_MASK 0x00001fff
108
109/* receive channel status */
110/* current descriptor pointer */
111#define D64_RS0_CD_MASK 0x00001fff
112/* receive state */
113#define D64_RS0_RS_MASK 0xf0000000
114#define D64_RS0_RS_SHIFT 28
115#define D64_RS0_RS_DISABLED 0x00000000
116#define D64_RS0_RS_ACTIVE 0x10000000
117#define D64_RS0_RS_IDLE 0x20000000
118#define D64_RS0_RS_STOPPED 0x30000000
119#define D64_RS0_RS_SUSP 0x40000000
120
121/* descriptor control flags 1 */
122/* core specific flags */
123#define D64_CTRL_COREFLAGS 0x0ff00000
124/* end of descriptor table */
125#define D64_CTRL1_EOT ((uint32_t)1 << 28)
126/* interrupt on completion */
127#define D64_CTRL1_IOC ((uint32_t)1 << 29)
128/* end of frame */
129#define D64_CTRL1_EOF ((uint32_t)1 << 30)
130/* start of frame */
131#define D64_CTRL1_SOF ((uint32_t)1 << 31)
132
133/* descriptor control flags 2 */
134/* buffer byte count. real data len must <= 16KB */
135#define D64_CTRL2_BC_MASK 0x00007fff
136/* address extension bits */
137#define D64_CTRL2_AE 0x00030000
138#define D64_CTRL2_AE_SHIFT 16
139/* parity bit */
140#define D64_CTRL2_PARITY 0x00040000
141/* control flags in the range [27:20] are core-specific and not defined here */
142#define D64_CTRL_CORE_MASK 0x0ff00000
143
144#define DC_MROR 0x00000010
145#define PC_MTE 0x00800000
146
147/* command config */
148#define CC_TE 0x00000001
149#define CC_RE 0x00000002
150#define CC_ES_MASK 0x0000000c
151#define CC_ES_SHIFT 2
152#define CC_PROM 0x00000010
153#define CC_PAD_EN 0x00000020
154#define CC_CF 0x00000040
155#define CC_PF 0x00000080
156#define CC_RPI 0x00000100
157#define CC_TAI 0x00000200
158#define CC_HD 0x00000400
159#define CC_HD_SHIFT 10
160#define CC_SR 0x00002000
161#define CC_ML 0x00008000
162#define CC_AE 0x00400000
163#define CC_CFE 0x00800000
164#define CC_NLC 0x01000000
165#define CC_RL 0x02000000
166#define CC_RED 0x04000000
167#define CC_PE 0x08000000
168#define CC_TPI 0x10000000
169#define CC_AT 0x20000000
170
171#define I_PDEE 0x00000400
172#define I_PDE 0x00000800
173#define I_DE 0x00001000
174#define I_RDU 0x00002000
175#define I_RFO 0x00004000
176#define I_XFU 0x00008000
177#define I_RI 0x00010000
178#define I_XI0 0x01000000
179#define I_XI1 0x02000000
180#define I_XI2 0x04000000
181#define I_XI3 0x08000000
182#define I_ERRORS (I_PDEE | I_PDE | I_DE | I_RDU | I_RFO | I_XFU)
183#define DEF_INTMASK (I_XI0 | I_XI1 | I_XI2 | I_XI3 | I_RI | I_ERRORS)
184
185#define I_INTMASK 0x0f01fcff
186
187#define CHIP_DRU_BASE 0x0301d000
188#define CRMU_CHIP_IO_PAD_CONTROL_ADDR (CHIP_DRU_BASE + 0x0bc)
189#define SWITCH_GLOBAL_CONFIG_ADDR (CHIP_DRU_BASE + 0x194)
190
191#define CDRU_IOMUX_FORCE_PAD_IN_SHIFT 0
192#define CDRU_SWITCH_BYPASS_SWITCH_SHIFT 13
193
194#define AMAC0_IDM_RESET_ADDR 0x18110800
195#define AMAC0_IO_CTRL_DIRECT_ADDR 0x18110408
196#define AMAC0_IO_CTRL_CLK_250_SEL_SHIFT 6
197#define AMAC0_IO_CTRL_GMII_MODE_SHIFT 5
198#define AMAC0_IO_CTRL_DEST_SYNC_MODE_EN_SHIFT 3
199
200#define CHIPA_CHIP_ID_ADDR 0x18000000
201#define CHIPID (readl(CHIPA_CHIP_ID_ADDR) & 0xFFFF)
202#define CHIPREV (((readl(CHIPA_CHIP_ID_ADDR) >> 16) & 0xF)
203#define CHIPSKU (((readl(CHIPA_CHIP_ID_ADDR) >> 20) & 0xF)
204
205#define GMAC_MII_CTRL_ADDR 0x18002000
206#define GMAC_MII_CTRL_BYP_SHIFT 10
207#define GMAC_MII_CTRL_EXT_SHIFT 9
208#define GMAC_MII_DATA_ADDR 0x18002004
209#define GMAC_MII_DATA_READ_CMD 0x60020000
210#define GMAC_MII_DATA_WRITE_CMD 0x50020000
211#define GMAC_MII_BUSY_SHIFT 8
212#define GMAC_MII_PHY_ADDR_SHIFT 23
213#define GMAC_MII_PHY_REG_SHIFT 18
214
215#define GMAC_RESET_DELAY 2
216#define HWRXOFF 30
217#define MAXNAMEL 8
218#define NUMTXQ 4
219
220int gmac_add(struct eth_device *dev);
221
222#endif /* _BCM_SF2_ETH_GMAC_H_ */