macb.h 8.5 KB

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