armada100_fec.h 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232
  1. /*
  2. * (C) Copyright 2011
  3. * eInfochips Ltd. <www.einfochips.com>
  4. * Written-by: Ajay Bhargav <ajay.bhargav@einfochips.com>
  5. *
  6. * (C) Copyright 2010
  7. * Marvell Semiconductor <www.marvell.com>
  8. * Contributor: Mahavir Jain <mjain@marvell.com>
  9. *
  10. * See file CREDITS for list of people who contributed to this
  11. * project.
  12. *
  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.
  17. *
  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.
  22. *
  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,
  26. * MA 02110-1301 USA
  27. */
  28. #ifndef __ARMADA100_FEC_H__
  29. #define __ARMADA100_FEC_H__
  30. #ifndef TRUE
  31. #define TRUE 1
  32. #endif
  33. #ifndef FALSE
  34. #define FALSE 0
  35. #endif
  36. #define PORT_NUM 0x0
  37. /* RX & TX descriptor command */
  38. #define BUF_OWNED_BY_DMA (1<<31)
  39. /* RX descriptor status */
  40. #define RX_EN_INT (1<<23)
  41. #define RX_FIRST_DESC (1<<17)
  42. #define RX_LAST_DESC (1<<16)
  43. #define RX_ERROR (1<<15)
  44. /* TX descriptor command */
  45. #define TX_EN_INT (1<<23)
  46. #define TX_GEN_CRC (1<<22)
  47. #define TX_ZERO_PADDING (1<<18)
  48. #define TX_FIRST_DESC (1<<17)
  49. #define TX_LAST_DESC (1<<16)
  50. #define TX_ERROR (1<<15)
  51. /* smi register */
  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 */
  56. #define HASH_ADD 0
  57. #define HASH_DELETE 1
  58. #define HASH_ADDR_TABLE_SIZE 0x4000 /* 16K (1/2K address - PCR_HS == 1) */
  59. #define HOP_NUMBER 12
  60. #define PHY_WAIT_ITERATIONS 1000 /* 1000 iterations * 10uS = 10mS max */
  61. #define PHY_WAIT_MICRO_SECONDS 10
  62. #define ETH_HW_IP_ALIGN 2 /* hw aligns IP header */
  63. #define ETH_EXTRA_HEADER (6+6+2+4)
  64. /* dest+src addr+protocol id+crc */
  65. #define MAX_PKT_SIZE 1536
  66. /* Bit definitions of the SDMA Config Reg */
  67. #define SDCR_BSZ_OFF 12
  68. #define SDCR_BSZ8 (3<<SDCR_BSZ_OFF)
  69. #define SDCR_BSZ4 (2<<SDCR_BSZ_OFF)
  70. #define SDCR_BSZ2 (1<<SDCR_BSZ_OFF)
  71. #define SDCR_BSZ1 (0<<SDCR_BSZ_OFF)
  72. #define SDCR_BLMR (1<<6)
  73. #define SDCR_BLMT (1<<7)
  74. #define SDCR_RIFB (1<<9)
  75. #define SDCR_RC_OFF 2
  76. #define SDCR_RC_MAX_RETRANS (0xf << SDCR_RC_OFF)
  77. /* SDMA_CMD */
  78. #define SDMA_CMD_AT (1<<31)
  79. #define SDMA_CMD_TXDL (1<<24)
  80. #define SDMA_CMD_TXDH (1<<23)
  81. #define SDMA_CMD_AR (1<<15)
  82. #define SDMA_CMD_ERD (1<<7)
  83. /* Bit definitions of the Port Config Reg */
  84. #define PCR_HS (1<<12)
  85. #define PCR_EN (1<<7)
  86. #define PCR_PM (1<<0)
  87. /* Bit definitions of the Port Config Extend Reg */
  88. #define PCXR_2BSM (1<<28)
  89. #define PCXR_DSCP_EN (1<<21)
  90. #define PCXR_MFL_1518 (0<<14)
  91. #define PCXR_MFL_1536 (1<<14)
  92. #define PCXR_MFL_2048 (2<<14)
  93. #define PCXR_MFL_64K (3<<14)
  94. #define PCXR_FLP (1<<11)
  95. #define PCXR_PRIO_TX_OFF 3
  96. #define PCXR_TX_HIGH_PRI (7<<PCXR_PRIO_TX_OFF)
  97. /*
  98. * * Bit definitions of the Interrupt Cause Reg
  99. * * and Interrupt MASK Reg is the same
  100. * */
  101. #define ICR_RXBUF (1<<0)
  102. #define ICR_TXBUF_H (1<<2)
  103. #define ICR_TXBUF_L (1<<3)
  104. #define ICR_TXEND_H (1<<6)
  105. #define ICR_TXEND_L (1<<7)
  106. #define ICR_RXERR (1<<8)
  107. #define ICR_TXERR_H (1<<10)
  108. #define ICR_TXERR_L (1<<11)
  109. #define ICR_TX_UDR (1<<13)
  110. #define ICR_MII_CH (1<<28)
  111. #define ALL_INTS (ICR_TXBUF_H | ICR_TXBUF_L | ICR_TX_UDR |\
  112. ICR_TXERR_H | ICR_TXERR_L |\
  113. ICR_TXEND_H | ICR_TXEND_L |\
  114. ICR_RXBUF | ICR_RXERR | ICR_MII_CH)
  115. #define PHY_MASK 0x0000001f
  116. #define to_darmdfec(_kd) container_of(_kd, struct armdfec_device, dev)
  117. /* Size of a Tx/Rx descriptor used in chain list data structure */
  118. #define ARMDFEC_RXQ_DESC_ALIGNED_SIZE \
  119. (((sizeof(struct rx_desc) / PKTALIGN) + 1) * PKTALIGN)
  120. #define RX_BUF_OFFSET 0x2
  121. #define RXQ 0x0 /* RX Queue 0 */
  122. #define TXQ 0x1 /* TX Queue 1 */
  123. struct addr_table_entry_t {
  124. u32 lo;
  125. u32 hi;
  126. };
  127. /* Bit fields of a Hash Table Entry */
  128. enum hash_table_entry {
  129. HTEVALID = 1,
  130. HTESKIP = 2,
  131. HTERD = 4,
  132. HTERDBIT = 2
  133. };
  134. struct tx_desc {
  135. u32 cmd_sts; /* Command/status field */
  136. u16 reserved;
  137. u16 byte_cnt; /* buffer byte count */
  138. u8 *buf_ptr; /* pointer to buffer for this descriptor */
  139. struct tx_desc *nextdesc_p; /* Pointer to next descriptor */
  140. };
  141. struct rx_desc {
  142. u32 cmd_sts; /* Descriptor command status */
  143. u16 byte_cnt; /* Descriptor buffer byte count */
  144. u16 buf_size; /* Buffer size */
  145. u8 *buf_ptr; /* Descriptor buffer pointer */
  146. struct rx_desc *nxtdesc_p; /* Next descriptor pointer */
  147. };
  148. /*
  149. * Armada100 Fast Ethernet controller Registers
  150. * Refer Datasheet Appendix A.22
  151. */
  152. struct armdfec_reg {
  153. u32 phyadr; /* PHY Address */
  154. u32 pad1[3];
  155. u32 smi; /* SMI */
  156. u32 pad2[0xFB];
  157. u32 pconf; /* Port configuration */
  158. u32 pad3;
  159. u32 pconf_ext; /* Port configuration extend */
  160. u32 pad4;
  161. u32 pcmd; /* Port Command */
  162. u32 pad5;
  163. u32 pstatus; /* Port Status */
  164. u32 pad6;
  165. u32 spar; /* Serial Parameters */
  166. u32 pad7;
  167. u32 htpr; /* Hash table pointer */
  168. u32 pad8;
  169. u32 fcsal; /* Flow control source address low */
  170. u32 pad9;
  171. u32 fcsah; /* Flow control source address high */
  172. u32 pad10;
  173. u32 sdma_conf; /* SDMA configuration */
  174. u32 pad11;
  175. u32 sdma_cmd; /* SDMA command */
  176. u32 pad12;
  177. u32 ic; /* Interrupt cause */
  178. u32 iwc; /* Interrupt write to clear */
  179. u32 im; /* Interrupt mask */
  180. u32 pad13;
  181. u32 *eth_idscpp[4]; /* Eth0 IP Differentiated Services Code
  182. Point to Priority 0 Low */
  183. u32 eth_vlan_p; /* Eth0 VLAN Priority Tag to Priority */
  184. u32 pad14[3];
  185. struct rx_desc *rxfdp[4]; /* Ethernet First Rx Descriptor
  186. Pointer */
  187. u32 pad15[4];
  188. struct rx_desc *rxcdp[4]; /* Ethernet Current Rx Descriptor
  189. Pointer */
  190. u32 pad16[0x0C];
  191. struct tx_desc *txcdp[2]; /* Ethernet Current Tx Descriptor
  192. Pointer */
  193. };
  194. struct armdfec_device {
  195. struct eth_device dev;
  196. struct armdfec_reg *regs;
  197. struct tx_desc *p_txdesc;
  198. struct rx_desc *p_rxdesc;
  199. struct rx_desc *p_rxdesc_curr;
  200. u8 *p_rxbuf;
  201. u8 *p_aligned_txbuf;
  202. u8 *htpr; /* hash pointer */
  203. };
  204. #endif /* __ARMADA100_FEC_H__ */