mac.h 10 KB

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