1 /* SPDX-License-Identifier: GPL-2.0-only */
3 * This file is part of wl12xx
5 * Copyright (c) 1998-2007 Texas Instruments Incorporated
6 * Copyright (C) 2008 Nokia Corporation
12 #include <linux/bitops.h>
14 #define REGISTERS_BASE 0x00300000
15 #define DRPW_BASE 0x00310000
17 #define REGISTERS_DOWN_SIZE 0x00008800
18 #define REGISTERS_WORK_SIZE 0x0000b000
20 #define HW_ACCESS_ELP_CTRL_REG_ADDR 0x1FFFC
22 /* ELP register commands */
23 #define ELPCTRL_WAKE_UP 0x1
24 #define ELPCTRL_WAKE_UP_WLAN_READY 0x5
25 #define ELPCTRL_SLEEP 0x0
26 /* ELP WLAN_READY bit */
27 #define ELPCTRL_WLAN_READY 0x2
29 /* Device Configuration registers*/
30 #define SOR_CFG (REGISTERS_BASE + 0x0800)
31 #define ECPU_CTRL (REGISTERS_BASE + 0x0804)
32 #define HI_CFG (REGISTERS_BASE + 0x0808)
34 /* EEPROM registers */
35 #define EE_START (REGISTERS_BASE + 0x080C)
36 #define EE_CTL (REGISTERS_BASE + 0x2000)
37 #define EE_DATA (REGISTERS_BASE + 0x2004)
38 #define EE_ADDR (REGISTERS_BASE + 0x2008)
42 #define CHIP_ID_B (REGISTERS_BASE + 0x5674)
44 #define CHIP_ID_1251_PG10 (0x7010101)
45 #define CHIP_ID_1251_PG11 (0x7020101)
46 #define CHIP_ID_1251_PG12 (0x7030101)
48 #define ENABLE (REGISTERS_BASE + 0x5450)
50 /* Power Management registers */
51 #define ELP_CFG_MODE (REGISTERS_BASE + 0x5804)
52 #define ELP_CMD (REGISTERS_BASE + 0x5808)
53 #define PLL_CAL_TIME (REGISTERS_BASE + 0x5810)
54 #define CLK_REQ_TIME (REGISTERS_BASE + 0x5814)
55 #define CLK_BUF_TIME (REGISTERS_BASE + 0x5818)
57 #define CFG_PLL_SYNC_CNT (REGISTERS_BASE + 0x5820)
59 /* Scratch Pad registers*/
60 #define SCR_PAD0 (REGISTERS_BASE + 0x5608)
61 #define SCR_PAD1 (REGISTERS_BASE + 0x560C)
62 #define SCR_PAD2 (REGISTERS_BASE + 0x5610)
63 #define SCR_PAD3 (REGISTERS_BASE + 0x5614)
64 #define SCR_PAD4 (REGISTERS_BASE + 0x5618)
65 #define SCR_PAD4_SET (REGISTERS_BASE + 0x561C)
66 #define SCR_PAD4_CLR (REGISTERS_BASE + 0x5620)
67 #define SCR_PAD5 (REGISTERS_BASE + 0x5624)
68 #define SCR_PAD5_SET (REGISTERS_BASE + 0x5628)
69 #define SCR_PAD5_CLR (REGISTERS_BASE + 0x562C)
70 #define SCR_PAD6 (REGISTERS_BASE + 0x5630)
71 #define SCR_PAD7 (REGISTERS_BASE + 0x5634)
72 #define SCR_PAD8 (REGISTERS_BASE + 0x5638)
73 #define SCR_PAD9 (REGISTERS_BASE + 0x563C)
76 #define SPARE_A1 (REGISTERS_BASE + 0x0994)
77 #define SPARE_A2 (REGISTERS_BASE + 0x0998)
78 #define SPARE_A3 (REGISTERS_BASE + 0x099C)
79 #define SPARE_A4 (REGISTERS_BASE + 0x09A0)
80 #define SPARE_A5 (REGISTERS_BASE + 0x09A4)
81 #define SPARE_A6 (REGISTERS_BASE + 0x09A8)
82 #define SPARE_A7 (REGISTERS_BASE + 0x09AC)
83 #define SPARE_A8 (REGISTERS_BASE + 0x09B0)
84 #define SPARE_B1 (REGISTERS_BASE + 0x5420)
85 #define SPARE_B2 (REGISTERS_BASE + 0x5424)
86 #define SPARE_B3 (REGISTERS_BASE + 0x5428)
87 #define SPARE_B4 (REGISTERS_BASE + 0x542C)
88 #define SPARE_B5 (REGISTERS_BASE + 0x5430)
89 #define SPARE_B6 (REGISTERS_BASE + 0x5434)
90 #define SPARE_B7 (REGISTERS_BASE + 0x5438)
91 #define SPARE_B8 (REGISTERS_BASE + 0x543C)
93 enum wl12xx_acx_int_reg
{
94 ACX_REG_INTERRUPT_TRIG
,
95 ACX_REG_INTERRUPT_TRIG_H
,
97 /*=============================================
98 Host Interrupt Mask Register - 32bit (RW)
99 ------------------------------------------
100 Setting a bit in this register masks the
101 corresponding interrupt to the host.
102 0 - RX0 - Rx first dubble buffer Data Interrupt
103 1 - TXD - Tx Data Interrupt
104 2 - TXXFR - Tx Transfer Interrupt
105 3 - RX1 - Rx second dubble buffer Data Interrupt
106 4 - RXXFR - Rx Transfer Interrupt
107 5 - EVENT_A - Event Mailbox interrupt
108 6 - EVENT_B - Event Mailbox interrupt
109 7 - WNONHST - Wake On Host Interrupt
110 8 - TRACE_A - Debug Trace interrupt
111 9 - TRACE_B - Debug Trace interrupt
112 10 - CDCMP - Command Complete Interrupt
116 14 - ICOMP - Initialization Complete Interrupt
117 16 - SG SE - Soft Gemini - Sense enable interrupt
118 17 - SG SD - Soft Gemini - Sense disable interrupt
124 *==============================================*/
125 ACX_REG_INTERRUPT_MASK
,
127 /*=============================================
128 Host Interrupt Mask Set 16bit, (Write only)
129 ------------------------------------------
130 Setting a bit in this register sets
131 the corresponding bin in ACX_HINT_MASK register
132 without effecting the mask
133 state of other bits (0 = no effect).
134 ==============================================*/
135 ACX_REG_HINT_MASK_SET
,
137 /*=============================================
138 Host Interrupt Mask Clear 16bit,(Write only)
139 ------------------------------------------
140 Setting a bit in this register clears
141 the corresponding bin in ACX_HINT_MASK register
142 without effecting the mask
143 state of other bits (0 = no effect).
144 =============================================*/
145 ACX_REG_HINT_MASK_CLR
,
147 /*=============================================
148 Host Interrupt Status Nondestructive Read
150 ------------------------------------------
151 The host can read this register to determine
152 which interrupts are active.
153 Reading this register doesn't
155 =============================================*/
156 ACX_REG_INTERRUPT_NO_CLEAR
,
158 /*=============================================
159 Host Interrupt Status Clear on Read Register
161 ------------------------------------------
162 The host can read this register to determine
163 which interrupts are active.
164 Reading this register clears it,
165 thus making all interrupts inactive.
166 ==============================================*/
167 ACX_REG_INTERRUPT_CLEAR
,
169 /*=============================================
170 Host Interrupt Acknowledge Register
172 ------------------------------------------
173 The host can set individual bits in this
174 register to clear (acknowledge) the corresp.
175 interrupt status bits in the HINT_STS_CLR and
176 HINT_STS_ND registers, thus making the
177 assotiated interrupt inactive. (0-no effect)
178 ==============================================*/
179 ACX_REG_INTERRUPT_ACK
,
181 /*===============================================
182 Host Software Reset - 32bit RW
183 ------------------------------------------
185 0 SOFT_RESET Soft Reset - When this bit is set,
186 it holds the Wlan hardware in a soft reset state.
187 This reset disables all MAC and baseband processor
188 clocks except the CardBus/PCI interface clock.
189 It also initializes all MAC state machines except
190 the host interface. It does not reload the
191 contents of the EEPROM. When this bit is cleared
192 (not self-clearing), the Wlan hardware
193 exits the software reset state.
194 ===============================================*/
195 ACX_REG_SLV_SOFT_RESET
,
197 /*===============================================
198 EEPROM Burst Read Start - 32bit RW
199 ------------------------------------------
201 0 ACX_EE_START - EEPROM Burst Read Start 0
202 Setting this bit starts a burst read from
204 If this bit is set (after reset) before an EEPROM read/write,
205 the burst read starts at EEPROM address 0.
206 Otherwise, it starts at the address
207 following the address of the previous access.
208 TheWlan hardware hardware clears this bit automatically.
211 *================================================*/
214 /* Embedded ARM CPU Control */
216 /*===============================================
218 ------------------------------------------
219 0 HALT_ECPU Halt Embedded CPU - This bit is the
220 compliment of bit 1 (MDATA2) in the SOR_CFG register.
221 During a hardware reset, this bit holds
222 the inverse of MDATA2.
223 When downloading firmware from the host,
224 set this bit (pull down MDATA2).
225 The host clears this bit after downloading the firmware into
226 zero-wait-state SSRAM.
227 When loading firmware from Flash, clear this bit (pull up MDATA2)
228 so that the eCPU can run the bootloader code in Flash
233 ===============================================*/
234 ACX_REG_ECPU_CONTROL
,
239 #define ACX_SLV_SOFT_RESET_BIT BIT(0)
240 #define ACX_REG_EEPROM_START_BIT BIT(0)
242 /* Command/Information Mailbox Pointers */
244 /*===============================================
245 Command Mailbox Pointer - 32bit RW
246 ------------------------------------------
247 This register holds the start address of
248 the command mailbox located in the Wlan hardware memory.
249 The host must read this pointer after a reset to
250 find the location of the command mailbox.
251 The Wlan hardware initializes the command mailbox
252 pointer with the default address of the command mailbox.
253 The command mailbox pointer is not valid until after
254 the host receives the Init Complete interrupt from
256 ===============================================*/
257 #define REG_COMMAND_MAILBOX_PTR (SCR_PAD0)
259 /*===============================================
260 Information Mailbox Pointer - 32bit RW
261 ------------------------------------------
262 This register holds the start address of
263 the information mailbox located in the Wlan hardware memory.
264 The host must read this pointer after a reset to find
265 the location of the information mailbox.
266 The Wlan hardware initializes the information mailbox pointer
267 with the default address of the information mailbox.
268 The information mailbox pointer is not valid
269 until after the host receives the Init Complete interrupt from
271 ===============================================*/
272 #define REG_EVENT_MAILBOX_PTR (SCR_PAD1)
277 #define REG_ENABLE_TX_RX (ENABLE)
279 * Rx configuration (filter) information element
280 * ---------------------------------------------
282 #define REG_RX_CONFIG (RX_CFG)
283 #define REG_RX_FILTER (RX_FILTER_CFG)
286 #define RX_CFG_ENABLE_PHY_HEADER_PLCP 0x0002
288 /* promiscuous - receives all valid frames */
289 #define RX_CFG_PROMISCUOUS 0x0008
291 /* receives frames from any BSSID */
292 #define RX_CFG_BSSID 0x0020
294 /* receives frames destined to any MAC address */
295 #define RX_CFG_MAC 0x0010
297 #define RX_CFG_ENABLE_ONLY_MY_DEST_MAC 0x0010
298 #define RX_CFG_ENABLE_ANY_DEST_MAC 0x0000
299 #define RX_CFG_ENABLE_ONLY_MY_BSSID 0x0020
300 #define RX_CFG_ENABLE_ANY_BSSID 0x0000
302 /* discards all broadcast frames */
303 #define RX_CFG_DISABLE_BCAST 0x0200
305 #define RX_CFG_ENABLE_ONLY_MY_SSID 0x0400
306 #define RX_CFG_ENABLE_RX_CMPLT_FCS_ERROR 0x0800
307 #define RX_CFG_COPY_RX_STATUS 0x2000
308 #define RX_CFG_TSF 0x10000
310 #define RX_CONFIG_OPTION_ANY_DST_MY_BSS (RX_CFG_ENABLE_ANY_DEST_MAC | \
311 RX_CFG_ENABLE_ONLY_MY_BSSID)
313 #define RX_CONFIG_OPTION_MY_DST_ANY_BSS (RX_CFG_ENABLE_ONLY_MY_DEST_MAC\
314 | RX_CFG_ENABLE_ANY_BSSID)
316 #define RX_CONFIG_OPTION_ANY_DST_ANY_BSS (RX_CFG_ENABLE_ANY_DEST_MAC | \
317 RX_CFG_ENABLE_ANY_BSSID)
319 #define RX_CONFIG_OPTION_MY_DST_MY_BSS (RX_CFG_ENABLE_ONLY_MY_DEST_MAC\
320 | RX_CFG_ENABLE_ONLY_MY_BSSID)
322 #define RX_CONFIG_OPTION_FOR_SCAN (RX_CFG_ENABLE_PHY_HEADER_PLCP \
323 | RX_CFG_ENABLE_RX_CMPLT_FCS_ERROR \
324 | RX_CFG_COPY_RX_STATUS | RX_CFG_TSF)
326 #define RX_CONFIG_OPTION_FOR_MEASUREMENT (RX_CFG_ENABLE_ANY_DEST_MAC)
328 #define RX_CONFIG_OPTION_FOR_JOIN (RX_CFG_ENABLE_ONLY_MY_BSSID | \
329 RX_CFG_ENABLE_ONLY_MY_DEST_MAC)
331 #define RX_CONFIG_OPTION_FOR_IBSS_JOIN (RX_CFG_ENABLE_ONLY_MY_SSID | \
332 RX_CFG_ENABLE_ONLY_MY_DEST_MAC)
334 #define RX_FILTER_OPTION_DEF (CFG_RX_MGMT_EN | CFG_RX_DATA_EN\
335 | CFG_RX_CTL_EN | CFG_RX_BCN_EN\
336 | CFG_RX_AUTH_EN | CFG_RX_ASSOC_EN)
338 #define RX_FILTER_OPTION_FILTER_ALL 0
340 #define RX_FILTER_OPTION_DEF_PRSP_BCN (CFG_RX_PRSP_EN | CFG_RX_MGMT_EN\
341 | CFG_RX_RCTS_ACK | CFG_RX_BCN_EN)
343 #define RX_FILTER_OPTION_JOIN (CFG_RX_MGMT_EN | CFG_RX_DATA_EN\
344 | CFG_RX_BCN_EN | CFG_RX_AUTH_EN\
345 | CFG_RX_ASSOC_EN | CFG_RX_RCTS_ACK\
349 /*===============================================
350 EEPROM Read/Write Request 32bit RW
351 ------------------------------------------
352 1 EE_READ - EEPROM Read Request 1 - Setting this bit
353 loads a single byte of data into the EE_DATA
354 register from the EEPROM location specified in
355 the EE_ADDR register.
356 The Wlan hardware hardware clears this bit automatically.
357 EE_DATA is valid when this bit is cleared.
359 0 EE_WRITE - EEPROM Write Request - Setting this bit
360 writes a single byte of data from the EE_DATA register into the
361 EEPROM location specified in the EE_ADDR register.
362 The Wlan hardware hardware clears this bit automatically.
363 *===============================================*/
364 #define EE_CTL (REGISTERS_BASE + 0x2000)
365 #define ACX_EE_CTL_REG EE_CTL
366 #define EE_WRITE 0x00000001ul
367 #define EE_READ 0x00000002ul
369 /*===============================================
370 EEPROM Address - 32bit RW
371 ------------------------------------------
372 This register specifies the address
373 within the EEPROM from/to which to read/write data.
374 ===============================================*/
375 #define EE_ADDR (REGISTERS_BASE + 0x2008)
376 #define ACX_EE_ADDR_REG EE_ADDR
378 /*===============================================
379 EEPROM Data - 32bit RW
380 ------------------------------------------
381 This register either holds the read 8 bits of
382 data from the EEPROM or the write data
383 to be written to the EEPROM.
384 ===============================================*/
385 #define EE_DATA (REGISTERS_BASE + 0x2004)
386 #define ACX_EE_DATA_REG EE_DATA
388 #define EEPROM_ACCESS_TO 10000 /* timeout counter */
389 #define START_EEPROM_MGR 0x00000001
391 /*===============================================
392 EEPROM Base Address - 32bit RW
393 ------------------------------------------
394 This register holds the upper nine bits
395 [23:15] of the 24-bit Wlan hardware memory
396 address for burst reads from EEPROM accesses.
397 The EEPROM provides the lower 15 bits of this address.
398 The MSB of the address from the EEPROM is ignored.
399 ===============================================*/
400 #define ACX_EE_CFG EE_CFG
402 /*===============================================
403 GPIO Output Values -32bit, RW
404 ------------------------------------------
406 [15: 0] Specify the output values (at the output driver inputs) for
407 GPIO[15:0], respectively.
408 ===============================================*/
409 #define ACX_GPIO_OUT_REG GPIO_OUT
410 #define ACX_MAX_GPIO_LINES 15
412 /*===============================================
413 Contention window -32bit, RW
414 ------------------------------------------
418 [06:00] Current contention window value - default is 0x1F
419 ===============================================*/
420 #define ACX_CONT_WIND_CFG_REG CONT_WIND_CFG
421 #define ACX_CONT_WIND_MIN_MASK 0x0000007f
422 #define ACX_CONT_WIND_MAX 0x03ff0000
424 /*===============================================
425 HI_CFG Interface Configuration Register Values
426 ------------------------------------------
427 ===============================================*/
428 #define HI_CFG_UART_ENABLE 0x00000004
429 #define HI_CFG_RST232_ENABLE 0x00000008
430 #define HI_CFG_CLOCK_REQ_SELECT 0x00000010
431 #define HI_CFG_HOST_INT_ENABLE 0x00000020
432 #define HI_CFG_VLYNQ_OUTPUT_ENABLE 0x00000040
433 #define HI_CFG_HOST_INT_ACTIVE_LOW 0x00000080
434 #define HI_CFG_UART_TX_OUT_GPIO_15 0x00000100
435 #define HI_CFG_UART_TX_OUT_GPIO_14 0x00000200
436 #define HI_CFG_UART_TX_OUT_GPIO_7 0x00000400
439 * NOTE: USE_ACTIVE_HIGH compilation flag should be defined in makefile
440 * for platforms using active high interrupt level
442 #ifdef USE_ACTIVE_HIGH
443 #define HI_CFG_DEF_VAL \
444 (HI_CFG_UART_ENABLE | \
445 HI_CFG_RST232_ENABLE | \
446 HI_CFG_CLOCK_REQ_SELECT | \
447 HI_CFG_HOST_INT_ENABLE)
449 #define HI_CFG_DEF_VAL \
450 (HI_CFG_UART_ENABLE | \
451 HI_CFG_RST232_ENABLE | \
452 HI_CFG_CLOCK_REQ_SELECT | \
453 HI_CFG_HOST_INT_ENABLE)
457 #define REF_FREQ_19_2 0
458 #define REF_FREQ_26_0 1
459 #define REF_FREQ_38_4 2
460 #define REF_FREQ_40_0 3
461 #define REF_FREQ_33_6 4
462 #define REF_FREQ_NUM 5
464 #define LUT_PARAM_INTEGER_DIVIDER 0
465 #define LUT_PARAM_FRACTIONAL_DIVIDER 1
466 #define LUT_PARAM_ATTN_BB 2
467 #define LUT_PARAM_ALPHA_BB 3
468 #define LUT_PARAM_STOP_TIME_BB 4
469 #define LUT_PARAM_BB_PLL_LOOP_FILTER 5
470 #define LUT_PARAM_NUM 6
472 #define ACX_EEPROMLESS_IND_REG (SCR_PAD4)
474 #define SOFT_RESET_MAX_TIME 1000000
475 #define SOFT_RESET_STALL_TIME 1000
476 #define NVS_DATA_BUNDARY_ALIGNMENT 4
479 /* Firmware image load chunk size */
480 #define CHUNK_SIZE 512
482 /* Firmware image header size */
483 #define FW_HDR_SIZE 8
485 #define ECPU_CONTROL_HALT 0x00000101
488 /******************************************************************************
490 CHANNELS, BAND & REG DOMAINS definitions
492 ******************************************************************************/
496 RADIO_BAND_2_4GHZ
= 0, /* 2.4 Ghz band */
497 RADIO_BAND_5GHZ
= 1, /* 5 Ghz band */
498 RADIO_BAND_JAPAN_4_9_GHZ
= 2,
499 DEFAULT_BAND
= RADIO_BAND_2_4GHZ
,
501 MAX_RADIO_BANDS
= 0xFF
522 RATE_INDEX_1MBPS
= 0,
523 RATE_INDEX_2MBPS
= 1,
524 RATE_INDEX_5_5MBPS
= 2,
525 RATE_INDEX_6MBPS
= 3,
526 RATE_INDEX_9MBPS
= 4,
527 RATE_INDEX_11MBPS
= 5,
528 RATE_INDEX_12MBPS
= 6,
529 RATE_INDEX_18MBPS
= 7,
530 RATE_INDEX_22MBPS
= 8,
531 RATE_INDEX_24MBPS
= 9,
532 RATE_INDEX_36MBPS
= 10,
533 RATE_INDEX_48MBPS
= 11,
534 RATE_INDEX_54MBPS
= 12,
535 RATE_INDEX_MAX
= RATE_INDEX_54MBPS
,
537 INVALID_RATE_INDEX
= MAX_RATE_INDEX
,
538 RATE_INDEX_ENUM_MAX_SIZE
= 0x7FFFFFFF
542 RATE_MASK_1MBPS
= 0x1,
543 RATE_MASK_2MBPS
= 0x2,
544 RATE_MASK_5_5MBPS
= 0x4,
545 RATE_MASK_11MBPS
= 0x20,
548 #define SHORT_PREAMBLE_BIT BIT(0) /* CCK or Barker depending on the rate */
549 #define OFDM_RATE_BIT BIT(6)
550 #define PBCC_RATE_BIT BIT(7)
554 CCK_SHORT
= SHORT_PREAMBLE_BIT
,
555 PBCC_LONG
= PBCC_RATE_BIT
,
556 PBCC_SHORT
= PBCC_RATE_BIT
| SHORT_PREAMBLE_BIT
,
560 /******************************************************************************
562 Transmit-Descriptor RATE-SET field definitions...
564 Define a new "Rate-Set" for TX path that incorporates the
565 Rate & Modulation info into a single 16-bit field.
568 b15 - Indicates Preamble type (1=SHORT, 0=LONG).
570 Must be LONG (0) for 1Mbps rate.
571 Does not apply (set to 0) for RevG-OFDM rates.
572 b14 - Indicates PBCC encoding (1=PBCC, 0=not).
574 Does not apply (set to 0) for rates 1 and 2 Mbps.
575 Does not apply (set to 0) for RevG-OFDM rates.
576 b13 - Unused (set to 0).
577 b12-b0 - Supported Rate indicator bits as defined below.
579 ******************************************************************************/
582 /*************************************************************************
584 Interrupt Trigger Register (Host -> WiLink)
586 **************************************************************************/
588 /* Hardware to Embedded CPU Interrupts - first 32-bit register set */
591 * Host Command Interrupt. Setting this bit masks
592 * the interrupt that the host issues to inform
593 * the FW that it has sent a command
594 * to the Wlan hardware Command Mailbox.
596 #define INTR_TRIG_CMD BIT(0)
599 * Host Event Acknowlegde Interrupt. The host
600 * sets this bit to acknowledge that it received
601 * the unsolicited information from the event
604 #define INTR_TRIG_EVENT_ACK BIT(1)
607 * The host sets this bit to inform the Wlan
608 * FW that a TX packet is in the XFER
611 #define INTR_TRIG_TX_PROC0 BIT(2)
614 * The host sets this bit to inform the FW
615 * that it read a packet from RX XFER
618 #define INTR_TRIG_RX_PROC0 BIT(3)
620 #define INTR_TRIG_DEBUG_ACK BIT(4)
622 #define INTR_TRIG_STATE_CHANGED BIT(5)
625 /* Hardware to Embedded CPU Interrupts - second 32-bit register set */
628 * The host sets this bit to inform the FW
629 * that it read a packet from RX XFER
632 #define INTR_TRIG_RX_PROC1 BIT(17)
635 * The host sets this bit to inform the Wlan
636 * hardware that a TX packet is in the XFER
639 #define INTR_TRIG_TX_PROC1 BIT(18)