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__
34 /* RX & TX descriptor command */
35 #define BUF_OWNED_BY_DMA (1<<31)
37 /* RX descriptor status */
38 #define RX_EN_INT (1<<23)
39 #define RX_FIRST_DESC (1<<17)
40 #define RX_LAST_DESC (1<<16)
41 #define RX_ERROR (1<<15)
43 /* TX descriptor command */
44 #define TX_EN_INT (1<<23)
45 #define TX_GEN_CRC (1<<22)
46 #define TX_ZERO_PADDING (1<<18)
47 #define TX_FIRST_DESC (1<<17)
48 #define TX_LAST_DESC (1<<16)
49 #define TX_ERROR (1<<15)
52 #define SMI_BUSY (1<<28) /* 0 - Write, 1 - Read */
53 #define SMI_R_VALID (1<<27) /* 0 - Write, 1 - Read */
54 #define SMI_OP_W (0<<26) /* Write operation */
55 #define SMI_OP_R (1<<26) /* Read operation */
59 #define HASH_ADDR_TABLE_SIZE 0x4000 /* 16K (1/2K address - PCR_HS == 1) */
62 #define PHY_WAIT_ITERATIONS 1000 /* 1000 iterations * 10uS = 10mS max */
63 #define PHY_WAIT_MICRO_SECONDS 10
65 #define ETH_HW_IP_ALIGN 2 /* hw aligns IP header */
66 #define ETH_EXTRA_HEADER (6+6+2+4)
67 /* dest+src addr+protocol id+crc */
68 #define MAX_PKT_SIZE 1536
71 /* Bit definitions of the SDMA Config Reg */
72 #define SDCR_BSZ_OFF 12
73 #define SDCR_BSZ8 (3<<SDCR_BSZ_OFF)
74 #define SDCR_BSZ4 (2<<SDCR_BSZ_OFF)
75 #define SDCR_BSZ2 (1<<SDCR_BSZ_OFF)
76 #define SDCR_BSZ1 (0<<SDCR_BSZ_OFF)
77 #define SDCR_BLMR (1<<6)
78 #define SDCR_BLMT (1<<7)
79 #define SDCR_RIFB (1<<9)
81 #define SDCR_RC_MAX_RETRANS (0xf << SDCR_RC_OFF)
84 #define SDMA_CMD_AT (1<<31)
85 #define SDMA_CMD_TXDL (1<<24)
86 #define SDMA_CMD_TXDH (1<<23)
87 #define SDMA_CMD_AR (1<<15)
88 #define SDMA_CMD_ERD (1<<7)
91 /* Bit definitions of the Port Config Reg */
92 #define PCR_HS (1<<12)
96 /* Bit definitions of the Port Config Extend Reg */
97 #define PCXR_2BSM (1<<28)
98 #define PCXR_DSCP_EN (1<<21)
99 #define PCXR_MFL_1518 (0<<14)
100 #define PCXR_MFL_1536 (1<<14)
101 #define PCXR_MFL_2048 (2<<14)
102 #define PCXR_MFL_64K (3<<14)
103 #define PCXR_FLP (1<<11)
104 #define PCXR_PRIO_TX_OFF 3
105 #define PCXR_TX_HIGH_PRI (7<<PCXR_PRIO_TX_OFF)
108 * * Bit definitions of the Interrupt Cause Reg
109 * * and Interrupt MASK Reg is the same
111 #define ICR_RXBUF (1<<0)
112 #define ICR_TXBUF_H (1<<2)
113 #define ICR_TXBUF_L (1<<3)
114 #define ICR_TXEND_H (1<<6)
115 #define ICR_TXEND_L (1<<7)
116 #define ICR_RXERR (1<<8)
117 #define ICR_TXERR_H (1<<10)
118 #define ICR_TXERR_L (1<<11)
119 #define ICR_TX_UDR (1<<13)
120 #define ICR_MII_CH (1<<28)
122 #define ALL_INTS (ICR_TXBUF_H | ICR_TXBUF_L | ICR_TX_UDR |\
123 ICR_TXERR_H | ICR_TXERR_L |\
124 ICR_TXEND_H | ICR_TXEND_L |\
125 ICR_RXBUF | ICR_RXERR | ICR_MII_CH)
127 #define PHY_MASK 0x0000001f
129 #define to_darmdfec(_kd) container_of(_kd, struct armdfec_device, dev)
130 /* Size of a Tx/Rx descriptor used in chain list data structure */
131 #define ARMDFEC_RXQ_DESC_ALIGNED_SIZE \
132 (((sizeof(struct rx_desc) / PKTALIGN) + 1) * PKTALIGN)
134 #define RX_BUF_OFFSET 0x2
135 #define RXQ 0x0 /* RX Queue 0 */
136 #define TXQ 0x1 /* TX Queue 1 */
138 struct addr_table_entry_t {
143 /* Bit fields of a Hash Table Entry */
144 enum hash_table_entry {
152 u32 cmd_sts; /* Command/status field */
154 u16 byte_cnt; /* buffer byte count */
155 u8 *buf_ptr; /* pointer to buffer for this descriptor */
156 struct tx_desc *nextdesc_p; /* Pointer to next descriptor */
160 u32 cmd_sts; /* Descriptor command status */
161 u16 byte_cnt; /* Descriptor buffer byte count */
162 u16 buf_size; /* Buffer size */
163 u8 *buf_ptr; /* Descriptor buffer pointer */
164 struct rx_desc *nxtdesc_p; /* Next descriptor pointer */
168 * Armada100 Fast Ethernet controller Registers
169 * Refer Datasheet Appendix A.22
172 u32 phyadr; /* PHY Address */
176 u32 pconf; /* Port configuration */
178 u32 pconf_ext; /* Port configuration extend */
180 u32 pcmd; /* Port Command */
182 u32 pstatus; /* Port Status */
184 u32 spar; /* Serial Parameters */
186 u32 htpr; /* Hash table pointer */
188 u32 fcsal; /* Flow control source address low */
190 u32 fcsah; /* Flow control source address high */
192 u32 sdma_conf; /* SDMA configuration */
194 u32 sdma_cmd; /* SDMA command */
196 u32 ic; /* Interrupt cause */
197 u32 iwc; /* Interrupt write to clear */
198 u32 im; /* Interrupt mask */
200 u32 *eth_idscpp[4]; /* Eth0 IP Differentiated Services Code
201 Point to Priority 0 Low */
202 u32 eth_vlan_p; /* Eth0 VLAN Priority Tag to Priority */
204 struct rx_desc *rxfdp[4]; /* Ethernet First Rx Descriptor
207 struct rx_desc *rxcdp[4]; /* Ethernet Current Rx Descriptor
210 struct tx_desc *txcdp[2]; /* Ethernet Current Tx Descriptor
214 struct armdfec_device {
215 struct eth_device dev;
216 struct armdfec_reg *regs;
217 struct tx_desc *p_txdesc;
218 struct rx_desc *p_rxdesc;
219 struct rx_desc *p_rxdesc_curr;
222 u8 *htpr; /* hash pointer */
225 #endif /* __ARMADA100_FEC_H__ */