xref: /linux/drivers/net/ethernet/ezchip/nps_enet.h (revision 4fa9c49f4d596edf89a6364a92af7b8102231d73)
1*4fa9c49fSThomas Gleixner /* SPDX-License-Identifier: GPL-2.0-only */
20dd07709SNoam Camus /*
30dd07709SNoam Camus  * Copyright(c) 2015 EZchip Technologies.
40dd07709SNoam Camus  */
50dd07709SNoam Camus 
60dd07709SNoam Camus #ifndef _NPS_ENET_H
70dd07709SNoam Camus #define _NPS_ENET_H
80dd07709SNoam Camus 
90dd07709SNoam Camus /* default values */
100dd07709SNoam Camus #define NPS_ENET_NAPI_POLL_WEIGHT		0x2
110dd07709SNoam Camus #define NPS_ENET_MAX_FRAME_LENGTH		0x3FFF
120dd07709SNoam Camus #define NPS_ENET_GE_MAC_CFG_0_TX_FC_RETR	0x7
130dd07709SNoam Camus #define NPS_ENET_GE_MAC_CFG_0_RX_IFG		0x5
140dd07709SNoam Camus #define NPS_ENET_GE_MAC_CFG_0_TX_IFG		0xC
150dd07709SNoam Camus #define NPS_ENET_GE_MAC_CFG_0_TX_PR_LEN		0x7
160dd07709SNoam Camus #define NPS_ENET_GE_MAC_CFG_2_STAT_EN		0x3
170dd07709SNoam Camus #define NPS_ENET_GE_MAC_CFG_3_RX_IFG_TH		0x14
180dd07709SNoam Camus #define NPS_ENET_GE_MAC_CFG_3_MAX_LEN		0x3FFC
190dd07709SNoam Camus #define NPS_ENET_ENABLE				1
200dd07709SNoam Camus #define NPS_ENET_DISABLE			0
210dd07709SNoam Camus 
220dd07709SNoam Camus /* register definitions  */
230dd07709SNoam Camus #define NPS_ENET_REG_TX_CTL		0x800
240dd07709SNoam Camus #define NPS_ENET_REG_TX_BUF		0x808
250dd07709SNoam Camus #define NPS_ENET_REG_RX_CTL		0x810
260dd07709SNoam Camus #define NPS_ENET_REG_RX_BUF		0x818
270dd07709SNoam Camus #define NPS_ENET_REG_BUF_INT_ENABLE	0x8C0
280dd07709SNoam Camus #define NPS_ENET_REG_GE_MAC_CFG_0	0x1000
290dd07709SNoam Camus #define NPS_ENET_REG_GE_MAC_CFG_1	0x1004
300dd07709SNoam Camus #define NPS_ENET_REG_GE_MAC_CFG_2	0x1008
310dd07709SNoam Camus #define NPS_ENET_REG_GE_MAC_CFG_3	0x100C
320dd07709SNoam Camus #define NPS_ENET_REG_GE_RST		0x1400
330dd07709SNoam Camus #define NPS_ENET_REG_PHASE_FIFO_CTL	0x1404
340dd07709SNoam Camus 
35b54b8c2dSLada Trimasova /* Tx control register masks and shifts */
36b54b8c2dSLada Trimasova #define TX_CTL_NT_MASK 0x7FF
37b54b8c2dSLada Trimasova #define TX_CTL_NT_SHIFT 0
38b54b8c2dSLada Trimasova #define TX_CTL_ET_MASK 0x4000
39b54b8c2dSLada Trimasova #define TX_CTL_ET_SHIFT 14
40b54b8c2dSLada Trimasova #define TX_CTL_CT_MASK 0x8000
41b54b8c2dSLada Trimasova #define TX_CTL_CT_SHIFT 15
420dd07709SNoam Camus 
43b54b8c2dSLada Trimasova /* Rx control register masks and shifts */
44b54b8c2dSLada Trimasova #define RX_CTL_NR_MASK 0x7FF
45b54b8c2dSLada Trimasova #define RX_CTL_NR_SHIFT 0
46b54b8c2dSLada Trimasova #define RX_CTL_CRC_MASK 0x2000
47b54b8c2dSLada Trimasova #define RX_CTL_CRC_SHIFT 13
48b54b8c2dSLada Trimasova #define RX_CTL_ER_MASK 0x4000
49b54b8c2dSLada Trimasova #define RX_CTL_ER_SHIFT 14
50b54b8c2dSLada Trimasova #define RX_CTL_CR_MASK 0x8000
51b54b8c2dSLada Trimasova #define RX_CTL_CR_SHIFT 15
520dd07709SNoam Camus 
53b54b8c2dSLada Trimasova /* Interrupt enable for data buffer events register masks and shifts */
54b54b8c2dSLada Trimasova #define RX_RDY_MASK 0x1
55b54b8c2dSLada Trimasova #define RX_RDY_SHIFT 0
56b54b8c2dSLada Trimasova #define TX_DONE_MASK 0x2
57b54b8c2dSLada Trimasova #define TX_DONE_SHIFT 1
580dd07709SNoam Camus 
59b54b8c2dSLada Trimasova /* Gbps Eth MAC Configuration 0 register masks and shifts */
60b54b8c2dSLada Trimasova #define CFG_0_RX_EN_MASK 0x1
61b54b8c2dSLada Trimasova #define CFG_0_RX_EN_SHIFT 0
62b54b8c2dSLada Trimasova #define CFG_0_TX_EN_MASK 0x2
63b54b8c2dSLada Trimasova #define CFG_0_TX_EN_SHIFT 1
64b54b8c2dSLada Trimasova #define CFG_0_TX_FC_EN_MASK 0x4
65b54b8c2dSLada Trimasova #define CFG_0_TX_FC_EN_SHIFT 2
66b54b8c2dSLada Trimasova #define CFG_0_TX_PAD_EN_MASK 0x8
67b54b8c2dSLada Trimasova #define CFG_0_TX_PAD_EN_SHIFT 3
68b54b8c2dSLada Trimasova #define CFG_0_TX_CRC_EN_MASK 0x10
69b54b8c2dSLada Trimasova #define CFG_0_TX_CRC_EN_SHIFT 4
70b54b8c2dSLada Trimasova #define CFG_0_RX_FC_EN_MASK 0x20
71b54b8c2dSLada Trimasova #define CFG_0_RX_FC_EN_SHIFT 5
72b54b8c2dSLada Trimasova #define CFG_0_RX_CRC_STRIP_MASK 0x40
73b54b8c2dSLada Trimasova #define CFG_0_RX_CRC_STRIP_SHIFT 6
74b54b8c2dSLada Trimasova #define CFG_0_RX_CRC_IGNORE_MASK 0x80
75b54b8c2dSLada Trimasova #define CFG_0_RX_CRC_IGNORE_SHIFT 7
76b54b8c2dSLada Trimasova #define CFG_0_RX_LENGTH_CHECK_EN_MASK 0x100
77b54b8c2dSLada Trimasova #define CFG_0_RX_LENGTH_CHECK_EN_SHIFT 8
78b54b8c2dSLada Trimasova #define CFG_0_TX_FC_RETR_MASK 0xE00
79b54b8c2dSLada Trimasova #define CFG_0_TX_FC_RETR_SHIFT 9
80b54b8c2dSLada Trimasova #define CFG_0_RX_IFG_MASK 0xF000
81b54b8c2dSLada Trimasova #define CFG_0_RX_IFG_SHIFT 12
82b54b8c2dSLada Trimasova #define CFG_0_TX_IFG_MASK 0x3F0000
83b54b8c2dSLada Trimasova #define CFG_0_TX_IFG_SHIFT 16
84b54b8c2dSLada Trimasova #define CFG_0_RX_PR_CHECK_EN_MASK 0x400000
85b54b8c2dSLada Trimasova #define CFG_0_RX_PR_CHECK_EN_SHIFT 22
86b54b8c2dSLada Trimasova #define CFG_0_NIB_MODE_MASK 0x800000
87b54b8c2dSLada Trimasova #define CFG_0_NIB_MODE_SHIFT 23
88b54b8c2dSLada Trimasova #define CFG_0_TX_IFG_NIB_MASK 0xF000000
89b54b8c2dSLada Trimasova #define CFG_0_TX_IFG_NIB_SHIFT 24
90b54b8c2dSLada Trimasova #define CFG_0_TX_PR_LEN_MASK 0xF0000000
91b54b8c2dSLada Trimasova #define CFG_0_TX_PR_LEN_SHIFT 28
920dd07709SNoam Camus 
93b54b8c2dSLada Trimasova /* Gbps Eth MAC Configuration 1 register masks and shifts */
94b54b8c2dSLada Trimasova #define CFG_1_OCTET_0_MASK 0x000000FF
95b54b8c2dSLada Trimasova #define CFG_1_OCTET_0_SHIFT 0
96b54b8c2dSLada Trimasova #define CFG_1_OCTET_1_MASK 0x0000FF00
97b54b8c2dSLada Trimasova #define CFG_1_OCTET_1_SHIFT 8
98b54b8c2dSLada Trimasova #define CFG_1_OCTET_2_MASK 0x00FF0000
99b54b8c2dSLada Trimasova #define CFG_1_OCTET_2_SHIFT 16
100b54b8c2dSLada Trimasova #define CFG_1_OCTET_3_MASK 0xFF000000
101b54b8c2dSLada Trimasova #define CFG_1_OCTET_3_SHIFT 24
1020dd07709SNoam Camus 
103b54b8c2dSLada Trimasova /* Gbps Eth MAC Configuration 2 register masks and shifts */
104b54b8c2dSLada Trimasova #define CFG_2_OCTET_4_MASK 0x000000FF
105b54b8c2dSLada Trimasova #define CFG_2_OCTET_4_SHIFT 0
106b54b8c2dSLada Trimasova #define CFG_2_OCTET_5_MASK 0x0000FF00
107b54b8c2dSLada Trimasova #define CFG_2_OCTET_5_SHIFT 8
108b54b8c2dSLada Trimasova #define CFG_2_DISK_MC_MASK 0x00100000
109b54b8c2dSLada Trimasova #define CFG_2_DISK_MC_SHIFT 20
110b54b8c2dSLada Trimasova #define CFG_2_DISK_BC_MASK 0x00200000
111b54b8c2dSLada Trimasova #define CFG_2_DISK_BC_SHIFT 21
112b54b8c2dSLada Trimasova #define CFG_2_DISK_DA_MASK 0x00400000
113b54b8c2dSLada Trimasova #define CFG_2_DISK_DA_SHIFT 22
114b54b8c2dSLada Trimasova #define CFG_2_STAT_EN_MASK 0x3000000
115b54b8c2dSLada Trimasova #define CFG_2_STAT_EN_SHIFT 24
116b54b8c2dSLada Trimasova #define CFG_2_TRANSMIT_FLUSH_EN_MASK 0x80000000
117b54b8c2dSLada Trimasova #define CFG_2_TRANSMIT_FLUSH_EN_SHIFT 31
1180dd07709SNoam Camus 
119b54b8c2dSLada Trimasova /* Gbps Eth MAC Configuration 3 register masks and shifts */
120b54b8c2dSLada Trimasova #define CFG_3_TM_HD_MODE_MASK 0x1
121b54b8c2dSLada Trimasova #define CFG_3_TM_HD_MODE_SHIFT 0
122b54b8c2dSLada Trimasova #define CFG_3_RX_CBFC_EN_MASK 0x2
123b54b8c2dSLada Trimasova #define CFG_3_RX_CBFC_EN_SHIFT 1
124b54b8c2dSLada Trimasova #define CFG_3_RX_CBFC_REDIR_EN_MASK 0x4
125b54b8c2dSLada Trimasova #define CFG_3_RX_CBFC_REDIR_EN_SHIFT 2
126b54b8c2dSLada Trimasova #define CFG_3_REDIRECT_CBFC_SEL_MASK 0x18
127b54b8c2dSLada Trimasova #define CFG_3_REDIRECT_CBFC_SEL_SHIFT 3
128b54b8c2dSLada Trimasova #define CFG_3_CF_DROP_MASK 0x20
129b54b8c2dSLada Trimasova #define CFG_3_CF_DROP_SHIFT 5
130b54b8c2dSLada Trimasova #define CFG_3_CF_TIMEOUT_MASK 0x3C0
131b54b8c2dSLada Trimasova #define CFG_3_CF_TIMEOUT_SHIFT 6
132b54b8c2dSLada Trimasova #define CFG_3_RX_IFG_TH_MASK 0x7C00
133b54b8c2dSLada Trimasova #define CFG_3_RX_IFG_TH_SHIFT 10
134b54b8c2dSLada Trimasova #define CFG_3_TX_CBFC_EN_MASK 0x8000
135b54b8c2dSLada Trimasova #define CFG_3_TX_CBFC_EN_SHIFT 15
136b54b8c2dSLada Trimasova #define CFG_3_MAX_LEN_MASK 0x3FFF0000
137b54b8c2dSLada Trimasova #define CFG_3_MAX_LEN_SHIFT 16
138b54b8c2dSLada Trimasova #define CFG_3_EXT_OOB_CBFC_SEL_MASK 0xC0000000
139b54b8c2dSLada Trimasova #define CFG_3_EXT_OOB_CBFC_SEL_SHIFT 30
1400dd07709SNoam Camus 
141b54b8c2dSLada Trimasova /* GE MAC, PCS reset control register masks and shifts */
142b54b8c2dSLada Trimasova #define RST_SPCS_MASK 0x1
143b54b8c2dSLada Trimasova #define RST_SPCS_SHIFT 0
144b54b8c2dSLada Trimasova #define RST_GMAC_0_MASK 0x100
145b54b8c2dSLada Trimasova #define RST_GMAC_0_SHIFT 8
1460dd07709SNoam Camus 
147b54b8c2dSLada Trimasova /* Tx phase sync FIFO control register masks and shifts */
148b54b8c2dSLada Trimasova #define PHASE_FIFO_CTL_RST_MASK 0x1
149b54b8c2dSLada Trimasova #define PHASE_FIFO_CTL_RST_SHIFT 0
150b54b8c2dSLada Trimasova #define PHASE_FIFO_CTL_INIT_MASK 0x2
151b54b8c2dSLada Trimasova #define PHASE_FIFO_CTL_INIT_SHIFT 1
1520dd07709SNoam Camus 
1530dd07709SNoam Camus /**
1540dd07709SNoam Camus  * struct nps_enet_priv - Storage of ENET's private information.
1550dd07709SNoam Camus  * @regs_base:      Base address of ENET memory-mapped control registers.
1560dd07709SNoam Camus  * @irq:            For RX/TX IRQ number.
1570dd07709SNoam Camus  * @tx_skb:         socket buffer of sent frame.
1580dd07709SNoam Camus  * @napi:           Structure for NAPI.
1590dd07709SNoam Camus  */
1600dd07709SNoam Camus struct nps_enet_priv {
1610dd07709SNoam Camus 	void __iomem *regs_base;
1620dd07709SNoam Camus 	s32 irq;
1630dd07709SNoam Camus 	struct sk_buff *tx_skb;
1640dd07709SNoam Camus 	struct napi_struct napi;
165b54b8c2dSLada Trimasova 	u32 ge_mac_cfg_2_value;
166b54b8c2dSLada Trimasova 	u32 ge_mac_cfg_3_value;
1670dd07709SNoam Camus };
1680dd07709SNoam Camus 
1690dd07709SNoam Camus /**
1700dd07709SNoam Camus  * nps_reg_set - Sets ENET register with provided value.
1710dd07709SNoam Camus  * @priv:       Pointer to EZchip ENET private data structure.
1720dd07709SNoam Camus  * @reg:        Register offset from base address.
1730dd07709SNoam Camus  * @value:      Value to set in register.
1740dd07709SNoam Camus  */
1750dd07709SNoam Camus static inline void nps_enet_reg_set(struct nps_enet_priv *priv,
1760dd07709SNoam Camus 				    s32 reg, s32 value)
1770dd07709SNoam Camus {
1780dd07709SNoam Camus 	iowrite32be(value, priv->regs_base + reg);
1790dd07709SNoam Camus }
1800dd07709SNoam Camus 
1810dd07709SNoam Camus /**
1820dd07709SNoam Camus  * nps_reg_get - Gets value of specified ENET register.
1830dd07709SNoam Camus  * @priv:       Pointer to EZchip ENET private data structure.
1840dd07709SNoam Camus  * @reg:        Register offset from base address.
1850dd07709SNoam Camus  *
1860dd07709SNoam Camus  * returns:     Value of requested register.
1870dd07709SNoam Camus  */
1880dd07709SNoam Camus static inline u32 nps_enet_reg_get(struct nps_enet_priv *priv, s32 reg)
1890dd07709SNoam Camus {
1900dd07709SNoam Camus 	return ioread32be(priv->regs_base + reg);
1910dd07709SNoam Camus }
1920dd07709SNoam Camus 
1930dd07709SNoam Camus #endif /* _NPS_ENET_H */
194