xref: /openbmc/linux/drivers/net/ethernet/stmicro/stmmac/dwmac5.h (revision d0c44de2d8ffd2e4780d360b34ee6614aa4af080)
1acb9bdc1SNishad Kamdar /* SPDX-License-Identifier: (GPL-2.0 OR MIT) */
28bf993a5SJose Abreu // Copyright (c) 2017 Synopsys, Inc. and/or its affiliates.
38bf993a5SJose Abreu // stmmac Support for 5.xx Ethernet QoS cores
48bf993a5SJose Abreu 
58bf993a5SJose Abreu #ifndef __DWMAC5_H__
68bf993a5SJose Abreu #define __DWMAC5_H__
78bf993a5SJose Abreu 
88bf993a5SJose Abreu #define MAC_DPP_FSM_INT_STATUS		0x00000140
98bf993a5SJose Abreu #define MAC_AXI_SLV_DPE_ADDR_STATUS	0x00000144
108bf993a5SJose Abreu #define MAC_FSM_CONTROL			0x00000148
118bf993a5SJose Abreu #define PRTYEN				BIT(1)
128bf993a5SJose Abreu #define TMOUTEN				BIT(0)
138bf993a5SJose Abreu 
147c728274SJose Abreu #define MAC_FPE_CTRL_STS		0x00000234
155a558611SOng Boon Leong #define TRSP				BIT(19)
165a558611SOng Boon Leong #define TVER				BIT(18)
175a558611SOng Boon Leong #define RRSP				BIT(17)
185a558611SOng Boon Leong #define RVER				BIT(16)
195a558611SOng Boon Leong #define SRSP				BIT(2)
205a558611SOng Boon Leong #define SVER				BIT(1)
217c728274SJose Abreu #define EFPE				BIT(0)
227c728274SJose Abreu 
239a8a02c9SJose Abreu #define MAC_PPS_CONTROL			0x00000b70
249a8a02c9SJose Abreu #define PPS_MAXIDX(x)			((((x) + 1) * 8) - 1)
259a8a02c9SJose Abreu #define PPS_MINIDX(x)			((x) * 8)
269a8a02c9SJose Abreu #define PPSx_MASK(x)			GENMASK(PPS_MAXIDX(x), PPS_MINIDX(x))
279a8a02c9SJose Abreu #define MCGRENx(x)			BIT(PPS_MAXIDX(x))
289a8a02c9SJose Abreu #define TRGTMODSELx(x, val)		\
299a8a02c9SJose Abreu 	GENMASK(PPS_MAXIDX(x) - 1, PPS_MAXIDX(x) - 2) & \
309a8a02c9SJose Abreu 	((val) << (PPS_MAXIDX(x) - 2))
319a8a02c9SJose Abreu #define PPSCMDx(x, val)			\
329a8a02c9SJose Abreu 	GENMASK(PPS_MINIDX(x) + 3, PPS_MINIDX(x)) & \
339a8a02c9SJose Abreu 	((val) << PPS_MINIDX(x))
349a8a02c9SJose Abreu #define PPSEN0				BIT(4)
359a8a02c9SJose Abreu #define MAC_PPSx_TARGET_TIME_SEC(x)	(0x00000b80 + ((x) * 0x10))
369a8a02c9SJose Abreu #define MAC_PPSx_TARGET_TIME_NSEC(x)	(0x00000b84 + ((x) * 0x10))
379a8a02c9SJose Abreu #define TRGTBUSY0			BIT(31)
389a8a02c9SJose Abreu #define TTSL0				GENMASK(30, 0)
399a8a02c9SJose Abreu #define MAC_PPSx_INTERVAL(x)		(0x00000b88 + ((x) * 0x10))
409a8a02c9SJose Abreu #define MAC_PPSx_WIDTH(x)		(0x00000b8c + ((x) * 0x10))
419a8a02c9SJose Abreu 
42504723afSJose Abreu #define MTL_EST_CONTROL			0x00000c50
43504723afSJose Abreu #define PTOV				GENMASK(31, 24)
44504723afSJose Abreu #define PTOV_SHIFT			24
45504723afSJose Abreu #define SSWL				BIT(1)
46504723afSJose Abreu #define EEST				BIT(0)
47e49aa315SVoon Weifeng 
48e49aa315SVoon Weifeng #define MTL_EST_STATUS			0x00000c58
49e49aa315SVoon Weifeng #define BTRL				GENMASK(11, 8)
50e49aa315SVoon Weifeng #define BTRL_SHIFT			8
51e49aa315SVoon Weifeng #define BTRL_MAX			(0xF << BTRL_SHIFT)
52e49aa315SVoon Weifeng #define SWOL				BIT(7)
53e49aa315SVoon Weifeng #define SWOL_SHIFT			7
54e49aa315SVoon Weifeng #define CGCE				BIT(4)
55e49aa315SVoon Weifeng #define HLBS				BIT(3)
56e49aa315SVoon Weifeng #define HLBF				BIT(2)
57e49aa315SVoon Weifeng #define BTRE				BIT(1)
58e49aa315SVoon Weifeng #define SWLC				BIT(0)
59e49aa315SVoon Weifeng 
60e49aa315SVoon Weifeng #define MTL_EST_SCH_ERR			0x00000c60
61e49aa315SVoon Weifeng #define MTL_EST_FRM_SZ_ERR		0x00000c64
62e49aa315SVoon Weifeng #define MTL_EST_FRM_SZ_CAP		0x00000c68
63e49aa315SVoon Weifeng #define SZ_CAP_HBFS_MASK		GENMASK(14, 0)
64e49aa315SVoon Weifeng #define SZ_CAP_HBFQ_SHIFT		16
65e49aa315SVoon Weifeng #define SZ_CAP_HBFQ_MASK(_val)		({ typeof(_val) (val) = (_val);	\
66e49aa315SVoon Weifeng 					((val) > 4 ? GENMASK(18, 16) :	\
67e49aa315SVoon Weifeng 					 (val) > 2 ? GENMASK(17, 16) :	\
68e49aa315SVoon Weifeng 					 BIT(16)); })
69e49aa315SVoon Weifeng 
70e49aa315SVoon Weifeng #define MTL_EST_INT_EN			0x00000c70
71e49aa315SVoon Weifeng #define IECGCE				CGCE
72e49aa315SVoon Weifeng #define IEHS				HLBS
73e49aa315SVoon Weifeng #define IEHF				HLBF
74e49aa315SVoon Weifeng #define IEBE				BTRE
75e49aa315SVoon Weifeng #define IECC				SWLC
76e49aa315SVoon Weifeng 
77504723afSJose Abreu #define MTL_EST_GCL_CONTROL		0x00000c80
78504723afSJose Abreu #define BTR_LOW				0x0
79504723afSJose Abreu #define BTR_HIGH			0x1
80504723afSJose Abreu #define CTR_LOW				0x2
81504723afSJose Abreu #define CTR_HIGH			0x3
82504723afSJose Abreu #define TER				0x4
83504723afSJose Abreu #define LLR				0x5
84504723afSJose Abreu #define ADDR_SHIFT			8
85504723afSJose Abreu #define GCRR				BIT(2)
86504723afSJose Abreu #define SRWO				BIT(0)
87504723afSJose Abreu #define MTL_EST_GCL_DATA		0x00000c84
88504723afSJose Abreu 
894dbbe8ddSJose Abreu #define MTL_RXP_CONTROL_STATUS		0x00000ca0
904dbbe8ddSJose Abreu #define RXPI				BIT(31)
914dbbe8ddSJose Abreu #define NPE				GENMASK(23, 16)
924dbbe8ddSJose Abreu #define NVE				GENMASK(7, 0)
934dbbe8ddSJose Abreu #define MTL_RXP_IACC_CTRL_STATUS	0x00000cb0
944dbbe8ddSJose Abreu #define STARTBUSY			BIT(31)
954dbbe8ddSJose Abreu #define RXPEIEC				GENMASK(22, 21)
964dbbe8ddSJose Abreu #define RXPEIEE				BIT(20)
974dbbe8ddSJose Abreu #define WRRDN				BIT(16)
984dbbe8ddSJose Abreu #define ADDR				GENMASK(15, 0)
994dbbe8ddSJose Abreu #define MTL_RXP_IACC_DATA		0x00000cb4
1008bf993a5SJose Abreu #define MTL_ECC_CONTROL			0x00000cc0
101b494ba5aSVoon Weifeng #define MEEAO				BIT(8)
1028bf993a5SJose Abreu #define TSOEE				BIT(4)
1038bf993a5SJose Abreu #define MRXPEE				BIT(3)
1048bf993a5SJose Abreu #define MESTEE				BIT(2)
1058bf993a5SJose Abreu #define MRXEE				BIT(1)
1068bf993a5SJose Abreu #define MTXEE				BIT(0)
1078bf993a5SJose Abreu 
1088bf993a5SJose Abreu #define MTL_SAFETY_INT_STATUS		0x00000cc4
1098bf993a5SJose Abreu #define MCSIS				BIT(31)
1108bf993a5SJose Abreu #define MEUIS				BIT(1)
1118bf993a5SJose Abreu #define MECIS				BIT(0)
1128bf993a5SJose Abreu #define MTL_ECC_INT_ENABLE		0x00000cc8
1138bf993a5SJose Abreu #define RPCEIE				BIT(12)
1148bf993a5SJose Abreu #define ECEIE				BIT(8)
1158bf993a5SJose Abreu #define RXCEIE				BIT(4)
1168bf993a5SJose Abreu #define TXCEIE				BIT(0)
1178bf993a5SJose Abreu #define MTL_ECC_INT_STATUS		0x00000ccc
1188bf993a5SJose Abreu #define MTL_DPP_CONTROL			0x00000ce0
1198bf993a5SJose Abreu #define EPSI				BIT(2)
1208bf993a5SJose Abreu #define OPE				BIT(1)
1218bf993a5SJose Abreu #define EDPP				BIT(0)
1228bf993a5SJose Abreu 
1238bf993a5SJose Abreu #define DMA_SAFETY_INT_STATUS		0x00001080
1248bf993a5SJose Abreu #define MSUIS				BIT(29)
1258bf993a5SJose Abreu #define MSCIS				BIT(28)
1268bf993a5SJose Abreu #define DEUIS				BIT(1)
1278bf993a5SJose Abreu #define DECIS				BIT(0)
1288bf993a5SJose Abreu #define DMA_ECC_INT_ENABLE		0x00001084
1298bf993a5SJose Abreu #define TCEIE				BIT(0)
1308bf993a5SJose Abreu #define DMA_ECC_INT_STATUS		0x00001088
1318bf993a5SJose Abreu 
132e0f9956aSChuah, Kim Tatt /* EQoS version 5.xx VLAN Tag Filter Fail Packets Queuing */
133e0f9956aSChuah, Kim Tatt #define GMAC_RXQ_CTRL4			0x00000094
134e0f9956aSChuah, Kim Tatt #define GMAC_RXQCTRL_VFFQ_MASK		GENMASK(19, 17)
135e0f9956aSChuah, Kim Tatt #define GMAC_RXQCTRL_VFFQ_SHIFT		17
136e0f9956aSChuah, Kim Tatt #define GMAC_RXQCTRL_VFFQE		BIT(16)
137e0f9956aSChuah, Kim Tatt 
1385a558611SOng Boon Leong #define GMAC_INT_FPE_EN			BIT(17)
1395a558611SOng Boon Leong 
1405ac712dcSWong Vee Khee int dwmac5_safety_feat_config(void __iomem *ioaddr, unsigned int asp,
1415ac712dcSWong Vee Khee 			      struct stmmac_safety_feature_cfg *safety_cfg);
142c10d4c82SJose Abreu int dwmac5_safety_feat_irq_status(struct net_device *ndev,
1438bf993a5SJose Abreu 		void __iomem *ioaddr, unsigned int asp,
1448bf993a5SJose Abreu 		struct stmmac_safety_stats *stats);
145c10d4c82SJose Abreu int dwmac5_safety_feat_dump(struct stmmac_safety_stats *stats,
146c10d4c82SJose Abreu 			int index, unsigned long *count, const char **desc);
1474dbbe8ddSJose Abreu int dwmac5_rxp_config(void __iomem *ioaddr, struct stmmac_tc_entry *entries,
1484dbbe8ddSJose Abreu 		      unsigned int count);
1499a8a02c9SJose Abreu int dwmac5_flex_pps_config(void __iomem *ioaddr, int index,
1509a8a02c9SJose Abreu 			   struct stmmac_pps_cfg *cfg, bool enable,
1519a8a02c9SJose Abreu 			   u32 sub_second_inc, u32 systime_flags);
152504723afSJose Abreu int dwmac5_est_configure(void __iomem *ioaddr, struct stmmac_est *cfg,
153504723afSJose Abreu 			 unsigned int ptp_rate);
154e49aa315SVoon Weifeng void dwmac5_est_irq_status(void __iomem *ioaddr, struct net_device *dev,
1559f298959SOng Boon Leong 			   struct stmmac_extra_stats *x, u32 txqcnt);
156*e1fbdef9SJianheng Zhang void dwmac5_fpe_configure(void __iomem *ioaddr, struct stmmac_fpe_cfg *cfg,
157*e1fbdef9SJianheng Zhang 			  u32 num_txq, u32 num_rxq,
1587c728274SJose Abreu 			  bool enable);
1595a558611SOng Boon Leong void dwmac5_fpe_send_mpacket(void __iomem *ioaddr,
160*e1fbdef9SJianheng Zhang 			     struct stmmac_fpe_cfg *cfg,
1615a558611SOng Boon Leong 			     enum stmmac_mpacket_type type);
1625a558611SOng Boon Leong int dwmac5_fpe_irq_status(void __iomem *ioaddr, struct net_device *dev);
1638bf993a5SJose Abreu 
1648bf993a5SJose Abreu #endif /* __DWMAC5_H__ */
165