0002-net-macb-sync-header-definitions-as-taken-from-Linux.patch 34 KB

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