macb.h 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275
  1. /*
  2. * Copyright (C) 2005-2006 Atmel Corporation
  3. *
  4. * See file CREDITS for list of people who contributed to this
  5. * project.
  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. #ifndef __DRIVERS_MACB_H__
  23. #define __DRIVERS_MACB_H__
  24. /* MACB register offsets */
  25. #define MACB_NCR 0x0000
  26. #define MACB_NCFGR 0x0004
  27. #define MACB_NSR 0x0008
  28. #define MACB_TSR 0x0014
  29. #define MACB_RBQP 0x0018
  30. #define MACB_TBQP 0x001c
  31. #define MACB_RSR 0x0020
  32. #define MACB_ISR 0x0024
  33. #define MACB_IER 0x0028
  34. #define MACB_IDR 0x002c
  35. #define MACB_IMR 0x0030
  36. #define MACB_MAN 0x0034
  37. #define MACB_PTR 0x0038
  38. #define MACB_PFR 0x003c
  39. #define MACB_FTO 0x0040
  40. #define MACB_SCF 0x0044
  41. #define MACB_MCF 0x0048
  42. #define MACB_FRO 0x004c
  43. #define MACB_FCSE 0x0050
  44. #define MACB_ALE 0x0054
  45. #define MACB_DTF 0x0058
  46. #define MACB_LCOL 0x005c
  47. #define MACB_EXCOL 0x0060
  48. #define MACB_TUND 0x0064
  49. #define MACB_CSE 0x0068
  50. #define MACB_RRE 0x006c
  51. #define MACB_ROVR 0x0070
  52. #define MACB_RSE 0x0074
  53. #define MACB_ELE 0x0078
  54. #define MACB_RJA 0x007c
  55. #define MACB_USF 0x0080
  56. #define MACB_STE 0x0084
  57. #define MACB_RLE 0x0088
  58. #define MACB_TPF 0x008c
  59. #define MACB_HRB 0x0090
  60. #define MACB_HRT 0x0094
  61. #define MACB_SA1B 0x0098
  62. #define MACB_SA1T 0x009c
  63. #define MACB_SA2B 0x00a0
  64. #define MACB_SA2T 0x00a4
  65. #define MACB_SA3B 0x00a8
  66. #define MACB_SA3T 0x00ac
  67. #define MACB_SA4B 0x00b0
  68. #define MACB_SA4T 0x00b4
  69. #define MACB_TID 0x00b8
  70. #define MACB_TPQ 0x00bc
  71. #define MACB_USRIO 0x00c0
  72. #define MACB_WOL 0x00c4
  73. /* Bitfields in NCR */
  74. #define MACB_LB_OFFSET 0
  75. #define MACB_LB_SIZE 1
  76. #define MACB_LLB_OFFSET 1
  77. #define MACB_LLB_SIZE 1
  78. #define MACB_RE_OFFSET 2
  79. #define MACB_RE_SIZE 1
  80. #define MACB_TE_OFFSET 3
  81. #define MACB_TE_SIZE 1
  82. #define MACB_MPE_OFFSET 4
  83. #define MACB_MPE_SIZE 1
  84. #define MACB_CLRSTAT_OFFSET 5
  85. #define MACB_CLRSTAT_SIZE 1
  86. #define MACB_INCSTAT_OFFSET 6
  87. #define MACB_INCSTAT_SIZE 1
  88. #define MACB_WESTAT_OFFSET 7
  89. #define MACB_WESTAT_SIZE 1
  90. #define MACB_BP_OFFSET 8
  91. #define MACB_BP_SIZE 1
  92. #define MACB_TSTART_OFFSET 9
  93. #define MACB_TSTART_SIZE 1
  94. #define MACB_THALT_OFFSET 10
  95. #define MACB_THALT_SIZE 1
  96. #define MACB_NCR_TPF_OFFSET 11
  97. #define MACB_NCR_TPF_SIZE 1
  98. #define MACB_TZQ_OFFSET 12
  99. #define MACB_TZQ_SIZE 1
  100. /* Bitfields in NCFGR */
  101. #define MACB_SPD_OFFSET 0
  102. #define MACB_SPD_SIZE 1
  103. #define MACB_FD_OFFSET 1
  104. #define MACB_FD_SIZE 1
  105. #define MACB_BIT_RATE_OFFSET 2
  106. #define MACB_BIT_RATE_SIZE 1
  107. #define MACB_JFRAME_OFFSET 3
  108. #define MACB_JFRAME_SIZE 1
  109. #define MACB_CAF_OFFSET 4
  110. #define MACB_CAF_SIZE 1
  111. #define MACB_NBC_OFFSET 5
  112. #define MACB_NBC_SIZE 1
  113. #define MACB_NCFGR_MTI_OFFSET 6
  114. #define MACB_NCFGR_MTI_SIZE 1
  115. #define MACB_UNI_OFFSET 7
  116. #define MACB_UNI_SIZE 1
  117. #define MACB_BIG_OFFSET 8
  118. #define MACB_BIG_SIZE 1
  119. #define MACB_EAE_OFFSET 9
  120. #define MACB_EAE_SIZE 1
  121. #define MACB_CLK_OFFSET 10
  122. #define MACB_CLK_SIZE 2
  123. #define MACB_RTY_OFFSET 12
  124. #define MACB_RTY_SIZE 1
  125. #define MACB_PAE_OFFSET 13
  126. #define MACB_PAE_SIZE 1
  127. #define MACB_RBOF_OFFSET 14
  128. #define MACB_RBOF_SIZE 2
  129. #define MACB_RLCE_OFFSET 16
  130. #define MACB_RLCE_SIZE 1
  131. #define MACB_DRFCS_OFFSET 17
  132. #define MACB_DRFCS_SIZE 1
  133. #define MACB_EFRHD_OFFSET 18
  134. #define MACB_EFRHD_SIZE 1
  135. #define MACB_IRXFCS_OFFSET 19
  136. #define MACB_IRXFCS_SIZE 1
  137. /* Bitfields in NSR */
  138. #define MACB_NSR_LINK_OFFSET 0
  139. #define MACB_NSR_LINK_SIZE 1
  140. #define MACB_MDIO_OFFSET 1
  141. #define MACB_MDIO_SIZE 1
  142. #define MACB_IDLE_OFFSET 2
  143. #define MACB_IDLE_SIZE 1
  144. /* Bitfields in TSR */
  145. #define MACB_UBR_OFFSET 0
  146. #define MACB_UBR_SIZE 1
  147. #define MACB_COL_OFFSET 1
  148. #define MACB_COL_SIZE 1
  149. #define MACB_TSR_RLE_OFFSET 2
  150. #define MACB_TSR_RLE_SIZE 1
  151. #define MACB_TGO_OFFSET 3
  152. #define MACB_TGO_SIZE 1
  153. #define MACB_BEX_OFFSET 4
  154. #define MACB_BEX_SIZE 1
  155. #define MACB_COMP_OFFSET 5
  156. #define MACB_COMP_SIZE 1
  157. #define MACB_UND_OFFSET 6
  158. #define MACB_UND_SIZE 1
  159. /* Bitfields in RSR */
  160. #define MACB_BNA_OFFSET 0
  161. #define MACB_BNA_SIZE 1
  162. #define MACB_REC_OFFSET 1
  163. #define MACB_REC_SIZE 1
  164. #define MACB_OVR_OFFSET 2
  165. #define MACB_OVR_SIZE 1
  166. /* Bitfields in ISR/IER/IDR/IMR */
  167. #define MACB_MFD_OFFSET 0
  168. #define MACB_MFD_SIZE 1
  169. #define MACB_RCOMP_OFFSET 1
  170. #define MACB_RCOMP_SIZE 1
  171. #define MACB_RXUBR_OFFSET 2
  172. #define MACB_RXUBR_SIZE 1
  173. #define MACB_TXUBR_OFFSET 3
  174. #define MACB_TXUBR_SIZE 1
  175. #define MACB_ISR_TUND_OFFSET 4
  176. #define MACB_ISR_TUND_SIZE 1
  177. #define MACB_ISR_RLE_OFFSET 5
  178. #define MACB_ISR_RLE_SIZE 1
  179. #define MACB_TXERR_OFFSET 6
  180. #define MACB_TXERR_SIZE 1
  181. #define MACB_TCOMP_OFFSET 7
  182. #define MACB_TCOMP_SIZE 1
  183. #define MACB_ISR_LINK_OFFSET 9
  184. #define MACB_ISR_LINK_SIZE 1
  185. #define MACB_ISR_ROVR_OFFSET 10
  186. #define MACB_ISR_ROVR_SIZE 1
  187. #define MACB_HRESP_OFFSET 11
  188. #define MACB_HRESP_SIZE 1
  189. #define MACB_PFR_OFFSET 12
  190. #define MACB_PFR_SIZE 1
  191. #define MACB_PTZ_OFFSET 13
  192. #define MACB_PTZ_SIZE 1
  193. /* Bitfields in MAN */
  194. #define MACB_DATA_OFFSET 0
  195. #define MACB_DATA_SIZE 16
  196. #define MACB_CODE_OFFSET 16
  197. #define MACB_CODE_SIZE 2
  198. #define MACB_REGA_OFFSET 18
  199. #define MACB_REGA_SIZE 5
  200. #define MACB_PHYA_OFFSET 23
  201. #define MACB_PHYA_SIZE 5
  202. #define MACB_RW_OFFSET 28
  203. #define MACB_RW_SIZE 2
  204. #define MACB_SOF_OFFSET 30
  205. #define MACB_SOF_SIZE 2
  206. /* Bitfields in USRIO */
  207. #define MACB_MII_OFFSET 0
  208. #define MACB_MII_SIZE 1
  209. #define MACB_EAM_OFFSET 1
  210. #define MACB_EAM_SIZE 1
  211. #define MACB_TX_PAUSE_OFFSET 2
  212. #define MACB_TX_PAUSE_SIZE 1
  213. #define MACB_TX_PAUSE_ZERO_OFFSET 3
  214. #define MACB_TX_PAUSE_ZERO_SIZE 1
  215. /* Bitfields in USRIO (AT91) */
  216. #define MACB_RMII_OFFSET 0
  217. #define MACB_RMII_SIZE 1
  218. #define MACB_CLKEN_OFFSET 1
  219. #define MACB_CLKEN_SIZE 1
  220. /* Bitfields in WOL */
  221. #define MACB_IP_OFFSET 0
  222. #define MACB_IP_SIZE 16
  223. #define MACB_MAG_OFFSET 16
  224. #define MACB_MAG_SIZE 1
  225. #define MACB_ARP_OFFSET 17
  226. #define MACB_ARP_SIZE 1
  227. #define MACB_SA1_OFFSET 18
  228. #define MACB_SA1_SIZE 1
  229. #define MACB_WOL_MTI_OFFSET 19
  230. #define MACB_WOL_MTI_SIZE 1
  231. /* Constants for CLK */
  232. #define MACB_CLK_DIV8 0
  233. #define MACB_CLK_DIV16 1
  234. #define MACB_CLK_DIV32 2
  235. #define MACB_CLK_DIV64 3
  236. /* Constants for MAN register */
  237. #define MACB_MAN_SOF 1
  238. #define MACB_MAN_WRITE 1
  239. #define MACB_MAN_READ 2
  240. #define MACB_MAN_CODE 2
  241. /* Bit manipulation macros */
  242. #define MACB_BIT(name) \
  243. (1 << MACB_##name##_OFFSET)
  244. #define MACB_BF(name,value) \
  245. (((value) & ((1 << MACB_##name##_SIZE) - 1)) \
  246. << MACB_##name##_OFFSET)
  247. #define MACB_BFEXT(name,value)\
  248. (((value) >> MACB_##name##_OFFSET) \
  249. & ((1 << MACB_##name##_SIZE) - 1))
  250. #define MACB_BFINS(name,value,old) \
  251. (((old) & ~(((1 << MACB_##name##_SIZE) - 1) \
  252. << MACB_##name##_OFFSET)) \
  253. | MACB_BF(name,value))
  254. /* Register access macros */
  255. #define macb_readl(port,reg) \
  256. readl((port)->regs + MACB_##reg)
  257. #define macb_writel(port,reg,value) \
  258. writel((value), (port)->regs + MACB_##reg)
  259. #endif /* __DRIVERS_MACB_H__ */