macb.h 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772
  1. /* SPDX-License-Identifier: GPL-2.0+ */
  2. /*
  3. * Copyright (C) 2005-2006 Atmel Corporation
  4. */
  5. #ifndef __DRIVERS_MACB_H__
  6. #define __DRIVERS_MACB_H__
  7. #define MACB_GREGS_NBR 16
  8. #define MACB_GREGS_VERSION 2
  9. #define MACB_MAX_QUEUES 8
  10. /* MACB register offsets */
  11. #define MACB_NCR 0x0000 /* Network Control */
  12. #define MACB_NCFGR 0x0004 /* Network Config */
  13. #define MACB_NSR 0x0008 /* Network Status */
  14. #define MACB_TAR 0x000c /* AT91RM9200 only */
  15. #define MACB_TCR 0x0010 /* AT91RM9200 only */
  16. #define MACB_TSR 0x0014 /* Transmit Status */
  17. #define MACB_RBQP 0x0018 /* RX Q Base Address */
  18. #define MACB_TBQP 0x001c /* TX Q Base Address */
  19. #define MACB_RSR 0x0020 /* Receive Status */
  20. #define MACB_ISR 0x0024 /* Interrupt Status */
  21. #define MACB_IER 0x0028 /* Interrupt Enable */
  22. #define MACB_IDR 0x002c /* Interrupt Disable */
  23. #define MACB_IMR 0x0030 /* Interrupt Mask */
  24. #define MACB_MAN 0x0034 /* PHY Maintenance */
  25. #define MACB_PTR 0x0038
  26. #define MACB_PFR 0x003c
  27. #define MACB_FTO 0x0040
  28. #define MACB_SCF 0x0044
  29. #define MACB_MCF 0x0048
  30. #define MACB_FRO 0x004c
  31. #define MACB_FCSE 0x0050
  32. #define MACB_ALE 0x0054
  33. #define MACB_DTF 0x0058
  34. #define MACB_LCOL 0x005c
  35. #define MACB_EXCOL 0x0060
  36. #define MACB_TUND 0x0064
  37. #define MACB_CSE 0x0068
  38. #define MACB_RRE 0x006c
  39. #define MACB_ROVR 0x0070
  40. #define MACB_RSE 0x0074
  41. #define MACB_ELE 0x0078
  42. #define MACB_RJA 0x007c
  43. #define MACB_USF 0x0080
  44. #define MACB_STE 0x0084
  45. #define MACB_RLE 0x0088
  46. #define MACB_TPF 0x008c
  47. #define MACB_HRB 0x0090
  48. #define MACB_HRT 0x0094
  49. #define MACB_SA1B 0x0098
  50. #define MACB_SA1T 0x009c
  51. #define MACB_SA2B 0x00a0
  52. #define MACB_SA2T 0x00a4
  53. #define MACB_SA3B 0x00a8
  54. #define MACB_SA3T 0x00ac
  55. #define MACB_SA4B 0x00b0
  56. #define MACB_SA4T 0x00b4
  57. #define MACB_TID 0x00b8
  58. #define MACB_TPQ 0x00bc
  59. #define MACB_USRIO 0x00c0
  60. #define MACB_WOL 0x00c4
  61. #define MACB_MID 0x00fc
  62. #define MACB_TBQPH 0x04C8
  63. #define MACB_RBQPH 0x04D4
  64. /* GEM register offsets. */
  65. #define GEM_NCFGR 0x0004 /* Network Config */
  66. #define GEM_USRIO 0x000c /* User IO */
  67. #define GEM_DMACFG 0x0010 /* DMA Configuration */
  68. #define GEM_JML 0x0048 /* Jumbo Max Length */
  69. #define GEM_HRB 0x0080 /* Hash Bottom */
  70. #define GEM_HRT 0x0084 /* Hash Top */
  71. #define GEM_SA1B 0x0088 /* Specific1 Bottom */
  72. #define GEM_SA1T 0x008C /* Specific1 Top */
  73. #define GEM_SA2B 0x0090 /* Specific2 Bottom */
  74. #define GEM_SA2T 0x0094 /* Specific2 Top */
  75. #define GEM_SA3B 0x0098 /* Specific3 Bottom */
  76. #define GEM_SA3T 0x009C /* Specific3 Top */
  77. #define GEM_SA4B 0x00A0 /* Specific4 Bottom */
  78. #define GEM_SA4T 0x00A4 /* Specific4 Top */
  79. #define GEM_EFTSH 0x00e8 /* PTP Event Frame Transmitted Seconds Register 47:32 */
  80. #define GEM_EFRSH 0x00ec /* PTP Event Frame Received Seconds Register 47:32 */
  81. #define GEM_PEFTSH 0x00f0 /* PTP Peer Event Frame Transmitted Seconds Register 47:32 */
  82. #define GEM_PEFRSH 0x00f4 /* PTP Peer Event Frame Received Seconds Register 47:32 */
  83. #define GEM_OTX 0x0100 /* Octets transmitted */
  84. #define GEM_OCTTXL 0x0100 /* Octets transmitted [31:0] */
  85. #define GEM_OCTTXH 0x0104 /* Octets transmitted [47:32] */
  86. #define GEM_TXCNT 0x0108 /* Frames Transmitted counter */
  87. #define GEM_TXBCCNT 0x010c /* Broadcast Frames counter */
  88. #define GEM_TXMCCNT 0x0110 /* Multicast Frames counter */
  89. #define GEM_TXPAUSECNT 0x0114 /* Pause Frames Transmitted Counter */
  90. #define GEM_TX64CNT 0x0118 /* 64 byte Frames TX counter */
  91. #define GEM_TX65CNT 0x011c /* 65-127 byte Frames TX counter */
  92. #define GEM_TX128CNT 0x0120 /* 128-255 byte Frames TX counter */
  93. #define GEM_TX256CNT 0x0124 /* 256-511 byte Frames TX counter */
  94. #define GEM_TX512CNT 0x0128 /* 512-1023 byte Frames TX counter */
  95. #define GEM_TX1024CNT 0x012c /* 1024-1518 byte Frames TX counter */
  96. #define GEM_TX1519CNT 0x0130 /* 1519+ byte Frames TX counter */
  97. #define GEM_TXURUNCNT 0x0134 /* TX under run error counter */
  98. #define GEM_SNGLCOLLCNT 0x0138 /* Single Collision Frame Counter */
  99. #define GEM_MULTICOLLCNT 0x013c /* Multiple Collision Frame Counter */
  100. #define GEM_EXCESSCOLLCNT 0x0140 /* Excessive Collision Frame Counter */
  101. #define GEM_LATECOLLCNT 0x0144 /* Late Collision Frame Counter */
  102. #define GEM_TXDEFERCNT 0x0148 /* Deferred Transmission Frame Counter */
  103. #define GEM_TXCSENSECNT 0x014c /* Carrier Sense Error Counter */
  104. #define GEM_ORX 0x0150 /* Octets received */
  105. #define GEM_OCTRXL 0x0150 /* Octets received [31:0] */
  106. #define GEM_OCTRXH 0x0154 /* Octets received [47:32] */
  107. #define GEM_RXCNT 0x0158 /* Frames Received Counter */
  108. #define GEM_RXBROADCNT 0x015c /* Broadcast Frames Received Counter */
  109. #define GEM_RXMULTICNT 0x0160 /* Multicast Frames Received Counter */
  110. #define GEM_RXPAUSECNT 0x0164 /* Pause Frames Received Counter */
  111. #define GEM_RX64CNT 0x0168 /* 64 byte Frames RX Counter */
  112. #define GEM_RX65CNT 0x016c /* 65-127 byte Frames RX Counter */
  113. #define GEM_RX128CNT 0x0170 /* 128-255 byte Frames RX Counter */
  114. #define GEM_RX256CNT 0x0174 /* 256-511 byte Frames RX Counter */
  115. #define GEM_RX512CNT 0x0178 /* 512-1023 byte Frames RX Counter */
  116. #define GEM_RX1024CNT 0x017c /* 1024-1518 byte Frames RX Counter */
  117. #define GEM_RX1519CNT 0x0180 /* 1519+ byte Frames RX Counter */
  118. #define GEM_RXUNDRCNT 0x0184 /* Undersize Frames Received Counter */
  119. #define GEM_RXOVRCNT 0x0188 /* Oversize Frames Received Counter */
  120. #define GEM_RXJABCNT 0x018c /* Jabbers Received Counter */
  121. #define GEM_RXFCSCNT 0x0190 /* Frame Check Sequence Error Counter */
  122. #define GEM_RXLENGTHCNT 0x0194 /* Length Field Error Counter */
  123. #define GEM_RXSYMBCNT 0x0198 /* Symbol Error Counter */
  124. #define GEM_RXALIGNCNT 0x019c /* Alignment Error Counter */
  125. #define GEM_RXRESERRCNT 0x01a0 /* Receive Resource Error Counter */
  126. #define GEM_RXORCNT 0x01a4 /* Receive Overrun Counter */
  127. #define GEM_RXIPCCNT 0x01a8 /* IP header Checksum Error Counter */
  128. #define GEM_RXTCPCCNT 0x01ac /* TCP Checksum Error Counter */
  129. #define GEM_RXUDPCCNT 0x01b0 /* UDP Checksum Error Counter */
  130. #define GEM_TISUBN 0x01bc /* 1588 Timer Increment Sub-ns */
  131. #define GEM_TSH 0x01c0 /* 1588 Timer Seconds High */
  132. #define GEM_TSL 0x01d0 /* 1588 Timer Seconds Low */
  133. #define GEM_TN 0x01d4 /* 1588 Timer Nanoseconds */
  134. #define GEM_TA 0x01d8 /* 1588 Timer Adjust */
  135. #define GEM_TI 0x01dc /* 1588 Timer Increment */
  136. #define GEM_EFTSL 0x01e0 /* PTP Event Frame Tx Seconds Low */
  137. #define GEM_EFTN 0x01e4 /* PTP Event Frame Tx Nanoseconds */
  138. #define GEM_EFRSL 0x01e8 /* PTP Event Frame Rx Seconds Low */
  139. #define GEM_EFRN 0x01ec /* PTP Event Frame Rx Nanoseconds */
  140. #define GEM_PEFTSL 0x01f0 /* PTP Peer Event Frame Tx Secs Low */
  141. #define GEM_PEFTN 0x01f4 /* PTP Peer Event Frame Tx Ns */
  142. #define GEM_PEFRSL 0x01f8 /* PTP Peer Event Frame Rx Sec Low */
  143. #define GEM_PEFRN 0x01fc /* PTP Peer Event Frame Rx Ns */
  144. #define GEM_DCFG1 0x0280 /* Design Config 1 */
  145. #define GEM_DCFG2 0x0284 /* Design Config 2 */
  146. #define GEM_DCFG3 0x0288 /* Design Config 3 */
  147. #define GEM_DCFG4 0x028c /* Design Config 4 */
  148. #define GEM_DCFG5 0x0290 /* Design Config 5 */
  149. #define GEM_DCFG6 0x0294 /* Design Config 6 */
  150. #define GEM_DCFG7 0x0298 /* Design Config 7 */
  151. #define GEM_DCFG8 0x029C /* Design Config 8 */
  152. #define GEM_DCFG10 0x02A4 /* Design Config 10 */
  153. #define GEM_TXBDCTRL 0x04cc /* TX Buffer Descriptor control register */
  154. #define GEM_RXBDCTRL 0x04d0 /* RX Buffer Descriptor control register */
  155. /* Screener Type 2 match registers */
  156. #define GEM_SCRT2 0x540
  157. /* EtherType registers */
  158. #define GEM_ETHT 0x06E0
  159. /* Type 2 compare registers */
  160. #define GEM_T2CMPW0 0x0700
  161. #define GEM_T2CMPW1 0x0704
  162. #define T2CMP_OFST(t2idx) (t2idx * 2)
  163. /* type 2 compare registers
  164. * each location requires 3 compare regs
  165. */
  166. #define GEM_IP4SRC_CMP(idx) (idx * 3)
  167. #define GEM_IP4DST_CMP(idx) (idx * 3 + 1)
  168. #define GEM_PORT_CMP(idx) (idx * 3 + 2)
  169. /* Which screening type 2 EtherType register will be used (0 - 7) */
  170. #define SCRT2_ETHT 0
  171. #define GEM_ISR(hw_q) (0x0400 + ((hw_q) << 2))
  172. #define GEM_TBQP(hw_q) (0x0440 + ((hw_q) << 2))
  173. #define GEM_TBQPH(hw_q) (0x04C8)
  174. #define GEM_RBQP(hw_q) (0x0480 + ((hw_q) << 2))
  175. #define GEM_RBQS(hw_q) (0x04A0 + ((hw_q) << 2))
  176. #define GEM_RBQPH(hw_q) (0x04D4)
  177. #define GEM_IER(hw_q) (0x0600 + ((hw_q) << 2))
  178. #define GEM_IDR(hw_q) (0x0620 + ((hw_q) << 2))
  179. #define GEM_IMR(hw_q) (0x0640 + ((hw_q) << 2))
  180. /* Bitfields in NCR */
  181. #define MACB_LB_OFFSET 0 /* reserved */
  182. #define MACB_LB_SIZE 1
  183. #define MACB_LLB_OFFSET 1 /* Loop back local */
  184. #define MACB_LLB_SIZE 1
  185. #define MACB_RE_OFFSET 2 /* Receive enable */
  186. #define MACB_RE_SIZE 1
  187. #define MACB_TE_OFFSET 3 /* Transmit enable */
  188. #define MACB_TE_SIZE 1
  189. #define MACB_MPE_OFFSET 4 /* Management port enable */
  190. #define MACB_MPE_SIZE 1
  191. #define MACB_CLRSTAT_OFFSET 5 /* Clear stats regs */
  192. #define MACB_CLRSTAT_SIZE 1
  193. #define MACB_INCSTAT_OFFSET 6 /* Incremental stats regs */
  194. #define MACB_INCSTAT_SIZE 1
  195. #define MACB_WESTAT_OFFSET 7 /* Write enable stats regs */
  196. #define MACB_WESTAT_SIZE 1
  197. #define MACB_BP_OFFSET 8 /* Back pressure */
  198. #define MACB_BP_SIZE 1
  199. #define MACB_TSTART_OFFSET 9 /* Start transmission */
  200. #define MACB_TSTART_SIZE 1
  201. #define MACB_THALT_OFFSET 10 /* Transmit halt */
  202. #define MACB_THALT_SIZE 1
  203. #define MACB_NCR_TPF_OFFSET 11 /* Transmit pause frame */
  204. #define MACB_NCR_TPF_SIZE 1
  205. #define MACB_TZQ_OFFSET 12 /* Transmit zero quantum pause frame */
  206. #define MACB_TZQ_SIZE 1
  207. #define MACB_SRTSM_OFFSET 15
  208. #define MACB_OSSMODE_OFFSET 24 /* Enable One Step Synchro Mode */
  209. #define MACB_OSSMODE_SIZE 1
  210. /* Bitfields in NCFGR */
  211. #define MACB_SPD_OFFSET 0 /* Speed */
  212. #define MACB_SPD_SIZE 1
  213. #define MACB_FD_OFFSET 1 /* Full duplex */
  214. #define MACB_FD_SIZE 1
  215. #define MACB_BIT_RATE_OFFSET 2 /* Discard non-VLAN frames */
  216. #define MACB_BIT_RATE_SIZE 1
  217. #define MACB_JFRAME_OFFSET 3 /* reserved */
  218. #define MACB_JFRAME_SIZE 1
  219. #define MACB_CAF_OFFSET 4 /* Copy all frames */
  220. #define MACB_CAF_SIZE 1
  221. #define MACB_NBC_OFFSET 5 /* No broadcast */
  222. #define MACB_NBC_SIZE 1
  223. #define MACB_NCFGR_MTI_OFFSET 6 /* Multicast hash enable */
  224. #define MACB_NCFGR_MTI_SIZE 1
  225. #define MACB_UNI_OFFSET 7 /* Unicast hash enable */
  226. #define MACB_UNI_SIZE 1
  227. #define MACB_BIG_OFFSET 8 /* Receive 1536 byte frames */
  228. #define MACB_BIG_SIZE 1
  229. #define MACB_EAE_OFFSET 9 /* External address match enable */
  230. #define MACB_EAE_SIZE 1
  231. #define MACB_CLK_OFFSET 10
  232. #define MACB_CLK_SIZE 2
  233. #define MACB_RTY_OFFSET 12 /* Retry test */
  234. #define MACB_RTY_SIZE 1
  235. #define MACB_PAE_OFFSET 13 /* Pause enable */
  236. #define MACB_PAE_SIZE 1
  237. #define MACB_RM9200_RMII_OFFSET 13 /* AT91RM9200 only */
  238. #define MACB_RM9200_RMII_SIZE 1 /* AT91RM9200 only */
  239. #define MACB_RBOF_OFFSET 14 /* Receive buffer offset */
  240. #define MACB_RBOF_SIZE 2
  241. #define MACB_RLCE_OFFSET 16 /* Length field error frame discard */
  242. #define MACB_RLCE_SIZE 1
  243. #define MACB_DRFCS_OFFSET 17 /* FCS remove */
  244. #define MACB_DRFCS_SIZE 1
  245. #define MACB_EFRHD_OFFSET 18
  246. #define MACB_EFRHD_SIZE 1
  247. #define MACB_IRXFCS_OFFSET 19
  248. #define MACB_IRXFCS_SIZE 1
  249. /* GEM specific NCFGR bitfields. */
  250. #define GEM_GBE_OFFSET 10 /* Gigabit mode enable */
  251. #define GEM_GBE_SIZE 1
  252. #define GEM_PCSSEL_OFFSET 11
  253. #define GEM_PCSSEL_SIZE 1
  254. #define GEM_CLK_OFFSET 18 /* MDC clock division */
  255. #define GEM_CLK_SIZE 3
  256. #define GEM_DBW_OFFSET 21 /* Data bus width */
  257. #define GEM_DBW_SIZE 2
  258. #define GEM_RXCOEN_OFFSET 24
  259. #define GEM_RXCOEN_SIZE 1
  260. #define GEM_SGMIIEN_OFFSET 27
  261. #define GEM_SGMIIEN_SIZE 1
  262. /* Constants for data bus width. */
  263. #define GEM_DBW32 0 /* 32 bit AMBA AHB data bus width */
  264. #define GEM_DBW64 1 /* 64 bit AMBA AHB data bus width */
  265. #define GEM_DBW128 2 /* 128 bit AMBA AHB data bus width */
  266. /* Bitfields in DMACFG. */
  267. #define GEM_FBLDO_OFFSET 0 /* fixed burst length for DMA */
  268. #define GEM_FBLDO_SIZE 5
  269. #define GEM_ENDIA_DESC_OFFSET 6 /* endian swap mode for management descriptor access */
  270. #define GEM_ENDIA_DESC_SIZE 1
  271. #define GEM_ENDIA_PKT_OFFSET 7 /* endian swap mode for packet data access */
  272. #define GEM_ENDIA_PKT_SIZE 1
  273. #define GEM_RXBMS_OFFSET 8 /* RX packet buffer memory size select */
  274. #define GEM_RXBMS_SIZE 2
  275. #define GEM_TXPBMS_OFFSET 10 /* TX packet buffer memory size select */
  276. #define GEM_TXPBMS_SIZE 1
  277. #define GEM_TXCOEN_OFFSET 11 /* TX IP/TCP/UDP checksum gen offload */
  278. #define GEM_TXCOEN_SIZE 1
  279. #define GEM_RXBS_OFFSET 16 /* DMA receive buffer size */
  280. #define GEM_RXBS_SIZE 8
  281. #define GEM_DDRP_OFFSET 24 /* disc_when_no_ahb */
  282. #define GEM_DDRP_SIZE 1
  283. #define GEM_RXEXT_OFFSET 28 /* RX extended Buffer Descriptor mode */
  284. #define GEM_RXEXT_SIZE 1
  285. #define GEM_TXEXT_OFFSET 29 /* TX extended Buffer Descriptor mode */
  286. #define GEM_TXEXT_SIZE 1
  287. #define GEM_ADDR64_OFFSET 30 /* Address bus width - 64b or 32b */
  288. #define GEM_ADDR64_SIZE 1
  289. /* Bitfields in NSR */
  290. #define MACB_NSR_LINK_OFFSET 0 /* pcs_link_state */
  291. #define MACB_NSR_LINK_SIZE 1
  292. #define MACB_MDIO_OFFSET 1 /* status of the mdio_in pin */
  293. #define MACB_MDIO_SIZE 1
  294. #define MACB_IDLE_OFFSET 2 /* The PHY management logic is idle */
  295. #define MACB_IDLE_SIZE 1
  296. /* Bitfields in TSR */
  297. #define MACB_UBR_OFFSET 0 /* Used bit read */
  298. #define MACB_UBR_SIZE 1
  299. #define MACB_COL_OFFSET 1 /* Collision occurred */
  300. #define MACB_COL_SIZE 1
  301. #define MACB_TSR_RLE_OFFSET 2 /* Retry limit exceeded */
  302. #define MACB_TSR_RLE_SIZE 1
  303. #define MACB_TGO_OFFSET 3 /* Transmit go */
  304. #define MACB_TGO_SIZE 1
  305. #define MACB_BEX_OFFSET 4 /* TX frame corruption due to AHB error */
  306. #define MACB_BEX_SIZE 1
  307. #define MACB_RM9200_BNQ_OFFSET 4 /* AT91RM9200 only */
  308. #define MACB_RM9200_BNQ_SIZE 1 /* AT91RM9200 only */
  309. #define MACB_COMP_OFFSET 5 /* Trnasmit complete */
  310. #define MACB_COMP_SIZE 1
  311. #define MACB_UND_OFFSET 6 /* Trnasmit under run */
  312. #define MACB_UND_SIZE 1
  313. /* Bitfields in RSR */
  314. #define MACB_BNA_OFFSET 0 /* Buffer not available */
  315. #define MACB_BNA_SIZE 1
  316. #define MACB_REC_OFFSET 1 /* Frame received */
  317. #define MACB_REC_SIZE 1
  318. #define MACB_OVR_OFFSET 2 /* Receive overrun */
  319. #define MACB_OVR_SIZE 1
  320. /* Bitfields in ISR/IER/IDR/IMR */
  321. #define MACB_MFD_OFFSET 0 /* Management frame sent */
  322. #define MACB_MFD_SIZE 1
  323. #define MACB_RCOMP_OFFSET 1 /* Receive complete */
  324. #define MACB_RCOMP_SIZE 1
  325. #define MACB_RXUBR_OFFSET 2 /* RX used bit read */
  326. #define MACB_RXUBR_SIZE 1
  327. #define MACB_TXUBR_OFFSET 3 /* TX used bit read */
  328. #define MACB_TXUBR_SIZE 1
  329. #define MACB_ISR_TUND_OFFSET 4 /* Enable TX buffer under run interrupt */
  330. #define MACB_ISR_TUND_SIZE 1
  331. #define MACB_ISR_RLE_OFFSET 5 /* EN retry exceeded/late coll interrupt */
  332. #define MACB_ISR_RLE_SIZE 1
  333. #define MACB_TXERR_OFFSET 6 /* EN TX frame corrupt from error interrupt */
  334. #define MACB_TXERR_SIZE 1
  335. #define MACB_TCOMP_OFFSET 7 /* Enable transmit complete interrupt */
  336. #define MACB_TCOMP_SIZE 1
  337. #define MACB_ISR_LINK_OFFSET 9 /* Enable link change interrupt */
  338. #define MACB_ISR_LINK_SIZE 1
  339. #define MACB_ISR_ROVR_OFFSET 10 /* Enable receive overrun interrupt */
  340. #define MACB_ISR_ROVR_SIZE 1
  341. #define MACB_HRESP_OFFSET 11 /* Enable hrsep not OK interrupt */
  342. #define MACB_HRESP_SIZE 1
  343. #define MACB_PFR_OFFSET 12 /* Enable pause frame w/ quantum interrupt */
  344. #define MACB_PFR_SIZE 1
  345. #define MACB_PTZ_OFFSET 13 /* Enable pause time zero interrupt */
  346. #define MACB_PTZ_SIZE 1
  347. #define MACB_WOL_OFFSET 14 /* Enable wake-on-lan interrupt */
  348. #define MACB_WOL_SIZE 1
  349. #define MACB_DRQFR_OFFSET 18 /* PTP Delay Request Frame Received */
  350. #define MACB_DRQFR_SIZE 1
  351. #define MACB_SFR_OFFSET 19 /* PTP Sync Frame Received */
  352. #define MACB_SFR_SIZE 1
  353. #define MACB_DRQFT_OFFSET 20 /* PTP Delay Request Frame Transmitted */
  354. #define MACB_DRQFT_SIZE 1
  355. #define MACB_SFT_OFFSET 21 /* PTP Sync Frame Transmitted */
  356. #define MACB_SFT_SIZE 1
  357. #define MACB_PDRQFR_OFFSET 22 /* PDelay Request Frame Received */
  358. #define MACB_PDRQFR_SIZE 1
  359. #define MACB_PDRSFR_OFFSET 23 /* PDelay Response Frame Received */
  360. #define MACB_PDRSFR_SIZE 1
  361. #define MACB_PDRQFT_OFFSET 24 /* PDelay Request Frame Transmitted */
  362. #define MACB_PDRQFT_SIZE 1
  363. #define MACB_PDRSFT_OFFSET 25 /* PDelay Response Frame Transmitted */
  364. #define MACB_PDRSFT_SIZE 1
  365. #define MACB_SRI_OFFSET 26 /* TSU Seconds Register Increment */
  366. #define MACB_SRI_SIZE 1
  367. /* Timer increment fields */
  368. #define MACB_TI_CNS_OFFSET 0
  369. #define MACB_TI_CNS_SIZE 8
  370. #define MACB_TI_ACNS_OFFSET 8
  371. #define MACB_TI_ACNS_SIZE 8
  372. #define MACB_TI_NIT_OFFSET 16
  373. #define MACB_TI_NIT_SIZE 8
  374. /* Bitfields in MAN */
  375. #define MACB_DATA_OFFSET 0 /* data */
  376. #define MACB_DATA_SIZE 16
  377. #define MACB_CODE_OFFSET 16 /* Must be written to 10 */
  378. #define MACB_CODE_SIZE 2
  379. #define MACB_REGA_OFFSET 18 /* Register address */
  380. #define MACB_REGA_SIZE 5
  381. #define MACB_PHYA_OFFSET 23 /* PHY address */
  382. #define MACB_PHYA_SIZE 5
  383. #define MACB_RW_OFFSET 28 /* Operation. 10 is read. 01 is write. */
  384. #define MACB_RW_SIZE 2
  385. #define MACB_SOF_OFFSET 30 /* Must be written to 1 for Clause 22 */
  386. #define MACB_SOF_SIZE 2
  387. /* Bitfields in USRIO (AVR32) */
  388. #define MACB_MII_OFFSET 0
  389. #define MACB_MII_SIZE 1
  390. #define MACB_EAM_OFFSET 1
  391. #define MACB_EAM_SIZE 1
  392. #define MACB_TX_PAUSE_OFFSET 2
  393. #define MACB_TX_PAUSE_SIZE 1
  394. #define MACB_TX_PAUSE_ZERO_OFFSET 3
  395. #define MACB_TX_PAUSE_ZERO_SIZE 1
  396. /* Bitfields in USRIO (AT91) */
  397. #define MACB_RMII_OFFSET 0
  398. #define MACB_RMII_SIZE 1
  399. #define GEM_RGMII_OFFSET 0 /* GEM gigabit mode */
  400. #define GEM_RGMII_SIZE 1
  401. #define MACB_CLKEN_OFFSET 1
  402. #define MACB_CLKEN_SIZE 1
  403. /* Bitfields in WOL */
  404. #define MACB_IP_OFFSET 0
  405. #define MACB_IP_SIZE 16
  406. #define MACB_MAG_OFFSET 16
  407. #define MACB_MAG_SIZE 1
  408. #define MACB_ARP_OFFSET 17
  409. #define MACB_ARP_SIZE 1
  410. #define MACB_SA1_OFFSET 18
  411. #define MACB_SA1_SIZE 1
  412. #define MACB_WOL_MTI_OFFSET 19
  413. #define MACB_WOL_MTI_SIZE 1
  414. /* Bitfields in MID */
  415. #define MACB_IDNUM_OFFSET 16
  416. #define MACB_IDNUM_SIZE 12
  417. #define MACB_REV_OFFSET 0
  418. #define MACB_REV_SIZE 16
  419. /* Bitfields in DCFG1. */
  420. #define GEM_IRQCOR_OFFSET 23
  421. #define GEM_IRQCOR_SIZE 1
  422. #define GEM_DBWDEF_OFFSET 25
  423. #define GEM_DBWDEF_SIZE 3
  424. /* Bitfields in DCFG2. */
  425. #define GEM_RX_PKT_BUFF_OFFSET 20
  426. #define GEM_RX_PKT_BUFF_SIZE 1
  427. #define GEM_TX_PKT_BUFF_OFFSET 21
  428. #define GEM_TX_PKT_BUFF_SIZE 1
  429. /* Bitfields in DCFG5. */
  430. #define GEM_TSU_OFFSET 8
  431. #define GEM_TSU_SIZE 1
  432. /* Bitfields in DCFG6. */
  433. #define GEM_PBUF_LSO_OFFSET 27
  434. #define GEM_PBUF_LSO_SIZE 1
  435. #define GEM_DAW64_OFFSET 23
  436. #define GEM_DAW64_SIZE 1
  437. /* Bitfields in DCFG8. */
  438. #define GEM_T1SCR_OFFSET 24
  439. #define GEM_T1SCR_SIZE 8
  440. #define GEM_T2SCR_OFFSET 16
  441. #define GEM_T2SCR_SIZE 8
  442. #define GEM_SCR2ETH_OFFSET 8
  443. #define GEM_SCR2ETH_SIZE 8
  444. #define GEM_SCR2CMP_OFFSET 0
  445. #define GEM_SCR2CMP_SIZE 8
  446. /* Bitfields in DCFG10 */
  447. #define GEM_TXBD_RDBUFF_OFFSET 12
  448. #define GEM_TXBD_RDBUFF_SIZE 4
  449. #define GEM_RXBD_RDBUFF_OFFSET 8
  450. #define GEM_RXBD_RDBUFF_SIZE 4
  451. /* Bitfields in TISUBN */
  452. #define GEM_SUBNSINCR_OFFSET 0
  453. #define GEM_SUBNSINCR_SIZE 16
  454. /* Bitfields in TI */
  455. #define GEM_NSINCR_OFFSET 0
  456. #define GEM_NSINCR_SIZE 8
  457. /* Bitfields in TSH */
  458. #define GEM_TSH_OFFSET 0 /* TSU timer value (s). MSB [47:32] of seconds timer count */
  459. #define GEM_TSH_SIZE 16
  460. /* Bitfields in TSL */
  461. #define GEM_TSL_OFFSET 0 /* TSU timer value (s). LSB [31:0] of seconds timer count */
  462. #define GEM_TSL_SIZE 32
  463. /* Bitfields in TN */
  464. #define GEM_TN_OFFSET 0 /* TSU timer value (ns) */
  465. #define GEM_TN_SIZE 30
  466. /* Bitfields in TXBDCTRL */
  467. #define GEM_TXTSMODE_OFFSET 4 /* TX Descriptor Timestamp Insertion mode */
  468. #define GEM_TXTSMODE_SIZE 2
  469. /* Bitfields in RXBDCTRL */
  470. #define GEM_RXTSMODE_OFFSET 4 /* RX Descriptor Timestamp Insertion mode */
  471. #define GEM_RXTSMODE_SIZE 2
  472. /* Bitfields in SCRT2 */
  473. #define GEM_QUEUE_OFFSET 0 /* Queue Number */
  474. #define GEM_QUEUE_SIZE 4
  475. #define GEM_VLANPR_OFFSET 4 /* VLAN Priority */
  476. #define GEM_VLANPR_SIZE 3
  477. #define GEM_VLANEN_OFFSET 8 /* VLAN Enable */
  478. #define GEM_VLANEN_SIZE 1
  479. #define GEM_ETHT2IDX_OFFSET 9 /* Index to screener type 2 EtherType register */
  480. #define GEM_ETHT2IDX_SIZE 3
  481. #define GEM_ETHTEN_OFFSET 12 /* EtherType Enable */
  482. #define GEM_ETHTEN_SIZE 1
  483. #define GEM_CMPA_OFFSET 13 /* Compare A - Index to screener type 2 Compare register */
  484. #define GEM_CMPA_SIZE 5
  485. #define GEM_CMPAEN_OFFSET 18 /* Compare A Enable */
  486. #define GEM_CMPAEN_SIZE 1
  487. #define GEM_CMPB_OFFSET 19 /* Compare B - Index to screener type 2 Compare register */
  488. #define GEM_CMPB_SIZE 5
  489. #define GEM_CMPBEN_OFFSET 24 /* Compare B Enable */
  490. #define GEM_CMPBEN_SIZE 1
  491. #define GEM_CMPC_OFFSET 25 /* Compare C - Index to screener type 2 Compare register */
  492. #define GEM_CMPC_SIZE 5
  493. #define GEM_CMPCEN_OFFSET 30 /* Compare C Enable */
  494. #define GEM_CMPCEN_SIZE 1
  495. /* Bitfields in ETHT */
  496. #define GEM_ETHTCMP_OFFSET 0 /* EtherType compare value */
  497. #define GEM_ETHTCMP_SIZE 16
  498. /* Bitfields in T2CMPW0 */
  499. #define GEM_T2CMP_OFFSET 16 /* 0xFFFF0000 compare value */
  500. #define GEM_T2CMP_SIZE 16
  501. #define GEM_T2MASK_OFFSET 0 /* 0x0000FFFF compare value or mask */
  502. #define GEM_T2MASK_SIZE 16
  503. /* Bitfields in T2CMPW1 */
  504. #define GEM_T2DISMSK_OFFSET 9 /* disable mask */
  505. #define GEM_T2DISMSK_SIZE 1
  506. #define GEM_T2CMPOFST_OFFSET 7 /* compare offset */
  507. #define GEM_T2CMPOFST_SIZE 2
  508. #define GEM_T2OFST_OFFSET 0 /* offset value */
  509. #define GEM_T2OFST_SIZE 7
  510. /* Offset for screener type 2 compare values (T2CMPOFST).
  511. * Note the offset is applied after the specified point,
  512. * e.g. GEM_T2COMPOFST_ETYPE denotes the EtherType field, so an offset
  513. * of 12 bytes from this would be the source IP address in an IP header
  514. */
  515. #define GEM_T2COMPOFST_SOF 0
  516. #define GEM_T2COMPOFST_ETYPE 1
  517. #define GEM_T2COMPOFST_IPHDR 2
  518. #define GEM_T2COMPOFST_TCPUDP 3
  519. /* offset from EtherType to IP address */
  520. #define ETYPE_SRCIP_OFFSET 12
  521. #define ETYPE_DSTIP_OFFSET 16
  522. /* offset from IP header to port */
  523. #define IPHDR_SRCPORT_OFFSET 0
  524. #define IPHDR_DSTPORT_OFFSET 2
  525. /* Transmit DMA buffer descriptor Word 1 */
  526. #define GEM_DMA_TXVALID_OFFSET 23 /* timestamp has been captured in the Buffer Descriptor */
  527. #define GEM_DMA_TXVALID_SIZE 1
  528. /* Receive DMA buffer descriptor Word 0 */
  529. #define GEM_DMA_RXVALID_OFFSET 2 /* indicates a valid timestamp in the Buffer Descriptor */
  530. #define GEM_DMA_RXVALID_SIZE 1
  531. /* DMA buffer descriptor Word 2 (32 bit addressing) or Word 4 (64 bit addressing) */
  532. #define GEM_DMA_SECL_OFFSET 30 /* Timestamp seconds[1:0] */
  533. #define GEM_DMA_SECL_SIZE 2
  534. #define GEM_DMA_NSEC_OFFSET 0 /* Timestamp nanosecs [29:0] */
  535. #define GEM_DMA_NSEC_SIZE 30
  536. /* DMA buffer descriptor Word 3 (32 bit addressing) or Word 5 (64 bit addressing) */
  537. /* New hardware supports 12 bit precision of timestamp in DMA buffer descriptor.
  538. * Old hardware supports only 6 bit precision but it is enough for PTP.
  539. * Less accuracy is used always instead of checking hardware version.
  540. */
  541. #define GEM_DMA_SECH_OFFSET 0 /* Timestamp seconds[5:2] */
  542. #define GEM_DMA_SECH_SIZE 4
  543. #define GEM_DMA_SEC_WIDTH (GEM_DMA_SECH_SIZE + GEM_DMA_SECL_SIZE)
  544. #define GEM_DMA_SEC_TOP (1 << GEM_DMA_SEC_WIDTH)
  545. #define GEM_DMA_SEC_MASK (GEM_DMA_SEC_TOP - 1)
  546. /* Bitfields in ADJ */
  547. #define GEM_ADDSUB_OFFSET 31
  548. #define GEM_ADDSUB_SIZE 1
  549. /* Constants for CLK */
  550. #define MACB_CLK_DIV8 0
  551. #define MACB_CLK_DIV16 1
  552. #define MACB_CLK_DIV32 2
  553. #define MACB_CLK_DIV64 3
  554. /* GEM specific constants for CLK */
  555. #define GEM_CLK_DIV8 0
  556. #define GEM_CLK_DIV16 1
  557. #define GEM_CLK_DIV32 2
  558. #define GEM_CLK_DIV48 3
  559. #define GEM_CLK_DIV64 4
  560. #define GEM_CLK_DIV96 5
  561. #define GEM_CLK_DIV128 6
  562. #define GEM_CLK_DIV224 7
  563. /* Constants for MAN register */
  564. #define MACB_MAN_SOF 1
  565. #define MACB_MAN_WRITE 1
  566. #define MACB_MAN_READ 2
  567. #define MACB_MAN_CODE 2
  568. /* Capability mask bits */
  569. #define MACB_CAPS_ISR_CLEAR_ON_WRITE 0x00000001
  570. #define MACB_CAPS_USRIO_HAS_CLKEN 0x00000002
  571. #define MACB_CAPS_USRIO_DEFAULT_IS_MII_GMII 0x00000004
  572. #define MACB_CAPS_NO_GIGABIT_HALF 0x00000008
  573. #define MACB_CAPS_USRIO_DISABLED 0x00000010
  574. #define MACB_CAPS_JUMBO 0x00000020
  575. #define MACB_CAPS_GEM_HAS_PTP 0x00000040
  576. #define MACB_CAPS_BD_RD_PREFETCH 0x00000080
  577. #define MACB_CAPS_NEEDS_RSTONUBR 0x00000100
  578. #define MACB_CAPS_FIFO_MODE 0x10000000
  579. #define MACB_CAPS_GIGABIT_MODE_AVAILABLE 0x20000000
  580. #define MACB_CAPS_SG_DISABLED 0x40000000
  581. #define MACB_CAPS_MACB_IS_GEM 0x80000000
  582. /* LSO settings */
  583. #define MACB_LSO_UFO_ENABLE 0x01
  584. #define MACB_LSO_TSO_ENABLE 0x02
  585. /* Bit manipulation macros */
  586. #define MACB_BIT(name) \
  587. (1 << MACB_##name##_OFFSET)
  588. #define MACB_BF(name,value) \
  589. (((value) & ((1 << MACB_##name##_SIZE) - 1)) \
  590. << MACB_##name##_OFFSET)
  591. #define MACB_BFEXT(name,value)\
  592. (((value) >> MACB_##name##_OFFSET) \
  593. & ((1 << MACB_##name##_SIZE) - 1))
  594. #define MACB_BFINS(name,value,old) \
  595. (((old) & ~(((1 << MACB_##name##_SIZE) - 1) \
  596. << MACB_##name##_OFFSET)) \
  597. | MACB_BF(name,value))
  598. #define GEM_BIT(name) \
  599. (1 << GEM_##name##_OFFSET)
  600. #define GEM_BF(name, value) \
  601. (((value) & ((1 << GEM_##name##_SIZE) - 1)) \
  602. << GEM_##name##_OFFSET)
  603. #define GEM_BFEXT(name, value)\
  604. (((value) >> GEM_##name##_OFFSET) \
  605. & ((1 << GEM_##name##_SIZE) - 1))
  606. #define GEM_BFINS(name, value, old) \
  607. (((old) & ~(((1 << GEM_##name##_SIZE) - 1) \
  608. << GEM_##name##_OFFSET)) \
  609. | GEM_BF(name, value))
  610. /* Register access macros */
  611. #define macb_readl(port, reg) \
  612. readl((port)->regs + MACB_##reg)
  613. #define macb_writel(port, reg, value) \
  614. writel((value), (port)->regs + MACB_##reg)
  615. #define gem_readl(port, reg) \
  616. readl((port)->regs + GEM_##reg)
  617. #define gem_writel(port, reg, value) \
  618. writel((value), (port)->regs + GEM_##reg)
  619. /* DMA descriptor bitfields */
  620. #define MACB_RX_USED_OFFSET 0
  621. #define MACB_RX_USED_SIZE 1
  622. #define MACB_RX_WRAP_OFFSET 1
  623. #define MACB_RX_WRAP_SIZE 1
  624. #define MACB_RX_WADDR_OFFSET 2
  625. #define MACB_RX_WADDR_SIZE 30
  626. #define MACB_RX_FRMLEN_OFFSET 0
  627. #define MACB_RX_FRMLEN_SIZE 12
  628. #define MACB_RX_OFFSET_OFFSET 12
  629. #define MACB_RX_OFFSET_SIZE 2
  630. #define MACB_RX_SOF_OFFSET 14
  631. #define MACB_RX_SOF_SIZE 1
  632. #define MACB_RX_EOF_OFFSET 15
  633. #define MACB_RX_EOF_SIZE 1
  634. #define MACB_RX_CFI_OFFSET 16
  635. #define MACB_RX_CFI_SIZE 1
  636. #define MACB_RX_VLAN_PRI_OFFSET 17
  637. #define MACB_RX_VLAN_PRI_SIZE 3
  638. #define MACB_RX_PRI_TAG_OFFSET 20
  639. #define MACB_RX_PRI_TAG_SIZE 1
  640. #define MACB_RX_VLAN_TAG_OFFSET 21
  641. #define MACB_RX_VLAN_TAG_SIZE 1
  642. #define MACB_RX_TYPEID_MATCH_OFFSET 22
  643. #define MACB_RX_TYPEID_MATCH_SIZE 1
  644. #define MACB_RX_SA4_MATCH_OFFSET 23
  645. #define MACB_RX_SA4_MATCH_SIZE 1
  646. #define MACB_RX_SA3_MATCH_OFFSET 24
  647. #define MACB_RX_SA3_MATCH_SIZE 1
  648. #define MACB_RX_SA2_MATCH_OFFSET 25
  649. #define MACB_RX_SA2_MATCH_SIZE 1
  650. #define MACB_RX_SA1_MATCH_OFFSET 26
  651. #define MACB_RX_SA1_MATCH_SIZE 1
  652. #define MACB_RX_EXT_MATCH_OFFSET 28
  653. #define MACB_RX_EXT_MATCH_SIZE 1
  654. #define MACB_RX_UHASH_MATCH_OFFSET 29
  655. #define MACB_RX_UHASH_MATCH_SIZE 1
  656. #define MACB_RX_MHASH_MATCH_OFFSET 30
  657. #define MACB_RX_MHASH_MATCH_SIZE 1
  658. #define MACB_RX_BROADCAST_OFFSET 31
  659. #define MACB_RX_BROADCAST_SIZE 1
  660. #define MACB_RX_FRMLEN_MASK 0xFFF
  661. #define MACB_RX_JFRMLEN_MASK 0x3FFF
  662. /* RX checksum offload disabled: bit 24 clear in NCFGR */
  663. #define GEM_RX_TYPEID_MATCH_OFFSET 22
  664. #define GEM_RX_TYPEID_MATCH_SIZE 2
  665. /* RX checksum offload enabled: bit 24 set in NCFGR */
  666. #define GEM_RX_CSUM_OFFSET 22
  667. #define GEM_RX_CSUM_SIZE 2
  668. #define MACB_TX_FRMLEN_OFFSET 0
  669. #define MACB_TX_FRMLEN_SIZE 11
  670. #define MACB_TX_LAST_OFFSET 15
  671. #define MACB_TX_LAST_SIZE 1
  672. #define MACB_TX_NOCRC_OFFSET 16
  673. #define MACB_TX_NOCRC_SIZE 1
  674. #define MACB_MSS_MFS_OFFSET 16
  675. #define MACB_MSS_MFS_SIZE 14
  676. #define MACB_TX_LSO_OFFSET 17
  677. #define MACB_TX_LSO_SIZE 2
  678. #define MACB_TX_TCP_SEQ_SRC_OFFSET 19
  679. #define MACB_TX_TCP_SEQ_SRC_SIZE 1
  680. #define MACB_TX_BUF_EXHAUSTED_OFFSET 27
  681. #define MACB_TX_BUF_EXHAUSTED_SIZE 1
  682. #define MACB_TX_UNDERRUN_OFFSET 28
  683. #define MACB_TX_UNDERRUN_SIZE 1
  684. #define MACB_TX_ERROR_OFFSET 29
  685. #define MACB_TX_ERROR_SIZE 1
  686. #define MACB_TX_WRAP_OFFSET 30
  687. #define MACB_TX_WRAP_SIZE 1
  688. #define MACB_TX_USED_OFFSET 31
  689. #define MACB_TX_USED_SIZE 1
  690. #define GEM_TX_FRMLEN_OFFSET 0
  691. #define GEM_TX_FRMLEN_SIZE 14
  692. /* Buffer descriptor constants */
  693. #define GEM_RX_CSUM_NONE 0
  694. #define GEM_RX_CSUM_IP_ONLY 1
  695. #define GEM_RX_CSUM_IP_TCP 2
  696. #define GEM_RX_CSUM_IP_UDP 3
  697. /* limit RX checksum offload to TCP and UDP packets */
  698. #define GEM_RX_CSUM_CHECKED_MASK 2
  699. #define gem_writel_queue_TBQP(port, value, queue_num) \
  700. writel((value), (port)->regs + GEM_TBQP(queue_num))
  701. #endif /* __DRIVERS_MACB_H__ */