armada100_fec.h 6.8 KB

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