smsc95xx.h 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353
  1. /* SPDX-License-Identifier: GPL-2.0-or-later */
  2. /***************************************************************************
  3. *
  4. * Copyright (C) 2007-2008 SMSC
  5. *
  6. *****************************************************************************/
  7. #ifndef _SMSC95XX_H
  8. #define _SMSC95XX_H
  9. /* Tx command words */
  10. #define TX_CMD_A_DATA_OFFSET_ (0x001F0000) /* Data Start Offset */
  11. #define TX_CMD_A_FIRST_SEG_ (0x00002000) /* First Segment */
  12. #define TX_CMD_A_LAST_SEG_ (0x00001000) /* Last Segment */
  13. #define TX_CMD_A_BUF_SIZE_ (0x000007FF) /* Buffer Size */
  14. #define TX_CMD_B_CSUM_ENABLE (0x00004000) /* TX Checksum Enable */
  15. #define TX_CMD_B_ADD_CRC_DIS_ (0x00002000) /* Add CRC Disable */
  16. #define TX_CMD_B_DIS_PADDING_ (0x00001000) /* Disable Frame Padding */
  17. #define TX_CMD_B_FRAME_LENGTH_ (0x000007FF) /* Frame Length (bytes) */
  18. /* Rx status word */
  19. #define RX_STS_FF_ (0x40000000) /* Filter Fail */
  20. #define RX_STS_FL_ (0x3FFF0000) /* Frame Length */
  21. #define RX_STS_ES_ (0x00008000) /* Error Summary */
  22. #define RX_STS_BF_ (0x00002000) /* Broadcast Frame */
  23. #define RX_STS_LE_ (0x00001000) /* Length Error */
  24. #define RX_STS_RF_ (0x00000800) /* Runt Frame */
  25. #define RX_STS_MF_ (0x00000400) /* Multicast Frame */
  26. #define RX_STS_TL_ (0x00000080) /* Frame too long */
  27. #define RX_STS_CS_ (0x00000040) /* Collision Seen */
  28. #define RX_STS_FT_ (0x00000020) /* Frame Type */
  29. #define RX_STS_RW_ (0x00000010) /* Receive Watchdog */
  30. #define RX_STS_ME_ (0x00000008) /* MII Error */
  31. #define RX_STS_DB_ (0x00000004) /* Dribbling */
  32. #define RX_STS_CRC_ (0x00000002) /* CRC Error */
  33. /* SCSRs - System Control and Status Registers */
  34. /* Device ID and Revision Register */
  35. #define ID_REV (0x00)
  36. #define ID_REV_CHIP_ID_MASK_ (0xFFFF0000)
  37. #define ID_REV_CHIP_REV_MASK_ (0x0000FFFF)
  38. #define ID_REV_CHIP_ID_9500_ (0x9500)
  39. #define ID_REV_CHIP_ID_9500A_ (0x9E00)
  40. #define ID_REV_CHIP_ID_9512_ (0xEC00)
  41. #define ID_REV_CHIP_ID_9530_ (0x9530)
  42. #define ID_REV_CHIP_ID_89530_ (0x9E08)
  43. #define ID_REV_CHIP_ID_9730_ (0x9730)
  44. /* Interrupt Status Register */
  45. #define INT_STS (0x08)
  46. #define INT_STS_MAC_RTO_ (0x00040000) /* MAC Reset Time Out */
  47. #define INT_STS_TX_STOP_ (0x00020000) /* TX Stopped */
  48. #define INT_STS_RX_STOP_ (0x00010000) /* RX Stopped */
  49. #define INT_STS_PHY_INT_ (0x00008000) /* PHY Interrupt */
  50. #define INT_STS_TXE_ (0x00004000) /* Transmitter Error */
  51. #define INT_STS_TDFU_ (0x00002000) /* TX Data FIFO Underrun */
  52. #define INT_STS_TDFO_ (0x00001000) /* TX Data FIFO Overrun */
  53. #define INT_STS_RXDF_ (0x00000800) /* RX Dropped Frame */
  54. #define INT_STS_GPIOS_ (0x000007FF) /* GPIOs Interrupts */
  55. #define INT_STS_CLEAR_ALL_ (0xFFFFFFFF)
  56. /* Receive Configuration Register */
  57. #define RX_CFG (0x0C)
  58. #define RX_FIFO_FLUSH_ (0x00000001) /* Receive FIFO Flush */
  59. /* Transmit Configuration Register */
  60. #define TX_CFG (0x10)
  61. #define TX_CFG_ON_ (0x00000004) /* Transmitter Enable */
  62. #define TX_CFG_STOP_ (0x00000002) /* Stop Transmitter */
  63. #define TX_CFG_FIFO_FLUSH_ (0x00000001) /* Transmit FIFO Flush */
  64. /* Hardware Configuration Register */
  65. #define HW_CFG (0x14)
  66. #define HW_CFG_BIR_ (0x00001000) /* Bulk In Empty Response */
  67. #define HW_CFG_LEDB_ (0x00000800) /* Activity LED 80ms Bypass */
  68. #define HW_CFG_RXDOFF_ (0x00000600) /* RX Data Offset */
  69. #define HW_CFG_SBP_ (0x00000100) /* Stall Bulk Out Pipe Dis. */
  70. #define HW_CFG_IME_ (0x00000080) /* Internal MII Visi. Enable */
  71. #define HW_CFG_DRP_ (0x00000040) /* Discard Errored RX Frame */
  72. #define HW_CFG_MEF_ (0x00000020) /* Mult. ETH Frames/USB pkt */
  73. #define HW_CFG_ETC_ (0x00000010) /* EEPROM Timeout Control */
  74. #define HW_CFG_LRST_ (0x00000008) /* Soft Lite Reset */
  75. #define HW_CFG_PSEL_ (0x00000004) /* External PHY Select */
  76. #define HW_CFG_BCE_ (0x00000002) /* Burst Cap Enable */
  77. #define HW_CFG_SRST_ (0x00000001) /* Soft Reset */
  78. /* Receive FIFO Information Register */
  79. #define RX_FIFO_INF (0x18)
  80. #define RX_FIFO_INF_USED_ (0x0000FFFF) /* RX Data FIFO Used Space */
  81. /* Transmit FIFO Information Register */
  82. #define TX_FIFO_INF (0x1C)
  83. #define TX_FIFO_INF_FREE_ (0x0000FFFF) /* TX Data FIFO Free Space */
  84. /* Power Management Control Register */
  85. #define PM_CTRL (0x20)
  86. #define PM_CTL_RES_CLR_WKP_STS (0x00000200) /* Resume Clears Wakeup STS */
  87. #define PM_CTL_RES_CLR_WKP_EN (0x00000100) /* Resume Clears Wkp Enables */
  88. #define PM_CTL_DEV_RDY_ (0x00000080) /* Device Ready */
  89. #define PM_CTL_SUS_MODE_ (0x00000060) /* Suspend Mode */
  90. #define PM_CTL_SUS_MODE_0 (0x00000000)
  91. #define PM_CTL_SUS_MODE_1 (0x00000020)
  92. #define PM_CTL_SUS_MODE_2 (0x00000040)
  93. #define PM_CTL_SUS_MODE_3 (0x00000060)
  94. #define PM_CTL_PHY_RST_ (0x00000010) /* PHY Reset */
  95. #define PM_CTL_WOL_EN_ (0x00000008) /* Wake On Lan Enable */
  96. #define PM_CTL_ED_EN_ (0x00000004) /* Energy Detect Enable */
  97. #define PM_CTL_WUPS_ (0x00000003) /* Wake Up Status */
  98. #define PM_CTL_WUPS_NO_ (0x00000000) /* No Wake Up Event Detected */
  99. #define PM_CTL_WUPS_ED_ (0x00000001) /* Energy Detect */
  100. #define PM_CTL_WUPS_WOL_ (0x00000002) /* Wake On Lan */
  101. #define PM_CTL_WUPS_MULTI_ (0x00000003) /* Multiple Events Occurred */
  102. /* LED General Purpose IO Configuration Register */
  103. #define LED_GPIO_CFG (0x24)
  104. #define LED_GPIO_CFG_SPD_LED (0x01000000) /* GPIOz as Speed LED */
  105. #define LED_GPIO_CFG_LNK_LED (0x00100000) /* GPIOy as Link LED */
  106. #define LED_GPIO_CFG_FDX_LED (0x00010000) /* GPIOx as Full Duplex LED */
  107. /* General Purpose IO Configuration Register */
  108. #define GPIO_CFG (0x28)
  109. /* Automatic Flow Control Configuration Register */
  110. #define AFC_CFG (0x2C)
  111. #define AFC_CFG_HI_ (0x00FF0000) /* Auto Flow Ctrl High Level */
  112. #define AFC_CFG_LO_ (0x0000FF00) /* Auto Flow Ctrl Low Level */
  113. #define AFC_CFG_BACK_DUR_ (0x000000F0) /* Back Pressure Duration */
  114. #define AFC_CFG_FC_MULT_ (0x00000008) /* Flow Ctrl on Mcast Frame */
  115. #define AFC_CFG_FC_BRD_ (0x00000004) /* Flow Ctrl on Bcast Frame */
  116. #define AFC_CFG_FC_ADD_ (0x00000002) /* Flow Ctrl on Addr. Decode */
  117. #define AFC_CFG_FC_ANY_ (0x00000001) /* Flow Ctrl on Any Frame */
  118. /* Hi watermark = 15.5Kb (~10 mtu pkts) */
  119. /* low watermark = 3k (~2 mtu pkts) */
  120. /* backpressure duration = ~ 350us */
  121. /* Apply FC on any frame. */
  122. #define AFC_CFG_DEFAULT (0x00F830A1)
  123. /* EEPROM Command Register */
  124. #define E2P_CMD (0x30)
  125. #define E2P_CMD_BUSY_ (0x80000000) /* E2P Controller Busy */
  126. #define E2P_CMD_MASK_ (0x70000000) /* Command Mask (see below) */
  127. #define E2P_CMD_READ_ (0x00000000) /* Read Location */
  128. #define E2P_CMD_EWDS_ (0x10000000) /* Erase/Write Disable */
  129. #define E2P_CMD_EWEN_ (0x20000000) /* Erase/Write Enable */
  130. #define E2P_CMD_WRITE_ (0x30000000) /* Write Location */
  131. #define E2P_CMD_WRAL_ (0x40000000) /* Write All */
  132. #define E2P_CMD_ERASE_ (0x50000000) /* Erase Location */
  133. #define E2P_CMD_ERAL_ (0x60000000) /* Erase All */
  134. #define E2P_CMD_RELOAD_ (0x70000000) /* Data Reload */
  135. #define E2P_CMD_TIMEOUT_ (0x00000400) /* Set if no resp within 30ms */
  136. #define E2P_CMD_LOADED_ (0x00000200) /* Valid EEPROM found */
  137. #define E2P_CMD_ADDR_ (0x000001FF) /* Byte aligned address */
  138. #define MAX_EEPROM_SIZE (512)
  139. /* EEPROM Data Register */
  140. #define E2P_DATA (0x34)
  141. #define E2P_DATA_MASK_ (0x000000FF) /* EEPROM Data Mask */
  142. /* Burst Cap Register */
  143. #define BURST_CAP (0x38)
  144. #define BURST_CAP_MASK_ (0x000000FF) /* Max burst sent by the UTX */
  145. /* Configuration Straps Status Register */
  146. #define STRAP_STATUS (0x3C)
  147. #define STRAP_STATUS_PWR_SEL_ (0x00000020) /* Device self-powered */
  148. #define STRAP_STATUS_AMDIX_EN_ (0x00000010) /* Auto-MDIX Enabled */
  149. #define STRAP_STATUS_PORT_SWAP_ (0x00000008) /* USBD+/USBD- Swapped */
  150. #define STRAP_STATUS_EEP_SIZE_ (0x00000004) /* EEPROM Size */
  151. #define STRAP_STATUS_RMT_WKP_ (0x00000002) /* Remote Wkp supported */
  152. #define STRAP_STATUS_EEP_DISABLE_ (0x00000001) /* EEPROM Disabled */
  153. /* Data Port Select Register */
  154. #define DP_SEL (0x40)
  155. /* Data Port Command Register */
  156. #define DP_CMD (0x44)
  157. /* Data Port Address Register */
  158. #define DP_ADDR (0x48)
  159. /* Data Port Data 0 Register */
  160. #define DP_DATA0 (0x4C)
  161. /* Data Port Data 1 Register */
  162. #define DP_DATA1 (0x50)
  163. /* General Purpose IO Wake Enable and Polarity Register */
  164. #define GPIO_WAKE (0x64)
  165. /* Interrupt Endpoint Control Register */
  166. #define INT_EP_CTL (0x68)
  167. #define INT_EP_CTL_INTEP_ (0x80000000) /* Always TX Interrupt PKT */
  168. #define INT_EP_CTL_MAC_RTO_ (0x00080000) /* MAC Reset Time Out */
  169. #define INT_EP_CTL_RX_FIFO_ (0x00040000) /* RX FIFO Has Frame */
  170. #define INT_EP_CTL_TX_STOP_ (0x00020000) /* TX Stopped */
  171. #define INT_EP_CTL_RX_STOP_ (0x00010000) /* RX Stopped */
  172. #define INT_EP_CTL_PHY_INT_ (0x00008000) /* PHY Interrupt */
  173. #define INT_EP_CTL_TXE_ (0x00004000) /* TX Error */
  174. #define INT_EP_CTL_TDFU_ (0x00002000) /* TX Data FIFO Underrun */
  175. #define INT_EP_CTL_TDFO_ (0x00001000) /* TX Data FIFO Overrun */
  176. #define INT_EP_CTL_RXDF_ (0x00000800) /* RX Dropped Frame */
  177. #define INT_EP_CTL_GPIOS_ (0x000007FF) /* GPIOs Interrupt Enable */
  178. /* Bulk In Delay Register (units of 16.667ns, until ~1092µs) */
  179. #define BULK_IN_DLY (0x6C)
  180. /* MAC CSRs - MAC Control and Status Registers */
  181. /* MAC Control Register */
  182. #define MAC_CR (0x100)
  183. #define MAC_CR_RXALL_ (0x80000000) /* Receive All Mode */
  184. #define MAC_CR_RCVOWN_ (0x00800000) /* Disable Receive Own */
  185. #define MAC_CR_LOOPBK_ (0x00200000) /* Loopback Operation Mode */
  186. #define MAC_CR_FDPX_ (0x00100000) /* Full Duplex Mode */
  187. #define MAC_CR_MCPAS_ (0x00080000) /* Pass All Multicast */
  188. #define MAC_CR_PRMS_ (0x00040000) /* Promiscuous Mode */
  189. #define MAC_CR_INVFILT_ (0x00020000) /* Inverse Filtering */
  190. #define MAC_CR_PASSBAD_ (0x00010000) /* Pass Bad Frames */
  191. #define MAC_CR_HFILT_ (0x00008000) /* Hash Only Filtering Mode */
  192. #define MAC_CR_HPFILT_ (0x00002000) /* Hash/Perfect Filt. Mode */
  193. #define MAC_CR_LCOLL_ (0x00001000) /* Late Collision Control */
  194. #define MAC_CR_BCAST_ (0x00000800) /* Disable Broadcast Frames */
  195. #define MAC_CR_DISRTY_ (0x00000400) /* Disable Retry */
  196. #define MAC_CR_PADSTR_ (0x00000100) /* Automatic Pad Stripping */
  197. #define MAC_CR_BOLMT_MASK (0x000000C0) /* BackOff Limit */
  198. #define MAC_CR_DFCHK_ (0x00000020) /* Deferral Check */
  199. #define MAC_CR_TXEN_ (0x00000008) /* Transmitter Enable */
  200. #define MAC_CR_RXEN_ (0x00000004) /* Receiver Enable */
  201. /* MAC Address High Register */
  202. #define ADDRH (0x104)
  203. /* MAC Address Low Register */
  204. #define ADDRL (0x108)
  205. /* Multicast Hash Table High Register */
  206. #define HASHH (0x10C)
  207. /* Multicast Hash Table Low Register */
  208. #define HASHL (0x110)
  209. /* MII Access Register */
  210. #define MII_ADDR (0x114)
  211. #define MII_WRITE_ (0x02)
  212. #define MII_BUSY_ (0x01)
  213. #define MII_READ_ (0x00) /* ~of MII Write bit */
  214. /* MII Data Register */
  215. #define MII_DATA (0x118)
  216. /* Flow Control Register */
  217. #define FLOW (0x11C)
  218. #define FLOW_FCPT_ (0xFFFF0000) /* Pause Time */
  219. #define FLOW_FCPASS_ (0x00000004) /* Pass Control Frames */
  220. #define FLOW_FCEN_ (0x00000002) /* Flow Control Enable */
  221. #define FLOW_FCBSY_ (0x00000001) /* Flow Control Busy */
  222. /* VLAN1 Tag Register */
  223. #define VLAN1 (0x120)
  224. /* VLAN2 Tag Register */
  225. #define VLAN2 (0x124)
  226. /* Wake Up Frame Filter Register */
  227. #define WUFF (0x128)
  228. #define LAN9500_WUFF_NUM (4)
  229. #define LAN9500A_WUFF_NUM (8)
  230. /* Wake Up Control and Status Register */
  231. #define WUCSR (0x12C)
  232. #define WUCSR_WFF_PTR_RST_ (0x80000000) /* WFrame Filter Pointer Rst */
  233. #define WUCSR_GUE_ (0x00000200) /* Global Unicast Enable */
  234. #define WUCSR_WUFR_ (0x00000040) /* Wakeup Frame Received */
  235. #define WUCSR_MPR_ (0x00000020) /* Magic Packet Received */
  236. #define WUCSR_WAKE_EN_ (0x00000004) /* Wakeup Frame Enable */
  237. #define WUCSR_MPEN_ (0x00000002) /* Magic Packet Enable */
  238. /* Checksum Offload Engine Control Register */
  239. #define COE_CR (0x130)
  240. #define Tx_COE_EN_ (0x00010000) /* TX Csum Offload Enable */
  241. #define Rx_COE_MODE_ (0x00000002) /* RX Csum Offload Mode */
  242. #define Rx_COE_EN_ (0x00000001) /* RX Csum Offload Enable */
  243. /* Vendor-specific PHY Definitions (via MII access) */
  244. /* EDPD NLP / crossover time configuration (LAN9500A only) */
  245. #define PHY_EDPD_CONFIG (16)
  246. #define PHY_EDPD_CONFIG_TX_NLP_EN_ ((u16)0x8000)
  247. #define PHY_EDPD_CONFIG_TX_NLP_1000_ ((u16)0x0000)
  248. #define PHY_EDPD_CONFIG_TX_NLP_768_ ((u16)0x2000)
  249. #define PHY_EDPD_CONFIG_TX_NLP_512_ ((u16)0x4000)
  250. #define PHY_EDPD_CONFIG_TX_NLP_256_ ((u16)0x6000)
  251. #define PHY_EDPD_CONFIG_RX_1_NLP_ ((u16)0x1000)
  252. #define PHY_EDPD_CONFIG_RX_NLP_64_ ((u16)0x0000)
  253. #define PHY_EDPD_CONFIG_RX_NLP_256_ ((u16)0x0400)
  254. #define PHY_EDPD_CONFIG_RX_NLP_512_ ((u16)0x0800)
  255. #define PHY_EDPD_CONFIG_RX_NLP_1000_ ((u16)0x0C00)
  256. #define PHY_EDPD_CONFIG_EXT_CROSSOVER_ ((u16)0x0001)
  257. #define PHY_EDPD_CONFIG_DEFAULT (PHY_EDPD_CONFIG_TX_NLP_EN_ | \
  258. PHY_EDPD_CONFIG_TX_NLP_768_ | \
  259. PHY_EDPD_CONFIG_RX_1_NLP_)
  260. /* Mode Control/Status Register */
  261. #define PHY_MODE_CTRL_STS (17)
  262. #define MODE_CTRL_STS_EDPWRDOWN_ ((u16)0x2000)
  263. #define MODE_CTRL_STS_ENERGYON_ ((u16)0x0002)
  264. /* Control/Status Indication Register */
  265. #define SPECIAL_CTRL_STS (27)
  266. #define SPECIAL_CTRL_STS_OVRRD_AMDIX_ ((u16)0x8000)
  267. #define SPECIAL_CTRL_STS_AMDIX_ENABLE_ ((u16)0x4000)
  268. #define SPECIAL_CTRL_STS_AMDIX_STATE_ ((u16)0x2000)
  269. /* Interrupt Source Register */
  270. #define PHY_INT_SRC (29)
  271. #define PHY_INT_SRC_ENERGY_ON_ ((u16)0x0080)
  272. #define PHY_INT_SRC_ANEG_COMP_ ((u16)0x0040)
  273. #define PHY_INT_SRC_REMOTE_FAULT_ ((u16)0x0020)
  274. #define PHY_INT_SRC_LINK_DOWN_ ((u16)0x0010)
  275. /* Interrupt Mask Register */
  276. #define PHY_INT_MASK (30)
  277. #define PHY_INT_MASK_ENERGY_ON_ ((u16)0x0080)
  278. #define PHY_INT_MASK_ANEG_COMP_ ((u16)0x0040)
  279. #define PHY_INT_MASK_REMOTE_FAULT_ ((u16)0x0020)
  280. #define PHY_INT_MASK_LINK_DOWN_ ((u16)0x0010)
  281. #define PHY_INT_MASK_DEFAULT_ (PHY_INT_MASK_ANEG_COMP_ | \
  282. PHY_INT_MASK_LINK_DOWN_)
  283. /* PHY Special Control/Status Register */
  284. #define PHY_SPECIAL (31)
  285. #define PHY_SPECIAL_SPD_ ((u16)0x001C)
  286. #define PHY_SPECIAL_SPD_10HALF_ ((u16)0x0004)
  287. #define PHY_SPECIAL_SPD_10FULL_ ((u16)0x0014)
  288. #define PHY_SPECIAL_SPD_100HALF_ ((u16)0x0008)
  289. #define PHY_SPECIAL_SPD_100FULL_ ((u16)0x0018)
  290. /* USB Vendor Requests */
  291. #define USB_VENDOR_REQUEST_WRITE_REGISTER 0xA0
  292. #define USB_VENDOR_REQUEST_READ_REGISTER 0xA1
  293. #define USB_VENDOR_REQUEST_GET_STATS 0xA2
  294. /* Interrupt Endpoint status word bitfields */
  295. #define INT_ENP_MAC_RTO_ ((u32)BIT(18)) /* MAC Reset Time Out */
  296. #define INT_ENP_TX_STOP_ ((u32)BIT(17)) /* TX Stopped */
  297. #define INT_ENP_RX_STOP_ ((u32)BIT(16)) /* RX Stopped */
  298. #define INT_ENP_PHY_INT_ ((u32)BIT(15)) /* PHY Interrupt */
  299. #define INT_ENP_TXE_ ((u32)BIT(14)) /* TX Error */
  300. #define INT_ENP_TDFU_ ((u32)BIT(13)) /* TX FIFO Underrun */
  301. #define INT_ENP_TDFO_ ((u32)BIT(12)) /* TX FIFO Overrun */
  302. #define INT_ENP_RXDF_ ((u32)BIT(11)) /* RX Dropped Frame */
  303. #endif /* _SMSC95XX_H */