wireless: Remove casts to same type
[deliverable/linux.git] / drivers / net / wireless / zd1211rw / zd_chip.h
CommitLineData
66bb42fd
DD
1/* ZD1211 USB-WLAN driver for Linux
2 *
3 * Copyright (C) 2005-2007 Ulrich Kunitz <kune@deine-taler.de>
4 * Copyright (C) 2006-2007 Daniel Drake <dsd@gentoo.org>
e85d0918
DD
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */
20
21#ifndef _ZD_CHIP_H
22#define _ZD_CHIP_H
23
9a066968
KV
24#include <net/mac80211.h>
25
e85d0918
DD
26#include "zd_rf.h"
27#include "zd_usb.h"
28
29/* Header for the Media Access Controller (MAC) and the Baseband Processor
30 * (BBP). It appears that the ZD1211 wraps the old ZD1205 with USB glue and
31 * adds a processor for handling the USB protocol.
32 */
33
0ce34bc8
DD
34/* Address space */
35enum {
36 /* CONTROL REGISTERS */
37 CR_START = 0x9000,
38
39
40 /* FIRMWARE */
41 FW_START = 0xee00,
42
43
44 /* EEPROM */
45 E2P_START = 0xf800,
46 E2P_LEN = 0x800,
47
48 /* EEPROM layout */
49 E2P_LOAD_CODE_LEN = 0xe, /* base 0xf800 */
50 E2P_LOAD_VECT_LEN = 0x9, /* base 0xf80e */
51 /* E2P_DATA indexes into this */
52 E2P_DATA_LEN = 0x7e, /* base 0xf817 */
53 E2P_BOOT_CODE_LEN = 0x760, /* base 0xf895 */
54 E2P_INTR_VECT_LEN = 0xb, /* base 0xfff5 */
55
56 /* Some precomputed offsets into the EEPROM */
57 E2P_DATA_OFFSET = E2P_LOAD_CODE_LEN + E2P_LOAD_VECT_LEN,
58 E2P_BOOT_CODE_OFFSET = E2P_DATA_OFFSET + E2P_DATA_LEN,
59};
60
61#define CTL_REG(offset) ((zd_addr_t)(CR_START + (offset)))
62#define E2P_DATA(offset) ((zd_addr_t)(E2P_START + E2P_DATA_OFFSET + (offset)))
63#define FWRAW_DATA(offset) ((zd_addr_t)(FW_START + (offset)))
64
e85d0918 65/* 8-bit hardware registers */
fbd5d17b
JK
66#define ZD_CR0 CTL_REG(0x0000)
67#define ZD_CR1 CTL_REG(0x0004)
68#define ZD_CR2 CTL_REG(0x0008)
69#define ZD_CR3 CTL_REG(0x000C)
e85d0918 70
fbd5d17b 71#define ZD_CR5 CTL_REG(0x0010)
e85d0918
DD
72/* bit 5: if set short preamble used
73 * bit 6: filter band - Japan channel 14 on, else off
74 */
fbd5d17b
JK
75#define ZD_CR6 CTL_REG(0x0014)
76#define ZD_CR7 CTL_REG(0x0018)
77#define ZD_CR8 CTL_REG(0x001C)
e85d0918 78
fbd5d17b 79#define ZD_CR4 CTL_REG(0x0020)
e85d0918 80
fbd5d17b
JK
81#define ZD_CR9 CTL_REG(0x0024)
82/* bit 2: antenna switch (together with ZD_CR10) */
83#define ZD_CR10 CTL_REG(0x0028)
84/* bit 1: antenna switch (together with ZD_CR9)
85 * RF2959 controls with ZD_CR11 radion on and off
e85d0918 86 */
fbd5d17b 87#define ZD_CR11 CTL_REG(0x002C)
e85d0918 88/* bit 6: TX power control for OFDM
fbd5d17b 89 * RF2959 controls with ZD_CR10 radio on and off
e85d0918 90 */
fbd5d17b
JK
91#define ZD_CR12 CTL_REG(0x0030)
92#define ZD_CR13 CTL_REG(0x0034)
93#define ZD_CR14 CTL_REG(0x0038)
94#define ZD_CR15 CTL_REG(0x003C)
95#define ZD_CR16 CTL_REG(0x0040)
96#define ZD_CR17 CTL_REG(0x0044)
97#define ZD_CR18 CTL_REG(0x0048)
98#define ZD_CR19 CTL_REG(0x004C)
99#define ZD_CR20 CTL_REG(0x0050)
100#define ZD_CR21 CTL_REG(0x0054)
101#define ZD_CR22 CTL_REG(0x0058)
102#define ZD_CR23 CTL_REG(0x005C)
103#define ZD_CR24 CTL_REG(0x0060) /* CCA threshold */
104#define ZD_CR25 CTL_REG(0x0064)
105#define ZD_CR26 CTL_REG(0x0068)
106#define ZD_CR27 CTL_REG(0x006C)
107#define ZD_CR28 CTL_REG(0x0070)
108#define ZD_CR29 CTL_REG(0x0074)
109#define ZD_CR30 CTL_REG(0x0078)
110#define ZD_CR31 CTL_REG(0x007C) /* TX power control for RF in
111 * CCK mode
112 */
113#define ZD_CR32 CTL_REG(0x0080)
114#define ZD_CR33 CTL_REG(0x0084)
115#define ZD_CR34 CTL_REG(0x0088)
116#define ZD_CR35 CTL_REG(0x008C)
117#define ZD_CR36 CTL_REG(0x0090)
118#define ZD_CR37 CTL_REG(0x0094)
119#define ZD_CR38 CTL_REG(0x0098)
120#define ZD_CR39 CTL_REG(0x009C)
121#define ZD_CR40 CTL_REG(0x00A0)
122#define ZD_CR41 CTL_REG(0x00A4)
123#define ZD_CR42 CTL_REG(0x00A8)
124#define ZD_CR43 CTL_REG(0x00AC)
125#define ZD_CR44 CTL_REG(0x00B0)
126#define ZD_CR45 CTL_REG(0x00B4)
127#define ZD_CR46 CTL_REG(0x00B8)
128#define ZD_CR47 CTL_REG(0x00BC) /* CCK baseband gain
129 * (patch value might be in EEPROM)
130 */
131#define ZD_CR48 CTL_REG(0x00C0)
132#define ZD_CR49 CTL_REG(0x00C4)
133#define ZD_CR50 CTL_REG(0x00C8)
134#define ZD_CR51 CTL_REG(0x00CC) /* TX power control for RF in
135 * 6-36M modes
136 */
137#define ZD_CR52 CTL_REG(0x00D0) /* TX power control for RF in
138 * 48M mode
139 */
140#define ZD_CR53 CTL_REG(0x00D4) /* TX power control for RF in
141 * 54M mode
142 */
143#define ZD_CR54 CTL_REG(0x00D8)
144#define ZD_CR55 CTL_REG(0x00DC)
145#define ZD_CR56 CTL_REG(0x00E0)
146#define ZD_CR57 CTL_REG(0x00E4)
147#define ZD_CR58 CTL_REG(0x00E8)
148#define ZD_CR59 CTL_REG(0x00EC)
149#define ZD_CR60 CTL_REG(0x00F0)
150#define ZD_CR61 CTL_REG(0x00F4)
151#define ZD_CR62 CTL_REG(0x00F8)
152#define ZD_CR63 CTL_REG(0x00FC)
153#define ZD_CR64 CTL_REG(0x0100)
154#define ZD_CR65 CTL_REG(0x0104) /* OFDM 54M calibration */
155#define ZD_CR66 CTL_REG(0x0108) /* OFDM 48M calibration */
156#define ZD_CR67 CTL_REG(0x010C) /* OFDM 36M calibration */
157#define ZD_CR68 CTL_REG(0x0110) /* CCK calibration */
158#define ZD_CR69 CTL_REG(0x0114)
159#define ZD_CR70 CTL_REG(0x0118)
160#define ZD_CR71 CTL_REG(0x011C)
161#define ZD_CR72 CTL_REG(0x0120)
162#define ZD_CR73 CTL_REG(0x0124)
163#define ZD_CR74 CTL_REG(0x0128)
164#define ZD_CR75 CTL_REG(0x012C)
165#define ZD_CR76 CTL_REG(0x0130)
166#define ZD_CR77 CTL_REG(0x0134)
167#define ZD_CR78 CTL_REG(0x0138)
168#define ZD_CR79 CTL_REG(0x013C)
169#define ZD_CR80 CTL_REG(0x0140)
170#define ZD_CR81 CTL_REG(0x0144)
171#define ZD_CR82 CTL_REG(0x0148)
172#define ZD_CR83 CTL_REG(0x014C)
173#define ZD_CR84 CTL_REG(0x0150)
174#define ZD_CR85 CTL_REG(0x0154)
175#define ZD_CR86 CTL_REG(0x0158)
176#define ZD_CR87 CTL_REG(0x015C)
177#define ZD_CR88 CTL_REG(0x0160)
178#define ZD_CR89 CTL_REG(0x0164)
179#define ZD_CR90 CTL_REG(0x0168)
180#define ZD_CR91 CTL_REG(0x016C)
181#define ZD_CR92 CTL_REG(0x0170)
182#define ZD_CR93 CTL_REG(0x0174)
183#define ZD_CR94 CTL_REG(0x0178)
184#define ZD_CR95 CTL_REG(0x017C)
185#define ZD_CR96 CTL_REG(0x0180)
186#define ZD_CR97 CTL_REG(0x0184)
187#define ZD_CR98 CTL_REG(0x0188)
188#define ZD_CR99 CTL_REG(0x018C)
189#define ZD_CR100 CTL_REG(0x0190)
190#define ZD_CR101 CTL_REG(0x0194)
191#define ZD_CR102 CTL_REG(0x0198)
192#define ZD_CR103 CTL_REG(0x019C)
193#define ZD_CR104 CTL_REG(0x01A0)
194#define ZD_CR105 CTL_REG(0x01A4)
195#define ZD_CR106 CTL_REG(0x01A8)
196#define ZD_CR107 CTL_REG(0x01AC)
197#define ZD_CR108 CTL_REG(0x01B0)
198#define ZD_CR109 CTL_REG(0x01B4)
199#define ZD_CR110 CTL_REG(0x01B8)
200#define ZD_CR111 CTL_REG(0x01BC)
201#define ZD_CR112 CTL_REG(0x01C0)
202#define ZD_CR113 CTL_REG(0x01C4)
203#define ZD_CR114 CTL_REG(0x01C8)
204#define ZD_CR115 CTL_REG(0x01CC)
205#define ZD_CR116 CTL_REG(0x01D0)
206#define ZD_CR117 CTL_REG(0x01D4)
207#define ZD_CR118 CTL_REG(0x01D8)
208#define ZD_CR119 CTL_REG(0x01DC)
209#define ZD_CR120 CTL_REG(0x01E0)
210#define ZD_CR121 CTL_REG(0x01E4)
211#define ZD_CR122 CTL_REG(0x01E8)
212#define ZD_CR123 CTL_REG(0x01EC)
213#define ZD_CR124 CTL_REG(0x01F0)
214#define ZD_CR125 CTL_REG(0x01F4)
215#define ZD_CR126 CTL_REG(0x01F8)
216#define ZD_CR127 CTL_REG(0x01FC)
217#define ZD_CR128 CTL_REG(0x0200)
218#define ZD_CR129 CTL_REG(0x0204)
219#define ZD_CR130 CTL_REG(0x0208)
220#define ZD_CR131 CTL_REG(0x020C)
221#define ZD_CR132 CTL_REG(0x0210)
222#define ZD_CR133 CTL_REG(0x0214)
223#define ZD_CR134 CTL_REG(0x0218)
224#define ZD_CR135 CTL_REG(0x021C)
225#define ZD_CR136 CTL_REG(0x0220)
226#define ZD_CR137 CTL_REG(0x0224)
227#define ZD_CR138 CTL_REG(0x0228)
228#define ZD_CR139 CTL_REG(0x022C)
229#define ZD_CR140 CTL_REG(0x0230)
230#define ZD_CR141 CTL_REG(0x0234)
231#define ZD_CR142 CTL_REG(0x0238)
232#define ZD_CR143 CTL_REG(0x023C)
233#define ZD_CR144 CTL_REG(0x0240)
234#define ZD_CR145 CTL_REG(0x0244)
235#define ZD_CR146 CTL_REG(0x0248)
236#define ZD_CR147 CTL_REG(0x024C)
237#define ZD_CR148 CTL_REG(0x0250)
238#define ZD_CR149 CTL_REG(0x0254)
239#define ZD_CR150 CTL_REG(0x0258)
240#define ZD_CR151 CTL_REG(0x025C)
241#define ZD_CR152 CTL_REG(0x0260)
242#define ZD_CR153 CTL_REG(0x0264)
243#define ZD_CR154 CTL_REG(0x0268)
244#define ZD_CR155 CTL_REG(0x026C)
245#define ZD_CR156 CTL_REG(0x0270)
246#define ZD_CR157 CTL_REG(0x0274)
247#define ZD_CR158 CTL_REG(0x0278)
248#define ZD_CR159 CTL_REG(0x027C)
249#define ZD_CR160 CTL_REG(0x0280)
250#define ZD_CR161 CTL_REG(0x0284)
251#define ZD_CR162 CTL_REG(0x0288)
252#define ZD_CR163 CTL_REG(0x028C)
253#define ZD_CR164 CTL_REG(0x0290)
254#define ZD_CR165 CTL_REG(0x0294)
255#define ZD_CR166 CTL_REG(0x0298)
256#define ZD_CR167 CTL_REG(0x029C)
257#define ZD_CR168 CTL_REG(0x02A0)
258#define ZD_CR169 CTL_REG(0x02A4)
259#define ZD_CR170 CTL_REG(0x02A8)
260#define ZD_CR171 CTL_REG(0x02AC)
261#define ZD_CR172 CTL_REG(0x02B0)
262#define ZD_CR173 CTL_REG(0x02B4)
263#define ZD_CR174 CTL_REG(0x02B8)
264#define ZD_CR175 CTL_REG(0x02BC)
265#define ZD_CR176 CTL_REG(0x02C0)
266#define ZD_CR177 CTL_REG(0x02C4)
267#define ZD_CR178 CTL_REG(0x02C8)
268#define ZD_CR179 CTL_REG(0x02CC)
269#define ZD_CR180 CTL_REG(0x02D0)
270#define ZD_CR181 CTL_REG(0x02D4)
271#define ZD_CR182 CTL_REG(0x02D8)
272#define ZD_CR183 CTL_REG(0x02DC)
273#define ZD_CR184 CTL_REG(0x02E0)
274#define ZD_CR185 CTL_REG(0x02E4)
275#define ZD_CR186 CTL_REG(0x02E8)
276#define ZD_CR187 CTL_REG(0x02EC)
277#define ZD_CR188 CTL_REG(0x02F0)
278#define ZD_CR189 CTL_REG(0x02F4)
279#define ZD_CR190 CTL_REG(0x02F8)
280#define ZD_CR191 CTL_REG(0x02FC)
281#define ZD_CR192 CTL_REG(0x0300)
282#define ZD_CR193 CTL_REG(0x0304)
283#define ZD_CR194 CTL_REG(0x0308)
284#define ZD_CR195 CTL_REG(0x030C)
285#define ZD_CR196 CTL_REG(0x0310)
286#define ZD_CR197 CTL_REG(0x0314)
287#define ZD_CR198 CTL_REG(0x0318)
288#define ZD_CR199 CTL_REG(0x031C)
289#define ZD_CR200 CTL_REG(0x0320)
290#define ZD_CR201 CTL_REG(0x0324)
291#define ZD_CR202 CTL_REG(0x0328)
292#define ZD_CR203 CTL_REG(0x032C) /* I2C bus template value & flash
293 * control
294 */
295#define ZD_CR204 CTL_REG(0x0330)
296#define ZD_CR205 CTL_REG(0x0334)
297#define ZD_CR206 CTL_REG(0x0338)
298#define ZD_CR207 CTL_REG(0x033C)
299#define ZD_CR208 CTL_REG(0x0340)
300#define ZD_CR209 CTL_REG(0x0344)
301#define ZD_CR210 CTL_REG(0x0348)
302#define ZD_CR211 CTL_REG(0x034C)
303#define ZD_CR212 CTL_REG(0x0350)
304#define ZD_CR213 CTL_REG(0x0354)
305#define ZD_CR214 CTL_REG(0x0358)
306#define ZD_CR215 CTL_REG(0x035C)
307#define ZD_CR216 CTL_REG(0x0360)
308#define ZD_CR217 CTL_REG(0x0364)
309#define ZD_CR218 CTL_REG(0x0368)
310#define ZD_CR219 CTL_REG(0x036C)
311#define ZD_CR220 CTL_REG(0x0370)
312#define ZD_CR221 CTL_REG(0x0374)
313#define ZD_CR222 CTL_REG(0x0378)
314#define ZD_CR223 CTL_REG(0x037C)
315#define ZD_CR224 CTL_REG(0x0380)
316#define ZD_CR225 CTL_REG(0x0384)
317#define ZD_CR226 CTL_REG(0x0388)
318#define ZD_CR227 CTL_REG(0x038C)
319#define ZD_CR228 CTL_REG(0x0390)
320#define ZD_CR229 CTL_REG(0x0394)
321#define ZD_CR230 CTL_REG(0x0398)
322#define ZD_CR231 CTL_REG(0x039C)
323#define ZD_CR232 CTL_REG(0x03A0)
324#define ZD_CR233 CTL_REG(0x03A4)
325#define ZD_CR234 CTL_REG(0x03A8)
326#define ZD_CR235 CTL_REG(0x03AC)
327#define ZD_CR236 CTL_REG(0x03B0)
e85d0918 328
fbd5d17b
JK
329#define ZD_CR240 CTL_REG(0x03C0)
330/* bit 7: host-controlled RF register writes
331 * ZD_CR241-ZD_CR245: for hardware controlled writing of RF bits, not needed for
332 * USB
e85d0918 333 */
fbd5d17b
JK
334#define ZD_CR241 CTL_REG(0x03C4)
335#define ZD_CR242 CTL_REG(0x03C8)
336#define ZD_CR243 CTL_REG(0x03CC)
337#define ZD_CR244 CTL_REG(0x03D0)
338#define ZD_CR245 CTL_REG(0x03D4)
e85d0918 339
fbd5d17b
JK
340#define ZD_CR251 CTL_REG(0x03EC) /* only used for activation and
341 * deactivation of Airoha RFs AL2230
342 * and AL7230B
343 */
344#define ZD_CR252 CTL_REG(0x03F0)
345#define ZD_CR253 CTL_REG(0x03F4)
346#define ZD_CR254 CTL_REG(0x03F8)
347#define ZD_CR255 CTL_REG(0x03FC)
e85d0918
DD
348
349#define CR_MAX_PHY_REG 255
350
0ce34bc8 351/* Taken from the ZYDAS driver, not all of them are relevant for the ZD1211
e85d0918
DD
352 * driver.
353 */
354
355#define CR_RF_IF_CLK CTL_REG(0x0400)
356#define CR_RF_IF_DATA CTL_REG(0x0404)
357#define CR_PE1_PE2 CTL_REG(0x0408)
358#define CR_PE2_DLY CTL_REG(0x040C)
359#define CR_LE1 CTL_REG(0x0410)
360#define CR_LE2 CTL_REG(0x0414)
361/* Seems to enable/disable GPI (General Purpose IO?) */
362#define CR_GPI_EN CTL_REG(0x0418)
363#define CR_RADIO_PD CTL_REG(0x042C)
364#define CR_RF2948_PD CTL_REG(0x042C)
365#define CR_ENABLE_PS_MANUAL_AGC CTL_REG(0x043C)
366#define CR_CONFIG_PHILIPS CTL_REG(0x0440)
367#define CR_SA2400_SER_AP CTL_REG(0x0444)
368#define CR_I2C_WRITE CTL_REG(0x0444)
369#define CR_SA2400_SER_RP CTL_REG(0x0448)
370#define CR_RADIO_PE CTL_REG(0x0458)
371#define CR_RST_BUS_MASTER CTL_REG(0x045C)
372#define CR_RFCFG CTL_REG(0x0464)
373#define CR_HSTSCHG CTL_REG(0x046C)
374#define CR_PHY_ON CTL_REG(0x0474)
375#define CR_RX_DELAY CTL_REG(0x0478)
376#define CR_RX_PE_DELAY CTL_REG(0x047C)
377#define CR_GPIO_1 CTL_REG(0x0490)
378#define CR_GPIO_2 CTL_REG(0x0494)
379#define CR_EncryBufMux CTL_REG(0x04A8)
380#define CR_PS_CTRL CTL_REG(0x0500)
381#define CR_ADDA_PWR_DWN CTL_REG(0x0504)
382#define CR_ADDA_MBIAS_WARMTIME CTL_REG(0x0508)
383#define CR_MAC_PS_STATE CTL_REG(0x050C)
384
385#define CR_INTERRUPT CTL_REG(0x0510)
741fec53
UK
386#define INT_TX_COMPLETE (1 << 0)
387#define INT_RX_COMPLETE (1 << 1)
388#define INT_RETRY_FAIL (1 << 2)
389#define INT_WAKEUP (1 << 3)
390#define INT_DTIM_NOTIFY (1 << 5)
391#define INT_CFG_NEXT_BCN (1 << 6)
392#define INT_BUS_ABORT (1 << 7)
393#define INT_TX_FIFO_READY (1 << 8)
394#define INT_UART (1 << 9)
395#define INT_TX_COMPLETE_EN (1 << 16)
396#define INT_RX_COMPLETE_EN (1 << 17)
397#define INT_RETRY_FAIL_EN (1 << 18)
398#define INT_WAKEUP_EN (1 << 19)
399#define INT_DTIM_NOTIFY_EN (1 << 21)
400#define INT_CFG_NEXT_BCN_EN (1 << 22)
401#define INT_BUS_ABORT_EN (1 << 23)
402#define INT_TX_FIFO_READY_EN (1 << 24)
403#define INT_UART_EN (1 << 25)
e85d0918
DD
404
405#define CR_TSF_LOW_PART CTL_REG(0x0514)
406#define CR_TSF_HIGH_PART CTL_REG(0x0518)
407
408/* Following three values are in time units (1024us)
409 * Following condition must be met:
410 * atim < tbtt < bcn
411 */
412#define CR_ATIM_WND_PERIOD CTL_REG(0x051C)
413#define CR_BCN_INTERVAL CTL_REG(0x0520)
414#define CR_PRE_TBTT CTL_REG(0x0524)
415/* in units of TU(1024us) */
416
417/* for UART support */
418#define CR_UART_RBR_THR_DLL CTL_REG(0x0540)
419#define CR_UART_DLM_IER CTL_REG(0x0544)
420#define CR_UART_IIR_FCR CTL_REG(0x0548)
421#define CR_UART_LCR CTL_REG(0x054c)
422#define CR_UART_MCR CTL_REG(0x0550)
423#define CR_UART_LSR CTL_REG(0x0554)
424#define CR_UART_MSR CTL_REG(0x0558)
425#define CR_UART_ECR CTL_REG(0x055c)
426#define CR_UART_STATUS CTL_REG(0x0560)
427
428#define CR_PCI_TX_ADDR_P1 CTL_REG(0x0600)
429#define CR_PCI_TX_AddR_P2 CTL_REG(0x0604)
430#define CR_PCI_RX_AddR_P1 CTL_REG(0x0608)
431#define CR_PCI_RX_AddR_P2 CTL_REG(0x060C)
432
433/* must be overwritten if custom MAC address will be used */
434#define CR_MAC_ADDR_P1 CTL_REG(0x0610)
435#define CR_MAC_ADDR_P2 CTL_REG(0x0614)
436#define CR_BSSID_P1 CTL_REG(0x0618)
437#define CR_BSSID_P2 CTL_REG(0x061C)
438#define CR_BCN_PLCP_CFG CTL_REG(0x0620)
9cdac965
UK
439
440/* Group hash table for filtering incoming packets.
441 *
442 * The group hash table is 64 bit large and split over two parts. The first
443 * part is the lower part. The upper 6 bits of the last byte of the target
444 * address are used as index. Packets are received if the hash table bit is
445 * set. This is used for multicast handling, but for broadcasts (address
446 * ff:ff:ff:ff:ff:ff) the highest bit in the second table must also be set.
447 */
e85d0918
DD
448#define CR_GROUP_HASH_P1 CTL_REG(0x0624)
449#define CR_GROUP_HASH_P2 CTL_REG(0x0628)
e85d0918 450
9cdac965 451#define CR_RX_TIMEOUT CTL_REG(0x062C)
459c51ad 452
e85d0918
DD
453/* Basic rates supported by the BSS. When producing ACK or CTS messages, the
454 * device will use a rate in this table that is less than or equal to the rate
459c51ad 455 * of the incoming frame which prompted the response. */
e85d0918 456#define CR_BASIC_RATE_TBL CTL_REG(0x0630)
741fec53
UK
457#define CR_RATE_1M (1 << 0) /* 802.11b */
458#define CR_RATE_2M (1 << 1) /* 802.11b */
459#define CR_RATE_5_5M (1 << 2) /* 802.11b */
460#define CR_RATE_11M (1 << 3) /* 802.11b */
461#define CR_RATE_6M (1 << 8) /* 802.11g */
462#define CR_RATE_9M (1 << 9) /* 802.11g */
463#define CR_RATE_12M (1 << 10) /* 802.11g */
464#define CR_RATE_18M (1 << 11) /* 802.11g */
465#define CR_RATE_24M (1 << 12) /* 802.11g */
466#define CR_RATE_36M (1 << 13) /* 802.11g */
467#define CR_RATE_48M (1 << 14) /* 802.11g */
468#define CR_RATE_54M (1 << 15) /* 802.11g */
e85d0918
DD
469#define CR_RATES_80211G 0xff00
470#define CR_RATES_80211B 0x000f
471
472/* Mandatory rates required in the BSS. When producing ACK or CTS messages, if
473 * the device could not find an appropriate rate in CR_BASIC_RATE_TBL, it will
474 * look for a rate in this table that is less than or equal to the rate of
475 * the incoming frame. */
476#define CR_MANDATORY_RATE_TBL CTL_REG(0x0634)
477#define CR_RTS_CTS_RATE CTL_REG(0x0638)
478
b1382ede
DD
479/* These are all bit indexes in CR_RTS_CTS_RATE, so remember to shift. */
480#define RTSCTS_SH_RTS_RATE 0
481#define RTSCTS_SH_EXP_CTS_RATE 4
482#define RTSCTS_SH_RTS_MOD_TYPE 8
483#define RTSCTS_SH_RTS_PMB_TYPE 9
484#define RTSCTS_SH_CTS_RATE 16
485#define RTSCTS_SH_CTS_MOD_TYPE 24
486#define RTSCTS_SH_CTS_PMB_TYPE 25
487
e85d0918
DD
488#define CR_WEP_PROTECT CTL_REG(0x063C)
489#define CR_RX_THRESHOLD CTL_REG(0x0640)
490
491/* register for controlling the LEDS */
492#define CR_LED CTL_REG(0x0644)
493/* masks for controlling LEDs */
741fec53
UK
494#define LED1 (1 << 8)
495#define LED2 (1 << 9)
496#define LED_SW (1 << 10)
e85d0918
DD
497
498/* Seems to indicate that the configuration is over.
499 */
500#define CR_AFTER_PNP CTL_REG(0x0648)
501#define CR_ACK_TIME_80211 CTL_REG(0x0658)
502
503#define CR_RX_OFFSET CTL_REG(0x065c)
504
72e77a8a 505#define CR_BCN_LENGTH CTL_REG(0x0664)
e85d0918
DD
506#define CR_PHY_DELAY CTL_REG(0x066C)
507#define CR_BCN_FIFO CTL_REG(0x0670)
508#define CR_SNIFFER_ON CTL_REG(0x0674)
509
510#define CR_ENCRYPTION_TYPE CTL_REG(0x0678)
511#define NO_WEP 0
512#define WEP64 1
513#define WEP128 5
514#define WEP256 6
515#define ENC_SNIFFER 8
516
517#define CR_ZD1211_RETRY_MAX CTL_REG(0x067C)
518
519#define CR_REG1 CTL_REG(0x0680)
520/* Setting the bit UNLOCK_PHY_REGS disallows the write access to physical
521 * registers, so one could argue it is a LOCK bit. But calling it
522 * LOCK_PHY_REGS makes it confusing.
523 */
741fec53 524#define UNLOCK_PHY_REGS (1 << 7)
e85d0918
DD
525
526#define CR_DEVICE_STATE CTL_REG(0x0684)
527#define CR_UNDERRUN_CNT CTL_REG(0x0688)
528
529#define CR_RX_FILTER CTL_REG(0x068c)
459c51ad 530#define RX_FILTER_ASSOC_REQUEST (1 << 0)
741fec53 531#define RX_FILTER_ASSOC_RESPONSE (1 << 1)
459c51ad 532#define RX_FILTER_REASSOC_REQUEST (1 << 2)
741fec53 533#define RX_FILTER_REASSOC_RESPONSE (1 << 3)
459c51ad 534#define RX_FILTER_PROBE_REQUEST (1 << 4)
741fec53 535#define RX_FILTER_PROBE_RESPONSE (1 << 5)
459c51ad 536/* bits 6 and 7 reserved */
741fec53 537#define RX_FILTER_BEACON (1 << 8)
459c51ad 538#define RX_FILTER_ATIM (1 << 9)
741fec53
UK
539#define RX_FILTER_DISASSOC (1 << 10)
540#define RX_FILTER_AUTH (1 << 11)
459c51ad
DD
541#define RX_FILTER_DEAUTH (1 << 12)
542#define RX_FILTER_PSPOLL (1 << 26)
543#define RX_FILTER_RTS (1 << 27)
544#define RX_FILTER_CTS (1 << 28)
545#define RX_FILTER_ACK (1 << 29)
546#define RX_FILTER_CFEND (1 << 30)
547#define RX_FILTER_CFACK (1 << 31)
548
549/* Enable bits for all frames you are interested in. */
550#define STA_RX_FILTER (RX_FILTER_ASSOC_REQUEST | RX_FILTER_ASSOC_RESPONSE | \
551 RX_FILTER_REASSOC_REQUEST | RX_FILTER_REASSOC_RESPONSE | \
552 RX_FILTER_PROBE_REQUEST | RX_FILTER_PROBE_RESPONSE | \
553 (0x3 << 6) /* vendor driver sets these reserved bits */ | \
554 RX_FILTER_BEACON | RX_FILTER_ATIM | RX_FILTER_DISASSOC | \
555 RX_FILTER_AUTH | RX_FILTER_DEAUTH | \
556 (0x7 << 13) /* vendor driver sets these reserved bits */ | \
557 RX_FILTER_PSPOLL | RX_FILTER_ACK) /* 0x2400ffff */
558
559#define RX_FILTER_CTRL (RX_FILTER_RTS | RX_FILTER_CTS | \
560 RX_FILTER_CFEND | RX_FILTER_CFACK)
fde627b5 561
b91a515d 562#define BCN_MODE_AP 0x1000000
72e77a8a
LCC
563#define BCN_MODE_IBSS 0x2000000
564
71eae25e 565/* Monitor mode sets filter to 0xfffff */
e85d0918
DD
566
567#define CR_ACK_TIMEOUT_EXT CTL_REG(0x0690)
568#define CR_BCN_FIFO_SEMAPHORE CTL_REG(0x0694)
98227a90 569
e85d0918 570#define CR_IFS_VALUE CTL_REG(0x0698)
98227a90
DD
571#define IFS_VALUE_DIFS_SH 0
572#define IFS_VALUE_EIFS_SH 12
573#define IFS_VALUE_SIFS_SH 24
574#define IFS_VALUE_DEFAULT (( 50 << IFS_VALUE_DIFS_SH) | \
575 (1148 << IFS_VALUE_EIFS_SH) | \
576 ( 10 << IFS_VALUE_SIFS_SH))
577
e85d0918
DD
578#define CR_RX_TIME_OUT CTL_REG(0x069C)
579#define CR_TOTAL_RX_FRM CTL_REG(0x06A0)
580#define CR_CRC32_CNT CTL_REG(0x06A4)
581#define CR_CRC16_CNT CTL_REG(0x06A8)
582#define CR_DECRYPTION_ERR_UNI CTL_REG(0x06AC)
583#define CR_RX_FIFO_OVERRUN CTL_REG(0x06B0)
584
585#define CR_DECRYPTION_ERR_MUL CTL_REG(0x06BC)
586
587#define CR_NAV_CNT CTL_REG(0x06C4)
588#define CR_NAV_CCA CTL_REG(0x06C8)
589#define CR_RETRY_CNT CTL_REG(0x06CC)
590
591#define CR_READ_TCB_ADDR CTL_REG(0x06E8)
592#define CR_READ_RFD_ADDR CTL_REG(0x06EC)
593#define CR_CWMIN_CWMAX CTL_REG(0x06F0)
594#define CR_TOTAL_TX_FRM CTL_REG(0x06F4)
595
596/* CAM: Continuous Access Mode (power management) */
597#define CR_CAM_MODE CTL_REG(0x0700)
72e77a8a
LCC
598#define MODE_IBSS 0x0
599#define MODE_AP 0x1
600#define MODE_STA 0x2
601#define MODE_AP_WDS 0x3
602
e85d0918
DD
603#define CR_CAM_ROLL_TB_LOW CTL_REG(0x0704)
604#define CR_CAM_ROLL_TB_HIGH CTL_REG(0x0708)
605#define CR_CAM_ADDRESS CTL_REG(0x070C)
606#define CR_CAM_DATA CTL_REG(0x0710)
607
608#define CR_ROMDIR CTL_REG(0x0714)
609
610#define CR_DECRY_ERR_FLG_LOW CTL_REG(0x0714)
611#define CR_DECRY_ERR_FLG_HIGH CTL_REG(0x0718)
612
613#define CR_WEPKEY0 CTL_REG(0x0720)
614#define CR_WEPKEY1 CTL_REG(0x0724)
615#define CR_WEPKEY2 CTL_REG(0x0728)
616#define CR_WEPKEY3 CTL_REG(0x072C)
617#define CR_WEPKEY4 CTL_REG(0x0730)
618#define CR_WEPKEY5 CTL_REG(0x0734)
619#define CR_WEPKEY6 CTL_REG(0x0738)
620#define CR_WEPKEY7 CTL_REG(0x073C)
621#define CR_WEPKEY8 CTL_REG(0x0740)
622#define CR_WEPKEY9 CTL_REG(0x0744)
623#define CR_WEPKEY10 CTL_REG(0x0748)
624#define CR_WEPKEY11 CTL_REG(0x074C)
625#define CR_WEPKEY12 CTL_REG(0x0750)
626#define CR_WEPKEY13 CTL_REG(0x0754)
627#define CR_WEPKEY14 CTL_REG(0x0758)
628#define CR_WEPKEY15 CTL_REG(0x075c)
629#define CR_TKIP_MODE CTL_REG(0x0760)
630
631#define CR_EEPROM_PROTECT0 CTL_REG(0x0758)
632#define CR_EEPROM_PROTECT1 CTL_REG(0x075C)
633
634#define CR_DBG_FIFO_RD CTL_REG(0x0800)
635#define CR_DBG_SELECT CTL_REG(0x0804)
636#define CR_FIFO_Length CTL_REG(0x0808)
637
638
639#define CR_RSSI_MGC CTL_REG(0x0810)
640
641#define CR_PON CTL_REG(0x0818)
642#define CR_RX_ON CTL_REG(0x081C)
643#define CR_TX_ON CTL_REG(0x0820)
644#define CR_CHIP_EN CTL_REG(0x0824)
645#define CR_LO_SW CTL_REG(0x0828)
646#define CR_TXRX_SW CTL_REG(0x082C)
647#define CR_S_MD CTL_REG(0x0830)
648
649#define CR_USB_DEBUG_PORT CTL_REG(0x0888)
e51c6837
JC
650#define CR_ZD1211B_CWIN_MAX_MIN_AC0 CTL_REG(0x0b00)
651#define CR_ZD1211B_CWIN_MAX_MIN_AC1 CTL_REG(0x0b04)
652#define CR_ZD1211B_CWIN_MAX_MIN_AC2 CTL_REG(0x0b08)
653#define CR_ZD1211B_CWIN_MAX_MIN_AC3 CTL_REG(0x0b0c)
e85d0918
DD
654#define CR_ZD1211B_AIFS_CTL1 CTL_REG(0x0b10)
655#define CR_ZD1211B_AIFS_CTL2 CTL_REG(0x0b14)
656#define CR_ZD1211B_TXOP CTL_REG(0x0b20)
657#define CR_ZD1211B_RETRY_MAX CTL_REG(0x0b28)
658
7f4013f0
BP
659/* Value for CR_ZD1211_RETRY_MAX & CR_ZD1211B_RETRY_MAX. Vendor driver uses 2,
660 * we use 0. The first rate is tried (count+2), then all next rates are tried
661 * twice, until 1 Mbits is tried. */
662#define ZD1211_RETRY_COUNT 0
663#define ZD1211B_RETRY_COUNT \
664 (ZD1211_RETRY_COUNT << 0)| \
665 (ZD1211_RETRY_COUNT << 8)| \
666 (ZD1211_RETRY_COUNT << 16)| \
667 (ZD1211_RETRY_COUNT << 24)
668
4481d609
DD
669/* Used to detect PLL lock */
670#define UW2453_INTR_REG ((zd_addr_t)0x85c1)
671
e85d0918
DD
672#define CWIN_SIZE 0x007f043f
673
674
7f4013f0
BP
675#define HWINT_ENABLED \
676 (INT_TX_COMPLETE_EN| \
677 INT_RX_COMPLETE_EN| \
678 INT_RETRY_FAIL_EN| \
679 INT_WAKEUP_EN| \
680 INT_CFG_NEXT_BCN_EN)
681
e85d0918
DD
682#define HWINT_DISABLED 0
683
684#define E2P_PWR_INT_GUARD 8
685#define E2P_CHANNEL_COUNT 14
686
687/* If you compare this addresses with the ZYDAS orignal driver, please notify
688 * that we use word mapping for the EEPROM.
689 */
690
691/*
692 * Upper 16 bit contains the regulatory domain.
693 */
ee302767
DD
694#define E2P_SUBID E2P_DATA(0x00)
695#define E2P_POD E2P_DATA(0x02)
696#define E2P_MAC_ADDR_P1 E2P_DATA(0x04)
697#define E2P_MAC_ADDR_P2 E2P_DATA(0x06)
698#define E2P_PWR_CAL_VALUE1 E2P_DATA(0x08)
699#define E2P_PWR_CAL_VALUE2 E2P_DATA(0x0a)
700#define E2P_PWR_CAL_VALUE3 E2P_DATA(0x0c)
701#define E2P_PWR_CAL_VALUE4 E2P_DATA(0x0e)
702#define E2P_PWR_INT_VALUE1 E2P_DATA(0x10)
703#define E2P_PWR_INT_VALUE2 E2P_DATA(0x12)
704#define E2P_PWR_INT_VALUE3 E2P_DATA(0x14)
705#define E2P_PWR_INT_VALUE4 E2P_DATA(0x16)
e85d0918
DD
706
707/* Contains a bit for each allowed channel. It gives for Europe (ETSI 0x30)
708 * also only 11 channels. */
ee302767
DD
709#define E2P_ALLOWED_CHANNEL E2P_DATA(0x18)
710
ee302767 711#define E2P_DEVICE_VER E2P_DATA(0x20)
92b3e2e9 712#define E2P_PHY_REG E2P_DATA(0x25)
ee302767
DD
713#define E2P_36M_CAL_VALUE1 E2P_DATA(0x28)
714#define E2P_36M_CAL_VALUE2 E2P_DATA(0x2a)
715#define E2P_36M_CAL_VALUE3 E2P_DATA(0x2c)
716#define E2P_36M_CAL_VALUE4 E2P_DATA(0x2e)
717#define E2P_11A_INT_VALUE1 E2P_DATA(0x30)
718#define E2P_11A_INT_VALUE2 E2P_DATA(0x32)
719#define E2P_11A_INT_VALUE3 E2P_DATA(0x34)
720#define E2P_11A_INT_VALUE4 E2P_DATA(0x36)
721#define E2P_48M_CAL_VALUE1 E2P_DATA(0x38)
722#define E2P_48M_CAL_VALUE2 E2P_DATA(0x3a)
723#define E2P_48M_CAL_VALUE3 E2P_DATA(0x3c)
724#define E2P_48M_CAL_VALUE4 E2P_DATA(0x3e)
725#define E2P_48M_INT_VALUE1 E2P_DATA(0x40)
726#define E2P_48M_INT_VALUE2 E2P_DATA(0x42)
727#define E2P_48M_INT_VALUE3 E2P_DATA(0x44)
728#define E2P_48M_INT_VALUE4 E2P_DATA(0x46)
729#define E2P_54M_CAL_VALUE1 E2P_DATA(0x48) /* ??? */
730#define E2P_54M_CAL_VALUE2 E2P_DATA(0x4a)
731#define E2P_54M_CAL_VALUE3 E2P_DATA(0x4c)
732#define E2P_54M_CAL_VALUE4 E2P_DATA(0x4e)
733#define E2P_54M_INT_VALUE1 E2P_DATA(0x50)
734#define E2P_54M_INT_VALUE2 E2P_DATA(0x52)
735#define E2P_54M_INT_VALUE3 E2P_DATA(0x54)
736#define E2P_54M_INT_VALUE4 E2P_DATA(0x56)
e85d0918 737
0ce34bc8
DD
738/* This word contains the base address of the FW_REG_ registers below */
739#define FWRAW_REGS_ADDR FWRAW_DATA(0x1d)
740
741/* All 16 bit values, offset from the address in FWRAW_REGS_ADDR */
742enum {
743 FW_REG_FIRMWARE_VER = 0,
744 /* non-zero if USB high speed connection */
745 FW_REG_USB_SPEED = 1,
746 FW_REG_FIX_TX_RATE = 2,
747 /* Seems to be able to control LEDs over the firmware */
748 FW_REG_LED_LINK_STATUS = 3,
749 FW_REG_SOFT_RESET = 4,
750 FW_REG_FLASH_CHK = 5,
751};
e85d0918 752
0ce34bc8 753/* Values for FW_LINK_STATUS */
583afd1e
UK
754#define FW_LINK_OFF 0x0
755#define FW_LINK_TX 0x1
756/* 0x2 - link led on? */
757
e85d0918
DD
758enum {
759 /* indices for ofdm_cal_values */
760 OFDM_36M_INDEX = 0,
761 OFDM_48M_INDEX = 1,
762 OFDM_54M_INDEX = 2,
763};
764
765struct zd_chip {
766 struct zd_usb usb;
767 struct zd_rf rf;
768 struct mutex mutex;
0ce34bc8
DD
769 /* Base address of FW_REG_ registers */
770 zd_addr_t fw_regs_base;
e85d0918
DD
771 /* EepSetPoint in the vendor driver */
772 u8 pwr_cal_values[E2P_CHANNEL_COUNT];
773 /* integration values in the vendor driver */
774 u8 pwr_int_values[E2P_CHANNEL_COUNT];
775 /* SetPointOFDM in the vendor driver */
776 u8 ofdm_cal_values[3][E2P_CHANNEL_COUNT];
583afd1e
UK
777 u16 link_led;
778 unsigned int pa_type:4,
779 patch_cck_gain:1, patch_cr157:1, patch_6m_band_edge:1,
ae6ead46 780 new_phy_layout:1, al2230s_bit:1,
74553aed 781 supports_tx_led:1;
e85d0918
DD
782};
783
784static inline struct zd_chip *zd_usb_to_chip(struct zd_usb *usb)
785{
786 return container_of(usb, struct zd_chip, usb);
787}
788
789static inline struct zd_chip *zd_rf_to_chip(struct zd_rf *rf)
790{
791 return container_of(rf, struct zd_chip, rf);
792}
793
794#define zd_chip_dev(chip) (&(chip)->usb.intf->dev)
795
796void zd_chip_init(struct zd_chip *chip,
459c51ad 797 struct ieee80211_hw *hw,
e85d0918
DD
798 struct usb_interface *intf);
799void zd_chip_clear(struct zd_chip *chip);
74553aed
DD
800int zd_chip_read_mac_addr_fw(struct zd_chip *chip, u8 *addr);
801int zd_chip_init_hw(struct zd_chip *chip);
e85d0918
DD
802int zd_chip_reset(struct zd_chip *chip);
803
74553aed
DD
804static inline int zd_chip_is_zd1211b(struct zd_chip *chip)
805{
806 return chip->usb.is_zd1211b;
807}
808
e85d0918
DD
809static inline int zd_ioread16v_locked(struct zd_chip *chip, u16 *values,
810 const zd_addr_t *addresses,
811 unsigned int count)
812{
813 ZD_ASSERT(mutex_is_locked(&chip->mutex));
814 return zd_usb_ioread16v(&chip->usb, values, addresses, count);
815}
816
817static inline int zd_ioread16_locked(struct zd_chip *chip, u16 *value,
818 const zd_addr_t addr)
819{
820 ZD_ASSERT(mutex_is_locked(&chip->mutex));
821 return zd_usb_ioread16(&chip->usb, value, addr);
822}
823
824int zd_ioread32v_locked(struct zd_chip *chip, u32 *values,
825 const zd_addr_t *addresses, unsigned int count);
826
827static inline int zd_ioread32_locked(struct zd_chip *chip, u32 *value,
828 const zd_addr_t addr)
829{
2c208890 830 return zd_ioread32v_locked(chip, value, &addr, 1);
e85d0918
DD
831}
832
833static inline int zd_iowrite16_locked(struct zd_chip *chip, u16 value,
834 zd_addr_t addr)
835{
836 struct zd_ioreq16 ioreq;
837
838 ZD_ASSERT(mutex_is_locked(&chip->mutex));
839 ioreq.addr = addr;
840 ioreq.value = value;
841
842 return zd_usb_iowrite16v(&chip->usb, &ioreq, 1);
843}
844
845int zd_iowrite16a_locked(struct zd_chip *chip,
846 const struct zd_ioreq16 *ioreqs, unsigned int count);
847
848int _zd_iowrite32v_locked(struct zd_chip *chip, const struct zd_ioreq32 *ioreqs,
849 unsigned int count);
850
851static inline int zd_iowrite32_locked(struct zd_chip *chip, u32 value,
852 zd_addr_t addr)
853{
854 struct zd_ioreq32 ioreq;
855
856 ioreq.addr = addr;
857 ioreq.value = value;
858
859 return _zd_iowrite32v_locked(chip, &ioreq, 1);
860}
861
862int zd_iowrite32a_locked(struct zd_chip *chip,
863 const struct zd_ioreq32 *ioreqs, unsigned int count);
864
865static inline int zd_rfwrite_locked(struct zd_chip *chip, u32 value, u8 bits)
866{
867 ZD_ASSERT(mutex_is_locked(&chip->mutex));
868 return zd_usb_rfwrite(&chip->usb, value, bits);
869}
870
ec62bd91
DD
871int zd_rfwrite_cr_locked(struct zd_chip *chip, u32 value);
872
e85d0918
DD
873int zd_rfwritev_locked(struct zd_chip *chip,
874 const u32* values, unsigned int count, u8 bits);
20fe2176
DD
875int zd_rfwritev_cr_locked(struct zd_chip *chip,
876 const u32* values, unsigned int count);
e85d0918
DD
877
878/* Locking functions for reading and writing registers.
879 * The different parameters are intentional.
880 */
881int zd_ioread16(struct zd_chip *chip, zd_addr_t addr, u16 *value);
882int zd_iowrite16(struct zd_chip *chip, zd_addr_t addr, u16 value);
883int zd_ioread32(struct zd_chip *chip, zd_addr_t addr, u32 *value);
884int zd_iowrite32(struct zd_chip *chip, zd_addr_t addr, u32 value);
885int zd_ioread32v(struct zd_chip *chip, const zd_addr_t *addresses,
886 u32 *values, unsigned int count);
887int zd_iowrite32a(struct zd_chip *chip, const struct zd_ioreq32 *ioreqs,
888 unsigned int count);
889
890int zd_chip_set_channel(struct zd_chip *chip, u8 channel);
891static inline u8 _zd_chip_get_channel(struct zd_chip *chip)
892{
893 return chip->rf.channel;
894}
895u8 zd_chip_get_channel(struct zd_chip *chip);
896int zd_read_regdomain(struct zd_chip *chip, u8 *regdomain);
e85d0918 897int zd_write_mac_addr(struct zd_chip *chip, const u8 *mac_addr);
c2fadcb3 898int zd_write_bssid(struct zd_chip *chip, const u8 *bssid);
e85d0918
DD
899int zd_chip_switch_radio_on(struct zd_chip *chip);
900int zd_chip_switch_radio_off(struct zd_chip *chip);
901int zd_chip_enable_int(struct zd_chip *chip);
902void zd_chip_disable_int(struct zd_chip *chip);
459c51ad
DD
903int zd_chip_enable_rxtx(struct zd_chip *chip);
904void zd_chip_disable_rxtx(struct zd_chip *chip);
e85d0918
DD
905int zd_chip_enable_hwint(struct zd_chip *chip);
906int zd_chip_disable_hwint(struct zd_chip *chip);
72018b22 907int zd_chip_generic_patch_6m_band(struct zd_chip *chip, int channel);
459c51ad 908int zd_chip_set_rts_cts_rate_locked(struct zd_chip *chip, int preamble);
b1382ede 909
e85d0918
DD
910static inline int zd_get_encryption_type(struct zd_chip *chip, u32 *type)
911{
912 return zd_ioread32(chip, CR_ENCRYPTION_TYPE, type);
913}
914
915static inline int zd_set_encryption_type(struct zd_chip *chip, u32 type)
916{
917 return zd_iowrite32(chip, CR_ENCRYPTION_TYPE, type);
918}
919
920static inline int zd_chip_get_basic_rates(struct zd_chip *chip, u16 *cr_rates)
921{
922 return zd_ioread16(chip, CR_BASIC_RATE_TBL, cr_rates);
923}
924
459c51ad 925int zd_chip_set_basic_rates(struct zd_chip *chip, u16 cr_rates);
e85d0918 926
e85d0918
DD
927int zd_chip_lock_phy_regs(struct zd_chip *chip);
928int zd_chip_unlock_phy_regs(struct zd_chip *chip);
929
930enum led_status {
14b46c8a
LR
931 ZD_LED_OFF = 0,
932 ZD_LED_SCANNING = 1,
933 ZD_LED_ASSOCIATED = 2,
e85d0918
DD
934};
935
583afd1e 936int zd_chip_control_leds(struct zd_chip *chip, enum led_status status);
e85d0918 937
b91a515d
JK
938int zd_set_beacon_interval(struct zd_chip *chip, u16 interval, u8 dtim_period,
939 int type);
e85d0918
DD
940
941static inline int zd_get_beacon_interval(struct zd_chip *chip, u32 *interval)
942{
943 return zd_ioread32(chip, CR_BCN_INTERVAL, interval);
944}
945
946struct rx_status;
947
459c51ad 948u8 zd_rx_rate(const void *rx_frame, const struct rx_status *status);
e85d0918 949
9cdac965
UK
950struct zd_mc_hash {
951 u32 low;
952 u32 high;
953};
954
955static inline void zd_mc_clear(struct zd_mc_hash *hash)
956{
957 hash->low = 0;
958 /* The interfaces must always received broadcasts.
959 * The hash of the broadcast address ff:ff:ff:ff:ff:ff is 63.
960 */
961 hash->high = 0x80000000;
962}
963
964static inline void zd_mc_add_all(struct zd_mc_hash *hash)
965{
966 hash->low = hash->high = 0xffffffff;
967}
968
969static inline void zd_mc_add_addr(struct zd_mc_hash *hash, u8 *addr)
970{
971 unsigned int i = addr[5] >> 2;
972 if (i < 32) {
973 hash->low |= 1 << i;
974 } else {
975 hash->high |= 1 << (i-32);
976 }
977}
978
979int zd_chip_set_multicast_hash(struct zd_chip *chip,
980 struct zd_mc_hash *hash);
981
5fe73197
AF
982u64 zd_chip_get_tsf(struct zd_chip *chip);
983
e85d0918 984#endif /* _ZD_CHIP_H */
This page took 1.379986 seconds and 5 git commands to generate.