blob: 0bf93759b6af9c1b106709b31277d3f981342c89 [file] [log] [blame]
Forest Bond5449c682009-04-25 10:30:44 -04001/*
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
Jim Lieb612822f2009-08-12 14:54:03 -070027 *
Forest Bond5449c682009-04-25 10:30:44 -040028 * 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
Forest Bond5449c682009-04-25 10:30:44 -040032 */
33
34#ifndef __MAC_H__
35#define __MAC_H__
36
Forest Bond5449c682009-04-25 10:30:44 -040037#include "ttype.h"
Forest Bond5449c682009-04-25 10:30:44 -040038#include "tmacro.h"
Forest Bond5449c682009-04-25 10:30:44 -040039#include "upc.h"
Forest Bond5449c682009-04-25 10:30:44 -040040
41/*--------------------- Export Definitions -------------------------*/
42//
43// Registers in the MAC
44//
45#define MAC_MAX_CONTEXT_SIZE_PAGE0 256
46#define MAC_MAX_CONTEXT_SIZE_PAGE1 128
Forest Bond5449c682009-04-25 10:30:44 -040047
48// Registers not related to 802.11b
49#define MAC_REG_BCFG0 0x00
50#define MAC_REG_BCFG1 0x01
51#define MAC_REG_FCR0 0x02
52#define MAC_REG_FCR1 0x03
53#define MAC_REG_BISTCMD 0x04
54#define MAC_REG_BISTSR0 0x05
55#define MAC_REG_BISTSR1 0x06
56#define MAC_REG_BISTSR2 0x07
57#define MAC_REG_I2MCSR 0x08
58#define MAC_REG_I2MTGID 0x09
59#define MAC_REG_I2MTGAD 0x0A
60#define MAC_REG_I2MCFG 0x0B
61#define MAC_REG_I2MDIPT 0x0C
62#define MAC_REG_I2MDOPT 0x0E
63#define MAC_REG_PMC0 0x10
64#define MAC_REG_PMC1 0x11
65#define MAC_REG_STICKHW 0x12
66#define MAC_REG_LOCALID 0x14
67#define MAC_REG_TESTCFG 0x15
68#define MAC_REG_JUMPER0 0x16
69#define MAC_REG_JUMPER1 0x17
70#define MAC_REG_TMCTL0 0x18
71#define MAC_REG_TMCTL1 0x19
72#define MAC_REG_TMDATA0 0x1C
73// MAC Parameter related
74#define MAC_REG_LRT 0x20 //
75#define MAC_REG_SRT 0x21 //
76#define MAC_REG_SIFS 0x22 //
77#define MAC_REG_DIFS 0x23 //
78#define MAC_REG_EIFS 0x24 //
79#define MAC_REG_SLOT 0x25 //
80#define MAC_REG_BI 0x26 //
81#define MAC_REG_CWMAXMIN0 0x28 //
82#define MAC_REG_LINKOFFTOTM 0x2A
83#define MAC_REG_SWTMOT 0x2B
84#define MAC_REG_MIBCNTR 0x2C
85#define MAC_REG_RTSOKCNT 0x2C
86#define MAC_REG_RTSFAILCNT 0x2D
87#define MAC_REG_ACKFAILCNT 0x2E
88#define MAC_REG_FCSERRCNT 0x2F
89// TSF Related
90#define MAC_REG_TSFCNTR 0x30 //
91#define MAC_REG_NEXTTBTT 0x38 //
92#define MAC_REG_TSFOFST 0x40 //
93#define MAC_REG_TFTCTL 0x48 //
94// WMAC Control/Status Related
95#define MAC_REG_ENCFG 0x4C //
96#define MAC_REG_PAGE1SEL 0x4F //
97#define MAC_REG_CFG 0x50 //
98#define MAC_REG_TEST 0x52 //
99#define MAC_REG_HOSTCR 0x54 //
100#define MAC_REG_MACCR 0x55 //
101#define MAC_REG_RCR 0x56 //
102#define MAC_REG_TCR 0x57 //
103#define MAC_REG_IMR 0x58 //
104#define MAC_REG_ISR 0x5C
105// Power Saving Related
106#define MAC_REG_PSCFG 0x60 //
107#define MAC_REG_PSCTL 0x61 //
108#define MAC_REG_PSPWRSIG 0x62 //
109#define MAC_REG_BBCR13 0x63
110#define MAC_REG_AIDATIM 0x64
111#define MAC_REG_PWBT 0x66
112#define MAC_REG_WAKEOKTMR 0x68
113#define MAC_REG_CALTMR 0x69
114#define MAC_REG_SYNSPACCNT 0x6A
115#define MAC_REG_WAKSYNOPT 0x6B
116// Baseband/IF Control Group
117#define MAC_REG_BBREGCTL 0x6C //
118#define MAC_REG_CHANNEL 0x6D
119#define MAC_REG_BBREGADR 0x6E
120#define MAC_REG_BBREGDATA 0x6F
121#define MAC_REG_IFREGCTL 0x70 //
122#define MAC_REG_IFDATA 0x71 //
123#define MAC_REG_ITRTMSET 0x74 //
Jim Lieb612822f2009-08-12 14:54:03 -0700124#define MAC_REG_PAPEDELAY 0x77
Forest Bond5449c682009-04-25 10:30:44 -0400125#define MAC_REG_SOFTPWRCTL 0x78 //
126#define MAC_REG_GPIOCTL0 0x7A //
127#define MAC_REG_GPIOCTL1 0x7B //
128
129// MAC DMA Related Group
130#define MAC_REG_TXDMACTL0 0x7C //
131#define MAC_REG_TXDMAPTR0 0x80 //
132#define MAC_REG_AC0DMACTL 0x84 //
133#define MAC_REG_AC0DMAPTR 0x88 //
134#define MAC_REG_BCNDMACTL 0x8C //
135#define MAC_REG_BCNDMAPTR 0x90 //
136#define MAC_REG_RXDMACTL0 0x94 //
137#define MAC_REG_RXDMAPTR0 0x98 //
138#define MAC_REG_RXDMACTL1 0x9C //
139#define MAC_REG_RXDMAPTR1 0xA0 //
140#define MAC_REG_SYNCDMACTL 0xA4 //
141#define MAC_REG_SYNCDMAPTR 0xA8
142#define MAC_REG_ATIMDMACTL 0xAC
143#define MAC_REG_ATIMDMAPTR 0xB0
144// MiscFF PIO related
145#define MAC_REG_MISCFFNDEX 0xB4
146#define MAC_REG_MISCFFCTL 0xB6
147#define MAC_REG_MISCFFDATA 0xB8
148// Extend SW Timer
149#define MAC_REG_TMDATA1 0xBC
150// WOW Related Group
151#define MAC_REG_WAKEUPEN0 0xC0
152#define MAC_REG_WAKEUPEN1 0xC1
153#define MAC_REG_WAKEUPSR0 0xC2
154#define MAC_REG_WAKEUPSR1 0xC3
155#define MAC_REG_WAKE128_0 0xC4
156#define MAC_REG_WAKE128_1 0xD4
157#define MAC_REG_WAKE128_2 0xE4
158#define MAC_REG_WAKE128_3 0xF4
159
160/////////////// Page 1 ///////////////////
161#define MAC_REG_CRC_128_0 0x04
162#define MAC_REG_CRC_128_1 0x06
163#define MAC_REG_CRC_128_2 0x08
164#define MAC_REG_CRC_128_3 0x0A
165// MAC Configuration Group
166#define MAC_REG_PAR0 0x0C
167#define MAC_REG_PAR4 0x10
168#define MAC_REG_BSSID0 0x14
169#define MAC_REG_BSSID4 0x18
170#define MAC_REG_MAR0 0x1C
171#define MAC_REG_MAR4 0x20
172// MAC RSPPKT INFO Group
173#define MAC_REG_RSPINF_B_1 0x24
174#define MAC_REG_RSPINF_B_2 0x28
175#define MAC_REG_RSPINF_B_5 0x2C
176#define MAC_REG_RSPINF_B_11 0x30
177#define MAC_REG_RSPINF_A_6 0x34
178#define MAC_REG_RSPINF_A_9 0x36
179#define MAC_REG_RSPINF_A_12 0x38
180#define MAC_REG_RSPINF_A_18 0x3A
181#define MAC_REG_RSPINF_A_24 0x3C
182#define MAC_REG_RSPINF_A_36 0x3E
183#define MAC_REG_RSPINF_A_48 0x40
184#define MAC_REG_RSPINF_A_54 0x42
185#define MAC_REG_RSPINF_A_72 0x44
186
187// 802.11h relative
188#define MAC_REG_QUIETINIT 0x60
189#define MAC_REG_QUIETGAP 0x62
190#define MAC_REG_QUIETDUR 0x64
191#define MAC_REG_MSRCTL 0x66
192#define MAC_REG_MSRBBSTS 0x67
193#define MAC_REG_MSRSTART 0x68
194#define MAC_REG_MSRDURATION 0x70
195#define MAC_REG_CCAFRACTION 0x72
196#define MAC_REG_PWRCCK 0x73
197#define MAC_REG_PWROFDM 0x7C
198
Forest Bond5449c682009-04-25 10:30:44 -0400199//
200// Bits in the BCFG0 register
201//
202#define BCFG0_PERROFF 0x40
203#define BCFG0_MRDMDIS 0x20
204#define BCFG0_MRDLDIS 0x10
205#define BCFG0_MWMEN 0x08
206#define BCFG0_VSERREN 0x02
207#define BCFG0_LATMEN 0x01
208
209//
210// Bits in the BCFG1 register
211//
212#define BCFG1_CFUNOPT 0x80
213#define BCFG1_CREQOPT 0x40
214#define BCFG1_DMA8 0x10
215#define BCFG1_ARBITOPT 0x08
216#define BCFG1_PCIMEN 0x04
217#define BCFG1_MIOEN 0x02
218#define BCFG1_CISDLYEN 0x01
219
220// Bits in RAMBIST registers
221#define BISTCMD_TSTPAT5 0x00 //
222#define BISTCMD_TSTPATA 0x80 //
223#define BISTCMD_TSTERR 0x20 //
224#define BISTCMD_TSTPATF 0x18 //
225#define BISTCMD_TSTPAT0 0x10 //
226#define BISTCMD_TSTMODE 0x04 //
227#define BISTCMD_TSTITTX 0x03 //
228#define BISTCMD_TSTATRX 0x02 //
229#define BISTCMD_TSTATTX 0x01 //
230#define BISTCMD_TSTRX 0x00 //
231#define BISTSR0_BISTGO 0x01 //
232#define BISTSR1_TSTSR 0x01 //
233#define BISTSR2_CMDPRTEN 0x02 //
234#define BISTSR2_RAMTSTEN 0x01 //
235
236//
237// Bits in the I2MCFG EEPROM register
238//
239#define I2MCFG_BOUNDCTL 0x80
240#define I2MCFG_WAITCTL 0x20
241#define I2MCFG_SCLOECTL 0x10
242#define I2MCFG_WBUSYCTL 0x08
243#define I2MCFG_NORETRY 0x04
244#define I2MCFG_I2MLDSEQ 0x02
245#define I2MCFG_I2CMFAST 0x01
246
247//
248// Bits in the I2MCSR EEPROM register
249//
250#define I2MCSR_EEMW 0x80
251#define I2MCSR_EEMR 0x40
252#define I2MCSR_AUTOLD 0x08
253#define I2MCSR_NACK 0x02
254#define I2MCSR_DONE 0x01
255
256//
257// Bits in the PMC1 register
258//
259#define SPS_RST 0x80
260#define PCISTIKY 0x40
261#define PME_OVR 0x02
262
263//
264// Bits in the STICKYHW register
265//
266#define STICKHW_DS1_SHADOW 0x02
267#define STICKHW_DS0_SHADOW 0x01
268
269//
270// Bits in the TMCTL register
271//
272#define TMCTL_TSUSP 0x04
273#define TMCTL_TMD 0x02
274#define TMCTL_TE 0x01
275
276//
277// Bits in the TFTCTL register
278//
279#define TFTCTL_HWUTSF 0x80 //
280#define TFTCTL_TBTTSYNC 0x40
281#define TFTCTL_HWUTSFEN 0x20
282#define TFTCTL_TSFCNTRRD 0x10 //
283#define TFTCTL_TBTTSYNCEN 0x08 //
284#define TFTCTL_TSFSYNCEN 0x04 //
285#define TFTCTL_TSFCNTRST 0x02 //
286#define TFTCTL_TSFCNTREN 0x01 //
287
288//
289// Bits in the EnhanceCFG register
290//
291#define EnCFG_BarkerPream 0x00020000
292#define EnCFG_NXTBTTCFPSTR 0x00010000
Forest Bond5449c682009-04-25 10:30:44 -0400293#define EnCFG_BcnSusClr 0x00000200
294#define EnCFG_BcnSusInd 0x00000100
Forest Bond5449c682009-04-25 10:30:44 -0400295#define EnCFG_CFP_ProtectEn 0x00000040
296#define EnCFG_ProtectMd 0x00000020
297#define EnCFG_HwParCFP 0x00000010
Forest Bond5449c682009-04-25 10:30:44 -0400298#define EnCFG_CFNULRSP 0x00000004
299#define EnCFG_BBType_MASK 0x00000003
300#define EnCFG_BBType_g 0x00000002
301#define EnCFG_BBType_b 0x00000001
302#define EnCFG_BBType_a 0x00000000
303
304//
305// Bits in the Page1Sel register
306//
307#define PAGE1_SEL 0x01
308
309//
310// Bits in the CFG register
311//
312#define CFG_TKIPOPT 0x80
313#define CFG_RXDMAOPT 0x40
314#define CFG_TMOT_SW 0x20
315#define CFG_TMOT_HWLONG 0x10
316#define CFG_TMOT_HW 0x00
317#define CFG_CFPENDOPT 0x08
318#define CFG_BCNSUSEN 0x04
319#define CFG_NOTXTIMEOUT 0x02
320#define CFG_NOBUFOPT 0x01
321
322//
323// Bits in the TEST register
324//
325#define TEST_LBEXT 0x80 //
326#define TEST_LBINT 0x40 //
327#define TEST_LBNONE 0x00 //
328#define TEST_SOFTINT 0x20 //
329#define TEST_CONTTX 0x10 //
330#define TEST_TXPE 0x08 //
331#define TEST_NAVDIS 0x04 //
332#define TEST_NOCTS 0x02 //
333#define TEST_NOACK 0x01 //
334
335//
336// Bits in the HOSTCR register
337//
338#define HOSTCR_TXONST 0x80 //
339#define HOSTCR_RXONST 0x40 //
340#define HOSTCR_ADHOC 0x20 // Network Type 1 = Ad-hoc
341#define HOSTCR_AP 0x10 // Port Type 1 = AP
342#define HOSTCR_TXON 0x08 //0000 1000
343#define HOSTCR_RXON 0x04 //0000 0100
344#define HOSTCR_MACEN 0x02 //0000 0010
345#define HOSTCR_SOFTRST 0x01 //0000 0001
346
347//
348// Bits in the MACCR register
349//
350#define MACCR_SYNCFLUSHOK 0x04 //
351#define MACCR_SYNCFLUSH 0x02 //
352#define MACCR_CLRNAV 0x01 //
353
354// Bits in the MAC_REG_GPIOCTL0 register
355//
356#define LED_ACTSET 0x01 //
357#define LED_RFOFF 0x02 //
358#define LED_NOCONNECT 0x04 //
359//
360// Bits in the RCR register
361//
362#define RCR_SSID 0x80
363#define RCR_RXALLTYPE 0x40 //
364#define RCR_UNICAST 0x20 //
365#define RCR_BROADCAST 0x10 //
366#define RCR_MULTICAST 0x08 //
367#define RCR_WPAERR 0x04 //
368#define RCR_ERRCRC 0x02 //
369#define RCR_BSSID 0x01 //
370
371//
372// Bits in the TCR register
373//
374#define TCR_SYNCDCFOPT 0x02 //
375#define TCR_AUTOBCNTX 0x01 // Beacon automatically transmit enable
376
377//
378// Bits in the IMR register
379//
380#define IMR_MEASURESTART 0x80000000 //
381#define IMR_QUIETSTART 0x20000000 //
382#define IMR_RADARDETECT 0x10000000 //
383#define IMR_MEASUREEND 0x08000000 //
384#define IMR_SOFTTIMER1 0x00200000 //
Forest Bond5449c682009-04-25 10:30:44 -0400385#define IMR_RXDMA1 0x00001000 //0000 0000 0001 0000 0000 0000
386#define IMR_RXNOBUF 0x00000800 //
387#define IMR_MIBNEARFULL 0x00000400 //
388#define IMR_SOFTINT 0x00000200 //
389#define IMR_FETALERR 0x00000100 //
390#define IMR_WATCHDOG 0x00000080 //
391#define IMR_SOFTTIMER 0x00000040 //
392#define IMR_GPIO 0x00000020 //
393#define IMR_TBTT 0x00000010 //
394#define IMR_RXDMA0 0x00000008 //
395#define IMR_BNTX 0x00000004 //
396#define IMR_AC0DMA 0x00000002 //
397#define IMR_TXDMA0 0x00000001 //
398
Forest Bond5449c682009-04-25 10:30:44 -0400399//
400// Bits in the ISR register
401//
402
403#define ISR_MEASURESTART 0x80000000 //
404#define ISR_QUIETSTART 0x20000000 //
405#define ISR_RADARDETECT 0x10000000 //
406#define ISR_MEASUREEND 0x08000000 //
407#define ISR_SOFTTIMER1 0x00200000 //
Forest Bond5449c682009-04-25 10:30:44 -0400408#define ISR_RXDMA1 0x00001000 //0000 0000 0001 0000 0000 0000
409#define ISR_RXNOBUF 0x00000800 //0000 0000 0000 1000 0000 0000
410#define ISR_MIBNEARFULL 0x00000400 //0000 0000 0000 0100 0000 0000
411#define ISR_SOFTINT 0x00000200 //
412#define ISR_FETALERR 0x00000100 //
413#define ISR_WATCHDOG 0x00000080 //
414#define ISR_SOFTTIMER 0x00000040 //
415#define ISR_GPIO 0x00000020 //
416#define ISR_TBTT 0x00000010 //
417#define ISR_RXDMA0 0x00000008 //
418#define ISR_BNTX 0x00000004 //
419#define ISR_AC0DMA 0x00000002 //
420#define ISR_TXDMA0 0x00000001 //
421
Forest Bond5449c682009-04-25 10:30:44 -0400422//
423// Bits in the PSCFG register
424//
425#define PSCFG_PHILIPMD 0x40 //
426#define PSCFG_WAKECALEN 0x20 //
427#define PSCFG_WAKETMREN 0x10 //
428#define PSCFG_BBPSPROG 0x08 //
429#define PSCFG_WAKESYN 0x04 //
430#define PSCFG_SLEEPSYN 0x02 //
431#define PSCFG_AUTOSLEEP 0x01 //
432
433//
434// Bits in the PSCTL register
435//
436#define PSCTL_WAKEDONE 0x20 //
437#define PSCTL_PS 0x10 //
438#define PSCTL_GO2DOZE 0x08 //
439#define PSCTL_LNBCN 0x04 //
440#define PSCTL_ALBCN 0x02 //
441#define PSCTL_PSEN 0x01 //
442
443//
444// Bits in the PSPWSIG register
445//
446#define PSSIG_WPE3 0x80 //
447#define PSSIG_WPE2 0x40 //
448#define PSSIG_WPE1 0x20 //
449#define PSSIG_WRADIOPE 0x10 //
450#define PSSIG_SPE3 0x08 //
451#define PSSIG_SPE2 0x04 //
452#define PSSIG_SPE1 0x02 //
453#define PSSIG_SRADIOPE 0x01 //
454
455//
456// Bits in the BBREGCTL register
457//
458#define BBREGCTL_DONE 0x04 //
459#define BBREGCTL_REGR 0x02 //
460#define BBREGCTL_REGW 0x01 //
461
462//
463// Bits in the IFREGCTL register
464//
465#define IFREGCTL_DONE 0x04 //
466#define IFREGCTL_IFRF 0x02 //
467#define IFREGCTL_REGW 0x01 //
468
469//
470// Bits in the SOFTPWRCTL register
471//
472#define SOFTPWRCTL_RFLEOPT 0x0800 //
473#define SOFTPWRCTL_TXPEINV 0x0200 //
474#define SOFTPWRCTL_SWPECTI 0x0100 //
475#define SOFTPWRCTL_SWPAPE 0x0020 //
476#define SOFTPWRCTL_SWCALEN 0x0010 //
477#define SOFTPWRCTL_SWRADIO_PE 0x0008 //
478#define SOFTPWRCTL_SWPE2 0x0004 //
479#define SOFTPWRCTL_SWPE1 0x0002 //
480#define SOFTPWRCTL_SWPE3 0x0001 //
481
482//
483// Bits in the GPIOCTL1 register
484//
485#define GPIO1_DATA1 0x20 //
486#define GPIO1_MD1 0x10 //
487#define GPIO1_DATA0 0x02 //
488#define GPIO1_MD0 0x01 //
489
490//
491// Bits in the DMACTL register
492//
493#define DMACTL_CLRRUN 0x00080000 //
494#define DMACTL_RUN 0x00000008 //
495#define DMACTL_WAKE 0x00000004 //
496#define DMACTL_DEAD 0x00000002 //
497#define DMACTL_ACTIVE 0x00000001 //
498//
499// Bits in the RXDMACTL0 register
500//
501#define RX_PERPKT 0x00000100 //
502#define RX_PERPKTCLR 0x01000000 //
503//
504// Bits in the BCNDMACTL register
505//
506#define BEACON_READY 0x01 //
507//
508// Bits in the MISCFFCTL register
509//
510#define MISCFFCTL_WRITE 0x0001 //
511
Forest Bond5449c682009-04-25 10:30:44 -0400512//
513// Bits in WAKEUPEN0
514//
515#define WAKEUPEN0_DIRPKT 0x10
516#define WAKEUPEN0_LINKOFF 0x08
517#define WAKEUPEN0_ATIMEN 0x04
518#define WAKEUPEN0_TIMEN 0x02
519#define WAKEUPEN0_MAGICEN 0x01
520
521//
522// Bits in WAKEUPEN1
523//
524#define WAKEUPEN1_128_3 0x08
525#define WAKEUPEN1_128_2 0x04
526#define WAKEUPEN1_128_1 0x02
527#define WAKEUPEN1_128_0 0x01
528
529//
530// Bits in WAKEUPSR0
531//
532#define WAKEUPSR0_DIRPKT 0x10
533#define WAKEUPSR0_LINKOFF 0x08
534#define WAKEUPSR0_ATIMEN 0x04
535#define WAKEUPSR0_TIMEN 0x02
536#define WAKEUPSR0_MAGICEN 0x01
537
538//
539// Bits in WAKEUPSR1
540//
541#define WAKEUPSR1_128_3 0x08
542#define WAKEUPSR1_128_2 0x04
543#define WAKEUPSR1_128_1 0x02
544#define WAKEUPSR1_128_0 0x01
545
546//
547// Bits in the MAC_REG_GPIOCTL register
548//
549#define GPIO0_MD 0x01 //
550#define GPIO0_DATA 0x02 //
551#define GPIO0_INTMD 0x04 //
552#define GPIO1_MD 0x10 //
553#define GPIO1_DATA 0x20 //
554
Forest Bond5449c682009-04-25 10:30:44 -0400555//
556// Bits in the MSRCTL register
557//
558#define MSRCTL_FINISH 0x80
559#define MSRCTL_READY 0x40
560#define MSRCTL_RADARDETECT 0x20
561#define MSRCTL_EN 0x10
562#define MSRCTL_QUIETTXCHK 0x08
563#define MSRCTL_QUIETRPT 0x04
564#define MSRCTL_QUIETINT 0x02
565#define MSRCTL_QUIETEN 0x01
566//
567// Bits in the MSRCTL1 register
568//
569#define MSRCTL1_TXPWR 0x08
570#define MSRCTL1_CSAPAREN 0x04
571#define MSRCTL1_TXPAUSE 0x01
572
Forest Bond5449c682009-04-25 10:30:44 -0400573// Loopback mode
574#define MAC_LB_EXT 0x02 //
575#define MAC_LB_INTERNAL 0x01 //
576#define MAC_LB_NONE 0x00 //
577
578// Ethernet address filter type
579#define PKT_TYPE_NONE 0x00 // turn off receiver
580#define PKT_TYPE_ALL_MULTICAST 0x80
581#define PKT_TYPE_PROMISCUOUS 0x40
Justin P. Mattock789d1ae2012-08-20 08:43:13 -0700582#define PKT_TYPE_DIRECTED 0x20 // obsolete, directed address is always accepted
Forest Bond5449c682009-04-25 10:30:44 -0400583#define PKT_TYPE_BROADCAST 0x10
584#define PKT_TYPE_MULTICAST 0x08
585#define PKT_TYPE_ERROR_WPA 0x04
586#define PKT_TYPE_ERROR_CRC 0x02
587#define PKT_TYPE_BSSID 0x01
588
589#define Default_BI 0x200
590
Forest Bond5449c682009-04-25 10:30:44 -0400591// MiscFIFO Offset
592#define MISCFIFO_KEYETRY0 32
593#define MISCFIFO_KEYENTRYSIZE 22
594#define MISCFIFO_SYNINFO_IDX 10
595#define MISCFIFO_SYNDATA_IDX 11
596#define MISCFIFO_SYNDATASIZE 21
597
598// enabled mask value of irq
Joe Perchesc3504bf2013-03-18 10:44:55 -0700599#define IMR_MASK_VALUE (IMR_SOFTTIMER1 | \
600 IMR_RXDMA1 | \
601 IMR_RXNOBUF | \
602 IMR_MIBNEARFULL | \
603 IMR_SOFTINT | \
604 IMR_FETALERR | \
605 IMR_WATCHDOG | \
606 IMR_SOFTTIMER | \
607 IMR_GPIO | \
608 IMR_TBTT | \
609 IMR_RXDMA0 | \
610 IMR_BNTX | \
611 IMR_AC0DMA | \
612 IMR_TXDMA0)
Forest Bond5449c682009-04-25 10:30:44 -0400613
614// max time out delay time
615#define W_MAX_TIMEOUT 0xFFF0U //
616
617// wait time within loop
618#define CB_DELAY_LOOP_WAIT 10 // 10ms
619
620//
621// revision id
622//
623#define REV_ID_VT3253_A0 0x00
624#define REV_ID_VT3253_A1 0x01
625#define REV_ID_VT3253_B0 0x08
626#define REV_ID_VT3253_B1 0x09
627
628/*--------------------- Export Types ------------------------------*/
629
630/*--------------------- Export Macros ------------------------------*/
631
Joe Perchesc3504bf2013-03-18 10:44:55 -0700632#define MACvRegBitsOn(dwIoBase, byRegOfs, byBits) \
Joe Perchesbda2a442013-03-18 20:55:40 -0700633do { \
634 unsigned char byData; \
635 VNSvInPortB(dwIoBase + byRegOfs, &byData); \
636 VNSvOutPortB(dwIoBase + byRegOfs, byData | (byBits)); \
637} while (0)
Forest Bond5449c682009-04-25 10:30:44 -0400638
Joe Perchesc3504bf2013-03-18 10:44:55 -0700639#define MACvWordRegBitsOn(dwIoBase, byRegOfs, wBits) \
Joe Perchesbda2a442013-03-18 20:55:40 -0700640do { \
641 unsigned short wData; \
642 VNSvInPortW(dwIoBase + byRegOfs, &wData); \
643 VNSvOutPortW(dwIoBase + byRegOfs, wData | (wBits)); \
644} while (0)
Forest Bond5449c682009-04-25 10:30:44 -0400645
Joe Perchesc3504bf2013-03-18 10:44:55 -0700646#define MACvDWordRegBitsOn(dwIoBase, byRegOfs, dwBits) \
Joe Perchesbda2a442013-03-18 20:55:40 -0700647do { \
648 unsigned long dwData; \
649 VNSvInPortD(dwIoBase + byRegOfs, &dwData); \
650 VNSvOutPortD(dwIoBase + byRegOfs, dwData | (dwBits)); \
651} while (0)
Forest Bond5449c682009-04-25 10:30:44 -0400652
Joe Perchesc3504bf2013-03-18 10:44:55 -0700653#define MACvRegBitsOnEx(dwIoBase, byRegOfs, byMask, byBits) \
Joe Perchesbda2a442013-03-18 20:55:40 -0700654do { \
655 unsigned char byData; \
656 VNSvInPortB(dwIoBase + byRegOfs, &byData); \
657 byData &= byMask; \
658 VNSvOutPortB(dwIoBase + byRegOfs, byData | (byBits)); \
659} while (0)
Forest Bond5449c682009-04-25 10:30:44 -0400660
Joe Perchesc3504bf2013-03-18 10:44:55 -0700661#define MACvRegBitsOff(dwIoBase, byRegOfs, byBits) \
Joe Perchesbda2a442013-03-18 20:55:40 -0700662do { \
663 unsigned char byData; \
664 VNSvInPortB(dwIoBase + byRegOfs, &byData); \
665 VNSvOutPortB(dwIoBase + byRegOfs, byData & ~(byBits)); \
666} while (0)
Forest Bond5449c682009-04-25 10:30:44 -0400667
Joe Perchesc3504bf2013-03-18 10:44:55 -0700668#define MACvWordRegBitsOff(dwIoBase, byRegOfs, wBits) \
Joe Perchesbda2a442013-03-18 20:55:40 -0700669do { \
670 unsigned short wData; \
671 VNSvInPortW(dwIoBase + byRegOfs, &wData); \
672 VNSvOutPortW(dwIoBase + byRegOfs, wData & ~(wBits)); \
673} while (0)
Forest Bond5449c682009-04-25 10:30:44 -0400674
Joe Perchesc3504bf2013-03-18 10:44:55 -0700675#define MACvDWordRegBitsOff(dwIoBase, byRegOfs, dwBits) \
Joe Perchesbda2a442013-03-18 20:55:40 -0700676do { \
677 unsigned long dwData; \
678 VNSvInPortD(dwIoBase + byRegOfs, &dwData); \
679 VNSvOutPortD(dwIoBase + byRegOfs, dwData & ~(dwBits)); \
680} while (0)
Forest Bond5449c682009-04-25 10:30:44 -0400681
Joe Perchesc3504bf2013-03-18 10:44:55 -0700682#define MACvGetCurrRx0DescAddr(dwIoBase, pdwCurrDescAddr) \
Joe Perchesbda2a442013-03-18 20:55:40 -0700683 VNSvInPortD(dwIoBase + MAC_REG_RXDMAPTR0, \
684 (unsigned long *)pdwCurrDescAddr)
Forest Bond5449c682009-04-25 10:30:44 -0400685
Joe Perchesc3504bf2013-03-18 10:44:55 -0700686#define MACvGetCurrRx1DescAddr(dwIoBase, pdwCurrDescAddr) \
Joe Perchesbda2a442013-03-18 20:55:40 -0700687 VNSvInPortD(dwIoBase + MAC_REG_RXDMAPTR1, \
688 (unsigned long *)pdwCurrDescAddr)
Forest Bond5449c682009-04-25 10:30:44 -0400689
Joe Perchesc3504bf2013-03-18 10:44:55 -0700690#define MACvGetCurrTx0DescAddr(dwIoBase, pdwCurrDescAddr) \
Joe Perchesbda2a442013-03-18 20:55:40 -0700691 VNSvInPortD(dwIoBase + MAC_REG_TXDMAPTR0, \
692 (unsigned long *)pdwCurrDescAddr)
Forest Bond5449c682009-04-25 10:30:44 -0400693
Joe Perchesc3504bf2013-03-18 10:44:55 -0700694#define MACvGetCurrAC0DescAddr(dwIoBase, pdwCurrDescAddr) \
Joe Perchesbda2a442013-03-18 20:55:40 -0700695 VNSvInPortD(dwIoBase + MAC_REG_AC0DMAPTR, \
696 (unsigned long *)pdwCurrDescAddr)
Forest Bond5449c682009-04-25 10:30:44 -0400697
Joe Perchesc3504bf2013-03-18 10:44:55 -0700698#define MACvGetCurrSyncDescAddr(dwIoBase, pdwCurrDescAddr) \
Joe Perchesbda2a442013-03-18 20:55:40 -0700699 VNSvInPortD(dwIoBase + MAC_REG_SYNCDMAPTR, \
700 (unsigned long *)pdwCurrDescAddr)
Forest Bond5449c682009-04-25 10:30:44 -0400701
Joe Perchesc3504bf2013-03-18 10:44:55 -0700702#define MACvGetCurrATIMDescAddr(dwIoBase, pdwCurrDescAddr) \
Joe Perchesbda2a442013-03-18 20:55:40 -0700703 VNSvInPortD(dwIoBase + MAC_REG_ATIMDMAPTR, \
704 (unsigned long *)pdwCurrDescAddr)
Forest Bond5449c682009-04-25 10:30:44 -0400705
706// set the chip with current BCN tx descriptor address
Joe Perchesc3504bf2013-03-18 10:44:55 -0700707#define MACvSetCurrBCNTxDescAddr(dwIoBase, dwCurrDescAddr) \
Joe Perchesbda2a442013-03-18 20:55:40 -0700708 VNSvOutPortD(dwIoBase + MAC_REG_BCNDMAPTR, \
709 dwCurrDescAddr)
Forest Bond5449c682009-04-25 10:30:44 -0400710
711// set the chip with current BCN length
Joe Perchesc3504bf2013-03-18 10:44:55 -0700712#define MACvSetCurrBCNLength(dwIoBase, wCurrBCNLength) \
Joe Perchesbda2a442013-03-18 20:55:40 -0700713 VNSvOutPortW(dwIoBase + MAC_REG_BCNDMACTL+2, \
714 wCurrBCNLength)
Forest Bond5449c682009-04-25 10:30:44 -0400715
Joe Perchesc3504bf2013-03-18 10:44:55 -0700716#define MACvReadBSSIDAddress(dwIoBase, pbyEtherAddr) \
Joe Perchesbda2a442013-03-18 20:55:40 -0700717do { \
718 VNSvOutPortB(dwIoBase + MAC_REG_PAGE1SEL, 1); \
719 VNSvInPortB(dwIoBase + MAC_REG_BSSID0, \
720 (unsigned char *)pbyEtherAddr); \
721 VNSvInPortB(dwIoBase + MAC_REG_BSSID0 + 1, \
722 pbyEtherAddr + 1); \
723 VNSvInPortB(dwIoBase + MAC_REG_BSSID0 + 2, \
724 pbyEtherAddr + 2); \
725 VNSvInPortB(dwIoBase + MAC_REG_BSSID0 + 3, \
726 pbyEtherAddr + 3); \
727 VNSvInPortB(dwIoBase + MAC_REG_BSSID0 + 4, \
728 pbyEtherAddr + 4); \
729 VNSvInPortB(dwIoBase + MAC_REG_BSSID0 + 5, \
730 pbyEtherAddr + 5); \
731 VNSvOutPortB(dwIoBase + MAC_REG_PAGE1SEL, 0); \
732} while (0)
Forest Bond5449c682009-04-25 10:30:44 -0400733
Joe Perchesc3504bf2013-03-18 10:44:55 -0700734#define MACvWriteBSSIDAddress(dwIoBase, pbyEtherAddr) \
Joe Perchesbda2a442013-03-18 20:55:40 -0700735do { \
736 VNSvOutPortB(dwIoBase + MAC_REG_PAGE1SEL, 1); \
737 VNSvOutPortB(dwIoBase + MAC_REG_BSSID0, \
738 *(pbyEtherAddr)); \
739 VNSvOutPortB(dwIoBase + MAC_REG_BSSID0 + 1, \
740 *(pbyEtherAddr + 1)); \
741 VNSvOutPortB(dwIoBase + MAC_REG_BSSID0 + 2, \
742 *(pbyEtherAddr + 2)); \
743 VNSvOutPortB(dwIoBase + MAC_REG_BSSID0 + 3, \
744 *(pbyEtherAddr + 3)); \
745 VNSvOutPortB(dwIoBase + MAC_REG_BSSID0 + 4, \
746 *(pbyEtherAddr + 4)); \
747 VNSvOutPortB(dwIoBase + MAC_REG_BSSID0 + 5, \
748 *(pbyEtherAddr + 5)); \
749 VNSvOutPortB(dwIoBase + MAC_REG_PAGE1SEL, 0); \
750} while (0)
Forest Bond5449c682009-04-25 10:30:44 -0400751
Joe Perchesc3504bf2013-03-18 10:44:55 -0700752#define MACvReadEtherAddress(dwIoBase, pbyEtherAddr) \
Joe Perchesbda2a442013-03-18 20:55:40 -0700753do { \
754 VNSvOutPortB(dwIoBase + MAC_REG_PAGE1SEL, 1); \
755 VNSvInPortB(dwIoBase + MAC_REG_PAR0, \
756 (unsigned char *)pbyEtherAddr); \
757 VNSvInPortB(dwIoBase + MAC_REG_PAR0 + 1, \
758 pbyEtherAddr + 1); \
759 VNSvInPortB(dwIoBase + MAC_REG_PAR0 + 2, \
760 pbyEtherAddr + 2); \
761 VNSvInPortB(dwIoBase + MAC_REG_PAR0 + 3, \
762 pbyEtherAddr + 3); \
763 VNSvInPortB(dwIoBase + MAC_REG_PAR0 + 4, \
764 pbyEtherAddr + 4); \
765 VNSvInPortB(dwIoBase + MAC_REG_PAR0 + 5, \
766 pbyEtherAddr + 5); \
767 VNSvOutPortB(dwIoBase + MAC_REG_PAGE1SEL, 0); \
768} while (0)
Forest Bond5449c682009-04-25 10:30:44 -0400769
Joe Perchesc3504bf2013-03-18 10:44:55 -0700770#define MACvWriteEtherAddress(dwIoBase, pbyEtherAddr) \
Joe Perchesbda2a442013-03-18 20:55:40 -0700771do { \
772 VNSvOutPortB(dwIoBase + MAC_REG_PAGE1SEL, 1); \
773 VNSvOutPortB(dwIoBase + MAC_REG_PAR0, \
774 *pbyEtherAddr); \
775 VNSvOutPortB(dwIoBase + MAC_REG_PAR0 + 1, \
776 *(pbyEtherAddr + 1)); \
777 VNSvOutPortB(dwIoBase + MAC_REG_PAR0 + 2, \
778 *(pbyEtherAddr + 2)); \
779 VNSvOutPortB(dwIoBase + MAC_REG_PAR0 + 3, \
780 *(pbyEtherAddr + 3)); \
781 VNSvOutPortB(dwIoBase + MAC_REG_PAR0 + 4, \
782 *(pbyEtherAddr + 4)); \
783 VNSvOutPortB(dwIoBase + MAC_REG_PAR0 + 5, \
784 *(pbyEtherAddr + 5)); \
785 VNSvOutPortB(dwIoBase + MAC_REG_PAGE1SEL, 0); \
786} while (0)
Forest Bond5449c682009-04-25 10:30:44 -0400787
Joe Perchesc3504bf2013-03-18 10:44:55 -0700788#define MACvClearISR(dwIoBase) \
Joe Perchesbda2a442013-03-18 20:55:40 -0700789 VNSvOutPortD(dwIoBase + MAC_REG_ISR, IMR_MASK_VALUE)
Forest Bond5449c682009-04-25 10:30:44 -0400790
Joe Perchesc3504bf2013-03-18 10:44:55 -0700791#define MACvStart(dwIoBase) \
Joe Perchesbda2a442013-03-18 20:55:40 -0700792 VNSvOutPortB(dwIoBase + MAC_REG_HOSTCR, \
793 (HOSTCR_MACEN | HOSTCR_RXON | HOSTCR_TXON))
Forest Bond5449c682009-04-25 10:30:44 -0400794
Joe Perchesc3504bf2013-03-18 10:44:55 -0700795#define MACvRx0PerPktMode(dwIoBase) \
Joe Perchesbda2a442013-03-18 20:55:40 -0700796 VNSvOutPortD(dwIoBase + MAC_REG_RXDMACTL0, RX_PERPKT)
Forest Bond5449c682009-04-25 10:30:44 -0400797
Joe Perchesc3504bf2013-03-18 10:44:55 -0700798#define MACvRx0BufferFillMode(dwIoBase) \
Joe Perchesbda2a442013-03-18 20:55:40 -0700799 VNSvOutPortD(dwIoBase + MAC_REG_RXDMACTL0, RX_PERPKTCLR)
Forest Bond5449c682009-04-25 10:30:44 -0400800
Joe Perchesc3504bf2013-03-18 10:44:55 -0700801#define MACvRx1PerPktMode(dwIoBase) \
Joe Perchesbda2a442013-03-18 20:55:40 -0700802 VNSvOutPortD(dwIoBase + MAC_REG_RXDMACTL1, RX_PERPKT)
Forest Bond5449c682009-04-25 10:30:44 -0400803
Joe Perchesc3504bf2013-03-18 10:44:55 -0700804#define MACvRx1BufferFillMode(dwIoBase) \
Joe Perchesbda2a442013-03-18 20:55:40 -0700805 VNSvOutPortD(dwIoBase + MAC_REG_RXDMACTL1, RX_PERPKTCLR)
Forest Bond5449c682009-04-25 10:30:44 -0400806
Joe Perchesc3504bf2013-03-18 10:44:55 -0700807#define MACvRxOn(dwIoBase) \
Joe Perchesbda2a442013-03-18 20:55:40 -0700808 MACvRegBitsOn(dwIoBase, MAC_REG_HOSTCR, HOSTCR_RXON)
Forest Bond5449c682009-04-25 10:30:44 -0400809
Joe Perchesc3504bf2013-03-18 10:44:55 -0700810#define MACvReceive0(dwIoBase) \
Joe Perchesbda2a442013-03-18 20:55:40 -0700811do { \
812 unsigned long dwData; \
813 VNSvInPortD(dwIoBase + MAC_REG_RXDMACTL0, &dwData); \
814 if (dwData & DMACTL_RUN) \
815 VNSvOutPortD(dwIoBase + MAC_REG_RXDMACTL0, DMACTL_WAKE); \
816 else \
817 VNSvOutPortD(dwIoBase + MAC_REG_RXDMACTL0, DMACTL_RUN); \
818} while (0)
Forest Bond5449c682009-04-25 10:30:44 -0400819
Joe Perchesc3504bf2013-03-18 10:44:55 -0700820#define MACvReceive1(dwIoBase) \
Joe Perchesbda2a442013-03-18 20:55:40 -0700821do { \
822 unsigned long dwData; \
823 VNSvInPortD(dwIoBase + MAC_REG_RXDMACTL1, &dwData); \
824 if (dwData & DMACTL_RUN) \
825 VNSvOutPortD(dwIoBase + MAC_REG_RXDMACTL1, DMACTL_WAKE); \
826 else \
827 VNSvOutPortD(dwIoBase + MAC_REG_RXDMACTL1, DMACTL_RUN); \
828} while (0)
Forest Bond5449c682009-04-25 10:30:44 -0400829
Joe Perchesc3504bf2013-03-18 10:44:55 -0700830#define MACvTxOn(dwIoBase) \
Joe Perchesbda2a442013-03-18 20:55:40 -0700831 MACvRegBitsOn(dwIoBase, MAC_REG_HOSTCR, HOSTCR_TXON)
Forest Bond5449c682009-04-25 10:30:44 -0400832
Joe Perchesc3504bf2013-03-18 10:44:55 -0700833#define MACvTransmit0(dwIoBase) \
Joe Perchesbda2a442013-03-18 20:55:40 -0700834do { \
835 unsigned long dwData; \
836 VNSvInPortD(dwIoBase + MAC_REG_TXDMACTL0, &dwData); \
837 if (dwData & DMACTL_RUN) \
838 VNSvOutPortD(dwIoBase + MAC_REG_TXDMACTL0, DMACTL_WAKE); \
839 else \
840 VNSvOutPortD(dwIoBase + MAC_REG_TXDMACTL0, DMACTL_RUN); \
841} while (0)
Forest Bond5449c682009-04-25 10:30:44 -0400842
Joe Perchesc3504bf2013-03-18 10:44:55 -0700843#define MACvTransmitAC0(dwIoBase) \
Joe Perchesbda2a442013-03-18 20:55:40 -0700844do { \
845 unsigned long dwData; \
846 VNSvInPortD(dwIoBase + MAC_REG_AC0DMACTL, &dwData); \
847 if (dwData & DMACTL_RUN) \
848 VNSvOutPortD(dwIoBase + MAC_REG_AC0DMACTL, DMACTL_WAKE); \
849 else \
850 VNSvOutPortD(dwIoBase + MAC_REG_AC0DMACTL, DMACTL_RUN); \
851} while (0)
Forest Bond5449c682009-04-25 10:30:44 -0400852
Joe Perchesc3504bf2013-03-18 10:44:55 -0700853#define MACvTransmitSYNC(dwIoBase) \
Joe Perchesbda2a442013-03-18 20:55:40 -0700854do { \
855 unsigned long dwData; \
856 VNSvInPortD(dwIoBase + MAC_REG_SYNCDMACTL, &dwData); \
857 if (dwData & DMACTL_RUN) \
858 VNSvOutPortD(dwIoBase + MAC_REG_SYNCDMACTL, DMACTL_WAKE); \
859 else \
860 VNSvOutPortD(dwIoBase + MAC_REG_SYNCDMACTL, DMACTL_RUN); \
861} while (0)
Forest Bond5449c682009-04-25 10:30:44 -0400862
Joe Perchesc3504bf2013-03-18 10:44:55 -0700863#define MACvTransmitATIM(dwIoBase) \
Joe Perchesbda2a442013-03-18 20:55:40 -0700864do { \
865 unsigned long dwData; \
866 VNSvInPortD(dwIoBase + MAC_REG_ATIMDMACTL, &dwData); \
867 if (dwData & DMACTL_RUN) \
868 VNSvOutPortD(dwIoBase + MAC_REG_ATIMDMACTL, DMACTL_WAKE); \
869 else \
870 VNSvOutPortD(dwIoBase + MAC_REG_ATIMDMACTL, DMACTL_RUN); \
871} while (0)
Forest Bond5449c682009-04-25 10:30:44 -0400872
Joe Perchesc3504bf2013-03-18 10:44:55 -0700873#define MACvTransmitBCN(dwIoBase) \
Joe Perchesbda2a442013-03-18 20:55:40 -0700874 VNSvOutPortB(dwIoBase + MAC_REG_BCNDMACTL, BEACON_READY)
Forest Bond5449c682009-04-25 10:30:44 -0400875
Joe Perchesc3504bf2013-03-18 10:44:55 -0700876#define MACvClearStckDS(dwIoBase) \
Joe Perchesbda2a442013-03-18 20:55:40 -0700877do { \
878 unsigned char byOrgValue; \
879 VNSvInPortB(dwIoBase + MAC_REG_STICKHW, &byOrgValue); \
880 byOrgValue = byOrgValue & 0xFC; \
881 VNSvOutPortB(dwIoBase + MAC_REG_STICKHW, byOrgValue); \
882} while (0)
Forest Bond5449c682009-04-25 10:30:44 -0400883
Joe Perchesc3504bf2013-03-18 10:44:55 -0700884#define MACvReadISR(dwIoBase, pdwValue) \
Joe Perchesbda2a442013-03-18 20:55:40 -0700885 VNSvInPortD(dwIoBase + MAC_REG_ISR, pdwValue)
Forest Bond5449c682009-04-25 10:30:44 -0400886
Joe Perchesc3504bf2013-03-18 10:44:55 -0700887#define MACvWriteISR(dwIoBase, dwValue) \
Joe Perchesbda2a442013-03-18 20:55:40 -0700888 VNSvOutPortD(dwIoBase + MAC_REG_ISR, dwValue)
Forest Bond5449c682009-04-25 10:30:44 -0400889
Joe Perchesc3504bf2013-03-18 10:44:55 -0700890#define MACvIntEnable(dwIoBase, dwMask) \
Joe Perchesbda2a442013-03-18 20:55:40 -0700891 VNSvOutPortD(dwIoBase + MAC_REG_IMR, dwMask)
Forest Bond5449c682009-04-25 10:30:44 -0400892
Joe Perchesc3504bf2013-03-18 10:44:55 -0700893#define MACvIntDisable(dwIoBase) \
Joe Perchesbda2a442013-03-18 20:55:40 -0700894 VNSvOutPortD(dwIoBase + MAC_REG_IMR, 0)
Forest Bond5449c682009-04-25 10:30:44 -0400895
Joe Perchesc3504bf2013-03-18 10:44:55 -0700896#define MACvSelectPage0(dwIoBase) \
Joe Perchesbda2a442013-03-18 20:55:40 -0700897 VNSvOutPortB(dwIoBase + MAC_REG_PAGE1SEL, 0)
898
Joe Perchesc3504bf2013-03-18 10:44:55 -0700899#define MACvSelectPage1(dwIoBase) \
Joe Perchesbda2a442013-03-18 20:55:40 -0700900 VNSvOutPortB(dwIoBase + MAC_REG_PAGE1SEL, 1)
Forest Bond5449c682009-04-25 10:30:44 -0400901
Joe Perchesc3504bf2013-03-18 10:44:55 -0700902#define MACvReadMIBCounter(dwIoBase, pdwCounter) \
Joe Perchesbda2a442013-03-18 20:55:40 -0700903 VNSvInPortD(dwIoBase + MAC_REG_MIBCNTR , pdwCounter)
Forest Bond5449c682009-04-25 10:30:44 -0400904
Joe Perchesc3504bf2013-03-18 10:44:55 -0700905#define MACvPwrEvntDisable(dwIoBase) \
Joe Perchesbda2a442013-03-18 20:55:40 -0700906 VNSvOutPortW(dwIoBase + MAC_REG_WAKEUPEN0, 0x0000)
Forest Bond5449c682009-04-25 10:30:44 -0400907
Joe Perchesc3504bf2013-03-18 10:44:55 -0700908#define MACvEnableProtectMD(dwIoBase) \
Joe Perchesbda2a442013-03-18 20:55:40 -0700909do { \
910 unsigned long dwOrgValue; \
911 VNSvInPortD(dwIoBase + MAC_REG_ENCFG , &dwOrgValue); \
912 dwOrgValue = dwOrgValue | EnCFG_ProtectMd; \
913 VNSvOutPortD(dwIoBase + MAC_REG_ENCFG, dwOrgValue); \
914} while (0)
Forest Bond5449c682009-04-25 10:30:44 -0400915
Joe Perchesc3504bf2013-03-18 10:44:55 -0700916#define MACvDisableProtectMD(dwIoBase) \
Joe Perchesbda2a442013-03-18 20:55:40 -0700917do { \
918 unsigned long dwOrgValue; \
919 VNSvInPortD(dwIoBase + MAC_REG_ENCFG , &dwOrgValue); \
920 dwOrgValue = dwOrgValue & ~EnCFG_ProtectMd; \
921 VNSvOutPortD(dwIoBase + MAC_REG_ENCFG, dwOrgValue); \
922} while (0)
Forest Bond5449c682009-04-25 10:30:44 -0400923
Joe Perchesc3504bf2013-03-18 10:44:55 -0700924#define MACvEnableBarkerPreambleMd(dwIoBase) \
Joe Perchesbda2a442013-03-18 20:55:40 -0700925do { \
926 unsigned long dwOrgValue; \
927 VNSvInPortD(dwIoBase + MAC_REG_ENCFG , &dwOrgValue); \
928 dwOrgValue = dwOrgValue | EnCFG_BarkerPream; \
929 VNSvOutPortD(dwIoBase + MAC_REG_ENCFG, dwOrgValue); \
930} while (0)
Forest Bond5449c682009-04-25 10:30:44 -0400931
Joe Perchesc3504bf2013-03-18 10:44:55 -0700932#define MACvDisableBarkerPreambleMd(dwIoBase) \
Joe Perchesbda2a442013-03-18 20:55:40 -0700933do { \
934 unsigned long dwOrgValue; \
935 VNSvInPortD(dwIoBase + MAC_REG_ENCFG , &dwOrgValue); \
936 dwOrgValue = dwOrgValue & ~EnCFG_BarkerPream; \
937 VNSvOutPortD(dwIoBase + MAC_REG_ENCFG, dwOrgValue); \
938} while (0)
Forest Bond5449c682009-04-25 10:30:44 -0400939
Joe Perchesc3504bf2013-03-18 10:44:55 -0700940#define MACvSetBBType(dwIoBase, byTyp) \
Joe Perchesbda2a442013-03-18 20:55:40 -0700941do { \
942 unsigned long dwOrgValue; \
943 VNSvInPortD(dwIoBase + MAC_REG_ENCFG , &dwOrgValue); \
944 dwOrgValue = dwOrgValue & ~EnCFG_BBType_MASK; \
945 dwOrgValue = dwOrgValue | (unsigned long)byTyp; \
946 VNSvOutPortD(dwIoBase + MAC_REG_ENCFG, dwOrgValue); \
947} while (0)
Forest Bond5449c682009-04-25 10:30:44 -0400948
Joe Perchesc3504bf2013-03-18 10:44:55 -0700949#define MACvReadATIMW(dwIoBase, pwCounter) \
Joe Perchesbda2a442013-03-18 20:55:40 -0700950 VNSvInPortW(dwIoBase + MAC_REG_AIDATIM, pwCounter)
Forest Bond5449c682009-04-25 10:30:44 -0400951
Joe Perchesc3504bf2013-03-18 10:44:55 -0700952#define MACvWriteATIMW(dwIoBase, wCounter) \
Joe Perchesbda2a442013-03-18 20:55:40 -0700953 VNSvOutPortW(dwIoBase + MAC_REG_AIDATIM, wCounter)
Forest Bond5449c682009-04-25 10:30:44 -0400954
Joe Perchesc3504bf2013-03-18 10:44:55 -0700955#define MACvWriteCRC16_128(dwIoBase, byRegOfs, wCRC) \
Joe Perchesbda2a442013-03-18 20:55:40 -0700956do { \
957 VNSvOutPortB(dwIoBase + MAC_REG_PAGE1SEL, 1); \
958 VNSvOutPortW(dwIoBase + byRegOfs, wCRC); \
959 VNSvOutPortB(dwIoBase + MAC_REG_PAGE1SEL, 0); \
960} while (0)
Forest Bond5449c682009-04-25 10:30:44 -0400961
Joe Perchesc3504bf2013-03-18 10:44:55 -0700962#define MACvGPIOIn(dwIoBase, pbyValue) \
Joe Perchesbda2a442013-03-18 20:55:40 -0700963 VNSvInPortB(dwIoBase + MAC_REG_GPIOCTL1, pbyValue)
Forest Bond5449c682009-04-25 10:30:44 -0400964
965#define MACvSetRFLE_LatchBase(dwIoBase) \
Joe Perchesbda2a442013-03-18 20:55:40 -0700966 MACvWordRegBitsOn(dwIoBase, MAC_REG_SOFTPWRCTL, SOFTPWRCTL_RFLEOPT)
Forest Bond5449c682009-04-25 10:30:44 -0400967
968/*--------------------- Export Classes ----------------------------*/
969
970/*--------------------- Export Variables --------------------------*/
971
972/*--------------------- Export Functions --------------------------*/
Forest Bond5449c682009-04-25 10:30:44 -0400973
Charles Clément2986db52010-06-24 11:02:26 -0700974extern unsigned short TxRate_iwconfig;//2008-5-8 <add> by chester
Guillaume Clement16834402014-07-22 22:08:26 +0200975void MACvReadAllRegs(void __iomem *dwIoBase, unsigned char *pbyMacRegs);
Forest Bond5449c682009-04-25 10:30:44 -0400976
Guillaume Clement16834402014-07-22 22:08:26 +0200977bool MACbIsRegBitsOn(void __iomem *dwIoBase, unsigned char byRegOfs, unsigned char byTestBits);
978bool MACbIsRegBitsOff(void __iomem *dwIoBase, unsigned char byRegOfs, unsigned char byTestBits);
Forest Bond5449c682009-04-25 10:30:44 -0400979
Guillaume Clement16834402014-07-22 22:08:26 +0200980bool MACbIsIntDisable(void __iomem *dwIoBase);
Forest Bond5449c682009-04-25 10:30:44 -0400981
Guillaume Clement16834402014-07-22 22:08:26 +0200982unsigned char MACbyReadMultiAddr(void __iomem *dwIoBase, unsigned int uByteIdx);
983void MACvWriteMultiAddr(void __iomem *dwIoBase, unsigned int uByteIdx, unsigned char byData);
984void MACvSetMultiAddrByHash(void __iomem *dwIoBase, unsigned char byHashIdx);
985void MACvResetMultiAddrByHash(void __iomem *dwIoBase, unsigned char byHashIdx);
Forest Bond5449c682009-04-25 10:30:44 -0400986
Guillaume Clement16834402014-07-22 22:08:26 +0200987void MACvSetRxThreshold(void __iomem *dwIoBase, unsigned char byThreshold);
988void MACvGetRxThreshold(void __iomem *dwIoBase, unsigned char *pbyThreshold);
Forest Bond5449c682009-04-25 10:30:44 -0400989
Guillaume Clement16834402014-07-22 22:08:26 +0200990void MACvSetTxThreshold(void __iomem *dwIoBase, unsigned char byThreshold);
991void MACvGetTxThreshold(void __iomem *dwIoBase, unsigned char *pbyThreshold);
Forest Bond5449c682009-04-25 10:30:44 -0400992
Guillaume Clement16834402014-07-22 22:08:26 +0200993void MACvSetDmaLength(void __iomem *dwIoBase, unsigned char byDmaLength);
994void MACvGetDmaLength(void __iomem *dwIoBase, unsigned char *pbyDmaLength);
Forest Bond5449c682009-04-25 10:30:44 -0400995
Guillaume Clement16834402014-07-22 22:08:26 +0200996void MACvSetShortRetryLimit(void __iomem *dwIoBase, unsigned char byRetryLimit);
997void MACvGetShortRetryLimit(void __iomem *dwIoBase, unsigned char *pbyRetryLimit);
Forest Bond5449c682009-04-25 10:30:44 -0400998
Guillaume Clement16834402014-07-22 22:08:26 +0200999void MACvSetLongRetryLimit(void __iomem *dwIoBase, unsigned char byRetryLimit);
1000void MACvGetLongRetryLimit(void __iomem *dwIoBase, unsigned char *pbyRetryLimit);
Forest Bond5449c682009-04-25 10:30:44 -04001001
Guillaume Clement16834402014-07-22 22:08:26 +02001002void MACvSetLoopbackMode(void __iomem *dwIoBase, unsigned char byLoopbackMode);
1003bool MACbIsInLoopbackMode(void __iomem *dwIoBase);
Forest Bond5449c682009-04-25 10:30:44 -04001004
Guillaume Clement16834402014-07-22 22:08:26 +02001005void MACvSetPacketFilter(void __iomem *dwIoBase, unsigned short wFilterType);
Forest Bond5449c682009-04-25 10:30:44 -04001006
Guillaume Clement16834402014-07-22 22:08:26 +02001007void MACvSaveContext(void __iomem *dwIoBase, unsigned char *pbyCxtBuf);
1008void MACvRestoreContext(void __iomem *dwIoBase, unsigned char *pbyCxtBuf);
1009bool MACbCompareContext(void __iomem *dwIoBase, unsigned char *pbyCxtBuf);
Forest Bond5449c682009-04-25 10:30:44 -04001010
Guillaume Clement16834402014-07-22 22:08:26 +02001011bool MACbSoftwareReset(void __iomem *dwIoBase);
1012bool MACbSafeSoftwareReset(void __iomem *dwIoBase);
1013bool MACbSafeRxOff(void __iomem *dwIoBase);
1014bool MACbSafeTxOff(void __iomem *dwIoBase);
1015bool MACbSafeStop(void __iomem *dwIoBase);
1016bool MACbShutdown(void __iomem *dwIoBase);
1017void MACvInitialize(void __iomem *dwIoBase);
1018void MACvSetCurrRx0DescAddr(void __iomem *dwIoBase, unsigned long dwCurrDescAddr);
1019void MACvSetCurrRx1DescAddr(void __iomem *dwIoBase, unsigned long dwCurrDescAddr);
1020void MACvSetCurrTXDescAddr(int iTxType, void __iomem *dwIoBase, unsigned long dwCurrDescAddr);
1021void MACvSetCurrTx0DescAddrEx(void __iomem *dwIoBase, unsigned long dwCurrDescAddr);
1022void MACvSetCurrAC0DescAddrEx(void __iomem *dwIoBase, unsigned long dwCurrDescAddr);
1023void MACvSetCurrSyncDescAddrEx(void __iomem *dwIoBase, unsigned long dwCurrDescAddr);
1024void MACvSetCurrATIMDescAddrEx(void __iomem *dwIoBase, unsigned long dwCurrDescAddr);
1025void MACvTimer0MicroSDelay(void __iomem *dwIoBase, unsigned int uDelay);
1026void MACvOneShotTimer0MicroSec(void __iomem *dwIoBase, unsigned int uDelayTime);
1027void MACvOneShotTimer1MicroSec(void __iomem *dwIoBase, unsigned int uDelayTime);
Forest Bond5449c682009-04-25 10:30:44 -04001028
Guillaume Clement16834402014-07-22 22:08:26 +02001029void MACvSetMISCFifo(void __iomem *dwIoBase, unsigned short wOffset, unsigned long dwData);
Forest Bond5449c682009-04-25 10:30:44 -04001030
Guillaume Clement16834402014-07-22 22:08:26 +02001031bool MACbTxDMAOff(void __iomem *dwIoBase, unsigned int idx);
Forest Bond5449c682009-04-25 10:30:44 -04001032
Guillaume Clement16834402014-07-22 22:08:26 +02001033void MACvClearBusSusInd(void __iomem *dwIoBase);
1034void MACvEnableBusSusEn(void __iomem *dwIoBase);
Forest Bond5449c682009-04-25 10:30:44 -04001035
Guillaume Clement16834402014-07-22 22:08:26 +02001036bool MACbFlushSYNCFifo(void __iomem *dwIoBase);
1037bool MACbPSWakeup(void __iomem *dwIoBase);
Forest Bond5449c682009-04-25 10:30:44 -04001038
Guillaume Clement16834402014-07-22 22:08:26 +02001039void MACvSetKeyEntry(void __iomem *dwIoBase, unsigned short wKeyCtl, unsigned int uEntryIdx,
Malcolm Priestley4dbc77c2014-03-06 22:44:22 +00001040 unsigned int uKeyIdx, unsigned char *pbyAddr, u32 *pdwKey, unsigned char byLocalID);
Guillaume Clement16834402014-07-22 22:08:26 +02001041void MACvDisableKeyEntry(void __iomem *dwIoBase, unsigned int uEntryIdx);
1042void MACvSetDefaultKeyEntry(void __iomem *dwIoBase, unsigned int uKeyLen,
Joe Perchesc3504bf2013-03-18 10:44:55 -07001043 unsigned int uKeyIdx, unsigned long *pdwKey, unsigned char byLocalID);
Guillaume Clement16834402014-07-22 22:08:26 +02001044void MACvDisableDefaultKey(void __iomem *dwIoBase);
1045void MACvSetDefaultTKIPKeyEntry(void __iomem *dwIoBase, unsigned int uKeyLen,
Joe Perchesc3504bf2013-03-18 10:44:55 -07001046 unsigned int uKeyIdx, unsigned long *pdwKey, unsigned char byLocalID);
Guillaume Clement16834402014-07-22 22:08:26 +02001047void MACvSetDefaultKeyCtl(void __iomem *dwIoBase, unsigned short wKeyCtl, unsigned int uEntryIdx, unsigned char byLocalID);
Forest Bond5449c682009-04-25 10:30:44 -04001048
Forest Bond5449c682009-04-25 10:30:44 -04001049#endif // __MAC_H__