ibm_emac.h 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267
  1. /*
  2. * ibm_emac.h
  3. *
  4. *
  5. * Armin Kuster akuster@mvista.com
  6. * June, 2002
  7. *
  8. * Copyright 2002 MontaVista Softare Inc.
  9. *
  10. * This program is free software; you can redistribute it and/or modify it
  11. * under the terms of the GNU General Public License as published by the
  12. * Free Software Foundation; either version 2 of the License, or (at your
  13. * option) any later version.
  14. */
  15. #ifndef _IBM_EMAC_H_
  16. #define _IBM_EMAC_H_
  17. /* General defines needed for the driver */
  18. /* Emac */
  19. typedef struct emac_regs {
  20. u32 em0mr0;
  21. u32 em0mr1;
  22. u32 em0tmr0;
  23. u32 em0tmr1;
  24. u32 em0rmr;
  25. u32 em0isr;
  26. u32 em0iser;
  27. u32 em0iahr;
  28. u32 em0ialr;
  29. u32 em0vtpid;
  30. u32 em0vtci;
  31. u32 em0ptr;
  32. u32 em0iaht1;
  33. u32 em0iaht2;
  34. u32 em0iaht3;
  35. u32 em0iaht4;
  36. u32 em0gaht1;
  37. u32 em0gaht2;
  38. u32 em0gaht3;
  39. u32 em0gaht4;
  40. u32 em0lsah;
  41. u32 em0lsal;
  42. u32 em0ipgvr;
  43. u32 em0stacr;
  44. u32 em0trtr;
  45. u32 em0rwmr;
  46. } emac_t;
  47. /* MODE REG 0 */
  48. #define EMAC_M0_RXI 0x80000000
  49. #define EMAC_M0_TXI 0x40000000
  50. #define EMAC_M0_SRST 0x20000000
  51. #define EMAC_M0_TXE 0x10000000
  52. #define EMAC_M0_RXE 0x08000000
  53. #define EMAC_M0_WKE 0x04000000
  54. /* MODE Reg 1 */
  55. #define EMAC_M1_FDE 0x80000000
  56. #define EMAC_M1_ILE 0x40000000
  57. #define EMAC_M1_VLE 0x20000000
  58. #define EMAC_M1_EIFC 0x10000000
  59. #define EMAC_M1_APP 0x08000000
  60. #define EMAC_M1_AEMI 0x02000000
  61. #define EMAC_M1_IST 0x01000000
  62. #define EMAC_M1_MF_1000GPCS 0x00c00000 /* Internal GPCS */
  63. #define EMAC_M1_MF_1000MBPS 0x00800000 /* External GPCS */
  64. #define EMAC_M1_MF_100MBPS 0x00400000
  65. #define EMAC_M1_RFS_16K 0x00280000 /* 000 for 512 byte */
  66. #define EMAC_M1_TR 0x00008000
  67. #ifdef CONFIG_IBM_EMAC4
  68. #define EMAC_M1_RFS_8K 0x00200000
  69. #define EMAC_M1_RFS_4K 0x00180000
  70. #define EMAC_M1_RFS_2K 0x00100000
  71. #define EMAC_M1_RFS_1K 0x00080000
  72. #define EMAC_M1_TX_FIFO_16K 0x00050000 /* 0's for 512 byte */
  73. #define EMAC_M1_TX_FIFO_8K 0x00040000
  74. #define EMAC_M1_TX_FIFO_4K 0x00030000
  75. #define EMAC_M1_TX_FIFO_2K 0x00020000
  76. #define EMAC_M1_TX_FIFO_1K 0x00010000
  77. #define EMAC_M1_TX_TR 0x00008000
  78. #define EMAC_M1_TX_MWSW 0x00001000 /* 0 wait for status */
  79. #define EMAC_M1_JUMBO_ENABLE 0x00000800 /* Upt to 9Kr status */
  80. #define EMAC_M1_OPB_CLK_66 0x00000008 /* 66Mhz */
  81. #define EMAC_M1_OPB_CLK_83 0x00000010 /* 83Mhz */
  82. #define EMAC_M1_OPB_CLK_100 0x00000018 /* 100Mhz */
  83. #define EMAC_M1_OPB_CLK_100P 0x00000020 /* 100Mhz+ */
  84. #else /* CONFIG_IBM_EMAC4 */
  85. #define EMAC_M1_RFS_4K 0x00300000 /* ~4k for 512 byte */
  86. #define EMAC_M1_RFS_2K 0x00200000
  87. #define EMAC_M1_RFS_1K 0x00100000
  88. #define EMAC_M1_TX_FIFO_2K 0x00080000 /* 0's for 512 byte */
  89. #define EMAC_M1_TX_FIFO_1K 0x00040000
  90. #define EMAC_M1_TR0_DEPEND 0x00010000 /* 0'x for single packet */
  91. #define EMAC_M1_TR1_DEPEND 0x00004000
  92. #define EMAC_M1_TR1_MULTI 0x00002000
  93. #define EMAC_M1_JUMBO_ENABLE 0x00001000
  94. #endif /* CONFIG_IBM_EMAC4 */
  95. #define EMAC_M1_BASE (EMAC_M1_TX_FIFO_2K | \
  96. EMAC_M1_APP | \
  97. EMAC_M1_TR | EMAC_M1_VLE)
  98. /* Transmit Mode Register 0 */
  99. #define EMAC_TMR0_GNP0 0x80000000
  100. #define EMAC_TMR0_GNP1 0x40000000
  101. #define EMAC_TMR0_GNPD 0x20000000
  102. #define EMAC_TMR0_FC 0x10000000
  103. #define EMAC_TMR0_TFAE_2_32 0x00000001
  104. #define EMAC_TMR0_TFAE_4_64 0x00000002
  105. #define EMAC_TMR0_TFAE_8_128 0x00000003
  106. #define EMAC_TMR0_TFAE_16_256 0x00000004
  107. #define EMAC_TMR0_TFAE_32_512 0x00000005
  108. #define EMAC_TMR0_TFAE_64_1024 0x00000006
  109. #define EMAC_TMR0_TFAE_128_2048 0x00000007
  110. /* Receive Mode Register */
  111. #define EMAC_RMR_SP 0x80000000
  112. #define EMAC_RMR_SFCS 0x40000000
  113. #define EMAC_RMR_ARRP 0x20000000
  114. #define EMAC_RMR_ARP 0x10000000
  115. #define EMAC_RMR_AROP 0x08000000
  116. #define EMAC_RMR_ARPI 0x04000000
  117. #define EMAC_RMR_PPP 0x02000000
  118. #define EMAC_RMR_PME 0x01000000
  119. #define EMAC_RMR_PMME 0x00800000
  120. #define EMAC_RMR_IAE 0x00400000
  121. #define EMAC_RMR_MIAE 0x00200000
  122. #define EMAC_RMR_BAE 0x00100000
  123. #define EMAC_RMR_MAE 0x00080000
  124. #define EMAC_RMR_RFAF_2_32 0x00000001
  125. #define EMAC_RMR_RFAF_4_64 0x00000002
  126. #define EMAC_RMR_RFAF_8_128 0x00000003
  127. #define EMAC_RMR_RFAF_16_256 0x00000004
  128. #define EMAC_RMR_RFAF_32_512 0x00000005
  129. #define EMAC_RMR_RFAF_64_1024 0x00000006
  130. #define EMAC_RMR_RFAF_128_2048 0x00000007
  131. #define EMAC_RMR_BASE (EMAC_RMR_IAE | EMAC_RMR_BAE)
  132. /* Interrupt Status & enable Regs */
  133. #define EMAC_ISR_OVR 0x02000000
  134. #define EMAC_ISR_PP 0x01000000
  135. #define EMAC_ISR_BP 0x00800000
  136. #define EMAC_ISR_RP 0x00400000
  137. #define EMAC_ISR_SE 0x00200000
  138. #define EMAC_ISR_ALE 0x00100000
  139. #define EMAC_ISR_BFCS 0x00080000
  140. #define EMAC_ISR_PTLE 0x00040000
  141. #define EMAC_ISR_ORE 0x00020000
  142. #define EMAC_ISR_IRE 0x00010000
  143. #define EMAC_ISR_DBDM 0x00000200
  144. #define EMAC_ISR_DB0 0x00000100
  145. #define EMAC_ISR_SE0 0x00000080
  146. #define EMAC_ISR_TE0 0x00000040
  147. #define EMAC_ISR_DB1 0x00000020
  148. #define EMAC_ISR_SE1 0x00000010
  149. #define EMAC_ISR_TE1 0x00000008
  150. #define EMAC_ISR_MOS 0x00000002
  151. #define EMAC_ISR_MOF 0x00000001
  152. /* STA CONTROL REG */
  153. #define EMAC_STACR_OC 0x00008000
  154. #define EMAC_STACR_PHYE 0x00004000
  155. #define EMAC_STACR_WRITE 0x00002000
  156. #define EMAC_STACR_READ 0x00001000
  157. #define EMAC_STACR_CLK_83MHZ 0x00000800 /* 0's for 50Mhz */
  158. #define EMAC_STACR_CLK_66MHZ 0x00000400
  159. #define EMAC_STACR_CLK_100MHZ 0x00000C00
  160. /* Transmit Request Threshold Register */
  161. #define EMAC_TRTR_1600 0x18000000 /* 0's for 64 Bytes */
  162. #define EMAC_TRTR_1024 0x0f000000
  163. #define EMAC_TRTR_512 0x07000000
  164. #define EMAC_TRTR_256 0x03000000
  165. #define EMAC_TRTR_192 0x10000000
  166. #define EMAC_TRTR_128 0x01000000
  167. #define EMAC_TX_CTRL_GFCS 0x0200
  168. #define EMAC_TX_CTRL_GP 0x0100
  169. #define EMAC_TX_CTRL_ISA 0x0080
  170. #define EMAC_TX_CTRL_RSA 0x0040
  171. #define EMAC_TX_CTRL_IVT 0x0020
  172. #define EMAC_TX_CTRL_RVT 0x0010
  173. #define EMAC_TX_CTRL_TAH_CSUM 0x000e /* TAH only */
  174. #define EMAC_TX_CTRL_TAH_SEG4 0x000a /* TAH only */
  175. #define EMAC_TX_CTRL_TAH_SEG3 0x0008 /* TAH only */
  176. #define EMAC_TX_CTRL_TAH_SEG2 0x0006 /* TAH only */
  177. #define EMAC_TX_CTRL_TAH_SEG1 0x0004 /* TAH only */
  178. #define EMAC_TX_CTRL_TAH_SEG0 0x0002 /* TAH only */
  179. #define EMAC_TX_CTRL_TAH_DIS 0x0000 /* TAH only */
  180. #define EMAC_TX_CTRL_DFLT ( \
  181. MAL_TX_CTRL_INTR | EMAC_TX_CTRL_GFCS | EMAC_TX_CTRL_GP )
  182. /* madmal transmit status / Control bits */
  183. #define EMAC_TX_ST_BFCS 0x0200
  184. #define EMAC_TX_ST_BPP 0x0100
  185. #define EMAC_TX_ST_LCS 0x0080
  186. #define EMAC_TX_ST_ED 0x0040
  187. #define EMAC_TX_ST_EC 0x0020
  188. #define EMAC_TX_ST_LC 0x0010
  189. #define EMAC_TX_ST_MC 0x0008
  190. #define EMAC_TX_ST_SC 0x0004
  191. #define EMAC_TX_ST_UR 0x0002
  192. #define EMAC_TX_ST_SQE 0x0001
  193. /* madmal receive status / Control bits */
  194. #define EMAC_RX_ST_OE 0x0200
  195. #define EMAC_RX_ST_PP 0x0100
  196. #define EMAC_RX_ST_BP 0x0080
  197. #define EMAC_RX_ST_RP 0x0040
  198. #define EMAC_RX_ST_SE 0x0020
  199. #define EMAC_RX_ST_AE 0x0010
  200. #define EMAC_RX_ST_BFCS 0x0008
  201. #define EMAC_RX_ST_PTL 0x0004
  202. #define EMAC_RX_ST_ORE 0x0002
  203. #define EMAC_RX_ST_IRE 0x0001
  204. #define EMAC_BAD_RX_PACKET 0x02ff
  205. #define EMAC_CSUM_VER_ERROR 0x0003
  206. /* identify a bad rx packet dependent on emac features */
  207. #ifdef CONFIG_IBM_EMAC4
  208. #define EMAC_IS_BAD_RX_PACKET(desc) \
  209. (((desc & (EMAC_BAD_RX_PACKET & ~EMAC_CSUM_VER_ERROR)) || \
  210. ((desc & EMAC_CSUM_VER_ERROR) == EMAC_RX_ST_ORE) || \
  211. ((desc & EMAC_CSUM_VER_ERROR) == EMAC_RX_ST_IRE)))
  212. #else
  213. #define EMAC_IS_BAD_RX_PACKET(desc) \
  214. (desc & EMAC_BAD_RX_PACKET)
  215. #endif
  216. /* SoC implementation specific EMAC register defaults */
  217. #if defined(CONFIG_440GP)
  218. #define EMAC_RWMR_DEFAULT 0x80009000
  219. #define EMAC_TMR0_DEFAULT 0x00000000
  220. #define EMAC_TMR1_DEFAULT 0xf8640000
  221. #elif defined(CONFIG_440GX)
  222. #define EMAC_RWMR_DEFAULT 0x1000a200
  223. #define EMAC_TMR0_DEFAULT EMAC_TMR0_TFAE_2_32
  224. #define EMAC_TMR1_DEFAULT 0xa00f0000
  225. #elif defined(CONFIG_440SP)
  226. #define EMAC_RWMR_DEFAULT 0x08002000
  227. #define EMAC_TMR0_DEFAULT EMAC_TMR0_TFAE_128_2048
  228. #define EMAC_TMR1_DEFAULT 0xf8200000
  229. #else
  230. #define EMAC_RWMR_DEFAULT 0x0f002000
  231. #define EMAC_TMR0_DEFAULT 0x00000000
  232. #define EMAC_TMR1_DEFAULT 0x380f0000
  233. #endif /* CONFIG_440GP */
  234. /* Revision specific EMAC register defaults */
  235. #ifdef CONFIG_IBM_EMAC4
  236. #define EMAC_M1_DEFAULT (EMAC_M1_BASE | \
  237. EMAC_M1_OPB_CLK_83 | \
  238. EMAC_M1_TX_MWSW)
  239. #define EMAC_RMR_DEFAULT (EMAC_RMR_BASE | \
  240. EMAC_RMR_RFAF_128_2048)
  241. #define EMAC_TMR0_XMIT (EMAC_TMR0_GNP0 | \
  242. EMAC_TMR0_DEFAULT)
  243. #define EMAC_TRTR_DEFAULT EMAC_TRTR_1024
  244. #else /* !CONFIG_IBM_EMAC4 */
  245. #define EMAC_M1_DEFAULT EMAC_M1_BASE
  246. #define EMAC_RMR_DEFAULT EMAC_RMR_BASE
  247. #define EMAC_TMR0_XMIT EMAC_TMR0_GNP0
  248. #define EMAC_TRTR_DEFAULT EMAC_TRTR_1600
  249. #endif /* CONFIG_IBM_EMAC4 */
  250. #endif