mac.h 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375
  1. // SPDX-License-Identifier: GPL-2.0+
  2. /*
  3. * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
  4. * All rights reserved.
  5. *
  6. * File: mac.h
  7. *
  8. * Purpose: MAC routines
  9. *
  10. * Author: Tevin Chen
  11. *
  12. * Date: May 21, 1996
  13. *
  14. * Revision History:
  15. * 07-01-2003 Bryan YC Fan: Re-write codes to support VT3253 spec.
  16. * 08-25-2003 Kyle Hsu: Porting MAC functions from sim53.
  17. * 09-03-2003 Bryan YC Fan: Add MACvDisableProtectMD & MACvEnableProtectMD
  18. */
  19. #ifndef __MAC_H__
  20. #define __MAC_H__
  21. #include "device.h"
  22. #define REV_ID_VT3253_A0 0x00
  23. #define REV_ID_VT3253_A1 0x01
  24. #define REV_ID_VT3253_B0 0x08
  25. #define REV_ID_VT3253_B1 0x09
  26. /* Registers in the MAC */
  27. #define MAC_REG_BISTCMD 0x04
  28. #define MAC_REG_BISTSR0 0x05
  29. #define MAC_REG_BISTSR1 0x06
  30. #define MAC_REG_BISTSR2 0x07
  31. #define MAC_REG_I2MCSR 0x08
  32. #define MAC_REG_I2MTGID 0x09
  33. #define MAC_REG_I2MTGAD 0x0a
  34. #define MAC_REG_I2MCFG 0x0b
  35. #define MAC_REG_I2MDIPT 0x0c
  36. #define MAC_REG_I2MDOPT 0x0e
  37. #define MAC_REG_USBSUS 0x0f
  38. #define MAC_REG_LOCALID 0x14
  39. #define MAC_REG_TESTCFG 0x15
  40. #define MAC_REG_JUMPER0 0x16
  41. #define MAC_REG_JUMPER1 0x17
  42. #define MAC_REG_TMCTL 0x18
  43. #define MAC_REG_TMDATA0 0x1c
  44. #define MAC_REG_TMDATA1 0x1d
  45. #define MAC_REG_TMDATA2 0x1e
  46. #define MAC_REG_TMDATA3 0x1f
  47. /* MAC Parameter related */
  48. #define MAC_REG_LRT 0x20
  49. #define MAC_REG_SRT 0x21
  50. #define MAC_REG_SIFS 0x22
  51. #define MAC_REG_DIFS 0x23
  52. #define MAC_REG_EIFS 0x24
  53. #define MAC_REG_SLOT 0x25
  54. #define MAC_REG_BI 0x26
  55. #define MAC_REG_CWMAXMIN0 0x28
  56. #define MAC_REG_LINKOFFTOTM 0x2a
  57. #define MAC_REG_SWTMOT 0x2b
  58. #define MAC_REG_RTSOKCNT 0x2c
  59. #define MAC_REG_RTSFAILCNT 0x2d
  60. #define MAC_REG_ACKFAILCNT 0x2e
  61. #define MAC_REG_FCSERRCNT 0x2f
  62. /* TSF Related */
  63. #define MAC_REG_TSFCNTR 0x30
  64. #define MAC_REG_NEXTTBTT 0x38
  65. #define MAC_REG_TSFOFST 0x40
  66. #define MAC_REG_TFTCTL 0x48
  67. /* WMAC Control/Status Related */
  68. #define MAC_REG_ENCFG0 0x4c
  69. #define MAC_REG_ENCFG1 0x4d
  70. #define MAC_REG_ENCFG2 0x4e
  71. #define MAC_REG_CFG 0x50
  72. #define MAC_REG_TEST 0x52
  73. #define MAC_REG_HOSTCR 0x54
  74. #define MAC_REG_MACCR 0x55
  75. #define MAC_REG_RCR 0x56
  76. #define MAC_REG_TCR 0x57
  77. #define MAC_REG_IMR 0x58
  78. #define MAC_REG_ISR 0x5c
  79. #define MAC_REG_ISR1 0x5d
  80. /* Power Saving Related */
  81. #define MAC_REG_PSCFG 0x60
  82. #define MAC_REG_PSCTL 0x61
  83. #define MAC_REG_PSPWRSIG 0x62
  84. #define MAC_REG_BBCR13 0x63
  85. #define MAC_REG_AIDATIM 0x64
  86. #define MAC_REG_PWBT 0x66
  87. #define MAC_REG_WAKEOKTMR 0x68
  88. #define MAC_REG_CALTMR 0x69
  89. #define MAC_REG_SYNSPACCNT 0x6a
  90. #define MAC_REG_WAKSYNOPT 0x6b
  91. /* Baseband/IF Control Group */
  92. #define MAC_REG_BBREGCTL 0x6c
  93. #define MAC_REG_CHANNEL 0x6d
  94. #define MAC_REG_BBREGADR 0x6e
  95. #define MAC_REG_BBREGDATA 0x6f
  96. #define MAC_REG_IFREGCTL 0x70
  97. #define MAC_REG_IFDATA 0x71
  98. #define MAC_REG_ITRTMSET 0x74
  99. #define MAC_REG_PAPEDELAY 0x77
  100. #define MAC_REG_SOFTPWRCTL 0x78
  101. #define MAC_REG_SOFTPWRCTL2 0x79
  102. #define MAC_REG_GPIOCTL0 0x7a
  103. #define MAC_REG_GPIOCTL1 0x7b
  104. /* MiscFF PIO related */
  105. #define MAC_REG_MISCFFNDEX 0xbc
  106. #define MAC_REG_MISCFFCTL 0xbe
  107. #define MAC_REG_MISCFFDATA 0xc0
  108. /* MAC Configuration Group */
  109. #define MAC_REG_PAR0 0xc4
  110. #define MAC_REG_PAR4 0xc8
  111. #define MAC_REG_BSSID0 0xcc
  112. #define MAC_REG_BSSID4 0xd0
  113. #define MAC_REG_MAR0 0xd4
  114. #define MAC_REG_MAR4 0xd8
  115. /* MAC RSPPKT INFO Group */
  116. #define MAC_REG_RSPINF_B_1 0xdC
  117. #define MAC_REG_RSPINF_B_2 0xe0
  118. #define MAC_REG_RSPINF_B_5 0xe4
  119. #define MAC_REG_RSPINF_B_11 0xe8
  120. #define MAC_REG_RSPINF_A_6 0xec
  121. #define MAC_REG_RSPINF_A_9 0xee
  122. #define MAC_REG_RSPINF_A_12 0xf0
  123. #define MAC_REG_RSPINF_A_18 0xf2
  124. #define MAC_REG_RSPINF_A_24 0xf4
  125. #define MAC_REG_RSPINF_A_36 0xf6
  126. #define MAC_REG_RSPINF_A_48 0xf8
  127. #define MAC_REG_RSPINF_A_54 0xfa
  128. #define MAC_REG_RSPINF_A_72 0xfc
  129. /* Bits in the I2MCFG EEPROM register */
  130. #define I2MCFG_BOUNDCTL 0x80
  131. #define I2MCFG_WAITCTL 0x20
  132. #define I2MCFG_SCLOECTL 0x10
  133. #define I2MCFG_WBUSYCTL 0x08
  134. #define I2MCFG_NORETRY 0x04
  135. #define I2MCFG_I2MLDSEQ 0x02
  136. #define I2MCFG_I2CMFAST 0x01
  137. /* Bits in the I2MCSR EEPROM register */
  138. #define I2MCSR_EEMW 0x80
  139. #define I2MCSR_EEMR 0x40
  140. #define I2MCSR_AUTOLD 0x08
  141. #define I2MCSR_NACK 0x02
  142. #define I2MCSR_DONE 0x01
  143. /* Bits in the TMCTL register */
  144. #define TMCTL_TSUSP 0x04
  145. #define TMCTL_TMD 0x02
  146. #define TMCTL_TE 0x01
  147. /* Bits in the TFTCTL register */
  148. #define TFTCTL_HWUTSF 0x80
  149. #define TFTCTL_TBTTSYNC 0x40
  150. #define TFTCTL_HWUTSFEN 0x20
  151. #define TFTCTL_TSFCNTRRD 0x10
  152. #define TFTCTL_TBTTSYNCEN 0x08
  153. #define TFTCTL_TSFSYNCEN 0x04
  154. #define TFTCTL_TSFCNTRST 0x02
  155. #define TFTCTL_TSFCNTREN 0x01
  156. /* Bits in the EnhanceCFG_0 register */
  157. #define EnCFG_BBType_a 0x00
  158. #define EnCFG_BBType_b 0x01
  159. #define EnCFG_BBType_g 0x02
  160. #define EnCFG_BBType_MASK 0x03
  161. #define EnCFG_ProtectMd 0x20
  162. /* Bits in the EnhanceCFG_1 register */
  163. #define EnCFG_BcnSusInd 0x01
  164. #define EnCFG_BcnSusClr 0x02
  165. /* Bits in the EnhanceCFG_2 register */
  166. #define EnCFG_NXTBTTCFPSTR 0x01
  167. #define EnCFG_BarkerPream 0x02
  168. #define EnCFG_PktBurstMode 0x04
  169. /* Bits in the CFG register */
  170. #define CFG_TKIPOPT 0x80
  171. #define CFG_RXDMAOPT 0x40
  172. #define CFG_TMOT_SW 0x20
  173. #define CFG_TMOT_HWLONG 0x10
  174. #define CFG_TMOT_HW 0x00
  175. #define CFG_CFPENDOPT 0x08
  176. #define CFG_BCNSUSEN 0x04
  177. #define CFG_NOTXTIMEOUT 0x02
  178. #define CFG_NOBUFOPT 0x01
  179. /* Bits in the TEST register */
  180. #define TEST_LBEXT 0x80
  181. #define TEST_LBINT 0x40
  182. #define TEST_LBNONE 0x00
  183. #define TEST_SOFTINT 0x20
  184. #define TEST_CONTTX 0x10
  185. #define TEST_TXPE 0x08
  186. #define TEST_NAVDIS 0x04
  187. #define TEST_NOCTS 0x02
  188. #define TEST_NOACK 0x01
  189. /* Bits in the HOSTCR register */
  190. #define HOSTCR_TXONST 0x80
  191. #define HOSTCR_RXONST 0x40
  192. #define HOSTCR_ADHOC 0x20
  193. #define HOSTCR_AP 0x10
  194. #define HOSTCR_TXON 0x08
  195. #define HOSTCR_RXON 0x04
  196. #define HOSTCR_MACEN 0x02
  197. #define HOSTCR_SOFTRST 0x01
  198. /* Bits in the MACCR register */
  199. #define MACCR_SYNCFLUSHOK 0x04
  200. #define MACCR_SYNCFLUSH 0x02
  201. #define MACCR_CLRNAV 0x01
  202. /* Bits in the RCR register */
  203. #define RCR_SSID 0x80
  204. #define RCR_RXALLTYPE 0x40
  205. #define RCR_UNICAST 0x20
  206. #define RCR_BROADCAST 0x10
  207. #define RCR_MULTICAST 0x08
  208. #define RCR_WPAERR 0x04
  209. #define RCR_ERRCRC 0x02
  210. #define RCR_BSSID 0x01
  211. /* Bits in the TCR register */
  212. #define TCR_SYNCDCFOPT 0x02
  213. #define TCR_AUTOBCNTX 0x01
  214. /* ISR1 */
  215. #define ISR_GPIO3 0x40
  216. #define ISR_RXNOBUF 0x08
  217. #define ISR_MIBNEARFULL 0x04
  218. #define ISR_SOFTINT 0x02
  219. #define ISR_FETALERR 0x01
  220. #define LEDSTS_STS 0x06
  221. #define LEDSTS_TMLEN 0x78
  222. #define LEDSTS_OFF 0x00
  223. #define LEDSTS_ON 0x02
  224. #define LEDSTS_SLOW 0x04
  225. #define LEDSTS_INTER 0x06
  226. /* ISR0 */
  227. #define ISR_WATCHDOG 0x80
  228. #define ISR_SOFTTIMER 0x40
  229. #define ISR_GPIO0 0x20
  230. #define ISR_TBTT 0x10
  231. #define ISR_RXDMA0 0x08
  232. #define ISR_BNTX 0x04
  233. #define ISR_ACTX 0x01
  234. /* Bits in the PSCFG register */
  235. #define PSCFG_PHILIPMD 0x40
  236. #define PSCFG_WAKECALEN 0x20
  237. #define PSCFG_WAKETMREN 0x10
  238. #define PSCFG_BBPSPROG 0x08
  239. #define PSCFG_WAKESYN 0x04
  240. #define PSCFG_SLEEPSYN 0x02
  241. #define PSCFG_AUTOSLEEP 0x01
  242. /* Bits in the PSCTL register */
  243. #define PSCTL_WAKEDONE 0x20
  244. #define PSCTL_PS 0x10
  245. #define PSCTL_GO2DOZE 0x08
  246. #define PSCTL_LNBCN 0x04
  247. #define PSCTL_ALBCN 0x02
  248. #define PSCTL_PSEN 0x01
  249. /* Bits in the PSPWSIG register */
  250. #define PSSIG_WPE3 0x80
  251. #define PSSIG_WPE2 0x40
  252. #define PSSIG_WPE1 0x20
  253. #define PSSIG_WRADIOPE 0x10
  254. #define PSSIG_SPE3 0x08
  255. #define PSSIG_SPE2 0x04
  256. #define PSSIG_SPE1 0x02
  257. #define PSSIG_SRADIOPE 0x01
  258. /* Bits in the BBREGCTL register */
  259. #define BBREGCTL_DONE 0x04
  260. #define BBREGCTL_REGR 0x02
  261. #define BBREGCTL_REGW 0x01
  262. /* Bits in the IFREGCTL register */
  263. #define IFREGCTL_DONE 0x04
  264. #define IFREGCTL_IFRF 0x02
  265. #define IFREGCTL_REGW 0x01
  266. /* Bits in the SOFTPWRCTL register */
  267. #define SOFTPWRCTL_RFLEOPT 0x08
  268. #define SOFTPWRCTL_TXPEINV 0x02
  269. #define SOFTPWRCTL_SWPECTI 0x01
  270. #define SOFTPWRCTL_SWPAPE 0x20
  271. #define SOFTPWRCTL_SWCALEN 0x10
  272. #define SOFTPWRCTL_SWRADIO_PE 0x08
  273. #define SOFTPWRCTL_SWPE2 0x04
  274. #define SOFTPWRCTL_SWPE1 0x02
  275. #define SOFTPWRCTL_SWPE3 0x01
  276. /* Bits in the GPIOCTL1 register */
  277. #define GPIO3_MD 0x20
  278. #define GPIO3_DATA 0x40
  279. #define GPIO3_INTMD 0x80
  280. /* Bits in the MISCFFCTL register */
  281. #define MISCFFCTL_WRITE 0x0001
  282. /* Loopback mode */
  283. #define MAC_LB_EXT 0x02
  284. #define MAC_LB_INTERNAL 0x01
  285. #define MAC_LB_NONE 0x00
  286. /* Ethernet address filter type */
  287. #define PKT_TYPE_NONE 0x00 /* turn off receiver */
  288. #define PKT_TYPE_ALL_MULTICAST 0x80
  289. #define PKT_TYPE_PROMISCUOUS 0x40
  290. #define PKT_TYPE_DIRECTED 0x20 /* obselete */
  291. #define PKT_TYPE_BROADCAST 0x10
  292. #define PKT_TYPE_MULTICAST 0x08
  293. #define PKT_TYPE_ERROR_WPA 0x04
  294. #define PKT_TYPE_ERROR_CRC 0x02
  295. #define PKT_TYPE_BSSID 0x01
  296. #define Default_BI 0x200
  297. /* MiscFIFO Offset */
  298. #define MISCFIFO_KEYETRY0 32
  299. #define MISCFIFO_KEYENTRYSIZE 22
  300. #define MAC_REVISION_A0 0x00
  301. #define MAC_REVISION_A1 0x01
  302. struct vnt_mac_set_key {
  303. union {
  304. struct {
  305. u8 addr[ETH_ALEN];
  306. __le16 key_ctl;
  307. } write __packed;
  308. u32 swap[2];
  309. } u;
  310. u8 key[WLAN_KEY_LEN_CCMP];
  311. } __packed;
  312. void vnt_mac_set_filter(struct vnt_private *priv, u64 mc_filter);
  313. void vnt_mac_shutdown(struct vnt_private *priv);
  314. void vnt_mac_set_bb_type(struct vnt_private *priv, u8 type);
  315. void vnt_mac_disable_keyentry(struct vnt_private *priv, u8 entry_idx);
  316. void vnt_mac_set_keyentry(struct vnt_private *priv, u16 key_ctl, u32 entry_idx,
  317. u32 key_idx, u8 *addr, u8 *key);
  318. void vnt_mac_reg_bits_off(struct vnt_private *priv, u8 reg_ofs, u8 bits);
  319. void vnt_mac_reg_bits_on(struct vnt_private *priv, u8 reg_ofs, u8 bits);
  320. void vnt_mac_write_word(struct vnt_private *priv, u8 reg_ofs, u16 word);
  321. void vnt_mac_set_bssid_addr(struct vnt_private *priv, u8 *addr);
  322. void vnt_mac_enable_protect_mode(struct vnt_private *priv);
  323. void vnt_mac_disable_protect_mode(struct vnt_private *priv);
  324. void vnt_mac_enable_barker_preamble_mode(struct vnt_private *priv);
  325. void vnt_mac_disable_barker_preamble_mode(struct vnt_private *priv);
  326. void vnt_mac_set_beacon_interval(struct vnt_private *priv, u16 interval);
  327. void vnt_mac_set_led(struct vnt_private *privpriv, u8 state, u8 led);
  328. #endif /* __MAC_H__ */