atl1e_hw.h 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691
  1. /*
  2. * Copyright(c) 2007 Atheros Corporation. All rights reserved.
  3. *
  4. * Derived from Intel e1000 driver
  5. * Copyright(c) 1999 - 2005 Intel Corporation. All rights reserved.
  6. *
  7. * This program is free software; you can redistribute it and/or modify it
  8. * under the terms of the GNU General Public License as published by the Free
  9. * Software Foundation; either version 2 of the License, or (at your option)
  10. * any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful, but WITHOUT
  13. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  14. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  15. * more details.
  16. *
  17. * You should have received a copy of the GNU General Public License along with
  18. * this program; if not, write to the Free Software Foundation, Inc., 59
  19. * Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  20. */
  21. #ifndef _ATHL1E_HW_H_
  22. #define _ATHL1E_HW_H_
  23. #include <linux/types.h>
  24. #include <linux/mii.h>
  25. struct atl1e_adapter;
  26. struct atl1e_hw;
  27. /* function prototype */
  28. s32 atl1e_reset_hw(struct atl1e_hw *hw);
  29. s32 atl1e_read_mac_addr(struct atl1e_hw *hw);
  30. s32 atl1e_init_hw(struct atl1e_hw *hw);
  31. s32 atl1e_phy_commit(struct atl1e_hw *hw);
  32. s32 atl1e_get_speed_and_duplex(struct atl1e_hw *hw, u16 *speed, u16 *duplex);
  33. u32 atl1e_auto_get_fc(struct atl1e_adapter *adapter, u16 duplex);
  34. u32 atl1e_hash_mc_addr(struct atl1e_hw *hw, u8 *mc_addr);
  35. void atl1e_hash_set(struct atl1e_hw *hw, u32 hash_value);
  36. s32 atl1e_read_phy_reg(struct atl1e_hw *hw, u16 reg_addr, u16 *phy_data);
  37. s32 atl1e_write_phy_reg(struct atl1e_hw *hw, u32 reg_addr, u16 phy_data);
  38. s32 atl1e_validate_mdi_setting(struct atl1e_hw *hw);
  39. void atl1e_hw_set_mac_addr(struct atl1e_hw *hw);
  40. bool atl1e_read_eeprom(struct atl1e_hw *hw, u32 offset, u32 *p_value);
  41. bool atl1e_write_eeprom(struct atl1e_hw *hw, u32 offset, u32 value);
  42. s32 atl1e_phy_enter_power_saving(struct atl1e_hw *hw);
  43. s32 atl1e_phy_leave_power_saving(struct atl1e_hw *hw);
  44. s32 atl1e_phy_init(struct atl1e_hw *hw);
  45. int atl1e_check_eeprom_exist(struct atl1e_hw *hw);
  46. void atl1e_force_ps(struct atl1e_hw *hw);
  47. s32 atl1e_restart_autoneg(struct atl1e_hw *hw);
  48. /* register definition */
  49. #define REG_PM_CTRLSTAT 0x44
  50. #define REG_PCIE_CAP_LIST 0x58
  51. #define REG_DEVICE_CAP 0x5C
  52. #define DEVICE_CAP_MAX_PAYLOAD_MASK 0x7
  53. #define DEVICE_CAP_MAX_PAYLOAD_SHIFT 0
  54. #define REG_DEVICE_CTRL 0x60
  55. #define DEVICE_CTRL_MAX_PAYLOAD_MASK 0x7
  56. #define DEVICE_CTRL_MAX_PAYLOAD_SHIFT 5
  57. #define DEVICE_CTRL_MAX_RREQ_SZ_MASK 0x7
  58. #define DEVICE_CTRL_MAX_RREQ_SZ_SHIFT 12
  59. #define REG_VPD_CAP 0x6C
  60. #define VPD_CAP_ID_MASK 0xff
  61. #define VPD_CAP_ID_SHIFT 0
  62. #define VPD_CAP_NEXT_PTR_MASK 0xFF
  63. #define VPD_CAP_NEXT_PTR_SHIFT 8
  64. #define VPD_CAP_VPD_ADDR_MASK 0x7FFF
  65. #define VPD_CAP_VPD_ADDR_SHIFT 16
  66. #define VPD_CAP_VPD_FLAG 0x80000000
  67. #define REG_VPD_DATA 0x70
  68. #define REG_SPI_FLASH_CTRL 0x200
  69. #define SPI_FLASH_CTRL_STS_NON_RDY 0x1
  70. #define SPI_FLASH_CTRL_STS_WEN 0x2
  71. #define SPI_FLASH_CTRL_STS_WPEN 0x80
  72. #define SPI_FLASH_CTRL_DEV_STS_MASK 0xFF
  73. #define SPI_FLASH_CTRL_DEV_STS_SHIFT 0
  74. #define SPI_FLASH_CTRL_INS_MASK 0x7
  75. #define SPI_FLASH_CTRL_INS_SHIFT 8
  76. #define SPI_FLASH_CTRL_START 0x800
  77. #define SPI_FLASH_CTRL_EN_VPD 0x2000
  78. #define SPI_FLASH_CTRL_LDSTART 0x8000
  79. #define SPI_FLASH_CTRL_CS_HI_MASK 0x3
  80. #define SPI_FLASH_CTRL_CS_HI_SHIFT 16
  81. #define SPI_FLASH_CTRL_CS_HOLD_MASK 0x3
  82. #define SPI_FLASH_CTRL_CS_HOLD_SHIFT 18
  83. #define SPI_FLASH_CTRL_CLK_LO_MASK 0x3
  84. #define SPI_FLASH_CTRL_CLK_LO_SHIFT 20
  85. #define SPI_FLASH_CTRL_CLK_HI_MASK 0x3
  86. #define SPI_FLASH_CTRL_CLK_HI_SHIFT 22
  87. #define SPI_FLASH_CTRL_CS_SETUP_MASK 0x3
  88. #define SPI_FLASH_CTRL_CS_SETUP_SHIFT 24
  89. #define SPI_FLASH_CTRL_EROM_PGSZ_MASK 0x3
  90. #define SPI_FLASH_CTRL_EROM_PGSZ_SHIFT 26
  91. #define SPI_FLASH_CTRL_WAIT_READY 0x10000000
  92. #define REG_SPI_ADDR 0x204
  93. #define REG_SPI_DATA 0x208
  94. #define REG_SPI_FLASH_CONFIG 0x20C
  95. #define SPI_FLASH_CONFIG_LD_ADDR_MASK 0xFFFFFF
  96. #define SPI_FLASH_CONFIG_LD_ADDR_SHIFT 0
  97. #define SPI_FLASH_CONFIG_VPD_ADDR_MASK 0x3
  98. #define SPI_FLASH_CONFIG_VPD_ADDR_SHIFT 24
  99. #define SPI_FLASH_CONFIG_LD_EXIST 0x4000000
  100. #define REG_SPI_FLASH_OP_PROGRAM 0x210
  101. #define REG_SPI_FLASH_OP_SC_ERASE 0x211
  102. #define REG_SPI_FLASH_OP_CHIP_ERASE 0x212
  103. #define REG_SPI_FLASH_OP_RDID 0x213
  104. #define REG_SPI_FLASH_OP_WREN 0x214
  105. #define REG_SPI_FLASH_OP_RDSR 0x215
  106. #define REG_SPI_FLASH_OP_WRSR 0x216
  107. #define REG_SPI_FLASH_OP_READ 0x217
  108. #define REG_TWSI_CTRL 0x218
  109. #define TWSI_CTRL_LD_OFFSET_MASK 0xFF
  110. #define TWSI_CTRL_LD_OFFSET_SHIFT 0
  111. #define TWSI_CTRL_LD_SLV_ADDR_MASK 0x7
  112. #define TWSI_CTRL_LD_SLV_ADDR_SHIFT 8
  113. #define TWSI_CTRL_SW_LDSTART 0x800
  114. #define TWSI_CTRL_HW_LDSTART 0x1000
  115. #define TWSI_CTRL_SMB_SLV_ADDR_MASK 0x7F
  116. #define TWSI_CTRL_SMB_SLV_ADDR_SHIFT 15
  117. #define TWSI_CTRL_LD_EXIST 0x400000
  118. #define TWSI_CTRL_READ_FREQ_SEL_MASK 0x3
  119. #define TWSI_CTRL_READ_FREQ_SEL_SHIFT 23
  120. #define TWSI_CTRL_FREQ_SEL_100K 0
  121. #define TWSI_CTRL_FREQ_SEL_200K 1
  122. #define TWSI_CTRL_FREQ_SEL_300K 2
  123. #define TWSI_CTRL_FREQ_SEL_400K 3
  124. #define TWSI_CTRL_SMB_SLV_ADDR
  125. #define TWSI_CTRL_WRITE_FREQ_SEL_MASK 0x3
  126. #define TWSI_CTRL_WRITE_FREQ_SEL_SHIFT 24
  127. #define REG_PCIE_DEV_MISC_CTRL 0x21C
  128. #define PCIE_DEV_MISC_CTRL_EXT_PIPE 0x2
  129. #define PCIE_DEV_MISC_CTRL_RETRY_BUFDIS 0x1
  130. #define PCIE_DEV_MISC_CTRL_SPIROM_EXIST 0x4
  131. #define PCIE_DEV_MISC_CTRL_SERDES_ENDIAN 0x8
  132. #define PCIE_DEV_MISC_CTRL_SERDES_SEL_DIN 0x10
  133. #define REG_PCIE_PHYMISC 0x1000
  134. #define PCIE_PHYMISC_FORCE_RCV_DET 0x4
  135. #define REG_LTSSM_TEST_MODE 0x12FC
  136. #define LTSSM_TEST_MODE_DEF 0xE000
  137. /* Selene Master Control Register */
  138. #define REG_MASTER_CTRL 0x1400
  139. #define MASTER_CTRL_SOFT_RST 0x1
  140. #define MASTER_CTRL_MTIMER_EN 0x2
  141. #define MASTER_CTRL_ITIMER_EN 0x4
  142. #define MASTER_CTRL_MANUAL_INT 0x8
  143. #define MASTER_CTRL_ITIMER2_EN 0x20
  144. #define MASTER_CTRL_INT_RDCLR 0x40
  145. #define MASTER_CTRL_LED_MODE 0x200
  146. #define MASTER_CTRL_REV_NUM_SHIFT 16
  147. #define MASTER_CTRL_REV_NUM_MASK 0xff
  148. #define MASTER_CTRL_DEV_ID_SHIFT 24
  149. #define MASTER_CTRL_DEV_ID_MASK 0xff
  150. /* Timer Initial Value Register */
  151. #define REG_MANUAL_TIMER_INIT 0x1404
  152. /* IRQ ModeratorTimer Initial Value Register */
  153. #define REG_IRQ_MODU_TIMER_INIT 0x1408 /* w */
  154. #define REG_IRQ_MODU_TIMER2_INIT 0x140A /* w */
  155. #define REG_GPHY_CTRL 0x140C
  156. #define GPHY_CTRL_EXT_RESET 1
  157. #define GPHY_CTRL_PIPE_MOD 2
  158. #define GPHY_CTRL_TEST_MODE_MASK 3
  159. #define GPHY_CTRL_TEST_MODE_SHIFT 2
  160. #define GPHY_CTRL_BERT_START 0x10
  161. #define GPHY_CTRL_GATE_25M_EN 0x20
  162. #define GPHY_CTRL_LPW_EXIT 0x40
  163. #define GPHY_CTRL_PHY_IDDQ 0x80
  164. #define GPHY_CTRL_PHY_IDDQ_DIS 0x100
  165. #define GPHY_CTRL_PCLK_SEL_DIS 0x200
  166. #define GPHY_CTRL_HIB_EN 0x400
  167. #define GPHY_CTRL_HIB_PULSE 0x800
  168. #define GPHY_CTRL_SEL_ANA_RST 0x1000
  169. #define GPHY_CTRL_PHY_PLL_ON 0x2000
  170. #define GPHY_CTRL_PWDOWN_HW 0x4000
  171. #define GPHY_CTRL_DEFAULT (\
  172. GPHY_CTRL_PHY_PLL_ON |\
  173. GPHY_CTRL_SEL_ANA_RST |\
  174. GPHY_CTRL_HIB_PULSE |\
  175. GPHY_CTRL_HIB_EN)
  176. #define GPHY_CTRL_PW_WOL_DIS (\
  177. GPHY_CTRL_PHY_PLL_ON |\
  178. GPHY_CTRL_SEL_ANA_RST |\
  179. GPHY_CTRL_HIB_PULSE |\
  180. GPHY_CTRL_HIB_EN |\
  181. GPHY_CTRL_PWDOWN_HW |\
  182. GPHY_CTRL_PCLK_SEL_DIS |\
  183. GPHY_CTRL_PHY_IDDQ)
  184. /* IRQ Anti-Lost Timer Initial Value Register */
  185. #define REG_CMBDISDMA_TIMER 0x140E
  186. /* Block IDLE Status Register */
  187. #define REG_IDLE_STATUS 0x1410
  188. #define IDLE_STATUS_RXMAC 1 /* 1: RXMAC state machine is in non-IDLE state. 0: RXMAC is idling */
  189. #define IDLE_STATUS_TXMAC 2 /* 1: TXMAC state machine is in non-IDLE state. 0: TXMAC is idling */
  190. #define IDLE_STATUS_RXQ 4 /* 1: RXQ state machine is in non-IDLE state. 0: RXQ is idling */
  191. #define IDLE_STATUS_TXQ 8 /* 1: TXQ state machine is in non-IDLE state. 0: TXQ is idling */
  192. #define IDLE_STATUS_DMAR 0x10 /* 1: DMAR state machine is in non-IDLE state. 0: DMAR is idling */
  193. #define IDLE_STATUS_DMAW 0x20 /* 1: DMAW state machine is in non-IDLE state. 0: DMAW is idling */
  194. #define IDLE_STATUS_SMB 0x40 /* 1: SMB state machine is in non-IDLE state. 0: SMB is idling */
  195. #define IDLE_STATUS_CMB 0x80 /* 1: CMB state machine is in non-IDLE state. 0: CMB is idling */
  196. /* MDIO Control Register */
  197. #define REG_MDIO_CTRL 0x1414
  198. #define MDIO_DATA_MASK 0xffff /* On MDIO write, the 16-bit control data to write to PHY MII management register */
  199. #define MDIO_DATA_SHIFT 0 /* On MDIO read, the 16-bit status data that was read from the PHY MII management register*/
  200. #define MDIO_REG_ADDR_MASK 0x1f /* MDIO register address */
  201. #define MDIO_REG_ADDR_SHIFT 16
  202. #define MDIO_RW 0x200000 /* 1: read, 0: write */
  203. #define MDIO_SUP_PREAMBLE 0x400000 /* Suppress preamble */
  204. #define MDIO_START 0x800000 /* Write 1 to initiate the MDIO master. And this bit is self cleared after one cycle*/
  205. #define MDIO_CLK_SEL_SHIFT 24
  206. #define MDIO_CLK_25_4 0
  207. #define MDIO_CLK_25_6 2
  208. #define MDIO_CLK_25_8 3
  209. #define MDIO_CLK_25_10 4
  210. #define MDIO_CLK_25_14 5
  211. #define MDIO_CLK_25_20 6
  212. #define MDIO_CLK_25_28 7
  213. #define MDIO_BUSY 0x8000000
  214. #define MDIO_AP_EN 0x10000000
  215. #define MDIO_WAIT_TIMES 10
  216. /* MII PHY Status Register */
  217. #define REG_PHY_STATUS 0x1418
  218. #define PHY_STATUS_100M 0x20000
  219. #define PHY_STATUS_EMI_CA 0x40000
  220. /* BIST Control and Status Register0 (for the Packet Memory) */
  221. #define REG_BIST0_CTRL 0x141c
  222. #define BIST0_NOW 0x1 /* 1: To trigger BIST0 logic. This bit stays high during the */
  223. /* BIST process and reset to zero when BIST is done */
  224. #define BIST0_SRAM_FAIL 0x2 /* 1: The SRAM failure is un-repairable because it has address */
  225. /* decoder failure or more than 1 cell stuck-to-x failure */
  226. #define BIST0_FUSE_FLAG 0x4 /* 1: Indicating one cell has been fixed */
  227. /* BIST Control and Status Register1(for the retry buffer of PCI Express) */
  228. #define REG_BIST1_CTRL 0x1420
  229. #define BIST1_NOW 0x1 /* 1: To trigger BIST0 logic. This bit stays high during the */
  230. /* BIST process and reset to zero when BIST is done */
  231. #define BIST1_SRAM_FAIL 0x2 /* 1: The SRAM failure is un-repairable because it has address */
  232. /* decoder failure or more than 1 cell stuck-to-x failure.*/
  233. #define BIST1_FUSE_FLAG 0x4
  234. /* SerDes Lock Detect Control and Status Register */
  235. #define REG_SERDES_LOCK 0x1424
  236. #define SERDES_LOCK_DETECT 1 /* 1: SerDes lock detected . This signal comes from Analog SerDes */
  237. #define SERDES_LOCK_DETECT_EN 2 /* 1: Enable SerDes Lock detect function */
  238. /* MAC Control Register */
  239. #define REG_MAC_CTRL 0x1480
  240. #define MAC_CTRL_TX_EN 1 /* 1: Transmit Enable */
  241. #define MAC_CTRL_RX_EN 2 /* 1: Receive Enable */
  242. #define MAC_CTRL_TX_FLOW 4 /* 1: Transmit Flow Control Enable */
  243. #define MAC_CTRL_RX_FLOW 8 /* 1: Receive Flow Control Enable */
  244. #define MAC_CTRL_LOOPBACK 0x10 /* 1: Loop back at G/MII Interface */
  245. #define MAC_CTRL_DUPLX 0x20 /* 1: Full-duplex mode 0: Half-duplex mode */
  246. #define MAC_CTRL_ADD_CRC 0x40 /* 1: Instruct MAC to attach CRC on all egress Ethernet frames */
  247. #define MAC_CTRL_PAD 0x80 /* 1: Instruct MAC to pad short frames to 60-bytes, and then attach CRC. This bit has higher priority over CRC_EN */
  248. #define MAC_CTRL_LENCHK 0x100 /* 1: Instruct MAC to check if length field matches the real packet length */
  249. #define MAC_CTRL_HUGE_EN 0x200 /* 1: receive Jumbo frame enable */
  250. #define MAC_CTRL_PRMLEN_SHIFT 10 /* Preamble length */
  251. #define MAC_CTRL_PRMLEN_MASK 0xf
  252. #define MAC_CTRL_RMV_VLAN 0x4000 /* 1: to remove VLAN Tag automatically from all receive packets */
  253. #define MAC_CTRL_PROMIS_EN 0x8000 /* 1: Promiscuous Mode Enable */
  254. #define MAC_CTRL_TX_PAUSE 0x10000 /* 1: transmit test pause */
  255. #define MAC_CTRL_SCNT 0x20000 /* 1: shortcut slot time counter */
  256. #define MAC_CTRL_SRST_TX 0x40000 /* 1: synchronized reset Transmit MAC module */
  257. #define MAC_CTRL_TX_SIMURST 0x80000 /* 1: transmit simulation reset */
  258. #define MAC_CTRL_SPEED_SHIFT 20 /* 10: gigabit 01:10M/100M */
  259. #define MAC_CTRL_SPEED_MASK 0x300000
  260. #define MAC_CTRL_SPEED_1000 2
  261. #define MAC_CTRL_SPEED_10_100 1
  262. #define MAC_CTRL_DBG_TX_BKPRESURE 0x400000 /* 1: transmit maximum backoff (half-duplex test bit) */
  263. #define MAC_CTRL_TX_HUGE 0x800000 /* 1: transmit huge enable */
  264. #define MAC_CTRL_RX_CHKSUM_EN 0x1000000 /* 1: RX checksum enable */
  265. #define MAC_CTRL_MC_ALL_EN 0x2000000 /* 1: upload all multicast frame without error to system */
  266. #define MAC_CTRL_BC_EN 0x4000000 /* 1: upload all broadcast frame without error to system */
  267. #define MAC_CTRL_DBG 0x8000000 /* 1: upload all received frame to system (Debug Mode) */
  268. /* MAC IPG/IFG Control Register */
  269. #define REG_MAC_IPG_IFG 0x1484
  270. #define MAC_IPG_IFG_IPGT_SHIFT 0 /* Desired back to back inter-packet gap. The default is 96-bit time */
  271. #define MAC_IPG_IFG_IPGT_MASK 0x7f
  272. #define MAC_IPG_IFG_MIFG_SHIFT 8 /* Minimum number of IFG to enforce in between RX frames */
  273. #define MAC_IPG_IFG_MIFG_MASK 0xff /* Frame gap below such IFP is dropped */
  274. #define MAC_IPG_IFG_IPGR1_SHIFT 16 /* 64bit Carrier-Sense window */
  275. #define MAC_IPG_IFG_IPGR1_MASK 0x7f
  276. #define MAC_IPG_IFG_IPGR2_SHIFT 24 /* 96-bit IPG window */
  277. #define MAC_IPG_IFG_IPGR2_MASK 0x7f
  278. /* MAC STATION ADDRESS */
  279. #define REG_MAC_STA_ADDR 0x1488
  280. /* Hash table for multicast address */
  281. #define REG_RX_HASH_TABLE 0x1490
  282. /* MAC Half-Duplex Control Register */
  283. #define REG_MAC_HALF_DUPLX_CTRL 0x1498
  284. #define MAC_HALF_DUPLX_CTRL_LCOL_SHIFT 0 /* Collision Window */
  285. #define MAC_HALF_DUPLX_CTRL_LCOL_MASK 0x3ff
  286. #define MAC_HALF_DUPLX_CTRL_RETRY_SHIFT 12 /* Retransmission maximum, afterwards the packet will be discarded */
  287. #define MAC_HALF_DUPLX_CTRL_RETRY_MASK 0xf
  288. #define MAC_HALF_DUPLX_CTRL_EXC_DEF_EN 0x10000 /* 1: Allow the transmission of a packet which has been excessively deferred */
  289. #define MAC_HALF_DUPLX_CTRL_NO_BACK_C 0x20000 /* 1: No back-off on collision, immediately start the retransmission */
  290. #define MAC_HALF_DUPLX_CTRL_NO_BACK_P 0x40000 /* 1: No back-off on backpressure, immediately start the transmission after back pressure */
  291. #define MAC_HALF_DUPLX_CTRL_ABEBE 0x80000 /* 1: Alternative Binary Exponential Back-off Enabled */
  292. #define MAC_HALF_DUPLX_CTRL_ABEBT_SHIFT 20 /* Maximum binary exponential number */
  293. #define MAC_HALF_DUPLX_CTRL_ABEBT_MASK 0xf
  294. #define MAC_HALF_DUPLX_CTRL_JAMIPG_SHIFT 24 /* IPG to start JAM for collision based flow control in half-duplex */
  295. #define MAC_HALF_DUPLX_CTRL_JAMIPG_MASK 0xf /* mode. In unit of 8-bit time */
  296. /* Maximum Frame Length Control Register */
  297. #define REG_MTU 0x149c
  298. /* Wake-On-Lan control register */
  299. #define REG_WOL_CTRL 0x14a0
  300. #define WOL_PATTERN_EN 0x00000001
  301. #define WOL_PATTERN_PME_EN 0x00000002
  302. #define WOL_MAGIC_EN 0x00000004
  303. #define WOL_MAGIC_PME_EN 0x00000008
  304. #define WOL_LINK_CHG_EN 0x00000010
  305. #define WOL_LINK_CHG_PME_EN 0x00000020
  306. #define WOL_PATTERN_ST 0x00000100
  307. #define WOL_MAGIC_ST 0x00000200
  308. #define WOL_LINKCHG_ST 0x00000400
  309. #define WOL_CLK_SWITCH_EN 0x00008000
  310. #define WOL_PT0_EN 0x00010000
  311. #define WOL_PT1_EN 0x00020000
  312. #define WOL_PT2_EN 0x00040000
  313. #define WOL_PT3_EN 0x00080000
  314. #define WOL_PT4_EN 0x00100000
  315. #define WOL_PT5_EN 0x00200000
  316. #define WOL_PT6_EN 0x00400000
  317. /* WOL Length ( 2 DWORD ) */
  318. #define REG_WOL_PATTERN_LEN 0x14a4
  319. #define WOL_PT_LEN_MASK 0x7f
  320. #define WOL_PT0_LEN_SHIFT 0
  321. #define WOL_PT1_LEN_SHIFT 8
  322. #define WOL_PT2_LEN_SHIFT 16
  323. #define WOL_PT3_LEN_SHIFT 24
  324. #define WOL_PT4_LEN_SHIFT 0
  325. #define WOL_PT5_LEN_SHIFT 8
  326. #define WOL_PT6_LEN_SHIFT 16
  327. /* Internal SRAM Partition Register */
  328. #define REG_SRAM_TRD_ADDR 0x1518
  329. #define REG_SRAM_TRD_LEN 0x151C
  330. #define REG_SRAM_RXF_ADDR 0x1520
  331. #define REG_SRAM_RXF_LEN 0x1524
  332. #define REG_SRAM_TXF_ADDR 0x1528
  333. #define REG_SRAM_TXF_LEN 0x152C
  334. #define REG_SRAM_TCPH_ADDR 0x1530
  335. #define REG_SRAM_PKTH_ADDR 0x1532
  336. /* Load Ptr Register */
  337. #define REG_LOAD_PTR 0x1534 /* Software sets this bit after the initialization of the head and tail */
  338. /*
  339. * addresses of all descriptors, as well as the following descriptor
  340. * control register, which triggers each function block to load the head
  341. * pointer to prepare for the operation. This bit is then self-cleared
  342. * after one cycle.
  343. */
  344. /* Descriptor Control register */
  345. #define REG_RXF3_BASE_ADDR_HI 0x153C
  346. #define REG_DESC_BASE_ADDR_HI 0x1540
  347. #define REG_RXF0_BASE_ADDR_HI 0x1540 /* share with DESC BASE ADDR HI */
  348. #define REG_HOST_RXF0_PAGE0_LO 0x1544
  349. #define REG_HOST_RXF0_PAGE1_LO 0x1548
  350. #define REG_TPD_BASE_ADDR_LO 0x154C
  351. #define REG_RXF1_BASE_ADDR_HI 0x1550
  352. #define REG_RXF2_BASE_ADDR_HI 0x1554
  353. #define REG_HOST_RXFPAGE_SIZE 0x1558
  354. #define REG_TPD_RING_SIZE 0x155C
  355. /* RSS about */
  356. #define REG_RSS_KEY0 0x14B0
  357. #define REG_RSS_KEY1 0x14B4
  358. #define REG_RSS_KEY2 0x14B8
  359. #define REG_RSS_KEY3 0x14BC
  360. #define REG_RSS_KEY4 0x14C0
  361. #define REG_RSS_KEY5 0x14C4
  362. #define REG_RSS_KEY6 0x14C8
  363. #define REG_RSS_KEY7 0x14CC
  364. #define REG_RSS_KEY8 0x14D0
  365. #define REG_RSS_KEY9 0x14D4
  366. #define REG_IDT_TABLE4 0x14E0
  367. #define REG_IDT_TABLE5 0x14E4
  368. #define REG_IDT_TABLE6 0x14E8
  369. #define REG_IDT_TABLE7 0x14EC
  370. #define REG_IDT_TABLE0 0x1560
  371. #define REG_IDT_TABLE1 0x1564
  372. #define REG_IDT_TABLE2 0x1568
  373. #define REG_IDT_TABLE3 0x156C
  374. #define REG_IDT_TABLE REG_IDT_TABLE0
  375. #define REG_RSS_HASH_VALUE 0x1570
  376. #define REG_RSS_HASH_FLAG 0x1574
  377. #define REG_BASE_CPU_NUMBER 0x157C
  378. /* TXQ Control Register */
  379. #define REG_TXQ_CTRL 0x1580
  380. #define TXQ_CTRL_NUM_TPD_BURST_MASK 0xF
  381. #define TXQ_CTRL_NUM_TPD_BURST_SHIFT 0
  382. #define TXQ_CTRL_EN 0x20 /* 1: Enable TXQ */
  383. #define TXQ_CTRL_ENH_MODE 0x40 /* Performance enhancement mode, in which up to two back-to-back DMA read commands might be dispatched. */
  384. #define TXQ_CTRL_TXF_BURST_NUM_SHIFT 16 /* Number of data byte to read in a cache-aligned burst. Each SRAM entry is 8-byte in length. */
  385. #define TXQ_CTRL_TXF_BURST_NUM_MASK 0xffff
  386. /* Jumbo packet Threshold for task offload */
  387. #define REG_TX_EARLY_TH 0x1584 /* Jumbo frame threshold in QWORD unit. Packet greater than */
  388. /* JUMBO_TASK_OFFLOAD_THRESHOLD will not be task offloaded. */
  389. #define TX_TX_EARLY_TH_MASK 0x7ff
  390. #define TX_TX_EARLY_TH_SHIFT 0
  391. /* RXQ Control Register */
  392. #define REG_RXQ_CTRL 0x15A0
  393. #define RXQ_CTRL_PBA_ALIGN_32 0 /* rx-packet alignment */
  394. #define RXQ_CTRL_PBA_ALIGN_64 1
  395. #define RXQ_CTRL_PBA_ALIGN_128 2
  396. #define RXQ_CTRL_PBA_ALIGN_256 3
  397. #define RXQ_CTRL_Q1_EN 0x10
  398. #define RXQ_CTRL_Q2_EN 0x20
  399. #define RXQ_CTRL_Q3_EN 0x40
  400. #define RXQ_CTRL_IPV6_XSUM_VERIFY_EN 0x80
  401. #define RXQ_CTRL_HASH_TLEN_SHIFT 8
  402. #define RXQ_CTRL_HASH_TLEN_MASK 0xFF
  403. #define RXQ_CTRL_HASH_TYPE_IPV4 0x10000
  404. #define RXQ_CTRL_HASH_TYPE_IPV4_TCP 0x20000
  405. #define RXQ_CTRL_HASH_TYPE_IPV6 0x40000
  406. #define RXQ_CTRL_HASH_TYPE_IPV6_TCP 0x80000
  407. #define RXQ_CTRL_RSS_MODE_DISABLE 0
  408. #define RXQ_CTRL_RSS_MODE_SQSINT 0x4000000
  409. #define RXQ_CTRL_RSS_MODE_MQUESINT 0x8000000
  410. #define RXQ_CTRL_RSS_MODE_MQUEMINT 0xC000000
  411. #define RXQ_CTRL_NIP_QUEUE_SEL_TBL 0x10000000
  412. #define RXQ_CTRL_HASH_ENABLE 0x20000000
  413. #define RXQ_CTRL_CUT_THRU_EN 0x40000000
  414. #define RXQ_CTRL_EN 0x80000000
  415. /* Rx jumbo packet threshold and rrd retirement timer */
  416. #define REG_RXQ_JMBOSZ_RRDTIM 0x15A4
  417. /*
  418. * Jumbo packet threshold for non-VLAN packet, in QWORD (64-bit) unit.
  419. * When the packet length greater than or equal to this value, RXQ
  420. * shall start cut-through forwarding of the received packet.
  421. */
  422. #define RXQ_JMBOSZ_TH_MASK 0x7ff
  423. #define RXQ_JMBOSZ_TH_SHIFT 0 /* RRD retirement timer. Decrement by 1 after every 512ns passes*/
  424. #define RXQ_JMBO_LKAH_MASK 0xf
  425. #define RXQ_JMBO_LKAH_SHIFT 11
  426. /* RXF flow control register */
  427. #define REG_RXQ_RXF_PAUSE_THRESH 0x15A8
  428. #define RXQ_RXF_PAUSE_TH_HI_SHIFT 0
  429. #define RXQ_RXF_PAUSE_TH_HI_MASK 0xfff
  430. #define RXQ_RXF_PAUSE_TH_LO_SHIFT 16
  431. #define RXQ_RXF_PAUSE_TH_LO_MASK 0xfff
  432. /* DMA Engine Control Register */
  433. #define REG_DMA_CTRL 0x15C0
  434. #define DMA_CTRL_DMAR_IN_ORDER 0x1
  435. #define DMA_CTRL_DMAR_ENH_ORDER 0x2
  436. #define DMA_CTRL_DMAR_OUT_ORDER 0x4
  437. #define DMA_CTRL_RCB_VALUE 0x8
  438. #define DMA_CTRL_DMAR_BURST_LEN_SHIFT 4
  439. #define DMA_CTRL_DMAR_BURST_LEN_MASK 7
  440. #define DMA_CTRL_DMAW_BURST_LEN_SHIFT 7
  441. #define DMA_CTRL_DMAW_BURST_LEN_MASK 7
  442. #define DMA_CTRL_DMAR_REQ_PRI 0x400
  443. #define DMA_CTRL_DMAR_DLY_CNT_MASK 0x1F
  444. #define DMA_CTRL_DMAR_DLY_CNT_SHIFT 11
  445. #define DMA_CTRL_DMAW_DLY_CNT_MASK 0xF
  446. #define DMA_CTRL_DMAW_DLY_CNT_SHIFT 16
  447. #define DMA_CTRL_TXCMB_EN 0x100000
  448. #define DMA_CTRL_RXCMB_EN 0x200000
  449. /* CMB/SMB Control Register */
  450. #define REG_SMB_STAT_TIMER 0x15C4
  451. #define REG_TRIG_RRD_THRESH 0x15CA
  452. #define REG_TRIG_TPD_THRESH 0x15C8
  453. #define REG_TRIG_TXTIMER 0x15CC
  454. #define REG_TRIG_RXTIMER 0x15CE
  455. /* HOST RXF Page 1,2,3 address */
  456. #define REG_HOST_RXF1_PAGE0_LO 0x15D0
  457. #define REG_HOST_RXF1_PAGE1_LO 0x15D4
  458. #define REG_HOST_RXF2_PAGE0_LO 0x15D8
  459. #define REG_HOST_RXF2_PAGE1_LO 0x15DC
  460. #define REG_HOST_RXF3_PAGE0_LO 0x15E0
  461. #define REG_HOST_RXF3_PAGE1_LO 0x15E4
  462. /* Mail box */
  463. #define REG_MB_RXF1_RADDR 0x15B4
  464. #define REG_MB_RXF2_RADDR 0x15B8
  465. #define REG_MB_RXF3_RADDR 0x15BC
  466. #define REG_MB_TPD_PROD_IDX 0x15F0
  467. /* RXF-Page 0-3 PageNo & Valid bit */
  468. #define REG_HOST_RXF0_PAGE0_VLD 0x15F4
  469. #define HOST_RXF_VALID 1
  470. #define HOST_RXF_PAGENO_SHIFT 1
  471. #define HOST_RXF_PAGENO_MASK 0x7F
  472. #define REG_HOST_RXF0_PAGE1_VLD 0x15F5
  473. #define REG_HOST_RXF1_PAGE0_VLD 0x15F6
  474. #define REG_HOST_RXF1_PAGE1_VLD 0x15F7
  475. #define REG_HOST_RXF2_PAGE0_VLD 0x15F8
  476. #define REG_HOST_RXF2_PAGE1_VLD 0x15F9
  477. #define REG_HOST_RXF3_PAGE0_VLD 0x15FA
  478. #define REG_HOST_RXF3_PAGE1_VLD 0x15FB
  479. /* Interrupt Status Register */
  480. #define REG_ISR 0x1600
  481. #define ISR_SMB 1
  482. #define ISR_TIMER 2 /* Interrupt when Timer is counted down to zero */
  483. /*
  484. * Software manual interrupt, for debug. Set when SW_MAN_INT_EN is set
  485. * in Table 51 Selene Master Control Register (Offset 0x1400).
  486. */
  487. #define ISR_MANUAL 4
  488. #define ISR_HW_RXF_OV 8 /* RXF overflow interrupt */
  489. #define ISR_HOST_RXF0_OV 0x10
  490. #define ISR_HOST_RXF1_OV 0x20
  491. #define ISR_HOST_RXF2_OV 0x40
  492. #define ISR_HOST_RXF3_OV 0x80
  493. #define ISR_TXF_UN 0x100
  494. #define ISR_RX0_PAGE_FULL 0x200
  495. #define ISR_DMAR_TO_RST 0x400
  496. #define ISR_DMAW_TO_RST 0x800
  497. #define ISR_GPHY 0x1000
  498. #define ISR_TX_CREDIT 0x2000
  499. #define ISR_GPHY_LPW 0x4000 /* GPHY low power state interrupt */
  500. #define ISR_RX_PKT 0x10000 /* One packet received, triggered by RFD */
  501. #define ISR_TX_PKT 0x20000 /* One packet transmitted, triggered by TPD */
  502. #define ISR_TX_DMA 0x40000
  503. #define ISR_RX_PKT_1 0x80000
  504. #define ISR_RX_PKT_2 0x100000
  505. #define ISR_RX_PKT_3 0x200000
  506. #define ISR_MAC_RX 0x400000
  507. #define ISR_MAC_TX 0x800000
  508. #define ISR_UR_DETECTED 0x1000000
  509. #define ISR_FERR_DETECTED 0x2000000
  510. #define ISR_NFERR_DETECTED 0x4000000
  511. #define ISR_CERR_DETECTED 0x8000000
  512. #define ISR_PHY_LINKDOWN 0x10000000
  513. #define ISR_DIS_INT 0x80000000
  514. /* Interrupt Mask Register */
  515. #define REG_IMR 0x1604
  516. #define IMR_NORMAL_MASK (\
  517. ISR_SMB |\
  518. ISR_TXF_UN |\
  519. ISR_HW_RXF_OV |\
  520. ISR_HOST_RXF0_OV|\
  521. ISR_MANUAL |\
  522. ISR_GPHY |\
  523. ISR_GPHY_LPW |\
  524. ISR_DMAR_TO_RST |\
  525. ISR_DMAW_TO_RST |\
  526. ISR_PHY_LINKDOWN|\
  527. ISR_RX_PKT |\
  528. ISR_TX_PKT)
  529. #define ISR_TX_EVENT (ISR_TXF_UN | ISR_TX_PKT)
  530. #define ISR_RX_EVENT (ISR_HOST_RXF0_OV | ISR_HW_RXF_OV | ISR_RX_PKT)
  531. #define REG_MAC_RX_STATUS_BIN 0x1700
  532. #define REG_MAC_RX_STATUS_END 0x175c
  533. #define REG_MAC_TX_STATUS_BIN 0x1760
  534. #define REG_MAC_TX_STATUS_END 0x17c0
  535. /* Hardware Offset Register */
  536. #define REG_HOST_RXF0_PAGEOFF 0x1800
  537. #define REG_TPD_CONS_IDX 0x1804
  538. #define REG_HOST_RXF1_PAGEOFF 0x1808
  539. #define REG_HOST_RXF2_PAGEOFF 0x180C
  540. #define REG_HOST_RXF3_PAGEOFF 0x1810
  541. /* RXF-Page 0-3 Offset DMA Address */
  542. #define REG_HOST_RXF0_MB0_LO 0x1820
  543. #define REG_HOST_RXF0_MB1_LO 0x1824
  544. #define REG_HOST_RXF1_MB0_LO 0x1828
  545. #define REG_HOST_RXF1_MB1_LO 0x182C
  546. #define REG_HOST_RXF2_MB0_LO 0x1830
  547. #define REG_HOST_RXF2_MB1_LO 0x1834
  548. #define REG_HOST_RXF3_MB0_LO 0x1838
  549. #define REG_HOST_RXF3_MB1_LO 0x183C
  550. /* Tpd CMB DMA Address */
  551. #define REG_HOST_TX_CMB_LO 0x1840
  552. #define REG_HOST_SMB_ADDR_LO 0x1844
  553. /* DEBUG ADDR */
  554. #define REG_DEBUG_DATA0 0x1900
  555. #define REG_DEBUG_DATA1 0x1904
  556. /***************************** MII definition ***************************************/
  557. /* PHY Common Register */
  558. #define MII_AT001_PSCR 0x10
  559. #define MII_AT001_PSSR 0x11
  560. #define MII_INT_CTRL 0x12
  561. #define MII_INT_STATUS 0x13
  562. #define MII_SMARTSPEED 0x14
  563. #define MII_LBRERROR 0x18
  564. #define MII_RESV2 0x1a
  565. #define MII_DBG_ADDR 0x1D
  566. #define MII_DBG_DATA 0x1E
  567. /* Autoneg Advertisement Register */
  568. #define MII_AR_DEFAULT_CAP_MASK 0
  569. /* 1000BASE-T Control Register */
  570. #define MII_AT001_CR_1000T_SPEED_MASK \
  571. (ADVERTISE_1000FULL | ADVERTISE_1000HALF)
  572. #define MII_AT001_CR_1000T_DEFAULT_CAP_MASK MII_AT001_CR_1000T_SPEED_MASK
  573. /* AT001 PHY Specific Control Register */
  574. #define MII_AT001_PSCR_JABBER_DISABLE 0x0001 /* 1=Jabber Function disabled */
  575. #define MII_AT001_PSCR_POLARITY_REVERSAL 0x0002 /* 1=Polarity Reversal enabled */
  576. #define MII_AT001_PSCR_SQE_TEST 0x0004 /* 1=SQE Test enabled */
  577. #define MII_AT001_PSCR_MAC_POWERDOWN 0x0008
  578. #define MII_AT001_PSCR_CLK125_DISABLE 0x0010 /* 1=CLK125 low,
  579. * 0=CLK125 toggling
  580. */
  581. #define MII_AT001_PSCR_MDI_MANUAL_MODE 0x0000 /* MDI Crossover Mode bits 6:5 */
  582. /* Manual MDI configuration */
  583. #define MII_AT001_PSCR_MDIX_MANUAL_MODE 0x0020 /* Manual MDIX configuration */
  584. #define MII_AT001_PSCR_AUTO_X_1000T 0x0040 /* 1000BASE-T: Auto crossover,
  585. * 100BASE-TX/10BASE-T:
  586. * MDI Mode
  587. */
  588. #define MII_AT001_PSCR_AUTO_X_MODE 0x0060 /* Auto crossover enabled
  589. * all speeds.
  590. */
  591. #define MII_AT001_PSCR_10BT_EXT_DIST_ENABLE 0x0080
  592. /* 1=Enable Extended 10BASE-T distance
  593. * (Lower 10BASE-T RX Threshold)
  594. * 0=Normal 10BASE-T RX Threshold */
  595. #define MII_AT001_PSCR_MII_5BIT_ENABLE 0x0100
  596. /* 1=5-Bit interface in 100BASE-TX
  597. * 0=MII interface in 100BASE-TX */
  598. #define MII_AT001_PSCR_SCRAMBLER_DISABLE 0x0200 /* 1=Scrambler disable */
  599. #define MII_AT001_PSCR_FORCE_LINK_GOOD 0x0400 /* 1=Force link good */
  600. #define MII_AT001_PSCR_ASSERT_CRS_ON_TX 0x0800 /* 1=Assert CRS on Transmit */
  601. #define MII_AT001_PSCR_POLARITY_REVERSAL_SHIFT 1
  602. #define MII_AT001_PSCR_AUTO_X_MODE_SHIFT 5
  603. #define MII_AT001_PSCR_10BT_EXT_DIST_ENABLE_SHIFT 7
  604. /* AT001 PHY Specific Status Register */
  605. #define MII_AT001_PSSR_SPD_DPLX_RESOLVED 0x0800 /* 1=Speed & Duplex resolved */
  606. #define MII_AT001_PSSR_DPLX 0x2000 /* 1=Duplex 0=Half Duplex */
  607. #define MII_AT001_PSSR_SPEED 0xC000 /* Speed, bits 14:15 */
  608. #define MII_AT001_PSSR_10MBS 0x0000 /* 00=10Mbs */
  609. #define MII_AT001_PSSR_100MBS 0x4000 /* 01=100Mbs */
  610. #define MII_AT001_PSSR_1000MBS 0x8000 /* 10=1000Mbs */
  611. #endif /*_ATHL1E_HW_H_*/