emac.h 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298
  1. /* SPDX-License-Identifier: GPL-2.0-or-later */
  2. /*
  3. * drivers/net/ethernet/ibm/emac/emac.h
  4. *
  5. * Register definitions for PowerPC 4xx on-chip ethernet contoller
  6. *
  7. * Copyright 2007 Benjamin Herrenschmidt, IBM Corp.
  8. * <[email protected]>
  9. *
  10. * Based on the arch/ppc version of the driver:
  11. *
  12. * Copyright (c) 2004, 2005 Zultys Technologies.
  13. * Eugene Surovegin <[email protected]> or <[email protected]>
  14. *
  15. * Based on original work by
  16. * Matt Porter <[email protected]>
  17. * Armin Kuster <[email protected]>
  18. * Copyright 2002-2004 MontaVista Software Inc.
  19. */
  20. #ifndef __IBM_NEWEMAC_H
  21. #define __IBM_NEWEMAC_H
  22. #include <linux/types.h>
  23. #include <linux/phy.h>
  24. /* EMAC registers Write Access rules */
  25. struct emac_regs {
  26. /* Common registers across all EMAC implementations. */
  27. u32 mr0; /* Special */
  28. u32 mr1; /* Reset */
  29. u32 tmr0; /* Special */
  30. u32 tmr1; /* Special */
  31. u32 rmr; /* Reset */
  32. u32 isr; /* Always */
  33. u32 iser; /* Reset */
  34. u32 iahr; /* Reset, R, T */
  35. u32 ialr; /* Reset, R, T */
  36. u32 vtpid; /* Reset, R, T */
  37. u32 vtci; /* Reset, R, T */
  38. u32 ptr; /* Reset, T */
  39. union {
  40. /* Registers unique to EMAC4 implementations */
  41. struct {
  42. u32 iaht1; /* Reset, R */
  43. u32 iaht2; /* Reset, R */
  44. u32 iaht3; /* Reset, R */
  45. u32 iaht4; /* Reset, R */
  46. u32 gaht1; /* Reset, R */
  47. u32 gaht2; /* Reset, R */
  48. u32 gaht3; /* Reset, R */
  49. u32 gaht4; /* Reset, R */
  50. } emac4;
  51. /* Registers unique to EMAC4SYNC implementations */
  52. struct {
  53. u32 mahr; /* Reset, R, T */
  54. u32 malr; /* Reset, R, T */
  55. u32 mmahr; /* Reset, R, T */
  56. u32 mmalr; /* Reset, R, T */
  57. u32 rsvd0[4];
  58. } emac4sync;
  59. } u0;
  60. /* Common registers across all EMAC implementations. */
  61. u32 lsah;
  62. u32 lsal;
  63. u32 ipgvr; /* Reset, T */
  64. u32 stacr; /* Special */
  65. u32 trtr; /* Special */
  66. u32 rwmr; /* Reset */
  67. u32 octx;
  68. u32 ocrx;
  69. union {
  70. /* Registers unique to EMAC4 implementations */
  71. struct {
  72. u32 ipcr;
  73. } emac4;
  74. /* Registers unique to EMAC4SYNC implementations */
  75. struct {
  76. u32 rsvd1;
  77. u32 revid;
  78. u32 rsvd2[2];
  79. u32 iaht1; /* Reset, R */
  80. u32 iaht2; /* Reset, R */
  81. u32 iaht3; /* Reset, R */
  82. u32 iaht4; /* Reset, R */
  83. u32 iaht5; /* Reset, R */
  84. u32 iaht6; /* Reset, R */
  85. u32 iaht7; /* Reset, R */
  86. u32 iaht8; /* Reset, R */
  87. u32 gaht1; /* Reset, R */
  88. u32 gaht2; /* Reset, R */
  89. u32 gaht3; /* Reset, R */
  90. u32 gaht4; /* Reset, R */
  91. u32 gaht5; /* Reset, R */
  92. u32 gaht6; /* Reset, R */
  93. u32 gaht7; /* Reset, R */
  94. u32 gaht8; /* Reset, R */
  95. u32 tpc; /* Reset, T */
  96. } emac4sync;
  97. } u1;
  98. };
  99. /* EMACx_MR0 */
  100. #define EMAC_MR0_RXI 0x80000000
  101. #define EMAC_MR0_TXI 0x40000000
  102. #define EMAC_MR0_SRST 0x20000000
  103. #define EMAC_MR0_TXE 0x10000000
  104. #define EMAC_MR0_RXE 0x08000000
  105. #define EMAC_MR0_WKE 0x04000000
  106. /* EMACx_MR1 */
  107. #define EMAC_MR1_FDE 0x80000000
  108. #define EMAC_MR1_ILE 0x40000000
  109. #define EMAC_MR1_VLE 0x20000000
  110. #define EMAC_MR1_EIFC 0x10000000
  111. #define EMAC_MR1_APP 0x08000000
  112. #define EMAC_MR1_IST 0x01000000
  113. #define EMAC_MR1_MF_MASK 0x00c00000
  114. #define EMAC_MR1_MF_10 0x00000000
  115. #define EMAC_MR1_MF_100 0x00400000
  116. #define EMAC_MR1_MF_1000 0x00800000
  117. #define EMAC_MR1_MF_1000GPCS 0x00c00000
  118. #define EMAC_MR1_MF_IPPA(id) (((id) & 0x1f) << 6)
  119. #define EMAC_MR1_RFS_4K 0x00300000
  120. #define EMAC_MR1_RFS_16K 0x00000000
  121. #define EMAC_MR1_TFS_2K 0x00080000
  122. #define EMAC_MR1_TR0_MULT 0x00008000
  123. #define EMAC_MR1_JPSM 0x00000000
  124. #define EMAC_MR1_MWSW_001 0x00000000
  125. #define EMAC_MR1_BASE(opb) (EMAC_MR1_TFS_2K | EMAC_MR1_TR0_MULT)
  126. #define EMAC4_MR1_RFS_2K 0x00100000
  127. #define EMAC4_MR1_RFS_4K 0x00180000
  128. #define EMAC4_MR1_RFS_8K 0x00200000
  129. #define EMAC4_MR1_RFS_16K 0x00280000
  130. #define EMAC4_MR1_TFS_2K 0x00020000
  131. #define EMAC4_MR1_TFS_4K 0x00030000
  132. #define EMAC4_MR1_TFS_8K 0x00040000
  133. #define EMAC4_MR1_TFS_16K 0x00050000
  134. #define EMAC4_MR1_TR 0x00008000
  135. #define EMAC4_MR1_MWSW_001 0x00001000
  136. #define EMAC4_MR1_JPSM 0x00000800
  137. #define EMAC4_MR1_OBCI_MASK 0x00000038
  138. #define EMAC4_MR1_OBCI_50 0x00000000
  139. #define EMAC4_MR1_OBCI_66 0x00000008
  140. #define EMAC4_MR1_OBCI_83 0x00000010
  141. #define EMAC4_MR1_OBCI_100 0x00000018
  142. #define EMAC4_MR1_OBCI_100P 0x00000020
  143. #define EMAC4_MR1_OBCI(freq) ((freq) <= 50 ? EMAC4_MR1_OBCI_50 : \
  144. (freq) <= 66 ? EMAC4_MR1_OBCI_66 : \
  145. (freq) <= 83 ? EMAC4_MR1_OBCI_83 : \
  146. (freq) <= 100 ? EMAC4_MR1_OBCI_100 : \
  147. EMAC4_MR1_OBCI_100P)
  148. /* EMACx_TMR0 */
  149. #define EMAC_TMR0_GNP 0x80000000
  150. #define EMAC_TMR0_DEFAULT 0x00000000
  151. #define EMAC4_TMR0_TFAE_2_32 0x00000001
  152. #define EMAC4_TMR0_TFAE_4_64 0x00000002
  153. #define EMAC4_TMR0_TFAE_8_128 0x00000003
  154. #define EMAC4_TMR0_TFAE_16_256 0x00000004
  155. #define EMAC4_TMR0_TFAE_32_512 0x00000005
  156. #define EMAC4_TMR0_TFAE_64_1024 0x00000006
  157. #define EMAC4_TMR0_TFAE_128_2048 0x00000007
  158. #define EMAC4_TMR0_DEFAULT EMAC4_TMR0_TFAE_2_32
  159. #define EMAC_TMR0_XMIT (EMAC_TMR0_GNP | EMAC_TMR0_DEFAULT)
  160. #define EMAC4_TMR0_XMIT (EMAC_TMR0_GNP | EMAC4_TMR0_DEFAULT)
  161. /* EMACx_TMR1 */
  162. #define EMAC_TMR1(l,h) (((l) << 27) | (((h) & 0xff) << 16))
  163. #define EMAC4_TMR1(l,h) (((l) << 27) | (((h) & 0x3ff) << 14))
  164. /* EMACx_RMR */
  165. #define EMAC_RMR_SP 0x80000000
  166. #define EMAC_RMR_SFCS 0x40000000
  167. #define EMAC_RMR_RRP 0x20000000
  168. #define EMAC_RMR_RFP 0x10000000
  169. #define EMAC_RMR_ROP 0x08000000
  170. #define EMAC_RMR_RPIR 0x04000000
  171. #define EMAC_RMR_PPP 0x02000000
  172. #define EMAC_RMR_PME 0x01000000
  173. #define EMAC_RMR_PMME 0x00800000
  174. #define EMAC_RMR_IAE 0x00400000
  175. #define EMAC_RMR_MIAE 0x00200000
  176. #define EMAC_RMR_BAE 0x00100000
  177. #define EMAC_RMR_MAE 0x00080000
  178. #define EMAC_RMR_BASE 0x00000000
  179. #define EMAC4_RMR_RFAF_2_32 0x00000001
  180. #define EMAC4_RMR_RFAF_4_64 0x00000002
  181. #define EMAC4_RMR_RFAF_8_128 0x00000003
  182. #define EMAC4_RMR_RFAF_16_256 0x00000004
  183. #define EMAC4_RMR_RFAF_32_512 0x00000005
  184. #define EMAC4_RMR_RFAF_64_1024 0x00000006
  185. #define EMAC4_RMR_RFAF_128_2048 0x00000007
  186. #define EMAC4_RMR_BASE EMAC4_RMR_RFAF_128_2048
  187. #define EMAC4_RMR_MJS_MASK 0x0001fff8
  188. #define EMAC4_RMR_MJS(s) (((s) << 3) & EMAC4_RMR_MJS_MASK)
  189. /* EMACx_ISR & EMACx_ISER */
  190. #define EMAC4_ISR_TXPE 0x20000000
  191. #define EMAC4_ISR_RXPE 0x10000000
  192. #define EMAC4_ISR_TXUE 0x08000000
  193. #define EMAC4_ISR_RXOE 0x04000000
  194. #define EMAC_ISR_OVR 0x02000000
  195. #define EMAC_ISR_PP 0x01000000
  196. #define EMAC_ISR_BP 0x00800000
  197. #define EMAC_ISR_RP 0x00400000
  198. #define EMAC_ISR_SE 0x00200000
  199. #define EMAC_ISR_ALE 0x00100000
  200. #define EMAC_ISR_BFCS 0x00080000
  201. #define EMAC_ISR_PTLE 0x00040000
  202. #define EMAC_ISR_ORE 0x00020000
  203. #define EMAC_ISR_IRE 0x00010000
  204. #define EMAC_ISR_SQE 0x00000080
  205. #define EMAC_ISR_TE 0x00000040
  206. #define EMAC_ISR_MOS 0x00000002
  207. #define EMAC_ISR_MOF 0x00000001
  208. /* EMACx_STACR */
  209. #define EMAC_STACR_PHYD_MASK 0xffff
  210. #define EMAC_STACR_PHYD_SHIFT 16
  211. #define EMAC_STACR_OC 0x00008000
  212. #define EMAC_STACR_PHYE 0x00004000
  213. #define EMAC_STACR_STAC_MASK 0x00003000
  214. #define EMAC_STACR_STAC_READ 0x00001000
  215. #define EMAC_STACR_STAC_WRITE 0x00002000
  216. #define EMAC_STACR_OPBC_MASK 0x00000C00
  217. #define EMAC_STACR_OPBC_50 0x00000000
  218. #define EMAC_STACR_OPBC_66 0x00000400
  219. #define EMAC_STACR_OPBC_83 0x00000800
  220. #define EMAC_STACR_OPBC_100 0x00000C00
  221. #define EMAC_STACR_OPBC(freq) ((freq) <= 50 ? EMAC_STACR_OPBC_50 : \
  222. (freq) <= 66 ? EMAC_STACR_OPBC_66 : \
  223. (freq) <= 83 ? EMAC_STACR_OPBC_83 : EMAC_STACR_OPBC_100)
  224. #define EMAC_STACR_BASE(opb) EMAC_STACR_OPBC(opb)
  225. #define EMAC4_STACR_BASE(opb) 0x00000000
  226. #define EMAC_STACR_PCDA_MASK 0x1f
  227. #define EMAC_STACR_PCDA_SHIFT 5
  228. #define EMAC_STACR_PRA_MASK 0x1f
  229. #define EMACX_STACR_STAC_MASK 0x00003800
  230. #define EMACX_STACR_STAC_READ 0x00001000
  231. #define EMACX_STACR_STAC_WRITE 0x00000800
  232. #define EMACX_STACR_STAC_IND_ADDR 0x00002000
  233. #define EMACX_STACR_STAC_IND_READ 0x00003800
  234. #define EMACX_STACR_STAC_IND_READINC 0x00003000
  235. #define EMACX_STACR_STAC_IND_WRITE 0x00002800
  236. /* EMACx_TRTR */
  237. #define EMAC_TRTR_SHIFT_EMAC4 24
  238. #define EMAC_TRTR_SHIFT 27
  239. /* EMAC specific TX descriptor control fields (write access) */
  240. #define EMAC_TX_CTRL_GFCS 0x0200
  241. #define EMAC_TX_CTRL_GP 0x0100
  242. #define EMAC_TX_CTRL_ISA 0x0080
  243. #define EMAC_TX_CTRL_RSA 0x0040
  244. #define EMAC_TX_CTRL_IVT 0x0020
  245. #define EMAC_TX_CTRL_RVT 0x0010
  246. #define EMAC_TX_CTRL_TAH_CSUM 0x000e
  247. /* EMAC specific TX descriptor status fields (read access) */
  248. #define EMAC_TX_ST_BFCS 0x0200
  249. #define EMAC_TX_ST_LCS 0x0080
  250. #define EMAC_TX_ST_ED 0x0040
  251. #define EMAC_TX_ST_EC 0x0020
  252. #define EMAC_TX_ST_LC 0x0010
  253. #define EMAC_TX_ST_MC 0x0008
  254. #define EMAC_TX_ST_SC 0x0004
  255. #define EMAC_TX_ST_UR 0x0002
  256. #define EMAC_TX_ST_SQE 0x0001
  257. #define EMAC_IS_BAD_TX (EMAC_TX_ST_LCS | EMAC_TX_ST_ED | \
  258. EMAC_TX_ST_EC | EMAC_TX_ST_LC | \
  259. EMAC_TX_ST_MC | EMAC_TX_ST_UR)
  260. #define EMAC_IS_BAD_TX_TAH (EMAC_TX_ST_LCS | EMAC_TX_ST_ED | \
  261. EMAC_TX_ST_EC | EMAC_TX_ST_LC)
  262. /* EMAC specific RX descriptor status fields (read access) */
  263. #define EMAC_RX_ST_OE 0x0200
  264. #define EMAC_RX_ST_PP 0x0100
  265. #define EMAC_RX_ST_BP 0x0080
  266. #define EMAC_RX_ST_RP 0x0040
  267. #define EMAC_RX_ST_SE 0x0020
  268. #define EMAC_RX_ST_AE 0x0010
  269. #define EMAC_RX_ST_BFCS 0x0008
  270. #define EMAC_RX_ST_PTL 0x0004
  271. #define EMAC_RX_ST_ORE 0x0002
  272. #define EMAC_RX_ST_IRE 0x0001
  273. #define EMAC_RX_TAH_BAD_CSUM 0x0003
  274. #define EMAC_BAD_RX_MASK (EMAC_RX_ST_OE | EMAC_RX_ST_BP | \
  275. EMAC_RX_ST_RP | EMAC_RX_ST_SE | \
  276. EMAC_RX_ST_AE | EMAC_RX_ST_BFCS | \
  277. EMAC_RX_ST_PTL | EMAC_RX_ST_ORE | \
  278. EMAC_RX_ST_IRE )
  279. #endif /* __IBM_NEWEMAC_H */