smsc9500.h 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888
  1. /***************************************************************************
  2. *
  3. * Copyright (C) 2007-2008 SMSC
  4. *
  5. * This program is free software; you can redistribute it and/or
  6. * modify it under the terms of the GNU General Public License
  7. * as published by the Free Software Foundation; either version 2
  8. * of the License, or (at your option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program; if not, write to the Free Software
  17. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  18. *
  19. ***************************************************************************
  20. * File: smsc9500.h
  21. *****************************************************************************/
  22. #ifndef _LAN9500_H
  23. #define _LAN9500_H
  24. typedef unsigned char BYTE;
  25. #define ON TRUE
  26. #define OFF FALSE
  27. #define STATUS_WORD_LEN 4
  28. #define RX_OFFSET
  29. #define LAN_REGISTER_RANGE 0xFF
  30. #define MAC_REGISTER_RANGE_MIN 0x100
  31. #define MAC_REGISTER_RANGE_MAX 0x130
  32. //product id definition
  33. #define PID_LAN9500 0x9500
  34. #define PID_LAN9500A 0x9E00
  35. #define PID_LAN9512 0xEC00
  36. #define PID_LAN9530 0x9530
  37. #define PID_LAN9535 0x9535
  38. #define PID_LAN9730 0x9730
  39. #define PID_LAN9735 0x9735
  40. #define PID_LAN89530 0x9E08
  41. // Tx MAT Cmds
  42. #define TX_CMD_A_DATA_OFFSET_ (0x001F0000UL)
  43. #define TX_CMD_A_FIRST_SEG_ (0x00002000UL)
  44. #define TX_CMD_A_LAST_SEG_ (0x00001000UL)
  45. #define TX_CMD_A_BUF_SIZE_ (0x000007FFUL)
  46. #define TX_CMD_B_CSUM_ENABLE (0x00004000UL)
  47. #define TX_CMD_B_ADD_CRC_DISABLE_ (0x00002000UL)
  48. #define TX_CMD_B_DISABLE_PADDING_ (0x00001000UL)
  49. #define TX_CMD_B_PKT_BYTE_LENGTH_ (0x000007FFUL)
  50. // Rx sts Wd
  51. #define RX_STS_FF_ 0x40000000UL // Filter Fail
  52. #define RX_STS_FL_ 0x3FFF0000UL // Frame Length
  53. #define RX_STS_DL_SHIFT_ 16UL
  54. #define RX_STS_ES_ 0x00008000UL // Error Summary
  55. #define RX_STS_BF_ 0x00002000UL // Broadcast Frame
  56. #define RX_STS_LE_ 0x00001000UL // Length Error
  57. #define RX_STS_RF_ 0x00000800UL // Runt Frame
  58. #define RX_STS_MF_ 0x00000400UL // Multicast Frame
  59. #define RX_STS_TL_ 0x00000080UL // Frame too long
  60. #define RX_STS_CS_ 0x00000040UL // Collision Seen
  61. #define RX_STS_FT_ 0x00000020UL // Frame Type
  62. #define RX_STS_RW_ 0x00000010UL // Receive Watchdog
  63. #define RX_STS_ME_ 0x00000008UL // Mii Error
  64. #define RX_STS_DB_ 0x00000004UL // Dribbling
  65. #define RX_STS_CRC_ 0x00000002UL // CRC Error
  66. #define RX_STS_ERR_MASK_ 0x000088DEUL
  67. // SCSRs
  68. #define ID_REV (0x00UL)
  69. #define ID_REV_CHIP_ID_MASK_ (0xffff0000UL)
  70. #define ID_REV_CHIP_REV_MASK_ (0x0000ffffUL)
  71. #define ID_REV_CHIP_ID_9500_ (0x9500UL)
  72. #define GetChipIdFromID_REV(dwReg) ((dwReg & ID_REV_CHIP_ID_MASK_) >> 16)
  73. #define GetChiprevFromID_REV(dwReg) (dwReg & ID_REV_CHIP_REV_MASK_)
  74. #define FPGA_REV (0x04UL)
  75. #define INT_STS (0x08UL)
  76. #define INT_STS_TX_STOP_ (0x00020000UL)
  77. #define INT_STS_RX_STOP_ (0x00010000UL)
  78. #define INT_STS_PHY_INT_ (0x00008000UL)
  79. #define INT_STS_TXE_ (0x00004000UL)
  80. #define INT_STS_TDFU_ (0x00002000UL)
  81. #define INT_STS_TDFO_ (0x00001000UL)
  82. #define INT_STS_RXDF_ (0x00000800UL)
  83. #define INT_STS_GPIOS_ (0x000007FFUL)
  84. #define RX_CFG (0x0CUL)
  85. #define RX_FIFO_FLUSH_ (0x00000001UL)
  86. #define TX_CFG (0x10UL)
  87. #define TX_CFG_ON_ (0x00000004UL)
  88. #define TX_CFG_STOP_ (0x00000002UL)
  89. #define TX_CFG_FIFO_FLUSH_ (0x00000001UL)
  90. #define HW_CFG (0x14UL)
  91. #define HW_CFG_SMDET_STS (0x00040000UL)
  92. #define HW_CFG_SMDET_EN (0x00020000UL)
  93. #define HW_CFG_EEM (0x00010000UL)
  94. #define HW_CFG_RST_PROTECT (0x00008000UL)
  95. #define HW_CFG_PHY_BOOST (0x00006000UL)
  96. #define HW_CFG_PHY_BOOST_NORMAL (0x00000000UL)
  97. #define HW_CFG_PHY_BOOST_4 (0x00002000UL)
  98. #define HW_CFG_PHY_BOOST_8 (0x00004000UL)
  99. #define HW_CFG_PHY_BOOST_12 (0x00006000UL)
  100. #define HW_CFG_BIR_ (0x00001000UL)
  101. #define HW_CFG_LEDB_ (0x00000800UL)
  102. #define HW_CFG_RXDOFF_ (0x00000600UL)
  103. #define HW_CFG_RXDOFF_2_ (0x00000400UL)
  104. #define HW_CFG_SBP_ (0x00000100UL)
  105. #define HW_CFG_IME_ (0x00000080UL)
  106. #define HW_CFG_DRP_ (0x00000040UL)
  107. #define HW_CFG_MEF_ (0x00000020UL)
  108. #define HW_CFG_ETC_ (0x00000010UL)
  109. #define HW_CFG_LRST_ (0x00000008UL)
  110. #define HW_CFG_PSEL_ (0x00000004UL)
  111. #define HW_CFG_BCE_ (0x00000002UL)
  112. #define HW_CFG_SRST_ (0x00000001UL)
  113. #define RX_FIFO_INF (0x18UL)
  114. #define TX_FIFO_INF (0x1CUL)
  115. #define PM_CTRL (0x20UL)
  116. #define PM_CTL_RES_CLR_WKP_STS (0x00000200UL)
  117. #define PM_CTL_RES_CLR_WKP_EN (0x00000100UL)
  118. #define PM_CTL_DEV_RDY_ (0x00000080UL)
  119. #define PM_CTL_SUS_MODE_ (0x00000060UL)
  120. #define PM_CTL_SUS_MODE_0 (0x00000000UL)
  121. #define PM_CTL_SUS_MODE_1 (0x00000020UL)
  122. #define PM_CTL_SUS_MODE_2 (0x00000040UL)
  123. #define PM_CTL_SUS_MODE_3 (0x00000060UL)
  124. #define PM_CTL_PHY_RST_ (0x00000010UL)
  125. #define PM_CTL_WOL_EN_ (0x00000008UL)
  126. #define PM_CTL_ED_EN_ (0x00000004UL)
  127. #define PM_CTL_WUPS_ (0x00000003UL)
  128. #define PM_CTL_WUPS_NO_ (0x00000000UL)
  129. #define PM_CTL_WUPS_ED_ (0x00000001UL)
  130. #define PM_CTL_WUPS_WOL_ (0x00000002UL)
  131. #define PM_CTL_WUPS_MULTI_ (0x00000003UL)
  132. #define LED_GPIO_CFG (0x24UL)
  133. #define LED_GPIO_CFG_LED_SEL_ (0x80000000UL)
  134. #define LED_GPIO_CFG_GPCTL_10_ (0x03000000UL)
  135. #define LED_GPIO_CFG_GPCTL_10_SH 24
  136. #define LED_GPIO_CFG_GPCTL_09_ (0x00300000UL)
  137. #define LED_GPIO_CFG_GPCTL_09_SH 20
  138. #define LED_GPIO_CFG_GPCTL_08_ (0x00030000UL)
  139. #define LED_GPIO_CFG_GPCTL_08_SH 16
  140. #define LED_GPIO_CFG_GPCTL_DIAG2_ (0x3UL)
  141. #define LED_GPIO_CFG_GPCTL_DIAG1_ (0x2UL)
  142. #define LED_GPIO_CFG_GPCTL_LED_ (0x1UL)
  143. #define LED_GPIO_CFG_GPCTL_GPIO_ (0x0UL)
  144. #define LED_GPIO_CFG_GPBUF_ (0x00000700UL)
  145. #define LED_GPIO_CFG_GPBUF_10_ (0x00000400UL)
  146. #define LED_GPIO_CFG_GPBUF_09_ (0x00000200UL)
  147. #define LED_GPIO_CFG_GPBUF_08_ (0x00000100UL)
  148. #define LED_GPIO_CFG_GPDIR_ (0x00000070UL)
  149. #define LED_GPIO_CFG_GPDIR_10_ (0x00000040UL)
  150. #define LED_GPIO_CFG_GPDIR_09_ (0x00000020UL)
  151. #define LED_GPIO_CFG_GPDIR_08_ (0x00000010UL)
  152. #define LED_GPIO_CFG_GPDATA_ (0x00000007UL)
  153. #define LED_GPIO_CFG_GPDATA_10_ (0x00000004UL)
  154. #define LED_GPIO_CFG_GPDATA_09_ (0x00000002UL)
  155. #define LED_GPIO_CFG_GPDATA_08_ (0x00000001UL)
  156. #define GPIO_CFG (0x28UL)
  157. #define GPIO_CFG_GPEN_ (0xFF000000UL)
  158. #define GPIO_CFG_GPO0_EN_ (0x01000000UL)
  159. #define GPIO_CFG_GPTYPE (0x00FF0000UL)
  160. #define GPIO_CFG_GPO0_TYPE (0x00010000UL)
  161. #define GPIO_CFG_GPDIR_ (0x0000FF00UL)
  162. #define GPIO_CFG_GPO0_DIR_ (0x00000100UL)
  163. #define GPIO_CFG_GPDATA_ (0x000000FFUL)
  164. #define GPIO_CFG_GPO0_DATA_ (0x00000001UL)
  165. #define AFC_CFG (0x2CUL)
  166. #define AFC_CFG_DEFAULT (0x00f830A1UL) // Hi watermark = 15.5Kb (~10 mtu pkts)
  167. // low watermark = 3k (~2 mtu pkts)
  168. // backpressure duration = ~ 350us
  169. // Apply FC on any frame.
  170. #define E2P_CMD (0x30UL)
  171. #define E2P_CMD_BUSY_ 0x80000000UL
  172. #define E2P_CMD_MASK_ 0x70000000UL
  173. #define E2P_CMD_READ_ 0x00000000UL
  174. #define E2P_CMD_EWDS_ 0x10000000UL
  175. #define E2P_CMD_EWEN_ 0x20000000UL
  176. #define E2P_CMD_WRITE_ 0x30000000UL
  177. #define E2P_CMD_WRAL_ 0x40000000UL
  178. #define E2P_CMD_ERASE_ 0x50000000UL
  179. #define E2P_CMD_ERAL_ 0x60000000UL
  180. #define E2P_CMD_RELOAD_ 0x70000000UL
  181. #define E2P_CMD_TIMEOUT_ 0x00000400UL
  182. #define E2P_CMD_LOADED_ 0x00000200UL
  183. #define E2P_CMD_ADDR_ 0x000001FFUL
  184. #define E2P_DATA (0x34UL)
  185. #define E2P_DATA_MASK_ 0x000000FFUL
  186. #define BURST_CAP (0x38UL)
  187. #define STRAP_DBG (0x3CUL)
  188. #define EEPROM_DISABLE (0x1)
  189. #define EEPROM_SIZE (0x4)
  190. #define DP_SEL (0x40UL)
  191. #define DP_SEL_DPRDY (0x80000000UL)
  192. #define DP_SEL_RSEL (0x00000006UL)
  193. #define DP_SEL_RSEL_FCT (0x00000000UL)
  194. #define DP_SEL_RSEL_EEPROM (0x00000002UL)
  195. #define DP_SEL_RSEL_TXTLI (0x00000004UL)
  196. #define DP_SEL_RSEL_RXTLI (0x00000006UL)
  197. #define DP_SEL_TESTEN (0x00000001UL)
  198. #define DP_CMD (0x44UL)
  199. #define DP_CMD_READ (0x0)
  200. #define DP_CMD_WRITE (0x1)
  201. #define DP_ADDR (0x48UL)
  202. #define DP_DATA0 (0x4CUL)
  203. #define DP_DATA1 (0x50UL)
  204. #define RAM_BIST0 (0x54UL)
  205. #define RAM_BIST1 (0x58UL)
  206. #define RAM_BIST2 (0x5CUL)
  207. #define RAM_BIST3 (0x60UL)
  208. #define GPIO_WAKE (0x64UL)
  209. #define INT_EP_CTL (0x68UL)
  210. #define BULK_IN_DLY (0x6CUL)
  211. #define INT_EP_CTL_INTEP_ (0x80000000UL)
  212. #define INT_EP_CTL_MACRTO_ (0x00080000UL)
  213. #define INT_EP_CTL_RX_FIFO_EN_ (0x00040000UL)
  214. #define INT_EP_CTL_TX_STOP_ (0x00020000UL)
  215. #define INT_EP_CTL_RX_STOP_ (0x00010000UL)
  216. #define INT_EP_CTL_PHY_INT_ (0x00008000UL)
  217. #define INT_EP_CTL_TXE_ (0x00004000UL)
  218. #define INT_EP_CTL_TDFU_ (0x00002000UL)
  219. #define INT_EP_CTL_TDFO_ (0x00001000UL)
  220. #define INT_EP_CTL_RXDF_ (0x00000800UL)
  221. #define INT_EP_CTL_GPIOS_ (0x000007FFUL)
  222. #define FLAG_ATTR (0xB0UL)
  223. #define FLAG_ATTR_RMT_WKP (0x20000UL)
  224. #define FLAG_ATTR_SELF_PWR (0x10000UL)
  225. #define FLAG_ATTR_PME_ENABLE (0x80UL)
  226. #define FLAG_ATTR_PME_CFG_PULSE (0x40UL)
  227. #define FLAG_ATTR_PME_LEN_150MS (0x20UL)
  228. #define FLAG_ATTR_PME_POL (0x10UL)
  229. #define FLAG_ATTR_PME_BUFF_TYPE (0x8UL)
  230. #define FLAG_ATTR_PME_WAKE_PHY (0x4UL)
  231. #define FLAG_ATTR_PME_GPIO10_HIGH (0x2UL)
  232. // MAC CSRs
  233. #define MAC_CR (0x100UL)
  234. #define MAC_CR_RXALL_ 0x80000000UL
  235. #define MAC_CR_ENABLE_EEE 0x02000000UL
  236. #define MAC_CR_RCVOWN_ 0x00800000UL
  237. #define MAC_CR_LOOPBK_ 0x00200000UL
  238. #define MAC_CR_FDPX_ 0x00100000UL
  239. #define MAC_CR_MCPAS_ 0x00080000UL
  240. #define MAC_CR_PRMS_ 0x00040000UL
  241. #define MAC_CR_INVFILT_ 0x00020000UL
  242. #define MAC_CR_PASSBAD_ 0x00010000UL
  243. #define MAC_CR_HFILT_ 0x00008000UL
  244. #define MAC_CR_HPFILT_ 0x00002000UL
  245. #define MAC_CR_LCOLL_ 0x00001000UL
  246. #define MAC_CR_BCAST_ 0x00000800UL
  247. #define MAC_CR_DISRTY_ 0x00000400UL
  248. #define MAC_CR_PADSTR_ 0x00000100UL
  249. #define MAC_CR_BOLMT_MASK 0x000000C0UL
  250. #define MAC_CR_DFCHK_ 0x00000020UL
  251. #define MAC_CR_TXEN_ 0x00000008UL
  252. #define MAC_CR_RXEN_ 0x00000004UL
  253. #define ADDRH (0x104UL)
  254. #define ADDRL (0x108UL)
  255. #define HASHH (0x10CUL)
  256. #define HASHL (0x110UL)
  257. #define MII_ADDR (0x114UL)
  258. #define MII_WRITE_ (0x02UL)
  259. #define MII_BUSY_ (0x01UL)
  260. #define MII_READ_ (0x00UL) // ~of MII Write bit
  261. #define MII_DATA (0x118UL)
  262. #define FLOW (0x11CUL)
  263. #define FLOW_FCPT_ (0xFFFF0000UL)
  264. #define FLOW_FCPASS_ (0x00000004UL)
  265. #define FLOW_FCEN_ (0x00000002UL)
  266. #define FLOW_FCBSY_ (0x00000001UL)
  267. #define VLAN1 (0x120UL)
  268. #define VLAN2 (0x124UL)
  269. #define WUFF (0x128UL)
  270. #define WUCSR (0x12CUL)
  271. #define WUCSR_GUE_ (0x00000200UL)
  272. #define WUCSR_WUFR_ (0x00000040UL)
  273. #define WUCSR_MPR_ (0x00000020UL)
  274. #define WUCSR_WAKE_EN_ (0x00000004UL)
  275. #define WUCSR_MPEN_ (0x00000002UL)
  276. #define COE_CR (0x130UL)
  277. #define Tx_COE_EN_ (0x00010000UL)
  278. #define Rx_COE_MODE_ (0x00000002UL)
  279. #define Rx_COE_EN_ (0x00000001UL)
  280. ////////////////////////////////////
  281. // PHY Definitions
  282. ////////////////////////////////////
  283. #define LAN_PHY_ADDR (1UL)
  284. #define PHY_BCR ((u32)0U)
  285. #define PHY_BCR_RESET_ ((u16)0x8000U)
  286. #define PHY_BCR_LOOPBACK_ ((u16)0x4000U)
  287. #define PHY_BCR_SPEED_SELECT_ ((u16)0x2000U)
  288. #define PHY_BCR_AUTO_NEG_ENABLE_ ((u16)0x1000U)
  289. #define PHY_BCR_POWER_DOWN ((u16)0x0800U)
  290. #define PHY_BCR_ISOLATE ((u16)0x0400U)
  291. #define PHY_BCR_RESTART_AUTO_NEG_ ((u16)0x0200U)
  292. #define PHY_BCR_DUPLEX_MODE_ ((u16)0x0100U)
  293. #define PHY_BSR ((u32)1U)
  294. #define PHY_BSR_AUTO_NEG_COMP_ ((u16)0x0020U)
  295. #define PHY_BSR_REMOTE_FAULT_ ((u16)0x0010U)
  296. #define PHY_BSR_LINK_STATUS_ ((u16)0x0004U)
  297. #define PHY_ID_1 ((u32)2U)
  298. #define PHY_ID_2 ((u32)3U)
  299. #define PHY_ANEG_ADV ((u32)4U)
  300. #define PHY_ANEG_NEXT_PAGE ((u16)0x8000)
  301. #define PHY_ANEG_ADV_PAUSE_ ((u16)0x0C00)
  302. #define PHY_ANEG_ADV_ASYMP_ ((u16)0x0800)
  303. #define PHY_ANEG_ADV_SYMP_ ((u16)0x0400)
  304. #define PHY_ANEG_ADV_SPEED_ ((u16)0x1E0)
  305. #define PHY_ANEG_ADV_100F_ ((u16)0x100)
  306. #define PHY_ANEG_ADV_100H_ ((u16)0x80)
  307. #define PHY_ANEG_ADV_10F_ ((u16)0x40)
  308. #define PHY_ANEG_ADV_10H_ ((u16)0x20)
  309. #define PHY_ANEG_LPA ((u32)5U)
  310. #define PHY_ANEG_LPA_ASYMP_ ((u16)0x0800)
  311. #define PHY_ANEG_LPA_SYMP_ ((u16)0x0400)
  312. #define PHY_ANEG_LPA_T4_ ((u16)0x0200)
  313. #define PHY_ANEG_LPA_100FDX_ ((u16)0x0100)
  314. #define PHY_ANEG_LPA_100HDX_ ((u16)0x0080)
  315. #define PHY_ANEG_LPA_10FDX_ ((u16)0x0040)
  316. #define PHY_ANEG_LPA_10HDX_ ((u16)0x0020)
  317. #define PHY_ANEG_REG ((u32)6U) /* Auto-Negotiation Expansion Reg */
  318. #define PHY_LP_AN_ABLE ((u16)0x0001)
  319. #define PHY_SILICON_REV ((u32)16U)
  320. #define PHY_SILICON_REV_TX_NLP_EN_ BIT_15
  321. #define PHY_SILICON_REV_TX_NLP_I_MSK_ (BIT_14 | BIT13)
  322. #define PHY_SILICON_REV_TX_NLP_I_256_ (BIT_14 | BIT13)
  323. #define PHY_SILICON_REV_TX_NLP_I_512_ BIT_14
  324. #define PHY_SILICON_REV_TX_NLP_I_768_ BIT_13
  325. #define PHY_SILICON_REV_TX_NLP_I_1S_ 0
  326. #define PHY_SILICON_REV_RX_1_NLP_ BIT_12
  327. #define PHY_SILICON_REV_EEE_ENABLE BIT_2
  328. #define PHY_SILICON_REV_EDPD_XTD_XOVR BIT_1
  329. #define PHY_SILICON_REV_AMDIX_XTD_ BIT_0
  330. #define EDPD_CFG_DEFAULT (PHY_SILICON_REV_TX_NLP_EN_ | PHY_SILICON_REV_TX_NLP_I_768_ | PHY_SILICON_REV_RX_1_NLP_)
  331. #define PHY_MODE_CTRL_STS ((u32)17) // Mode Control/Status Register
  332. #define MODE_CTRL_STS_FASTRIP_ ((u16)0x4000U)
  333. #define MODE_CTRL_STS_EDPWRDOWN_ ((u16)0x2000U)
  334. #define MODE_CTRL_STS_LOWSQEN_ ((u16)0x0800U)
  335. #define MODE_CTRL_STS_MDPREBP_ ((u16)0x0400U)
  336. #define MODE_CTRL_STS_FARLOOPBACK_ ((u16)0x0200U)
  337. #define MODE_CTRL_STS_FASTEST_ ((u16)0x0100U)
  338. #define MODE_CTRL_STS_REFCLKEN_ ((u16)0x0010U)
  339. #define MODE_CTRL_STS_PHYADBP_ ((u16)0x0008U)
  340. #define MODE_CTRL_STS_FORCE_G_LINK_ ((u16)0x0004U)
  341. #define MODE_CTRL_STS_ENERGYON_ ((u16)0x0002U)
  342. #define PHY_SPECIAL_MODES ((u32)18) // Special Modes
  343. #define PHY_TSTCNTL ((u32)20) // Testability/Configuration Control
  344. #define PHY_TSTCNTL_READ ((u16)0x8000U)
  345. #define PHY_TSTCNTL_WRITE ((u16)0x4000U)
  346. #define PHY_TSTCNTL_TEST_MODE ((u16)0x0400U)
  347. #define PHY_TSTCNTL_READ_MASK ((u16)0x02E0U)
  348. #define PHY_TSTCNTL_WRITE_MASK ((u16)0x001FU)
  349. #define PHY_TSTREAD1 ((u32)21) // Testability data Read for LSB
  350. #define PHY_TSTREAD2 ((u32)22) // Testability data Read for MSB
  351. #define PHY_TSTWRITE ((u32)23) // Testability/Configuration data Write
  352. #define PHY_SPECIAL_CTRL_STS ((u32)27)
  353. #define SPECIAL_CTRL_STS_OVRRD_AMDIX_ ((u16)0x8000U)
  354. #define SPECIAL_CTRL_STS_AMDIX_ENABLE_ ((u16)0x4000U)
  355. #define SPECIAL_CTRL_STS_AMDIX_STATE_ ((u16)0x2000U)
  356. #define PHY_SITC ((u32)28) //Special internal testability controls
  357. #define PHY_INT_SRC ((u32)29)
  358. #define PHY_INT_SRC_ENERGY_ON_ ((u16)0x0080U)
  359. #define PHY_INT_SRC_ANEG_COMP_ ((u16)0x0040U)
  360. #define PHY_INT_SRC_REMOTE_FAULT_ ((u16)0x0020U)
  361. #define PHY_INT_SRC_LINK_DOWN_ ((u16)0x0010U)
  362. #define PHY_INT_MASK ((u32)30)
  363. #define PHY_INT_MASK_ALL ((u16)0x00FFU)
  364. #define PHY_INT_MASK_ENERGY_ON_ ((u16)0x0080U)
  365. #define PHY_INT_MASK_ANEG_COMP_ ((u16)0x0040U)
  366. #define PHY_INT_MASK_REMOTE_FAULT_ ((u16)0x0020U)
  367. #define PHY_INT_MASK_LINK_DOWN_ ((u16)0x0010U)
  368. #define PHY_SPECIAL ((u32)31)
  369. #define PHY_SPECIAL_SPD_ ((u16)0x001CU)
  370. #define PHY_SPECIAL_SPD_10HALF_ ((u16)0x0004U)
  371. #define PHY_SPECIAL_SPD_10FULL_ ((u16)0x0014U)
  372. #define PHY_SPECIAL_SPD_100HALF_ ((u16)0x0008U)
  373. #define PHY_SPECIAL_SPD_100FULL_ ((u16)0x0018U)
  374. #define AMDIX_DISABLE_STRAIGHT ((u16)0x0U)
  375. #define AMDIX_DISABLE_CROSSOVER ((u16)0x01U)
  376. #define AMDIX_ENABLE ((u16)0x02U)
  377. #define PHY_LAN83C180_INT_ACK_REG 0x15
  378. #define PHY_LAN83C180_OPTIONS 0x18
  379. #define PHY_LAN83C183_STATUS_OUTPUT 0x12
  380. #define PHY_LAN83C183_INT_MASK 0x13
  381. #define PHY_LAN83C183_MASK_BASE 0xFFC0
  382. #define PHY_LAN83C183_MASK_INT ~0x8000
  383. #define PHY_LAN83C183_MASK_LINK ~0x4000
  384. #define PHY_FOX_INT_SOURCE 0x1D
  385. #define PHY_FOX_INT_ENERGY_ON BIT_7
  386. #define PHY_FOX_INT_NWAY_DONE BIT_6
  387. #define PHY_FOX_INT_REMOTE_FAULT BIT_5
  388. #define PHY_FOX_INT_LINK_DOWN BIT_4
  389. #define PHY_FOX_INT_NWAY_LP_ACK BIT_3
  390. #define PHY_FOX_INT_PARALLEL_DET BIT_2
  391. #define PHY_FOX_INT_NWAY_PAGE_RX BIT_1
  392. #define PHY_FOX_INT_RESERVED BIT_0
  393. #define PHY_FOX_INT_MASK 0x1E
  394. #define PHY_QSI_INT_SOURCE_REG 0x1D /* Interrupt Source Register for QSI */
  395. #define PHY_QSI_AN_COMPLETE_INT BIT_6
  396. #define PHY_QSI_REM_FAULT_INT BIT_5
  397. #define PHY_QSI_LINK_DOWN_INT BIT_4
  398. #define PHY_QSI_AN_LP_ACK_INT BIT_3
  399. #define PHY_QSI_PAR_DET_INT BIT_2
  400. #define PHY_QSI_AN_PAGE_RCVD_INT BIT_1
  401. #define PHY_QSI_RCV_ERR_CNT_INT BIT_0
  402. #define PHY_QSI_INT_MASK_REG 0x1E /* Interrupt Mask Register for QSI */
  403. #define PHY_QSI_INT_MODE BIT_15
  404. /******************************************************************************/
  405. /* Bit Mask definitions */
  406. /******************************************************************************/
  407. #define BIT_NONE 0x00000000
  408. #define BIT_0 0x0001
  409. #define BIT_1 0x0002
  410. #define BIT_2 0x0004
  411. #define BIT_3 0x0008
  412. #define BIT_4 0x0010
  413. #define BIT_5 0x0020
  414. #define BIT_6 0x0040
  415. #define BIT_7 0x0080
  416. #define BIT_8 0x0100
  417. #define BIT_9 0x0200
  418. #define BIT_10 0x0400
  419. #define BIT_11 0x0800
  420. #define BIT_12 0x1000
  421. #define BIT_13 0x2000
  422. #define BIT_14 0x4000
  423. #define BIT_15 0x8000
  424. #define BIT_16 0x10000
  425. #define BIT_17 0x20000
  426. #define BIT_18 0x40000
  427. #define BIT_19 0x80000
  428. #define BIT_20 0x100000
  429. #define BIT_21 0x200000
  430. #define BIT_22 0x400000
  431. #define BIT_23 0x800000
  432. #define BIT_24 0x1000000
  433. #define BIT_25 0x2000000
  434. #define BIT_26 0x4000000
  435. #define BIT_27 0x8000000
  436. #define BIT_28 0x10000000
  437. #define BIT_29 0x20000000
  438. #define BIT_30 0x40000000
  439. #define BIT_31 0x80000000
  440. // Vendor Requests
  441. #define USB_VENDOR_REQUEST_WRITE_REGISTER 0xA0
  442. #define USB_VENDOR_REQUEST_READ_REGISTER 0xA1
  443. #define USB_VENDOR_REQUEST_GET_STATS 0xA2
  444. #define rx_stat_count 8
  445. #define tx_stat_count 10
  446. // Stats block structures
  447. typedef struct _SMSC9500_RX_STATS {
  448. u32 RxGoodFrames;
  449. u32 RxCrcErrors;
  450. u32 RxRuntFrameErrors;
  451. u32 RxAlignmentErrors;
  452. u32 RxFrameTooLongError;
  453. u32 RxLaterCollisionError;
  454. u32 RxBadFrames;
  455. u32 RxFifoDroppedFrames;
  456. u32 EeeRxLpiTransitions;
  457. u32 EeeRxLpiTime;
  458. }SMSC9500_RX_STATS, *pSMSC9500_RX_STATS;
  459. typedef struct _SMSC9500_TX_STATS {
  460. u32 TxGoodFrames;
  461. u32 TxPauseFrames;
  462. u32 TxSingleCollisions;
  463. u32 TxMultipleCollisions;
  464. u32 TxExcessiveCollisionErrors;
  465. u32 TxLateCollisionErrors;
  466. u32 TxBufferUnderrunErrors;
  467. u32 TxExcessiveDeferralErrors;
  468. u32 TxCarrierErrors;
  469. u32 TxBadFrames;
  470. u32 EeeTxLpiTransitions;
  471. u32 EeeTxLpiTime;
  472. } SMSC9500_TX_STATS, *pSMSC9500_TX_STATS;
  473. // Interrupt Endpoint status word bitfields
  474. #define INT_ENP_RFHF_ (0x00040000UL)
  475. #define INT_ENP_TX_STOP_ ETH_INT_STS_TX_STOP_
  476. #define INT_ENP_RX_STOP_ ETH_INT_STS_RX_STOP_
  477. #define INT_ENP_PHY_INT_ ETH_INT_STS_PHY_INT_
  478. #define INT_ENP_TXE_ ETH_INT_STS_TXE_
  479. #define INT_ENP_TDFU_ ETH_INT_STS_TDFU_
  480. #define INT_ENP_TDFO_ ETH_INT_STS_TDFO_
  481. #define INT_ENP_RXDF_ ETH_INT_STS_RXDF_
  482. #define INT_ENP_GPIOS_ ETH_INT_STS_GPIOS_
  483. struct USB_CONTEXT{
  484. struct usb_ctrlrequest req;
  485. struct completion notify;
  486. };
  487. enum{
  488. ASYNC_RW_SUCCESS,
  489. ASYNC_RW_FAIL,
  490. ASYNC_RW_TIMEOUT,
  491. };
  492. #define USE_DEBUG
  493. #ifdef USE_DEBUG
  494. #define USE_WARNING
  495. #define USE_TRACE
  496. #define USE_ASSERT
  497. #endif //USE_DEBUG
  498. #define HIBYTE(word) ((BYTE)(((u16)(word))>>8))
  499. #define LOBYTE(word) ((BYTE)(((u16)(word))&0x00FFU))
  500. #define HIWORD(dWord) ((u16)(((u32)(dWord))>>16))
  501. #define LOWORD(dWord) ((u16)(((u32)(dWord))&0x0000FFFFUL))
  502. /*******************************************************
  503. * Macro: SMSC_TRACE
  504. * Description:
  505. * This macro is used like printf.
  506. * It can be used anywhere you want to display information
  507. * For any release version it should not be left in
  508. * performance sensitive Tx and Rx code paths.
  509. * To use this macro define USE_TRACE and set bit 0 of debug_mode
  510. *******************************************************/
  511. #ifdef USING_LINT
  512. extern void SMSC_TRACE(unsigned long dbgBit, const char * a, ...);
  513. #else //not USING_LINT
  514. #ifdef USE_TRACE
  515. extern u32 debug_mode;
  516. #ifndef USE_WARNING
  517. #define USE_WARNING
  518. #endif
  519. # define SMSC_TRACE(dbgBit,msg,args...) \
  520. if(debug_mode&dbgBit) { \
  521. printk("SMSC_9500: " msg "\n", ## args); \
  522. }
  523. #else
  524. # define SMSC_TRACE(dbgBit,msg,args...)
  525. #endif
  526. #endif //end of not USING_LINT
  527. /*******************************************************
  528. * Macro: SMSC_WARNING
  529. * Description:
  530. * This macro is used like printf.
  531. * It can be used anywhere you want to display warning information
  532. * For any release version it should not be left in
  533. * performance sensitive Tx and Rx code paths.
  534. * To use this macro define USE_TRACE or
  535. * USE_WARNING and set bit 1 of debug_mode
  536. *******************************************************/
  537. #ifdef USING_LINT
  538. extern void SMSC_WARNING(const char * a, ...);
  539. #else //not USING_LINT
  540. #ifdef USE_WARNING
  541. extern u32 debug_mode;
  542. #ifndef USE_ASSERT
  543. #define USE_ASSERT
  544. #endif
  545. # define SMSC_WARNING(msg, args...) \
  546. if(debug_mode&DBG_WARNING) { \
  547. printk("SMSC_9500_WARNING: ");\
  548. printk(__FUNCTION__);\
  549. printk(": " msg "\n",## args);\
  550. }
  551. #else
  552. # define SMSC_WARNING(msg, args...)
  553. #endif
  554. #endif //end of not USING_LINT
  555. /*******************************************************
  556. * Macro: SMSC_ASSERT
  557. * Description:
  558. * This macro is used to test assumptions made when coding.
  559. * It can be used anywhere, but is intended only for situations
  560. * where a failure is fatal.
  561. * If code execution where allowed to continue it is assumed that
  562. * only further unrecoverable errors would occur and so this macro
  563. * includes an infinite loop to prevent further corruption.
  564. * Assertions are only intended for use during developement to
  565. * insure consistency of logic through out the driver.
  566. * A driver should not be released if assertion failures are
  567. * still occuring.
  568. * To use this macro define USE_TRACE or USE_WARNING or
  569. * USE_ASSERT
  570. *******************************************************/
  571. #ifdef USING_LINT
  572. extern void SMSC_ASSERT(BOOLEAN condition);
  573. #else //not USING_LINT
  574. #ifdef USE_ASSERT
  575. #define SMSC_ASSERT(condition) \
  576. if(!(condition)) { \
  577. printk("SMSC_9500_ASSERTION_FAILURE: \n");\
  578. printk(" Condition = " #condition "\n");\
  579. printk(" Function = ");printk(__FUNCTION__);printk("\n");\
  580. printk(" File = " __FILE__ "\n");\
  581. printk(" Line = %d\n",__LINE__); \
  582. while(1);\
  583. }
  584. #else
  585. #define SMSC_ASSERT(condition)
  586. #endif
  587. #endif //end of not USING_LINT
  588. #define LINK_INIT (0xFFFF)
  589. #define LINK_OFF (0x00UL)
  590. #define LINK_SPEED_10HD (0x01UL)
  591. #define LINK_SPEED_10FD (0x02UL)
  592. #define LINK_SPEED_100HD (0x04UL)
  593. #define LINK_SPEED_100FD (0x08UL)
  594. #define LINK_SYMMETRIC_PAUSE (0x10UL)
  595. #define LINK_ASYMMETRIC_PAUSE (0x20UL)
  596. #define LINK_AUTO_NEGOTIATE (0x40UL)
  597. #define INT_END_MACRTO_INT_ (0x00080000UL)
  598. #define INT_END_RXFIFO_HAS_FRAME_ (0x00040000UL)
  599. #define INT_END_TXSTOP_INT_ (0x00020000UL)
  600. #define INT_END_RXSTOP_INT_ (0x00010000UL)
  601. #define INT_END_PHY_INT_ (0x00008000UL)
  602. #define INT_END_TXE_ (0x00004000UL)
  603. #define INT_END_TDFU_ (0x00002000UL)
  604. #define INT_END_TDFO_ (0x00001000UL)
  605. #define INT_END_RXDF_INT_ (0x00000800UL)
  606. #define INT_END_GPIO_INT_ (0x000007FFUL)
  607. #define DBG_TRACE (0x01UL)
  608. #define DBG_WARNING (0x02UL)
  609. #define DBG_INIT (0x80000000UL)
  610. #define DBG_CLOSE (0x40000000UL)
  611. #define DBG_INTR (0x20000000UL)
  612. #define DBG_PWR (0x10000000UL)
  613. #define DBG_IOCTL (0x08000000UL)
  614. #define DBG_LINK (0x04000000UL)
  615. #define DBG_RX (0x02000000UL)
  616. #define DBG_TX (0x01000000UL)
  617. #define DBG_MCAST (0x00800000UL)
  618. #define DBG_HOST (0x00400000UL)
  619. #define DBG_LINK_CHANGE (0x00200000UL)
  620. #define HS_USB_PKT_SIZE 512
  621. #define FS_USB_PKT_SIZE 64
  622. #define DEFAULT_HS_BURST_CAP_SIZE (16 *1024 + 5 * HS_USB_PKT_SIZE)
  623. #define DEFAULT_FS_BURST_CAP_SIZE (6 *1024 + 33 * FS_USB_PKT_SIZE)
  624. #define DEFAULT_BULK_IN_DELAY (0x00002000UL)
  625. #define ETH_HEADER_SIZE 14
  626. #define ETH_MAX_DATA_SIZE 1500
  627. #define ETH_MAX_PACKET_SIZE (ETH_MAX_DATA_SIZE + ETH_HEADER_SIZE)
  628. #define MAX_SINGLE_PACKET_SIZE 2048
  629. #define LAN9500_EEPROM_MAGIC 0x9500UL
  630. #define EEPROM_MAC_OFFSET 0x01
  631. struct smsc9500_int_data {
  632. u32 IntEndPoint;
  633. } __attribute__ ((packed));
  634. #define MAX_WUFF_NUM 8
  635. #define LAN9500_WUFF_NUM 4
  636. #define LAN9500A_WUFF_NUM 8
  637. typedef struct _WAKEUP_FILTER {
  638. u32 dwFilterMask[MAX_WUFF_NUM*4];
  639. u32 dwCommad[MAX_WUFF_NUM/4];
  640. u32 dwOffset[MAX_WUFF_NUM/4];
  641. u32 dwCRC[MAX_WUFF_NUM/2];
  642. } WAKEUP_FILTER, *PWAKEUP_FILTER;
  643. static struct {
  644. const char str[ETH_GSTRING_LEN];
  645. } ethtool_stats_keys[] = {
  646. { "rx_packets"},
  647. { "tx_packets"},
  648. { "rx_bytes"},
  649. { "tx_bytes"},
  650. { "rx_errors"},
  651. { "tx_errors"},
  652. { "tx_dropped"},
  653. { "rx_no_buffer_count"},
  654. { "rx_length_errors"},
  655. { "rx_over_errors"},
  656. { "rx_crc_errors"},
  657. { "rx_frame_errors"},
  658. { "RxGoodFrames"},
  659. { "RxCrcErrors"},
  660. { "RxRuntFrameErrors"},
  661. { "RxAlignmentErrors"},
  662. { "RxFrameTooLongError"},
  663. { "RxLaterCollisionError"},
  664. { "RxBadFrames"},
  665. { "RxFifoDroppedFrames"},
  666. { "TxGoodFrames"},
  667. { "TxPauseFrames"},
  668. { "TxSingleCollisions"},
  669. { "TxMultipleCollisions"},
  670. { "TxExcessiveCollisionErrors"},
  671. { "TxLateCollisionErrors"},
  672. { "TxBufferUnderrunErrors"},
  673. { "TxExcessiveDeferralErrors"},
  674. { "TxCarrierErrors"},
  675. { "TxBadFrames"},
  676. };
  677. typedef struct _ADAPTER_DATA {
  678. u32 dwIdRev;
  679. u32 dwPhyAddress;
  680. u32 dwPhyId;
  681. u32 dwFpgaRev;
  682. u32 macAddrHi16; //Mac address high 16 bits
  683. u32 MmacAddrLo32; //Mac address Low 32 bits
  684. BOOLEAN internalPhy;
  685. BOOLEAN UseScatterGather;
  686. BOOLEAN UseTxCsum;
  687. BOOLEAN UseRxCsum;
  688. BOOLEAN LanInitialized;
  689. BYTE bPhyModel;
  690. BYTE bPhyRev;
  691. u32 dwLinkSpeed;
  692. u32 dwLinkSettings;
  693. u32 dwSavedLinkSettings;
  694. struct semaphore phy_mutex; // Mutex for PHY access
  695. struct semaphore eeprom_mutex; //Mutex for eeprom access
  696. struct semaphore internal_ram_mutex; //Mutex for internal ram operation
  697. struct semaphore RxFilterLock;
  698. u16 wLastADV;
  699. u16 wLastADVatRestart;
  700. spinlock_t TxQueueLock;
  701. BOOLEAN TxInitialized;
  702. u32 dwTxQueueDisableMask;
  703. BOOLEAN TxQueueDisabled;
  704. u32 WolWakeupOpts;
  705. u32 wakeupOptsBackup;
  706. u32 dwWUFF[20];
  707. /* for Rx Multicast work around */
  708. volatile u32 HashLo;
  709. volatile u32 HashHi;
  710. volatile BOOLEAN MulticastUpdatePending;
  711. volatile u32 set_bits_mask;
  712. volatile u32 clear_bits_mask;
  713. u32 LinkLedOnGpio; //Gpio port number for link led
  714. u32 LinkLedOnGpioPolarity; //Gpio Output polarity
  715. u32 LinkActLedCfg; //
  716. u32 LinkLedOnGpioBufType;
  717. u32 dynamicSuspendPHYEvent; //Store PHY interrupt source for dynamic suspend
  718. u32 systemSuspendPHYEvent; //Store PHY interrupt source for system suspend
  719. u16 eepromSize;
  720. BOOLEAN eepromContentValid;
  721. // Count of transmit errors & other stats.
  722. u64 TxGoodFrames;
  723. u32 TxPauseFrames;
  724. u32 TxSingleCollisions;
  725. u32 TxMultipleCollisions;
  726. u32 TxExcessiveCollisionErrors;
  727. u32 TxLateCollisionErrors;
  728. u32 TxBufferUnderrunErrors;
  729. u32 TxExcessiveDeferralErrors;
  730. u32 TxCarrierErrors;
  731. u32 TxBadFrames;
  732. u32 EeeTxLpiTransitions;
  733. u32 EeeTxLpiTime;
  734. // Count of receive errors
  735. u64 RxGoodFrames;
  736. u32 RxCrcErrors;
  737. u32 RxRuntFrameErrors;
  738. u32 RxAlignmentErrors;
  739. u32 RxFrameTooLongError;
  740. u32 RxLaterCollisionError;
  741. u32 RxBadFrames;
  742. u32 RxFifoDroppedFrames;
  743. u32 EeeRxLpiTransitions;
  744. u32 EeeRxLpiTime;
  745. SMSC9500_RX_STATS rx_statistics;
  746. SMSC9500_TX_STATS tx_statistics;
  747. } ADAPTER_DATA, *PADAPTER_DATA;
  748. typedef struct _MAC_ADDR_IN_RAM{
  749. u32 signature;
  750. u32 MacAddrL;
  751. u32 MacAddrH;
  752. u16 crc;
  753. u16 crcComplement;
  754. }MAC_ADDR_IN_RAM;
  755. enum{
  756. RAMSEL_FCT,
  757. RAMSEL_EEPROM,
  758. RAMSEL_TXTLI,
  759. RAMSEL_RXTLI
  760. };
  761. #ifndef min
  762. #define min(_a, _b) (((_a) < (_b)) ? (_a) : (_b))
  763. #endif
  764. #ifndef max
  765. #define max(_a, _b) (((_a) > (_b)) ? (_a) : (_b))
  766. #endif
  767. #define BCAST_LEN 6
  768. #define MCAST_LEN 3
  769. #define ARP_LEN 2
  770. #endif // _LAN9500_H