xref: /linux/drivers/net/dsa/lantiq/lantiq_gswip.h (revision 7a1eaef0a791e017b67c71836f5bb42d669ade28)
1cb477c30SDaniel Golle // SPDX-License-Identifier: GPL-2.0
2cb477c30SDaniel Golle #ifndef __LANTIQ_GSWIP_H
3cb477c30SDaniel Golle #define __LANTIQ_GSWIP_H
4cb477c30SDaniel Golle 
5cb477c30SDaniel Golle #include <linux/clk.h>
6cb477c30SDaniel Golle #include <linux/mutex.h>
7*7a1eaef0SDaniel Golle #include <linux/phylink.h>
8cb477c30SDaniel Golle #include <linux/platform_device.h>
9cb477c30SDaniel Golle #include <linux/regmap.h>
10cb477c30SDaniel Golle #include <linux/reset.h>
11cb477c30SDaniel Golle #include <linux/swab.h>
12cb477c30SDaniel Golle #include <net/dsa.h>
13cb477c30SDaniel Golle 
14cb477c30SDaniel Golle /* GSWIP MDIO Registers */
15cb477c30SDaniel Golle #define GSWIP_MDIO_GLOB			0x00
16cb477c30SDaniel Golle #define  GSWIP_MDIO_GLOB_ENABLE		BIT(15)
17cb477c30SDaniel Golle #define GSWIP_MDIO_CTRL			0x08
18cb477c30SDaniel Golle #define  GSWIP_MDIO_CTRL_BUSY		BIT(12)
19cb477c30SDaniel Golle #define  GSWIP_MDIO_CTRL_RD		BIT(11)
20cb477c30SDaniel Golle #define  GSWIP_MDIO_CTRL_WR		BIT(10)
21cb477c30SDaniel Golle #define  GSWIP_MDIO_CTRL_PHYAD_MASK	0x1f
22cb477c30SDaniel Golle #define  GSWIP_MDIO_CTRL_PHYAD_SHIFT	5
23cb477c30SDaniel Golle #define  GSWIP_MDIO_CTRL_REGAD_MASK	0x1f
24cb477c30SDaniel Golle #define GSWIP_MDIO_READ			0x09
25cb477c30SDaniel Golle #define GSWIP_MDIO_WRITE		0x0A
26cb477c30SDaniel Golle #define GSWIP_MDIO_MDC_CFG0		0x0B
27cb477c30SDaniel Golle #define GSWIP_MDIO_MDC_CFG1		0x0C
28cb477c30SDaniel Golle #define GSWIP_MDIO_PHYp(p)		(0x15 - (p))
29cb477c30SDaniel Golle #define  GSWIP_MDIO_PHY_LINK_MASK	0x6000
30cb477c30SDaniel Golle #define  GSWIP_MDIO_PHY_LINK_AUTO	0x0000
31cb477c30SDaniel Golle #define  GSWIP_MDIO_PHY_LINK_DOWN	0x4000
32cb477c30SDaniel Golle #define  GSWIP_MDIO_PHY_LINK_UP		0x2000
33cb477c30SDaniel Golle #define  GSWIP_MDIO_PHY_SPEED_MASK	0x1800
34cb477c30SDaniel Golle #define  GSWIP_MDIO_PHY_SPEED_AUTO	0x1800
35cb477c30SDaniel Golle #define  GSWIP_MDIO_PHY_SPEED_M10	0x0000
36cb477c30SDaniel Golle #define  GSWIP_MDIO_PHY_SPEED_M100	0x0800
37cb477c30SDaniel Golle #define  GSWIP_MDIO_PHY_SPEED_G1	0x1000
38cb477c30SDaniel Golle #define  GSWIP_MDIO_PHY_FDUP_MASK	0x0600
39cb477c30SDaniel Golle #define  GSWIP_MDIO_PHY_FDUP_AUTO	0x0000
40cb477c30SDaniel Golle #define  GSWIP_MDIO_PHY_FDUP_EN		0x0200
41cb477c30SDaniel Golle #define  GSWIP_MDIO_PHY_FDUP_DIS	0x0600
42cb477c30SDaniel Golle #define  GSWIP_MDIO_PHY_FCONTX_MASK	0x0180
43cb477c30SDaniel Golle #define  GSWIP_MDIO_PHY_FCONTX_AUTO	0x0000
44cb477c30SDaniel Golle #define  GSWIP_MDIO_PHY_FCONTX_EN	0x0100
45cb477c30SDaniel Golle #define  GSWIP_MDIO_PHY_FCONTX_DIS	0x0180
46cb477c30SDaniel Golle #define  GSWIP_MDIO_PHY_FCONRX_MASK	0x0060
47cb477c30SDaniel Golle #define  GSWIP_MDIO_PHY_FCONRX_AUTO	0x0000
48cb477c30SDaniel Golle #define  GSWIP_MDIO_PHY_FCONRX_EN	0x0020
49cb477c30SDaniel Golle #define  GSWIP_MDIO_PHY_FCONRX_DIS	0x0060
50cb477c30SDaniel Golle #define  GSWIP_MDIO_PHY_ADDR_MASK	0x001f
51cb477c30SDaniel Golle #define  GSWIP_MDIO_PHY_MASK		(GSWIP_MDIO_PHY_ADDR_MASK | \
52cb477c30SDaniel Golle 					 GSWIP_MDIO_PHY_FCONRX_MASK | \
53cb477c30SDaniel Golle 					 GSWIP_MDIO_PHY_FCONTX_MASK | \
54cb477c30SDaniel Golle 					 GSWIP_MDIO_PHY_LINK_MASK | \
55cb477c30SDaniel Golle 					 GSWIP_MDIO_PHY_SPEED_MASK | \
56cb477c30SDaniel Golle 					 GSWIP_MDIO_PHY_FDUP_MASK)
57cb477c30SDaniel Golle 
58cb477c30SDaniel Golle /* GSWIP MII Registers */
59cb477c30SDaniel Golle #define GSWIP_MII_CFGp(p)		(0x2 * (p))
60cb477c30SDaniel Golle #define  GSWIP_MII_CFG_RESET		BIT(15)
61cb477c30SDaniel Golle #define  GSWIP_MII_CFG_EN		BIT(14)
62cb477c30SDaniel Golle #define  GSWIP_MII_CFG_ISOLATE		BIT(13)
63cb477c30SDaniel Golle #define  GSWIP_MII_CFG_LDCLKDIS		BIT(12)
64cb477c30SDaniel Golle #define  GSWIP_MII_CFG_RGMII_IBS	BIT(8)
65cb477c30SDaniel Golle #define  GSWIP_MII_CFG_RMII_CLK		BIT(7)
66cb477c30SDaniel Golle #define  GSWIP_MII_CFG_MODE_MIIP	0x0
67cb477c30SDaniel Golle #define  GSWIP_MII_CFG_MODE_MIIM	0x1
68cb477c30SDaniel Golle #define  GSWIP_MII_CFG_MODE_RMIIP	0x2
69cb477c30SDaniel Golle #define  GSWIP_MII_CFG_MODE_RMIIM	0x3
70cb477c30SDaniel Golle #define  GSWIP_MII_CFG_MODE_RGMII	0x4
71cb477c30SDaniel Golle #define  GSWIP_MII_CFG_MODE_GMII	0x9
72cb477c30SDaniel Golle #define  GSWIP_MII_CFG_MODE_MASK	0xf
73cb477c30SDaniel Golle #define  GSWIP_MII_CFG_RATE_M2P5	0x00
74cb477c30SDaniel Golle #define  GSWIP_MII_CFG_RATE_M25	0x10
75cb477c30SDaniel Golle #define  GSWIP_MII_CFG_RATE_M125	0x20
76cb477c30SDaniel Golle #define  GSWIP_MII_CFG_RATE_M50	0x30
77cb477c30SDaniel Golle #define  GSWIP_MII_CFG_RATE_AUTO	0x40
78cb477c30SDaniel Golle #define  GSWIP_MII_CFG_RATE_MASK	0x70
79cb477c30SDaniel Golle #define GSWIP_MII_PCDU0			0x01
80cb477c30SDaniel Golle #define GSWIP_MII_PCDU1			0x03
81cb477c30SDaniel Golle #define GSWIP_MII_PCDU5			0x05
82cb477c30SDaniel Golle #define  GSWIP_MII_PCDU_TXDLY_MASK	GENMASK(2, 0)
83cb477c30SDaniel Golle #define  GSWIP_MII_PCDU_RXDLY_MASK	GENMASK(9, 7)
84cb477c30SDaniel Golle 
85cb477c30SDaniel Golle /* GSWIP Core Registers */
86cb477c30SDaniel Golle #define GSWIP_SWRES			0x000
87cb477c30SDaniel Golle #define  GSWIP_SWRES_R1			BIT(1)	/* GSWIP Software reset */
88cb477c30SDaniel Golle #define  GSWIP_SWRES_R0			BIT(0)	/* GSWIP Hardware reset */
89cb477c30SDaniel Golle #define GSWIP_VERSION			0x013
90cb477c30SDaniel Golle #define  GSWIP_VERSION_REV_MASK		GENMASK(7, 0)
91cb477c30SDaniel Golle #define  GSWIP_VERSION_MOD_MASK		GENMASK(15, 8)
92cb477c30SDaniel Golle #define  GSWIP_VERSION_REV(v)		FIELD_GET(GSWIP_VERSION_REV_MASK, v)
93cb477c30SDaniel Golle #define  GSWIP_VERSION_MOD(v)		FIELD_GET(GSWIP_VERSION_MOD_MASK, v)
94cb477c30SDaniel Golle #define   GSWIP_VERSION_2_0		0x100
95cb477c30SDaniel Golle #define   GSWIP_VERSION_2_1		0x021
96cb477c30SDaniel Golle #define   GSWIP_VERSION_2_2		0x122
97cb477c30SDaniel Golle #define   GSWIP_VERSION_2_2_ETC		0x022
98cb477c30SDaniel Golle /* The hardware has the 'major/minor' version bytes in the wrong order
99cb477c30SDaniel Golle  * preventing numerical comparisons. Swap the bytes of the 16-bit value
100cb477c30SDaniel Golle  * to end up with REV being the most significant byte and MOD being the
101cb477c30SDaniel Golle  * least significant byte, which then allows comparing it with the
102cb477c30SDaniel Golle  * value stored in struct gswip_priv.
103cb477c30SDaniel Golle  */
104cb477c30SDaniel Golle #define GSWIP_VERSION_GE(priv, ver)	((priv)->version >= swab16(ver))
105cb477c30SDaniel Golle 
106cb477c30SDaniel Golle #define GSWIP_BM_RAM_VAL(x)		(0x043 - (x))
107cb477c30SDaniel Golle #define GSWIP_BM_RAM_ADDR		0x044
108cb477c30SDaniel Golle #define GSWIP_BM_RAM_CTRL		0x045
109cb477c30SDaniel Golle #define  GSWIP_BM_RAM_CTRL_BAS		BIT(15)
110cb477c30SDaniel Golle #define  GSWIP_BM_RAM_CTRL_OPMOD	BIT(5)
111cb477c30SDaniel Golle #define  GSWIP_BM_RAM_CTRL_ADDR_MASK	GENMASK(4, 0)
112cb477c30SDaniel Golle #define GSWIP_BM_QUEUE_GCTRL		0x04A
113cb477c30SDaniel Golle #define  GSWIP_BM_QUEUE_GCTRL_GL_MOD	BIT(10)
114cb477c30SDaniel Golle /* buffer management Port Configuration Register */
115cb477c30SDaniel Golle #define GSWIP_BM_PCFGp(p)		(0x080 + ((p) * 2))
116cb477c30SDaniel Golle #define  GSWIP_BM_PCFG_CNTEN		BIT(0)	/* RMON Counter Enable */
117cb477c30SDaniel Golle #define  GSWIP_BM_PCFG_IGCNT		BIT(1)	/* Ingres Special Tag RMON count */
118cb477c30SDaniel Golle /* buffer management Port Control Register */
119cb477c30SDaniel Golle #define GSWIP_BM_RMON_CTRLp(p)		(0x81 + ((p) * 2))
120cb477c30SDaniel Golle #define  GSWIP_BM_CTRL_RMON_RAM1_RES	BIT(0)	/* Software Reset for RMON RAM 1 */
121cb477c30SDaniel Golle #define  GSWIP_BM_CTRL_RMON_RAM2_RES	BIT(1)	/* Software Reset for RMON RAM 2 */
122cb477c30SDaniel Golle 
123cb477c30SDaniel Golle /* PCE */
124cb477c30SDaniel Golle #define GSWIP_PCE_TBL_KEY(x)		(0x447 - (x))
125cb477c30SDaniel Golle #define GSWIP_PCE_TBL_MASK		0x448
126cb477c30SDaniel Golle #define GSWIP_PCE_TBL_VAL(x)		(0x44D - (x))
127cb477c30SDaniel Golle #define GSWIP_PCE_TBL_ADDR		0x44E
128cb477c30SDaniel Golle #define GSWIP_PCE_TBL_CTRL		0x44F
129cb477c30SDaniel Golle #define  GSWIP_PCE_TBL_CTRL_BAS		BIT(15)
130cb477c30SDaniel Golle #define  GSWIP_PCE_TBL_CTRL_TYPE	BIT(13)
131cb477c30SDaniel Golle #define  GSWIP_PCE_TBL_CTRL_VLD		BIT(12)
132cb477c30SDaniel Golle #define  GSWIP_PCE_TBL_CTRL_KEYFORM	BIT(11)
133cb477c30SDaniel Golle #define  GSWIP_PCE_TBL_CTRL_GMAP_MASK	GENMASK(10, 7)
134cb477c30SDaniel Golle #define  GSWIP_PCE_TBL_CTRL_OPMOD_MASK	GENMASK(6, 5)
135cb477c30SDaniel Golle #define  GSWIP_PCE_TBL_CTRL_OPMOD_ADRD	0x00
136cb477c30SDaniel Golle #define  GSWIP_PCE_TBL_CTRL_OPMOD_ADWR	0x20
137cb477c30SDaniel Golle #define  GSWIP_PCE_TBL_CTRL_OPMOD_KSRD	0x40
138cb477c30SDaniel Golle #define  GSWIP_PCE_TBL_CTRL_OPMOD_KSWR	0x60
139cb477c30SDaniel Golle #define  GSWIP_PCE_TBL_CTRL_ADDR_MASK	GENMASK(4, 0)
140cb477c30SDaniel Golle #define GSWIP_PCE_PMAP1			0x453	/* Monitoring port map */
141cb477c30SDaniel Golle #define GSWIP_PCE_PMAP2			0x454	/* Default Multicast port map */
142cb477c30SDaniel Golle #define GSWIP_PCE_PMAP3			0x455	/* Default Unknown Unicast port map */
143cb477c30SDaniel Golle #define GSWIP_PCE_GCTRL_0		0x456
144cb477c30SDaniel Golle #define  GSWIP_PCE_GCTRL_0_MTFL		BIT(0)  /* MAC Table Flushing */
145cb477c30SDaniel Golle #define  GSWIP_PCE_GCTRL_0_MC_VALID	BIT(3)
146cb477c30SDaniel Golle #define  GSWIP_PCE_GCTRL_0_VLAN		BIT(14) /* VLAN aware Switching */
147cb477c30SDaniel Golle #define GSWIP_PCE_GCTRL_1		0x457
148cb477c30SDaniel Golle #define  GSWIP_PCE_GCTRL_1_MAC_GLOCK	BIT(2)	/* MAC Address table lock */
149cb477c30SDaniel Golle #define  GSWIP_PCE_GCTRL_1_MAC_GLOCK_MOD	BIT(3) /* Mac address table lock forwarding mode */
150cb477c30SDaniel Golle #define GSWIP_PCE_PCTRL_0p(p)		(0x480 + ((p) * 0xA))
151cb477c30SDaniel Golle #define  GSWIP_PCE_PCTRL_0_TVM		BIT(5)	/* Transparent VLAN mode */
152cb477c30SDaniel Golle #define  GSWIP_PCE_PCTRL_0_VREP		BIT(6)	/* VLAN Replace Mode */
153cb477c30SDaniel Golle #define  GSWIP_PCE_PCTRL_0_INGRESS	BIT(11)	/* Accept special tag in ingress */
154cb477c30SDaniel Golle #define  GSWIP_PCE_PCTRL_0_PSTATE_LISTEN	0x0
155cb477c30SDaniel Golle #define  GSWIP_PCE_PCTRL_0_PSTATE_RX		0x1
156cb477c30SDaniel Golle #define  GSWIP_PCE_PCTRL_0_PSTATE_TX		0x2
157cb477c30SDaniel Golle #define  GSWIP_PCE_PCTRL_0_PSTATE_LEARNING	0x3
158cb477c30SDaniel Golle #define  GSWIP_PCE_PCTRL_0_PSTATE_FORWARDING	0x7
159cb477c30SDaniel Golle #define  GSWIP_PCE_PCTRL_0_PSTATE_MASK	GENMASK(2, 0)
160cb477c30SDaniel Golle #define GSWIP_PCE_VCTRL(p)		(0x485 + ((p) * 0xA))
161cb477c30SDaniel Golle #define  GSWIP_PCE_VCTRL_UVR		BIT(0)	/* Unknown VLAN Rule */
162cb477c30SDaniel Golle #define  GSWIP_PCE_VCTRL_VIMR		BIT(3)	/* VLAN Ingress Member violation rule */
163cb477c30SDaniel Golle #define  GSWIP_PCE_VCTRL_VEMR		BIT(4)	/* VLAN Egress Member violation rule */
164cb477c30SDaniel Golle #define  GSWIP_PCE_VCTRL_VSR		BIT(5)	/* VLAN Security */
165cb477c30SDaniel Golle #define  GSWIP_PCE_VCTRL_VID0		BIT(6)	/* Priority Tagged Rule */
166cb477c30SDaniel Golle #define GSWIP_PCE_DEFPVID(p)		(0x486 + ((p) * 0xA))
167cb477c30SDaniel Golle 
168cb477c30SDaniel Golle #define GSWIP_MAC_FLEN			0x8C5
169cb477c30SDaniel Golle #define GSWIP_MAC_CTRL_0p(p)		(0x903 + ((p) * 0xC))
170cb477c30SDaniel Golle #define  GSWIP_MAC_CTRL_0_PADEN		BIT(8)
171cb477c30SDaniel Golle #define  GSWIP_MAC_CTRL_0_FCS_EN	BIT(7)
172cb477c30SDaniel Golle #define  GSWIP_MAC_CTRL_0_FCON_MASK	0x0070
173cb477c30SDaniel Golle #define  GSWIP_MAC_CTRL_0_FCON_AUTO	0x0000
174cb477c30SDaniel Golle #define  GSWIP_MAC_CTRL_0_FCON_RX	0x0010
175cb477c30SDaniel Golle #define  GSWIP_MAC_CTRL_0_FCON_TX	0x0020
176cb477c30SDaniel Golle #define  GSWIP_MAC_CTRL_0_FCON_RXTX	0x0030
177cb477c30SDaniel Golle #define  GSWIP_MAC_CTRL_0_FCON_NONE	0x0040
178cb477c30SDaniel Golle #define  GSWIP_MAC_CTRL_0_FDUP_MASK	0x000C
179cb477c30SDaniel Golle #define  GSWIP_MAC_CTRL_0_FDUP_AUTO	0x0000
180cb477c30SDaniel Golle #define  GSWIP_MAC_CTRL_0_FDUP_EN	0x0004
181cb477c30SDaniel Golle #define  GSWIP_MAC_CTRL_0_FDUP_DIS	0x000C
182cb477c30SDaniel Golle #define  GSWIP_MAC_CTRL_0_GMII_MASK	0x0003
183cb477c30SDaniel Golle #define  GSWIP_MAC_CTRL_0_GMII_AUTO	0x0000
184cb477c30SDaniel Golle #define  GSWIP_MAC_CTRL_0_GMII_MII	0x0001
185cb477c30SDaniel Golle #define  GSWIP_MAC_CTRL_0_GMII_RGMII	0x0002
186cb477c30SDaniel Golle #define GSWIP_MAC_CTRL_2p(p)		(0x905 + ((p) * 0xC))
187cb477c30SDaniel Golle #define GSWIP_MAC_CTRL_2_LCHKL		BIT(2) /* Frame Length Check Long Enable */
188cb477c30SDaniel Golle #define GSWIP_MAC_CTRL_2_MLEN		BIT(3) /* Maximum Untagged Frame Lnegth */
189cb477c30SDaniel Golle 
190cb477c30SDaniel Golle /* Ethernet Switch Fetch DMA Port Control Register */
191cb477c30SDaniel Golle #define GSWIP_FDMA_PCTRLp(p)		(0xA80 + ((p) * 0x6))
192cb477c30SDaniel Golle #define  GSWIP_FDMA_PCTRL_EN		BIT(0)	/* FDMA Port Enable */
193cb477c30SDaniel Golle #define  GSWIP_FDMA_PCTRL_STEN		BIT(1)	/* Special Tag Insertion Enable */
194cb477c30SDaniel Golle #define  GSWIP_FDMA_PCTRL_VLANMOD_MASK	GENMASK(4, 3)	/* VLAN Modification Control */
195cb477c30SDaniel Golle #define  GSWIP_FDMA_PCTRL_VLANMOD_SHIFT	3	/* VLAN Modification Control */
196cb477c30SDaniel Golle #define  GSWIP_FDMA_PCTRL_VLANMOD_DIS	(0x0 << GSWIP_FDMA_PCTRL_VLANMOD_SHIFT)
197cb477c30SDaniel Golle #define  GSWIP_FDMA_PCTRL_VLANMOD_PRIO	(0x1 << GSWIP_FDMA_PCTRL_VLANMOD_SHIFT)
198cb477c30SDaniel Golle #define  GSWIP_FDMA_PCTRL_VLANMOD_ID	(0x2 << GSWIP_FDMA_PCTRL_VLANMOD_SHIFT)
199cb477c30SDaniel Golle #define  GSWIP_FDMA_PCTRL_VLANMOD_BOTH	(0x3 << GSWIP_FDMA_PCTRL_VLANMOD_SHIFT)
200cb477c30SDaniel Golle 
201cb477c30SDaniel Golle /* Ethernet Switch Store DMA Port Control Register */
202cb477c30SDaniel Golle #define GSWIP_SDMA_PCTRLp(p)		(0xBC0 + ((p) * 0x6))
203cb477c30SDaniel Golle #define  GSWIP_SDMA_PCTRL_EN		BIT(0)	/* SDMA Port Enable */
204cb477c30SDaniel Golle #define  GSWIP_SDMA_PCTRL_FCEN		BIT(1)	/* Flow Control Enable */
205cb477c30SDaniel Golle #define  GSWIP_SDMA_PCTRL_PAUFWD	BIT(3)	/* Pause Frame Forwarding */
206cb477c30SDaniel Golle 
207cb477c30SDaniel Golle #define GSWIP_TABLE_ACTIVE_VLAN		0x01
208cb477c30SDaniel Golle #define GSWIP_TABLE_VLAN_MAPPING	0x02
209cb477c30SDaniel Golle #define GSWIP_TABLE_MAC_BRIDGE		0x0b
210cb477c30SDaniel Golle #define  GSWIP_TABLE_MAC_BRIDGE_KEY3_FID	GENMASK(5, 0)	/* Filtering identifier */
211cb477c30SDaniel Golle #define  GSWIP_TABLE_MAC_BRIDGE_VAL0_PORT	GENMASK(7, 4)	/* Port on learned entries */
212cb477c30SDaniel Golle #define  GSWIP_TABLE_MAC_BRIDGE_VAL1_STATIC	BIT(0)		/* Static, non-aging entry */
213cb477c30SDaniel Golle 
214cb477c30SDaniel Golle #define XRX200_GPHY_FW_ALIGN	(16 * 1024)
215cb477c30SDaniel Golle 
216cb477c30SDaniel Golle /* Maximum packet size supported by the switch. In theory this should be 10240,
217cb477c30SDaniel Golle  * but long packets currently cause lock-ups with an MTU of over 2526. Medium
218cb477c30SDaniel Golle  * packets are sometimes dropped (e.g. TCP over 2477, UDP over 2516-2519, ICMP
219cb477c30SDaniel Golle  * over 2526), hence an MTU value of 2400 seems safe. This issue only affects
220cb477c30SDaniel Golle  * packet reception. This is probably caused by the PPA engine, which is on the
221cb477c30SDaniel Golle  * RX part of the device. Packet transmission works properly up to 10240.
222cb477c30SDaniel Golle  */
223cb477c30SDaniel Golle #define GSWIP_MAX_PACKET_LENGTH	2400
224cb477c30SDaniel Golle 
225cb477c30SDaniel Golle struct gswip_pce_microcode {
226cb477c30SDaniel Golle 	u16 val_3;
227cb477c30SDaniel Golle 	u16 val_2;
228cb477c30SDaniel Golle 	u16 val_1;
229cb477c30SDaniel Golle 	u16 val_0;
230cb477c30SDaniel Golle };
231cb477c30SDaniel Golle 
232cb477c30SDaniel Golle struct gswip_hw_info {
233cb477c30SDaniel Golle 	int max_ports;
234cb477c30SDaniel Golle 	unsigned int allowed_cpu_ports;
235cb477c30SDaniel Golle 	unsigned int mii_ports;
236cb477c30SDaniel Golle 	const struct gswip_pce_microcode (*pce_microcode)[];
237cb477c30SDaniel Golle 	size_t pce_microcode_size;
238cb477c30SDaniel Golle 	enum dsa_tag_protocol tag_protocol;
239cb477c30SDaniel Golle 	void (*phylink_get_caps)(struct dsa_switch *ds, int port,
240cb477c30SDaniel Golle 				 struct phylink_config *config);
241*7a1eaef0SDaniel Golle 	struct phylink_pcs *(*mac_select_pcs)(struct phylink_config *config,
242*7a1eaef0SDaniel Golle 					      phy_interface_t interface);
243cb477c30SDaniel Golle };
244cb477c30SDaniel Golle 
245cb477c30SDaniel Golle struct gswip_gphy_fw {
246cb477c30SDaniel Golle 	struct clk *clk_gate;
247cb477c30SDaniel Golle 	struct reset_control *reset;
248cb477c30SDaniel Golle 	u32 fw_addr_offset;
249cb477c30SDaniel Golle 	char *fw_name;
250cb477c30SDaniel Golle };
251cb477c30SDaniel Golle 
252cb477c30SDaniel Golle struct gswip_vlan {
253cb477c30SDaniel Golle 	struct net_device *bridge;
254cb477c30SDaniel Golle 	u16 vid;
255cb477c30SDaniel Golle 	u8 fid;
256cb477c30SDaniel Golle };
257cb477c30SDaniel Golle 
258cb477c30SDaniel Golle struct gswip_priv {
259cb477c30SDaniel Golle 	__iomem void *gswip;
260cb477c30SDaniel Golle 	__iomem void *mdio;
261cb477c30SDaniel Golle 	__iomem void *mii;
262cb477c30SDaniel Golle 	const struct gswip_hw_info *hw_info;
263cb477c30SDaniel Golle 	const struct xway_gphy_match_data *gphy_fw_name_cfg;
264cb477c30SDaniel Golle 	struct dsa_switch *ds;
265cb477c30SDaniel Golle 	struct device *dev;
266cb477c30SDaniel Golle 	struct regmap *rcu_regmap;
267cb477c30SDaniel Golle 	struct gswip_vlan vlans[64];
268cb477c30SDaniel Golle 	int num_gphy_fw;
269cb477c30SDaniel Golle 	struct gswip_gphy_fw *gphy_fw;
270cb477c30SDaniel Golle 	u32 port_vlan_filter;
271cb477c30SDaniel Golle 	struct mutex pce_table_lock;
272cb477c30SDaniel Golle 	u16 version;
273cb477c30SDaniel Golle };
274cb477c30SDaniel Golle 
275cb477c30SDaniel Golle #endif /* __LANTIQ_GSWIP_H */
276