smsc911x.h 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405
  1. /***************************************************************************
  2. *
  3. * Copyright (C) 2004-2008 SMSC
  4. * Copyright (C) 2005-2008 ARM
  5. *
  6. * This program is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU General Public License
  8. * as published by the Free Software Foundation; either version 2
  9. * of the License, or (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program; if not, write to the Free Software
  18. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  19. *
  20. ***************************************************************************/
  21. #ifndef __SMSC911X_H__
  22. #define __SMSC911X_H__
  23. #define TX_FIFO_LOW_THRESHOLD ((u32)1600)
  24. #define SMSC911X_EEPROM_SIZE ((u32)128)
  25. #define USE_DEBUG 0
  26. /* This is the maximum number of packets to be received every
  27. * NAPI poll */
  28. #define SMSC_NAPI_WEIGHT 16
  29. /* implements a PHY loopback test at initialisation time, to ensure a packet
  30. * can be successfully looped back */
  31. #define USE_PHY_WORK_AROUND
  32. #if USE_DEBUG >= 1
  33. #define SMSC_WARN(pdata, nlevel, fmt, args...) \
  34. netif_warn(pdata, nlevel, (pdata)->dev, \
  35. "%s: " fmt "\n", __func__, ##args)
  36. #else
  37. #define SMSC_WARN(pdata, nlevel, fmt, args...) \
  38. no_printk(fmt "\n", ##args)
  39. #endif
  40. #if USE_DEBUG >= 2
  41. #define SMSC_TRACE(pdata, nlevel, fmt, args...) \
  42. netif_info(pdata, nlevel, pdata->dev, fmt "\n", ##args)
  43. #else
  44. #define SMSC_TRACE(pdata, nlevel, fmt, args...) \
  45. no_printk(fmt "\n", ##args)
  46. #endif
  47. #ifdef CONFIG_DEBUG_SPINLOCK
  48. #define SMSC_ASSERT_MAC_LOCK(pdata) \
  49. WARN_ON(!spin_is_locked(&pdata->mac_lock))
  50. #else
  51. #define SMSC_ASSERT_MAC_LOCK(pdata) do {} while (0)
  52. #endif /* CONFIG_DEBUG_SPINLOCK */
  53. /* SMSC911x registers and bitfields */
  54. #define RX_DATA_FIFO 0x00
  55. #define TX_DATA_FIFO 0x20
  56. #define TX_CMD_A_ON_COMP_ 0x80000000
  57. #define TX_CMD_A_BUF_END_ALGN_ 0x03000000
  58. #define TX_CMD_A_4_BYTE_ALGN_ 0x00000000
  59. #define TX_CMD_A_16_BYTE_ALGN_ 0x01000000
  60. #define TX_CMD_A_32_BYTE_ALGN_ 0x02000000
  61. #define TX_CMD_A_DATA_OFFSET_ 0x001F0000
  62. #define TX_CMD_A_FIRST_SEG_ 0x00002000
  63. #define TX_CMD_A_LAST_SEG_ 0x00001000
  64. #define TX_CMD_A_BUF_SIZE_ 0x000007FF
  65. #define TX_CMD_B_PKT_TAG_ 0xFFFF0000
  66. #define TX_CMD_B_ADD_CRC_DISABLE_ 0x00002000
  67. #define TX_CMD_B_DISABLE_PADDING_ 0x00001000
  68. #define TX_CMD_B_PKT_BYTE_LENGTH_ 0x000007FF
  69. #define RX_STATUS_FIFO 0x40
  70. #define RX_STS_ES_ 0x00008000
  71. #define RX_STS_LENGTH_ERR_ 0x00001000
  72. #define RX_STS_MCAST_ 0x00000400
  73. #define RX_STS_FRAME_TYPE_ 0x00000020
  74. #define RX_STS_CRC_ERR_ 0x00000002
  75. #define RX_STATUS_FIFO_PEEK 0x44
  76. #define TX_STATUS_FIFO 0x48
  77. #define TX_STS_ES_ 0x00008000
  78. #define TX_STS_LOST_CARRIER_ 0x00000800
  79. #define TX_STS_NO_CARRIER_ 0x00000400
  80. #define TX_STS_LATE_COL_ 0x00000200
  81. #define TX_STS_EXCESS_COL_ 0x00000100
  82. #define TX_STATUS_FIFO_PEEK 0x4C
  83. #define ID_REV 0x50
  84. #define ID_REV_CHIP_ID_ 0xFFFF0000
  85. #define ID_REV_REV_ID_ 0x0000FFFF
  86. #define INT_CFG 0x54
  87. #define INT_CFG_INT_DEAS_ 0xFF000000
  88. #define INT_CFG_INT_DEAS_CLR_ 0x00004000
  89. #define INT_CFG_INT_DEAS_STS_ 0x00002000
  90. #define INT_CFG_IRQ_INT_ 0x00001000
  91. #define INT_CFG_IRQ_EN_ 0x00000100
  92. #define INT_CFG_IRQ_POL_ 0x00000010
  93. #define INT_CFG_IRQ_TYPE_ 0x00000001
  94. #define INT_STS 0x58
  95. #define INT_STS_SW_INT_ 0x80000000
  96. #define INT_STS_TXSTOP_INT_ 0x02000000
  97. #define INT_STS_RXSTOP_INT_ 0x01000000
  98. #define INT_STS_RXDFH_INT_ 0x00800000
  99. #define INT_STS_RXDF_INT_ 0x00400000
  100. #define INT_STS_TX_IOC_ 0x00200000
  101. #define INT_STS_RXD_INT_ 0x00100000
  102. #define INT_STS_GPT_INT_ 0x00080000
  103. #define INT_STS_PHY_INT_ 0x00040000
  104. #define INT_STS_PME_INT_ 0x00020000
  105. #define INT_STS_TXSO_ 0x00010000
  106. #define INT_STS_RWT_ 0x00008000
  107. #define INT_STS_RXE_ 0x00004000
  108. #define INT_STS_TXE_ 0x00002000
  109. #define INT_STS_TDFU_ 0x00000800
  110. #define INT_STS_TDFO_ 0x00000400
  111. #define INT_STS_TDFA_ 0x00000200
  112. #define INT_STS_TSFF_ 0x00000100
  113. #define INT_STS_TSFL_ 0x00000080
  114. #define INT_STS_RXDF_ 0x00000040
  115. #define INT_STS_RDFL_ 0x00000020
  116. #define INT_STS_RSFF_ 0x00000010
  117. #define INT_STS_RSFL_ 0x00000008
  118. #define INT_STS_GPIO2_INT_ 0x00000004
  119. #define INT_STS_GPIO1_INT_ 0x00000002
  120. #define INT_STS_GPIO0_INT_ 0x00000001
  121. #define INT_EN 0x5C
  122. #define INT_EN_SW_INT_EN_ 0x80000000
  123. #define INT_EN_TXSTOP_INT_EN_ 0x02000000
  124. #define INT_EN_RXSTOP_INT_EN_ 0x01000000
  125. #define INT_EN_RXDFH_INT_EN_ 0x00800000
  126. #define INT_EN_TIOC_INT_EN_ 0x00200000
  127. #define INT_EN_RXD_INT_EN_ 0x00100000
  128. #define INT_EN_GPT_INT_EN_ 0x00080000
  129. #define INT_EN_PHY_INT_EN_ 0x00040000
  130. #define INT_EN_PME_INT_EN_ 0x00020000
  131. #define INT_EN_TXSO_EN_ 0x00010000
  132. #define INT_EN_RWT_EN_ 0x00008000
  133. #define INT_EN_RXE_EN_ 0x00004000
  134. #define INT_EN_TXE_EN_ 0x00002000
  135. #define INT_EN_TDFU_EN_ 0x00000800
  136. #define INT_EN_TDFO_EN_ 0x00000400
  137. #define INT_EN_TDFA_EN_ 0x00000200
  138. #define INT_EN_TSFF_EN_ 0x00000100
  139. #define INT_EN_TSFL_EN_ 0x00000080
  140. #define INT_EN_RXDF_EN_ 0x00000040
  141. #define INT_EN_RDFL_EN_ 0x00000020
  142. #define INT_EN_RSFF_EN_ 0x00000010
  143. #define INT_EN_RSFL_EN_ 0x00000008
  144. #define INT_EN_GPIO2_INT_ 0x00000004
  145. #define INT_EN_GPIO1_INT_ 0x00000002
  146. #define INT_EN_GPIO0_INT_ 0x00000001
  147. #define BYTE_TEST 0x64
  148. #define FIFO_INT 0x68
  149. #define FIFO_INT_TX_AVAIL_LEVEL_ 0xFF000000
  150. #define FIFO_INT_TX_STS_LEVEL_ 0x00FF0000
  151. #define FIFO_INT_RX_AVAIL_LEVEL_ 0x0000FF00
  152. #define FIFO_INT_RX_STS_LEVEL_ 0x000000FF
  153. #define RX_CFG 0x6C
  154. #define RX_CFG_RX_END_ALGN_ 0xC0000000
  155. #define RX_CFG_RX_END_ALGN4_ 0x00000000
  156. #define RX_CFG_RX_END_ALGN16_ 0x40000000
  157. #define RX_CFG_RX_END_ALGN32_ 0x80000000
  158. #define RX_CFG_RX_DMA_CNT_ 0x0FFF0000
  159. #define RX_CFG_RX_DUMP_ 0x00008000
  160. #define RX_CFG_RXDOFF_ 0x00001F00
  161. #define TX_CFG 0x70
  162. #define TX_CFG_TXS_DUMP_ 0x00008000
  163. #define TX_CFG_TXD_DUMP_ 0x00004000
  164. #define TX_CFG_TXSAO_ 0x00000004
  165. #define TX_CFG_TX_ON_ 0x00000002
  166. #define TX_CFG_STOP_TX_ 0x00000001
  167. #define HW_CFG 0x74
  168. #define HW_CFG_TTM_ 0x00200000
  169. #define HW_CFG_SF_ 0x00100000
  170. #define HW_CFG_TX_FIF_SZ_ 0x000F0000
  171. #define HW_CFG_TR_ 0x00003000
  172. #define HW_CFG_SRST_ 0x00000001
  173. /* only available on 115/117 */
  174. #define HW_CFG_PHY_CLK_SEL_ 0x00000060
  175. #define HW_CFG_PHY_CLK_SEL_INT_PHY_ 0x00000000
  176. #define HW_CFG_PHY_CLK_SEL_EXT_PHY_ 0x00000020
  177. #define HW_CFG_PHY_CLK_SEL_CLK_DIS_ 0x00000040
  178. #define HW_CFG_SMI_SEL_ 0x00000010
  179. #define HW_CFG_EXT_PHY_DET_ 0x00000008
  180. #define HW_CFG_EXT_PHY_EN_ 0x00000004
  181. #define HW_CFG_SRST_TO_ 0x00000002
  182. /* only available on 116/118 */
  183. #define HW_CFG_32_16_BIT_MODE_ 0x00000004
  184. #define RX_DP_CTRL 0x78
  185. #define RX_DP_CTRL_RX_FFWD_ 0x80000000
  186. #define RX_FIFO_INF 0x7C
  187. #define RX_FIFO_INF_RXSUSED_ 0x00FF0000
  188. #define RX_FIFO_INF_RXDUSED_ 0x0000FFFF
  189. #define TX_FIFO_INF 0x80
  190. #define TX_FIFO_INF_TSUSED_ 0x00FF0000
  191. #define TX_FIFO_INF_TDFREE_ 0x0000FFFF
  192. #define PMT_CTRL 0x84
  193. #define PMT_CTRL_PM_MODE_ 0x00003000
  194. #define PMT_CTRL_PM_MODE_D0_ 0x00000000
  195. #define PMT_CTRL_PM_MODE_D1_ 0x00001000
  196. #define PMT_CTRL_PM_MODE_D2_ 0x00002000
  197. #define PMT_CTRL_PM_MODE_D3_ 0x00003000
  198. #define PMT_CTRL_PHY_RST_ 0x00000400
  199. #define PMT_CTRL_WOL_EN_ 0x00000200
  200. #define PMT_CTRL_ED_EN_ 0x00000100
  201. #define PMT_CTRL_PME_TYPE_ 0x00000040
  202. #define PMT_CTRL_WUPS_ 0x00000030
  203. #define PMT_CTRL_WUPS_NOWAKE_ 0x00000000
  204. #define PMT_CTRL_WUPS_ED_ 0x00000010
  205. #define PMT_CTRL_WUPS_WOL_ 0x00000020
  206. #define PMT_CTRL_WUPS_MULTI_ 0x00000030
  207. #define PMT_CTRL_PME_IND_ 0x00000008
  208. #define PMT_CTRL_PME_POL_ 0x00000004
  209. #define PMT_CTRL_PME_EN_ 0x00000002
  210. #define PMT_CTRL_READY_ 0x00000001
  211. #define GPIO_CFG 0x88
  212. #define GPIO_CFG_LED3_EN_ 0x40000000
  213. #define GPIO_CFG_LED2_EN_ 0x20000000
  214. #define GPIO_CFG_LED1_EN_ 0x10000000
  215. #define GPIO_CFG_GPIO2_INT_POL_ 0x04000000
  216. #define GPIO_CFG_GPIO1_INT_POL_ 0x02000000
  217. #define GPIO_CFG_GPIO0_INT_POL_ 0x01000000
  218. #define GPIO_CFG_EEPR_EN_ 0x00700000
  219. #define GPIO_CFG_GPIOBUF2_ 0x00040000
  220. #define GPIO_CFG_GPIOBUF1_ 0x00020000
  221. #define GPIO_CFG_GPIOBUF0_ 0x00010000
  222. #define GPIO_CFG_GPIODIR2_ 0x00000400
  223. #define GPIO_CFG_GPIODIR1_ 0x00000200
  224. #define GPIO_CFG_GPIODIR0_ 0x00000100
  225. #define GPIO_CFG_GPIOD4_ 0x00000020
  226. #define GPIO_CFG_GPIOD3_ 0x00000010
  227. #define GPIO_CFG_GPIOD2_ 0x00000004
  228. #define GPIO_CFG_GPIOD1_ 0x00000002
  229. #define GPIO_CFG_GPIOD0_ 0x00000001
  230. #define GPT_CFG 0x8C
  231. #define GPT_CFG_TIMER_EN_ 0x20000000
  232. #define GPT_CFG_GPT_LOAD_ 0x0000FFFF
  233. #define GPT_CNT 0x90
  234. #define GPT_CNT_GPT_CNT_ 0x0000FFFF
  235. #define WORD_SWAP 0x98
  236. #define FREE_RUN 0x9C
  237. #define RX_DROP 0xA0
  238. #define MAC_CSR_CMD 0xA4
  239. #define MAC_CSR_CMD_CSR_BUSY_ 0x80000000
  240. #define MAC_CSR_CMD_R_NOT_W_ 0x40000000
  241. #define MAC_CSR_CMD_CSR_ADDR_ 0x000000FF
  242. #define MAC_CSR_DATA 0xA8
  243. #define AFC_CFG 0xAC
  244. #define AFC_CFG_AFC_HI_ 0x00FF0000
  245. #define AFC_CFG_AFC_LO_ 0x0000FF00
  246. #define AFC_CFG_BACK_DUR_ 0x000000F0
  247. #define AFC_CFG_FCMULT_ 0x00000008
  248. #define AFC_CFG_FCBRD_ 0x00000004
  249. #define AFC_CFG_FCADD_ 0x00000002
  250. #define AFC_CFG_FCANY_ 0x00000001
  251. #define E2P_CMD 0xB0
  252. #define E2P_CMD_EPC_BUSY_ 0x80000000
  253. #define E2P_CMD_EPC_CMD_ 0x70000000
  254. #define E2P_CMD_EPC_CMD_READ_ 0x00000000
  255. #define E2P_CMD_EPC_CMD_EWDS_ 0x10000000
  256. #define E2P_CMD_EPC_CMD_EWEN_ 0x20000000
  257. #define E2P_CMD_EPC_CMD_WRITE_ 0x30000000
  258. #define E2P_CMD_EPC_CMD_WRAL_ 0x40000000
  259. #define E2P_CMD_EPC_CMD_ERASE_ 0x50000000
  260. #define E2P_CMD_EPC_CMD_ERAL_ 0x60000000
  261. #define E2P_CMD_EPC_CMD_RELOAD_ 0x70000000
  262. #define E2P_CMD_EPC_TIMEOUT_ 0x00000200
  263. #define E2P_CMD_MAC_ADDR_LOADED_ 0x00000100
  264. #define E2P_CMD_EPC_ADDR_ 0x000000FF
  265. #define E2P_DATA 0xB4
  266. #define E2P_DATA_EEPROM_DATA_ 0x000000FF
  267. #define LAN_REGISTER_EXTENT 0x00000100
  268. /*
  269. * MAC Control and Status Register (Indirect Address)
  270. * Offset (through the MAC_CSR CMD and DATA port)
  271. */
  272. #define MAC_CR 0x01
  273. #define MAC_CR_RXALL_ 0x80000000
  274. #define MAC_CR_HBDIS_ 0x10000000
  275. #define MAC_CR_RCVOWN_ 0x00800000
  276. #define MAC_CR_LOOPBK_ 0x00200000
  277. #define MAC_CR_FDPX_ 0x00100000
  278. #define MAC_CR_MCPAS_ 0x00080000
  279. #define MAC_CR_PRMS_ 0x00040000
  280. #define MAC_CR_INVFILT_ 0x00020000
  281. #define MAC_CR_PASSBAD_ 0x00010000
  282. #define MAC_CR_HFILT_ 0x00008000
  283. #define MAC_CR_HPFILT_ 0x00002000
  284. #define MAC_CR_LCOLL_ 0x00001000
  285. #define MAC_CR_BCAST_ 0x00000800
  286. #define MAC_CR_DISRTY_ 0x00000400
  287. #define MAC_CR_PADSTR_ 0x00000100
  288. #define MAC_CR_BOLMT_MASK_ 0x000000C0
  289. #define MAC_CR_DFCHK_ 0x00000020
  290. #define MAC_CR_TXEN_ 0x00000008
  291. #define MAC_CR_RXEN_ 0x00000004
  292. #define ADDRH 0x02
  293. #define ADDRL 0x03
  294. #define HASHH 0x04
  295. #define HASHL 0x05
  296. #define MII_ACC 0x06
  297. #define MII_ACC_PHY_ADDR_ 0x0000F800
  298. #define MII_ACC_MIIRINDA_ 0x000007C0
  299. #define MII_ACC_MII_WRITE_ 0x00000002
  300. #define MII_ACC_MII_BUSY_ 0x00000001
  301. #define MII_DATA 0x07
  302. #define FLOW 0x08
  303. #define FLOW_FCPT_ 0xFFFF0000
  304. #define FLOW_FCPASS_ 0x00000004
  305. #define FLOW_FCEN_ 0x00000002
  306. #define FLOW_FCBSY_ 0x00000001
  307. #define VLAN1 0x09
  308. #define VLAN2 0x0A
  309. #define WUFF 0x0B
  310. #define WUCSR 0x0C
  311. #define WUCSR_GUE_ 0x00000200
  312. #define WUCSR_WUFR_ 0x00000040
  313. #define WUCSR_MPR_ 0x00000020
  314. #define WUCSR_WAKE_EN_ 0x00000004
  315. #define WUCSR_MPEN_ 0x00000002
  316. /*
  317. * Phy definitions (vendor-specific)
  318. */
  319. #define LAN9118_PHY_ID 0x00C0001C
  320. #define MII_INTSTS 0x1D
  321. #define MII_INTMSK 0x1E
  322. #define PHY_INTMSK_AN_RCV_ (1 << 1)
  323. #define PHY_INTMSK_PDFAULT_ (1 << 2)
  324. #define PHY_INTMSK_AN_ACK_ (1 << 3)
  325. #define PHY_INTMSK_LNKDOWN_ (1 << 4)
  326. #define PHY_INTMSK_RFAULT_ (1 << 5)
  327. #define PHY_INTMSK_AN_COMP_ (1 << 6)
  328. #define PHY_INTMSK_ENERGYON_ (1 << 7)
  329. #define PHY_INTMSK_DEFAULT_ (PHY_INTMSK_ENERGYON_ | \
  330. PHY_INTMSK_AN_COMP_ | \
  331. PHY_INTMSK_RFAULT_ | \
  332. PHY_INTMSK_LNKDOWN_)
  333. #define ADVERTISE_PAUSE_ALL (ADVERTISE_PAUSE_CAP | \
  334. ADVERTISE_PAUSE_ASYM)
  335. #define LPA_PAUSE_ALL (LPA_PAUSE_CAP | \
  336. LPA_PAUSE_ASYM)
  337. /*
  338. * Provide hooks to let the arch add to the initialisation procedure
  339. * and to override the source of the MAC address.
  340. */
  341. #define SMSC_INITIALIZE() do {} while (0)
  342. #define smsc_get_mac(dev) smsc911x_read_mac_address((dev))
  343. #ifdef CONFIG_SMSC911X_ARCH_HOOKS
  344. #include <asm/smsc911x.h>
  345. #endif
  346. #endif /* __SMSC911X_H__ */