ibm_emac.h 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330
  1. /*
  2. * drivers/net/ibm_emac/ibm_emac.h
  3. *
  4. * Register definitions for PowerPC 4xx on-chip ethernet contoller
  5. *
  6. * Copyright (c) 2004, 2005 Zultys Technologies.
  7. * Eugene Surovegin <eugene.surovegin@zultys.com> or <ebs@ebshome.net>
  8. *
  9. * Based on original work by
  10. * Matt Porter <mporter@kernel.crashing.org>
  11. * Armin Kuster <akuster@mvista.com>
  12. * Copyright 2002-2004 MontaVista Software Inc.
  13. *
  14. * This program is free software; you can redistribute it and/or modify it
  15. * under the terms of the GNU General Public License as published by the
  16. * Free Software Foundation; either version 2 of the License, or (at your
  17. * option) any later version.
  18. *
  19. */
  20. #ifndef __IBM_EMAC_H_
  21. #define __IBM_EMAC_H_
  22. #include <linux/config.h>
  23. #include <linux/types.h>
  24. /* This is a simple check to prevent use of this driver on non-tested SoCs */
  25. #if !defined(CONFIG_405GP) && !defined(CONFIG_405GPR) && !defined(CONFIG_405EP) && \
  26. !defined(CONFIG_440GP) && !defined(CONFIG_440GX) && !defined(CONFIG_440SP) && \
  27. !defined(CONFIG_440EP) && !defined(CONFIG_NP405H) && !defined(CONFIG_440SPE) && \
  28. !defined(CONFIG_440GR)
  29. #error "Unknown SoC. Please, check chip user manual and make sure EMAC defines are OK"
  30. #endif
  31. /* EMAC registers Write Access rules */
  32. struct emac_regs {
  33. u32 mr0; /* special */
  34. u32 mr1; /* Reset */
  35. u32 tmr0; /* special */
  36. u32 tmr1; /* special */
  37. u32 rmr; /* Reset */
  38. u32 isr; /* Always */
  39. u32 iser; /* Reset */
  40. u32 iahr; /* Reset, R, T */
  41. u32 ialr; /* Reset, R, T */
  42. u32 vtpid; /* Reset, R, T */
  43. u32 vtci; /* Reset, R, T */
  44. u32 ptr; /* Reset, T */
  45. u32 iaht1; /* Reset, R */
  46. u32 iaht2; /* Reset, R */
  47. u32 iaht3; /* Reset, R */
  48. u32 iaht4; /* Reset, R */
  49. u32 gaht1; /* Reset, R */
  50. u32 gaht2; /* Reset, R */
  51. u32 gaht3; /* Reset, R */
  52. u32 gaht4; /* Reset, R */
  53. u32 lsah;
  54. u32 lsal;
  55. u32 ipgvr; /* Reset, T */
  56. u32 stacr; /* special */
  57. u32 trtr; /* special */
  58. u32 rwmr; /* Reset */
  59. u32 octx;
  60. u32 ocrx;
  61. u32 ipcr;
  62. };
  63. #if !defined(CONFIG_IBM_EMAC4)
  64. #define EMAC_ETHTOOL_REGS_VER 0
  65. #define EMAC_ETHTOOL_REGS_SIZE (sizeof(struct emac_regs) - sizeof(u32))
  66. #else
  67. #define EMAC_ETHTOOL_REGS_VER 1
  68. #define EMAC_ETHTOOL_REGS_SIZE sizeof(struct emac_regs)
  69. #endif
  70. /* EMACx_MR0 */
  71. #define EMAC_MR0_RXI 0x80000000
  72. #define EMAC_MR0_TXI 0x40000000
  73. #define EMAC_MR0_SRST 0x20000000
  74. #define EMAC_MR0_TXE 0x10000000
  75. #define EMAC_MR0_RXE 0x08000000
  76. #define EMAC_MR0_WKE 0x04000000
  77. /* EMACx_MR1 */
  78. #define EMAC_MR1_FDE 0x80000000
  79. #define EMAC_MR1_ILE 0x40000000
  80. #define EMAC_MR1_VLE 0x20000000
  81. #define EMAC_MR1_EIFC 0x10000000
  82. #define EMAC_MR1_APP 0x08000000
  83. #define EMAC_MR1_IST 0x01000000
  84. #define EMAC_MR1_MF_MASK 0x00c00000
  85. #define EMAC_MR1_MF_10 0x00000000
  86. #define EMAC_MR1_MF_100 0x00400000
  87. #if !defined(CONFIG_IBM_EMAC4)
  88. #define EMAC_MR1_MF_1000 0x00000000
  89. #define EMAC_MR1_MF_1000GPCS 0x00000000
  90. #define EMAC_MR1_MF_IPPA(id) 0x00000000
  91. #else
  92. #define EMAC_MR1_MF_1000 0x00800000
  93. #define EMAC_MR1_MF_1000GPCS 0x00c00000
  94. #define EMAC_MR1_MF_IPPA(id) (((id) & 0x1f) << 6)
  95. #endif
  96. #define EMAC_TX_FIFO_SIZE 2048
  97. #if !defined(CONFIG_IBM_EMAC4)
  98. #define EMAC_MR1_RFS_4K 0x00300000
  99. #define EMAC_MR1_RFS_16K 0x00000000
  100. #define EMAC_RX_FIFO_SIZE(gige) 4096
  101. #define EMAC_MR1_TFS_2K 0x00080000
  102. #define EMAC_MR1_TR0_MULT 0x00008000
  103. #define EMAC_MR1_JPSM 0x00000000
  104. #define EMAC_MR1_MWSW_001 0x00000000
  105. #define EMAC_MR1_BASE(opb) (EMAC_MR1_TFS_2K | EMAC_MR1_TR0_MULT)
  106. #else
  107. #define EMAC_MR1_RFS_4K 0x00180000
  108. #define EMAC_MR1_RFS_16K 0x00280000
  109. #define EMAC_RX_FIFO_SIZE(gige) ((gige) ? 16384 : 4096)
  110. #define EMAC_MR1_TFS_2K 0x00020000
  111. #define EMAC_MR1_TR 0x00008000
  112. #define EMAC_MR1_MWSW_001 0x00001000
  113. #define EMAC_MR1_JPSM 0x00000800
  114. #define EMAC_MR1_OBCI_MASK 0x00000038
  115. #define EMAC_MR1_OBCI_50 0x00000000
  116. #define EMAC_MR1_OBCI_66 0x00000008
  117. #define EMAC_MR1_OBCI_83 0x00000010
  118. #define EMAC_MR1_OBCI_100 0x00000018
  119. #define EMAC_MR1_OBCI_100P 0x00000020
  120. #define EMAC_MR1_OBCI(freq) ((freq) <= 50 ? EMAC_MR1_OBCI_50 : \
  121. (freq) <= 66 ? EMAC_MR1_OBCI_66 : \
  122. (freq) <= 83 ? EMAC_MR1_OBCI_83 : \
  123. (freq) <= 100 ? EMAC_MR1_OBCI_100 : EMAC_MR1_OBCI_100P)
  124. #define EMAC_MR1_BASE(opb) (EMAC_MR1_TFS_2K | EMAC_MR1_TR | \
  125. EMAC_MR1_OBCI(opb))
  126. #endif
  127. /* EMACx_TMR0 */
  128. #define EMAC_TMR0_GNP 0x80000000
  129. #if !defined(CONFIG_IBM_EMAC4)
  130. #define EMAC_TMR0_DEFAULT 0x00000000
  131. #else
  132. #define EMAC_TMR0_TFAE_2_32 0x00000001
  133. #define EMAC_TMR0_TFAE_4_64 0x00000002
  134. #define EMAC_TMR0_TFAE_8_128 0x00000003
  135. #define EMAC_TMR0_TFAE_16_256 0x00000004
  136. #define EMAC_TMR0_TFAE_32_512 0x00000005
  137. #define EMAC_TMR0_TFAE_64_1024 0x00000006
  138. #define EMAC_TMR0_TFAE_128_2048 0x00000007
  139. #define EMAC_TMR0_DEFAULT EMAC_TMR0_TFAE_2_32
  140. #endif
  141. #define EMAC_TMR0_XMIT (EMAC_TMR0_GNP | EMAC_TMR0_DEFAULT)
  142. /* EMACx_TMR1 */
  143. /* IBM manuals are not very clear here.
  144. * This is my interpretation of how things are. --ebs
  145. */
  146. #if defined(CONFIG_40x)
  147. #define EMAC_FIFO_ENTRY_SIZE 8
  148. #define EMAC_MAL_BURST_SIZE (16 * 4)
  149. #else
  150. #define EMAC_FIFO_ENTRY_SIZE 16
  151. #define EMAC_MAL_BURST_SIZE (64 * 4)
  152. #endif
  153. #if !defined(CONFIG_IBM_EMAC4)
  154. #define EMAC_TMR1(l,h) (((l) << 27) | (((h) & 0xff) << 16))
  155. #else
  156. #define EMAC_TMR1(l,h) (((l) << 27) | (((h) & 0x3ff) << 14))
  157. #endif
  158. /* EMACx_RMR */
  159. #define EMAC_RMR_SP 0x80000000
  160. #define EMAC_RMR_SFCS 0x40000000
  161. #define EMAC_RMR_RRP 0x20000000
  162. #define EMAC_RMR_RFP 0x10000000
  163. #define EMAC_RMR_ROP 0x08000000
  164. #define EMAC_RMR_RPIR 0x04000000
  165. #define EMAC_RMR_PPP 0x02000000
  166. #define EMAC_RMR_PME 0x01000000
  167. #define EMAC_RMR_PMME 0x00800000
  168. #define EMAC_RMR_IAE 0x00400000
  169. #define EMAC_RMR_MIAE 0x00200000
  170. #define EMAC_RMR_BAE 0x00100000
  171. #define EMAC_RMR_MAE 0x00080000
  172. #if !defined(CONFIG_IBM_EMAC4)
  173. #define EMAC_RMR_BASE 0x00000000
  174. #else
  175. #define EMAC_RMR_RFAF_2_32 0x00000001
  176. #define EMAC_RMR_RFAF_4_64 0x00000002
  177. #define EMAC_RMR_RFAF_8_128 0x00000003
  178. #define EMAC_RMR_RFAF_16_256 0x00000004
  179. #define EMAC_RMR_RFAF_32_512 0x00000005
  180. #define EMAC_RMR_RFAF_64_1024 0x00000006
  181. #define EMAC_RMR_RFAF_128_2048 0x00000007
  182. #define EMAC_RMR_BASE EMAC_RMR_RFAF_128_2048
  183. #endif
  184. /* EMACx_ISR & EMACx_ISER */
  185. #if !defined(CONFIG_IBM_EMAC4)
  186. #define EMAC_ISR_TXPE 0x00000000
  187. #define EMAC_ISR_RXPE 0x00000000
  188. #define EMAC_ISR_TXUE 0x00000000
  189. #define EMAC_ISR_RXOE 0x00000000
  190. #else
  191. #define EMAC_ISR_TXPE 0x20000000
  192. #define EMAC_ISR_RXPE 0x10000000
  193. #define EMAC_ISR_TXUE 0x08000000
  194. #define EMAC_ISR_RXOE 0x04000000
  195. #endif
  196. #define EMAC_ISR_OVR 0x02000000
  197. #define EMAC_ISR_PP 0x01000000
  198. #define EMAC_ISR_BP 0x00800000
  199. #define EMAC_ISR_RP 0x00400000
  200. #define EMAC_ISR_SE 0x00200000
  201. #define EMAC_ISR_ALE 0x00100000
  202. #define EMAC_ISR_BFCS 0x00080000
  203. #define EMAC_ISR_PTLE 0x00040000
  204. #define EMAC_ISR_ORE 0x00020000
  205. #define EMAC_ISR_IRE 0x00010000
  206. #define EMAC_ISR_SQE 0x00000080
  207. #define EMAC_ISR_TE 0x00000040
  208. #define EMAC_ISR_MOS 0x00000002
  209. #define EMAC_ISR_MOF 0x00000001
  210. /* EMACx_STACR */
  211. #define EMAC_STACR_PHYD_MASK 0xffff
  212. #define EMAC_STACR_PHYD_SHIFT 16
  213. #define EMAC_STACR_OC 0x00008000
  214. #define EMAC_STACR_PHYE 0x00004000
  215. #define EMAC_STACR_STAC_MASK 0x00003000
  216. #define EMAC_STACR_STAC_READ 0x00001000
  217. #define EMAC_STACR_STAC_WRITE 0x00002000
  218. #if !defined(CONFIG_IBM_EMAC4)
  219. #define EMAC_STACR_OPBC_MASK 0x00000C00
  220. #define EMAC_STACR_OPBC_50 0x00000000
  221. #define EMAC_STACR_OPBC_66 0x00000400
  222. #define EMAC_STACR_OPBC_83 0x00000800
  223. #define EMAC_STACR_OPBC_100 0x00000C00
  224. #define EMAC_STACR_OPBC(freq) ((freq) <= 50 ? EMAC_STACR_OPBC_50 : \
  225. (freq) <= 66 ? EMAC_STACR_OPBC_66 : \
  226. (freq) <= 83 ? EMAC_STACR_OPBC_83 : EMAC_STACR_OPBC_100)
  227. #define EMAC_STACR_BASE(opb) EMAC_STACR_OPBC(opb)
  228. #else
  229. #define EMAC_STACR_BASE(opb) 0x00000000
  230. #endif
  231. #define EMAC_STACR_PCDA_MASK 0x1f
  232. #define EMAC_STACR_PCDA_SHIFT 5
  233. #define EMAC_STACR_PRA_MASK 0x1f
  234. /*
  235. * For the 440SPe, AMCC inexplicably changed the polarity of
  236. * the "operation complete" bit in the MII control register.
  237. */
  238. #if defined(CONFIG_440SPE)
  239. static inline int emac_phy_done(u32 stacr)
  240. {
  241. return !(stacr & EMAC_STACR_OC);
  242. };
  243. #define EMAC_STACR_START EMAC_STACR_OC
  244. #else /* CONFIG_440SPE */
  245. static inline int emac_phy_done(u32 stacr)
  246. {
  247. return stacr & EMAC_STACR_OC;
  248. };
  249. #define EMAC_STACR_START 0
  250. #endif /* !CONFIG_440SPE */
  251. /* EMACx_TRTR */
  252. #if !defined(CONFIG_IBM_EMAC4)
  253. #define EMAC_TRTR_SHIFT 27
  254. #else
  255. #define EMAC_TRTR_SHIFT 24
  256. #endif
  257. #define EMAC_TRTR(size) ((((size) >> 6) - 1) << EMAC_TRTR_SHIFT)
  258. /* EMACx_RWMR */
  259. #if !defined(CONFIG_IBM_EMAC4)
  260. #define EMAC_RWMR(l,h) (((l) << 23) | ( ((h) & 0x1ff) << 7))
  261. #else
  262. #define EMAC_RWMR(l,h) (((l) << 22) | ( ((h) & 0x3ff) << 6))
  263. #endif
  264. /* EMAC specific TX descriptor control fields (write access) */
  265. #define EMAC_TX_CTRL_GFCS 0x0200
  266. #define EMAC_TX_CTRL_GP 0x0100
  267. #define EMAC_TX_CTRL_ISA 0x0080
  268. #define EMAC_TX_CTRL_RSA 0x0040
  269. #define EMAC_TX_CTRL_IVT 0x0020
  270. #define EMAC_TX_CTRL_RVT 0x0010
  271. #define EMAC_TX_CTRL_TAH_CSUM 0x000e
  272. /* EMAC specific TX descriptor status fields (read access) */
  273. #define EMAC_TX_ST_BFCS 0x0200
  274. #define EMAC_TX_ST_LCS 0x0080
  275. #define EMAC_TX_ST_ED 0x0040
  276. #define EMAC_TX_ST_EC 0x0020
  277. #define EMAC_TX_ST_LC 0x0010
  278. #define EMAC_TX_ST_MC 0x0008
  279. #define EMAC_TX_ST_SC 0x0004
  280. #define EMAC_TX_ST_UR 0x0002
  281. #define EMAC_TX_ST_SQE 0x0001
  282. #if !defined(CONFIG_IBM_EMAC_TAH)
  283. #define EMAC_IS_BAD_TX(v) ((v) & (EMAC_TX_ST_LCS | EMAC_TX_ST_ED | \
  284. EMAC_TX_ST_EC | EMAC_TX_ST_LC | \
  285. EMAC_TX_ST_MC | EMAC_TX_ST_UR))
  286. #else
  287. #define EMAC_IS_BAD_TX(v) ((v) & (EMAC_TX_ST_LCS | EMAC_TX_ST_ED | \
  288. EMAC_TX_ST_EC | EMAC_TX_ST_LC))
  289. #endif
  290. /* EMAC specific RX descriptor status fields (read access) */
  291. #define EMAC_RX_ST_OE 0x0200
  292. #define EMAC_RX_ST_PP 0x0100
  293. #define EMAC_RX_ST_BP 0x0080
  294. #define EMAC_RX_ST_RP 0x0040
  295. #define EMAC_RX_ST_SE 0x0020
  296. #define EMAC_RX_ST_AE 0x0010
  297. #define EMAC_RX_ST_BFCS 0x0008
  298. #define EMAC_RX_ST_PTL 0x0004
  299. #define EMAC_RX_ST_ORE 0x0002
  300. #define EMAC_RX_ST_IRE 0x0001
  301. #define EMAC_RX_TAH_BAD_CSUM 0x0003
  302. #define EMAC_BAD_RX_MASK (EMAC_RX_ST_OE | EMAC_RX_ST_BP | \
  303. EMAC_RX_ST_RP | EMAC_RX_ST_SE | \
  304. EMAC_RX_ST_AE | EMAC_RX_ST_BFCS | \
  305. EMAC_RX_ST_PTL | EMAC_RX_ST_ORE | \
  306. EMAC_RX_ST_IRE )
  307. #endif /* __IBM_EMAC_H_ */