asix.h 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596
  1. /*
  2. * Change Logs
  3. * Date Author Notes
  4. * 2022-04-17 aozima the first version for CherryUSB.
  5. */
  6. #ifndef __LINUX_USBNET_ASIX_H
  7. #define __LINUX_USBNET_ASIX_H
  8. // #define __BIG_ENDIAN_BITFIELD
  9. #define __LITTLE_ENDIAN_BITFIELD
  10. typedef uint8_t u8;
  11. typedef uint16_t u16;
  12. typedef uint32_t u32;
  13. #define KERNEL_VERSION(...) (0)
  14. #define LINUX_VERSION_CODE (1)
  15. /*
  16. * Turn on this flag if the implementation of your USB host controller
  17. * cannot handle non-double word aligned buffer.
  18. * When turn on this flag, driver will fixup egress packet aligned on double
  19. * word boundary before deliver to USB host controller. And will Disable the
  20. * function "skb_reserve (skb, NET_IP_ALIGN)" to retain the buffer aligned on
  21. * double word alignment for ingress packets.
  22. */
  23. #define AX_FORCE_BUFF_ALIGN 0
  24. //#define RX_SKB_COPY
  25. #define AX_MONITOR_MODE 0x01
  26. #define AX_MONITOR_LINK 0x02
  27. #define AX_MONITOR_MAGIC 0x04
  28. #define AX_MONITOR_HSFS 0x10
  29. /* AX88172 Medium Status Register values */
  30. #define AX_MEDIUM_FULL_DUPLEX 0x02
  31. #define AX_MEDIUM_TX_ABORT_ALLOW 0x04
  32. #define AX_MEDIUM_FLOW_CONTROL_EN 0x10
  33. #define AX_MCAST_FILTER_SIZE 8
  34. #define AX_MAX_MCAST 64
  35. #define AX_EEPROM_LEN 0x40
  36. #define AX_SWRESET_CLEAR 0x00
  37. #define AX_SWRESET_RR 0x01
  38. #define AX_SWRESET_RT 0x02
  39. #define AX_SWRESET_PRTE 0x04
  40. #define AX_SWRESET_PRL 0x08
  41. #define AX_SWRESET_BZ 0x10
  42. #define AX_SWRESET_IPRL 0x20
  43. #define AX_SWRESET_IPPD 0x40
  44. #define AX_SWRESET_IPOSC 0x0080
  45. #define AX_SWRESET_IPPSL_0 0x0100
  46. #define AX_SWRESET_IPPSL_1 0x0200
  47. #define AX_SWRESET_IPCOPS 0x0400
  48. #define AX_SWRESET_IPCOPSC 0x0800
  49. #define AX_SWRESET_AUTODETACH 0x1000
  50. #define AX_SWRESET_WOLLP 0x8000
  51. #define AX88772_IPG0_DEFAULT 0x15
  52. #define AX88772_IPG1_DEFAULT 0x0c
  53. #define AX88772_IPG2_DEFAULT 0x0E
  54. #define AX88772A_IPG0_DEFAULT 0x15
  55. #define AX88772A_IPG1_DEFAULT 0x16
  56. #define AX88772A_IPG2_DEFAULT 0x1A
  57. #define AX88772_MEDIUM_FULL_DUPLEX 0x0002
  58. #define AX88772_MEDIUM_RESERVED 0x0004
  59. #define AX88772_MEDIUM_RX_FC_ENABLE 0x0010
  60. #define AX88772_MEDIUM_TX_FC_ENABLE 0x0020
  61. #define AX88772_MEDIUM_PAUSE_FORMAT 0x0080
  62. #define AX88772_MEDIUM_RX_ENABLE 0x0100
  63. #define AX88772_MEDIUM_100MB 0x0200
  64. #define AX88772_MEDIUM_DEFAULT \
  65. (AX88772_MEDIUM_FULL_DUPLEX | AX88772_MEDIUM_RX_FC_ENABLE | \
  66. AX88772_MEDIUM_TX_FC_ENABLE | AX88772_MEDIUM_100MB | \
  67. AX88772_MEDIUM_RESERVED | AX88772_MEDIUM_RX_ENABLE)
  68. #define AX_CMD_SET_SW_MII 0x06
  69. #define AX_CMD_READ_MII_REG 0x07
  70. #define AX_CMD_WRITE_MII_REG 0x08
  71. #define AX_CMD_READ_STATMNGSTS_REG 0x09
  72. #define AX_HOST_EN 0x01
  73. #define AX_CMD_SET_HW_MII 0x0a
  74. #define AX_CMD_READ_EEPROM 0x0b
  75. #define AX_CMD_WRITE_EEPROM 0x0c
  76. #define AX_CMD_WRITE_EEPROM_EN 0x0d
  77. #define AX_CMD_WRITE_EEPROM_DIS 0x0e
  78. #define AX_CMD_WRITE_RX_CTL 0x10
  79. #define AX_CMD_READ_IPG012 0x11
  80. #define AX_CMD_WRITE_IPG0 0x12
  81. #define AX_CMD_WRITE_IPG1 0x13
  82. #define AX_CMD_WRITE_IPG2 0x14
  83. #define AX_CMD_WRITE_MULTI_FILTER 0x16
  84. #define AX_CMD_READ_NODE_ID 0x17
  85. #define AX_CMD_READ_PHY_ID 0x19
  86. #define AX_CMD_READ_MEDIUM_MODE 0x1a
  87. #define AX_CMD_WRITE_MEDIUM_MODE 0x1b
  88. #define AX_CMD_READ_MONITOR_MODE 0x1c
  89. #define AX_CMD_WRITE_MONITOR_MODE 0x1d
  90. #define AX_CMD_WRITE_GPIOS 0x1f
  91. #define AX_CMD_SW_RESET 0x20
  92. #define AX_CMD_SW_PHY_STATUS 0x21
  93. #define AX_CMD_SW_PHY_SELECT 0x22
  94. #define AX_PHYSEL_PSEL (1 << 0)
  95. #define AX_PHYSEL_ASEL (1 << 1)
  96. #define AX_PHYSEL_SSMII (0 << 2)
  97. #define AX_PHYSEL_SSRMII (1 << 2)
  98. #define AX_PHYSEL_SSRRMII (3 << 2)
  99. #define AX_PHYSEL_SSEN (1 << 4)
  100. #define AX88772_CMD_READ_NODE_ID 0x13
  101. #define AX88772_CMD_WRITE_NODE_ID 0x14
  102. #define AX_CMD_READ_WKFARY 0x23
  103. #define AX_CMD_WRITE_WKFARY 0x24
  104. #define AX_CMD_READ_RXCOE_CTL 0x2b
  105. #define AX_CMD_WRITE_RXCOE_CTL 0x2c
  106. #define AX_CMD_READ_TXCOE_CTL 0x2d
  107. #define AX_CMD_WRITE_TXCOE_CTL 0x2e
  108. #define REG_LENGTH 2
  109. #define PHY_ID_MASK 0x1f
  110. #define AX_RXCOE_IPCE 0x0001
  111. #define AX_RXCOE_IPVE 0x0002
  112. #define AX_RXCOE_V6VE 0x0004
  113. #define AX_RXCOE_TCPE 0x0008
  114. #define AX_RXCOE_UDPE 0x0010
  115. #define AX_RXCOE_ICMP 0x0020
  116. #define AX_RXCOE_IGMP 0x0040
  117. #define AX_RXCOE_ICV6 0x0080
  118. #define AX_RXCOE_TCPV6 0x0100
  119. #define AX_RXCOE_UDPV6 0x0200
  120. #define AX_RXCOE_ICMV6 0x0400
  121. #define AX_RXCOE_IGMV6 0x0800
  122. #define AX_RXCOE_ICV6V6 0x1000
  123. #define AX_RXCOE_FOPC 0x8000
  124. #if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 22)
  125. #define AX_RXCOE_DEF_CSUM (AX_RXCOE_IPCE | AX_RXCOE_IPVE | \
  126. AX_RXCOE_V6VE | AX_RXCOE_TCPE | \
  127. AX_RXCOE_UDPE | AX_RXCOE_ICV6 | \
  128. AX_RXCOE_TCPV6 | AX_RXCOE_UDPV6)
  129. #else
  130. #define AX_RXCOE_DEF_CSUM (AX_RXCOE_IPCE | AX_RXCOE_IPVE | \
  131. AX_RXCOE_TCPE | AX_RXCOE_UDPE)
  132. #endif
  133. #define AX_RXCOE_64TE 0x0100
  134. #define AX_RXCOE_PPPOE 0x0200
  135. #define AX_RXCOE_RPCE 0x8000
  136. #define AX_TXCOE_IP 0x0001
  137. #define AX_TXCOE_TCP 0x0002
  138. #define AX_TXCOE_UDP 0x0004
  139. #define AX_TXCOE_ICMP 0x0008
  140. #define AX_TXCOE_IGMP 0x0010
  141. #define AX_TXCOE_ICV6 0x0020
  142. #define AX_TXCOE_TCPV6 0x0100
  143. #define AX_TXCOE_UDPV6 0x0200
  144. #define AX_TXCOE_ICMV6 0x0400
  145. #define AX_TXCOE_IGMV6 0x0800
  146. #define AX_TXCOE_ICV6V6 0x1000
  147. #if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 22)
  148. #define AX_TXCOE_DEF_CSUM (AX_TXCOE_TCP | AX_TXCOE_UDP | \
  149. AX_TXCOE_TCPV6 | AX_TXCOE_UDPV6)
  150. #else
  151. #define AX_TXCOE_DEF_CSUM (AX_TXCOE_TCP | AX_TXCOE_UDP)
  152. #endif
  153. #define AX_TXCOE_64TE 0x0001
  154. #define AX_TXCOE_PPPE 0x0002
  155. #define AX88772B_MAX_BULKIN_2K 0
  156. #define AX88772B_MAX_BULKIN_4K 1
  157. #define AX88772B_MAX_BULKIN_6K 2
  158. #define AX88772B_MAX_BULKIN_8K 3
  159. #define AX88772B_MAX_BULKIN_16K 4
  160. #define AX88772B_MAX_BULKIN_20K 5
  161. #define AX88772B_MAX_BULKIN_24K 6
  162. #define AX88772B_MAX_BULKIN_32K 7
  163. struct {unsigned short size, byte_cnt, threshold; } AX88772B_BULKIN_SIZE[] = {
  164. /* 2k */
  165. {2048, 0x8000, 0x8001},
  166. /* 4k */
  167. {4096, 0x8100, 0x8147},
  168. /* 6k */
  169. {6144, 0x8200, 0x81EB},
  170. /* 8k */
  171. {8192, 0x8300, 0x83D7},
  172. /* 16 */
  173. {16384, 0x8400, 0x851E},
  174. /* 20k */
  175. {20480, 0x8500, 0x8666},
  176. /* 24k */
  177. {24576, 0x8600, 0x87AE},
  178. /* 32k */
  179. {32768, 0x8700, 0x8A3D},
  180. };
  181. #define AX_RX_CTL_RH1M 0x0100 /* Enable RX-Header mode 0 */
  182. #define AX_RX_CTL_RH2M 0x0200 /* Enable IP header in receive buffer aligned on 32-bit aligment */
  183. #define AX_RX_CTL_RH3M 0x0400 /* checksum value in rx header 3 */
  184. #define AX_RX_HEADER_DEFAULT (AX_RX_CTL_RH1M | AX_RX_CTL_RH2M)
  185. #define AX_RX_CTL_MFB 0x0300 /* Maximum Frame size 16384bytes */
  186. #define AX_RX_CTL_START 0x0080 /* Ethernet MAC start */
  187. #define AX_RX_CTL_AP 0x0020 /* Accept physcial address from Multicast array */
  188. #define AX_RX_CTL_AM 0x0010
  189. #define AX_RX_CTL_AB 0x0008 /* Accetp Brocadcast frames*/
  190. #define AX_RX_CTL_SEP 0x0004 /* Save error packets */
  191. #define AX_RX_CTL_AMALL 0x0002 /* Accetp all multicast frames */
  192. #define AX_RX_CTL_PRO 0x0001 /* Promiscuous Mode */
  193. #define AX_RX_CTL_STOP 0x0000 /* Stop MAC */
  194. #define AX_MONITOR_MODE 0x01
  195. #define AX_MONITOR_LINK 0x02
  196. #define AX_MONITOR_MAGIC 0x04
  197. #define AX_MONITOR_HSFS 0x10
  198. #define AX_MCAST_FILTER_SIZE 8
  199. #define AX_MAX_MCAST 64
  200. #define AX_INTERRUPT_BUFSIZE 8
  201. #define AX_EEPROM_LEN 0x40
  202. #define AX_EEPROM_MAGIC 0xdeadbeef
  203. #define EEPROMMASK 0x7f
  204. /* GPIO REGISTER */
  205. #define AXGPIOS_GPO0EN 0X01 /* 1 << 0 */
  206. #define AXGPIOS_GPO0 0X02 /* 1 << 1 */
  207. #define AXGPIOS_GPO1EN 0X04 /* 1 << 2 */
  208. #define AXGPIOS_GPO1 0X08 /* 1 << 3 */
  209. #define AXGPIOS_GPO2EN 0X10 /* 1 << 4 */
  210. #define AXGPIOS_GPO2 0X20 /* 1 << 5 */
  211. #define AXGPIOS_RSE 0X80 /* 1 << 7 */
  212. /* TX-header format */
  213. #define AX_TX_HDR_CPHI 0x4000
  214. #define AX_TX_HDR_DICF 0x8000
  215. /* GMII register definitions */
  216. #define GMII_PHY_CONTROL 0x00 /* control reg */
  217. #define GMII_PHY_STATUS 0x01 /* status reg */
  218. #define GMII_PHY_OUI 0x02 /* most of the OUI bits */
  219. #define GMII_PHY_MODEL 0x03 /* model/rev bits, and rest of OUI */
  220. #define GMII_PHY_ANAR 0x04 /* AN advertisement reg */
  221. #define GMII_PHY_ANLPAR 0x05 /* AN Link Partner */
  222. #define GMII_PHY_ANER 0x06 /* AN expansion reg */
  223. #define GMII_PHY_1000BT_CONTROL 0x09 /* control reg for 1000BT */
  224. #define GMII_PHY_1000BT_STATUS 0x0A /* status reg for 1000BT */
  225. /* Bit definitions: GMII Control */
  226. #define GMII_CONTROL_RESET 0x8000 /* reset bit in control reg */
  227. #define GMII_CONTROL_LOOPBACK 0x4000 /* loopback bit in control reg */
  228. #define GMII_CONTROL_10MB 0x0000 /* 10 Mbit */
  229. #define GMII_CONTROL_100MB 0x2000 /* 100Mbit */
  230. #define GMII_CONTROL_1000MB 0x0040 /* 1000Mbit */
  231. #define GMII_CONTROL_SPEED_BITS 0x2040 /* speed bit mask */
  232. #define GMII_CONTROL_ENABLE_AUTO 0x1000 /* autonegotiate enable */
  233. #define GMII_CONTROL_POWER_DOWN 0x0800
  234. #define GMII_CONTROL_ISOLATE 0x0400 /* islolate bit */
  235. #define GMII_CONTROL_START_AUTO 0x0200 /* restart autonegotiate */
  236. #define GMII_CONTROL_FULL_DUPLEX 0x0100
  237. /* Bit definitions: GMII Status */
  238. #define GMII_STATUS_100MB_MASK 0xE000 /* any of these indicate 100 Mbit */
  239. #define GMII_STATUS_10MB_MASK 0x1800 /* either of these indicate 10 Mbit */
  240. #define GMII_STATUS_AUTO_DONE 0x0020 /* auto negotiation complete */
  241. #define GMII_STATUS_AUTO 0x0008 /* auto negotiation is available */
  242. #define GMII_STATUS_LINK_UP 0x0004 /* link status bit */
  243. #define GMII_STATUS_EXTENDED 0x0001 /* extended regs exist */
  244. #define GMII_STATUS_100T4 0x8000 /* capable of 100BT4 */
  245. #define GMII_STATUS_100TXFD 0x4000 /* capable of 100BTX full duplex */
  246. #define GMII_STATUS_100TX 0x2000 /* capable of 100BTX */
  247. #define GMII_STATUS_10TFD 0x1000 /* capable of 10BT full duplex */
  248. #define GMII_STATUS_10T 0x0800 /* capable of 10BT */
  249. /* Bit definitions: Auto-Negotiation Advertisement */
  250. #define GMII_ANAR_ASYM_PAUSE 0x0800 /* support asymetric pause */
  251. #define GMII_ANAR_PAUSE 0x0400 /* support pause packets */
  252. #define GMII_ANAR_100T4 0x0200 /* support 100BT4 */
  253. #define GMII_ANAR_100TXFD 0x0100 /* support 100BTX full duplex */
  254. #define GMII_ANAR_100TX 0x0080 /* support 100BTX half duplex */
  255. #define GMII_ANAR_10TFD 0x0040 /* support 10BT full duplex */
  256. #define GMII_ANAR_10T 0x0020 /* support 10BT half duplex */
  257. #define GMII_SELECTOR_FIELD 0x001F /* selector field. */
  258. /* Bit definitions: Auto-Negotiation Link Partner Ability */
  259. #define GMII_ANLPAR_100T4 0x0200 /* support 100BT4 */
  260. #define GMII_ANLPAR_100TXFD 0x0100 /* support 100BTX full duplex */
  261. #define GMII_ANLPAR_100TX 0x0080 /* support 100BTX half duplex */
  262. #define GMII_ANLPAR_10TFD 0x0040 /* support 10BT full duplex */
  263. #define GMII_ANLPAR_10T 0x0020 /* support 10BT half duplex */
  264. #define GMII_ANLPAR_PAUSE 0x0400 /* support pause packets */
  265. #define GMII_ANLPAR_ASYM_PAUSE 0x0800 /* support asymetric pause */
  266. #define GMII_ANLPAR_ACK 0x4000 /* means LCB was successfully rx'd */
  267. #define GMII_SELECTOR_8023 0x0001;
  268. /* Bit definitions: 1000BaseT AUX Control */
  269. #define GMII_1000_AUX_CTRL_MASTER_SLAVE 0x1000
  270. #define GMII_1000_AUX_CTRL_FD_CAPABLE 0x0200 /* full duplex capable */
  271. #define GMII_1000_AUX_CTRL_HD_CAPABLE 0x0100 /* half duplex capable */
  272. /* Bit definitions: 1000BaseT AUX Status */
  273. #define GMII_1000_AUX_STATUS_FD_CAPABLE 0x0800 /* full duplex capable */
  274. #define GMII_1000_AUX_STATUS_HD_CAPABLE 0x0400 /* half duplex capable */
  275. /* Cicada MII Registers */
  276. #define GMII_AUX_CTRL_STATUS 0x1C
  277. #define GMII_AUX_ANEG_CPLT 0x8000
  278. #define GMII_AUX_FDX 0x0020
  279. #define GMII_AUX_SPEED_1000 0x0010
  280. #define GMII_AUX_SPEED_100 0x0008
  281. #ifndef ADVERTISE_PAUSE_CAP
  282. #define ADVERTISE_PAUSE_CAP 0x0400
  283. #endif
  284. #ifndef MII_STAT1000
  285. #define MII_STAT1000 0x000A
  286. #endif
  287. #ifndef LPA_1000FULL
  288. #define LPA_1000FULL 0x0800
  289. #endif
  290. /* medium mode register */
  291. #define MEDIUM_GIGA_MODE 0x0001
  292. #define MEDIUM_FULL_DUPLEX_MODE 0x0002
  293. #define MEDIUM_TX_ABORT_MODE 0x0004
  294. #define MEDIUM_ENABLE_125MHZ 0x0008
  295. #define MEDIUM_ENABLE_RX_FLOWCTRL 0x0010
  296. #define MEDIUM_ENABLE_TX_FLOWCTRL 0x0020
  297. #define MEDIUM_ENABLE_JUMBO_FRAME 0x0040
  298. #define MEDIUM_CHECK_PAUSE_FRAME_MODE 0x0080
  299. #define MEDIUM_ENABLE_RECEIVE 0x0100
  300. #define MEDIUM_MII_100M_MODE 0x0200
  301. #define MEDIUM_ENABLE_JAM_PATTERN 0x0400
  302. #define MEDIUM_ENABLE_STOP_BACKPRESSURE 0x0800
  303. #define MEDIUM_ENABLE_SUPPER_MAC_SUPPORT 0x1000
  304. /* PHY mode */
  305. #define PHY_MODE_MARVELL 0
  306. #define PHY_MODE_CICADA_FAMILY 1
  307. #define PHY_MODE_CICADA_V1 1
  308. #define PHY_MODE_AGERE_FAMILY 2
  309. #define PHY_MODE_AGERE_V0 2
  310. #define PHY_MODE_CICADA_V2 5
  311. #define PHY_MODE_AGERE_V0_GMII 6
  312. #define PHY_MODE_CICADA_V2_ASIX 9
  313. #define PHY_MODE_VSC8601 10
  314. #define PHY_MODE_RTL8211CL 12
  315. #define PHY_MODE_RTL8211BN 13
  316. #define PHY_MODE_RTL8251CL 14
  317. #define PHY_MODE_ATTANSIC_V0 0x40
  318. #define PHY_MODE_ATTANSIC_FAMILY 0x40
  319. #define PHY_MODE_MAC_TO_MAC_GMII 0x7C
  320. /* */
  321. #define LED_MODE_MARVELL 0
  322. #define LED_MODE_CAMEO 1
  323. #define MARVELL_LED_CTRL 0x18
  324. #define MARVELL_MANUAL_LED 0x19
  325. #define PHY_IDENTIFIER 0x0002
  326. #define PHY_AGERE_IDENTIFIER 0x0282
  327. #define PHY_CICADA_IDENTIFIER 0x000f
  328. #define PHY_MARVELL_IDENTIFIER 0x0141
  329. #define PHY_MARVELL_STATUS 0x001b
  330. #define MARVELL_STATUS_HWCFG 0x0004 /* SGMII without clock */
  331. #define PHY_MARVELL_CTRL 0x0014
  332. #define MARVELL_CTRL_RXDELAY 0x0080
  333. #define MARVELL_CTRL_TXDELAY 0x0002
  334. #define PHY_CICADA_EXTPAGE 0x001f
  335. #define CICADA_EXTPAGE_EN 0x0001
  336. #define CICADA_EXTPAGE_DIS 0x0000
  337. /* External ethernet phy */
  338. #define EXTPHY_ID_MASK_OUI(phyid1, phyid2) ((phyid1 << 6) | ((phyid2 & 0xFC00) >> 10))
  339. #define EXTPHY_ID_MASK_MODEL(phyid2) ((phyid2 & 0x3F0) >> 4)
  340. #define EXTPHY_BROADCOM_OUI 0x2B8094
  341. #define EXTPHY_BCM89811_MODEL 0x02
  342. struct {unsigned short value, offset; } CICADA_FAMILY_HWINIT[] = {
  343. {0x0001, 0x001f}, {0x1c25, 0x0017}, {0x2a30, 0x001f}, {0x234c, 0x0010},
  344. {0x2a30, 0x001f}, {0x0212, 0x0008}, {0x52b5, 0x001f}, {0xa7fa, 0x0000},
  345. {0x0012, 0x0002}, {0x3002, 0x0001}, {0x87fa, 0x0000}, {0x52b5, 0x001f},
  346. {0xafac, 0x0000}, {0x000d, 0x0002}, {0x001c, 0x0001}, {0x8fac, 0x0000},
  347. {0x2a30, 0x001f}, {0x0012, 0x0008}, {0x2a30, 0x001f}, {0x0400, 0x0014},
  348. {0x2a30, 0x001f}, {0x0212, 0x0008}, {0x52b5, 0x001f}, {0xa760, 0x0000},
  349. {0x0000, 0x0002}, {0xfaff, 0x0001}, {0x8760, 0x0000}, {0x52b5, 0x001f},
  350. {0xa760, 0x0000}, {0x0000, 0x0002}, {0xfaff, 0x0001}, {0x8760, 0x0000},
  351. {0x52b5, 0x001f}, {0xafae, 0x0000}, {0x0004, 0x0002}, {0x0671, 0x0001},
  352. {0x8fae, 0x0000}, {0x2a30, 0x001f}, {0x0012, 0x0008}, {0x0000, 0x001f},
  353. };
  354. struct {unsigned short value, offset; } CICADA_V2_HWINIT[] = {
  355. {0x2a30, 0x001f}, {0x0212, 0x0008}, {0x52b5, 0x001f}, {0x000f, 0x0002},
  356. {0x472a, 0x0001}, {0x8fa4, 0x0000}, {0x2a30, 0x001f}, {0x0212, 0x0008},
  357. {0x0000, 0x001f},
  358. };
  359. struct {unsigned short value, offset; } CICADA_V2_ASIX_HWINIT[] = {
  360. {0x2a30, 0x001f}, {0x0212, 0x0008}, {0x52b5, 0x001f}, {0x0012, 0x0002},
  361. {0x3002, 0x0001}, {0x87fa, 0x0000}, {0x52b5, 0x001f}, {0x000f, 0x0002},
  362. {0x472a, 0x0001}, {0x8fa4, 0x0000}, {0x2a30, 0x001f}, {0x0212, 0x0008},
  363. {0x0000, 0x001f},
  364. };
  365. struct {unsigned short value, offset; } AGERE_FAMILY_HWINIT[] = {
  366. {0x0800, 0x0000}, {0x0007, 0x0012}, {0x8805, 0x0010}, {0xb03e, 0x0011},
  367. {0x8808, 0x0010}, {0xe110, 0x0011}, {0x8806, 0x0010}, {0xb03e, 0x0011},
  368. {0x8807, 0x0010}, {0xff00, 0x0011}, {0x880e, 0x0010}, {0xb4d3, 0x0011},
  369. {0x880f, 0x0010}, {0xb4d3, 0x0011}, {0x8810, 0x0010}, {0xb4d3, 0x0011},
  370. {0x8817, 0x0010}, {0x1c00, 0x0011}, {0x300d, 0x0010}, {0x0001, 0x0011},
  371. {0x0002, 0x0012},
  372. };
  373. struct ax88178_data {
  374. u16 EepromData;
  375. u16 MediaLink;
  376. int UseGpio0;
  377. int UseRgmii;
  378. u8 PhyMode;
  379. u8 LedMode;
  380. u8 BuffaloOld;
  381. };
  382. enum watchdog_state {
  383. AX_NOP = 0,
  384. CHK_LINK, /* Routine A */
  385. CHK_CABLE_EXIST, /* Called by A */
  386. CHK_CABLE_EXIST_AGAIN, /* Routine B */
  387. PHY_POWER_UP, /* Called by B */
  388. PHY_POWER_UP_BH,
  389. PHY_POWER_DOWN,
  390. CHK_CABLE_STATUS, /* Routine C */
  391. WAIT_AUTONEG_COMPLETE,
  392. AX_SET_RX_CFG,
  393. AX_CHK_AUTODETACH,
  394. };
  395. #if 0
  396. struct ax88772b_data {
  397. struct usbnet *dev;
  398. struct workqueue_struct *ax_work;
  399. struct work_struct check_link;
  400. unsigned long time_to_chk;
  401. u16 psc;
  402. u8 pw_enabled;
  403. u8 Event;
  404. u8 checksum;
  405. u8 PhySelect:1;
  406. u8 OperationMode:1;
  407. u16 presvd_phy_advertise;
  408. u16 presvd_phy_bmcr;
  409. u32 ext_phy_oui;
  410. u8 ext_phy_model;
  411. };
  412. #endif
  413. /* define for MAC or PHY mode */
  414. #define OPERATION_MAC_MODE 0
  415. #define OPERATION_PHY_MODE 1
  416. #if 0
  417. struct ax88772a_data {
  418. struct usbnet *dev;
  419. struct workqueue_struct *ax_work;
  420. struct work_struct check_link;
  421. unsigned long autoneg_start;
  422. #define AX88772B_WATCHDOG (6 * HZ)
  423. u8 Event;
  424. u8 TickToExpire;
  425. u8 DlyIndex;
  426. u8 DlySel;
  427. u16 EepromData;
  428. u16 presvd_phy_advertise;
  429. u16 presvd_phy_bmcr;
  430. };
  431. struct ax88772_data {
  432. struct usbnet *dev;
  433. struct workqueue_struct *ax_work;
  434. struct work_struct check_link;
  435. unsigned long autoneg_start;
  436. u8 Event;
  437. u8 TickToExpire;
  438. u16 presvd_phy_advertise;
  439. u16 presvd_phy_bmcr;
  440. };
  441. #endif
  442. #define AX_RX_CHECKSUM 1
  443. #define AX_TX_CHECKSUM 2
  444. #if 0
  445. /* This structure cannot exceed sizeof(unsigned long [5]) AKA 20 bytes */
  446. struct ax8817x_data {
  447. u8 multi_filter[AX_MCAST_FILTER_SIZE];
  448. int (*resume) (struct usb_interface *intf);
  449. int (*suspend) (struct usb_interface *intf,
  450. #if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 10)
  451. pm_message_t message);
  452. #else
  453. u32 message);
  454. #endif
  455. };
  456. #endif
  457. struct ax88172_int_data {
  458. u16 res1;
  459. #define AX_INT_PPLS_LINK (1 << 0)
  460. #define AX_INT_SPLS_LINK (1 << 1)
  461. #define AX_INT_CABOFF_UNPLUG (1 << 7)
  462. u8 link;
  463. u16 res2;
  464. u8 status;
  465. u16 res3;
  466. } __attribute__ ((packed));
  467. #define AX_RXHDR_L4_ERR (1 << 8)
  468. #define AX_RXHDR_L3_ERR (1 << 9)
  469. #define AX_RXHDR_L4_TYPE_UDP 1
  470. #define AX_RXHDR_L4_TYPE_ICMP 2
  471. #define AX_RXHDR_L4_TYPE_IGMP 3
  472. #define AX_RXHDR_L4_TYPE_TCP 4
  473. #define AX_RXHDR_L4_TYPE_TCMPV6 5
  474. #define AX_RXHDR_L4_TYPE_MASK 7
  475. #define AX_RXHDR_L3_TYPE_IP 1
  476. #define AX_RXHDR_L3_TYPE_IPV6 2
  477. struct ax88772b_rx_header {
  478. #if defined(__LITTLE_ENDIAN_BITFIELD)
  479. u16 len:11,
  480. res1:1,
  481. crc:1,
  482. mii:1,
  483. runt:1,
  484. mc_bc:1;
  485. u16 len_bar:11,
  486. res2:5;
  487. u8 vlan_ind:3,
  488. vlan_tag_striped:1,
  489. pri:3,
  490. res3:1;
  491. u8 l4_csum_err:1,
  492. l3_csum_err:1,
  493. l4_type:3,
  494. l3_type:2,
  495. ce:1;
  496. #elif defined(__BIG_ENDIAN_BITFIELD)
  497. u16 mc_bc:1,
  498. runt:1,
  499. mii:1,
  500. crc:1,
  501. res1:1,
  502. len:11;
  503. u16 res2:5,
  504. len_bar:11;
  505. u8 res3:1,
  506. pri:3,
  507. vlan_tag_striped:1,
  508. vlan_ind:3;
  509. u8 ce:1,
  510. l3_type:2,
  511. l4_type:3,
  512. l3_csum_err:1,
  513. l4_csum_err:1;
  514. #else
  515. #error "Please fix <asm/byteorder.h>"
  516. #endif
  517. } __attribute__ ((packed));
  518. #endif /* __LINUX_USBNET_ASIX_H */