mac.h 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933
  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 "tmacro.h"
  22. #include "upc.h"
  23. /*--------------------- Export Definitions -------------------------*/
  24. /* Registers in the MAC */
  25. #define MAC_MAX_CONTEXT_SIZE_PAGE0 256
  26. #define MAC_MAX_CONTEXT_SIZE_PAGE1 128
  27. /* Registers not related to 802.11b */
  28. #define MAC_REG_BCFG0 0x00
  29. #define MAC_REG_BCFG1 0x01
  30. #define MAC_REG_FCR0 0x02
  31. #define MAC_REG_FCR1 0x03
  32. #define MAC_REG_BISTCMD 0x04
  33. #define MAC_REG_BISTSR0 0x05
  34. #define MAC_REG_BISTSR1 0x06
  35. #define MAC_REG_BISTSR2 0x07
  36. #define MAC_REG_I2MCSR 0x08
  37. #define MAC_REG_I2MTGID 0x09
  38. #define MAC_REG_I2MTGAD 0x0A
  39. #define MAC_REG_I2MCFG 0x0B
  40. #define MAC_REG_I2MDIPT 0x0C
  41. #define MAC_REG_I2MDOPT 0x0E
  42. #define MAC_REG_PMC0 0x10
  43. #define MAC_REG_PMC1 0x11
  44. #define MAC_REG_STICKHW 0x12
  45. #define MAC_REG_LOCALID 0x14
  46. #define MAC_REG_TESTCFG 0x15
  47. #define MAC_REG_JUMPER0 0x16
  48. #define MAC_REG_JUMPER1 0x17
  49. #define MAC_REG_TMCTL0 0x18
  50. #define MAC_REG_TMCTL1 0x19
  51. #define MAC_REG_TMDATA0 0x1C
  52. /* MAC Parameter related */
  53. #define MAC_REG_LRT 0x20
  54. #define MAC_REG_SRT 0x21
  55. #define MAC_REG_SIFS 0x22
  56. #define MAC_REG_DIFS 0x23
  57. #define MAC_REG_EIFS 0x24
  58. #define MAC_REG_SLOT 0x25
  59. #define MAC_REG_BI 0x26
  60. #define MAC_REG_CWMAXMIN0 0x28
  61. #define MAC_REG_LINKOFFTOTM 0x2A
  62. #define MAC_REG_SWTMOT 0x2B
  63. #define MAC_REG_MIBCNTR 0x2C
  64. #define MAC_REG_RTSOKCNT 0x2C
  65. #define MAC_REG_RTSFAILCNT 0x2D
  66. #define MAC_REG_ACKFAILCNT 0x2E
  67. #define MAC_REG_FCSERRCNT 0x2F
  68. /* TSF Related */
  69. #define MAC_REG_TSFCNTR 0x30
  70. #define MAC_REG_NEXTTBTT 0x38
  71. #define MAC_REG_TSFOFST 0x40
  72. #define MAC_REG_TFTCTL 0x48
  73. /* WMAC Control/Status Related */
  74. #define MAC_REG_ENCFG 0x4C
  75. #define MAC_REG_PAGE1SEL 0x4F
  76. #define MAC_REG_CFG 0x50
  77. #define MAC_REG_TEST 0x52
  78. #define MAC_REG_HOSTCR 0x54
  79. #define MAC_REG_MACCR 0x55
  80. #define MAC_REG_RCR 0x56
  81. #define MAC_REG_TCR 0x57
  82. #define MAC_REG_IMR 0x58
  83. #define MAC_REG_ISR 0x5C
  84. /* Power Saving Related */
  85. #define MAC_REG_PSCFG 0x60
  86. #define MAC_REG_PSCTL 0x61
  87. #define MAC_REG_PSPWRSIG 0x62
  88. #define MAC_REG_BBCR13 0x63
  89. #define MAC_REG_AIDATIM 0x64
  90. #define MAC_REG_PWBT 0x66
  91. #define MAC_REG_WAKEOKTMR 0x68
  92. #define MAC_REG_CALTMR 0x69
  93. #define MAC_REG_SYNSPACCNT 0x6A
  94. #define MAC_REG_WAKSYNOPT 0x6B
  95. /* Baseband/IF Control Group */
  96. #define MAC_REG_BBREGCTL 0x6C
  97. #define MAC_REG_CHANNEL 0x6D
  98. #define MAC_REG_BBREGADR 0x6E
  99. #define MAC_REG_BBREGDATA 0x6F
  100. #define MAC_REG_IFREGCTL 0x70
  101. #define MAC_REG_IFDATA 0x71
  102. #define MAC_REG_ITRTMSET 0x74
  103. #define MAC_REG_PAPEDELAY 0x77
  104. #define MAC_REG_SOFTPWRCTL 0x78
  105. #define MAC_REG_GPIOCTL0 0x7A
  106. #define MAC_REG_GPIOCTL1 0x7B
  107. /* MAC DMA Related Group */
  108. #define MAC_REG_TXDMACTL0 0x7C
  109. #define MAC_REG_TXDMAPTR0 0x80
  110. #define MAC_REG_AC0DMACTL 0x84
  111. #define MAC_REG_AC0DMAPTR 0x88
  112. #define MAC_REG_BCNDMACTL 0x8C
  113. #define MAC_REG_BCNDMAPTR 0x90
  114. #define MAC_REG_RXDMACTL0 0x94
  115. #define MAC_REG_RXDMAPTR0 0x98
  116. #define MAC_REG_RXDMACTL1 0x9C
  117. #define MAC_REG_RXDMAPTR1 0xA0
  118. #define MAC_REG_SYNCDMACTL 0xA4
  119. #define MAC_REG_SYNCDMAPTR 0xA8
  120. #define MAC_REG_ATIMDMACTL 0xAC
  121. #define MAC_REG_ATIMDMAPTR 0xB0
  122. /* MiscFF PIO related */
  123. #define MAC_REG_MISCFFNDEX 0xB4
  124. #define MAC_REG_MISCFFCTL 0xB6
  125. #define MAC_REG_MISCFFDATA 0xB8
  126. /* Extend SW Timer */
  127. #define MAC_REG_TMDATA1 0xBC
  128. /* WOW Related Group */
  129. #define MAC_REG_WAKEUPEN0 0xC0
  130. #define MAC_REG_WAKEUPEN1 0xC1
  131. #define MAC_REG_WAKEUPSR0 0xC2
  132. #define MAC_REG_WAKEUPSR1 0xC3
  133. #define MAC_REG_WAKE128_0 0xC4
  134. #define MAC_REG_WAKE128_1 0xD4
  135. #define MAC_REG_WAKE128_2 0xE4
  136. #define MAC_REG_WAKE128_3 0xF4
  137. /************** Page 1 ******************/
  138. #define MAC_REG_CRC_128_0 0x04
  139. #define MAC_REG_CRC_128_1 0x06
  140. #define MAC_REG_CRC_128_2 0x08
  141. #define MAC_REG_CRC_128_3 0x0A
  142. /* MAC Configuration Group */
  143. #define MAC_REG_PAR0 0x0C
  144. #define MAC_REG_PAR4 0x10
  145. #define MAC_REG_BSSID0 0x14
  146. #define MAC_REG_BSSID4 0x18
  147. #define MAC_REG_MAR0 0x1C
  148. #define MAC_REG_MAR4 0x20
  149. /* MAC RSPPKT INFO Group */
  150. #define MAC_REG_RSPINF_B_1 0x24
  151. #define MAC_REG_RSPINF_B_2 0x28
  152. #define MAC_REG_RSPINF_B_5 0x2C
  153. #define MAC_REG_RSPINF_B_11 0x30
  154. #define MAC_REG_RSPINF_A_6 0x34
  155. #define MAC_REG_RSPINF_A_9 0x36
  156. #define MAC_REG_RSPINF_A_12 0x38
  157. #define MAC_REG_RSPINF_A_18 0x3A
  158. #define MAC_REG_RSPINF_A_24 0x3C
  159. #define MAC_REG_RSPINF_A_36 0x3E
  160. #define MAC_REG_RSPINF_A_48 0x40
  161. #define MAC_REG_RSPINF_A_54 0x42
  162. #define MAC_REG_RSPINF_A_72 0x44
  163. /* 802.11h relative */
  164. #define MAC_REG_QUIETINIT 0x60
  165. #define MAC_REG_QUIETGAP 0x62
  166. #define MAC_REG_QUIETDUR 0x64
  167. #define MAC_REG_MSRCTL 0x66
  168. #define MAC_REG_MSRBBSTS 0x67
  169. #define MAC_REG_MSRSTART 0x68
  170. #define MAC_REG_MSRDURATION 0x70
  171. #define MAC_REG_CCAFRACTION 0x72
  172. #define MAC_REG_PWRCCK 0x73
  173. #define MAC_REG_PWROFDM 0x7C
  174. /* Bits in the BCFG0 register */
  175. #define BCFG0_PERROFF 0x40
  176. #define BCFG0_MRDMDIS 0x20
  177. #define BCFG0_MRDLDIS 0x10
  178. #define BCFG0_MWMEN 0x08
  179. #define BCFG0_VSERREN 0x02
  180. #define BCFG0_LATMEN 0x01
  181. /* Bits in the BCFG1 register */
  182. #define BCFG1_CFUNOPT 0x80
  183. #define BCFG1_CREQOPT 0x40
  184. #define BCFG1_DMA8 0x10
  185. #define BCFG1_ARBITOPT 0x08
  186. #define BCFG1_PCIMEN 0x04
  187. #define BCFG1_MIOEN 0x02
  188. #define BCFG1_CISDLYEN 0x01
  189. /* Bits in RAMBIST registers */
  190. #define BISTCMD_TSTPAT5 0x00
  191. #define BISTCMD_TSTPATA 0x80
  192. #define BISTCMD_TSTERR 0x20
  193. #define BISTCMD_TSTPATF 0x18
  194. #define BISTCMD_TSTPAT0 0x10
  195. #define BISTCMD_TSTMODE 0x04
  196. #define BISTCMD_TSTITTX 0x03
  197. #define BISTCMD_TSTATRX 0x02
  198. #define BISTCMD_TSTATTX 0x01
  199. #define BISTCMD_TSTRX 0x00
  200. #define BISTSR0_BISTGO 0x01
  201. #define BISTSR1_TSTSR 0x01
  202. #define BISTSR2_CMDPRTEN 0x02
  203. #define BISTSR2_RAMTSTEN 0x01
  204. /* Bits in the I2MCFG EEPROM register */
  205. #define I2MCFG_BOUNDCTL 0x80
  206. #define I2MCFG_WAITCTL 0x20
  207. #define I2MCFG_SCLOECTL 0x10
  208. #define I2MCFG_WBUSYCTL 0x08
  209. #define I2MCFG_NORETRY 0x04
  210. #define I2MCFG_I2MLDSEQ 0x02
  211. #define I2MCFG_I2CMFAST 0x01
  212. /* Bits in the I2MCSR EEPROM register */
  213. #define I2MCSR_EEMW 0x80
  214. #define I2MCSR_EEMR 0x40
  215. #define I2MCSR_AUTOLD 0x08
  216. #define I2MCSR_NACK 0x02
  217. #define I2MCSR_DONE 0x01
  218. /* Bits in the PMC1 register */
  219. #define SPS_RST 0x80
  220. #define PCISTIKY 0x40
  221. #define PME_OVR 0x02
  222. /* Bits in the STICKYHW register */
  223. #define STICKHW_DS1_SHADOW 0x02
  224. #define STICKHW_DS0_SHADOW 0x01
  225. /* Bits in the TMCTL register */
  226. #define TMCTL_TSUSP 0x04
  227. #define TMCTL_TMD 0x02
  228. #define TMCTL_TE 0x01
  229. /* Bits in the TFTCTL register */
  230. #define TFTCTL_HWUTSF 0x80
  231. #define TFTCTL_TBTTSYNC 0x40
  232. #define TFTCTL_HWUTSFEN 0x20
  233. #define TFTCTL_TSFCNTRRD 0x10
  234. #define TFTCTL_TBTTSYNCEN 0x08
  235. #define TFTCTL_TSFSYNCEN 0x04
  236. #define TFTCTL_TSFCNTRST 0x02
  237. #define TFTCTL_TSFCNTREN 0x01
  238. /* Bits in the EnhanceCFG register */
  239. #define EnCFG_BarkerPream 0x00020000
  240. #define EnCFG_NXTBTTCFPSTR 0x00010000
  241. #define EnCFG_BcnSusClr 0x00000200
  242. #define EnCFG_BcnSusInd 0x00000100
  243. #define EnCFG_CFP_ProtectEn 0x00000040
  244. #define EnCFG_ProtectMd 0x00000020
  245. #define EnCFG_HwParCFP 0x00000010
  246. #define EnCFG_CFNULRSP 0x00000004
  247. #define EnCFG_BBType_MASK 0x00000003
  248. #define EnCFG_BBType_g 0x00000002
  249. #define EnCFG_BBType_b 0x00000001
  250. #define EnCFG_BBType_a 0x00000000
  251. /* Bits in the Page1Sel register */
  252. #define PAGE1_SEL 0x01
  253. /* Bits in the CFG register */
  254. #define CFG_TKIPOPT 0x80
  255. #define CFG_RXDMAOPT 0x40
  256. #define CFG_TMOT_SW 0x20
  257. #define CFG_TMOT_HWLONG 0x10
  258. #define CFG_TMOT_HW 0x00
  259. #define CFG_CFPENDOPT 0x08
  260. #define CFG_BCNSUSEN 0x04
  261. #define CFG_NOTXTIMEOUT 0x02
  262. #define CFG_NOBUFOPT 0x01
  263. /* Bits in the TEST register */
  264. #define TEST_LBEXT 0x80
  265. #define TEST_LBINT 0x40
  266. #define TEST_LBNONE 0x00
  267. #define TEST_SOFTINT 0x20
  268. #define TEST_CONTTX 0x10
  269. #define TEST_TXPE 0x08
  270. #define TEST_NAVDIS 0x04
  271. #define TEST_NOCTS 0x02
  272. #define TEST_NOACK 0x01
  273. /* Bits in the HOSTCR register */
  274. #define HOSTCR_TXONST 0x80
  275. #define HOSTCR_RXONST 0x40
  276. #define HOSTCR_ADHOC 0x20 /* Network Type 1 = Ad-hoc */
  277. #define HOSTCR_AP 0x10 /* Port Type 1 = AP */
  278. #define HOSTCR_TXON 0x08 /* 0000 1000 */
  279. #define HOSTCR_RXON 0x04 /* 0000 0100 */
  280. #define HOSTCR_MACEN 0x02 /* 0000 0010 */
  281. #define HOSTCR_SOFTRST 0x01 /* 0000 0001 */
  282. /* Bits in the MACCR register */
  283. #define MACCR_SYNCFLUSHOK 0x04
  284. #define MACCR_SYNCFLUSH 0x02
  285. #define MACCR_CLRNAV 0x01
  286. /* Bits in the MAC_REG_GPIOCTL0 register */
  287. #define LED_ACTSET 0x01
  288. #define LED_RFOFF 0x02
  289. #define LED_NOCONNECT 0x04
  290. /* Bits in the RCR register */
  291. #define RCR_SSID 0x80
  292. #define RCR_RXALLTYPE 0x40
  293. #define RCR_UNICAST 0x20
  294. #define RCR_BROADCAST 0x10
  295. #define RCR_MULTICAST 0x08
  296. #define RCR_WPAERR 0x04
  297. #define RCR_ERRCRC 0x02
  298. #define RCR_BSSID 0x01
  299. /* Bits in the TCR register */
  300. #define TCR_SYNCDCFOPT 0x02
  301. #define TCR_AUTOBCNTX 0x01 /* Beacon automatically transmit enable */
  302. /* Bits in the IMR register */
  303. #define IMR_MEASURESTART 0x80000000
  304. #define IMR_QUIETSTART 0x20000000
  305. #define IMR_RADARDETECT 0x10000000
  306. #define IMR_MEASUREEND 0x08000000
  307. #define IMR_SOFTTIMER1 0x00200000
  308. #define IMR_RXDMA1 0x00001000 /* 0000 0000 0001 0000 0000 0000 */
  309. #define IMR_RXNOBUF 0x00000800
  310. #define IMR_MIBNEARFULL 0x00000400
  311. #define IMR_SOFTINT 0x00000200
  312. #define IMR_FETALERR 0x00000100
  313. #define IMR_WATCHDOG 0x00000080
  314. #define IMR_SOFTTIMER 0x00000040
  315. #define IMR_GPIO 0x00000020
  316. #define IMR_TBTT 0x00000010
  317. #define IMR_RXDMA0 0x00000008
  318. #define IMR_BNTX 0x00000004
  319. #define IMR_AC0DMA 0x00000002
  320. #define IMR_TXDMA0 0x00000001
  321. /* Bits in the ISR register */
  322. #define ISR_MEASURESTART 0x80000000
  323. #define ISR_QUIETSTART 0x20000000
  324. #define ISR_RADARDETECT 0x10000000
  325. #define ISR_MEASUREEND 0x08000000
  326. #define ISR_SOFTTIMER1 0x00200000
  327. #define ISR_RXDMA1 0x00001000 /* 0000 0000 0001 0000 0000 0000 */
  328. #define ISR_RXNOBUF 0x00000800 /* 0000 0000 0000 1000 0000 0000 */
  329. #define ISR_MIBNEARFULL 0x00000400 /* 0000 0000 0000 0100 0000 0000 */
  330. #define ISR_SOFTINT 0x00000200
  331. #define ISR_FETALERR 0x00000100
  332. #define ISR_WATCHDOG 0x00000080
  333. #define ISR_SOFTTIMER 0x00000040
  334. #define ISR_GPIO 0x00000020
  335. #define ISR_TBTT 0x00000010
  336. #define ISR_RXDMA0 0x00000008
  337. #define ISR_BNTX 0x00000004
  338. #define ISR_AC0DMA 0x00000002
  339. #define ISR_TXDMA0 0x00000001
  340. /* Bits in the PSCFG register */
  341. #define PSCFG_PHILIPMD 0x40
  342. #define PSCFG_WAKECALEN 0x20
  343. #define PSCFG_WAKETMREN 0x10
  344. #define PSCFG_BBPSPROG 0x08
  345. #define PSCFG_WAKESYN 0x04
  346. #define PSCFG_SLEEPSYN 0x02
  347. #define PSCFG_AUTOSLEEP 0x01
  348. /* Bits in the PSCTL register */
  349. #define PSCTL_WAKEDONE 0x20
  350. #define PSCTL_PS 0x10
  351. #define PSCTL_GO2DOZE 0x08
  352. #define PSCTL_LNBCN 0x04
  353. #define PSCTL_ALBCN 0x02
  354. #define PSCTL_PSEN 0x01
  355. /* Bits in the PSPWSIG register */
  356. #define PSSIG_WPE3 0x80
  357. #define PSSIG_WPE2 0x40
  358. #define PSSIG_WPE1 0x20
  359. #define PSSIG_WRADIOPE 0x10
  360. #define PSSIG_SPE3 0x08
  361. #define PSSIG_SPE2 0x04
  362. #define PSSIG_SPE1 0x02
  363. #define PSSIG_SRADIOPE 0x01
  364. /* Bits in the BBREGCTL register */
  365. #define BBREGCTL_DONE 0x04
  366. #define BBREGCTL_REGR 0x02
  367. #define BBREGCTL_REGW 0x01
  368. /* Bits in the IFREGCTL register */
  369. #define IFREGCTL_DONE 0x04
  370. #define IFREGCTL_IFRF 0x02
  371. #define IFREGCTL_REGW 0x01
  372. /* Bits in the SOFTPWRCTL register */
  373. #define SOFTPWRCTL_RFLEOPT 0x0800
  374. #define SOFTPWRCTL_TXPEINV 0x0200
  375. #define SOFTPWRCTL_SWPECTI 0x0100
  376. #define SOFTPWRCTL_SWPAPE 0x0020
  377. #define SOFTPWRCTL_SWCALEN 0x0010
  378. #define SOFTPWRCTL_SWRADIO_PE 0x0008
  379. #define SOFTPWRCTL_SWPE2 0x0004
  380. #define SOFTPWRCTL_SWPE1 0x0002
  381. #define SOFTPWRCTL_SWPE3 0x0001
  382. /* Bits in the GPIOCTL1 register */
  383. #define GPIO1_DATA1 0x20
  384. #define GPIO1_MD1 0x10
  385. #define GPIO1_DATA0 0x02
  386. #define GPIO1_MD0 0x01
  387. /* Bits in the DMACTL register */
  388. #define DMACTL_CLRRUN 0x00080000
  389. #define DMACTL_RUN 0x00000008
  390. #define DMACTL_WAKE 0x00000004
  391. #define DMACTL_DEAD 0x00000002
  392. #define DMACTL_ACTIVE 0x00000001
  393. /* Bits in the RXDMACTL0 register */
  394. #define RX_PERPKT 0x00000100
  395. #define RX_PERPKTCLR 0x01000000
  396. /* Bits in the BCNDMACTL register */
  397. #define BEACON_READY 0x01
  398. /* Bits in the MISCFFCTL register */
  399. #define MISCFFCTL_WRITE 0x0001
  400. /* Bits in WAKEUPEN0 */
  401. #define WAKEUPEN0_DIRPKT 0x10
  402. #define WAKEUPEN0_LINKOFF 0x08
  403. #define WAKEUPEN0_ATIMEN 0x04
  404. #define WAKEUPEN0_TIMEN 0x02
  405. #define WAKEUPEN0_MAGICEN 0x01
  406. /* Bits in WAKEUPEN1 */
  407. #define WAKEUPEN1_128_3 0x08
  408. #define WAKEUPEN1_128_2 0x04
  409. #define WAKEUPEN1_128_1 0x02
  410. #define WAKEUPEN1_128_0 0x01
  411. /* Bits in WAKEUPSR0 */
  412. #define WAKEUPSR0_DIRPKT 0x10
  413. #define WAKEUPSR0_LINKOFF 0x08
  414. #define WAKEUPSR0_ATIMEN 0x04
  415. #define WAKEUPSR0_TIMEN 0x02
  416. #define WAKEUPSR0_MAGICEN 0x01
  417. /* Bits in WAKEUPSR1 */
  418. #define WAKEUPSR1_128_3 0x08
  419. #define WAKEUPSR1_128_2 0x04
  420. #define WAKEUPSR1_128_1 0x02
  421. #define WAKEUPSR1_128_0 0x01
  422. /* Bits in the MAC_REG_GPIOCTL register */
  423. #define GPIO0_MD 0x01
  424. #define GPIO0_DATA 0x02
  425. #define GPIO0_INTMD 0x04
  426. #define GPIO1_MD 0x10
  427. #define GPIO1_DATA 0x20
  428. /* Bits in the MSRCTL register */
  429. #define MSRCTL_FINISH 0x80
  430. #define MSRCTL_READY 0x40
  431. #define MSRCTL_RADARDETECT 0x20
  432. #define MSRCTL_EN 0x10
  433. #define MSRCTL_QUIETTXCHK 0x08
  434. #define MSRCTL_QUIETRPT 0x04
  435. #define MSRCTL_QUIETINT 0x02
  436. #define MSRCTL_QUIETEN 0x01
  437. /* Bits in the MSRCTL1 register */
  438. #define MSRCTL1_TXPWR 0x08
  439. #define MSRCTL1_CSAPAREN 0x04
  440. #define MSRCTL1_TXPAUSE 0x01
  441. /* Loopback mode */
  442. #define MAC_LB_EXT 0x02
  443. #define MAC_LB_INTERNAL 0x01
  444. #define MAC_LB_NONE 0x00
  445. #define Default_BI 0x200
  446. /* MiscFIFO Offset */
  447. #define MISCFIFO_KEYETRY0 32
  448. #define MISCFIFO_KEYENTRYSIZE 22
  449. #define MISCFIFO_SYNINFO_IDX 10
  450. #define MISCFIFO_SYNDATA_IDX 11
  451. #define MISCFIFO_SYNDATASIZE 21
  452. /* enabled mask value of irq */
  453. #define IMR_MASK_VALUE (IMR_SOFTTIMER1 | \
  454. IMR_RXDMA1 | \
  455. IMR_RXNOBUF | \
  456. IMR_MIBNEARFULL | \
  457. IMR_SOFTINT | \
  458. IMR_FETALERR | \
  459. IMR_WATCHDOG | \
  460. IMR_SOFTTIMER | \
  461. IMR_GPIO | \
  462. IMR_TBTT | \
  463. IMR_RXDMA0 | \
  464. IMR_BNTX | \
  465. IMR_AC0DMA | \
  466. IMR_TXDMA0)
  467. /* max time out delay time */
  468. #define W_MAX_TIMEOUT 0xFFF0U
  469. /* wait time within loop */
  470. #define CB_DELAY_LOOP_WAIT 10 /* 10ms */
  471. /* revision id */
  472. #define REV_ID_VT3253_A0 0x00
  473. #define REV_ID_VT3253_A1 0x01
  474. #define REV_ID_VT3253_B0 0x08
  475. #define REV_ID_VT3253_B1 0x09
  476. /*--------------------- Export Types ------------------------------*/
  477. /*--------------------- Export Macros ------------------------------*/
  478. #define MACvRegBitsOn(iobase, byRegOfs, byBits) \
  479. do { \
  480. unsigned char byData; \
  481. VNSvInPortB(iobase + byRegOfs, &byData); \
  482. VNSvOutPortB(iobase + byRegOfs, byData | (byBits)); \
  483. } while (0)
  484. #define MACvWordRegBitsOn(iobase, byRegOfs, wBits) \
  485. do { \
  486. unsigned short wData; \
  487. VNSvInPortW(iobase + byRegOfs, &wData); \
  488. VNSvOutPortW(iobase + byRegOfs, wData | (wBits)); \
  489. } while (0)
  490. #define MACvDWordRegBitsOn(iobase, byRegOfs, dwBits) \
  491. do { \
  492. unsigned long dwData; \
  493. VNSvInPortD(iobase + byRegOfs, &dwData); \
  494. VNSvOutPortD(iobase + byRegOfs, dwData | (dwBits)); \
  495. } while (0)
  496. #define MACvRegBitsOnEx(iobase, byRegOfs, byMask, byBits) \
  497. do { \
  498. unsigned char byData; \
  499. VNSvInPortB(iobase + byRegOfs, &byData); \
  500. byData &= byMask; \
  501. VNSvOutPortB(iobase + byRegOfs, byData | (byBits)); \
  502. } while (0)
  503. #define MACvRegBitsOff(iobase, byRegOfs, byBits) \
  504. do { \
  505. unsigned char byData; \
  506. VNSvInPortB(iobase + byRegOfs, &byData); \
  507. VNSvOutPortB(iobase + byRegOfs, byData & ~(byBits)); \
  508. } while (0)
  509. #define MACvWordRegBitsOff(iobase, byRegOfs, wBits) \
  510. do { \
  511. unsigned short wData; \
  512. VNSvInPortW(iobase + byRegOfs, &wData); \
  513. VNSvOutPortW(iobase + byRegOfs, wData & ~(wBits)); \
  514. } while (0)
  515. #define MACvDWordRegBitsOff(iobase, byRegOfs, dwBits) \
  516. do { \
  517. unsigned long dwData; \
  518. VNSvInPortD(iobase + byRegOfs, &dwData); \
  519. VNSvOutPortD(iobase + byRegOfs, dwData & ~(dwBits)); \
  520. } while (0)
  521. #define MACvGetCurrRx0DescAddr(iobase, pdwCurrDescAddr) \
  522. VNSvInPortD(iobase + MAC_REG_RXDMAPTR0, \
  523. (unsigned long *)pdwCurrDescAddr)
  524. #define MACvGetCurrRx1DescAddr(iobase, pdwCurrDescAddr) \
  525. VNSvInPortD(iobase + MAC_REG_RXDMAPTR1, \
  526. (unsigned long *)pdwCurrDescAddr)
  527. #define MACvGetCurrTx0DescAddr(iobase, pdwCurrDescAddr) \
  528. VNSvInPortD(iobase + MAC_REG_TXDMAPTR0, \
  529. (unsigned long *)pdwCurrDescAddr)
  530. #define MACvGetCurrAC0DescAddr(iobase, pdwCurrDescAddr) \
  531. VNSvInPortD(iobase + MAC_REG_AC0DMAPTR, \
  532. (unsigned long *)pdwCurrDescAddr)
  533. #define MACvGetCurrSyncDescAddr(iobase, pdwCurrDescAddr) \
  534. VNSvInPortD(iobase + MAC_REG_SYNCDMAPTR, \
  535. (unsigned long *)pdwCurrDescAddr)
  536. #define MACvGetCurrATIMDescAddr(iobase, pdwCurrDescAddr) \
  537. VNSvInPortD(iobase + MAC_REG_ATIMDMAPTR, \
  538. (unsigned long *)pdwCurrDescAddr)
  539. /* set the chip with current BCN tx descriptor address */
  540. #define MACvSetCurrBCNTxDescAddr(iobase, dwCurrDescAddr) \
  541. VNSvOutPortD(iobase + MAC_REG_BCNDMAPTR, \
  542. dwCurrDescAddr)
  543. /* set the chip with current BCN length */
  544. #define MACvSetCurrBCNLength(iobase, wCurrBCNLength) \
  545. VNSvOutPortW(iobase + MAC_REG_BCNDMACTL+2, \
  546. wCurrBCNLength)
  547. #define MACvReadBSSIDAddress(iobase, pbyEtherAddr) \
  548. do { \
  549. VNSvOutPortB(iobase + MAC_REG_PAGE1SEL, 1); \
  550. VNSvInPortB(iobase + MAC_REG_BSSID0, \
  551. (unsigned char *)pbyEtherAddr); \
  552. VNSvInPortB(iobase + MAC_REG_BSSID0 + 1, \
  553. pbyEtherAddr + 1); \
  554. VNSvInPortB(iobase + MAC_REG_BSSID0 + 2, \
  555. pbyEtherAddr + 2); \
  556. VNSvInPortB(iobase + MAC_REG_BSSID0 + 3, \
  557. pbyEtherAddr + 3); \
  558. VNSvInPortB(iobase + MAC_REG_BSSID0 + 4, \
  559. pbyEtherAddr + 4); \
  560. VNSvInPortB(iobase + MAC_REG_BSSID0 + 5, \
  561. pbyEtherAddr + 5); \
  562. VNSvOutPortB(iobase + MAC_REG_PAGE1SEL, 0); \
  563. } while (0)
  564. #define MACvWriteBSSIDAddress(iobase, pbyEtherAddr) \
  565. do { \
  566. VNSvOutPortB(iobase + MAC_REG_PAGE1SEL, 1); \
  567. VNSvOutPortB(iobase + MAC_REG_BSSID0, \
  568. *(pbyEtherAddr)); \
  569. VNSvOutPortB(iobase + MAC_REG_BSSID0 + 1, \
  570. *(pbyEtherAddr + 1)); \
  571. VNSvOutPortB(iobase + MAC_REG_BSSID0 + 2, \
  572. *(pbyEtherAddr + 2)); \
  573. VNSvOutPortB(iobase + MAC_REG_BSSID0 + 3, \
  574. *(pbyEtherAddr + 3)); \
  575. VNSvOutPortB(iobase + MAC_REG_BSSID0 + 4, \
  576. *(pbyEtherAddr + 4)); \
  577. VNSvOutPortB(iobase + MAC_REG_BSSID0 + 5, \
  578. *(pbyEtherAddr + 5)); \
  579. VNSvOutPortB(iobase + MAC_REG_PAGE1SEL, 0); \
  580. } while (0)
  581. #define MACvReadEtherAddress(iobase, pbyEtherAddr) \
  582. do { \
  583. VNSvOutPortB(iobase + MAC_REG_PAGE1SEL, 1); \
  584. VNSvInPortB(iobase + MAC_REG_PAR0, \
  585. (unsigned char *)pbyEtherAddr); \
  586. VNSvInPortB(iobase + MAC_REG_PAR0 + 1, \
  587. pbyEtherAddr + 1); \
  588. VNSvInPortB(iobase + MAC_REG_PAR0 + 2, \
  589. pbyEtherAddr + 2); \
  590. VNSvInPortB(iobase + MAC_REG_PAR0 + 3, \
  591. pbyEtherAddr + 3); \
  592. VNSvInPortB(iobase + MAC_REG_PAR0 + 4, \
  593. pbyEtherAddr + 4); \
  594. VNSvInPortB(iobase + MAC_REG_PAR0 + 5, \
  595. pbyEtherAddr + 5); \
  596. VNSvOutPortB(iobase + MAC_REG_PAGE1SEL, 0); \
  597. } while (0)
  598. #define MACvWriteEtherAddress(iobase, pbyEtherAddr) \
  599. do { \
  600. VNSvOutPortB(iobase + MAC_REG_PAGE1SEL, 1); \
  601. VNSvOutPortB(iobase + MAC_REG_PAR0, \
  602. *pbyEtherAddr); \
  603. VNSvOutPortB(iobase + MAC_REG_PAR0 + 1, \
  604. *(pbyEtherAddr + 1)); \
  605. VNSvOutPortB(iobase + MAC_REG_PAR0 + 2, \
  606. *(pbyEtherAddr + 2)); \
  607. VNSvOutPortB(iobase + MAC_REG_PAR0 + 3, \
  608. *(pbyEtherAddr + 3)); \
  609. VNSvOutPortB(iobase + MAC_REG_PAR0 + 4, \
  610. *(pbyEtherAddr + 4)); \
  611. VNSvOutPortB(iobase + MAC_REG_PAR0 + 5, \
  612. *(pbyEtherAddr + 5)); \
  613. VNSvOutPortB(iobase + MAC_REG_PAGE1SEL, 0); \
  614. } while (0)
  615. #define MACvClearISR(iobase) \
  616. VNSvOutPortD(iobase + MAC_REG_ISR, IMR_MASK_VALUE)
  617. #define MACvStart(iobase) \
  618. VNSvOutPortB(iobase + MAC_REG_HOSTCR, \
  619. (HOSTCR_MACEN | HOSTCR_RXON | HOSTCR_TXON))
  620. #define MACvRx0PerPktMode(iobase) \
  621. VNSvOutPortD(iobase + MAC_REG_RXDMACTL0, RX_PERPKT)
  622. #define MACvRx0BufferFillMode(iobase) \
  623. VNSvOutPortD(iobase + MAC_REG_RXDMACTL0, RX_PERPKTCLR)
  624. #define MACvRx1PerPktMode(iobase) \
  625. VNSvOutPortD(iobase + MAC_REG_RXDMACTL1, RX_PERPKT)
  626. #define MACvRx1BufferFillMode(iobase) \
  627. VNSvOutPortD(iobase + MAC_REG_RXDMACTL1, RX_PERPKTCLR)
  628. #define MACvRxOn(iobase) \
  629. MACvRegBitsOn(iobase, MAC_REG_HOSTCR, HOSTCR_RXON)
  630. #define MACvReceive0(iobase) \
  631. do { \
  632. unsigned long dwData; \
  633. VNSvInPortD(iobase + MAC_REG_RXDMACTL0, &dwData); \
  634. if (dwData & DMACTL_RUN) \
  635. VNSvOutPortD(iobase + MAC_REG_RXDMACTL0, DMACTL_WAKE); \
  636. else \
  637. VNSvOutPortD(iobase + MAC_REG_RXDMACTL0, DMACTL_RUN); \
  638. } while (0)
  639. #define MACvReceive1(iobase) \
  640. do { \
  641. unsigned long dwData; \
  642. VNSvInPortD(iobase + MAC_REG_RXDMACTL1, &dwData); \
  643. if (dwData & DMACTL_RUN) \
  644. VNSvOutPortD(iobase + MAC_REG_RXDMACTL1, DMACTL_WAKE); \
  645. else \
  646. VNSvOutPortD(iobase + MAC_REG_RXDMACTL1, DMACTL_RUN); \
  647. } while (0)
  648. #define MACvTxOn(iobase) \
  649. MACvRegBitsOn(iobase, MAC_REG_HOSTCR, HOSTCR_TXON)
  650. #define MACvTransmit0(iobase) \
  651. do { \
  652. unsigned long dwData; \
  653. VNSvInPortD(iobase + MAC_REG_TXDMACTL0, &dwData); \
  654. if (dwData & DMACTL_RUN) \
  655. VNSvOutPortD(iobase + MAC_REG_TXDMACTL0, DMACTL_WAKE); \
  656. else \
  657. VNSvOutPortD(iobase + MAC_REG_TXDMACTL0, DMACTL_RUN); \
  658. } while (0)
  659. #define MACvTransmitAC0(iobase) \
  660. do { \
  661. unsigned long dwData; \
  662. VNSvInPortD(iobase + MAC_REG_AC0DMACTL, &dwData); \
  663. if (dwData & DMACTL_RUN) \
  664. VNSvOutPortD(iobase + MAC_REG_AC0DMACTL, DMACTL_WAKE); \
  665. else \
  666. VNSvOutPortD(iobase + MAC_REG_AC0DMACTL, DMACTL_RUN); \
  667. } while (0)
  668. #define MACvTransmitSYNC(iobase) \
  669. do { \
  670. unsigned long dwData; \
  671. VNSvInPortD(iobase + MAC_REG_SYNCDMACTL, &dwData); \
  672. if (dwData & DMACTL_RUN) \
  673. VNSvOutPortD(iobase + MAC_REG_SYNCDMACTL, DMACTL_WAKE); \
  674. else \
  675. VNSvOutPortD(iobase + MAC_REG_SYNCDMACTL, DMACTL_RUN); \
  676. } while (0)
  677. #define MACvTransmitATIM(iobase) \
  678. do { \
  679. unsigned long dwData; \
  680. VNSvInPortD(iobase + MAC_REG_ATIMDMACTL, &dwData); \
  681. if (dwData & DMACTL_RUN) \
  682. VNSvOutPortD(iobase + MAC_REG_ATIMDMACTL, DMACTL_WAKE); \
  683. else \
  684. VNSvOutPortD(iobase + MAC_REG_ATIMDMACTL, DMACTL_RUN); \
  685. } while (0)
  686. #define MACvTransmitBCN(iobase) \
  687. VNSvOutPortB(iobase + MAC_REG_BCNDMACTL, BEACON_READY)
  688. #define MACvClearStckDS(iobase) \
  689. do { \
  690. unsigned char byOrgValue; \
  691. VNSvInPortB(iobase + MAC_REG_STICKHW, &byOrgValue); \
  692. byOrgValue = byOrgValue & 0xFC; \
  693. VNSvOutPortB(iobase + MAC_REG_STICKHW, byOrgValue); \
  694. } while (0)
  695. #define MACvReadISR(iobase, pdwValue) \
  696. VNSvInPortD(iobase + MAC_REG_ISR, pdwValue)
  697. #define MACvWriteISR(iobase, dwValue) \
  698. VNSvOutPortD(iobase + MAC_REG_ISR, dwValue)
  699. #define MACvIntEnable(iobase, dwMask) \
  700. VNSvOutPortD(iobase + MAC_REG_IMR, dwMask)
  701. #define MACvIntDisable(iobase) \
  702. VNSvOutPortD(iobase + MAC_REG_IMR, 0)
  703. #define MACvSelectPage0(iobase) \
  704. VNSvOutPortB(iobase + MAC_REG_PAGE1SEL, 0)
  705. #define MACvSelectPage1(iobase) \
  706. VNSvOutPortB(iobase + MAC_REG_PAGE1SEL, 1)
  707. #define MACvReadMIBCounter(iobase, pdwCounter) \
  708. VNSvInPortD(iobase + MAC_REG_MIBCNTR, pdwCounter)
  709. #define MACvPwrEvntDisable(iobase) \
  710. VNSvOutPortW(iobase + MAC_REG_WAKEUPEN0, 0x0000)
  711. #define MACvEnableProtectMD(iobase) \
  712. do { \
  713. unsigned long dwOrgValue; \
  714. VNSvInPortD(iobase + MAC_REG_ENCFG, &dwOrgValue); \
  715. dwOrgValue = dwOrgValue | EnCFG_ProtectMd; \
  716. VNSvOutPortD(iobase + MAC_REG_ENCFG, dwOrgValue); \
  717. } while (0)
  718. #define MACvDisableProtectMD(iobase) \
  719. do { \
  720. unsigned long dwOrgValue; \
  721. VNSvInPortD(iobase + MAC_REG_ENCFG, &dwOrgValue); \
  722. dwOrgValue = dwOrgValue & ~EnCFG_ProtectMd; \
  723. VNSvOutPortD(iobase + MAC_REG_ENCFG, dwOrgValue); \
  724. } while (0)
  725. #define MACvEnableBarkerPreambleMd(iobase) \
  726. do { \
  727. unsigned long dwOrgValue; \
  728. VNSvInPortD(iobase + MAC_REG_ENCFG, &dwOrgValue); \
  729. dwOrgValue = dwOrgValue | EnCFG_BarkerPream; \
  730. VNSvOutPortD(iobase + MAC_REG_ENCFG, dwOrgValue); \
  731. } while (0)
  732. #define MACvDisableBarkerPreambleMd(iobase) \
  733. do { \
  734. unsigned long dwOrgValue; \
  735. VNSvInPortD(iobase + MAC_REG_ENCFG, &dwOrgValue); \
  736. dwOrgValue = dwOrgValue & ~EnCFG_BarkerPream; \
  737. VNSvOutPortD(iobase + MAC_REG_ENCFG, dwOrgValue); \
  738. } while (0)
  739. #define MACvSetBBType(iobase, byTyp) \
  740. do { \
  741. unsigned long dwOrgValue; \
  742. VNSvInPortD(iobase + MAC_REG_ENCFG, &dwOrgValue); \
  743. dwOrgValue = dwOrgValue & ~EnCFG_BBType_MASK; \
  744. dwOrgValue = dwOrgValue | (unsigned long)byTyp; \
  745. VNSvOutPortD(iobase + MAC_REG_ENCFG, dwOrgValue); \
  746. } while (0)
  747. #define MACvReadATIMW(iobase, pwCounter) \
  748. VNSvInPortW(iobase + MAC_REG_AIDATIM, pwCounter)
  749. #define MACvWriteATIMW(iobase, wCounter) \
  750. VNSvOutPortW(iobase + MAC_REG_AIDATIM, wCounter)
  751. #define MACvWriteCRC16_128(iobase, byRegOfs, wCRC) \
  752. do { \
  753. VNSvOutPortB(iobase + MAC_REG_PAGE1SEL, 1); \
  754. VNSvOutPortW(iobase + byRegOfs, wCRC); \
  755. VNSvOutPortB(iobase + MAC_REG_PAGE1SEL, 0); \
  756. } while (0)
  757. #define MACvGPIOIn(iobase, pbyValue) \
  758. VNSvInPortB(iobase + MAC_REG_GPIOCTL1, pbyValue)
  759. #define MACvSetRFLE_LatchBase(iobase) \
  760. MACvWordRegBitsOn(iobase, MAC_REG_SOFTPWRCTL, SOFTPWRCTL_RFLEOPT)
  761. bool MACbIsRegBitsOn(struct vnt_private *priv, unsigned char byRegOfs,
  762. unsigned char byTestBits);
  763. bool MACbIsRegBitsOff(struct vnt_private *priv, unsigned char byRegOfs,
  764. unsigned char byTestBits);
  765. bool MACbIsIntDisable(struct vnt_private *priv);
  766. void MACvSetShortRetryLimit(struct vnt_private *priv, unsigned char byRetryLimit);
  767. void MACvSetLongRetryLimit(struct vnt_private *priv, unsigned char byRetryLimit);
  768. void MACvGetLongRetryLimit(struct vnt_private *priv,
  769. unsigned char *pbyRetryLimit);
  770. void MACvSetLoopbackMode(struct vnt_private *priv, unsigned char byLoopbackMode);
  771. void MACvSaveContext(struct vnt_private *priv, unsigned char *pbyCxtBuf);
  772. void MACvRestoreContext(struct vnt_private *priv, unsigned char *pbyCxtBuf);
  773. bool MACbSoftwareReset(struct vnt_private *priv);
  774. bool MACbSafeSoftwareReset(struct vnt_private *priv);
  775. bool MACbSafeRxOff(struct vnt_private *priv);
  776. bool MACbSafeTxOff(struct vnt_private *priv);
  777. bool MACbSafeStop(struct vnt_private *priv);
  778. bool MACbShutdown(struct vnt_private *priv);
  779. void MACvInitialize(struct vnt_private *priv);
  780. void MACvSetCurrRx0DescAddr(struct vnt_private *priv,
  781. u32 curr_desc_addr);
  782. void MACvSetCurrRx1DescAddr(struct vnt_private *priv,
  783. u32 curr_desc_addr);
  784. void MACvSetCurrTXDescAddr(int iTxType, struct vnt_private *priv,
  785. u32 curr_desc_addr);
  786. void MACvSetCurrTx0DescAddrEx(struct vnt_private *priv,
  787. u32 curr_desc_addr);
  788. void MACvSetCurrAC0DescAddrEx(struct vnt_private *priv,
  789. u32 curr_desc_addr);
  790. void MACvSetCurrSyncDescAddrEx(struct vnt_private *priv,
  791. u32 curr_desc_addr);
  792. void MACvSetCurrATIMDescAddrEx(struct vnt_private *priv,
  793. u32 curr_desc_addr);
  794. void MACvTimer0MicroSDelay(struct vnt_private *priv, unsigned int uDelay);
  795. void MACvOneShotTimer1MicroSec(struct vnt_private *priv, unsigned int uDelayTime);
  796. void MACvSetMISCFifo(struct vnt_private *priv, unsigned short wOffset,
  797. u32 dwData);
  798. bool MACbPSWakeup(struct vnt_private *priv);
  799. void MACvSetKeyEntry(struct vnt_private *priv, unsigned short wKeyCtl,
  800. unsigned int uEntryIdx, unsigned int uKeyIdx,
  801. unsigned char *pbyAddr, u32 *pdwKey,
  802. unsigned char byLocalID);
  803. void MACvDisableKeyEntry(struct vnt_private *priv, unsigned int uEntryIdx);
  804. #endif /* __MAC_H__ */