smsc911x.h 12 KB

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