/drivers/net/sun4i/sun4i_wemac.h

https://bitbucket.org/ndreys/linux-sunxi · C Header · 251 lines · 176 code · 37 blank · 38 comment · 0 complexity · dff20ddf47683c56852595abf5de84cd MD5 · raw file

  1. /*
  2. * drivers/net/sun4i/sun4i_wemac.h
  3. *
  4. * (C) Copyright 2007-2012
  5. * Allwinner Technology Co., Ltd. <www.allwinnertech.com>
  6. *
  7. * This program is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU General Public License as
  9. * published by the Free Software Foundation; either version 2 of
  10. * the License, or (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program; if not, write to the Free Software
  19. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  20. * MA 02111-1307 USA
  21. */
  22. /*
  23. * wemac Ethernet
  24. */
  25. #ifndef _WEMACX_H_
  26. #define _WEMACX_H_
  27. /* registers define */
  28. /* EMAC register */
  29. #define EMAC_BASE 0x01C0B000
  30. #define EMAC_CTL_REG (0x00)
  31. #define EMAC_TX_MODE_REG (0x04)
  32. #define EMAC_TX_FLOW_REG (0x08)
  33. #define EMAC_TX_CTL0_REG (0x0C)
  34. #define EMAC_TX_CTL1_REG (0x10)
  35. #define EMAC_TX_INS_REG (0x14)
  36. #define EMAC_TX_PL0_REG (0x18)
  37. #define EMAC_TX_PL1_REG (0x1C)
  38. #define EMAC_TX_STA_REG (0x20)
  39. #define EMAC_TX_IO_DATA_REG (0x24)
  40. #define EMAC_TX_IO_DATA1_REG (0x28)
  41. #define EMAC_TX_TSVL0_REG (0x2C)
  42. #define EMAC_TX_TSVH0_REG (0x30)
  43. #define EMAC_TX_TSVL1_REG (0x34)
  44. #define EMAC_TX_TSVH1_REG (0x38)
  45. #define EMAC_RX_CTL_REG (0x3C)
  46. #define EMAC_RX_HASH0_REG (0x40)
  47. #define EMAC_RX_HASH1_REG (0x44)
  48. #define EMAC_RX_STA_REG (0x48)
  49. #define EMAC_RX_IO_DATA_REG (0x4C)
  50. #define EMAC_RX_FBC_REG (0x50)
  51. #define EMAC_INT_CTL_REG (0x54)
  52. #define EMAC_INT_STA_REG (0x58)
  53. #define EMAC_MAC_CTL0_REG (0x5C)
  54. #define EMAC_MAC_CTL1_REG (0x60)
  55. #define EMAC_MAC_IPGT_REG (0x64)
  56. #define EMAC_MAC_IPGR_REG (0x68)
  57. #define EMAC_MAC_CLRT_REG (0x6C)
  58. #define EMAC_MAC_MAXF_REG (0x70)
  59. #define EMAC_MAC_SUPP_REG (0x74)
  60. #define EMAC_MAC_TEST_REG (0x78)
  61. #define EMAC_MAC_MCFG_REG (0x7C)
  62. #define EMAC_MAC_MCMD_REG (0x80)
  63. #define EMAC_MAC_MADR_REG (0x84)
  64. #define EMAC_MAC_MWTD_REG (0x88)
  65. #define EMAC_MAC_MRDD_REG (0x8C)
  66. #define EMAC_MAC_MIND_REG (0x90)
  67. #define EMAC_MAC_SSRR_REG (0x94)
  68. #define EMAC_MAC_A0_REG (0x98)
  69. #define EMAC_MAC_A1_REG (0x9C)
  70. #define EMAC_MAC_A2_REG (0xA0)
  71. #define EMAC_SAFX_L_REG0 (0xA4)
  72. #define EMAC_SAFX_H_REG0 (0xA8)
  73. #define EMAC_SAFX_L_REG1 (0xAC)
  74. #define EMAC_SAFX_H_REG1 (0xB0)
  75. #define EMAC_SAFX_L_REG2 (0xB4)
  76. #define EMAC_SAFX_H_REG2 (0xB8)
  77. #define EMAC_SAFX_L_REG3 (0xBC)
  78. #define EMAC_SAFX_H_REG3 (0xC0)
  79. /* PIO register */
  80. //#define PIO_BASE 0x01c20800
  81. #define PA_CFG0_REG (0x00)
  82. #define PA_CFG1_REG (0x04)
  83. #define PA_CFG2_REG (0x08)
  84. #define PA_DAT_REG (0x0c)
  85. #define PA_DRV0_REG (0x10)
  86. #define PA_DRV1_REG (0x14)
  87. #define PA_PULLUP0_REG (0x18)
  88. #define PA_PULLUP1_REG (0x1c)
  89. #define PB_CFG0_REG (0x20)
  90. #define PB_CFG1_REG (0x24)
  91. #define PB_CFG2_REG (0x28)
  92. #define PB_DAT_REG (0x2c)
  93. #define PB_DRV0_REG (0x30)
  94. #define PB_DRV1_REG (0x34)
  95. #define PB_PULLUP0_REG (0x38)
  96. #define PB_PULLUP1_REG (0x3c)
  97. #define PC_CFG0_REG (0x40)
  98. #define PC_CFG1_REG (0x44)
  99. #define PC_CFG2_REG (0x48)
  100. #define PC_DAT_REG (0x4c)
  101. #define PC_DRV0_REG (0x50)
  102. #define PC_DRV1_REG (0x54)
  103. #define PC_PULLUP0_REG (0x58)
  104. #define PC_PULLUP1_REG (0x5c)
  105. #define PD_CFG0_REG (0x60)
  106. #define PD_CFG1_REG (0x64)
  107. #define PD_CFG2_REG (0x68)
  108. #define PD_CFG3_REG (0x6c)
  109. #define PD_DAT_REG (0x70)
  110. #define PD_DRV0_REG (0x74)
  111. #define PD_DRV1_REG (0x78)
  112. #define PD_PULLUP0_REG (0x7c)
  113. #define PD_PULLUP1_REG (0x80)
  114. #define PE_CFG0_REG (0x84)
  115. #define PE_CFG1_REG (0x88)
  116. #define PE_DAT_REG (0x8c)
  117. #define PE_DRV_REG (0x90)
  118. #define PE_PULLUP_REG (0x94)
  119. #define PF_DRV_REG (0x98)
  120. #define PF_PULLUP_REG (0x9c)
  121. #define PD_INT_REG (0xa0)
  122. //CCM register
  123. #define CCM_BASE 0x01c20000
  124. #define CCM_AC320_MACC_REG (0x00)
  125. #define CCM_AUDIO_HOSC_REG (0x04)
  126. #define CCM_AHB_APB_REG (0x08)
  127. #define CCM_AHB_GATING_REG (0x0c)
  128. #define CCM_APB_GATING_REG (0x10)
  129. #define CCM_NFC_MS_REG (0x14)
  130. #define CCM_SD01_REG (0x18)
  131. #define CCM_SD23_REG (0x1c)
  132. #define CCM_DRAM_PLL_REG (0x20)
  133. #define CCM_DE_REG (0x24)
  134. #define CCM_LCD_MACC_REG (0x28)
  135. #define CCM_TV_CSI_REG (0x2c)
  136. #define CCM_VIDEO_PLL_REG (0x30)
  137. #define CCM_IR_CLK_REG (0x34)
  138. #define CCM_AUDIO_CLK_REG (0x38)
  139. #define CCM_TS_CLK_REG (0x3c)
  140. #define CCM_AVS_USB_CLK_REG (0x40)
  141. #define CCM_PID_CLK_REG (0xd0)
  142. #define CCM_WAKEUP_PENDING_REG (0xd4)
  143. //SRAMC register
  144. #define SRAMC_BASE 0x01c00000
  145. #define SRAMC_CFG_REG (0x04)
  146. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~registers define~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  147. //set up PHY
  148. #define PHY_AUTO_NEGOTIOATION 1 // 0: Normal 1: Auto(default)
  149. #define PHY_SPEED 1 // 0: 10M 1: 100M(default)
  150. #define EMAC_MAC_FULL 1 //0: Half duplex 1: Full duplex(default)
  151. //set up EMAC TX
  152. #define EMAC_TX_TM 0 //0: CPU 1: DMA(default)
  153. #define EMAC_TX_AB_M 1 //0: Disable 1: Aborted frame enable(default)
  154. //set up EMAC RX
  155. #define EMAC_RX_TM 0 //0: CPU 1: DMA(default)
  156. #define EMAC_RX_DRQ_MODE 0 //0: DRQ asserted 1: DRQ automatically(default)
  157. #define EMAC_RX_PA 0 //0: Normal(default) 1: Pass all Frames
  158. #define EMAC_RX_PCF 0 //0: Normal(default) 1: Pass Control Frames
  159. #define EMAC_RX_PCRCE 0 //0: Normal(default) 1: Pass Frames with CRC Error
  160. #define EMAC_RX_POR 1 //0: Normal 1: Pass Frames length out of range(default)
  161. #define EMAC_RX_PLE 0 //0: Normal(default) 1: Pass Frames with Length Error
  162. #define EMAC_RX_UCAD 1 //0: Not accept 1: Accept unicast Packets(default)
  163. #define EMAC_RX_DAF 1 //0: Normal(default) 1: DA Filtering
  164. #define EMAC_RX_MCO 1 //0: Not accept 1: Accept multicast Packets(default)
  165. #define EMAC_RX_MHF 0 //0: Disable(default) 1: Enable Hash filter
  166. #define EMAC_RX_BCO 1 //0: Not accept 1: Accept Broadcast Packets(default)
  167. #define EMAC_RX_SAF 0 //0: Disable(default) 1: Enable SA Filtering
  168. #define EMAC_RX_SAIF 0 //0: Normal(default) 1: Inverse Filtering
  169. //set up MAC
  170. #define EMAC_MAC_TFC 1 //0: Disable 1: Enable Transmit Flow Control(default)
  171. #define EMAC_MAC_RFC 1 //0: Disable 1: Enable Receive Flow Control(default)
  172. #define EMAC_MAC_FLC 1 //0: Disable 1: Enable MAC Frame Length Checking(default)
  173. #define EMAC_MAC_HF 0 //0: Disable(default) 1: Enable Huge Frame
  174. #define EMAC_MAC_DCRC 0 //0: Disable(default) 1: Enable MAC Delayed CRC
  175. #define EMAC_MAC_CRC 1 //0: Disable 1: Enable MAC CRC(default)
  176. #define EMAC_MAC_PC 1 //0: Disable 1: Enable MAC PAD Short frames(default)
  177. #define EMAC_MAC_VC 0 //0: Disable(default) 1: Enable MAC PAD Short frames and append CRC
  178. #define EMAC_MAC_ADP 0 //0: Disable(default) 1: Enable MAC auto detect Short frames
  179. #define EMAC_MAC_PRE 0 //0: Disable(default) 1: Enable
  180. #define EMAC_MAC_LPE 0 //0: Disable(default) 1: Enable
  181. #define EMAC_MAC_NB 0 //0: Disable(default) 1: Enable no back off
  182. #define EMAC_MAC_BNB 0 //0: Disable(default) 1: Enable
  183. #define EMAC_MAC_ED 0 //0: Disable(default) 1: Enable
  184. #if EMAC_MAC_FULL
  185. #define EMAC_MAC_IPGT 0x15
  186. #else
  187. #define EMAC_MAC_IPGT 0x12
  188. #endif
  189. #define EMAC_MAC_NBTB_IPG1 0xC
  190. #define EMAC_MAC_NBTB_IPG2 0x12
  191. #define EMAC_MAC_CW 0x37
  192. #define EMAC_MAC_RM 0xF
  193. #define EMAC_MAC_MFL 0x0600
  194. #define EMAC_MAP1
  195. //define receive status
  196. #define EMAC_CRCERR (1<<4)
  197. #define EMAC_LENERR (3<<5)
  198. #define WEMAC_PLATF_8BITONLY (0x0001)
  199. #define WEMAC_PLATF_16BITONLY (0x0002)
  200. #define WEMAC_PLATF_32BITONLY (0x0004)
  201. #define WEMAC_PLATF_EXT_PHY (0x0008)
  202. #define WEMAC_PLATF_NO_EEPROM (0x0010)
  203. #define WEMAC_PLATF_SIMPLE_PHY (0x0020) /* Use NSR to find LinkStatus */
  204. #define EMAC_EEPROM_MAGIC (0x444D394B)
  205. /* platfrom data for platfrom device structure's platfrom_data field */
  206. struct wemac_plat_data {
  207. unsigned int flags;
  208. unsigned char dev_addr[6];
  209. /* allow replacement IO routines */
  210. void (*inblk)(void __iomem *reg, void *data, int len);
  211. void (*outblk)(void __iomem *reg, void *data, int len);
  212. void (*dumpblk)(void __iomem *reg, int len);
  213. };
  214. #endif /* _WEMACX_H_ */