1 /*        $NetBSD: bwireg.h,v 1.5 2025/01/19 00:29:28 jmcneill Exp $  */
2 /*        $OpenBSD: bwireg.h,v 1.7 2007/11/17 16:50:02 mglocker Exp $ */
3 
4 /*
5  * Copyright (c) 2007 The DragonFly Project.  All rights reserved.
6  *
7  * This code is derived from software contributed to The DragonFly Project
8  * by Sepherosa Ziehau <sepherosa@gmail.com>
9  *
10  * Redistribution and use in source and binary forms, with or without
11  * modification, are permitted provided that the following conditions
12  * are met:
13  *
14  * 1. Redistributions of source code must retain the above copyright
15  *    notice, this list of conditions and the following disclaimer.
16  * 2. Redistributions in binary form must reproduce the above copyright
17  *    notice, this list of conditions and the following disclaimer in
18  *    the documentation and/or other materials provided with the
19  *    distribution.
20  * 3. Neither the name of The DragonFly Project nor the names of its
21  *    contributors may be used to endorse or promote products derived
22  *    from this software without specific, prior written permission.
23  *
24  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
25  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
26  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
27  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE
28  * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
29  * INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING,
30  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
31  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
32  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
33  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
34  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
35  * SUCH DAMAGE.
36  *
37  * $DragonFly: src/sys/dev/netif/bwi/if_bwireg.h,v 1.1 2007/09/08 06:15:54 sephe Exp $
38  */
39 
40 #ifndef _DEV_IC_BWIREG_H
41 #define _DEV_IC_BWIREG_H
42 
43 /*
44  * Registers for all of the register windows
45  */
46 #define BWI_FLAGS                       0x00000f18
47 #define BWI_FLAGS_INTR_MASK             0x0000003f
48 
49 #define BWI_IMSTATE                     0x00000f90
50 #define BWI_IMSTATE_INBAND_ERR                    (1 << 17)
51 #define BWI_IMSTATE_TIMEOUT             (1 << 18)
52 
53 #define BWI_INTRVEC                     0x00000f94
54 
55 #define BWI_STATE_LO                              0x00000f98
56 #define BWI_STATE_LO_RESET              (1 << 0)
57 #define BWI_STATE_LO_DISABLE1           (1 << 1)
58 #define BWI_STATE_LO_DISABLE2           (1 << 2)
59 #define BWI_STATE_LO_CLOCK              (1 << 16)
60 #define BWI_STATE_LO_GATED_CLOCK        (1 << 17)
61 #define BWI_STATE_LO_FLAG_PHYCLKEN      (1 << 0)
62 #define BWI_STATE_LO_FLAG_PHYRST        (1 << 1)
63 #define BWI_STATE_LO_FLAG_PHYLNK        (1 << 11)
64 #define BWI_STATE_LO_FLAGS_MASK                   0x3ffc0000
65 
66 #define BWI_STATE_HI                              0x00000f9c
67 #define BWI_STATE_HI_SERROR             (1 << 0)
68 #define BWI_STATE_HI_BUSY               (1 << 2)
69 #define BWI_STATE_HI_FLAG_MAGIC1        0x1
70 #define BWI_STATE_HI_FLAG_MAGIC2        0x2
71 #define BWI_STATE_HI_FLAG_64BIT                   0x1000
72 #define BWI_STATE_HI_FLAGS_MASK                   0x1fff0000
73 
74 #define BWI_CONF_LO                     0x00000fa8
75 #define BWI_CONF_LO_SERVTO_MASK                   0x00000007          /* service timeout */
76 #define BWI_CONF_LO_SERVTO              2
77 #define BWI_CONF_LO_REQTO_MASK                    0x00000070          /* request timeout */
78 #define BWI_CONF_LO_REQTO               3
79 
80 #define BWI_ID_LO                       0x00000ff8
81 #define BWI_ID_LO_BUSREV_MASK           0xf0000000
82 /* Bus revision */
83 #define BWI_BUSREV_0                              0
84 #define BWI_BUSREV_1                              1
85 
86 #define BWI_ID_HI                       0x00000ffc
87 #define BWI_ID_HI_REGWIN_REV(v)                   (((v) & 0xf) | (((v) & 0x7000) >> 8))
88 #define BWI_ID_HI_REGWIN_TYPE(v)        (((v) & 0x8ff0) >> 4)
89 #define BWI_ID_HI_REGWIN_VENDOR_MASK    0xffff0000
90 
91 /*
92  * Registers for common register window
93  */
94 #define BWI_INFO                        0x00000000
95 #define BWI_INFO_BBPID_MASK             0x0000ffff
96 #define BWI_INFO_BBPREV_MASK            0x000f0000
97 #define BWI_INFO_BBPPKG_MASK            0x00f00000
98 #define BWI_INFO_NREGWIN_MASK           0x0f000000
99 
100 #define BWI_CAPABILITY                            0x00000004
101 #define BWI_CAP_CLKMODE                           (1 << 18)
102 
103 #define BWI_CONTROL                     0x00000028
104 #define BWI_CONTROL_MAGIC0              0x3a4
105 #define BWI_CONTROL_MAGIC1              0xa4
106 #define BWI_PLL_ON_DELAY                0xb0
107 #define BWI_FREQ_SEL_DELAY              0xb4
108 
109 #define BWI_CLOCK_CTRL                            0x000000b8
110 #define BWI_CLOCK_CTRL_CLKSRC           (7 << 0)
111 #define BWI_CLOCK_CTRL_SLOW             (1 << 11)
112 #define BWI_CLOCK_CTRL_IGNPLL           (1 << 12)
113 #define BWI_CLOCK_CTRL_NODYN            (1 << 13)
114 #define BWI_CLOCK_CTRL_FDIV             (0xffff << 16)      /* freq divisor */
115 
116 /* Possible values for BWI_CLOCK_CTRL_CLKSRC */
117 #define BWI_CLKSRC_LP_OSC               0         /* Low power oscillator */
118 #define BWI_CLKSRC_CS_OSC               1         /* Crystal oscillator */
119 #define BWI_CLKSRC_PCI                            2
120 #define BWI_CLKSRC_MAX                            3         /* Maximum of clock source */
121 /* Min/Max frequency for given clock source */
122 #define BWI_CLKSRC_LP_OSC_FMIN                    25000
123 #define BWI_CLKSRC_LP_OSC_FMAX                    43000
124 #define BWI_CLKSRC_CS_OSC_FMIN                    19800000
125 #define BWI_CLKSRC_CS_OSC_FMAX                    20200000
126 #define BWI_CLKSRC_PCI_FMIN             25000000
127 #define BWI_CLKSRC_PCI_FMAX             34000000
128 
129 #define BWI_CLOCK_INFO                            0x000000c0
130 #define BWI_CLOCK_INFO_FDIV             (0xffff << 16)      /* freq divisor */
131 
132 /*
133  * Registers for bus register window
134  */
135 #define BWI_BUS_ADDR                              0x00000050
136 #define BWI_BUS_ADDR_MAGIC              0xfd8
137 
138 #define BWI_BUS_DATA                              0x00000054
139 
140 #define BWI_BUS_CONFIG                            0x00000108
141 #define BWI_BUS_CONFIG_PREFETCH                   (1 << 2)
142 #define BWI_BUS_CONFIG_BURST            (1 << 3)
143 #define BWI_BUS_CONFIG_MRM              (1 << 5)
144 
145 /*
146  * Register for MAC
147  */
148 #define BWI_TXRX_INTR_STATUS_BASE       0x20
149 #define BWI_TXRX_INTR_MASK_BASE                   0x24
150 #define BWI_TXRX_INTR_STATUS(i)                   (BWI_TXRX_INTR_STATUS_BASE + ((i) * 8))
151 #define BWI_TXRX_INTR_MASK(i)           (BWI_TXRX_INTR_MASK_BASE + ((i) * 8))
152 
153 #define BWI_PIO_TXCTL(qid)              (0x0000300 + (qid) * 0x10 + 0x0)
154 #define BWI_PIO_TXCTL_VALID             (0xf << 0)
155 #define BWI_PIO_TXCTL_VALID_BYTES(n)    ((1 << (n)) - 1)
156 #define BWI_PIO_TXCTL_EOF               (1 << 4)
157 #define BWI_PIO_TXCTL_FREADY            (1 << 7)
158 #define BWI_PIO_TXDATA(qid)             (0x0000300 + (qid) * 0x10 + 0x4)
159 
160 #define BWI_PIO_RXCTL(qid)              (0x0000300 + (qid) * 0x10 + 0x8)
161 #define BWI_PIO_RXCTL_FRAMERDY                    (1 << 0)
162 #define BWI_PIO_RXCTL_DATARDY           (1 << 1)
163 #define BWI_PIO_RXDATA(qid)             (0x0000300 + (qid) * 0x10 + 0xc)
164 
165 #define BWI_MAC_STATUS                            0x00000120
166 #define BWI_MAC_STATUS_ENABLE           (1 << 0)
167 #define BWI_MAC_STATUS_UCODE_START      (1 << 1)
168 #define BWI_MAC_STATUS_UCODE_JUMP0      (1 << 2)
169 #define BWI_MAC_STATUS_IHREN            (1 << 10)
170 #define BWI_MAC_STATUS_GPOSEL_MASK      (3 << 14)
171 #define BWI_MAC_STATUS_BSWAP            (1 << 16)
172 #define BWI_MAC_STATUS_INFRA            (1 << 17)
173 #define BWI_MAC_STATUS_OPMODE_HOSTAP    (1 << 18)
174 #define BWI_MAC_STATUS_RFLOCK           (1 << 19)
175 #define BWI_MAC_STATUS_PASS_BCN                   (1 << 20)
176 #define BWI_MAC_STATUS_PASS_BADPLCP     (1 << 21)
177 #define BWI_MAC_STATUS_PASS_CTL                   (1 << 22)
178 #define BWI_MAC_STATUS_PASS_BADFCS      (1 << 23)
179 #define BWI_MAC_STATUS_PROMISC                    (1 << 24)
180 #define BWI_MAC_STATUS_HW_PS            (1 << 25)
181 #define BWI_MAC_STATUS_WAKEUP           (1 << 26)
182 #define BWI_MAC_STATUS_PHYLNK           (1 << 31)
183 
184 #define BWI_MAC_INTR_STATUS             0x00000128
185 #define BWI_MAC_INTR_MASK               0x0000012c
186 
187 #define BWI_MAC_TMPLT_CTRL              0x00000130
188 #define BWI_MAC_TMPLT_DATA              0x00000134
189 
190 #define BWI_MAC_PS_STATUS               0x00000140
191 
192 #define BWI_MOBJ_CTRL                             0x00000160
193 #define BWI_MOBJ_CTRL_VAL(objid, ofs)   ((objid) << 16 | (ofs))
194 #define BWI_MOBJ_DATA                             0x00000164
195 #define BWI_MOBJ_DATA_UNALIGN           0x0166
196 
197 /*
198  * Memory object IDs
199  */
200 #define BWI_WR_MOBJ_AUTOINC             0x100     /* Auto-increment wr */
201 #define BWI_RD_MOBJ_AUTOINC             0x200     /* Auto-increment rd */
202 /* Firmware ucode object */
203 #define BWI_FW_UCODE_MOBJ               0x0
204 /* Common object */
205 #define BWI_COMM_MOBJ                             0x1
206 #define BWI_COMM_MOBJ_FWREV             0x0
207 #define BWI_COMM_MOBJ_FWPATCHLV                   0x2
208 #define BWI_COMM_MOBJ_SLOTTIME                    0x10
209 #define BWI_COMM_MOBJ_MACREV            0x16
210 #define BWI_COMM_MOBJ_TX_ACK            0x22
211 #define BWI_COMM_MOBJ_RXPADOFF                    0x34
212 #define BWI_COMM_MOBJ_UCODE_STATE       0x40
213 #define BWI_COMM_MOBJ_SHRETRY_FB        0x44
214 #define BWI_COMM_MOBJ_LGRETEY_FB        0x46
215 #define BWI_COMM_MOBJ_TX_BEACON                   0x54
216 #define BWI_COMM_MOBJ_KEYTABLE_OFS      0x56
217 #define BWI_COMM_MOBJ_TSSI_DS           0x58
218 #define BWI_COMM_MOBJ_HFLAGS_LO                   0x5e
219 #define BWI_COMM_MOBJ_HFLAGS_MI                   0x60
220 #define BWI_COMM_MOBJ_HFLAGS_HI                   0x62
221 #define BWI_COMM_MOBJ_RF_ATTEN                    0x64
222 #define BWI_COMM_MOBJ_TSSI_OFDM                   0x70
223 #define BWI_COMM_MOBJ_PROBE_RESP_TO     0x74
224 #define BWI_COMM_MOBJ_CHAN              0xa0
225 #define BWI_COMM_MOBJ_KEY_ALGO                    0x100
226 #define BWI_COMM_MOBJ_TX_PROBE_RESP     0x188
227 #define BWI_HFLAG_AUTO_ANTDIV           0x1ULL
228 #define BWI_HFLAG_SYM_WA                0x2ULL    /* ??? SYM work around */
229 #define BWI_HFLAG_PWR_BOOST_DS                    0x8ULL
230 #define BWI_HFLAG_GDC_WA                0x20ULL   /* ??? GDC work around */
231 #define BWI_HFLAG_OFDM_PA               0x40ULL
232 #define BWI_HFLAG_NOT_JAPAN             0x80ULL
233 #define BWI_HFLAG_MAGIC1                0x200ULL
234 #define BWI_UCODE_STATE_PS              4
235 #define BWI_LO_TSSI_MASK                0x00ff
236 #define BWI_HI_TSSI_MASK                0xff00
237 #define BWI_INVALID_TSSI                0x7f
238 /* 802.11 object */
239 #define BWI_80211_MOBJ                            0x2
240 #define BWI_80211_MOBJ_CWMIN            0xc
241 #define BWI_80211_MOBJ_CWMAX            0x10
242 #define BWI_80211_MOBJ_SHRETRY                    0x18
243 #define BWI_80211_MOBJ_LGRETRY                    0x1c
244 /* Firmware PCM object */
245 #define BWI_FW_PCM_MOBJ                           0x3
246 /* MAC address of pairwise keys */
247 #define BWI_PKEY_ADDR_MOBJ              0x4
248 
249 /* [TRC: XXX Adapt DragonFlyBSD's more elaborate TX status flags, perhaps.
250    See bwi_txeof &c.] */
251 #define BWI_TXSTATUS_0                            0x00000170
252 #define BWI_TXSTATUS_0_MORE             (1 << 0)
253 #define BWI_TXSTATUS_0_TXID_MASK        0xffff0000
254 #define BWI_TXSTATUS_0_INFO(st)                   (((st) & 0xfff0) | (((st) & 0xf) >> 1))
255 #define BWI_TXSTATUS_1                            0x00000174
256 
257 #define BWI_TXRX_CTRL_BASE              0x200
258 #define BWI_TX32_CTRL                             0x0
259 #define BWI_TX32_RINGINFO               0x4
260 #define BWI_TX32_INDEX                            0x8
261 #define BWI_TX32_STATUS                           0xc
262 #define BWI_TX32_STATUS_STATE_MASK      0xf000
263 #define BWI_TX32_STATUS_STATE_DISABLED  0
264 #define BWI_TX32_STATUS_STATE_IDLE      2
265 #define BWI_TX32_STATUS_STATE_STOPPED   3
266 #define BWI_RX32_CTRL                             0x10
267 #define BWI_RX32_CTRL_HDRSZ_MASK        0x00fe
268 #define BWI_RX32_CTRL_DIRECT_FIFO       0x0100
269 #define BWI_RX32_RINGINFO               0x14
270 #define BWI_RX32_INDEX                            0x18
271 #define BWI_RX32_STATUS                           0x1c
272 #define BWI_RX32_STATUS_INDEX_MASK      0x0fff
273 #define BWI_RX32_STATUS_STATE_MASK      0xf000
274 #define BWI_RX32_STATUS_STATE_DISABLED  0
275 /* Shared by 32bit TX/RX CTRL */
276 #define BWI_TXRX32_CTRL_ENABLE                    (1 << 0)
277 #define BWI_TXRX32_CTRL_ADDRHI_MASK     0x00030000
278 /* Shared by 32bit TX/RX RINGINFO */
279 #define BWI_TXRX32_RINGINFO_FUNC_TXRX   0x1
280 #define BWI_TXRX32_RINGINFO_FUNC_MASK   0xc0000000
281 #define BWI_TXRX32_RINGINFO_ADDR_MASK   0x3fffffff
282 
283 #define BWI_PHYINFO                     0x03e0
284 #define BWI_PHYINFO_REV_MASK            0x000f
285 #define BWI_PHYINFO_TYPE_MASK           0x0f00
286 #define BWI_PHYINFO_TYPE_11A            0
287 #define BWI_PHYINFO_TYPE_11B            1
288 #define BWI_PHYINFO_TYPE_11G            2
289 #define BWI_PHYINFO_TYPE_11N            4
290 #define BWI_PHYINFO_TYPE_11LP           5
291 #define BWI_PHYINFO_VER_MASK            0xf000
292 
293 #define BWI_RF_ANTDIV                             0x03e2    /* Antenna Diversity ?? */
294 
295 #define BWI_PHY_MAGIC_REG1              0x03e4
296 #define BWI_PHY_MAGIC_REG1_VAL1                   0x3000
297 #define BWI_PHY_MAGIC_REG1_VAL2                   0x0009
298 
299 #define BWI_BBP_ATTEN                             0x03e6
300 #define BWI_BBP_ATTEN_MAGIC             0x00f4
301 #define BWI_BBP_ATTEN_MAGIC2            0x8140
302 
303 #define BWI_BPHY_CTRL                             0x03ec
304 #define BWI_BPHY_CTRL_INIT              0x3f22
305 
306 #define BWI_RF_CHAN                     0x03f0
307 #define BWI_RF_CHAN_EX                            0x03f4
308 
309 #define BWI_RF_CTRL                     0x03f6
310 /* Register values for BWI_RF_CTRL */
311 #define BWI_RF_CTRL_RFINFO              0x1
312 /* XXX extra bits for reading from radio */
313 #define BWI_RF_CTRL_RD_11A              0x40
314 #define BWI_RF_CTRL_RD_11BG             0x80
315 #define BWI_RF_DATA_HI                            0x3f8
316 #define BWI_RF_DATA_LO                            0x3fa
317 /* Values read from BWI_RF_DATA_{HI,LO} after BWI_RF_CTRL_RFINFO */
318 #define BWI_RFINFO_MANUFACT_MASK        0x0fff
319 #define BWI_RF_MANUFACT_BCM             0x17f               /* XXX */
320 #define BWI_RFINFO_TYPE_MASK            0x0ffff000
321 #define BWI_RF_T_BCM2050                0x2050
322 #define BWI_RF_T_BCM2053                0x2053
323 #define BWI_RF_T_BCM2060                0x2060
324 #define BWI_RFINFO_REV_MASK             0xf0000000
325 
326 #define BWI_PHY_CTRL                              0x03fc
327 #define BWI_PHY_DATA                              0x03fe
328 
329 #define BWI_ADDR_FILTER_CTRL            0x0420
330 #define BWI_ADDR_FILTER_CTRL_SET        0x0020
331 #define BWI_ADDR_FILTER_MYADDR                    0
332 #define BWI_ADDR_FILTER_BSSID           3
333 #define BWI_ADDR_FILTER_DATA            0x422
334 
335 #define BWI_MAC_GPIO_CTRL               0x049c
336 #define BWI_MAC_GPIO_MASK               0x049e
337 #define BWI_MAC_PRE_TBTT                0x0612
338 #define BWI_MAC_SLOTTIME                0x0684
339 #define BWI_MAC_SLOTTIME_ADJUST                   510
340 #define BWI_MAC_POWERUP_DELAY           0x06a8
341 
342 /*
343  * Special registers
344  */
345 /*
346  * GPIO control
347  * If common regwin exists, then it is within common regwin,
348  * else it is in bus regwin.
349  */
350 #define BWI_GPIO_CTRL                             0x0000006c
351 
352 /*
353  * Extended PCI registers
354  */
355 #define BWI_PCIR_BAR                              0x10 /* [TRC: Was PCIR_BAR(0).] */
356 #define BWI_PCIR_SEL_REGWIN             0x00000080
357 /* Register value for BWI_PCIR_SEL_REGWIN */
358 #define BWI_PCIM_REGWIN(id)             (((id) * 0x1000) + 0x18000000)
359 #define BWI_PCIR_GPIO_IN                0x000000b0
360 #define BWI_PCIR_GPIO_OUT               0x000000b4
361 #define BWI_PCIM_GPIO_OUT_CLKSRC        (1 << 4)
362 #define BWI_PCIR_GPIO_ENABLE            0x000000b8
363 /* Register values for BWI_PCIR_GPIO_{IN,OUT,ENABLE} */
364 #define BWI_PCIM_GPIO_PWR_ON            (1 << 6)
365 #define BWI_PCIM_GPIO_PLL_PWR_OFF       (1 << 7)
366 #define BWI_PCIR_INTCTL                           0x00000094
367 
368 /*
369  * PCI subdevice IDs
370  */
371 #define BWI_PCI_SUBDEVICE_BU4306        0x416
372 #define BWI_PCI_SUBDEVICE_BCM4309G      0x421
373 
374 #define BWI_IS_BRCM_BU4306(sc)                                                  \
375           ((sc)->sc_pci_subvid == PCI_VENDOR_BROADCOM &&              \
376            (sc)->sc_pci_subdid == BWI_PCI_SUBDEVICE_BU4306)
377 #define BWI_IS_BRCM_BCM4309G(sc)                                      \
378           ((sc)->sc_pci_subvid == PCI_VENDOR_BROADCOM &&              \
379            (sc)->sc_pci_subdid == BWI_PCI_SUBDEVICE_BCM4309G)
380 
381 /*
382  * EEPROM start address
383  */
384 #define BWI_SPROM_START                           0x1000
385 #define BWI_SPROM_11BG_EADDR            0x48
386 #define BWI_SPROM_11A_EADDR             0x54
387 #define BWI_SPROM_CARD_INFO             0x5c
388 #define BWI_SPROM_CARD_INFO_LOCALE      (0x0f << 8)
389 #define BWI_SPROM_LOCALE_JAPAN                    5
390 #define BWI_SPROM_PA_PARAM_11BG                   0x5e
391 #define BWI_SPROM_GPIO01                0x64
392 #define BWI_SPROM_GPIO_0                0x00ff
393 #define BWI_SPROM_GPIO_1                0xff00
394 #define BWI_SPROM_GPIO23                0x0066
395 #define BWI_SPROM_GPIO_2                0x00ff
396 #define BWI_SPROM_GPIO_3                0xff00
397 #define BWI_SPROM_MAX_TXPWR             0x68
398 #define BWI_SPROM_MAX_TXPWR_MASK_11BG   0x00ff              /* XXX */
399 #define BWI_SPROM_MAX_TXPWR_MASK_11A    0xff00              /* XXX */
400 #define BWI_SPROM_PA_PARAM_11A                    0x6a
401 #define BWI_SPROM_IDLE_TSSI             0x70
402 #define BWI_SPROM_IDLE_TSSI_MASK_11BG   0x00ff              /* XXX */
403 #define BWI_SPROM_IDLE_TSSI_MASK_11A    0xff00              /* XXX */
404 #define BWI_SPROM_CARD_FLAGS            0x72
405 #define BWI_SPROM_ANT_GAIN              0x74
406 #define BWI_SPROM_ANT_GAIN_MASK_11A     0x00ff
407 #define BWI_SPROM_ANT_GAIN_MASK_11BG    0xff00
408 
409 /*
410  * SPROM card flags
411  */
412 #define BWI_CARD_F_PA_GPIO9             (1 << 1)  /* GPIO 9 controls PA */
413 #define BWI_CARD_F_SW_NRSSI             (1 << 3)
414 #define BWI_CARD_F_NO_SLOWCLK           (1 << 5)  /* no slow clock */
415 #define BWI_CARD_F_EXT_LNA              (1 << 12) /* external LNA */
416 #define BWI_CARD_F_ALT_IQ               (1 << 15) /* alternate I/Q */
417 
418 /*
419  * PROM GPIO
420  */
421 #define BWI_LED_ACT_LOW                           (1 << 7)
422 #define BWI_LED_ACT_MASK                0x7f
423 #define BWI_LED_ACT_OFF                           0
424 #define BWI_LED_ACT_ON                            1
425 #define BWI_LED_ACT_BLINK               2
426 #define BWI_LED_ACT_RF_ENABLED                    3
427 #define BWI_LED_ACT_5GHZ                4
428 #define BWI_LED_ACT_2GHZ                5
429 #define BWI_LED_ACT_11G                           6
430 #define BWI_LED_ACT_BLINK_SLOW                    7
431 #define BWI_LED_ACT_BLINK_POLL                    8
432 #define BWI_LED_ACT_UNKN                9
433 #define BWI_LED_ACT_ASSOC               10
434 #define BWI_LED_ACT_NULL                11
435 
436 #define BWI_VENDOR_LED_ACT_COMPAQ       \
437           BWI_LED_ACT_RF_ENABLED,                 \
438           BWI_LED_ACT_2GHZ,             \
439           BWI_LED_ACT_5GHZ,             \
440           BWI_LED_ACT_OFF
441 
442 #define BWI_VENDOR_LED_ACT_LINKSYS      \
443           BWI_LED_ACT_ASSOC,            \
444           BWI_LED_ACT_2GHZ,             \
445           BWI_LED_ACT_5GHZ,             \
446           BWI_LED_ACT_OFF
447 
448 #define BWI_VENDOR_LED_ACT_DEFAULT      \
449           BWI_LED_ACT_BLINK,            \
450           BWI_LED_ACT_2GHZ,             \
451           BWI_LED_ACT_5GHZ,             \
452           BWI_LED_ACT_OFF
453 
454 /*
455  * BBP IDs
456  */
457 #define BWI_BBPID_BCM4301               0x4301
458 #define BWI_BBPID_BCM4306               0x4306
459 #define BWI_BBPID_BCM4317               0x4317
460 #define BWI_BBPID_BCM4320               0x4320
461 #define BWI_BBPID_BCM4321               0x4321
462 
463 /*
464  * Register window types
465  */
466 #define BWI_REGWIN_T_COM                0x800
467 #define BWI_REGWIN_T_BUSPCI             0x804
468 #define BWI_REGWIN_T_MAC                0x812
469 #define BWI_REGWIN_T_BUSPCIE            0x820
470 
471 /*
472  * MAC interrupts
473  */
474 #define BWI_INTR_READY                            (1 << 0)
475 #define BWI_INTR_BEACON                           (1 << 1)
476 #define BWI_INTR_TBTT                             (1 << 2)
477 #define BWI_INTR_EO_ATIM                (1 << 5)  /* End of ATIM */
478 #define BWI_INTR_PMQ                              (1 << 6)  /* XXX?? */
479 #define BWI_INTR_MAC_TXERR              (1 << 9)
480 #define BWI_INTR_PHY_TXERR              (1 << 11)
481 #define BWI_INTR_TIMER1                           (1 << 14)
482 #define BWI_INTR_RX_DONE                (1 << 15)
483 #define BWI_INTR_TX_FIFO                (1 << 16) /* XXX?? */
484 #define BWI_INTR_NOISE                            (1 << 18)
485 #define BWI_INTR_RF_DISABLED            (1 << 28)
486 #define BWI_INTR_TX_DONE                (1 << 29)
487 
488 #define BWI_INIT_INTRS                                                                    \
489           (BWI_INTR_READY | BWI_INTR_BEACON | BWI_INTR_TBTT |                   \
490            BWI_INTR_EO_ATIM | BWI_INTR_PMQ | BWI_INTR_MAC_TXERR |               \
491            BWI_INTR_PHY_TXERR | BWI_INTR_RX_DONE | BWI_INTR_TX_FIFO | \
492            BWI_INTR_NOISE | BWI_INTR_RF_DISABLED | BWI_INTR_TX_DONE)
493 #define BWI_ALL_INTRS                             0xffffffff
494 
495 /*
496  * TX/RX interrupts
497  */
498 #define BWI_TXRX_INTR_ERROR             ((1 << 15) | (1 << 14) | (1 << 12) | \
499                                                    (1 << 11) | (1 << 10))
500 #define BWI_TXRX_INTR_RX                (1 << 16)
501 #define BWI_TXRX_TX_INTRS               BWI_TXRX_INTR_ERROR
502 #define BWI_TXRX_RX_INTRS               (BWI_TXRX_INTR_ERROR | BWI_TXRX_INTR_RX)
503 #define BWI_TXRX_IS_RX(i)               ((i) % 3 == 0)
504 
505 /* PHY */
506 
507 #define BWI_PHYR_NRSSI_THR_11B                    0x020
508 #define BWI_PHYR_BBP_ATTEN              0x060
509 #define BWI_PHYR_TBL_CTRL_11A           0x072
510 #define BWI_PHYR_TBL_DATA_LO_11A        0x073
511 #define BWI_PHYR_TBL_DATA_HI_11A        0x074
512 #define BWI_PHYR_TBL_CTRL_11G           0x472
513 #define BWI_PHYR_TBL_DATA_LO_11G        0x473
514 #define BWI_PHYR_TBL_DATA_HI_11G        0x474
515 #define BWI_PHYR_NRSSI_THR_11G                    0x48a
516 #define BWI_PHYR_NRSSI_CTRL             0x803
517 #define BWI_PHYR_NRSSI_DATA             0x804
518 #define BWI_PHYR_RF_LO                            0x810
519 
520 /*
521  * PHY Tables
522  */
523 /*
524  * http://bcm-specs.sipsolutions.net/APHYSetup/FineFrequency
525  * G PHY
526  */
527 #define BWI_PHY_FREQ_11G_REV1                                                   \
528           0x0089,   0x02e9,   0x0409,   0x04e9,   0x05a9,   0x0669,   0x0709,   0x0789,   \
529           0x0829,   0x08a9,   0x0929,   0x0989,   0x0a09,   0x0a69,   0x0ac9,   0x0b29,   \
530           0x0ba9,   0x0be9,   0x0c49,   0x0ca9,   0x0d09,   0x0d69,   0x0da9,   0x0e09,   \
531           0x0e69,   0x0ea9,   0x0f09,   0x0f49,   0x0fa9,   0x0fe9,   0x1029,   0x1089,   \
532           0x10c9,   0x1109,   0x1169,   0x11a9,   0x11e9,   0x1229,   0x1289,   0x12c9,   \
533           0x1309,   0x1349,   0x1389,   0x13c9,   0x1409,   0x1449,   0x14a9,   0x14e9,   \
534           0x1529,   0x1569,   0x15a9,   0x15e9,   0x1629,   0x1669,   0x16a9,   0x16e8,   \
535           0x1728,   0x1768,   0x17a8,   0x17e8,   0x1828,   0x1868,   0x18a8,   0x18e8,   \
536           0x1928,   0x1968,   0x19a8,   0x19e8,   0x1a28,   0x1a68,   0x1aa8,   0x1ae8,   \
537           0x1b28,   0x1b68,   0x1ba8,   0x1be8,   0x1c28,   0x1c68,   0x1ca8,   0x1ce8,   \
538           0x1d28,   0x1d68,   0x1dc8,   0x1e08,   0x1e48,   0x1e88,   0x1ec8,   0x1f08,   \
539           0x1f48,   0x1f88,   0x1fe8,   0x2028,   0x2068,   0x20a8,   0x2108,   0x2148,   \
540           0x2188,   0x21c8,   0x2228,   0x2268,   0x22c8,   0x2308,   0x2348,   0x23a8,   \
541           0x23e8,   0x2448,   0x24a8,   0x24e8,   0x2548,   0x25a8,   0x2608,   0x2668,   \
542           0x26c8,   0x2728,   0x2787,   0x27e7,   0x2847,   0x28c7,   0x2947,   0x29a7,   \
543           0x2a27,   0x2ac7,   0x2b47,   0x2be7,   0x2ca7,   0x2d67,   0x2e47,   0x2f67,   \
544           0x3247,   0x3526,   0x3646,   0x3726,   0x3806,   0x38a6,   0x3946,   0x39e6,   \
545           0x3a66,   0x3ae6,   0x3b66,   0x3bc6,   0x3c45,   0x3ca5,   0x3d05,   0x3d85,   \
546           0x3de5,   0x3e45,   0x3ea5,   0x3ee5,   0x3f45,   0x3fa5,   0x4005,   0x4045,   \
547           0x40a5,   0x40e5,   0x4145,   0x4185,   0x41e5,   0x4225,   0x4265,   0x42c5,   \
548           0x4305,   0x4345,   0x43a5,   0x43e5,   0x4424,   0x4464,   0x44c4,   0x4504,   \
549           0x4544,   0x4584,   0x45c4,   0x4604,   0x4644,   0x46a4,   0x46e4,   0x4724,   \
550           0x4764,   0x47a4,   0x47e4,   0x4824,   0x4864,   0x48a4,   0x48e4,   0x4924,   \
551           0x4964,   0x49a4,   0x49e4,   0x4a24,   0x4a64,   0x4aa4,   0x4ae4,   0x4b23,   \
552           0x4b63,   0x4ba3,   0x4be3,   0x4c23,   0x4c63,   0x4ca3,   0x4ce3,   0x4d23,   \
553           0x4d63,   0x4da3,   0x4de3,   0x4e23,   0x4e63,   0x4ea3,   0x4ee3,   0x4f23,   \
554           0x4f63,   0x4fc3,   0x5003,   0x5043,   0x5083,   0x50c3,   0x5103,   0x5143,   \
555           0x5183,   0x51e2,   0x5222,   0x5262,   0x52a2,   0x52e2,   0x5342,   0x5382,   \
556           0x53c2,   0x5402,   0x5462,   0x54a2,   0x5502,   0x5542,   0x55a2,   0x55e2,   \
557           0x5642,   0x5682,   0x56e2,   0x5722,   0x5782,   0x57e1,   0x5841,   0x58a1,   \
558           0x5901,   0x5961,   0x59c1,   0x5a21,   0x5aa1,   0x5b01,   0x5b81,   0x5be1,   \
559           0x5c61,   0x5d01,   0x5d80,   0x5e20,   0x5ee0,   0x5fa0,   0x6080,   0x61c0
560 
561 /*
562  * http://bcm-specs.sipsolutions.net/APHYSetup/noise_table
563  */
564 /* G PHY Revision 1 */
565 #define BWI_PHY_NOISE_11G_REV1 \
566           0x013c,   0x01f5,   0x031a,   0x0631,   0x0001,   0x0001,   0x0001,   0x0001
567 /* G PHY generic */
568 #define BWI_PHY_NOISE_11G \
569           0x5484, 0x3c40, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000
570 
571 /*
572  * http://bcm-specs.sipsolutions.net/APHYSetup/rotor_table
573  * G PHY Revision 1
574  */
575 #define BWI_PHY_ROTOR_11G_REV1                                        \
576           0xfeb93ffd, 0xfec63ffd, 0xfed23ffd, 0xfedf3ffd,   \
577           0xfeec3ffe, 0xfef83ffe, 0xff053ffe, 0xff113ffe,   \
578           0xff1e3ffe, 0xff2a3fff, 0xff373fff, 0xff443fff,   \
579           0xff503fff, 0xff5d3fff, 0xff693fff, 0xff763fff,   \
580           0xff824000, 0xff8f4000, 0xff9b4000, 0xffa84000,   \
581           0xffb54000, 0xffc14000, 0xffce4000, 0xffda4000,   \
582           0xffe74000, 0xfff34000, 0x00004000, 0x000d4000,   \
583           0x00194000, 0x00264000, 0x00324000, 0x003f4000,   \
584           0x004b4000, 0x00584000, 0x00654000, 0x00714000,   \
585           0x007e4000, 0x008a3fff, 0x00973fff, 0x00a33fff,   \
586           0x00b03fff, 0x00bc3fff, 0x00c93fff, 0x00d63fff,   \
587           0x00e23ffe, 0x00ef3ffe, 0x00fb3ffe, 0x01083ffe,   \
588           0x01143ffe, 0x01213ffd, 0x012e3ffd, 0x013a3ffd,   \
589           0x01473ffd
590 
591 /*
592  * http://bcm-specs.sipsolutions.net/APHYSetup/noise_scale_table
593  */
594 /* G PHY Revision [0,2] */
595 #define BWI_PHY_NOISE_SCALE_11G_REV2                                            \
596           0x6c77,   0x5162,   0x3b40,   0x3335,   0x2f2d,   0x2a2a,   0x2527,   0x1f21,   \
597           0x1a1d,   0x1719,   0x1616,   0x1414,   0x1414,   0x1400,   0x1414,   0x1614,   \
598           0x1716,   0x1a19,   0x1f1d,   0x2521,   0x2a27,   0x2f2a,   0x332d,   0x3b35,   \
599           0x5140,   0x6c62,   0x0077
600 /* G PHY Revision 7 */
601 #define BWI_PHY_NOISE_SCALE_11G_REV7                                            \
602           0xa4a4,   0xa4a4,   0xa4a4,   0xa4a4,   0xa4a4,   0xa4a4,   0xa4a4,   0xa4a4,   \
603           0xa4a4,   0xa4a4,   0xa4a4,   0xa4a4,   0xa4a4,   0xa400,   0xa4a4,   0xa4a4,   \
604           0xa4a4,   0xa4a4,   0xa4a4,   0xa4a4,   0xa4a4,   0xa4a4,   0xa4a4,   0xa4a4,   \
605           0xa4a4,   0xa4a4,   0x00a4
606 /* G PHY generic */
607 #define BWI_PHY_NOISE_SCALE_11G                                                           \
608           0xd8dd,   0xcbd4,   0xbcc0,   0xb6b7,   0xb2b0,   0xadad,   0xa7a9,   0x9fa1,   \
609           0x969b,   0x9195,   0x8f8f,   0x8a8a,   0x8a8a,   0x8a00,   0x8a8a,   0x8f8a,   \
610           0x918f,   0x9695,   0x9f9b,   0xa7a1,   0xada9,   0xb2ad,   0xb6b0,   0xbcb7,   \
611           0xcbc0,   0xd8d4,   0x00dd
612 
613 /*
614  * http://bcm-specs.sipsolutions.net/APHYSetup/sigma_square_table
615  */
616 /* G PHY Revision 2 */
617 #define BWI_PHY_SIGMA_SQ_11G_REV2                                               \
618           0x007a,   0x0075,   0x0071,   0x006c,   0x0067,   0x0063,   0x005e,   0x0059,   \
619           0x0054,   0x0050,   0x004b,   0x0046,   0x0042,   0x003d,   0x003d,   0x003d,   \
620           0x003d,   0x003d,   0x003d,   0x003d,   0x003d,   0x003d,   0x003d,   0x003d,   \
621           0x003d,   0x003d,   0x0000,   0x003d,   0x003d,   0x003d,   0x003d,   0x003d,   \
622           0x003d,   0x003d,   0x003d,   0x003d,   0x003d,   0x003d,   0x003d,   0x003d,   \
623           0x0042,   0x0046,   0x004b,   0x0050,   0x0054,   0x0059,   0x005e,   0x0063,   \
624           0x0067,   0x006c,   0x0071,   0x0075,   0x007a
625 /* G PHY Revision (2,7] */
626 #define BWI_PHY_SIGMA_SQ_11G_REV7                                               \
627           0x00de,   0x00dc,   0x00da,   0x00d8,   0x00d6,   0x00d4,   0x00d2,   0x00cf,   \
628           0x00cd,   0x00ca,   0x00c7,   0x00c4,   0x00c1,   0x00be,   0x00be,   0x00be,   \
629           0x00be,   0x00be,   0x00be,   0x00be,   0x00be,   0x00be,   0x00be,   0x00be,   \
630           0x00be,   0x00be,   0x0000,   0x00be,   0x00be,   0x00be,   0x00be,   0x00be,   \
631           0x00be,   0x00be,   0x00be,   0x00be,   0x00be,   0x00be,   0x00be,   0x00be,   \
632           0x00c1,   0x00c4,   0x00c7,   0x00ca,   0x00cd,   0x00cf,   0x00d2,   0x00d4,   \
633           0x00d6,   0x00d8,   0x00da,   0x00dc,   0x00de
634 
635 /*
636  * http://bcm-specs.sipsolutions.net/APHYSetup/retard_table
637  * G PHY
638  */
639 #define BWI_PHY_DELAY_11G_REV1                                        \
640           0xdb93cb87, 0xd666cf64, 0xd1fdd358, 0xcda6d826,   \
641           0xca38dd9f, 0xc729e2b4, 0xc469e88e, 0xc26aee2b,   \
642           0xc0def46c, 0xc073fa62, 0xc01d00d5, 0xc0760743,   \
643           0xc1560d1e, 0xc2e51369, 0xc4ed18ff, 0xc7ac1ed7,   \
644           0xcb2823b2, 0xcefa28d9, 0xd2f62d3f, 0xd7bb3197,   \
645           0xdce53568, 0xe1fe3875, 0xe7d13b35, 0xed663d35,   \
646           0xf39b3ec4, 0xf98e3fa7, 0x00004000, 0x06723fa7,   \
647           0x0c653ec4, 0x129a3d35, 0x182f3b35, 0x1e023875,   \
648           0x231b3568, 0x28453197, 0x2d0a2d3f, 0x310628d9,   \
649           0x34d823b2, 0x38541ed7, 0x3b1318ff, 0x3d1b1369,   \
650           0x3eaa0d1e, 0x3f8a0743, 0x3fe300d5, 0x3f8dfa62,   \
651           0x3f22f46c, 0x3d96ee2b, 0x3b97e88e, 0x38d7e2b4,   \
652           0x35c8dd9f, 0x325ad826, 0x2e03d358, 0x299acf64,   \
653           0x246dcb87
654 
655 /* RF */
656 
657 #define BWI_RFR_ATTEN                             0x43
658 
659 #define BWI_RFR_TXPWR                             0x52
660 #define BWI_RFR_TXPWR1_MASK             0x0070
661 
662 #define BWI_RFR_BBP_ATTEN               0x60
663 #define BWI_RFR_BBP_ATTEN_CALIB_BIT     (1 << 0)
664 #define BWI_RFR_BBP_ATTEN_CALIB_IDX     (0x0f << 1)
665 
666 /*
667  * TSSI -- TX power maps
668  */
669 /*
670  * http://bcm-specs.sipsolutions.net/TSSI_to_DBM_Table
671  * B PHY
672  */
673 #define BWI_TXPOWER_MAP_11B                                                     \
674           0x4d,     0x4c,     0x4b,     0x4a,     0x4a,     0x49,     0x48,     0x47,     \
675           0x47,     0x46,     0x45,     0x45,     0x44,     0x43,     0x42,     0x42,     \
676           0x41,     0x40,     0x3f,     0x3e,     0x3d,     0x3c,     0x3b,     0x3a,     \
677           0x39,     0x38,     0x37,     0x36,     0x35,     0x34,     0x32,     0x31,     \
678           0x30,     0x2f,     0x2d,     0x2c,     0x2b,     0x29,     0x28,     0x26,     \
679           0x25,     0x23,     0x21,     0x1f,     0x1d,     0x1a,     0x17,     0x14,     \
680           0x10,     0x0c,     0x06,     0x00,     -7,       -7,       -7,       -7,       \
681           -7,       -7,       -7,       -7,       -7,       -7,       -7,       -7
682 /*
683  * http://bcm-specs.sipsolutions.net/TSSI_to_DBM_Table
684  * G PHY
685  */
686 #define BWI_TXPOWER_MAP_11G                                                     \
687           77,       77,       77,       76,       76,       76,       75,       75,       \
688           74,       74,       73,       73,       73,       72,       72,       71,       \
689           71,       70,       70,       69,       68,       68,       67,       67,       \
690           66,       65,       65,       64,       63,       63,       62,       61,       \
691           60,       59,       58,       57,       56,       55,       54,       53,       \
692           52,       50,       49,       47,       45,       43,       40,       37,       \
693           33,       28,       22,       14,       5,        -7,       -20,      -20,      \
694           -20,      -20,      -20,      -20,      -20,      -20,      -20,      -20
695 
696 #endif /* !_DEV_IC_BWIREG_H */
697