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 * See file CREDITS for list of people who contributed to this
13 * This program is free software; you can redistribute it and/or
14 * modify it under the terms of the GNU General Public License as
15 * published by the Free Software Foundation; either version 2 of
16 * the License, or (at your option) any later version.
18 * This program is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
23 * You should have received a copy of the GNU General Public License
24 * along with this program; if not, write to the Free Software
25 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
29 #ifndef __ARMADA100_FEC_H__
30 #define __ARMADA100_FEC_H__
41 /* RX & TX descriptor command */
42 #define BUF_OWNED_BY_DMA (1<<31)
44 /* RX descriptor status */
45 #define RX_EN_INT (1<<23)
46 #define RX_FIRST_DESC (1<<17)
47 #define RX_LAST_DESC (1<<16)
48 #define RX_ERROR (1<<15)
50 /* TX descriptor command */
51 #define TX_EN_INT (1<<23)
52 #define TX_GEN_CRC (1<<22)
53 #define TX_ZERO_PADDING (1<<18)
54 #define TX_FIRST_DESC (1<<17)
55 #define TX_LAST_DESC (1<<16)
56 #define TX_ERROR (1<<15)
59 #define SMI_BUSY (1<<28) /* 0 - Write, 1 - Read */
60 #define SMI_R_VALID (1<<27) /* 0 - Write, 1 - Read */
61 #define SMI_OP_W (0<<26) /* Write operation */
62 #define SMI_OP_R (1<<26) /* Read operation */
66 #define HASH_ADDR_TABLE_SIZE 0x4000 /* 16K (1/2K address - PCR_HS == 1) */
69 #define PHY_WAIT_ITERATIONS 1000 /* 1000 iterations * 10uS = 10mS max */
70 #define PHY_WAIT_MICRO_SECONDS 10
72 #define ETH_HW_IP_ALIGN 2 /* hw aligns IP header */
73 #define ETH_EXTRA_HEADER (6+6+2+4)
74 /* dest+src addr+protocol id+crc */
75 #define MAX_PKT_SIZE 1536
78 /* Bit definitions of the SDMA Config Reg */
79 #define SDCR_BSZ_OFF 12
80 #define SDCR_BSZ8 (3<<SDCR_BSZ_OFF)
81 #define SDCR_BSZ4 (2<<SDCR_BSZ_OFF)
82 #define SDCR_BSZ2 (1<<SDCR_BSZ_OFF)
83 #define SDCR_BSZ1 (0<<SDCR_BSZ_OFF)
84 #define SDCR_BLMR (1<<6)
85 #define SDCR_BLMT (1<<7)
86 #define SDCR_RIFB (1<<9)
88 #define SDCR_RC_MAX_RETRANS (0xf << SDCR_RC_OFF)
91 #define SDMA_CMD_AT (1<<31)
92 #define SDMA_CMD_TXDL (1<<24)
93 #define SDMA_CMD_TXDH (1<<23)
94 #define SDMA_CMD_AR (1<<15)
95 #define SDMA_CMD_ERD (1<<7)
98 /* Bit definitions of the Port Config Reg */
99 #define PCR_HS (1<<12)
100 #define PCR_EN (1<<7)
101 #define PCR_PM (1<<0)
103 /* Bit definitions of the Port Config Extend Reg */
104 #define PCXR_2BSM (1<<28)
105 #define PCXR_DSCP_EN (1<<21)
106 #define PCXR_MFL_1518 (0<<14)
107 #define PCXR_MFL_1536 (1<<14)
108 #define PCXR_MFL_2048 (2<<14)
109 #define PCXR_MFL_64K (3<<14)
110 #define PCXR_FLP (1<<11)
111 #define PCXR_PRIO_TX_OFF 3
112 #define PCXR_TX_HIGH_PRI (7<<PCXR_PRIO_TX_OFF)
115 * * Bit definitions of the Interrupt Cause Reg
116 * * and Interrupt MASK Reg is the same
118 #define ICR_RXBUF (1<<0)
119 #define ICR_TXBUF_H (1<<2)
120 #define ICR_TXBUF_L (1<<3)
121 #define ICR_TXEND_H (1<<6)
122 #define ICR_TXEND_L (1<<7)
123 #define ICR_RXERR (1<<8)
124 #define ICR_TXERR_H (1<<10)
125 #define ICR_TXERR_L (1<<11)
126 #define ICR_TX_UDR (1<<13)
127 #define ICR_MII_CH (1<<28)
129 #define ALL_INTS (ICR_TXBUF_H | ICR_TXBUF_L | ICR_TX_UDR |\
130 ICR_TXERR_H | ICR_TXERR_L |\
131 ICR_TXEND_H | ICR_TXEND_L |\
132 ICR_RXBUF | ICR_RXERR | ICR_MII_CH)
134 #define PHY_MASK 0x0000001f
136 #define to_darmdfec(_kd) container_of(_kd, struct armdfec_device, dev)
137 /* Size of a Tx/Rx descriptor used in chain list data structure */
138 #define ARMDFEC_RXQ_DESC_ALIGNED_SIZE \
139 (((sizeof(struct rx_desc) / PKTALIGN) + 1) * PKTALIGN)
141 #define RX_BUF_OFFSET 0x2
142 #define RXQ 0x0 /* RX Queue 0 */
143 #define TXQ 0x1 /* TX Queue 1 */
145 struct addr_table_entry_t {
150 /* Bit fields of a Hash Table Entry */
151 enum hash_table_entry {
159 u32 cmd_sts; /* Command/status field */
161 u16 byte_cnt; /* buffer byte count */
162 u8 *buf_ptr; /* pointer to buffer for this descriptor */
163 struct tx_desc *nextdesc_p; /* Pointer to next descriptor */
167 u32 cmd_sts; /* Descriptor command status */
168 u16 byte_cnt; /* Descriptor buffer byte count */
169 u16 buf_size; /* Buffer size */
170 u8 *buf_ptr; /* Descriptor buffer pointer */
171 struct rx_desc *nxtdesc_p; /* Next descriptor pointer */
175 * Armada100 Fast Ethernet controller Registers
176 * Refer Datasheet Appendix A.22
179 u32 phyadr; /* PHY Address */
183 u32 pconf; /* Port configuration */
185 u32 pconf_ext; /* Port configuration extend */
187 u32 pcmd; /* Port Command */
189 u32 pstatus; /* Port Status */
191 u32 spar; /* Serial Parameters */
193 u32 htpr; /* Hash table pointer */
195 u32 fcsal; /* Flow control source address low */
197 u32 fcsah; /* Flow control source address high */
199 u32 sdma_conf; /* SDMA configuration */
201 u32 sdma_cmd; /* SDMA command */
203 u32 ic; /* Interrupt cause */
204 u32 iwc; /* Interrupt write to clear */
205 u32 im; /* Interrupt mask */
207 u32 *eth_idscpp[4]; /* Eth0 IP Differentiated Services Code
208 Point to Priority 0 Low */
209 u32 eth_vlan_p; /* Eth0 VLAN Priority Tag to Priority */
211 struct rx_desc *rxfdp[4]; /* Ethernet First Rx Descriptor
214 struct rx_desc *rxcdp[4]; /* Ethernet Current Rx Descriptor
217 struct tx_desc *txcdp[2]; /* Ethernet Current Tx Descriptor
221 struct armdfec_device {
222 struct eth_device dev;
223 struct armdfec_reg *regs;
224 struct tx_desc *p_txdesc;
225 struct rx_desc *p_rxdesc;
226 struct rx_desc *p_rxdesc_curr;
229 u8 *htpr; /* hash pointer */
232 #endif /* __ARMADA100_FEC_H__ */