• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

Commit MetaInfo

Revision149e80f74b6c28ff3e06b210579919cbb2c69a8d (tree)
Time2022-07-26 18:29:01
AuthorPeng Fan <peng.fan@nxp....>
CommiterStefano Babic

Log Message

net: dwc_eth_qos: public some functions

Move macros and structures to header file and make some functions
public, so that could used by other files, this is to
prepare split platform specific config to one file.

Signed-off-by: Peng Fan <peng.fan@nxp.com>

Change Summary

Incremental Difference

--- a/drivers/net/dwc_eth_qos.c
+++ b/drivers/net/dwc_eth_qos.c
@@ -51,275 +51,9 @@
5151 #include <asm/arch/clock.h>
5252 #include <asm/mach-imx/sys_proto.h>
5353 #endif
54-#include <linux/bitops.h>
5554 #include <linux/delay.h>
5655
57-/* Core registers */
58-
59-#define EQOS_MAC_REGS_BASE 0x000
60-struct eqos_mac_regs {
61- uint32_t configuration; /* 0x000 */
62- uint32_t unused_004[(0x070 - 0x004) / 4]; /* 0x004 */
63- uint32_t q0_tx_flow_ctrl; /* 0x070 */
64- uint32_t unused_070[(0x090 - 0x074) / 4]; /* 0x074 */
65- uint32_t rx_flow_ctrl; /* 0x090 */
66- uint32_t unused_094; /* 0x094 */
67- uint32_t txq_prty_map0; /* 0x098 */
68- uint32_t unused_09c; /* 0x09c */
69- uint32_t rxq_ctrl0; /* 0x0a0 */
70- uint32_t unused_0a4; /* 0x0a4 */
71- uint32_t rxq_ctrl2; /* 0x0a8 */
72- uint32_t unused_0ac[(0x0dc - 0x0ac) / 4]; /* 0x0ac */
73- uint32_t us_tic_counter; /* 0x0dc */
74- uint32_t unused_0e0[(0x11c - 0x0e0) / 4]; /* 0x0e0 */
75- uint32_t hw_feature0; /* 0x11c */
76- uint32_t hw_feature1; /* 0x120 */
77- uint32_t hw_feature2; /* 0x124 */
78- uint32_t unused_128[(0x200 - 0x128) / 4]; /* 0x128 */
79- uint32_t mdio_address; /* 0x200 */
80- uint32_t mdio_data; /* 0x204 */
81- uint32_t unused_208[(0x300 - 0x208) / 4]; /* 0x208 */
82- uint32_t address0_high; /* 0x300 */
83- uint32_t address0_low; /* 0x304 */
84-};
85-
86-#define EQOS_MAC_CONFIGURATION_GPSLCE BIT(23)
87-#define EQOS_MAC_CONFIGURATION_CST BIT(21)
88-#define EQOS_MAC_CONFIGURATION_ACS BIT(20)
89-#define EQOS_MAC_CONFIGURATION_WD BIT(19)
90-#define EQOS_MAC_CONFIGURATION_JD BIT(17)
91-#define EQOS_MAC_CONFIGURATION_JE BIT(16)
92-#define EQOS_MAC_CONFIGURATION_PS BIT(15)
93-#define EQOS_MAC_CONFIGURATION_FES BIT(14)
94-#define EQOS_MAC_CONFIGURATION_DM BIT(13)
95-#define EQOS_MAC_CONFIGURATION_LM BIT(12)
96-#define EQOS_MAC_CONFIGURATION_TE BIT(1)
97-#define EQOS_MAC_CONFIGURATION_RE BIT(0)
98-
99-#define EQOS_MAC_Q0_TX_FLOW_CTRL_PT_SHIFT 16
100-#define EQOS_MAC_Q0_TX_FLOW_CTRL_PT_MASK 0xffff
101-#define EQOS_MAC_Q0_TX_FLOW_CTRL_TFE BIT(1)
102-
103-#define EQOS_MAC_RX_FLOW_CTRL_RFE BIT(0)
104-
105-#define EQOS_MAC_TXQ_PRTY_MAP0_PSTQ0_SHIFT 0
106-#define EQOS_MAC_TXQ_PRTY_MAP0_PSTQ0_MASK 0xff
107-
108-#define EQOS_MAC_RXQ_CTRL0_RXQ0EN_SHIFT 0
109-#define EQOS_MAC_RXQ_CTRL0_RXQ0EN_MASK 3
110-#define EQOS_MAC_RXQ_CTRL0_RXQ0EN_NOT_ENABLED 0
111-#define EQOS_MAC_RXQ_CTRL0_RXQ0EN_ENABLED_DCB 2
112-#define EQOS_MAC_RXQ_CTRL0_RXQ0EN_ENABLED_AV 1
113-
114-#define EQOS_MAC_RXQ_CTRL2_PSRQ0_SHIFT 0
115-#define EQOS_MAC_RXQ_CTRL2_PSRQ0_MASK 0xff
116-
117-#define EQOS_MAC_HW_FEATURE0_MMCSEL_SHIFT 8
118-#define EQOS_MAC_HW_FEATURE0_HDSEL_SHIFT 2
119-#define EQOS_MAC_HW_FEATURE0_GMIISEL_SHIFT 1
120-#define EQOS_MAC_HW_FEATURE0_MIISEL_SHIFT 0
121-
122-#define EQOS_MAC_HW_FEATURE1_TXFIFOSIZE_SHIFT 6
123-#define EQOS_MAC_HW_FEATURE1_TXFIFOSIZE_MASK 0x1f
124-#define EQOS_MAC_HW_FEATURE1_RXFIFOSIZE_SHIFT 0
125-#define EQOS_MAC_HW_FEATURE1_RXFIFOSIZE_MASK 0x1f
126-
127-#define EQOS_MAC_HW_FEATURE3_ASP_SHIFT 28
128-#define EQOS_MAC_HW_FEATURE3_ASP_MASK 0x3
129-
130-#define EQOS_MAC_MDIO_ADDRESS_PA_SHIFT 21
131-#define EQOS_MAC_MDIO_ADDRESS_RDA_SHIFT 16
132-#define EQOS_MAC_MDIO_ADDRESS_CR_SHIFT 8
133-#define EQOS_MAC_MDIO_ADDRESS_CR_20_35 2
134-#define EQOS_MAC_MDIO_ADDRESS_CR_250_300 5
135-#define EQOS_MAC_MDIO_ADDRESS_SKAP BIT(4)
136-#define EQOS_MAC_MDIO_ADDRESS_GOC_SHIFT 2
137-#define EQOS_MAC_MDIO_ADDRESS_GOC_READ 3
138-#define EQOS_MAC_MDIO_ADDRESS_GOC_WRITE 1
139-#define EQOS_MAC_MDIO_ADDRESS_C45E BIT(1)
140-#define EQOS_MAC_MDIO_ADDRESS_GB BIT(0)
141-
142-#define EQOS_MAC_MDIO_DATA_GD_MASK 0xffff
143-
144-#define EQOS_MTL_REGS_BASE 0xd00
145-struct eqos_mtl_regs {
146- uint32_t txq0_operation_mode; /* 0xd00 */
147- uint32_t unused_d04; /* 0xd04 */
148- uint32_t txq0_debug; /* 0xd08 */
149- uint32_t unused_d0c[(0xd18 - 0xd0c) / 4]; /* 0xd0c */
150- uint32_t txq0_quantum_weight; /* 0xd18 */
151- uint32_t unused_d1c[(0xd30 - 0xd1c) / 4]; /* 0xd1c */
152- uint32_t rxq0_operation_mode; /* 0xd30 */
153- uint32_t unused_d34; /* 0xd34 */
154- uint32_t rxq0_debug; /* 0xd38 */
155-};
156-
157-#define EQOS_MTL_TXQ0_OPERATION_MODE_TQS_SHIFT 16
158-#define EQOS_MTL_TXQ0_OPERATION_MODE_TQS_MASK 0x1ff
159-#define EQOS_MTL_TXQ0_OPERATION_MODE_TXQEN_SHIFT 2
160-#define EQOS_MTL_TXQ0_OPERATION_MODE_TXQEN_MASK 3
161-#define EQOS_MTL_TXQ0_OPERATION_MODE_TXQEN_ENABLED 2
162-#define EQOS_MTL_TXQ0_OPERATION_MODE_TSF BIT(1)
163-#define EQOS_MTL_TXQ0_OPERATION_MODE_FTQ BIT(0)
164-
165-#define EQOS_MTL_TXQ0_DEBUG_TXQSTS BIT(4)
166-#define EQOS_MTL_TXQ0_DEBUG_TRCSTS_SHIFT 1
167-#define EQOS_MTL_TXQ0_DEBUG_TRCSTS_MASK 3
168-
169-#define EQOS_MTL_RXQ0_OPERATION_MODE_RQS_SHIFT 20
170-#define EQOS_MTL_RXQ0_OPERATION_MODE_RQS_MASK 0x3ff
171-#define EQOS_MTL_RXQ0_OPERATION_MODE_RFD_SHIFT 14
172-#define EQOS_MTL_RXQ0_OPERATION_MODE_RFD_MASK 0x3f
173-#define EQOS_MTL_RXQ0_OPERATION_MODE_RFA_SHIFT 8
174-#define EQOS_MTL_RXQ0_OPERATION_MODE_RFA_MASK 0x3f
175-#define EQOS_MTL_RXQ0_OPERATION_MODE_EHFC BIT(7)
176-#define EQOS_MTL_RXQ0_OPERATION_MODE_RSF BIT(5)
177-
178-#define EQOS_MTL_RXQ0_DEBUG_PRXQ_SHIFT 16
179-#define EQOS_MTL_RXQ0_DEBUG_PRXQ_MASK 0x7fff
180-#define EQOS_MTL_RXQ0_DEBUG_RXQSTS_SHIFT 4
181-#define EQOS_MTL_RXQ0_DEBUG_RXQSTS_MASK 3
182-
183-#define EQOS_DMA_REGS_BASE 0x1000
184-struct eqos_dma_regs {
185- uint32_t mode; /* 0x1000 */
186- uint32_t sysbus_mode; /* 0x1004 */
187- uint32_t unused_1008[(0x1100 - 0x1008) / 4]; /* 0x1008 */
188- uint32_t ch0_control; /* 0x1100 */
189- uint32_t ch0_tx_control; /* 0x1104 */
190- uint32_t ch0_rx_control; /* 0x1108 */
191- uint32_t unused_110c; /* 0x110c */
192- uint32_t ch0_txdesc_list_haddress; /* 0x1110 */
193- uint32_t ch0_txdesc_list_address; /* 0x1114 */
194- uint32_t ch0_rxdesc_list_haddress; /* 0x1118 */
195- uint32_t ch0_rxdesc_list_address; /* 0x111c */
196- uint32_t ch0_txdesc_tail_pointer; /* 0x1120 */
197- uint32_t unused_1124; /* 0x1124 */
198- uint32_t ch0_rxdesc_tail_pointer; /* 0x1128 */
199- uint32_t ch0_txdesc_ring_length; /* 0x112c */
200- uint32_t ch0_rxdesc_ring_length; /* 0x1130 */
201-};
202-
203-#define EQOS_DMA_MODE_SWR BIT(0)
204-
205-#define EQOS_DMA_SYSBUS_MODE_RD_OSR_LMT_SHIFT 16
206-#define EQOS_DMA_SYSBUS_MODE_RD_OSR_LMT_MASK 0xf
207-#define EQOS_DMA_SYSBUS_MODE_EAME BIT(11)
208-#define EQOS_DMA_SYSBUS_MODE_BLEN16 BIT(3)
209-#define EQOS_DMA_SYSBUS_MODE_BLEN8 BIT(2)
210-#define EQOS_DMA_SYSBUS_MODE_BLEN4 BIT(1)
211-
212-#define EQOS_DMA_CH0_CONTROL_DSL_SHIFT 18
213-#define EQOS_DMA_CH0_CONTROL_PBLX8 BIT(16)
214-
215-#define EQOS_DMA_CH0_TX_CONTROL_TXPBL_SHIFT 16
216-#define EQOS_DMA_CH0_TX_CONTROL_TXPBL_MASK 0x3f
217-#define EQOS_DMA_CH0_TX_CONTROL_OSP BIT(4)
218-#define EQOS_DMA_CH0_TX_CONTROL_ST BIT(0)
219-
220-#define EQOS_DMA_CH0_RX_CONTROL_RXPBL_SHIFT 16
221-#define EQOS_DMA_CH0_RX_CONTROL_RXPBL_MASK 0x3f
222-#define EQOS_DMA_CH0_RX_CONTROL_RBSZ_SHIFT 1
223-#define EQOS_DMA_CH0_RX_CONTROL_RBSZ_MASK 0x3fff
224-#define EQOS_DMA_CH0_RX_CONTROL_SR BIT(0)
225-
226-/* These registers are Tegra186-specific */
227-#define EQOS_TEGRA186_REGS_BASE 0x8800
228-struct eqos_tegra186_regs {
229- uint32_t sdmemcomppadctrl; /* 0x8800 */
230- uint32_t auto_cal_config; /* 0x8804 */
231- uint32_t unused_8808; /* 0x8808 */
232- uint32_t auto_cal_status; /* 0x880c */
233-};
234-
235-#define EQOS_SDMEMCOMPPADCTRL_PAD_E_INPUT_OR_E_PWRD BIT(31)
236-
237-#define EQOS_AUTO_CAL_CONFIG_START BIT(31)
238-#define EQOS_AUTO_CAL_CONFIG_ENABLE BIT(29)
239-
240-#define EQOS_AUTO_CAL_STATUS_ACTIVE BIT(31)
241-
242-/* Descriptors */
243-#define EQOS_DESCRIPTORS_TX 4
244-#define EQOS_DESCRIPTORS_RX 4
245-#define EQOS_DESCRIPTORS_NUM (EQOS_DESCRIPTORS_TX + EQOS_DESCRIPTORS_RX)
246-#define EQOS_BUFFER_ALIGN ARCH_DMA_MINALIGN
247-#define EQOS_MAX_PACKET_SIZE ALIGN(1568, ARCH_DMA_MINALIGN)
248-#define EQOS_RX_BUFFER_SIZE (EQOS_DESCRIPTORS_RX * EQOS_MAX_PACKET_SIZE)
249-
250-struct eqos_desc {
251- u32 des0;
252- u32 des1;
253- u32 des2;
254- u32 des3;
255-};
256-
257-#define EQOS_DESC3_OWN BIT(31)
258-#define EQOS_DESC3_FD BIT(29)
259-#define EQOS_DESC3_LD BIT(28)
260-#define EQOS_DESC3_BUF1V BIT(24)
261-
262-#define EQOS_AXI_WIDTH_32 4
263-#define EQOS_AXI_WIDTH_64 8
264-#define EQOS_AXI_WIDTH_128 16
265-
266-struct eqos_config {
267- bool reg_access_always_ok;
268- int mdio_wait;
269- int swr_wait;
270- int config_mac;
271- int config_mac_mdio;
272- unsigned int axi_bus_width;
273- phy_interface_t (*interface)(const struct udevice *dev);
274- struct eqos_ops *ops;
275-};
276-
277-struct eqos_ops {
278- void (*eqos_inval_desc)(void *desc);
279- void (*eqos_flush_desc)(void *desc);
280- void (*eqos_inval_buffer)(void *buf, size_t size);
281- void (*eqos_flush_buffer)(void *buf, size_t size);
282- int (*eqos_probe_resources)(struct udevice *dev);
283- int (*eqos_remove_resources)(struct udevice *dev);
284- int (*eqos_stop_resets)(struct udevice *dev);
285- int (*eqos_start_resets)(struct udevice *dev);
286- int (*eqos_stop_clks)(struct udevice *dev);
287- int (*eqos_start_clks)(struct udevice *dev);
288- int (*eqos_calibrate_pads)(struct udevice *dev);
289- int (*eqos_disable_calibration)(struct udevice *dev);
290- int (*eqos_set_tx_clk_speed)(struct udevice *dev);
291- ulong (*eqos_get_tick_clk_rate)(struct udevice *dev);
292-};
293-
294-struct eqos_priv {
295- struct udevice *dev;
296- const struct eqos_config *config;
297- fdt_addr_t regs;
298- struct eqos_mac_regs *mac_regs;
299- struct eqos_mtl_regs *mtl_regs;
300- struct eqos_dma_regs *dma_regs;
301- struct eqos_tegra186_regs *tegra186_regs;
302- struct reset_ctl reset_ctl;
303- struct gpio_desc phy_reset_gpio;
304- struct clk clk_master_bus;
305- struct clk clk_rx;
306- struct clk clk_ptp_ref;
307- struct clk clk_tx;
308- struct clk clk_ck;
309- struct clk clk_slave_bus;
310- struct mii_dev *mii;
311- struct phy_device *phy;
312- u32 max_speed;
313- void *descs;
314- int tx_desc_idx, rx_desc_idx;
315- unsigned int desc_size;
316- void *tx_dma_buf;
317- void *rx_dma_buf;
318- void *rx_pkt;
319- bool started;
320- bool reg_access_ok;
321- bool clk_ck_enabled;
322-};
56+#include "dwc_eth_qos.h"
32357
32458 /*
32559 * TX and RX descriptors are 16 bytes. This causes problems with the cache
@@ -359,7 +93,7 @@ static struct eqos_desc *eqos_get_desc(struct eqos_priv *eqos,
35993 ((rx ? EQOS_DESCRIPTORS_TX : 0) + num) * eqos->desc_size;
36094 }
36195
362-static void eqos_inval_desc_generic(void *desc)
96+void eqos_inval_desc_generic(void *desc)
36397 {
36498 unsigned long start = (unsigned long)desc;
36599 unsigned long end = ALIGN(start + sizeof(struct eqos_desc),
@@ -368,7 +102,7 @@ static void eqos_inval_desc_generic(void *desc)
368102 invalidate_dcache_range(start, end);
369103 }
370104
371-static void eqos_flush_desc_generic(void *desc)
105+void eqos_flush_desc_generic(void *desc)
372106 {
373107 unsigned long start = (unsigned long)desc;
374108 unsigned long end = ALIGN(start + sizeof(struct eqos_desc),
@@ -377,7 +111,7 @@ static void eqos_flush_desc_generic(void *desc)
377111 flush_dcache_range(start, end);
378112 }
379113
380-static void eqos_inval_buffer_tegra186(void *buf, size_t size)
114+void eqos_inval_buffer_tegra186(void *buf, size_t size)
381115 {
382116 unsigned long start = (unsigned long)buf & ~(ARCH_DMA_MINALIGN - 1);
383117 unsigned long end = ALIGN(start + size, ARCH_DMA_MINALIGN);
@@ -385,7 +119,7 @@ static void eqos_inval_buffer_tegra186(void *buf, size_t size)
385119 invalidate_dcache_range(start, end);
386120 }
387121
388-static void eqos_inval_buffer_generic(void *buf, size_t size)
122+void eqos_inval_buffer_generic(void *buf, size_t size)
389123 {
390124 unsigned long start = rounddown((unsigned long)buf, ARCH_DMA_MINALIGN);
391125 unsigned long end = roundup((unsigned long)buf + size,
@@ -399,7 +133,7 @@ static void eqos_flush_buffer_tegra186(void *buf, size_t size)
399133 flush_cache((unsigned long)buf, size);
400134 }
401135
402-static void eqos_flush_buffer_generic(void *buf, size_t size)
136+void eqos_flush_buffer_generic(void *buf, size_t size)
403137 {
404138 unsigned long start = rounddown((unsigned long)buf, ARCH_DMA_MINALIGN);
405139 unsigned long end = roundup((unsigned long)buf + size,
@@ -1890,7 +1624,7 @@ static int eqos_remove(struct udevice *dev)
18901624 return 0;
18911625 }
18921626
1893-static int eqos_null_ops(struct udevice *dev)
1627+int eqos_null_ops(struct udevice *dev)
18941628 {
18951629 return 0;
18961630 }
--- /dev/null
+++ b/drivers/net/dwc_eth_qos.h
@@ -0,0 +1,280 @@
1+/* SPDX-License-Identifier: GPL-2.0+ */
2+/*
3+ * Copyright 2022 NXP
4+ */
5+
6+#include <phy_interface.h>
7+#include <linux/bitops.h>
8+
9+/* Core registers */
10+
11+#define EQOS_MAC_REGS_BASE 0x000
12+struct eqos_mac_regs {
13+ u32 configuration; /* 0x000 */
14+ u32 unused_004[(0x070 - 0x004) / 4]; /* 0x004 */
15+ u32 q0_tx_flow_ctrl; /* 0x070 */
16+ u32 unused_070[(0x090 - 0x074) / 4]; /* 0x074 */
17+ u32 rx_flow_ctrl; /* 0x090 */
18+ u32 unused_094; /* 0x094 */
19+ u32 txq_prty_map0; /* 0x098 */
20+ u32 unused_09c; /* 0x09c */
21+ u32 rxq_ctrl0; /* 0x0a0 */
22+ u32 unused_0a4; /* 0x0a4 */
23+ u32 rxq_ctrl2; /* 0x0a8 */
24+ u32 unused_0ac[(0x0dc - 0x0ac) / 4]; /* 0x0ac */
25+ u32 us_tic_counter; /* 0x0dc */
26+ u32 unused_0e0[(0x11c - 0x0e0) / 4]; /* 0x0e0 */
27+ u32 hw_feature0; /* 0x11c */
28+ u32 hw_feature1; /* 0x120 */
29+ u32 hw_feature2; /* 0x124 */
30+ u32 unused_128[(0x200 - 0x128) / 4]; /* 0x128 */
31+ u32 mdio_address; /* 0x200 */
32+ u32 mdio_data; /* 0x204 */
33+ u32 unused_208[(0x300 - 0x208) / 4]; /* 0x208 */
34+ u32 address0_high; /* 0x300 */
35+ u32 address0_low; /* 0x304 */
36+};
37+
38+#define EQOS_MAC_CONFIGURATION_GPSLCE BIT(23)
39+#define EQOS_MAC_CONFIGURATION_CST BIT(21)
40+#define EQOS_MAC_CONFIGURATION_ACS BIT(20)
41+#define EQOS_MAC_CONFIGURATION_WD BIT(19)
42+#define EQOS_MAC_CONFIGURATION_JD BIT(17)
43+#define EQOS_MAC_CONFIGURATION_JE BIT(16)
44+#define EQOS_MAC_CONFIGURATION_PS BIT(15)
45+#define EQOS_MAC_CONFIGURATION_FES BIT(14)
46+#define EQOS_MAC_CONFIGURATION_DM BIT(13)
47+#define EQOS_MAC_CONFIGURATION_LM BIT(12)
48+#define EQOS_MAC_CONFIGURATION_TE BIT(1)
49+#define EQOS_MAC_CONFIGURATION_RE BIT(0)
50+
51+#define EQOS_MAC_Q0_TX_FLOW_CTRL_PT_SHIFT 16
52+#define EQOS_MAC_Q0_TX_FLOW_CTRL_PT_MASK 0xffff
53+#define EQOS_MAC_Q0_TX_FLOW_CTRL_TFE BIT(1)
54+
55+#define EQOS_MAC_RX_FLOW_CTRL_RFE BIT(0)
56+
57+#define EQOS_MAC_TXQ_PRTY_MAP0_PSTQ0_SHIFT 0
58+#define EQOS_MAC_TXQ_PRTY_MAP0_PSTQ0_MASK 0xff
59+
60+#define EQOS_MAC_RXQ_CTRL0_RXQ0EN_SHIFT 0
61+#define EQOS_MAC_RXQ_CTRL0_RXQ0EN_MASK 3
62+#define EQOS_MAC_RXQ_CTRL0_RXQ0EN_NOT_ENABLED 0
63+#define EQOS_MAC_RXQ_CTRL0_RXQ0EN_ENABLED_DCB 2
64+#define EQOS_MAC_RXQ_CTRL0_RXQ0EN_ENABLED_AV 1
65+
66+#define EQOS_MAC_RXQ_CTRL2_PSRQ0_SHIFT 0
67+#define EQOS_MAC_RXQ_CTRL2_PSRQ0_MASK 0xff
68+
69+#define EQOS_MAC_HW_FEATURE0_MMCSEL_SHIFT 8
70+#define EQOS_MAC_HW_FEATURE0_HDSEL_SHIFT 2
71+#define EQOS_MAC_HW_FEATURE0_GMIISEL_SHIFT 1
72+#define EQOS_MAC_HW_FEATURE0_MIISEL_SHIFT 0
73+
74+#define EQOS_MAC_HW_FEATURE1_TXFIFOSIZE_SHIFT 6
75+#define EQOS_MAC_HW_FEATURE1_TXFIFOSIZE_MASK 0x1f
76+#define EQOS_MAC_HW_FEATURE1_RXFIFOSIZE_SHIFT 0
77+#define EQOS_MAC_HW_FEATURE1_RXFIFOSIZE_MASK 0x1f
78+
79+#define EQOS_MAC_HW_FEATURE3_ASP_SHIFT 28
80+#define EQOS_MAC_HW_FEATURE3_ASP_MASK 0x3
81+
82+#define EQOS_MAC_MDIO_ADDRESS_PA_SHIFT 21
83+#define EQOS_MAC_MDIO_ADDRESS_RDA_SHIFT 16
84+#define EQOS_MAC_MDIO_ADDRESS_CR_SHIFT 8
85+#define EQOS_MAC_MDIO_ADDRESS_CR_20_35 2
86+#define EQOS_MAC_MDIO_ADDRESS_CR_250_300 5
87+#define EQOS_MAC_MDIO_ADDRESS_SKAP BIT(4)
88+#define EQOS_MAC_MDIO_ADDRESS_GOC_SHIFT 2
89+#define EQOS_MAC_MDIO_ADDRESS_GOC_READ 3
90+#define EQOS_MAC_MDIO_ADDRESS_GOC_WRITE 1
91+#define EQOS_MAC_MDIO_ADDRESS_C45E BIT(1)
92+#define EQOS_MAC_MDIO_ADDRESS_GB BIT(0)
93+
94+#define EQOS_MAC_MDIO_DATA_GD_MASK 0xffff
95+
96+#define EQOS_MTL_REGS_BASE 0xd00
97+struct eqos_mtl_regs {
98+ u32 txq0_operation_mode; /* 0xd00 */
99+ u32 unused_d04; /* 0xd04 */
100+ u32 txq0_debug; /* 0xd08 */
101+ u32 unused_d0c[(0xd18 - 0xd0c) / 4]; /* 0xd0c */
102+ u32 txq0_quantum_weight; /* 0xd18 */
103+ u32 unused_d1c[(0xd30 - 0xd1c) / 4]; /* 0xd1c */
104+ u32 rxq0_operation_mode; /* 0xd30 */
105+ u32 unused_d34; /* 0xd34 */
106+ u32 rxq0_debug; /* 0xd38 */
107+};
108+
109+#define EQOS_MTL_TXQ0_OPERATION_MODE_TQS_SHIFT 16
110+#define EQOS_MTL_TXQ0_OPERATION_MODE_TQS_MASK 0x1ff
111+#define EQOS_MTL_TXQ0_OPERATION_MODE_TXQEN_SHIFT 2
112+#define EQOS_MTL_TXQ0_OPERATION_MODE_TXQEN_MASK 3
113+#define EQOS_MTL_TXQ0_OPERATION_MODE_TXQEN_ENABLED 2
114+#define EQOS_MTL_TXQ0_OPERATION_MODE_TSF BIT(1)
115+#define EQOS_MTL_TXQ0_OPERATION_MODE_FTQ BIT(0)
116+
117+#define EQOS_MTL_TXQ0_DEBUG_TXQSTS BIT(4)
118+#define EQOS_MTL_TXQ0_DEBUG_TRCSTS_SHIFT 1
119+#define EQOS_MTL_TXQ0_DEBUG_TRCSTS_MASK 3
120+
121+#define EQOS_MTL_RXQ0_OPERATION_MODE_RQS_SHIFT 20
122+#define EQOS_MTL_RXQ0_OPERATION_MODE_RQS_MASK 0x3ff
123+#define EQOS_MTL_RXQ0_OPERATION_MODE_RFD_SHIFT 14
124+#define EQOS_MTL_RXQ0_OPERATION_MODE_RFD_MASK 0x3f
125+#define EQOS_MTL_RXQ0_OPERATION_MODE_RFA_SHIFT 8
126+#define EQOS_MTL_RXQ0_OPERATION_MODE_RFA_MASK 0x3f
127+#define EQOS_MTL_RXQ0_OPERATION_MODE_EHFC BIT(7)
128+#define EQOS_MTL_RXQ0_OPERATION_MODE_RSF BIT(5)
129+
130+#define EQOS_MTL_RXQ0_DEBUG_PRXQ_SHIFT 16
131+#define EQOS_MTL_RXQ0_DEBUG_PRXQ_MASK 0x7fff
132+#define EQOS_MTL_RXQ0_DEBUG_RXQSTS_SHIFT 4
133+#define EQOS_MTL_RXQ0_DEBUG_RXQSTS_MASK 3
134+
135+#define EQOS_DMA_REGS_BASE 0x1000
136+struct eqos_dma_regs {
137+ u32 mode; /* 0x1000 */
138+ u32 sysbus_mode; /* 0x1004 */
139+ u32 unused_1008[(0x1100 - 0x1008) / 4]; /* 0x1008 */
140+ u32 ch0_control; /* 0x1100 */
141+ u32 ch0_tx_control; /* 0x1104 */
142+ u32 ch0_rx_control; /* 0x1108 */
143+ u32 unused_110c; /* 0x110c */
144+ u32 ch0_txdesc_list_haddress; /* 0x1110 */
145+ u32 ch0_txdesc_list_address; /* 0x1114 */
146+ u32 ch0_rxdesc_list_haddress; /* 0x1118 */
147+ u32 ch0_rxdesc_list_address; /* 0x111c */
148+ u32 ch0_txdesc_tail_pointer; /* 0x1120 */
149+ u32 unused_1124; /* 0x1124 */
150+ u32 ch0_rxdesc_tail_pointer; /* 0x1128 */
151+ u32 ch0_txdesc_ring_length; /* 0x112c */
152+ u32 ch0_rxdesc_ring_length; /* 0x1130 */
153+};
154+
155+#define EQOS_DMA_MODE_SWR BIT(0)
156+
157+#define EQOS_DMA_SYSBUS_MODE_RD_OSR_LMT_SHIFT 16
158+#define EQOS_DMA_SYSBUS_MODE_RD_OSR_LMT_MASK 0xf
159+#define EQOS_DMA_SYSBUS_MODE_EAME BIT(11)
160+#define EQOS_DMA_SYSBUS_MODE_BLEN16 BIT(3)
161+#define EQOS_DMA_SYSBUS_MODE_BLEN8 BIT(2)
162+#define EQOS_DMA_SYSBUS_MODE_BLEN4 BIT(1)
163+
164+#define EQOS_DMA_CH0_CONTROL_DSL_SHIFT 18
165+#define EQOS_DMA_CH0_CONTROL_PBLX8 BIT(16)
166+
167+#define EQOS_DMA_CH0_TX_CONTROL_TXPBL_SHIFT 16
168+#define EQOS_DMA_CH0_TX_CONTROL_TXPBL_MASK 0x3f
169+#define EQOS_DMA_CH0_TX_CONTROL_OSP BIT(4)
170+#define EQOS_DMA_CH0_TX_CONTROL_ST BIT(0)
171+
172+#define EQOS_DMA_CH0_RX_CONTROL_RXPBL_SHIFT 16
173+#define EQOS_DMA_CH0_RX_CONTROL_RXPBL_MASK 0x3f
174+#define EQOS_DMA_CH0_RX_CONTROL_RBSZ_SHIFT 1
175+#define EQOS_DMA_CH0_RX_CONTROL_RBSZ_MASK 0x3fff
176+#define EQOS_DMA_CH0_RX_CONTROL_SR BIT(0)
177+
178+/* These registers are Tegra186-specific */
179+#define EQOS_TEGRA186_REGS_BASE 0x8800
180+struct eqos_tegra186_regs {
181+ u32 sdmemcomppadctrl; /* 0x8800 */
182+ u32 auto_cal_config; /* 0x8804 */
183+ u32 unused_8808; /* 0x8808 */
184+ u32 auto_cal_status; /* 0x880c */
185+};
186+
187+#define EQOS_SDMEMCOMPPADCTRL_PAD_E_INPUT_OR_E_PWRD BIT(31)
188+
189+#define EQOS_AUTO_CAL_CONFIG_START BIT(31)
190+#define EQOS_AUTO_CAL_CONFIG_ENABLE BIT(29)
191+
192+#define EQOS_AUTO_CAL_STATUS_ACTIVE BIT(31)
193+
194+/* Descriptors */
195+#define EQOS_DESCRIPTORS_TX 4
196+#define EQOS_DESCRIPTORS_RX 4
197+#define EQOS_DESCRIPTORS_NUM (EQOS_DESCRIPTORS_TX + EQOS_DESCRIPTORS_RX)
198+#define EQOS_BUFFER_ALIGN ARCH_DMA_MINALIGN
199+#define EQOS_MAX_PACKET_SIZE ALIGN(1568, ARCH_DMA_MINALIGN)
200+#define EQOS_RX_BUFFER_SIZE (EQOS_DESCRIPTORS_RX * EQOS_MAX_PACKET_SIZE)
201+
202+struct eqos_desc {
203+ u32 des0;
204+ u32 des1;
205+ u32 des2;
206+ u32 des3;
207+};
208+
209+#define EQOS_DESC3_OWN BIT(31)
210+#define EQOS_DESC3_FD BIT(29)
211+#define EQOS_DESC3_LD BIT(28)
212+#define EQOS_DESC3_BUF1V BIT(24)
213+
214+#define EQOS_AXI_WIDTH_32 4
215+#define EQOS_AXI_WIDTH_64 8
216+#define EQOS_AXI_WIDTH_128 16
217+
218+struct eqos_config {
219+ bool reg_access_always_ok;
220+ int mdio_wait;
221+ int swr_wait;
222+ int config_mac;
223+ int config_mac_mdio;
224+ unsigned int axi_bus_width;
225+ phy_interface_t (*interface)(const struct udevice *dev);
226+ struct eqos_ops *ops;
227+};
228+
229+struct eqos_ops {
230+ void (*eqos_inval_desc)(void *desc);
231+ void (*eqos_flush_desc)(void *desc);
232+ void (*eqos_inval_buffer)(void *buf, size_t size);
233+ void (*eqos_flush_buffer)(void *buf, size_t size);
234+ int (*eqos_probe_resources)(struct udevice *dev);
235+ int (*eqos_remove_resources)(struct udevice *dev);
236+ int (*eqos_stop_resets)(struct udevice *dev);
237+ int (*eqos_start_resets)(struct udevice *dev);
238+ int (*eqos_stop_clks)(struct udevice *dev);
239+ int (*eqos_start_clks)(struct udevice *dev);
240+ int (*eqos_calibrate_pads)(struct udevice *dev);
241+ int (*eqos_disable_calibration)(struct udevice *dev);
242+ int (*eqos_set_tx_clk_speed)(struct udevice *dev);
243+ ulong (*eqos_get_tick_clk_rate)(struct udevice *dev);
244+};
245+
246+struct eqos_priv {
247+ struct udevice *dev;
248+ const struct eqos_config *config;
249+ fdt_addr_t regs;
250+ struct eqos_mac_regs *mac_regs;
251+ struct eqos_mtl_regs *mtl_regs;
252+ struct eqos_dma_regs *dma_regs;
253+ struct eqos_tegra186_regs *tegra186_regs;
254+ struct reset_ctl reset_ctl;
255+ struct gpio_desc phy_reset_gpio;
256+ struct clk clk_master_bus;
257+ struct clk clk_rx;
258+ struct clk clk_ptp_ref;
259+ struct clk clk_tx;
260+ struct clk clk_ck;
261+ struct clk clk_slave_bus;
262+ struct mii_dev *mii;
263+ struct phy_device *phy;
264+ u32 max_speed;
265+ void *descs;
266+ int tx_desc_idx, rx_desc_idx;
267+ unsigned int desc_size;
268+ void *tx_dma_buf;
269+ void *rx_dma_buf;
270+ void *rx_pkt;
271+ bool started;
272+ bool reg_access_ok;
273+ bool clk_ck_enabled;
274+};
275+
276+void eqos_inval_desc_generic(void *desc);
277+void eqos_flush_desc_generic(void *desc);
278+void eqos_inval_buffer_generic(void *buf, size_t size);
279+void eqos_flush_buffer_generic(void *buf, size_t size);
280+int eqos_null_ops(struct udevice *dev);