atl1_hw.h 36 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951
  1. /*
  2. * Copyright(c) 2005 - 2006 Attansic Corporation. All rights reserved.
  3. * Copyright(c) 2006 Chris Snook <csnook@redhat.com>
  4. * Copyright(c) 2006 Jay Cliburn <jcliburn@gmail.com>
  5. *
  6. * Derived from Intel e1000 driver
  7. * Copyright(c) 1999 - 2005 Intel Corporation. All rights reserved.
  8. *
  9. * This program is free software; you can redistribute it and/or modify it
  10. * under the terms of the GNU General Public License as published by the Free
  11. * Software Foundation; either version 2 of the License, or (at your option)
  12. * any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful, but WITHOUT
  15. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  16. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  17. * more details.
  18. *
  19. * You should have received a copy of the GNU General Public License along with
  20. * this program; if not, write to the Free Software Foundation, Inc., 59
  21. * Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  22. *
  23. * There are a lot of defines in here that are unused and/or have cryptic
  24. * names. Please leave them alone, as they're the closest thing we have
  25. * to a spec from Attansic at present. *ahem* -- CHS
  26. */
  27. #ifndef _ATL1_HW_H_
  28. #define _ATL1_HW_H_
  29. #include <linux/types.h>
  30. #include <linux/mii.h>
  31. struct atl1_adapter;
  32. struct atl1_hw;
  33. /* function prototypes needed by multiple files */
  34. s32 atl1_phy_setup_autoneg_adv(struct atl1_hw *hw);
  35. s32 atl1_write_phy_reg(struct atl1_hw *hw, u32 reg_addr, u16 phy_data);
  36. s32 atl1_get_speed_and_duplex(struct atl1_hw *hw, u16 *speed, u16 *duplex);
  37. s32 atl1_read_mac_addr(struct atl1_hw *hw);
  38. s32 atl1_init_hw(struct atl1_hw *hw);
  39. s32 atl1_get_speed_and_duplex(struct atl1_hw *hw, u16 *speed, u16 *duplex);
  40. s32 atl1_set_speed_and_duplex(struct atl1_hw *hw, u16 speed, u16 duplex);
  41. u32 atl1_hash_mc_addr(struct atl1_hw *hw, u8 *mc_addr);
  42. void atl1_hash_set(struct atl1_hw *hw, u32 hash_value);
  43. s32 atl1_read_phy_reg(struct atl1_hw *hw, u16 reg_addr, u16 *phy_data);
  44. void atl1_set_mac_addr(struct atl1_hw *hw);
  45. s32 atl1_phy_enter_power_saving(struct atl1_hw *hw);
  46. s32 atl1_reset_hw(struct atl1_hw *hw);
  47. void atl1_check_options(struct atl1_adapter *adapter);
  48. /* register definitions */
  49. #define REG_PCIE_CAP_LIST 0x58
  50. #define REG_VPD_CAP 0x6C
  51. #define VPD_CAP_ID_MASK 0xff
  52. #define VPD_CAP_ID_SHIFT 0
  53. #define VPD_CAP_NEXT_PTR_MASK 0xFF
  54. #define VPD_CAP_NEXT_PTR_SHIFT 8
  55. #define VPD_CAP_VPD_ADDR_MASK 0x7FFF
  56. #define VPD_CAP_VPD_ADDR_SHIFT 16
  57. #define VPD_CAP_VPD_FLAG 0x80000000
  58. #define REG_VPD_DATA 0x70
  59. #define REG_SPI_FLASH_CTRL 0x200
  60. #define SPI_FLASH_CTRL_STS_NON_RDY 0x1
  61. #define SPI_FLASH_CTRL_STS_WEN 0x2
  62. #define SPI_FLASH_CTRL_STS_WPEN 0x80
  63. #define SPI_FLASH_CTRL_DEV_STS_MASK 0xFF
  64. #define SPI_FLASH_CTRL_DEV_STS_SHIFT 0
  65. #define SPI_FLASH_CTRL_INS_MASK 0x7
  66. #define SPI_FLASH_CTRL_INS_SHIFT 8
  67. #define SPI_FLASH_CTRL_START 0x800
  68. #define SPI_FLASH_CTRL_EN_VPD 0x2000
  69. #define SPI_FLASH_CTRL_LDSTART 0x8000
  70. #define SPI_FLASH_CTRL_CS_HI_MASK 0x3
  71. #define SPI_FLASH_CTRL_CS_HI_SHIFT 16
  72. #define SPI_FLASH_CTRL_CS_HOLD_MASK 0x3
  73. #define SPI_FLASH_CTRL_CS_HOLD_SHIFT 18
  74. #define SPI_FLASH_CTRL_CLK_LO_MASK 0x3
  75. #define SPI_FLASH_CTRL_CLK_LO_SHIFT 20
  76. #define SPI_FLASH_CTRL_CLK_HI_MASK 0x3
  77. #define SPI_FLASH_CTRL_CLK_HI_SHIFT 22
  78. #define SPI_FLASH_CTRL_CS_SETUP_MASK 0x3
  79. #define SPI_FLASH_CTRL_CS_SETUP_SHIFT 24
  80. #define SPI_FLASH_CTRL_EROM_PGSZ_MASK 0x3
  81. #define SPI_FLASH_CTRL_EROM_PGSZ_SHIFT 26
  82. #define SPI_FLASH_CTRL_WAIT_READY 0x10000000
  83. #define REG_SPI_ADDR 0x204
  84. #define REG_SPI_DATA 0x208
  85. #define REG_SPI_FLASH_CONFIG 0x20C
  86. #define SPI_FLASH_CONFIG_LD_ADDR_MASK 0xFFFFFF
  87. #define SPI_FLASH_CONFIG_LD_ADDR_SHIFT 0
  88. #define SPI_FLASH_CONFIG_VPD_ADDR_MASK 0x3
  89. #define SPI_FLASH_CONFIG_VPD_ADDR_SHIFT 24
  90. #define SPI_FLASH_CONFIG_LD_EXIST 0x4000000
  91. #define REG_SPI_FLASH_OP_PROGRAM 0x210
  92. #define REG_SPI_FLASH_OP_SC_ERASE 0x211
  93. #define REG_SPI_FLASH_OP_CHIP_ERASE 0x212
  94. #define REG_SPI_FLASH_OP_RDID 0x213
  95. #define REG_SPI_FLASH_OP_WREN 0x214
  96. #define REG_SPI_FLASH_OP_RDSR 0x215
  97. #define REG_SPI_FLASH_OP_WRSR 0x216
  98. #define REG_SPI_FLASH_OP_READ 0x217
  99. #define REG_TWSI_CTRL 0x218
  100. #define TWSI_CTRL_LD_OFFSET_MASK 0xFF
  101. #define TWSI_CTRL_LD_OFFSET_SHIFT 0
  102. #define TWSI_CTRL_LD_SLV_ADDR_MASK 0x7
  103. #define TWSI_CTRL_LD_SLV_ADDR_SHIFT 8
  104. #define TWSI_CTRL_SW_LDSTART 0x800
  105. #define TWSI_CTRL_HW_LDSTART 0x1000
  106. #define TWSI_CTRL_SMB_SLV_ADDR_MASK 0x7F
  107. #define TWSI_CTRL_SMB_SLV_ADDR_SHIFT 15
  108. #define TWSI_CTRL_LD_EXIST 0x400000
  109. #define TWSI_CTRL_READ_FREQ_SEL_MASK 0x3
  110. #define TWSI_CTRL_READ_FREQ_SEL_SHIFT 23
  111. #define TWSI_CTRL_FREQ_SEL_100K 0
  112. #define TWSI_CTRL_FREQ_SEL_200K 1
  113. #define TWSI_CTRL_FREQ_SEL_300K 2
  114. #define TWSI_CTRL_FREQ_SEL_400K 3
  115. #define TWSI_CTRL_SMB_SLV_ADDR
  116. #define TWSI_CTRL_WRITE_FREQ_SEL_MASK 0x3
  117. #define TWSI_CTRL_WRITE_FREQ_SEL_SHIFT 24
  118. #define REG_PCIE_DEV_MISC_CTRL 0x21C
  119. #define PCIE_DEV_MISC_CTRL_EXT_PIPE 0x2
  120. #define PCIE_DEV_MISC_CTRL_RETRY_BUFDIS 0x1
  121. #define PCIE_DEV_MISC_CTRL_SPIROM_EXIST 0x4
  122. #define PCIE_DEV_MISC_CTRL_SERDES_ENDIAN 0x8
  123. #define PCIE_DEV_MISC_CTRL_SERDES_SEL_DIN 0x10
  124. /* Selene Master Control Register */
  125. #define REG_MASTER_CTRL 0x1400
  126. #define MASTER_CTRL_SOFT_RST 0x1
  127. #define MASTER_CTRL_MTIMER_EN 0x2
  128. #define MASTER_CTRL_ITIMER_EN 0x4
  129. #define MASTER_CTRL_MANUAL_INT 0x8
  130. #define MASTER_CTRL_REV_NUM_SHIFT 16
  131. #define MASTER_CTRL_REV_NUM_MASK 0xff
  132. #define MASTER_CTRL_DEV_ID_SHIFT 24
  133. #define MASTER_CTRL_DEV_ID_MASK 0xff
  134. /* Timer Initial Value Register */
  135. #define REG_MANUAL_TIMER_INIT 0x1404
  136. /* IRQ ModeratorTimer Initial Value Register */
  137. #define REG_IRQ_MODU_TIMER_INIT 0x1408
  138. #define REG_GPHY_ENABLE 0x140C
  139. /* IRQ Anti-Lost Timer Initial Value Register */
  140. #define REG_CMBDISDMA_TIMER 0x140E
  141. /* Block IDLE Status Register */
  142. #define REG_IDLE_STATUS 0x1410
  143. #define IDLE_STATUS_RXMAC 1
  144. #define IDLE_STATUS_TXMAC 2
  145. #define IDLE_STATUS_RXQ 4
  146. #define IDLE_STATUS_TXQ 8
  147. #define IDLE_STATUS_DMAR 0x10
  148. #define IDLE_STATUS_DMAW 0x20
  149. #define IDLE_STATUS_SMB 0x40
  150. #define IDLE_STATUS_CMB 0x80
  151. /* MDIO Control Register */
  152. #define REG_MDIO_CTRL 0x1414
  153. #define MDIO_DATA_MASK 0xffff
  154. #define MDIO_DATA_SHIFT 0
  155. #define MDIO_REG_ADDR_MASK 0x1f
  156. #define MDIO_REG_ADDR_SHIFT 16
  157. #define MDIO_RW 0x200000
  158. #define MDIO_SUP_PREAMBLE 0x400000
  159. #define MDIO_START 0x800000
  160. #define MDIO_CLK_SEL_SHIFT 24
  161. #define MDIO_CLK_25_4 0
  162. #define MDIO_CLK_25_6 2
  163. #define MDIO_CLK_25_8 3
  164. #define MDIO_CLK_25_10 4
  165. #define MDIO_CLK_25_14 5
  166. #define MDIO_CLK_25_20 6
  167. #define MDIO_CLK_25_28 7
  168. #define MDIO_BUSY 0x8000000
  169. #define MDIO_WAIT_TIMES 30
  170. /* MII PHY Status Register */
  171. #define REG_PHY_STATUS 0x1418
  172. /* BIST Control and Status Register0 (for the Packet Memory) */
  173. #define REG_BIST0_CTRL 0x141c
  174. #define BIST0_NOW 0x1
  175. #define BIST0_SRAM_FAIL 0x2
  176. #define BIST0_FUSE_FLAG 0x4
  177. #define REG_BIST1_CTRL 0x1420
  178. #define BIST1_NOW 0x1
  179. #define BIST1_SRAM_FAIL 0x2
  180. #define BIST1_FUSE_FLAG 0x4
  181. /* MAC Control Register */
  182. #define REG_MAC_CTRL 0x1480
  183. #define MAC_CTRL_TX_EN 1
  184. #define MAC_CTRL_RX_EN 2
  185. #define MAC_CTRL_TX_FLOW 4
  186. #define MAC_CTRL_RX_FLOW 8
  187. #define MAC_CTRL_LOOPBACK 0x10
  188. #define MAC_CTRL_DUPLX 0x20
  189. #define MAC_CTRL_ADD_CRC 0x40
  190. #define MAC_CTRL_PAD 0x80
  191. #define MAC_CTRL_LENCHK 0x100
  192. #define MAC_CTRL_HUGE_EN 0x200
  193. #define MAC_CTRL_PRMLEN_SHIFT 10
  194. #define MAC_CTRL_PRMLEN_MASK 0xf
  195. #define MAC_CTRL_RMV_VLAN 0x4000
  196. #define MAC_CTRL_PROMIS_EN 0x8000
  197. #define MAC_CTRL_TX_PAUSE 0x10000
  198. #define MAC_CTRL_SCNT 0x20000
  199. #define MAC_CTRL_SRST_TX 0x40000
  200. #define MAC_CTRL_TX_SIMURST 0x80000
  201. #define MAC_CTRL_SPEED_SHIFT 20
  202. #define MAC_CTRL_SPEED_MASK 0x300000
  203. #define MAC_CTRL_SPEED_1000 2
  204. #define MAC_CTRL_SPEED_10_100 1
  205. #define MAC_CTRL_DBG_TX_BKPRESURE 0x400000
  206. #define MAC_CTRL_TX_HUGE 0x800000
  207. #define MAC_CTRL_RX_CHKSUM_EN 0x1000000
  208. #define MAC_CTRL_MC_ALL_EN 0x2000000
  209. #define MAC_CTRL_BC_EN 0x4000000
  210. #define MAC_CTRL_DBG 0x8000000
  211. /* MAC IPG/IFG Control Register */
  212. #define REG_MAC_IPG_IFG 0x1484
  213. #define MAC_IPG_IFG_IPGT_SHIFT 0
  214. #define MAC_IPG_IFG_IPGT_MASK 0x7f
  215. #define MAC_IPG_IFG_MIFG_SHIFT 8
  216. #define MAC_IPG_IFG_MIFG_MASK 0xff
  217. #define MAC_IPG_IFG_IPGR1_SHIFT 16
  218. #define MAC_IPG_IFG_IPGR1_MASK 0x7f
  219. #define MAC_IPG_IFG_IPGR2_SHIFT 24
  220. #define MAC_IPG_IFG_IPGR2_MASK 0x7f
  221. /* MAC STATION ADDRESS */
  222. #define REG_MAC_STA_ADDR 0x1488
  223. /* Hash table for multicast address */
  224. #define REG_RX_HASH_TABLE 0x1490
  225. /* MAC Half-Duplex Control Register */
  226. #define REG_MAC_HALF_DUPLX_CTRL 0x1498
  227. #define MAC_HALF_DUPLX_CTRL_LCOL_SHIFT 0
  228. #define MAC_HALF_DUPLX_CTRL_LCOL_MASK 0x3ff
  229. #define MAC_HALF_DUPLX_CTRL_RETRY_SHIFT 12
  230. #define MAC_HALF_DUPLX_CTRL_RETRY_MASK 0xf
  231. #define MAC_HALF_DUPLX_CTRL_EXC_DEF_EN 0x10000
  232. #define MAC_HALF_DUPLX_CTRL_NO_BACK_C 0x20000
  233. #define MAC_HALF_DUPLX_CTRL_NO_BACK_P 0x40000
  234. #define MAC_HALF_DUPLX_CTRL_ABEBE 0x80000
  235. #define MAC_HALF_DUPLX_CTRL_ABEBT_SHIFT 20
  236. #define MAC_HALF_DUPLX_CTRL_ABEBT_MASK 0xf
  237. #define MAC_HALF_DUPLX_CTRL_JAMIPG_SHIFT 24
  238. #define MAC_HALF_DUPLX_CTRL_JAMIPG_MASK 0xf
  239. /* Maximum Frame Length Control Register */
  240. #define REG_MTU 0x149c
  241. /* Wake-On-Lan control register */
  242. #define REG_WOL_CTRL 0x14a0
  243. #define WOL_PATTERN_EN 0x00000001
  244. #define WOL_PATTERN_PME_EN 0x00000002
  245. #define WOL_MAGIC_EN 0x00000004
  246. #define WOL_MAGIC_PME_EN 0x00000008
  247. #define WOL_LINK_CHG_EN 0x00000010
  248. #define WOL_LINK_CHG_PME_EN 0x00000020
  249. #define WOL_PATTERN_ST 0x00000100
  250. #define WOL_MAGIC_ST 0x00000200
  251. #define WOL_LINKCHG_ST 0x00000400
  252. #define WOL_CLK_SWITCH_EN 0x00008000
  253. #define WOL_PT0_EN 0x00010000
  254. #define WOL_PT1_EN 0x00020000
  255. #define WOL_PT2_EN 0x00040000
  256. #define WOL_PT3_EN 0x00080000
  257. #define WOL_PT4_EN 0x00100000
  258. #define WOL_PT5_EN 0x00200000
  259. #define WOL_PT6_EN 0x00400000
  260. /* WOL Length ( 2 DWORD ) */
  261. #define REG_WOL_PATTERN_LEN 0x14a4
  262. #define WOL_PT_LEN_MASK 0x7f
  263. #define WOL_PT0_LEN_SHIFT 0
  264. #define WOL_PT1_LEN_SHIFT 8
  265. #define WOL_PT2_LEN_SHIFT 16
  266. #define WOL_PT3_LEN_SHIFT 24
  267. #define WOL_PT4_LEN_SHIFT 0
  268. #define WOL_PT5_LEN_SHIFT 8
  269. #define WOL_PT6_LEN_SHIFT 16
  270. /* Internal SRAM Partition Register */
  271. #define REG_SRAM_RFD_ADDR 0x1500
  272. #define REG_SRAM_RFD_LEN (REG_SRAM_RFD_ADDR+ 4)
  273. #define REG_SRAM_RRD_ADDR (REG_SRAM_RFD_ADDR+ 8)
  274. #define REG_SRAM_RRD_LEN (REG_SRAM_RFD_ADDR+12)
  275. #define REG_SRAM_TPD_ADDR (REG_SRAM_RFD_ADDR+16)
  276. #define REG_SRAM_TPD_LEN (REG_SRAM_RFD_ADDR+20)
  277. #define REG_SRAM_TRD_ADDR (REG_SRAM_RFD_ADDR+24)
  278. #define REG_SRAM_TRD_LEN (REG_SRAM_RFD_ADDR+28)
  279. #define REG_SRAM_RXF_ADDR (REG_SRAM_RFD_ADDR+32)
  280. #define REG_SRAM_RXF_LEN (REG_SRAM_RFD_ADDR+36)
  281. #define REG_SRAM_TXF_ADDR (REG_SRAM_RFD_ADDR+40)
  282. #define REG_SRAM_TXF_LEN (REG_SRAM_RFD_ADDR+44)
  283. #define REG_SRAM_TCPH_PATH_ADDR (REG_SRAM_RFD_ADDR+48)
  284. #define SRAM_TCPH_ADDR_MASK 0x0fff
  285. #define SRAM_TCPH_ADDR_SHIFT 0
  286. #define SRAM_PATH_ADDR_MASK 0x0fff
  287. #define SRAM_PATH_ADDR_SHIFT 16
  288. /* Load Ptr Register */
  289. #define REG_LOAD_PTR (REG_SRAM_RFD_ADDR+52)
  290. /* Descriptor Control register */
  291. #define REG_DESC_BASE_ADDR_HI 0x1540
  292. #define REG_DESC_RFD_ADDR_LO (REG_DESC_BASE_ADDR_HI+4)
  293. #define REG_DESC_RRD_ADDR_LO (REG_DESC_BASE_ADDR_HI+8)
  294. #define REG_DESC_TPD_ADDR_LO (REG_DESC_BASE_ADDR_HI+12)
  295. #define REG_DESC_CMB_ADDR_LO (REG_DESC_BASE_ADDR_HI+16)
  296. #define REG_DESC_SMB_ADDR_LO (REG_DESC_BASE_ADDR_HI+20)
  297. #define REG_DESC_RFD_RRD_RING_SIZE (REG_DESC_BASE_ADDR_HI+24)
  298. #define DESC_RFD_RING_SIZE_MASK 0x7ff
  299. #define DESC_RFD_RING_SIZE_SHIFT 0
  300. #define DESC_RRD_RING_SIZE_MASK 0x7ff
  301. #define DESC_RRD_RING_SIZE_SHIFT 16
  302. #define REG_DESC_TPD_RING_SIZE (REG_DESC_BASE_ADDR_HI+28)
  303. #define DESC_TPD_RING_SIZE_MASK 0x3ff
  304. #define DESC_TPD_RING_SIZE_SHIFT 0
  305. /* TXQ Control Register */
  306. #define REG_TXQ_CTRL 0x1580
  307. #define TXQ_CTRL_TPD_BURST_NUM_SHIFT 0
  308. #define TXQ_CTRL_TPD_BURST_NUM_MASK 0x1f
  309. #define TXQ_CTRL_EN 0x20
  310. #define TXQ_CTRL_ENH_MODE 0x40
  311. #define TXQ_CTRL_TPD_FETCH_TH_SHIFT 8
  312. #define TXQ_CTRL_TPD_FETCH_TH_MASK 0x3f
  313. #define TXQ_CTRL_TXF_BURST_NUM_SHIFT 16
  314. #define TXQ_CTRL_TXF_BURST_NUM_MASK 0xffff
  315. /* Jumbo packet Threshold for task offload */
  316. #define REG_TX_JUMBO_TASK_TH_TPD_IPG 0x1584
  317. #define TX_JUMBO_TASK_TH_MASK 0x7ff
  318. #define TX_JUMBO_TASK_TH_SHIFT 0
  319. #define TX_TPD_MIN_IPG_MASK 0x1f
  320. #define TX_TPD_MIN_IPG_SHIFT 16
  321. /* RXQ Control Register */
  322. #define REG_RXQ_CTRL 0x15a0
  323. #define RXQ_CTRL_RFD_BURST_NUM_SHIFT 0
  324. #define RXQ_CTRL_RFD_BURST_NUM_MASK 0xff
  325. #define RXQ_CTRL_RRD_BURST_THRESH_SHIFT 8
  326. #define RXQ_CTRL_RRD_BURST_THRESH_MASK 0xff
  327. #define RXQ_CTRL_RFD_PREF_MIN_IPG_SHIFT 16
  328. #define RXQ_CTRL_RFD_PREF_MIN_IPG_MASK 0x1f
  329. #define RXQ_CTRL_CUT_THRU_EN 0x40000000
  330. #define RXQ_CTRL_EN 0x80000000
  331. /* Rx jumbo packet threshold and rrd retirement timer */
  332. #define REG_RXQ_JMBOSZ_RRDTIM (REG_RXQ_CTRL+ 4)
  333. #define RXQ_JMBOSZ_TH_MASK 0x7ff
  334. #define RXQ_JMBOSZ_TH_SHIFT 0
  335. #define RXQ_JMBO_LKAH_MASK 0xf
  336. #define RXQ_JMBO_LKAH_SHIFT 11
  337. #define RXQ_RRD_TIMER_MASK 0xffff
  338. #define RXQ_RRD_TIMER_SHIFT 16
  339. /* RFD flow control register */
  340. #define REG_RXQ_RXF_PAUSE_THRESH (REG_RXQ_CTRL+ 8)
  341. #define RXQ_RXF_PAUSE_TH_HI_SHIFT 16
  342. #define RXQ_RXF_PAUSE_TH_HI_MASK 0xfff
  343. #define RXQ_RXF_PAUSE_TH_LO_SHIFT 0
  344. #define RXQ_RXF_PAUSE_TH_LO_MASK 0xfff
  345. /* RRD flow control register */
  346. #define REG_RXQ_RRD_PAUSE_THRESH (REG_RXQ_CTRL+12)
  347. #define RXQ_RRD_PAUSE_TH_HI_SHIFT 0
  348. #define RXQ_RRD_PAUSE_TH_HI_MASK 0xfff
  349. #define RXQ_RRD_PAUSE_TH_LO_SHIFT 16
  350. #define RXQ_RRD_PAUSE_TH_LO_MASK 0xfff
  351. /* DMA Engine Control Register */
  352. #define REG_DMA_CTRL 0x15c0
  353. #define DMA_CTRL_DMAR_IN_ORDER 0x1
  354. #define DMA_CTRL_DMAR_ENH_ORDER 0x2
  355. #define DMA_CTRL_DMAR_OUT_ORDER 0x4
  356. #define DMA_CTRL_RCB_VALUE 0x8
  357. #define DMA_CTRL_DMAR_BURST_LEN_SHIFT 4
  358. #define DMA_CTRL_DMAR_BURST_LEN_MASK 7
  359. #define DMA_CTRL_DMAW_BURST_LEN_SHIFT 7
  360. #define DMA_CTRL_DMAW_BURST_LEN_MASK 7
  361. #define DMA_CTRL_DMAR_EN 0x400
  362. #define DMA_CTRL_DMAW_EN 0x800
  363. /* CMB/SMB Control Register */
  364. #define REG_CSMB_CTRL 0x15d0
  365. #define CSMB_CTRL_CMB_NOW 1
  366. #define CSMB_CTRL_SMB_NOW 2
  367. #define CSMB_CTRL_CMB_EN 4
  368. #define CSMB_CTRL_SMB_EN 8
  369. /* CMB DMA Write Threshold Register */
  370. #define REG_CMB_WRITE_TH (REG_CSMB_CTRL+ 4)
  371. #define CMB_RRD_TH_SHIFT 0
  372. #define CMB_RRD_TH_MASK 0x7ff
  373. #define CMB_TPD_TH_SHIFT 16
  374. #define CMB_TPD_TH_MASK 0x7ff
  375. /* RX/TX count-down timer to trigger CMB-write. 2us resolution. */
  376. #define REG_CMB_WRITE_TIMER (REG_CSMB_CTRL+ 8)
  377. #define CMB_RX_TM_SHIFT 0
  378. #define CMB_RX_TM_MASK 0xffff
  379. #define CMB_TX_TM_SHIFT 16
  380. #define CMB_TX_TM_MASK 0xffff
  381. /* Number of packet received since last CMB write */
  382. #define REG_CMB_RX_PKT_CNT (REG_CSMB_CTRL+12)
  383. /* Number of packet transmitted since last CMB write */
  384. #define REG_CMB_TX_PKT_CNT (REG_CSMB_CTRL+16)
  385. /* SMB auto DMA timer register */
  386. #define REG_SMB_TIMER (REG_CSMB_CTRL+20)
  387. /* Mailbox Register */
  388. #define REG_MAILBOX 0x15f0
  389. #define MB_RFD_PROD_INDX_SHIFT 0
  390. #define MB_RFD_PROD_INDX_MASK 0x7ff
  391. #define MB_RRD_CONS_INDX_SHIFT 11
  392. #define MB_RRD_CONS_INDX_MASK 0x7ff
  393. #define MB_TPD_PROD_INDX_SHIFT 22
  394. #define MB_TPD_PROD_INDX_MASK 0x3ff
  395. /* Interrupt Status Register */
  396. #define REG_ISR 0x1600
  397. #define ISR_SMB 1
  398. #define ISR_TIMER 2
  399. #define ISR_MANUAL 4
  400. #define ISR_RXF_OV 8
  401. #define ISR_RFD_UNRUN 0x10
  402. #define ISR_RRD_OV 0x20
  403. #define ISR_TXF_UNRUN 0x40
  404. #define ISR_LINK 0x80
  405. #define ISR_HOST_RFD_UNRUN 0x100
  406. #define ISR_HOST_RRD_OV 0x200
  407. #define ISR_DMAR_TO_RST 0x400
  408. #define ISR_DMAW_TO_RST 0x800
  409. #define ISR_GPHY 0x1000
  410. #define ISR_RX_PKT 0x10000
  411. #define ISR_TX_PKT 0x20000
  412. #define ISR_TX_DMA 0x40000
  413. #define ISR_RX_DMA 0x80000
  414. #define ISR_CMB_RX 0x100000
  415. #define ISR_CMB_TX 0x200000
  416. #define ISR_MAC_RX 0x400000
  417. #define ISR_MAC_TX 0x800000
  418. #define ISR_UR_DETECTED 0x1000000
  419. #define ISR_FERR_DETECTED 0x2000000
  420. #define ISR_NFERR_DETECTED 0x4000000
  421. #define ISR_CERR_DETECTED 0x8000000
  422. #define ISR_PHY_LINKDOWN 0x10000000
  423. #define ISR_DIS_SMB 0x20000000
  424. #define ISR_DIS_DMA 0x40000000
  425. #define ISR_DIS_INT 0x80000000
  426. /* Interrupt Mask Register */
  427. #define REG_IMR 0x1604
  428. /* Normal Interrupt mask */
  429. #define IMR_NORMAL_MASK (\
  430. ISR_SMB |\
  431. ISR_GPHY |\
  432. ISR_PHY_LINKDOWN|\
  433. ISR_DMAR_TO_RST |\
  434. ISR_DMAW_TO_RST |\
  435. ISR_CMB_TX |\
  436. ISR_CMB_RX )
  437. /* Debug Interrupt Mask (enable all interrupt) */
  438. #define IMR_DEBUG_MASK (\
  439. ISR_SMB |\
  440. ISR_TIMER |\
  441. ISR_MANUAL |\
  442. ISR_RXF_OV |\
  443. ISR_RFD_UNRUN |\
  444. ISR_RRD_OV |\
  445. ISR_TXF_UNRUN |\
  446. ISR_LINK |\
  447. ISR_CMB_TX |\
  448. ISR_CMB_RX |\
  449. ISR_RX_PKT |\
  450. ISR_TX_PKT |\
  451. ISR_MAC_RX |\
  452. ISR_MAC_TX )
  453. /* Interrupt Status Register */
  454. #define REG_RFD_RRD_IDX 0x1800
  455. #define REG_TPD_IDX 0x1804
  456. /* MII definition */
  457. /* PHY Common Register */
  458. #define MII_AT001_CR 0x09
  459. #define MII_AT001_SR 0x0A
  460. #define MII_AT001_ESR 0x0F
  461. #define MII_AT001_PSCR 0x10
  462. #define MII_AT001_PSSR 0x11
  463. /* PHY Control Register */
  464. #define MII_CR_SPEED_SELECT_MSB 0x0040 /* bits 6,13: 10=1000, 01=100, 00=10 */
  465. #define MII_CR_COLL_TEST_ENABLE 0x0080 /* Collision test enable */
  466. #define MII_CR_FULL_DUPLEX 0x0100 /* FDX =1, half duplex =0 */
  467. #define MII_CR_RESTART_AUTO_NEG 0x0200 /* Restart auto negotiation */
  468. #define MII_CR_ISOLATE 0x0400 /* Isolate PHY from MII */
  469. #define MII_CR_POWER_DOWN 0x0800 /* Power down */
  470. #define MII_CR_AUTO_NEG_EN 0x1000 /* Auto Neg Enable */
  471. #define MII_CR_SPEED_SELECT_LSB 0x2000 /* bits 6,13: 10=1000, 01=100, 00=10 */
  472. #define MII_CR_LOOPBACK 0x4000 /* 0 = normal, 1 = loopback */
  473. #define MII_CR_RESET 0x8000 /* 0 = normal, 1 = PHY reset */
  474. #define MII_CR_SPEED_MASK 0x2040
  475. #define MII_CR_SPEED_1000 0x0040
  476. #define MII_CR_SPEED_100 0x2000
  477. #define MII_CR_SPEED_10 0x0000
  478. /* PHY Status Register */
  479. #define MII_SR_EXTENDED_CAPS 0x0001 /* Extended register capabilities */
  480. #define MII_SR_JABBER_DETECT 0x0002 /* Jabber Detected */
  481. #define MII_SR_LINK_STATUS 0x0004 /* Link Status 1 = link */
  482. #define MII_SR_AUTONEG_CAPS 0x0008 /* Auto Neg Capable */
  483. #define MII_SR_REMOTE_FAULT 0x0010 /* Remote Fault Detect */
  484. #define MII_SR_AUTONEG_COMPLETE 0x0020 /* Auto Neg Complete */
  485. #define MII_SR_PREAMBLE_SUPPRESS 0x0040 /* Preamble may be suppressed */
  486. #define MII_SR_EXTENDED_STATUS 0x0100 /* Ext. status info in Reg 0x0F */
  487. #define MII_SR_100T2_HD_CAPS 0x0200 /* 100T2 Half Duplex Capable */
  488. #define MII_SR_100T2_FD_CAPS 0x0400 /* 100T2 Full Duplex Capable */
  489. #define MII_SR_10T_HD_CAPS 0x0800 /* 10T Half Duplex Capable */
  490. #define MII_SR_10T_FD_CAPS 0x1000 /* 10T Full Duplex Capable */
  491. #define MII_SR_100X_HD_CAPS 0x2000 /* 100X Half Duplex Capable */
  492. #define MII_SR_100X_FD_CAPS 0x4000 /* 100X Full Duplex Capable */
  493. #define MII_SR_100T4_CAPS 0x8000 /* 100T4 Capable */
  494. /* Link partner ability register. */
  495. #define MII_LPA_SLCT 0x001f /* Same as advertise selector */
  496. #define MII_LPA_10HALF 0x0020 /* Can do 10mbps half-duplex */
  497. #define MII_LPA_10FULL 0x0040 /* Can do 10mbps full-duplex */
  498. #define MII_LPA_100HALF 0x0080 /* Can do 100mbps half-duplex */
  499. #define MII_LPA_100FULL 0x0100 /* Can do 100mbps full-duplex */
  500. #define MII_LPA_100BASE4 0x0200 /* 100BASE-T4 */
  501. #define MII_LPA_PAUSE 0x0400 /* PAUSE */
  502. #define MII_LPA_ASYPAUSE 0x0800 /* Asymmetrical PAUSE */
  503. #define MII_LPA_RFAULT 0x2000 /* Link partner faulted */
  504. #define MII_LPA_LPACK 0x4000 /* Link partner acked us */
  505. #define MII_LPA_NPAGE 0x8000 /* Next page bit */
  506. /* Autoneg Advertisement Register */
  507. #define MII_AR_SELECTOR_FIELD 0x0001 /* indicates IEEE 802.3 CSMA/CD */
  508. #define MII_AR_10T_HD_CAPS 0x0020 /* 10T Half Duplex Capable */
  509. #define MII_AR_10T_FD_CAPS 0x0040 /* 10T Full Duplex Capable */
  510. #define MII_AR_100TX_HD_CAPS 0x0080 /* 100TX Half Duplex Capable */
  511. #define MII_AR_100TX_FD_CAPS 0x0100 /* 100TX Full Duplex Capable */
  512. #define MII_AR_100T4_CAPS 0x0200 /* 100T4 Capable */
  513. #define MII_AR_PAUSE 0x0400 /* Pause operation desired */
  514. #define MII_AR_ASM_DIR 0x0800 /* Asymmetric Pause Direction bit */
  515. #define MII_AR_REMOTE_FAULT 0x2000 /* Remote Fault detected */
  516. #define MII_AR_NEXT_PAGE 0x8000 /* Next Page ability supported */
  517. #define MII_AR_SPEED_MASK 0x01E0
  518. #define MII_AR_DEFAULT_CAP_MASK 0x0DE0
  519. /* 1000BASE-T Control Register */
  520. #define MII_AT001_CR_1000T_HD_CAPS 0x0100 /* Advertise 1000T HD capability */
  521. #define MII_AT001_CR_1000T_FD_CAPS 0x0200 /* Advertise 1000T FD capability */
  522. #define MII_AT001_CR_1000T_REPEATER_DTE 0x0400 /* 1=Repeater/switch device port, 0=DTE device */
  523. #define MII_AT001_CR_1000T_MS_VALUE 0x0800 /* 1=Configure PHY as Master, 0=Configure PHY as Slave */
  524. #define MII_AT001_CR_1000T_MS_ENABLE 0x1000 /* 1=Master/Slave manual config value, 0=Automatic Master/Slave config */
  525. #define MII_AT001_CR_1000T_TEST_MODE_NORMAL 0x0000 /* Normal Operation */
  526. #define MII_AT001_CR_1000T_TEST_MODE_1 0x2000 /* Transmit Waveform test */
  527. #define MII_AT001_CR_1000T_TEST_MODE_2 0x4000 /* Master Transmit Jitter test */
  528. #define MII_AT001_CR_1000T_TEST_MODE_3 0x6000 /* Slave Transmit Jitter test */
  529. #define MII_AT001_CR_1000T_TEST_MODE_4 0x8000 /* Transmitter Distortion test */
  530. #define MII_AT001_CR_1000T_SPEED_MASK 0x0300
  531. #define MII_AT001_CR_1000T_DEFAULT_CAP_MASK 0x0300
  532. /* 1000BASE-T Status Register */
  533. #define MII_AT001_SR_1000T_LP_HD_CAPS 0x0400 /* LP is 1000T HD capable */
  534. #define MII_AT001_SR_1000T_LP_FD_CAPS 0x0800 /* LP is 1000T FD capable */
  535. #define MII_AT001_SR_1000T_REMOTE_RX_STATUS 0x1000 /* Remote receiver OK */
  536. #define MII_AT001_SR_1000T_LOCAL_RX_STATUS 0x2000 /* Local receiver OK */
  537. #define MII_AT001_SR_1000T_MS_CONFIG_RES 0x4000 /* 1=Local TX is Master, 0=Slave */
  538. #define MII_AT001_SR_1000T_MS_CONFIG_FAULT 0x8000 /* Master/Slave config fault */
  539. #define MII_AT001_SR_1000T_REMOTE_RX_STATUS_SHIFT 12
  540. #define MII_AT001_SR_1000T_LOCAL_RX_STATUS_SHIFT 13
  541. /* Extended Status Register */
  542. #define MII_AT001_ESR_1000T_HD_CAPS 0x1000 /* 1000T HD capable */
  543. #define MII_AT001_ESR_1000T_FD_CAPS 0x2000 /* 1000T FD capable */
  544. #define MII_AT001_ESR_1000X_HD_CAPS 0x4000 /* 1000X HD capable */
  545. #define MII_AT001_ESR_1000X_FD_CAPS 0x8000 /* 1000X FD capable */
  546. /* AT001 PHY Specific Control Register */
  547. #define MII_AT001_PSCR_JABBER_DISABLE 0x0001 /* 1=Jabber Function disabled */
  548. #define MII_AT001_PSCR_POLARITY_REVERSAL 0x0002 /* 1=Polarity Reversal enabled */
  549. #define MII_AT001_PSCR_SQE_TEST 0x0004 /* 1=SQE Test enabled */
  550. #define MII_AT001_PSCR_MAC_POWERDOWN 0x0008
  551. #define MII_AT001_PSCR_CLK125_DISABLE 0x0010 /* 1=CLK125 low, 0=CLK125 toggling */
  552. #define MII_AT001_PSCR_MDI_MANUAL_MODE 0x0000 /* MDI Crossover Mode bits 6:5, Manual MDI configuration */
  553. #define MII_AT001_PSCR_MDIX_MANUAL_MODE 0x0020 /* Manual MDIX configuration */
  554. #define MII_AT001_PSCR_AUTO_X_1000T 0x0040 /* 1000BASE-T: Auto crossover, 100BASE-TX/10BASE-T: MDI Mode */
  555. #define MII_AT001_PSCR_AUTO_X_MODE 0x0060 /* Auto crossover enabled all speeds. */
  556. #define MII_AT001_PSCR_10BT_EXT_DIST_ENABLE 0x0080 /* 1=Enable Extended 10BASE-T distance (Lower 10BASE-T RX Threshold), 0=Normal 10BASE-T RX Threshold */
  557. #define MII_AT001_PSCR_MII_5BIT_ENABLE 0x0100 /* 1=5-Bit interface in 100BASE-TX, 0=MII interface in 100BASE-TX */
  558. #define MII_AT001_PSCR_SCRAMBLER_DISABLE 0x0200 /* 1=Scrambler disable */
  559. #define MII_AT001_PSCR_FORCE_LINK_GOOD 0x0400 /* 1=Force link good */
  560. #define MII_AT001_PSCR_ASSERT_CRS_ON_TX 0x0800 /* 1=Assert CRS on Transmit */
  561. #define MII_AT001_PSCR_POLARITY_REVERSAL_SHIFT 1
  562. #define MII_AT001_PSCR_AUTO_X_MODE_SHIFT 5
  563. #define MII_AT001_PSCR_10BT_EXT_DIST_ENABLE_SHIFT 7
  564. /* AT001 PHY Specific Status Register */
  565. #define MII_AT001_PSSR_SPD_DPLX_RESOLVED 0x0800 /* 1=Speed & Duplex resolved */
  566. #define MII_AT001_PSSR_DPLX 0x2000 /* 1=Duplex 0=Half Duplex */
  567. #define MII_AT001_PSSR_SPEED 0xC000 /* Speed, bits 14:15 */
  568. #define MII_AT001_PSSR_10MBS 0x0000 /* 00=10Mbs */
  569. #define MII_AT001_PSSR_100MBS 0x4000 /* 01=100Mbs */
  570. #define MII_AT001_PSSR_1000MBS 0x8000 /* 10=1000Mbs */
  571. /* PCI Command Register Bit Definitions */
  572. #define PCI_REG_COMMAND 0x04 /* PCI Command Register */
  573. #define CMD_IO_SPACE 0x0001
  574. #define CMD_MEMORY_SPACE 0x0002
  575. #define CMD_BUS_MASTER 0x0004
  576. /* Wake Up Filter Control */
  577. #define ATL1_WUFC_LNKC 0x00000001 /* Link Status Change Wakeup Enable */
  578. #define ATL1_WUFC_MAG 0x00000002 /* Magic Packet Wakeup Enable */
  579. #define ATL1_WUFC_EX 0x00000004 /* Directed Exact Wakeup Enable */
  580. #define ATL1_WUFC_MC 0x00000008 /* Multicast Wakeup Enable */
  581. #define ATL1_WUFC_BC 0x00000010 /* Broadcast Wakeup Enable */
  582. /* Error Codes */
  583. #define ATL1_SUCCESS 0
  584. #define ATL1_ERR_EEPROM 1
  585. #define ATL1_ERR_PHY 2
  586. #define ATL1_ERR_CONFIG 3
  587. #define ATL1_ERR_PARAM 4
  588. #define ATL1_ERR_MAC_TYPE 5
  589. #define ATL1_ERR_PHY_TYPE 6
  590. #define ATL1_ERR_PHY_SPEED 7
  591. #define ATL1_ERR_PHY_RES 8
  592. #define SPEED_0 0xffff
  593. #define SPEED_10 10
  594. #define SPEED_100 100
  595. #define SPEED_1000 1000
  596. #define HALF_DUPLEX 1
  597. #define FULL_DUPLEX 2
  598. #define MEDIA_TYPE_AUTO_SENSOR 0
  599. #define MEDIA_TYPE_1000M_FULL 1
  600. #define MEDIA_TYPE_100M_FULL 2
  601. #define MEDIA_TYPE_100M_HALF 3
  602. #define MEDIA_TYPE_10M_FULL 4
  603. #define MEDIA_TYPE_10M_HALF 5
  604. #define ADVERTISE_10_HALF 0x0001
  605. #define ADVERTISE_10_FULL 0x0002
  606. #define ADVERTISE_100_HALF 0x0004
  607. #define ADVERTISE_100_FULL 0x0008
  608. #define ADVERTISE_1000_HALF 0x0010
  609. #define ADVERTISE_1000_FULL 0x0020
  610. #define AUTONEG_ADVERTISE_SPEED_DEFAULT 0x002F /* Everything but 1000-Half */
  611. #define AUTONEG_ADVERTISE_10_100_ALL 0x000F /* All 10/100 speeds */
  612. #define AUTONEG_ADVERTISE_10_ALL 0x0003 /* 10Mbps Full & Half speeds */
  613. /* The size (in bytes) of a ethernet packet */
  614. #define ENET_HEADER_SIZE 14
  615. #define MAXIMUM_ETHERNET_FRAME_SIZE 1518 /* with FCS */
  616. #define MINIMUM_ETHERNET_FRAME_SIZE 64 /* with FCS */
  617. #define ETHERNET_FCS_SIZE 4
  618. #define MAX_JUMBO_FRAME_SIZE 0x2800
  619. #define PHY_AUTO_NEG_TIME 45 /* 4.5 Seconds */
  620. #define PHY_FORCE_TIME 20 /* 2.0 Seconds */
  621. /* For checksumming , the sum of all words in the EEPROM should equal 0xBABA */
  622. #define EEPROM_SUM 0xBABA
  623. #define ATL1_EEDUMP_LEN 48
  624. /* Statistics counters collected by the MAC */
  625. struct stats_msg_block {
  626. /* rx */
  627. u32 rx_ok; /* The number of good packet received. */
  628. u32 rx_bcast; /* The number of good broadcast packet received. */
  629. u32 rx_mcast; /* The number of good multicast packet received. */
  630. u32 rx_pause; /* The number of Pause packet received. */
  631. u32 rx_ctrl; /* The number of Control packet received other than Pause frame. */
  632. u32 rx_fcs_err; /* The number of packets with bad FCS. */
  633. u32 rx_len_err; /* The number of packets with mismatch of length field and actual size. */
  634. u32 rx_byte_cnt; /* The number of bytes of good packet received. FCS is NOT included. */
  635. u32 rx_runt; /* The number of packets received that are less than 64 byte long and with good FCS. */
  636. u32 rx_frag; /* The number of packets received that are less than 64 byte long and with bad FCS. */
  637. u32 rx_sz_64; /* The number of good and bad packets received that are 64 byte long. */
  638. u32 rx_sz_65_127; /* The number of good and bad packets received that are between 65 and 127-byte long. */
  639. u32 rx_sz_128_255; /* The number of good and bad packets received that are between 128 and 255-byte long. */
  640. u32 rx_sz_256_511; /* The number of good and bad packets received that are between 256 and 511-byte long. */
  641. u32 rx_sz_512_1023; /* The number of good and bad packets received that are between 512 and 1023-byte long. */
  642. u32 rx_sz_1024_1518; /* The number of good and bad packets received that are between 1024 and 1518-byte long. */
  643. u32 rx_sz_1519_max; /* The number of good and bad packets received that are between 1519-byte and MTU. */
  644. u32 rx_sz_ov; /* The number of good and bad packets received that are more than MTU size šC truncated by Selene. */
  645. u32 rx_rxf_ov; /* The number of frame dropped due to occurrence of RX FIFO overflow. */
  646. u32 rx_rrd_ov; /* The number of frame dropped due to occurrence of RRD overflow. */
  647. u32 rx_align_err; /* Alignment Error */
  648. u32 rx_bcast_byte_cnt; /* The byte count of broadcast packet received, excluding FCS. */
  649. u32 rx_mcast_byte_cnt; /* The byte count of multicast packet received, excluding FCS. */
  650. u32 rx_err_addr; /* The number of packets dropped due to address filtering. */
  651. /* tx */
  652. u32 tx_ok; /* The number of good packet transmitted. */
  653. u32 tx_bcast; /* The number of good broadcast packet transmitted. */
  654. u32 tx_mcast; /* The number of good multicast packet transmitted. */
  655. u32 tx_pause; /* The number of Pause packet transmitted. */
  656. u32 tx_exc_defer; /* The number of packets transmitted with excessive deferral. */
  657. u32 tx_ctrl; /* The number of packets transmitted is a control frame, excluding Pause frame. */
  658. u32 tx_defer; /* The number of packets transmitted that is deferred. */
  659. u32 tx_byte_cnt; /* The number of bytes of data transmitted. FCS is NOT included. */
  660. u32 tx_sz_64; /* The number of good and bad packets transmitted that are 64 byte long. */
  661. u32 tx_sz_65_127; /* The number of good and bad packets transmitted that are between 65 and 127-byte long. */
  662. u32 tx_sz_128_255; /* The number of good and bad packets transmitted that are between 128 and 255-byte long. */
  663. u32 tx_sz_256_511; /* The number of good and bad packets transmitted that are between 256 and 511-byte long. */
  664. u32 tx_sz_512_1023; /* The number of good and bad packets transmitted that are between 512 and 1023-byte long. */
  665. u32 tx_sz_1024_1518; /* The number of good and bad packets transmitted that are between 1024 and 1518-byte long. */
  666. u32 tx_sz_1519_max; /* The number of good and bad packets transmitted that are between 1519-byte and MTU. */
  667. u32 tx_1_col; /* The number of packets subsequently transmitted successfully with a single prior collision. */
  668. u32 tx_2_col; /* The number of packets subsequently transmitted successfully with multiple prior collisions. */
  669. u32 tx_late_col; /* The number of packets transmitted with late collisions. */
  670. u32 tx_abort_col; /* The number of transmit packets aborted due to excessive collisions. */
  671. u32 tx_underrun; /* The number of transmit packets aborted due to transmit FIFO underrun, or TRD FIFO underrun */
  672. u32 tx_rd_eop; /* The number of times that read beyond the EOP into the next frame area when TRD was not written timely */
  673. u32 tx_len_err; /* The number of transmit packets with length field does NOT match the actual frame size. */
  674. u32 tx_trunc; /* The number of transmit packets truncated due to size exceeding MTU. */
  675. u32 tx_bcast_byte; /* The byte count of broadcast packet transmitted, excluding FCS. */
  676. u32 tx_mcast_byte; /* The byte count of multicast packet transmitted, excluding FCS. */
  677. u32 smb_updated; /* 1: SMB Updated. This is used by software as the indication of the statistics update.
  678. * Software should clear this bit as soon as retrieving the statistics information. */
  679. };
  680. /* Coalescing Message Block */
  681. struct coals_msg_block {
  682. u32 int_stats; /* interrupt status */
  683. u16 rrd_prod_idx; /* TRD Producer Index. */
  684. u16 rfd_cons_idx; /* RFD Consumer Index. */
  685. u16 update; /* Selene sets this bit every time it DMA the CMB to host memory.
  686. * Software supposes to clear this bit when CMB information is processed. */
  687. u16 tpd_cons_idx; /* TPD Consumer Index. */
  688. };
  689. /* RRD descriptor */
  690. struct rx_return_desc {
  691. u8 num_buf; /* Number of RFD buffers used by the received packet */
  692. u8 resved;
  693. u16 buf_indx; /* RFD Index of the first buffer */
  694. union {
  695. u32 valid;
  696. struct {
  697. u16 rx_chksum;
  698. u16 pkt_size;
  699. } xsum_sz;
  700. } xsz;
  701. u16 pkt_flg; /* Packet flags */
  702. u16 err_flg; /* Error flags */
  703. u16 resved2;
  704. u16 vlan_tag; /* VLAN TAG */
  705. };
  706. #define PACKET_FLAG_ETH_TYPE 0x0080
  707. #define PACKET_FLAG_VLAN_INS 0x0100
  708. #define PACKET_FLAG_ERR 0x0200
  709. #define PACKET_FLAG_IPV4 0x0400
  710. #define PACKET_FLAG_UDP 0x0800
  711. #define PACKET_FLAG_TCP 0x1000
  712. #define PACKET_FLAG_BCAST 0x2000
  713. #define PACKET_FLAG_MCAST 0x4000
  714. #define PACKET_FLAG_PAUSE 0x8000
  715. #define ERR_FLAG_CRC 0x0001
  716. #define ERR_FLAG_CODE 0x0002
  717. #define ERR_FLAG_DRIBBLE 0x0004
  718. #define ERR_FLAG_RUNT 0x0008
  719. #define ERR_FLAG_OV 0x0010
  720. #define ERR_FLAG_TRUNC 0x0020
  721. #define ERR_FLAG_IP_CHKSUM 0x0040
  722. #define ERR_FLAG_L4_CHKSUM 0x0080
  723. #define ERR_FLAG_LEN 0x0100
  724. #define ERR_FLAG_DES_ADDR 0x0200
  725. /* RFD descriptor */
  726. struct rx_free_desc {
  727. __le64 buffer_addr; /* Address of the descriptor's data buffer */
  728. __le16 buf_len; /* Size of the receive buffer in host memory, in byte */
  729. u16 coalese; /* Update consumer index to host after the reception of this frame */
  730. /* __attribute__ ((packed)) is required */
  731. } __attribute__ ((packed));
  732. /* tsopu defines */
  733. #define TSO_PARAM_BUFLEN_MASK 0x3FFF
  734. #define TSO_PARAM_BUFLEN_SHIFT 0
  735. #define TSO_PARAM_DMAINT_MASK 0x0001
  736. #define TSO_PARAM_DMAINT_SHIFT 14
  737. #define TSO_PARAM_PKTNT_MASK 0x0001
  738. #define TSO_PARAM_PKTINT_SHIFT 15
  739. #define TSO_PARAM_VLANTAG_MASK 0xFFFF
  740. #define TSO_PARAM_VLAN_SHIFT 16
  741. /* tsopl defines */
  742. #define TSO_PARAM_EOP_MASK 0x0001
  743. #define TSO_PARAM_EOP_SHIFT 0
  744. #define TSO_PARAM_COALESCE_MASK 0x0001
  745. #define TSO_PARAM_COALESCE_SHIFT 1
  746. #define TSO_PARAM_INSVLAG_MASK 0x0001
  747. #define TSO_PARAM_INSVLAG_SHIFT 2
  748. #define TSO_PARAM_CUSTOMCKSUM_MASK 0x0001
  749. #define TSO_PARAM_CUSTOMCKSUM_SHIFT 3
  750. #define TSO_PARAM_SEGMENT_MASK 0x0001
  751. #define TSO_PARAM_SEGMENT_SHIFT 4
  752. #define TSO_PARAM_IPCKSUM_MASK 0x0001
  753. #define TSO_PARAM_IPCKSUM_SHIFT 5
  754. #define TSO_PARAM_TCPCKSUM_MASK 0x0001
  755. #define TSO_PARAM_TCPCKSUM_SHIFT 6
  756. #define TSO_PARAM_UDPCKSUM_MASK 0x0001
  757. #define TSO_PARAM_UDPCKSUM_SHIFT 7
  758. #define TSO_PARAM_VLANTAGGED_MASK 0x0001
  759. #define TSO_PARAM_VLANTAGGED_SHIFT 8
  760. #define TSO_PARAM_ETHTYPE_MASK 0x0001
  761. #define TSO_PARAM_ETHTYPE_SHIFT 9
  762. #define TSO_PARAM_IPHL_MASK 0x000F
  763. #define TSO_PARAM_IPHL_SHIFT 10
  764. #define TSO_PARAM_TCPHDRLEN_MASK 0x000F
  765. #define TSO_PARAM_TCPHDRLEN_SHIFT 14
  766. #define TSO_PARAM_HDRFLAG_MASK 0x0001
  767. #define TSO_PARAM_HDRFLAG_SHIFT 18
  768. #define TSO_PARAM_MSS_MASK 0x1FFF
  769. #define TSO_PARAM_MSS_SHIFT 19
  770. /* csumpu defines */
  771. #define CSUM_PARAM_BUFLEN_MASK 0x3FFF
  772. #define CSUM_PARAM_BUFLEN_SHIFT 0
  773. #define CSUM_PARAM_DMAINT_MASK 0x0001
  774. #define CSUM_PARAM_DMAINT_SHIFT 14
  775. #define CSUM_PARAM_PKTINT_MASK 0x0001
  776. #define CSUM_PARAM_PKTINT_SHIFT 15
  777. #define CSUM_PARAM_VALANTAG_MASK 0xFFFF
  778. #define CSUM_PARAM_VALAN_SHIFT 16
  779. /* csumpl defines*/
  780. #define CSUM_PARAM_EOP_MASK 0x0001
  781. #define CSUM_PARAM_EOP_SHIFT 0
  782. #define CSUM_PARAM_COALESCE_MASK 0x0001
  783. #define CSUM_PARAM_COALESCE_SHIFT 1
  784. #define CSUM_PARAM_INSVLAG_MASK 0x0001
  785. #define CSUM_PARAM_INSVLAG_SHIFT 2
  786. #define CSUM_PARAM_CUSTOMCKSUM_MASK 0x0001
  787. #define CSUM_PARAM_CUSTOMCKSUM_SHIFT 3
  788. #define CSUM_PARAM_SEGMENT_MASK 0x0001
  789. #define CSUM_PARAM_SEGMENT_SHIFT 4
  790. #define CSUM_PARAM_IPCKSUM_MASK 0x0001
  791. #define CSUM_PARAM_IPCKSUM_SHIFT 5
  792. #define CSUM_PARAM_TCPCKSUM_MASK 0x0001
  793. #define CSUM_PARAM_TCPCKSUM_SHIFT 6
  794. #define CSUM_PARAM_UDPCKSUM_MASK 0x0001
  795. #define CSUM_PARAM_UDPCKSUM_SHIFT 7
  796. #define CSUM_PARAM_VLANTAGGED_MASK 0x0001
  797. #define CSUM_PARAM_VLANTAGGED_SHIFT 8
  798. #define CSUM_PARAM_ETHTYPE_MASK 0x0001
  799. #define CSUM_PARAM_ETHTYPE_SHIFT 9
  800. #define CSUM_PARAM_IPHL_MASK 0x000F
  801. #define CSUM_PARAM_IPHL_SHIFT 10
  802. #define CSUM_PARAM_PLOADOFFSET_MASK 0x00FF
  803. #define CSUM_PARAM_PLOADOFFSET_SHIFT 16
  804. #define CSUM_PARAM_XSUMOFFSET_MASK 0x00FF
  805. #define CSUM_PARAM_XSUMOFFSET_SHIFT 24
  806. /* TPD descriptor */
  807. struct tso_param {
  808. /* The order of these declarations is important -- don't change it */
  809. u32 tsopu; /* tso_param upper word */
  810. u32 tsopl; /* tso_param lower word */
  811. };
  812. struct csum_param {
  813. /* The order of these declarations is important -- don't change it */
  814. u32 csumpu; /* csum_param upper word */
  815. u32 csumpl; /* csum_param lower word */
  816. };
  817. union tpd_descr {
  818. u64 data;
  819. struct csum_param csum;
  820. struct tso_param tso;
  821. };
  822. struct tx_packet_desc {
  823. __le64 buffer_addr;
  824. union tpd_descr desc;
  825. };
  826. /* DMA Order Settings */
  827. enum atl1_dma_order {
  828. atl1_dma_ord_in = 1,
  829. atl1_dma_ord_enh = 2,
  830. atl1_dma_ord_out = 4
  831. };
  832. enum atl1_dma_rcb {
  833. atl1_rcb_64 = 0,
  834. atl1_rcb_128 = 1
  835. };
  836. enum atl1_dma_req_block {
  837. atl1_dma_req_128 = 0,
  838. atl1_dma_req_256 = 1,
  839. atl1_dma_req_512 = 2,
  840. atl1_dam_req_1024 = 3,
  841. atl1_dam_req_2048 = 4,
  842. atl1_dma_req_4096 = 5
  843. };
  844. struct atl1_spi_flash_dev {
  845. const char *manu_name; /* manufacturer id */
  846. /* op-code */
  847. u8 cmd_wrsr;
  848. u8 cmd_read;
  849. u8 cmd_program;
  850. u8 cmd_wren;
  851. u8 cmd_wrdi;
  852. u8 cmd_rdsr;
  853. u8 cmd_rdid;
  854. u8 cmd_sector_erase;
  855. u8 cmd_chip_erase;
  856. };
  857. #endif /* _ATL1_HW_H_ */