3 * eInfochips Ltd. <www.einfochips.com>
4 * Written-by: Ajay Bhargav <ajay.bhargav@einfochips.com>
7 * Marvell Semiconductor <www.marvell.com>
8 * Contributor: Mahavir Jain <mjain@marvell.com>
10 * SPDX-License-Identifier: GPL-2.0+
13 #ifndef __ARMADA100_FEC_H__
14 #define __ARMADA100_FEC_H__
18 /* RX & TX descriptor command */
19 #define BUF_OWNED_BY_DMA (1<<31)
21 /* RX descriptor status */
22 #define RX_EN_INT (1<<23)
23 #define RX_FIRST_DESC (1<<17)
24 #define RX_LAST_DESC (1<<16)
25 #define RX_ERROR (1<<15)
27 /* TX descriptor command */
28 #define TX_EN_INT (1<<23)
29 #define TX_GEN_CRC (1<<22)
30 #define TX_ZERO_PADDING (1<<18)
31 #define TX_FIRST_DESC (1<<17)
32 #define TX_LAST_DESC (1<<16)
33 #define TX_ERROR (1<<15)
36 #define SMI_BUSY (1<<28) /* 0 - Write, 1 - Read */
37 #define SMI_R_VALID (1<<27) /* 0 - Write, 1 - Read */
38 #define SMI_OP_W (0<<26) /* Write operation */
39 #define SMI_OP_R (1<<26) /* Read operation */
43 #define HASH_ADDR_TABLE_SIZE 0x4000 /* 16K (1/2K address - PCR_HS == 1) */
46 #define PHY_WAIT_ITERATIONS 1000 /* 1000 iterations * 10uS = 10mS max */
47 #define PHY_WAIT_MICRO_SECONDS 10
49 #define ETH_HW_IP_ALIGN 2 /* hw aligns IP header */
50 #define ETH_EXTRA_HEADER (6+6+2+4)
51 /* dest+src addr+protocol id+crc */
52 #define MAX_PKT_SIZE 1536
55 /* Bit definitions of the SDMA Config Reg */
56 #define SDCR_BSZ_OFF 12
57 #define SDCR_BSZ8 (3<<SDCR_BSZ_OFF)
58 #define SDCR_BSZ4 (2<<SDCR_BSZ_OFF)
59 #define SDCR_BSZ2 (1<<SDCR_BSZ_OFF)
60 #define SDCR_BSZ1 (0<<SDCR_BSZ_OFF)
61 #define SDCR_BLMR (1<<6)
62 #define SDCR_BLMT (1<<7)
63 #define SDCR_RIFB (1<<9)
65 #define SDCR_RC_MAX_RETRANS (0xf << SDCR_RC_OFF)
68 #define SDMA_CMD_AT (1<<31)
69 #define SDMA_CMD_TXDL (1<<24)
70 #define SDMA_CMD_TXDH (1<<23)
71 #define SDMA_CMD_AR (1<<15)
72 #define SDMA_CMD_ERD (1<<7)
75 /* Bit definitions of the Port Config Reg */
76 #define PCR_HS (1<<12)
80 /* Bit definitions of the Port Config Extend Reg */
81 #define PCXR_2BSM (1<<28)
82 #define PCXR_DSCP_EN (1<<21)
83 #define PCXR_MFL_1518 (0<<14)
84 #define PCXR_MFL_1536 (1<<14)
85 #define PCXR_MFL_2048 (2<<14)
86 #define PCXR_MFL_64K (3<<14)
87 #define PCXR_FLP (1<<11)
88 #define PCXR_PRIO_TX_OFF 3
89 #define PCXR_TX_HIGH_PRI (7<<PCXR_PRIO_TX_OFF)
92 * * Bit definitions of the Interrupt Cause Reg
93 * * and Interrupt MASK Reg is the same
95 #define ICR_RXBUF (1<<0)
96 #define ICR_TXBUF_H (1<<2)
97 #define ICR_TXBUF_L (1<<3)
98 #define ICR_TXEND_H (1<<6)
99 #define ICR_TXEND_L (1<<7)
100 #define ICR_RXERR (1<<8)
101 #define ICR_TXERR_H (1<<10)
102 #define ICR_TXERR_L (1<<11)
103 #define ICR_TX_UDR (1<<13)
104 #define ICR_MII_CH (1<<28)
106 #define ALL_INTS (ICR_TXBUF_H | ICR_TXBUF_L | ICR_TX_UDR |\
107 ICR_TXERR_H | ICR_TXERR_L |\
108 ICR_TXEND_H | ICR_TXEND_L |\
109 ICR_RXBUF | ICR_RXERR | ICR_MII_CH)
111 #define PHY_MASK 0x0000001f
113 #define to_darmdfec(_kd) container_of(_kd, struct armdfec_device, dev)
114 /* Size of a Tx/Rx descriptor used in chain list data structure */
115 #define ARMDFEC_RXQ_DESC_ALIGNED_SIZE \
116 (((sizeof(struct rx_desc) / PKTALIGN) + 1) * PKTALIGN)
118 #define RX_BUF_OFFSET 0x2
119 #define RXQ 0x0 /* RX Queue 0 */
120 #define TXQ 0x1 /* TX Queue 1 */
122 struct addr_table_entry_t {
127 /* Bit fields of a Hash Table Entry */
128 enum hash_table_entry {
136 u32 cmd_sts; /* Command/status field */
138 u16 byte_cnt; /* buffer byte count */
139 u8 *buf_ptr; /* pointer to buffer for this descriptor */
140 struct tx_desc *nextdesc_p; /* Pointer to next descriptor */
144 u32 cmd_sts; /* Descriptor command status */
145 u16 byte_cnt; /* Descriptor buffer byte count */
146 u16 buf_size; /* Buffer size */
147 u8 *buf_ptr; /* Descriptor buffer pointer */
148 struct rx_desc *nxtdesc_p; /* Next descriptor pointer */
152 * Armada100 Fast Ethernet controller Registers
153 * Refer Datasheet Appendix A.22
156 u32 phyadr; /* PHY Address */
160 u32 pconf; /* Port configuration */
162 u32 pconf_ext; /* Port configuration extend */
164 u32 pcmd; /* Port Command */
166 u32 pstatus; /* Port Status */
168 u32 spar; /* Serial Parameters */
170 u32 htpr; /* Hash table pointer */
172 u32 fcsal; /* Flow control source address low */
174 u32 fcsah; /* Flow control source address high */
176 u32 sdma_conf; /* SDMA configuration */
178 u32 sdma_cmd; /* SDMA command */
180 u32 ic; /* Interrupt cause */
181 u32 iwc; /* Interrupt write to clear */
182 u32 im; /* Interrupt mask */
184 u32 *eth_idscpp[4]; /* Eth0 IP Differentiated Services Code
185 Point to Priority 0 Low */
186 u32 eth_vlan_p; /* Eth0 VLAN Priority Tag to Priority */
188 struct rx_desc *rxfdp[4]; /* Ethernet First Rx Descriptor
191 struct rx_desc *rxcdp[4]; /* Ethernet Current Rx Descriptor
194 struct tx_desc *txcdp[2]; /* Ethernet Current Tx Descriptor
198 struct armdfec_device {
199 struct eth_device dev;
200 struct armdfec_reg *regs;
201 struct tx_desc *p_txdesc;
202 struct rx_desc *p_rxdesc;
203 struct rx_desc *p_rxdesc_curr;
206 u8 *htpr; /* hash pointer */
209 #endif /* __ARMADA100_FEC_H__ */