xgbe-common.h 45 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302
  1. /*
  2. * AMD 10Gb Ethernet driver
  3. *
  4. * This file is available to you under your choice of the following two
  5. * licenses:
  6. *
  7. * License 1: GPLv2
  8. *
  9. * Copyright (c) 2014 Advanced Micro Devices, Inc.
  10. *
  11. * This file is free software; you may copy, redistribute and/or modify
  12. * it under the terms of the GNU General Public License as published by
  13. * the Free Software Foundation, either version 2 of the License, or (at
  14. * your option) any later version.
  15. *
  16. * This file is distributed in the hope that it will be useful, but
  17. * WITHOUT ANY WARRANTY; without even the implied warranty of
  18. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  19. * General Public License for more details.
  20. *
  21. * You should have received a copy of the GNU General Public License
  22. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  23. *
  24. * This file incorporates work covered by the following copyright and
  25. * permission notice:
  26. * The Synopsys DWC ETHER XGMAC Software Driver and documentation
  27. * (hereinafter "Software") is an unsupported proprietary work of Synopsys,
  28. * Inc. unless otherwise expressly agreed to in writing between Synopsys
  29. * and you.
  30. *
  31. * The Software IS NOT an item of Licensed Software or Licensed Product
  32. * under any End User Software License Agreement or Agreement for Licensed
  33. * Product with Synopsys or any supplement thereto. Permission is hereby
  34. * granted, free of charge, to any person obtaining a copy of this software
  35. * annotated with this license and the Software, to deal in the Software
  36. * without restriction, including without limitation the rights to use,
  37. * copy, modify, merge, publish, distribute, sublicense, and/or sell copies
  38. * of the Software, and to permit persons to whom the Software is furnished
  39. * to do so, subject to the following conditions:
  40. *
  41. * The above copyright notice and this permission notice shall be included
  42. * in all copies or substantial portions of the Software.
  43. *
  44. * THIS SOFTWARE IS BEING DISTRIBUTED BY SYNOPSYS SOLELY ON AN "AS IS"
  45. * BASIS AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
  46. * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
  47. * PARTICULAR PURPOSE ARE HEREBY DISCLAIMED. IN NO EVENT SHALL SYNOPSYS
  48. * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  49. * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  50. * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  51. * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  52. * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  53. * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
  54. * THE POSSIBILITY OF SUCH DAMAGE.
  55. *
  56. *
  57. * License 2: Modified BSD
  58. *
  59. * Copyright (c) 2014 Advanced Micro Devices, Inc.
  60. * All rights reserved.
  61. *
  62. * Redistribution and use in source and binary forms, with or without
  63. * modification, are permitted provided that the following conditions are met:
  64. * * Redistributions of source code must retain the above copyright
  65. * notice, this list of conditions and the following disclaimer.
  66. * * Redistributions in binary form must reproduce the above copyright
  67. * notice, this list of conditions and the following disclaimer in the
  68. * documentation and/or other materials provided with the distribution.
  69. * * Neither the name of Advanced Micro Devices, Inc. nor the
  70. * names of its contributors may be used to endorse or promote products
  71. * derived from this software without specific prior written permission.
  72. *
  73. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  74. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  75. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  76. * ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
  77. * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  78. * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  79. * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  80. * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  81. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  82. * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  83. *
  84. * This file incorporates work covered by the following copyright and
  85. * permission notice:
  86. * The Synopsys DWC ETHER XGMAC Software Driver and documentation
  87. * (hereinafter "Software") is an unsupported proprietary work of Synopsys,
  88. * Inc. unless otherwise expressly agreed to in writing between Synopsys
  89. * and you.
  90. *
  91. * The Software IS NOT an item of Licensed Software or Licensed Product
  92. * under any End User Software License Agreement or Agreement for Licensed
  93. * Product with Synopsys or any supplement thereto. Permission is hereby
  94. * granted, free of charge, to any person obtaining a copy of this software
  95. * annotated with this license and the Software, to deal in the Software
  96. * without restriction, including without limitation the rights to use,
  97. * copy, modify, merge, publish, distribute, sublicense, and/or sell copies
  98. * of the Software, and to permit persons to whom the Software is furnished
  99. * to do so, subject to the following conditions:
  100. *
  101. * The above copyright notice and this permission notice shall be included
  102. * in all copies or substantial portions of the Software.
  103. *
  104. * THIS SOFTWARE IS BEING DISTRIBUTED BY SYNOPSYS SOLELY ON AN "AS IS"
  105. * BASIS AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
  106. * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
  107. * PARTICULAR PURPOSE ARE HEREBY DISCLAIMED. IN NO EVENT SHALL SYNOPSYS
  108. * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  109. * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  110. * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  111. * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  112. * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  113. * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
  114. * THE POSSIBILITY OF SUCH DAMAGE.
  115. */
  116. #ifndef __XGBE_COMMON_H__
  117. #define __XGBE_COMMON_H__
  118. /* DMA register offsets */
  119. #define DMA_MR 0x3000
  120. #define DMA_SBMR 0x3004
  121. #define DMA_ISR 0x3008
  122. #define DMA_AXIARCR 0x3010
  123. #define DMA_AXIAWCR 0x3018
  124. #define DMA_DSR0 0x3020
  125. #define DMA_DSR1 0x3024
  126. /* DMA register entry bit positions and sizes */
  127. #define DMA_AXIARCR_DRC_INDEX 0
  128. #define DMA_AXIARCR_DRC_WIDTH 4
  129. #define DMA_AXIARCR_DRD_INDEX 4
  130. #define DMA_AXIARCR_DRD_WIDTH 2
  131. #define DMA_AXIARCR_TEC_INDEX 8
  132. #define DMA_AXIARCR_TEC_WIDTH 4
  133. #define DMA_AXIARCR_TED_INDEX 12
  134. #define DMA_AXIARCR_TED_WIDTH 2
  135. #define DMA_AXIARCR_THC_INDEX 16
  136. #define DMA_AXIARCR_THC_WIDTH 4
  137. #define DMA_AXIARCR_THD_INDEX 20
  138. #define DMA_AXIARCR_THD_WIDTH 2
  139. #define DMA_AXIAWCR_DWC_INDEX 0
  140. #define DMA_AXIAWCR_DWC_WIDTH 4
  141. #define DMA_AXIAWCR_DWD_INDEX 4
  142. #define DMA_AXIAWCR_DWD_WIDTH 2
  143. #define DMA_AXIAWCR_RPC_INDEX 8
  144. #define DMA_AXIAWCR_RPC_WIDTH 4
  145. #define DMA_AXIAWCR_RPD_INDEX 12
  146. #define DMA_AXIAWCR_RPD_WIDTH 2
  147. #define DMA_AXIAWCR_RHC_INDEX 16
  148. #define DMA_AXIAWCR_RHC_WIDTH 4
  149. #define DMA_AXIAWCR_RHD_INDEX 20
  150. #define DMA_AXIAWCR_RHD_WIDTH 2
  151. #define DMA_AXIAWCR_TDC_INDEX 24
  152. #define DMA_AXIAWCR_TDC_WIDTH 4
  153. #define DMA_AXIAWCR_TDD_INDEX 28
  154. #define DMA_AXIAWCR_TDD_WIDTH 2
  155. #define DMA_ISR_MACIS_INDEX 17
  156. #define DMA_ISR_MACIS_WIDTH 1
  157. #define DMA_ISR_MTLIS_INDEX 16
  158. #define DMA_ISR_MTLIS_WIDTH 1
  159. #define DMA_MR_SWR_INDEX 0
  160. #define DMA_MR_SWR_WIDTH 1
  161. #define DMA_SBMR_EAME_INDEX 11
  162. #define DMA_SBMR_EAME_WIDTH 1
  163. #define DMA_SBMR_BLEN_256_INDEX 7
  164. #define DMA_SBMR_BLEN_256_WIDTH 1
  165. #define DMA_SBMR_UNDEF_INDEX 0
  166. #define DMA_SBMR_UNDEF_WIDTH 1
  167. /* DMA register values */
  168. #define DMA_DSR_RPS_WIDTH 4
  169. #define DMA_DSR_TPS_WIDTH 4
  170. #define DMA_DSR_Q_WIDTH (DMA_DSR_RPS_WIDTH + DMA_DSR_TPS_WIDTH)
  171. #define DMA_DSR0_RPS_START 8
  172. #define DMA_DSR0_TPS_START 12
  173. #define DMA_DSRX_FIRST_QUEUE 3
  174. #define DMA_DSRX_INC 4
  175. #define DMA_DSRX_QPR 4
  176. #define DMA_DSRX_RPS_START 0
  177. #define DMA_DSRX_TPS_START 4
  178. #define DMA_TPS_STOPPED 0x00
  179. #define DMA_TPS_SUSPENDED 0x06
  180. /* DMA channel register offsets
  181. * Multiple channels can be active. The first channel has registers
  182. * that begin at 0x3100. Each subsequent channel has registers that
  183. * are accessed using an offset of 0x80 from the previous channel.
  184. */
  185. #define DMA_CH_BASE 0x3100
  186. #define DMA_CH_INC 0x80
  187. #define DMA_CH_CR 0x00
  188. #define DMA_CH_TCR 0x04
  189. #define DMA_CH_RCR 0x08
  190. #define DMA_CH_TDLR_HI 0x10
  191. #define DMA_CH_TDLR_LO 0x14
  192. #define DMA_CH_RDLR_HI 0x18
  193. #define DMA_CH_RDLR_LO 0x1c
  194. #define DMA_CH_TDTR_LO 0x24
  195. #define DMA_CH_RDTR_LO 0x2c
  196. #define DMA_CH_TDRLR 0x30
  197. #define DMA_CH_RDRLR 0x34
  198. #define DMA_CH_IER 0x38
  199. #define DMA_CH_RIWT 0x3c
  200. #define DMA_CH_CATDR_LO 0x44
  201. #define DMA_CH_CARDR_LO 0x4c
  202. #define DMA_CH_CATBR_HI 0x50
  203. #define DMA_CH_CATBR_LO 0x54
  204. #define DMA_CH_CARBR_HI 0x58
  205. #define DMA_CH_CARBR_LO 0x5c
  206. #define DMA_CH_SR 0x60
  207. /* DMA channel register entry bit positions and sizes */
  208. #define DMA_CH_CR_PBLX8_INDEX 16
  209. #define DMA_CH_CR_PBLX8_WIDTH 1
  210. #define DMA_CH_CR_SPH_INDEX 24
  211. #define DMA_CH_CR_SPH_WIDTH 1
  212. #define DMA_CH_IER_AIE_INDEX 15
  213. #define DMA_CH_IER_AIE_WIDTH 1
  214. #define DMA_CH_IER_FBEE_INDEX 12
  215. #define DMA_CH_IER_FBEE_WIDTH 1
  216. #define DMA_CH_IER_NIE_INDEX 16
  217. #define DMA_CH_IER_NIE_WIDTH 1
  218. #define DMA_CH_IER_RBUE_INDEX 7
  219. #define DMA_CH_IER_RBUE_WIDTH 1
  220. #define DMA_CH_IER_RIE_INDEX 6
  221. #define DMA_CH_IER_RIE_WIDTH 1
  222. #define DMA_CH_IER_RSE_INDEX 8
  223. #define DMA_CH_IER_RSE_WIDTH 1
  224. #define DMA_CH_IER_TBUE_INDEX 2
  225. #define DMA_CH_IER_TBUE_WIDTH 1
  226. #define DMA_CH_IER_TIE_INDEX 0
  227. #define DMA_CH_IER_TIE_WIDTH 1
  228. #define DMA_CH_IER_TXSE_INDEX 1
  229. #define DMA_CH_IER_TXSE_WIDTH 1
  230. #define DMA_CH_RCR_PBL_INDEX 16
  231. #define DMA_CH_RCR_PBL_WIDTH 6
  232. #define DMA_CH_RCR_RBSZ_INDEX 1
  233. #define DMA_CH_RCR_RBSZ_WIDTH 14
  234. #define DMA_CH_RCR_SR_INDEX 0
  235. #define DMA_CH_RCR_SR_WIDTH 1
  236. #define DMA_CH_RIWT_RWT_INDEX 0
  237. #define DMA_CH_RIWT_RWT_WIDTH 8
  238. #define DMA_CH_SR_FBE_INDEX 12
  239. #define DMA_CH_SR_FBE_WIDTH 1
  240. #define DMA_CH_SR_RBU_INDEX 7
  241. #define DMA_CH_SR_RBU_WIDTH 1
  242. #define DMA_CH_SR_RI_INDEX 6
  243. #define DMA_CH_SR_RI_WIDTH 1
  244. #define DMA_CH_SR_RPS_INDEX 8
  245. #define DMA_CH_SR_RPS_WIDTH 1
  246. #define DMA_CH_SR_TBU_INDEX 2
  247. #define DMA_CH_SR_TBU_WIDTH 1
  248. #define DMA_CH_SR_TI_INDEX 0
  249. #define DMA_CH_SR_TI_WIDTH 1
  250. #define DMA_CH_SR_TPS_INDEX 1
  251. #define DMA_CH_SR_TPS_WIDTH 1
  252. #define DMA_CH_TCR_OSP_INDEX 4
  253. #define DMA_CH_TCR_OSP_WIDTH 1
  254. #define DMA_CH_TCR_PBL_INDEX 16
  255. #define DMA_CH_TCR_PBL_WIDTH 6
  256. #define DMA_CH_TCR_ST_INDEX 0
  257. #define DMA_CH_TCR_ST_WIDTH 1
  258. #define DMA_CH_TCR_TSE_INDEX 12
  259. #define DMA_CH_TCR_TSE_WIDTH 1
  260. /* DMA channel register values */
  261. #define DMA_OSP_DISABLE 0x00
  262. #define DMA_OSP_ENABLE 0x01
  263. #define DMA_PBL_1 1
  264. #define DMA_PBL_2 2
  265. #define DMA_PBL_4 4
  266. #define DMA_PBL_8 8
  267. #define DMA_PBL_16 16
  268. #define DMA_PBL_32 32
  269. #define DMA_PBL_64 64 /* 8 x 8 */
  270. #define DMA_PBL_128 128 /* 8 x 16 */
  271. #define DMA_PBL_256 256 /* 8 x 32 */
  272. #define DMA_PBL_X8_DISABLE 0x00
  273. #define DMA_PBL_X8_ENABLE 0x01
  274. /* MAC register offsets */
  275. #define MAC_TCR 0x0000
  276. #define MAC_RCR 0x0004
  277. #define MAC_PFR 0x0008
  278. #define MAC_WTR 0x000c
  279. #define MAC_HTR0 0x0010
  280. #define MAC_VLANTR 0x0050
  281. #define MAC_VLANHTR 0x0058
  282. #define MAC_VLANIR 0x0060
  283. #define MAC_IVLANIR 0x0064
  284. #define MAC_RETMR 0x006c
  285. #define MAC_Q0TFCR 0x0070
  286. #define MAC_RFCR 0x0090
  287. #define MAC_RQC0R 0x00a0
  288. #define MAC_RQC1R 0x00a4
  289. #define MAC_RQC2R 0x00a8
  290. #define MAC_RQC3R 0x00ac
  291. #define MAC_ISR 0x00b0
  292. #define MAC_IER 0x00b4
  293. #define MAC_RTSR 0x00b8
  294. #define MAC_PMTCSR 0x00c0
  295. #define MAC_RWKPFR 0x00c4
  296. #define MAC_LPICSR 0x00d0
  297. #define MAC_LPITCR 0x00d4
  298. #define MAC_VR 0x0110
  299. #define MAC_DR 0x0114
  300. #define MAC_HWF0R 0x011c
  301. #define MAC_HWF1R 0x0120
  302. #define MAC_HWF2R 0x0124
  303. #define MAC_GPIOCR 0x0278
  304. #define MAC_GPIOSR 0x027c
  305. #define MAC_MACA0HR 0x0300
  306. #define MAC_MACA0LR 0x0304
  307. #define MAC_MACA1HR 0x0308
  308. #define MAC_MACA1LR 0x030c
  309. #define MAC_RSSCR 0x0c80
  310. #define MAC_RSSAR 0x0c88
  311. #define MAC_RSSDR 0x0c8c
  312. #define MAC_TSCR 0x0d00
  313. #define MAC_SSIR 0x0d04
  314. #define MAC_STSR 0x0d08
  315. #define MAC_STNR 0x0d0c
  316. #define MAC_STSUR 0x0d10
  317. #define MAC_STNUR 0x0d14
  318. #define MAC_TSAR 0x0d18
  319. #define MAC_TSSR 0x0d20
  320. #define MAC_TXSNR 0x0d30
  321. #define MAC_TXSSR 0x0d34
  322. #define MAC_QTFCR_INC 4
  323. #define MAC_MACA_INC 4
  324. #define MAC_HTR_INC 4
  325. #define MAC_RQC2_INC 4
  326. #define MAC_RQC2_Q_PER_REG 4
  327. /* MAC register entry bit positions and sizes */
  328. #define MAC_HWF0R_ADDMACADRSEL_INDEX 18
  329. #define MAC_HWF0R_ADDMACADRSEL_WIDTH 5
  330. #define MAC_HWF0R_ARPOFFSEL_INDEX 9
  331. #define MAC_HWF0R_ARPOFFSEL_WIDTH 1
  332. #define MAC_HWF0R_EEESEL_INDEX 13
  333. #define MAC_HWF0R_EEESEL_WIDTH 1
  334. #define MAC_HWF0R_GMIISEL_INDEX 1
  335. #define MAC_HWF0R_GMIISEL_WIDTH 1
  336. #define MAC_HWF0R_MGKSEL_INDEX 7
  337. #define MAC_HWF0R_MGKSEL_WIDTH 1
  338. #define MAC_HWF0R_MMCSEL_INDEX 8
  339. #define MAC_HWF0R_MMCSEL_WIDTH 1
  340. #define MAC_HWF0R_RWKSEL_INDEX 6
  341. #define MAC_HWF0R_RWKSEL_WIDTH 1
  342. #define MAC_HWF0R_RXCOESEL_INDEX 16
  343. #define MAC_HWF0R_RXCOESEL_WIDTH 1
  344. #define MAC_HWF0R_SAVLANINS_INDEX 27
  345. #define MAC_HWF0R_SAVLANINS_WIDTH 1
  346. #define MAC_HWF0R_SMASEL_INDEX 5
  347. #define MAC_HWF0R_SMASEL_WIDTH 1
  348. #define MAC_HWF0R_TSSEL_INDEX 12
  349. #define MAC_HWF0R_TSSEL_WIDTH 1
  350. #define MAC_HWF0R_TSSTSSEL_INDEX 25
  351. #define MAC_HWF0R_TSSTSSEL_WIDTH 2
  352. #define MAC_HWF0R_TXCOESEL_INDEX 14
  353. #define MAC_HWF0R_TXCOESEL_WIDTH 1
  354. #define MAC_HWF0R_VLHASH_INDEX 4
  355. #define MAC_HWF0R_VLHASH_WIDTH 1
  356. #define MAC_HWF1R_ADDR64_INDEX 14
  357. #define MAC_HWF1R_ADDR64_WIDTH 2
  358. #define MAC_HWF1R_ADVTHWORD_INDEX 13
  359. #define MAC_HWF1R_ADVTHWORD_WIDTH 1
  360. #define MAC_HWF1R_DBGMEMA_INDEX 19
  361. #define MAC_HWF1R_DBGMEMA_WIDTH 1
  362. #define MAC_HWF1R_DCBEN_INDEX 16
  363. #define MAC_HWF1R_DCBEN_WIDTH 1
  364. #define MAC_HWF1R_HASHTBLSZ_INDEX 24
  365. #define MAC_HWF1R_HASHTBLSZ_WIDTH 3
  366. #define MAC_HWF1R_L3L4FNUM_INDEX 27
  367. #define MAC_HWF1R_L3L4FNUM_WIDTH 4
  368. #define MAC_HWF1R_NUMTC_INDEX 21
  369. #define MAC_HWF1R_NUMTC_WIDTH 3
  370. #define MAC_HWF1R_RSSEN_INDEX 20
  371. #define MAC_HWF1R_RSSEN_WIDTH 1
  372. #define MAC_HWF1R_RXFIFOSIZE_INDEX 0
  373. #define MAC_HWF1R_RXFIFOSIZE_WIDTH 5
  374. #define MAC_HWF1R_SPHEN_INDEX 17
  375. #define MAC_HWF1R_SPHEN_WIDTH 1
  376. #define MAC_HWF1R_TSOEN_INDEX 18
  377. #define MAC_HWF1R_TSOEN_WIDTH 1
  378. #define MAC_HWF1R_TXFIFOSIZE_INDEX 6
  379. #define MAC_HWF1R_TXFIFOSIZE_WIDTH 5
  380. #define MAC_HWF2R_AUXSNAPNUM_INDEX 28
  381. #define MAC_HWF2R_AUXSNAPNUM_WIDTH 3
  382. #define MAC_HWF2R_PPSOUTNUM_INDEX 24
  383. #define MAC_HWF2R_PPSOUTNUM_WIDTH 3
  384. #define MAC_HWF2R_RXCHCNT_INDEX 12
  385. #define MAC_HWF2R_RXCHCNT_WIDTH 4
  386. #define MAC_HWF2R_RXQCNT_INDEX 0
  387. #define MAC_HWF2R_RXQCNT_WIDTH 4
  388. #define MAC_HWF2R_TXCHCNT_INDEX 18
  389. #define MAC_HWF2R_TXCHCNT_WIDTH 4
  390. #define MAC_HWF2R_TXQCNT_INDEX 6
  391. #define MAC_HWF2R_TXQCNT_WIDTH 4
  392. #define MAC_IER_TSIE_INDEX 12
  393. #define MAC_IER_TSIE_WIDTH 1
  394. #define MAC_ISR_MMCRXIS_INDEX 9
  395. #define MAC_ISR_MMCRXIS_WIDTH 1
  396. #define MAC_ISR_MMCTXIS_INDEX 10
  397. #define MAC_ISR_MMCTXIS_WIDTH 1
  398. #define MAC_ISR_PMTIS_INDEX 4
  399. #define MAC_ISR_PMTIS_WIDTH 1
  400. #define MAC_ISR_TSIS_INDEX 12
  401. #define MAC_ISR_TSIS_WIDTH 1
  402. #define MAC_MACA1HR_AE_INDEX 31
  403. #define MAC_MACA1HR_AE_WIDTH 1
  404. #define MAC_PFR_HMC_INDEX 2
  405. #define MAC_PFR_HMC_WIDTH 1
  406. #define MAC_PFR_HPF_INDEX 10
  407. #define MAC_PFR_HPF_WIDTH 1
  408. #define MAC_PFR_HUC_INDEX 1
  409. #define MAC_PFR_HUC_WIDTH 1
  410. #define MAC_PFR_PM_INDEX 4
  411. #define MAC_PFR_PM_WIDTH 1
  412. #define MAC_PFR_PR_INDEX 0
  413. #define MAC_PFR_PR_WIDTH 1
  414. #define MAC_PFR_VTFE_INDEX 16
  415. #define MAC_PFR_VTFE_WIDTH 1
  416. #define MAC_PMTCSR_MGKPKTEN_INDEX 1
  417. #define MAC_PMTCSR_MGKPKTEN_WIDTH 1
  418. #define MAC_PMTCSR_PWRDWN_INDEX 0
  419. #define MAC_PMTCSR_PWRDWN_WIDTH 1
  420. #define MAC_PMTCSR_RWKFILTRST_INDEX 31
  421. #define MAC_PMTCSR_RWKFILTRST_WIDTH 1
  422. #define MAC_PMTCSR_RWKPKTEN_INDEX 2
  423. #define MAC_PMTCSR_RWKPKTEN_WIDTH 1
  424. #define MAC_Q0TFCR_PT_INDEX 16
  425. #define MAC_Q0TFCR_PT_WIDTH 16
  426. #define MAC_Q0TFCR_TFE_INDEX 1
  427. #define MAC_Q0TFCR_TFE_WIDTH 1
  428. #define MAC_RCR_ACS_INDEX 1
  429. #define MAC_RCR_ACS_WIDTH 1
  430. #define MAC_RCR_CST_INDEX 2
  431. #define MAC_RCR_CST_WIDTH 1
  432. #define MAC_RCR_DCRCC_INDEX 3
  433. #define MAC_RCR_DCRCC_WIDTH 1
  434. #define MAC_RCR_HDSMS_INDEX 12
  435. #define MAC_RCR_HDSMS_WIDTH 3
  436. #define MAC_RCR_IPC_INDEX 9
  437. #define MAC_RCR_IPC_WIDTH 1
  438. #define MAC_RCR_JE_INDEX 8
  439. #define MAC_RCR_JE_WIDTH 1
  440. #define MAC_RCR_LM_INDEX 10
  441. #define MAC_RCR_LM_WIDTH 1
  442. #define MAC_RCR_RE_INDEX 0
  443. #define MAC_RCR_RE_WIDTH 1
  444. #define MAC_RFCR_PFCE_INDEX 8
  445. #define MAC_RFCR_PFCE_WIDTH 1
  446. #define MAC_RFCR_RFE_INDEX 0
  447. #define MAC_RFCR_RFE_WIDTH 1
  448. #define MAC_RFCR_UP_INDEX 1
  449. #define MAC_RFCR_UP_WIDTH 1
  450. #define MAC_RQC0R_RXQ0EN_INDEX 0
  451. #define MAC_RQC0R_RXQ0EN_WIDTH 2
  452. #define MAC_RSSAR_ADDRT_INDEX 2
  453. #define MAC_RSSAR_ADDRT_WIDTH 1
  454. #define MAC_RSSAR_CT_INDEX 1
  455. #define MAC_RSSAR_CT_WIDTH 1
  456. #define MAC_RSSAR_OB_INDEX 0
  457. #define MAC_RSSAR_OB_WIDTH 1
  458. #define MAC_RSSAR_RSSIA_INDEX 8
  459. #define MAC_RSSAR_RSSIA_WIDTH 8
  460. #define MAC_RSSCR_IP2TE_INDEX 1
  461. #define MAC_RSSCR_IP2TE_WIDTH 1
  462. #define MAC_RSSCR_RSSE_INDEX 0
  463. #define MAC_RSSCR_RSSE_WIDTH 1
  464. #define MAC_RSSCR_TCP4TE_INDEX 2
  465. #define MAC_RSSCR_TCP4TE_WIDTH 1
  466. #define MAC_RSSCR_UDP4TE_INDEX 3
  467. #define MAC_RSSCR_UDP4TE_WIDTH 1
  468. #define MAC_RSSDR_DMCH_INDEX 0
  469. #define MAC_RSSDR_DMCH_WIDTH 4
  470. #define MAC_SSIR_SNSINC_INDEX 8
  471. #define MAC_SSIR_SNSINC_WIDTH 8
  472. #define MAC_SSIR_SSINC_INDEX 16
  473. #define MAC_SSIR_SSINC_WIDTH 8
  474. #define MAC_TCR_SS_INDEX 29
  475. #define MAC_TCR_SS_WIDTH 2
  476. #define MAC_TCR_TE_INDEX 0
  477. #define MAC_TCR_TE_WIDTH 1
  478. #define MAC_TSCR_AV8021ASMEN_INDEX 28
  479. #define MAC_TSCR_AV8021ASMEN_WIDTH 1
  480. #define MAC_TSCR_SNAPTYPSEL_INDEX 16
  481. #define MAC_TSCR_SNAPTYPSEL_WIDTH 2
  482. #define MAC_TSCR_TSADDREG_INDEX 5
  483. #define MAC_TSCR_TSADDREG_WIDTH 1
  484. #define MAC_TSCR_TSCFUPDT_INDEX 1
  485. #define MAC_TSCR_TSCFUPDT_WIDTH 1
  486. #define MAC_TSCR_TSCTRLSSR_INDEX 9
  487. #define MAC_TSCR_TSCTRLSSR_WIDTH 1
  488. #define MAC_TSCR_TSENA_INDEX 0
  489. #define MAC_TSCR_TSENA_WIDTH 1
  490. #define MAC_TSCR_TSENALL_INDEX 8
  491. #define MAC_TSCR_TSENALL_WIDTH 1
  492. #define MAC_TSCR_TSEVNTENA_INDEX 14
  493. #define MAC_TSCR_TSEVNTENA_WIDTH 1
  494. #define MAC_TSCR_TSINIT_INDEX 2
  495. #define MAC_TSCR_TSINIT_WIDTH 1
  496. #define MAC_TSCR_TSIPENA_INDEX 11
  497. #define MAC_TSCR_TSIPENA_WIDTH 1
  498. #define MAC_TSCR_TSIPV4ENA_INDEX 13
  499. #define MAC_TSCR_TSIPV4ENA_WIDTH 1
  500. #define MAC_TSCR_TSIPV6ENA_INDEX 12
  501. #define MAC_TSCR_TSIPV6ENA_WIDTH 1
  502. #define MAC_TSCR_TSMSTRENA_INDEX 15
  503. #define MAC_TSCR_TSMSTRENA_WIDTH 1
  504. #define MAC_TSCR_TSVER2ENA_INDEX 10
  505. #define MAC_TSCR_TSVER2ENA_WIDTH 1
  506. #define MAC_TSCR_TXTSSTSM_INDEX 24
  507. #define MAC_TSCR_TXTSSTSM_WIDTH 1
  508. #define MAC_TSSR_TXTSC_INDEX 15
  509. #define MAC_TSSR_TXTSC_WIDTH 1
  510. #define MAC_TXSNR_TXTSSTSMIS_INDEX 31
  511. #define MAC_TXSNR_TXTSSTSMIS_WIDTH 1
  512. #define MAC_VLANHTR_VLHT_INDEX 0
  513. #define MAC_VLANHTR_VLHT_WIDTH 16
  514. #define MAC_VLANIR_VLTI_INDEX 20
  515. #define MAC_VLANIR_VLTI_WIDTH 1
  516. #define MAC_VLANIR_CSVL_INDEX 19
  517. #define MAC_VLANIR_CSVL_WIDTH 1
  518. #define MAC_VLANTR_DOVLTC_INDEX 20
  519. #define MAC_VLANTR_DOVLTC_WIDTH 1
  520. #define MAC_VLANTR_ERSVLM_INDEX 19
  521. #define MAC_VLANTR_ERSVLM_WIDTH 1
  522. #define MAC_VLANTR_ESVL_INDEX 18
  523. #define MAC_VLANTR_ESVL_WIDTH 1
  524. #define MAC_VLANTR_ETV_INDEX 16
  525. #define MAC_VLANTR_ETV_WIDTH 1
  526. #define MAC_VLANTR_EVLS_INDEX 21
  527. #define MAC_VLANTR_EVLS_WIDTH 2
  528. #define MAC_VLANTR_EVLRXS_INDEX 24
  529. #define MAC_VLANTR_EVLRXS_WIDTH 1
  530. #define MAC_VLANTR_VL_INDEX 0
  531. #define MAC_VLANTR_VL_WIDTH 16
  532. #define MAC_VLANTR_VTHM_INDEX 25
  533. #define MAC_VLANTR_VTHM_WIDTH 1
  534. #define MAC_VLANTR_VTIM_INDEX 17
  535. #define MAC_VLANTR_VTIM_WIDTH 1
  536. #define MAC_VR_DEVID_INDEX 8
  537. #define MAC_VR_DEVID_WIDTH 8
  538. #define MAC_VR_SNPSVER_INDEX 0
  539. #define MAC_VR_SNPSVER_WIDTH 8
  540. #define MAC_VR_USERVER_INDEX 16
  541. #define MAC_VR_USERVER_WIDTH 8
  542. /* MMC register offsets */
  543. #define MMC_CR 0x0800
  544. #define MMC_RISR 0x0804
  545. #define MMC_TISR 0x0808
  546. #define MMC_RIER 0x080c
  547. #define MMC_TIER 0x0810
  548. #define MMC_TXOCTETCOUNT_GB_LO 0x0814
  549. #define MMC_TXOCTETCOUNT_GB_HI 0x0818
  550. #define MMC_TXFRAMECOUNT_GB_LO 0x081c
  551. #define MMC_TXFRAMECOUNT_GB_HI 0x0820
  552. #define MMC_TXBROADCASTFRAMES_G_LO 0x0824
  553. #define MMC_TXBROADCASTFRAMES_G_HI 0x0828
  554. #define MMC_TXMULTICASTFRAMES_G_LO 0x082c
  555. #define MMC_TXMULTICASTFRAMES_G_HI 0x0830
  556. #define MMC_TX64OCTETS_GB_LO 0x0834
  557. #define MMC_TX64OCTETS_GB_HI 0x0838
  558. #define MMC_TX65TO127OCTETS_GB_LO 0x083c
  559. #define MMC_TX65TO127OCTETS_GB_HI 0x0840
  560. #define MMC_TX128TO255OCTETS_GB_LO 0x0844
  561. #define MMC_TX128TO255OCTETS_GB_HI 0x0848
  562. #define MMC_TX256TO511OCTETS_GB_LO 0x084c
  563. #define MMC_TX256TO511OCTETS_GB_HI 0x0850
  564. #define MMC_TX512TO1023OCTETS_GB_LO 0x0854
  565. #define MMC_TX512TO1023OCTETS_GB_HI 0x0858
  566. #define MMC_TX1024TOMAXOCTETS_GB_LO 0x085c
  567. #define MMC_TX1024TOMAXOCTETS_GB_HI 0x0860
  568. #define MMC_TXUNICASTFRAMES_GB_LO 0x0864
  569. #define MMC_TXUNICASTFRAMES_GB_HI 0x0868
  570. #define MMC_TXMULTICASTFRAMES_GB_LO 0x086c
  571. #define MMC_TXMULTICASTFRAMES_GB_HI 0x0870
  572. #define MMC_TXBROADCASTFRAMES_GB_LO 0x0874
  573. #define MMC_TXBROADCASTFRAMES_GB_HI 0x0878
  574. #define MMC_TXUNDERFLOWERROR_LO 0x087c
  575. #define MMC_TXUNDERFLOWERROR_HI 0x0880
  576. #define MMC_TXOCTETCOUNT_G_LO 0x0884
  577. #define MMC_TXOCTETCOUNT_G_HI 0x0888
  578. #define MMC_TXFRAMECOUNT_G_LO 0x088c
  579. #define MMC_TXFRAMECOUNT_G_HI 0x0890
  580. #define MMC_TXPAUSEFRAMES_LO 0x0894
  581. #define MMC_TXPAUSEFRAMES_HI 0x0898
  582. #define MMC_TXVLANFRAMES_G_LO 0x089c
  583. #define MMC_TXVLANFRAMES_G_HI 0x08a0
  584. #define MMC_RXFRAMECOUNT_GB_LO 0x0900
  585. #define MMC_RXFRAMECOUNT_GB_HI 0x0904
  586. #define MMC_RXOCTETCOUNT_GB_LO 0x0908
  587. #define MMC_RXOCTETCOUNT_GB_HI 0x090c
  588. #define MMC_RXOCTETCOUNT_G_LO 0x0910
  589. #define MMC_RXOCTETCOUNT_G_HI 0x0914
  590. #define MMC_RXBROADCASTFRAMES_G_LO 0x0918
  591. #define MMC_RXBROADCASTFRAMES_G_HI 0x091c
  592. #define MMC_RXMULTICASTFRAMES_G_LO 0x0920
  593. #define MMC_RXMULTICASTFRAMES_G_HI 0x0924
  594. #define MMC_RXCRCERROR_LO 0x0928
  595. #define MMC_RXCRCERROR_HI 0x092c
  596. #define MMC_RXRUNTERROR 0x0930
  597. #define MMC_RXJABBERERROR 0x0934
  598. #define MMC_RXUNDERSIZE_G 0x0938
  599. #define MMC_RXOVERSIZE_G 0x093c
  600. #define MMC_RX64OCTETS_GB_LO 0x0940
  601. #define MMC_RX64OCTETS_GB_HI 0x0944
  602. #define MMC_RX65TO127OCTETS_GB_LO 0x0948
  603. #define MMC_RX65TO127OCTETS_GB_HI 0x094c
  604. #define MMC_RX128TO255OCTETS_GB_LO 0x0950
  605. #define MMC_RX128TO255OCTETS_GB_HI 0x0954
  606. #define MMC_RX256TO511OCTETS_GB_LO 0x0958
  607. #define MMC_RX256TO511OCTETS_GB_HI 0x095c
  608. #define MMC_RX512TO1023OCTETS_GB_LO 0x0960
  609. #define MMC_RX512TO1023OCTETS_GB_HI 0x0964
  610. #define MMC_RX1024TOMAXOCTETS_GB_LO 0x0968
  611. #define MMC_RX1024TOMAXOCTETS_GB_HI 0x096c
  612. #define MMC_RXUNICASTFRAMES_G_LO 0x0970
  613. #define MMC_RXUNICASTFRAMES_G_HI 0x0974
  614. #define MMC_RXLENGTHERROR_LO 0x0978
  615. #define MMC_RXLENGTHERROR_HI 0x097c
  616. #define MMC_RXOUTOFRANGETYPE_LO 0x0980
  617. #define MMC_RXOUTOFRANGETYPE_HI 0x0984
  618. #define MMC_RXPAUSEFRAMES_LO 0x0988
  619. #define MMC_RXPAUSEFRAMES_HI 0x098c
  620. #define MMC_RXFIFOOVERFLOW_LO 0x0990
  621. #define MMC_RXFIFOOVERFLOW_HI 0x0994
  622. #define MMC_RXVLANFRAMES_GB_LO 0x0998
  623. #define MMC_RXVLANFRAMES_GB_HI 0x099c
  624. #define MMC_RXWATCHDOGERROR 0x09a0
  625. /* MMC register entry bit positions and sizes */
  626. #define MMC_CR_CR_INDEX 0
  627. #define MMC_CR_CR_WIDTH 1
  628. #define MMC_CR_CSR_INDEX 1
  629. #define MMC_CR_CSR_WIDTH 1
  630. #define MMC_CR_ROR_INDEX 2
  631. #define MMC_CR_ROR_WIDTH 1
  632. #define MMC_CR_MCF_INDEX 3
  633. #define MMC_CR_MCF_WIDTH 1
  634. #define MMC_CR_MCT_INDEX 4
  635. #define MMC_CR_MCT_WIDTH 2
  636. #define MMC_RIER_ALL_INTERRUPTS_INDEX 0
  637. #define MMC_RIER_ALL_INTERRUPTS_WIDTH 23
  638. #define MMC_RISR_RXFRAMECOUNT_GB_INDEX 0
  639. #define MMC_RISR_RXFRAMECOUNT_GB_WIDTH 1
  640. #define MMC_RISR_RXOCTETCOUNT_GB_INDEX 1
  641. #define MMC_RISR_RXOCTETCOUNT_GB_WIDTH 1
  642. #define MMC_RISR_RXOCTETCOUNT_G_INDEX 2
  643. #define MMC_RISR_RXOCTETCOUNT_G_WIDTH 1
  644. #define MMC_RISR_RXBROADCASTFRAMES_G_INDEX 3
  645. #define MMC_RISR_RXBROADCASTFRAMES_G_WIDTH 1
  646. #define MMC_RISR_RXMULTICASTFRAMES_G_INDEX 4
  647. #define MMC_RISR_RXMULTICASTFRAMES_G_WIDTH 1
  648. #define MMC_RISR_RXCRCERROR_INDEX 5
  649. #define MMC_RISR_RXCRCERROR_WIDTH 1
  650. #define MMC_RISR_RXRUNTERROR_INDEX 6
  651. #define MMC_RISR_RXRUNTERROR_WIDTH 1
  652. #define MMC_RISR_RXJABBERERROR_INDEX 7
  653. #define MMC_RISR_RXJABBERERROR_WIDTH 1
  654. #define MMC_RISR_RXUNDERSIZE_G_INDEX 8
  655. #define MMC_RISR_RXUNDERSIZE_G_WIDTH 1
  656. #define MMC_RISR_RXOVERSIZE_G_INDEX 9
  657. #define MMC_RISR_RXOVERSIZE_G_WIDTH 1
  658. #define MMC_RISR_RX64OCTETS_GB_INDEX 10
  659. #define MMC_RISR_RX64OCTETS_GB_WIDTH 1
  660. #define MMC_RISR_RX65TO127OCTETS_GB_INDEX 11
  661. #define MMC_RISR_RX65TO127OCTETS_GB_WIDTH 1
  662. #define MMC_RISR_RX128TO255OCTETS_GB_INDEX 12
  663. #define MMC_RISR_RX128TO255OCTETS_GB_WIDTH 1
  664. #define MMC_RISR_RX256TO511OCTETS_GB_INDEX 13
  665. #define MMC_RISR_RX256TO511OCTETS_GB_WIDTH 1
  666. #define MMC_RISR_RX512TO1023OCTETS_GB_INDEX 14
  667. #define MMC_RISR_RX512TO1023OCTETS_GB_WIDTH 1
  668. #define MMC_RISR_RX1024TOMAXOCTETS_GB_INDEX 15
  669. #define MMC_RISR_RX1024TOMAXOCTETS_GB_WIDTH 1
  670. #define MMC_RISR_RXUNICASTFRAMES_G_INDEX 16
  671. #define MMC_RISR_RXUNICASTFRAMES_G_WIDTH 1
  672. #define MMC_RISR_RXLENGTHERROR_INDEX 17
  673. #define MMC_RISR_RXLENGTHERROR_WIDTH 1
  674. #define MMC_RISR_RXOUTOFRANGETYPE_INDEX 18
  675. #define MMC_RISR_RXOUTOFRANGETYPE_WIDTH 1
  676. #define MMC_RISR_RXPAUSEFRAMES_INDEX 19
  677. #define MMC_RISR_RXPAUSEFRAMES_WIDTH 1
  678. #define MMC_RISR_RXFIFOOVERFLOW_INDEX 20
  679. #define MMC_RISR_RXFIFOOVERFLOW_WIDTH 1
  680. #define MMC_RISR_RXVLANFRAMES_GB_INDEX 21
  681. #define MMC_RISR_RXVLANFRAMES_GB_WIDTH 1
  682. #define MMC_RISR_RXWATCHDOGERROR_INDEX 22
  683. #define MMC_RISR_RXWATCHDOGERROR_WIDTH 1
  684. #define MMC_TIER_ALL_INTERRUPTS_INDEX 0
  685. #define MMC_TIER_ALL_INTERRUPTS_WIDTH 18
  686. #define MMC_TISR_TXOCTETCOUNT_GB_INDEX 0
  687. #define MMC_TISR_TXOCTETCOUNT_GB_WIDTH 1
  688. #define MMC_TISR_TXFRAMECOUNT_GB_INDEX 1
  689. #define MMC_TISR_TXFRAMECOUNT_GB_WIDTH 1
  690. #define MMC_TISR_TXBROADCASTFRAMES_G_INDEX 2
  691. #define MMC_TISR_TXBROADCASTFRAMES_G_WIDTH 1
  692. #define MMC_TISR_TXMULTICASTFRAMES_G_INDEX 3
  693. #define MMC_TISR_TXMULTICASTFRAMES_G_WIDTH 1
  694. #define MMC_TISR_TX64OCTETS_GB_INDEX 4
  695. #define MMC_TISR_TX64OCTETS_GB_WIDTH 1
  696. #define MMC_TISR_TX65TO127OCTETS_GB_INDEX 5
  697. #define MMC_TISR_TX65TO127OCTETS_GB_WIDTH 1
  698. #define MMC_TISR_TX128TO255OCTETS_GB_INDEX 6
  699. #define MMC_TISR_TX128TO255OCTETS_GB_WIDTH 1
  700. #define MMC_TISR_TX256TO511OCTETS_GB_INDEX 7
  701. #define MMC_TISR_TX256TO511OCTETS_GB_WIDTH 1
  702. #define MMC_TISR_TX512TO1023OCTETS_GB_INDEX 8
  703. #define MMC_TISR_TX512TO1023OCTETS_GB_WIDTH 1
  704. #define MMC_TISR_TX1024TOMAXOCTETS_GB_INDEX 9
  705. #define MMC_TISR_TX1024TOMAXOCTETS_GB_WIDTH 1
  706. #define MMC_TISR_TXUNICASTFRAMES_GB_INDEX 10
  707. #define MMC_TISR_TXUNICASTFRAMES_GB_WIDTH 1
  708. #define MMC_TISR_TXMULTICASTFRAMES_GB_INDEX 11
  709. #define MMC_TISR_TXMULTICASTFRAMES_GB_WIDTH 1
  710. #define MMC_TISR_TXBROADCASTFRAMES_GB_INDEX 12
  711. #define MMC_TISR_TXBROADCASTFRAMES_GB_WIDTH 1
  712. #define MMC_TISR_TXUNDERFLOWERROR_INDEX 13
  713. #define MMC_TISR_TXUNDERFLOWERROR_WIDTH 1
  714. #define MMC_TISR_TXOCTETCOUNT_G_INDEX 14
  715. #define MMC_TISR_TXOCTETCOUNT_G_WIDTH 1
  716. #define MMC_TISR_TXFRAMECOUNT_G_INDEX 15
  717. #define MMC_TISR_TXFRAMECOUNT_G_WIDTH 1
  718. #define MMC_TISR_TXPAUSEFRAMES_INDEX 16
  719. #define MMC_TISR_TXPAUSEFRAMES_WIDTH 1
  720. #define MMC_TISR_TXVLANFRAMES_G_INDEX 17
  721. #define MMC_TISR_TXVLANFRAMES_G_WIDTH 1
  722. /* MTL register offsets */
  723. #define MTL_OMR 0x1000
  724. #define MTL_FDCR 0x1008
  725. #define MTL_FDSR 0x100c
  726. #define MTL_FDDR 0x1010
  727. #define MTL_ISR 0x1020
  728. #define MTL_RQDCM0R 0x1030
  729. #define MTL_TCPM0R 0x1040
  730. #define MTL_TCPM1R 0x1044
  731. #define MTL_RQDCM_INC 4
  732. #define MTL_RQDCM_Q_PER_REG 4
  733. #define MTL_TCPM_INC 4
  734. #define MTL_TCPM_TC_PER_REG 4
  735. /* MTL register entry bit positions and sizes */
  736. #define MTL_OMR_ETSALG_INDEX 5
  737. #define MTL_OMR_ETSALG_WIDTH 2
  738. #define MTL_OMR_RAA_INDEX 2
  739. #define MTL_OMR_RAA_WIDTH 1
  740. /* MTL queue register offsets
  741. * Multiple queues can be active. The first queue has registers
  742. * that begin at 0x1100. Each subsequent queue has registers that
  743. * are accessed using an offset of 0x80 from the previous queue.
  744. */
  745. #define MTL_Q_BASE 0x1100
  746. #define MTL_Q_INC 0x80
  747. #define MTL_Q_TQOMR 0x00
  748. #define MTL_Q_TQUR 0x04
  749. #define MTL_Q_TQDR 0x08
  750. #define MTL_Q_RQOMR 0x40
  751. #define MTL_Q_RQMPOCR 0x44
  752. #define MTL_Q_RQDR 0x4c
  753. #define MTL_Q_RQFCR 0x50
  754. #define MTL_Q_IER 0x70
  755. #define MTL_Q_ISR 0x74
  756. /* MTL queue register entry bit positions and sizes */
  757. #define MTL_Q_RQFCR_RFA_INDEX 1
  758. #define MTL_Q_RQFCR_RFA_WIDTH 6
  759. #define MTL_Q_RQFCR_RFD_INDEX 17
  760. #define MTL_Q_RQFCR_RFD_WIDTH 6
  761. #define MTL_Q_RQOMR_EHFC_INDEX 7
  762. #define MTL_Q_RQOMR_EHFC_WIDTH 1
  763. #define MTL_Q_RQOMR_RQS_INDEX 16
  764. #define MTL_Q_RQOMR_RQS_WIDTH 9
  765. #define MTL_Q_RQOMR_RSF_INDEX 5
  766. #define MTL_Q_RQOMR_RSF_WIDTH 1
  767. #define MTL_Q_RQOMR_RTC_INDEX 0
  768. #define MTL_Q_RQOMR_RTC_WIDTH 2
  769. #define MTL_Q_TQOMR_FTQ_INDEX 0
  770. #define MTL_Q_TQOMR_FTQ_WIDTH 1
  771. #define MTL_Q_TQOMR_Q2TCMAP_INDEX 8
  772. #define MTL_Q_TQOMR_Q2TCMAP_WIDTH 3
  773. #define MTL_Q_TQOMR_TQS_INDEX 16
  774. #define MTL_Q_TQOMR_TQS_WIDTH 10
  775. #define MTL_Q_TQOMR_TSF_INDEX 1
  776. #define MTL_Q_TQOMR_TSF_WIDTH 1
  777. #define MTL_Q_TQOMR_TTC_INDEX 4
  778. #define MTL_Q_TQOMR_TTC_WIDTH 3
  779. #define MTL_Q_TQOMR_TXQEN_INDEX 2
  780. #define MTL_Q_TQOMR_TXQEN_WIDTH 2
  781. /* MTL queue register value */
  782. #define MTL_RSF_DISABLE 0x00
  783. #define MTL_RSF_ENABLE 0x01
  784. #define MTL_TSF_DISABLE 0x00
  785. #define MTL_TSF_ENABLE 0x01
  786. #define MTL_RX_THRESHOLD_64 0x00
  787. #define MTL_RX_THRESHOLD_96 0x02
  788. #define MTL_RX_THRESHOLD_128 0x03
  789. #define MTL_TX_THRESHOLD_32 0x01
  790. #define MTL_TX_THRESHOLD_64 0x00
  791. #define MTL_TX_THRESHOLD_96 0x02
  792. #define MTL_TX_THRESHOLD_128 0x03
  793. #define MTL_TX_THRESHOLD_192 0x04
  794. #define MTL_TX_THRESHOLD_256 0x05
  795. #define MTL_TX_THRESHOLD_384 0x06
  796. #define MTL_TX_THRESHOLD_512 0x07
  797. #define MTL_ETSALG_WRR 0x00
  798. #define MTL_ETSALG_WFQ 0x01
  799. #define MTL_ETSALG_DWRR 0x02
  800. #define MTL_RAA_SP 0x00
  801. #define MTL_RAA_WSP 0x01
  802. #define MTL_Q_DISABLED 0x00
  803. #define MTL_Q_ENABLED 0x02
  804. /* MTL traffic class register offsets
  805. * Multiple traffic classes can be active. The first class has registers
  806. * that begin at 0x1100. Each subsequent queue has registers that
  807. * are accessed using an offset of 0x80 from the previous queue.
  808. */
  809. #define MTL_TC_BASE MTL_Q_BASE
  810. #define MTL_TC_INC MTL_Q_INC
  811. #define MTL_TC_ETSCR 0x10
  812. #define MTL_TC_ETSSR 0x14
  813. #define MTL_TC_QWR 0x18
  814. /* MTL traffic class register entry bit positions and sizes */
  815. #define MTL_TC_ETSCR_TSA_INDEX 0
  816. #define MTL_TC_ETSCR_TSA_WIDTH 2
  817. #define MTL_TC_QWR_QW_INDEX 0
  818. #define MTL_TC_QWR_QW_WIDTH 21
  819. /* MTL traffic class register value */
  820. #define MTL_TSA_SP 0x00
  821. #define MTL_TSA_ETS 0x02
  822. /* PCS MMD select register offset
  823. * The MMD select register is used for accessing PCS registers
  824. * when the underlying APB3 interface is using indirect addressing.
  825. * Indirect addressing requires accessing registers in two phases,
  826. * an address phase and a data phase. The address phases requires
  827. * writing an address selection value to the MMD select regiesters.
  828. */
  829. #define PCS_MMD_SELECT 0xff
  830. /* SerDes integration register offsets */
  831. #define SIR0_KR_RT_1 0x002c
  832. #define SIR0_STATUS 0x0040
  833. #define SIR1_SPEED 0x0000
  834. /* SerDes integration register entry bit positions and sizes */
  835. #define SIR0_KR_RT_1_RESET_INDEX 11
  836. #define SIR0_KR_RT_1_RESET_WIDTH 1
  837. #define SIR0_STATUS_RX_READY_INDEX 0
  838. #define SIR0_STATUS_RX_READY_WIDTH 1
  839. #define SIR0_STATUS_TX_READY_INDEX 8
  840. #define SIR0_STATUS_TX_READY_WIDTH 1
  841. #define SIR1_SPEED_CDR_RATE_INDEX 12
  842. #define SIR1_SPEED_CDR_RATE_WIDTH 4
  843. #define SIR1_SPEED_DATARATE_INDEX 4
  844. #define SIR1_SPEED_DATARATE_WIDTH 2
  845. #define SIR1_SPEED_PLLSEL_INDEX 3
  846. #define SIR1_SPEED_PLLSEL_WIDTH 1
  847. #define SIR1_SPEED_RATECHANGE_INDEX 6
  848. #define SIR1_SPEED_RATECHANGE_WIDTH 1
  849. #define SIR1_SPEED_TXAMP_INDEX 8
  850. #define SIR1_SPEED_TXAMP_WIDTH 4
  851. #define SIR1_SPEED_WORDMODE_INDEX 0
  852. #define SIR1_SPEED_WORDMODE_WIDTH 3
  853. /* SerDes RxTx register offsets */
  854. #define RXTX_REG6 0x0018
  855. #define RXTX_REG20 0x0050
  856. #define RXTX_REG22 0x0058
  857. #define RXTX_REG114 0x01c8
  858. #define RXTX_REG129 0x0204
  859. /* SerDes RxTx register entry bit positions and sizes */
  860. #define RXTX_REG6_RESETB_RXD_INDEX 8
  861. #define RXTX_REG6_RESETB_RXD_WIDTH 1
  862. #define RXTX_REG20_BLWC_ENA_INDEX 2
  863. #define RXTX_REG20_BLWC_ENA_WIDTH 1
  864. #define RXTX_REG114_PQ_REG_INDEX 9
  865. #define RXTX_REG114_PQ_REG_WIDTH 7
  866. #define RXTX_REG129_RXDFE_CONFIG_INDEX 14
  867. #define RXTX_REG129_RXDFE_CONFIG_WIDTH 2
  868. /* Descriptor/Packet entry bit positions and sizes */
  869. #define RX_PACKET_ERRORS_CRC_INDEX 2
  870. #define RX_PACKET_ERRORS_CRC_WIDTH 1
  871. #define RX_PACKET_ERRORS_FRAME_INDEX 3
  872. #define RX_PACKET_ERRORS_FRAME_WIDTH 1
  873. #define RX_PACKET_ERRORS_LENGTH_INDEX 0
  874. #define RX_PACKET_ERRORS_LENGTH_WIDTH 1
  875. #define RX_PACKET_ERRORS_OVERRUN_INDEX 1
  876. #define RX_PACKET_ERRORS_OVERRUN_WIDTH 1
  877. #define RX_PACKET_ATTRIBUTES_CSUM_DONE_INDEX 0
  878. #define RX_PACKET_ATTRIBUTES_CSUM_DONE_WIDTH 1
  879. #define RX_PACKET_ATTRIBUTES_VLAN_CTAG_INDEX 1
  880. #define RX_PACKET_ATTRIBUTES_VLAN_CTAG_WIDTH 1
  881. #define RX_PACKET_ATTRIBUTES_LAST_INDEX 2
  882. #define RX_PACKET_ATTRIBUTES_LAST_WIDTH 1
  883. #define RX_PACKET_ATTRIBUTES_CONTEXT_NEXT_INDEX 3
  884. #define RX_PACKET_ATTRIBUTES_CONTEXT_NEXT_WIDTH 1
  885. #define RX_PACKET_ATTRIBUTES_CONTEXT_INDEX 4
  886. #define RX_PACKET_ATTRIBUTES_CONTEXT_WIDTH 1
  887. #define RX_PACKET_ATTRIBUTES_RX_TSTAMP_INDEX 5
  888. #define RX_PACKET_ATTRIBUTES_RX_TSTAMP_WIDTH 1
  889. #define RX_PACKET_ATTRIBUTES_RSS_HASH_INDEX 6
  890. #define RX_PACKET_ATTRIBUTES_RSS_HASH_WIDTH 1
  891. #define RX_PACKET_ATTRIBUTES_FIRST_INDEX 7
  892. #define RX_PACKET_ATTRIBUTES_FIRST_WIDTH 1
  893. #define RX_NORMAL_DESC0_OVT_INDEX 0
  894. #define RX_NORMAL_DESC0_OVT_WIDTH 16
  895. #define RX_NORMAL_DESC2_HL_INDEX 0
  896. #define RX_NORMAL_DESC2_HL_WIDTH 10
  897. #define RX_NORMAL_DESC3_CDA_INDEX 27
  898. #define RX_NORMAL_DESC3_CDA_WIDTH 1
  899. #define RX_NORMAL_DESC3_CTXT_INDEX 30
  900. #define RX_NORMAL_DESC3_CTXT_WIDTH 1
  901. #define RX_NORMAL_DESC3_ES_INDEX 15
  902. #define RX_NORMAL_DESC3_ES_WIDTH 1
  903. #define RX_NORMAL_DESC3_ETLT_INDEX 16
  904. #define RX_NORMAL_DESC3_ETLT_WIDTH 4
  905. #define RX_NORMAL_DESC3_FD_INDEX 29
  906. #define RX_NORMAL_DESC3_FD_WIDTH 1
  907. #define RX_NORMAL_DESC3_INTE_INDEX 30
  908. #define RX_NORMAL_DESC3_INTE_WIDTH 1
  909. #define RX_NORMAL_DESC3_L34T_INDEX 20
  910. #define RX_NORMAL_DESC3_L34T_WIDTH 4
  911. #define RX_NORMAL_DESC3_LD_INDEX 28
  912. #define RX_NORMAL_DESC3_LD_WIDTH 1
  913. #define RX_NORMAL_DESC3_OWN_INDEX 31
  914. #define RX_NORMAL_DESC3_OWN_WIDTH 1
  915. #define RX_NORMAL_DESC3_PL_INDEX 0
  916. #define RX_NORMAL_DESC3_PL_WIDTH 14
  917. #define RX_NORMAL_DESC3_RSV_INDEX 26
  918. #define RX_NORMAL_DESC3_RSV_WIDTH 1
  919. #define RX_DESC3_L34T_IPV4_TCP 1
  920. #define RX_DESC3_L34T_IPV4_UDP 2
  921. #define RX_DESC3_L34T_IPV4_ICMP 3
  922. #define RX_DESC3_L34T_IPV6_TCP 9
  923. #define RX_DESC3_L34T_IPV6_UDP 10
  924. #define RX_DESC3_L34T_IPV6_ICMP 11
  925. #define RX_CONTEXT_DESC3_TSA_INDEX 4
  926. #define RX_CONTEXT_DESC3_TSA_WIDTH 1
  927. #define RX_CONTEXT_DESC3_TSD_INDEX 6
  928. #define RX_CONTEXT_DESC3_TSD_WIDTH 1
  929. #define TX_PACKET_ATTRIBUTES_CSUM_ENABLE_INDEX 0
  930. #define TX_PACKET_ATTRIBUTES_CSUM_ENABLE_WIDTH 1
  931. #define TX_PACKET_ATTRIBUTES_TSO_ENABLE_INDEX 1
  932. #define TX_PACKET_ATTRIBUTES_TSO_ENABLE_WIDTH 1
  933. #define TX_PACKET_ATTRIBUTES_VLAN_CTAG_INDEX 2
  934. #define TX_PACKET_ATTRIBUTES_VLAN_CTAG_WIDTH 1
  935. #define TX_PACKET_ATTRIBUTES_PTP_INDEX 3
  936. #define TX_PACKET_ATTRIBUTES_PTP_WIDTH 1
  937. #define TX_CONTEXT_DESC2_MSS_INDEX 0
  938. #define TX_CONTEXT_DESC2_MSS_WIDTH 15
  939. #define TX_CONTEXT_DESC3_CTXT_INDEX 30
  940. #define TX_CONTEXT_DESC3_CTXT_WIDTH 1
  941. #define TX_CONTEXT_DESC3_TCMSSV_INDEX 26
  942. #define TX_CONTEXT_DESC3_TCMSSV_WIDTH 1
  943. #define TX_CONTEXT_DESC3_VLTV_INDEX 16
  944. #define TX_CONTEXT_DESC3_VLTV_WIDTH 1
  945. #define TX_CONTEXT_DESC3_VT_INDEX 0
  946. #define TX_CONTEXT_DESC3_VT_WIDTH 16
  947. #define TX_NORMAL_DESC2_HL_B1L_INDEX 0
  948. #define TX_NORMAL_DESC2_HL_B1L_WIDTH 14
  949. #define TX_NORMAL_DESC2_IC_INDEX 31
  950. #define TX_NORMAL_DESC2_IC_WIDTH 1
  951. #define TX_NORMAL_DESC2_TTSE_INDEX 30
  952. #define TX_NORMAL_DESC2_TTSE_WIDTH 1
  953. #define TX_NORMAL_DESC2_VTIR_INDEX 14
  954. #define TX_NORMAL_DESC2_VTIR_WIDTH 2
  955. #define TX_NORMAL_DESC3_CIC_INDEX 16
  956. #define TX_NORMAL_DESC3_CIC_WIDTH 2
  957. #define TX_NORMAL_DESC3_CPC_INDEX 26
  958. #define TX_NORMAL_DESC3_CPC_WIDTH 2
  959. #define TX_NORMAL_DESC3_CTXT_INDEX 30
  960. #define TX_NORMAL_DESC3_CTXT_WIDTH 1
  961. #define TX_NORMAL_DESC3_FD_INDEX 29
  962. #define TX_NORMAL_DESC3_FD_WIDTH 1
  963. #define TX_NORMAL_DESC3_FL_INDEX 0
  964. #define TX_NORMAL_DESC3_FL_WIDTH 15
  965. #define TX_NORMAL_DESC3_LD_INDEX 28
  966. #define TX_NORMAL_DESC3_LD_WIDTH 1
  967. #define TX_NORMAL_DESC3_OWN_INDEX 31
  968. #define TX_NORMAL_DESC3_OWN_WIDTH 1
  969. #define TX_NORMAL_DESC3_TCPHDRLEN_INDEX 19
  970. #define TX_NORMAL_DESC3_TCPHDRLEN_WIDTH 4
  971. #define TX_NORMAL_DESC3_TCPPL_INDEX 0
  972. #define TX_NORMAL_DESC3_TCPPL_WIDTH 18
  973. #define TX_NORMAL_DESC3_TSE_INDEX 18
  974. #define TX_NORMAL_DESC3_TSE_WIDTH 1
  975. #define TX_NORMAL_DESC2_VLAN_INSERT 0x2
  976. /* MDIO undefined or vendor specific registers */
  977. #ifndef MDIO_PMA_10GBR_PMD_CTRL
  978. #define MDIO_PMA_10GBR_PMD_CTRL 0x0096
  979. #endif
  980. #ifndef MDIO_PMA_10GBR_FECCTRL
  981. #define MDIO_PMA_10GBR_FECCTRL 0x00ab
  982. #endif
  983. #ifndef MDIO_AN_XNP
  984. #define MDIO_AN_XNP 0x0016
  985. #endif
  986. #ifndef MDIO_AN_LPX
  987. #define MDIO_AN_LPX 0x0019
  988. #endif
  989. #ifndef MDIO_AN_COMP_STAT
  990. #define MDIO_AN_COMP_STAT 0x0030
  991. #endif
  992. #ifndef MDIO_AN_INTMASK
  993. #define MDIO_AN_INTMASK 0x8001
  994. #endif
  995. #ifndef MDIO_AN_INT
  996. #define MDIO_AN_INT 0x8002
  997. #endif
  998. #ifndef MDIO_CTRL1_SPEED1G
  999. #define MDIO_CTRL1_SPEED1G (MDIO_CTRL1_SPEED10G & ~BMCR_SPEED100)
  1000. #endif
  1001. /* MDIO mask values */
  1002. #define XGBE_XNP_MCF_NULL_MESSAGE 0x001
  1003. #define XGBE_XNP_ACK_PROCESSED BIT(12)
  1004. #define XGBE_XNP_MP_FORMATTED BIT(13)
  1005. #define XGBE_XNP_NP_EXCHANGE BIT(15)
  1006. #define XGBE_KR_TRAINING_START BIT(0)
  1007. #define XGBE_KR_TRAINING_ENABLE BIT(1)
  1008. /* Bit setting and getting macros
  1009. * The get macro will extract the current bit field value from within
  1010. * the variable
  1011. *
  1012. * The set macro will clear the current bit field value within the
  1013. * variable and then set the bit field of the variable to the
  1014. * specified value
  1015. */
  1016. #define GET_BITS(_var, _index, _width) \
  1017. (((_var) >> (_index)) & ((0x1 << (_width)) - 1))
  1018. #define SET_BITS(_var, _index, _width, _val) \
  1019. do { \
  1020. (_var) &= ~(((0x1 << (_width)) - 1) << (_index)); \
  1021. (_var) |= (((_val) & ((0x1 << (_width)) - 1)) << (_index)); \
  1022. } while (0)
  1023. #define GET_BITS_LE(_var, _index, _width) \
  1024. ((le32_to_cpu((_var)) >> (_index)) & ((0x1 << (_width)) - 1))
  1025. #define SET_BITS_LE(_var, _index, _width, _val) \
  1026. do { \
  1027. (_var) &= cpu_to_le32(~(((0x1 << (_width)) - 1) << (_index))); \
  1028. (_var) |= cpu_to_le32((((_val) & \
  1029. ((0x1 << (_width)) - 1)) << (_index))); \
  1030. } while (0)
  1031. /* Bit setting and getting macros based on register fields
  1032. * The get macro uses the bit field definitions formed using the input
  1033. * names to extract the current bit field value from within the
  1034. * variable
  1035. *
  1036. * The set macro uses the bit field definitions formed using the input
  1037. * names to set the bit field of the variable to the specified value
  1038. */
  1039. #define XGMAC_GET_BITS(_var, _prefix, _field) \
  1040. GET_BITS((_var), \
  1041. _prefix##_##_field##_INDEX, \
  1042. _prefix##_##_field##_WIDTH)
  1043. #define XGMAC_SET_BITS(_var, _prefix, _field, _val) \
  1044. SET_BITS((_var), \
  1045. _prefix##_##_field##_INDEX, \
  1046. _prefix##_##_field##_WIDTH, (_val))
  1047. #define XGMAC_GET_BITS_LE(_var, _prefix, _field) \
  1048. GET_BITS_LE((_var), \
  1049. _prefix##_##_field##_INDEX, \
  1050. _prefix##_##_field##_WIDTH)
  1051. #define XGMAC_SET_BITS_LE(_var, _prefix, _field, _val) \
  1052. SET_BITS_LE((_var), \
  1053. _prefix##_##_field##_INDEX, \
  1054. _prefix##_##_field##_WIDTH, (_val))
  1055. /* Macros for reading or writing registers
  1056. * The ioread macros will get bit fields or full values using the
  1057. * register definitions formed using the input names
  1058. *
  1059. * The iowrite macros will set bit fields or full values using the
  1060. * register definitions formed using the input names
  1061. */
  1062. #define XGMAC_IOREAD(_pdata, _reg) \
  1063. ioread32((_pdata)->xgmac_regs + _reg)
  1064. #define XGMAC_IOREAD_BITS(_pdata, _reg, _field) \
  1065. GET_BITS(XGMAC_IOREAD((_pdata), _reg), \
  1066. _reg##_##_field##_INDEX, \
  1067. _reg##_##_field##_WIDTH)
  1068. #define XGMAC_IOWRITE(_pdata, _reg, _val) \
  1069. iowrite32((_val), (_pdata)->xgmac_regs + _reg)
  1070. #define XGMAC_IOWRITE_BITS(_pdata, _reg, _field, _val) \
  1071. do { \
  1072. u32 reg_val = XGMAC_IOREAD((_pdata), _reg); \
  1073. SET_BITS(reg_val, \
  1074. _reg##_##_field##_INDEX, \
  1075. _reg##_##_field##_WIDTH, (_val)); \
  1076. XGMAC_IOWRITE((_pdata), _reg, reg_val); \
  1077. } while (0)
  1078. /* Macros for reading or writing MTL queue or traffic class registers
  1079. * Similar to the standard read and write macros except that the
  1080. * base register value is calculated by the queue or traffic class number
  1081. */
  1082. #define XGMAC_MTL_IOREAD(_pdata, _n, _reg) \
  1083. ioread32((_pdata)->xgmac_regs + \
  1084. MTL_Q_BASE + ((_n) * MTL_Q_INC) + _reg)
  1085. #define XGMAC_MTL_IOREAD_BITS(_pdata, _n, _reg, _field) \
  1086. GET_BITS(XGMAC_MTL_IOREAD((_pdata), (_n), _reg), \
  1087. _reg##_##_field##_INDEX, \
  1088. _reg##_##_field##_WIDTH)
  1089. #define XGMAC_MTL_IOWRITE(_pdata, _n, _reg, _val) \
  1090. iowrite32((_val), (_pdata)->xgmac_regs + \
  1091. MTL_Q_BASE + ((_n) * MTL_Q_INC) + _reg)
  1092. #define XGMAC_MTL_IOWRITE_BITS(_pdata, _n, _reg, _field, _val) \
  1093. do { \
  1094. u32 reg_val = XGMAC_MTL_IOREAD((_pdata), (_n), _reg); \
  1095. SET_BITS(reg_val, \
  1096. _reg##_##_field##_INDEX, \
  1097. _reg##_##_field##_WIDTH, (_val)); \
  1098. XGMAC_MTL_IOWRITE((_pdata), (_n), _reg, reg_val); \
  1099. } while (0)
  1100. /* Macros for reading or writing DMA channel registers
  1101. * Similar to the standard read and write macros except that the
  1102. * base register value is obtained from the ring
  1103. */
  1104. #define XGMAC_DMA_IOREAD(_channel, _reg) \
  1105. ioread32((_channel)->dma_regs + _reg)
  1106. #define XGMAC_DMA_IOREAD_BITS(_channel, _reg, _field) \
  1107. GET_BITS(XGMAC_DMA_IOREAD((_channel), _reg), \
  1108. _reg##_##_field##_INDEX, \
  1109. _reg##_##_field##_WIDTH)
  1110. #define XGMAC_DMA_IOWRITE(_channel, _reg, _val) \
  1111. iowrite32((_val), (_channel)->dma_regs + _reg)
  1112. #define XGMAC_DMA_IOWRITE_BITS(_channel, _reg, _field, _val) \
  1113. do { \
  1114. u32 reg_val = XGMAC_DMA_IOREAD((_channel), _reg); \
  1115. SET_BITS(reg_val, \
  1116. _reg##_##_field##_INDEX, \
  1117. _reg##_##_field##_WIDTH, (_val)); \
  1118. XGMAC_DMA_IOWRITE((_channel), _reg, reg_val); \
  1119. } while (0)
  1120. /* Macros for building, reading or writing register values or bits
  1121. * within the register values of XPCS registers.
  1122. */
  1123. #define XPCS_IOWRITE(_pdata, _off, _val) \
  1124. iowrite32(_val, (_pdata)->xpcs_regs + (_off))
  1125. #define XPCS_IOREAD(_pdata, _off) \
  1126. ioread32((_pdata)->xpcs_regs + (_off))
  1127. /* Macros for building, reading or writing register values or bits
  1128. * within the register values of SerDes integration registers.
  1129. */
  1130. #define XSIR_GET_BITS(_var, _prefix, _field) \
  1131. GET_BITS((_var), \
  1132. _prefix##_##_field##_INDEX, \
  1133. _prefix##_##_field##_WIDTH)
  1134. #define XSIR_SET_BITS(_var, _prefix, _field, _val) \
  1135. SET_BITS((_var), \
  1136. _prefix##_##_field##_INDEX, \
  1137. _prefix##_##_field##_WIDTH, (_val))
  1138. #define XSIR0_IOREAD(_pdata, _reg) \
  1139. ioread16((_pdata)->sir0_regs + _reg)
  1140. #define XSIR0_IOREAD_BITS(_pdata, _reg, _field) \
  1141. GET_BITS(XSIR0_IOREAD((_pdata), _reg), \
  1142. _reg##_##_field##_INDEX, \
  1143. _reg##_##_field##_WIDTH)
  1144. #define XSIR0_IOWRITE(_pdata, _reg, _val) \
  1145. iowrite16((_val), (_pdata)->sir0_regs + _reg)
  1146. #define XSIR0_IOWRITE_BITS(_pdata, _reg, _field, _val) \
  1147. do { \
  1148. u16 reg_val = XSIR0_IOREAD((_pdata), _reg); \
  1149. SET_BITS(reg_val, \
  1150. _reg##_##_field##_INDEX, \
  1151. _reg##_##_field##_WIDTH, (_val)); \
  1152. XSIR0_IOWRITE((_pdata), _reg, reg_val); \
  1153. } while (0)
  1154. #define XSIR1_IOREAD(_pdata, _reg) \
  1155. ioread16((_pdata)->sir1_regs + _reg)
  1156. #define XSIR1_IOREAD_BITS(_pdata, _reg, _field) \
  1157. GET_BITS(XSIR1_IOREAD((_pdata), _reg), \
  1158. _reg##_##_field##_INDEX, \
  1159. _reg##_##_field##_WIDTH)
  1160. #define XSIR1_IOWRITE(_pdata, _reg, _val) \
  1161. iowrite16((_val), (_pdata)->sir1_regs + _reg)
  1162. #define XSIR1_IOWRITE_BITS(_pdata, _reg, _field, _val) \
  1163. do { \
  1164. u16 reg_val = XSIR1_IOREAD((_pdata), _reg); \
  1165. SET_BITS(reg_val, \
  1166. _reg##_##_field##_INDEX, \
  1167. _reg##_##_field##_WIDTH, (_val)); \
  1168. XSIR1_IOWRITE((_pdata), _reg, reg_val); \
  1169. } while (0)
  1170. /* Macros for building, reading or writing register values or bits
  1171. * within the register values of SerDes RxTx registers.
  1172. */
  1173. #define XRXTX_IOREAD(_pdata, _reg) \
  1174. ioread16((_pdata)->rxtx_regs + _reg)
  1175. #define XRXTX_IOREAD_BITS(_pdata, _reg, _field) \
  1176. GET_BITS(XRXTX_IOREAD((_pdata), _reg), \
  1177. _reg##_##_field##_INDEX, \
  1178. _reg##_##_field##_WIDTH)
  1179. #define XRXTX_IOWRITE(_pdata, _reg, _val) \
  1180. iowrite16((_val), (_pdata)->rxtx_regs + _reg)
  1181. #define XRXTX_IOWRITE_BITS(_pdata, _reg, _field, _val) \
  1182. do { \
  1183. u16 reg_val = XRXTX_IOREAD((_pdata), _reg); \
  1184. SET_BITS(reg_val, \
  1185. _reg##_##_field##_INDEX, \
  1186. _reg##_##_field##_WIDTH, (_val)); \
  1187. XRXTX_IOWRITE((_pdata), _reg, reg_val); \
  1188. } while (0)
  1189. /* Macros for building, reading or writing register values or bits
  1190. * using MDIO. Different from above because of the use of standardized
  1191. * Linux include values. No shifting is performed with the bit
  1192. * operations, everything works on mask values.
  1193. */
  1194. #define XMDIO_READ(_pdata, _mmd, _reg) \
  1195. ((_pdata)->hw_if.read_mmd_regs((_pdata), 0, \
  1196. MII_ADDR_C45 | (_mmd << 16) | ((_reg) & 0xffff)))
  1197. #define XMDIO_READ_BITS(_pdata, _mmd, _reg, _mask) \
  1198. (XMDIO_READ((_pdata), _mmd, _reg) & _mask)
  1199. #define XMDIO_WRITE(_pdata, _mmd, _reg, _val) \
  1200. ((_pdata)->hw_if.write_mmd_regs((_pdata), 0, \
  1201. MII_ADDR_C45 | (_mmd << 16) | ((_reg) & 0xffff), (_val)))
  1202. #define XMDIO_WRITE_BITS(_pdata, _mmd, _reg, _mask, _val) \
  1203. do { \
  1204. u32 mmd_val = XMDIO_READ((_pdata), _mmd, _reg); \
  1205. mmd_val &= ~_mask; \
  1206. mmd_val |= (_val); \
  1207. XMDIO_WRITE((_pdata), _mmd, _reg, mmd_val); \
  1208. } while (0)
  1209. #endif