mac.h 43 KB

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