ax88180.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366
  1. /* ax88180.h: ASIX AX88180 Non-PCI Gigabit Ethernet u-boot driver */
  2. /*
  3. *
  4. * This program is free software; you can distribute it and/or modify it
  5. * under the terms of the GNU General Public License (Version 2) as
  6. * published by the Free Software Foundation.
  7. *
  8. * This program is distributed in the hope it will be useful, but WITHOUT
  9. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  10. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
  11. * for more details.
  12. *
  13. * You should have received a copy of the GNU General Public License along
  14. * with this program; if not, write to the Free Software Foundation, Inc.,
  15. * 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
  16. *
  17. */
  18. #ifndef _AX88180_H_
  19. #define _AX88180_H_
  20. #include <asm/types.h>
  21. #include <config.h>
  22. typedef enum _ax88180_link_state {
  23. INS_LINK_DOWN,
  24. INS_LINK_UP,
  25. INS_LINK_UNKNOWN
  26. } ax88180_link_state;
  27. struct ax88180_private {
  28. unsigned char BusWidth;
  29. unsigned char PadSize;
  30. unsigned short PhyAddr;
  31. unsigned short PhyID0;
  32. unsigned short FirstTxDesc;
  33. unsigned short NextTxDesc;
  34. ax88180_link_state LinkState;
  35. };
  36. #define BUS_WIDTH_16 1
  37. #define BUS_WIDTH_32 2
  38. #define ENABLE_JUMBO 1
  39. #define DISABLE_JUMBO 0
  40. #define ENABLE_BURST 1
  41. #define DISABLE_BURST 0
  42. #define NORMAL_RX_MODE 0
  43. #define RX_LOOPBACK_MODE 1
  44. #define RX_INIFINIT_LOOP_MODE 2
  45. #define TX_INIFINIT_LOOP_MODE 3
  46. #define DEFAULT_ETH_MTU 1500
  47. /* Jumbo packet size 4086 bytes included 4 bytes CRC*/
  48. #define MAX_JUMBO_MTU 4072
  49. /* Max Tx Jumbo size 4086 bytes included 4 bytes CRC */
  50. #define MAX_TX_JUMBO_SIZE 4086
  51. /* Max Rx Jumbo size is 15K Bytes */
  52. #define MAX_RX_SIZE 0x3C00
  53. #define MARVELL_88E1111_PHYSID0 0x0141
  54. #define CICADA_CIS8201_PHYSID0 0x000F
  55. #define MEDIA_AUTO 0
  56. #define MEDIA_1000FULL 1
  57. #define MEDIA_1000HALF 2
  58. #define MEDIA_100FULL 3
  59. #define MEDIA_100HALF 4
  60. #define MEDIA_10FULL 5
  61. #define MEDIA_10HALF 6
  62. #define MEDIA_UNKNOWN 7
  63. #define AUTO_MEDIA 0
  64. #define FORCE_MEDIA 1
  65. #define TXDP_MASK 3
  66. #define TXDP0 0
  67. #define TXDP1 1
  68. #define TXDP2 2
  69. #define TXDP3 3
  70. #define CMD_MAP_SIZE 0x100
  71. #if defined (CONFIG_DRIVER_AX88180_16BIT)
  72. #define AX88180_MEMORY_SIZE 0x00004000
  73. #define START_BASE 0x1000
  74. #define RX_BUF_SIZE 0x1000
  75. #define TX_BUF_SIZE 0x0F00
  76. #define TX_BASE START_BASE
  77. #define CMD_BASE (TX_BASE + TX_BUF_SIZE)
  78. #define RX_BASE (CMD_BASE + CMD_MAP_SIZE)
  79. #else
  80. #define AX88180_MEMORY_SIZE 0x00010000
  81. #define RX_BUF_SIZE 0x8000
  82. #define TX_BUF_SIZE 0x7C00
  83. #define RX_BASE 0x0000
  84. #define TX_BASE (RX_BASE + RX_BUF_SIZE)
  85. #define CMD_BASE (TX_BASE + TX_BUF_SIZE)
  86. #endif
  87. /* AX88180 Memory Mapping Definition */
  88. #define RXBUFFER_START RX_BASE
  89. #define RX_PACKET_LEN_OFFSET 0
  90. #define RX_PAGE_NUM_MASK 0x7FF /* RX pages 0~7FFh */
  91. #define TXBUFFER_START TX_BASE
  92. /* AX88180 MAC Register Definition */
  93. #define DECODE (0)
  94. #define DECODE_EN 0x00000001
  95. #define BASE (6)
  96. #define CMD (CMD_BASE + 0x0000)
  97. #define WAKEMOD 0x00000001
  98. #define TXEN 0x00000100
  99. #define RXEN 0x00000200
  100. #define DEFAULT_CMD WAKEMOD
  101. #define IMR (CMD_BASE + 0x0004)
  102. #define IMR_RXBUFFOVR 0x00000001
  103. #define IMR_WATCHDOG 0x00000002
  104. #define IMR_TX 0x00000008
  105. #define IMR_RX 0x00000010
  106. #define IMR_PHY 0x00000020
  107. #define CLEAR_IMR 0x00000000
  108. #define DEFAULT_IMR (IMR_PHY | IMR_RX | IMR_TX |\
  109. IMR_RXBUFFOVR | IMR_WATCHDOG)
  110. #define ISR (CMD_BASE + 0x0008)
  111. #define ISR_RXBUFFOVR 0x00000001
  112. #define ISR_WATCHDOG 0x00000002
  113. #define ISR_TX 0x00000008
  114. #define ISR_RX 0x00000010
  115. #define ISR_PHY 0x00000020
  116. #define TXCFG (CMD_BASE + 0x0010)
  117. #define AUTOPAD_CRC 0x00000050
  118. #define DEFAULT_TXCFG AUTOPAD_CRC
  119. #define TXCMD (CMD_BASE + 0x0014)
  120. #define TXCMD_TXDP_MASK 0x00006000
  121. #define TXCMD_TXDP0 0x00000000
  122. #define TXCMD_TXDP1 0x00002000
  123. #define TXCMD_TXDP2 0x00004000
  124. #define TXCMD_TXDP3 0x00006000
  125. #define TX_START_WRITE 0x00008000
  126. #define TX_STOP_WRITE 0x00000000
  127. #define DEFAULT_TXCMD 0x00000000
  128. #define TXBS (CMD_BASE + 0x0018)
  129. #define TXDP0_USED 0x00000001
  130. #define TXDP1_USED 0x00000002
  131. #define TXDP2_USED 0x00000004
  132. #define TXDP3_USED 0x00000008
  133. #define DEFAULT_TXBS 0x00000000
  134. #define TXDES0 (CMD_BASE + 0x0020)
  135. #define TXDPx_ENABLE 0x00008000
  136. #define TXDPx_LEN_MASK 0x00001FFF
  137. #define DEFAULT_TXDES0 0x00000000
  138. #define TXDES1 (CMD_BASE + 0x0024)
  139. #define TXDPx_ENABLE 0x00008000
  140. #define TXDPx_LEN_MASK 0x00001FFF
  141. #define DEFAULT_TXDES1 0x00000000
  142. #define TXDES2 (CMD_BASE + 0x0028)
  143. #define TXDPx_ENABLE 0x00008000
  144. #define TXDPx_LEN_MASK 0x00001FFF
  145. #define DEFAULT_TXDES2 0x00000000
  146. #define TXDES3 (CMD_BASE + 0x002C)
  147. #define TXDPx_ENABLE 0x00008000
  148. #define TXDPx_LEN_MASK 0x00001FFF
  149. #define DEFAULT_TXDES3 0x00000000
  150. #define RXCFG (CMD_BASE + 0x0030)
  151. #define RXBUFF_PROTECT 0x00000001
  152. #define RXTCPCRC_CHECK 0x00000010
  153. #define RXFLOW_ENABLE 0x00000100
  154. #define DEFAULT_RXCFG RXBUFF_PROTECT
  155. #define RXCURT (CMD_BASE + 0x0034)
  156. #define DEFAULT_RXCURT 0x00000000
  157. #define RXBOUND (CMD_BASE + 0x0038)
  158. #define DEFAULT_RXBOUND 0x7FF /* RX pages 0~7FFh */
  159. #define MACCFG0 (CMD_BASE + 0x0040)
  160. #define MACCFG0_BIT3_0 0x00000007
  161. #define IPGT_VAL 0x00000150
  162. #define TXFLOW_ENABLE 0x00001000
  163. #define SPEED100 0x00008000
  164. #define DEFAULT_MACCFG0 (IPGT_VAL | MACCFG0_BIT3_0)
  165. #define MACCFG1 (CMD_BASE + 0x0044)
  166. #define RGMII_EN 0x00000002
  167. #define RXFLOW_EN 0x00000020
  168. #define FULLDUPLEX 0x00000040
  169. #define MAX_JUMBO_LEN 0x00000780
  170. #define RXJUMBO_EN 0x00000800
  171. #define GIGA_MODE_EN 0x00001000
  172. #define RXCRC_CHECK 0x00002000
  173. #define RXPAUSE_DA_CHECK 0x00004000
  174. #define JUMBO_LEN_4K 0x00000200
  175. #define JUMBO_LEN_15K 0x00000780
  176. #define DEFAULT_MACCFG1 (RXCRC_CHECK | RXPAUSE_DA_CHECK | \
  177. RGMII_EN)
  178. #define CICADA_DEFAULT_MACCFG1 (RXCRC_CHECK | RXPAUSE_DA_CHECK)
  179. #define MACCFG2 (CMD_BASE + 0x0048)
  180. #define MACCFG2_BIT15_8 0x00000100
  181. #define JAM_LIMIT_MASK 0x000000FC
  182. #define DEFAULT_JAM_LIMIT 0x00000064
  183. #define DEFAULT_MACCFG2 MACCFG2_BIT15_8
  184. #define MACCFG3 (CMD_BASE + 0x004C)
  185. #define IPGR2_VAL 0x0000000E
  186. #define IPGR1_VAL 0x00000600
  187. #define NOABORT 0x00008000
  188. #define DEFAULT_MACCFG3 (IPGR1_VAL | IPGR2_VAL)
  189. #define TXPAUT (CMD_BASE + 0x0054)
  190. #define DEFAULT_TXPAUT 0x001FE000
  191. #define RXBTHD0 (CMD_BASE + 0x0058)
  192. #define DEFAULT_RXBTHD0 0x00000300
  193. #define RXBTHD1 (CMD_BASE + 0x005C)
  194. #define DEFAULT_RXBTHD1 0x00000600
  195. #define RXFULTHD (CMD_BASE + 0x0060)
  196. #define DEFAULT_RXFULTHD 0x00000100
  197. #define MISC (CMD_BASE + 0x0068)
  198. /* Normal operation mode */
  199. #define MISC_NORMAL 0x00000003
  200. /* Clear bit 0 to reset MAC */
  201. #define MISC_RESET_MAC 0x00000002
  202. /* Clear bit 1 to reset PHY */
  203. #define MISC_RESET_PHY 0x00000001
  204. /* Clear bit 0 and 1 to reset MAC and PHY */
  205. #define MISC_RESET_MAC_PHY 0x00000000
  206. #define DEFAULT_MISC MISC_NORMAL
  207. #define MACID0 (CMD_BASE + 0x0070)
  208. #define MACID1 (CMD_BASE + 0x0074)
  209. #define MACID2 (CMD_BASE + 0x0078)
  210. #define TXLEN (CMD_BASE + 0x007C)
  211. #define DEFAULT_TXLEN 0x000005FC
  212. #define RXFILTER (CMD_BASE + 0x0080)
  213. #define RX_RXANY 0x00000001
  214. #define RX_MULTICAST 0x00000002
  215. #define RX_UNICAST 0x00000004
  216. #define RX_BROADCAST 0x00000008
  217. #define RX_MULTI_HASH 0x00000010
  218. #define DISABLE_RXFILTER 0x00000000
  219. #define DEFAULT_RXFILTER (RX_BROADCAST + RX_UNICAST)
  220. #define MDIOCTRL (CMD_BASE + 0x0084)
  221. #define PHY_ADDR_MASK 0x0000001F
  222. #define REG_ADDR_MASK 0x00001F00
  223. #define READ_PHY 0x00004000
  224. #define WRITE_PHY 0x00008000
  225. #define MDIODP (CMD_BASE + 0x0088)
  226. #define GPIOCTRL (CMD_BASE + 0x008C)
  227. #define RXINDICATOR (CMD_BASE + 0x0090)
  228. #define RX_START_READ 0x00000001
  229. #define RX_STOP_READ 0x00000000
  230. #define DEFAULT_RXINDICATOR RX_STOP_READ
  231. #define TXST (CMD_BASE + 0x0094)
  232. #define MDCCLKPAT (CMD_BASE + 0x00A0)
  233. #define RXIPCRCCNT (CMD_BASE + 0x00A4)
  234. #define RXCRCCNT (CMD_BASE + 0x00A8)
  235. #define TXFAILCNT (CMD_BASE + 0x00AC)
  236. #define PROMDP (CMD_BASE + 0x00B0)
  237. #define PROMCTRL (CMD_BASE + 0x00B4)
  238. #define RELOAD_EEPROM 0x00000200
  239. #define MAXRXLEN (CMD_BASE + 0x00B8)
  240. #define HASHTAB0 (CMD_BASE + 0x00C0)
  241. #define HASHTAB1 (CMD_BASE + 0x00C4)
  242. #define HASHTAB2 (CMD_BASE + 0x00C8)
  243. #define HASHTAB3 (CMD_BASE + 0x00CC)
  244. #define DOGTHD0 (CMD_BASE + 0x00E0)
  245. #define DEFAULT_DOGTHD0 0x0000FFFF
  246. #define DOGTHD1 (CMD_BASE + 0x00E4)
  247. #define START_WATCHDOG_TIMER 0x00008000
  248. #define DEFAULT_DOGTHD1 0x00000FFF
  249. #define SOFTRST (CMD_BASE + 0x00EC)
  250. #define SOFTRST_NORMAL 0x00000003
  251. #define SOFTRST_RESET_MAC 0x00000002
  252. /* Marvell 88E1111 Gigabit PHY Register Definition */
  253. #define M88_SSR 0x0011
  254. #define SSR_SPEED_MASK 0xC000
  255. #define SSR_SPEED_1000 0x8000
  256. #define SSR_SPEED_100 0x4000
  257. #define SSR_SPEED_10 0x0000
  258. #define SSR_DUPLEX 0x2000
  259. #define SSR_MEDIA_RESOLVED_OK 0x0800
  260. #define SSR_MEDIA_MASK (SSR_SPEED_MASK | SSR_DUPLEX)
  261. #define SSR_1000FULL (SSR_SPEED_1000 | SSR_DUPLEX)
  262. #define SSR_1000HALF SSR_SPEED_1000
  263. #define SSR_100FULL (SSR_SPEED_100 | SSR_DUPLEX)
  264. #define SSR_100HALF SSR_SPEED_100
  265. #define SSR_10FULL (SSR_SPEED_10 | SSR_DUPLEX)
  266. #define SSR_10HALF SSR_SPEED_10
  267. #define M88_IER 0x0012
  268. #define LINK_CHANGE_INT 0x0400
  269. #define M88_ISR 0x0013
  270. #define LINK_CHANGE_STATUS 0x0400
  271. #define M88_EXT_SCR 0x0014
  272. #define RGMII_RXCLK_DELAY 0x0080
  273. #define RGMII_TXCLK_DELAY 0x0002
  274. #define DEFAULT_EXT_SCR (RGMII_TXCLK_DELAY | RGMII_RXCLK_DELAY)
  275. #define M88_EXT_SSR 0x001B
  276. #define HWCFG_MODE_MASK 0x000F
  277. #define RGMII_COPPER_MODE 0x000B
  278. /* CICADA CIS8201 Gigabit PHY Register Definition */
  279. #define CIS_IMR 0x0019
  280. #define CIS_INT_ENABLE 0x8000
  281. #define CIS_LINK_CHANGE_INT 0x2000
  282. #define CIS_ISR 0x001A
  283. #define CIS_INT_PENDING 0x8000
  284. #define CIS_LINK_CHANGE_STATUS 0x2000
  285. #define CIS_AUX_CTRL_STATUS 0x001C
  286. #define CIS_AUTONEG_COMPLETE 0x8000
  287. #define CIS_SPEED_MASK 0x0018
  288. #define CIS_SPEED_1000 0x0010
  289. #define CIS_SPEED_100 0x0008
  290. #define CIS_SPEED_10 0x0000
  291. #define CIS_DUPLEX 0x0020
  292. #define CIS_MEDIA_MASK (CIS_SPEED_MASK | CIS_DUPLEX)
  293. #define CIS_1000FULL (CIS_SPEED_1000 | CIS_DUPLEX)
  294. #define CIS_1000HALF CIS_SPEED_1000
  295. #define CIS_100FULL (CIS_SPEED_100 | CIS_DUPLEX)
  296. #define CIS_100HALF CIS_SPEED_100
  297. #define CIS_10FULL (CIS_SPEED_10 | CIS_DUPLEX)
  298. #define CIS_10HALF CIS_SPEED_10
  299. #define CIS_SMI_PRIORITY 0x0004
  300. static inline unsigned short INW (struct eth_device *dev, unsigned long addr)
  301. {
  302. return le16_to_cpu (*(volatile unsigned short *) (addr + dev->iobase));
  303. }
  304. static inline void OUTW (struct eth_device *dev, unsigned short command, unsigned long addr)
  305. {
  306. *(volatile unsigned short *) ((addr + dev->iobase)) = cpu_to_le16 (command);
  307. }
  308. /*
  309. Access RXBUFFER_START/TXBUFFER_START to read RX buffer/write TX buffer
  310. */
  311. #if defined (CONFIG_DRIVER_AX88180_16BIT)
  312. static inline unsigned short READ_RXBUF (struct eth_device *dev)
  313. {
  314. return le16_to_cpu (*(volatile unsigned short *) (RXBUFFER_START + dev->iobase));
  315. }
  316. static inline void WRITE_TXBUF (struct eth_device *dev, unsigned short data)
  317. {
  318. *(volatile unsigned short *) ((TXBUFFER_START + dev->iobase)) = cpu_to_le16 (data);
  319. }
  320. #else
  321. static inline unsigned long READ_RXBUF (struct eth_device *dev)
  322. {
  323. return le32_to_cpu (*(volatile unsigned long *) (RXBUFFER_START + dev->iobase));
  324. }
  325. static inline void WRITE_TXBUF (struct eth_device *dev, unsigned long data)
  326. {
  327. *(volatile unsigned long *) ((TXBUFFER_START + dev->iobase)) = cpu_to_le32 (data);
  328. }
  329. #endif
  330. #endif /* _AX88180_H_ */