2 * This file is part of wlcore
4 * Copyright (C) 2011 Texas Instruments Inc.
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * version 2 as published by the Free Software Foundation.
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
25 #include <linux/platform_device.h>
31 /* The maximum number of Tx descriptors in all chip families */
32 #define WLCORE_MAX_TX_DESCRIPTORS 32
35 * We always allocate this number of mac addresses. If we don't
36 * have enough allocated addresses, the LAA bit is used
38 #define WLCORE_NUM_MAC_ADDRESSES 3
40 /* wl12xx/wl18xx maximum transmission power (in dBm) */
41 #define WLCORE_MAX_TXPWR 25
43 /* Texas Instruments pre assigned OUI */
44 #define WLCORE_TI_OUI_ADDRESS 0x080028
46 /* forward declaration */
47 struct wl1271_tx_hw_descr
;
49 struct wl1271_rx_descriptor
;
52 int (*setup
)(struct wl1271
*wl
);
53 int (*identify_chip
)(struct wl1271
*wl
);
54 int (*identify_fw
)(struct wl1271
*wl
);
55 int (*boot
)(struct wl1271
*wl
);
56 int (*plt_init
)(struct wl1271
*wl
);
57 int (*trigger_cmd
)(struct wl1271
*wl
, int cmd_box_addr
,
58 void *buf
, size_t len
);
59 int (*ack_event
)(struct wl1271
*wl
);
60 int (*wait_for_event
)(struct wl1271
*wl
, enum wlcore_wait_event event
,
62 int (*process_mailbox_events
)(struct wl1271
*wl
);
63 u32 (*calc_tx_blocks
)(struct wl1271
*wl
, u32 len
, u32 spare_blks
);
64 void (*set_tx_desc_blocks
)(struct wl1271
*wl
,
65 struct wl1271_tx_hw_descr
*desc
,
66 u32 blks
, u32 spare_blks
);
67 void (*set_tx_desc_data_len
)(struct wl1271
*wl
,
68 struct wl1271_tx_hw_descr
*desc
,
70 enum wl_rx_buf_align (*get_rx_buf_align
)(struct wl1271
*wl
,
72 int (*prepare_read
)(struct wl1271
*wl
, u32 rx_desc
, u32 len
);
73 u32 (*get_rx_packet_len
)(struct wl1271
*wl
, void *rx_data
,
75 int (*tx_delayed_compl
)(struct wl1271
*wl
);
76 void (*tx_immediate_compl
)(struct wl1271
*wl
);
77 int (*hw_init
)(struct wl1271
*wl
);
78 int (*init_vif
)(struct wl1271
*wl
, struct wl12xx_vif
*wlvif
);
79 void (*convert_fw_status
)(struct wl1271
*wl
, void *raw_fw_status
,
80 struct wl_fw_status
*fw_status
);
81 u32 (*sta_get_ap_rate_mask
)(struct wl1271
*wl
,
82 struct wl12xx_vif
*wlvif
);
83 int (*get_pg_ver
)(struct wl1271
*wl
, s8
*ver
);
84 int (*get_mac
)(struct wl1271
*wl
);
85 void (*set_tx_desc_csum
)(struct wl1271
*wl
,
86 struct wl1271_tx_hw_descr
*desc
,
88 void (*set_rx_csum
)(struct wl1271
*wl
,
89 struct wl1271_rx_descriptor
*desc
,
91 u32 (*ap_get_mimo_wide_rate_mask
)(struct wl1271
*wl
,
92 struct wl12xx_vif
*wlvif
);
93 int (*debugfs_init
)(struct wl1271
*wl
, struct dentry
*rootdir
);
94 int (*handle_static_data
)(struct wl1271
*wl
,
95 struct wl1271_static_data
*static_data
);
96 int (*scan_start
)(struct wl1271
*wl
, struct wl12xx_vif
*wlvif
,
97 struct cfg80211_scan_request
*req
);
98 int (*scan_stop
)(struct wl1271
*wl
, struct wl12xx_vif
*wlvif
);
99 int (*sched_scan_start
)(struct wl1271
*wl
, struct wl12xx_vif
*wlvif
,
100 struct cfg80211_sched_scan_request
*req
,
101 struct ieee80211_scan_ies
*ies
);
102 void (*sched_scan_stop
)(struct wl1271
*wl
, struct wl12xx_vif
*wlvif
);
103 int (*get_spare_blocks
)(struct wl1271
*wl
, bool is_gem
);
104 int (*set_key
)(struct wl1271
*wl
, enum set_key_cmd cmd
,
105 struct ieee80211_vif
*vif
,
106 struct ieee80211_sta
*sta
,
107 struct ieee80211_key_conf
*key_conf
);
108 int (*channel_switch
)(struct wl1271
*wl
,
109 struct wl12xx_vif
*wlvif
,
110 struct ieee80211_channel_switch
*ch_switch
);
111 u32 (*pre_pkt_send
)(struct wl1271
*wl
, u32 buf_offset
, u32 last_len
);
112 void (*sta_rc_update
)(struct wl1271
*wl
, struct wl12xx_vif
*wlvif
);
113 int (*set_peer_cap
)(struct wl1271
*wl
,
114 struct ieee80211_sta_ht_cap
*ht_cap
,
115 bool allow_ht_operation
,
116 u32 rate_set
, u8 hlid
);
117 u32 (*convert_hwaddr
)(struct wl1271
*wl
, u32 hwaddr
);
118 bool (*lnk_high_prio
)(struct wl1271
*wl
, u8 hlid
,
119 struct wl1271_link
*lnk
);
120 bool (*lnk_low_prio
)(struct wl1271
*wl
, u8 hlid
,
121 struct wl1271_link
*lnk
);
122 int (*interrupt_notify
)(struct wl1271
*wl
, bool action
);
123 int (*rx_ba_filter
)(struct wl1271
*wl
, bool action
);
124 int (*ap_sleep
)(struct wl1271
*wl
);
125 int (*smart_config_start
)(struct wl1271
*wl
, u32 group_bitmap
);
126 int (*smart_config_stop
)(struct wl1271
*wl
);
127 int (*smart_config_set_group_key
)(struct wl1271
*wl
, u16 group_id
,
128 u8 key_len
, u8
*key
);
129 int (*set_cac
)(struct wl1271
*wl
, struct wl12xx_vif
*wlvif
,
131 int (*dfs_master_restart
)(struct wl1271
*wl
, struct wl12xx_vif
*wlvif
);
134 enum wlcore_partitions
{
139 PART_TOP_PRCM_ELP_SOC
,
145 struct wlcore_partition
{
150 struct wlcore_partition_set
{
151 struct wlcore_partition mem
;
152 struct wlcore_partition reg
;
153 struct wlcore_partition mem2
;
154 struct wlcore_partition mem3
;
157 enum wlcore_registers
{
158 /* register addresses, used with partition translation */
160 REG_INTERRUPT_NO_CLEAR
,
162 REG_COMMAND_MAILBOX_PTR
,
163 REG_EVENT_MAILBOX_PTR
,
168 REG_CMD_MBOX_ADDRESS
,
170 /* data access memory addresses, used with partition translation */
174 /* raw data access memory addresses */
175 REG_RAW_FW_STATUS_ADDR
,
180 struct wl1271_stats
{
182 unsigned long fw_stats_update
;
185 unsigned int retry_count
;
186 unsigned int excessive_retries
;
191 struct ieee80211_hw
*hw
;
192 bool mac80211_registered
;
195 struct platform_device
*pdev
;
199 struct wl1271_if_operations
*if_ops
;
207 enum wlcore_state state
;
208 enum wl12xx_fw_type fw_type
;
210 enum plt_mode plt_mode
;
217 struct wlcore_partition_set curr_part
;
219 struct wl1271_chip chip
;
230 /* address read from the fuse ROM */
234 /* we have up to 2 MAC addresses */
235 struct mac_address addresses
[WLCORE_NUM_MAC_ADDRESSES
];
239 unsigned long links_map
[BITS_TO_LONGS(WLCORE_MAX_LINKS
)];
240 unsigned long roles_map
[BITS_TO_LONGS(WL12XX_MAX_ROLES
)];
241 unsigned long roc_map
[BITS_TO_LONGS(WL12XX_MAX_ROLES
)];
242 unsigned long rate_policies_map
[
243 BITS_TO_LONGS(WL12XX_MAX_RATE_POLICIES
)];
244 unsigned long klv_templates_map
[
245 BITS_TO_LONGS(WLCORE_MAX_KLV_TEMPLATES
)];
247 u8 session_ids
[WLCORE_MAX_LINKS
];
249 struct list_head wlvif_list
;
254 struct wl1271_acx_mem_map
*target_mem_map
;
256 /* Accounting for allocated / available TX blocks on HW */
258 u32 tx_blocks_available
;
259 u32 tx_allocated_blocks
;
260 u32 tx_results_count
;
262 /* Accounting for allocated / available Tx packets in HW */
263 u32 tx_pkts_freed
[NUM_TX_QUEUES
];
264 u32 tx_allocated_pkts
[NUM_TX_QUEUES
];
266 /* Transmitted TX packets counter for chipset interface */
267 u32 tx_packets_count
;
269 /* Time-offset between host and chipset clocks */
272 /* Frames scheduled for transmission, not handled yet */
273 int tx_queue_count
[NUM_TX_QUEUES
];
274 unsigned long queue_stop_reasons
[
275 NUM_TX_QUEUES
* WLCORE_NUM_MAC_ADDRESSES
];
277 /* Frames received, not handled yet by mac80211 */
278 struct sk_buff_head deferred_rx_queue
;
280 /* Frames sent, not returned yet to mac80211 */
281 struct sk_buff_head deferred_tx_queue
;
283 struct work_struct tx_work
;
284 struct workqueue_struct
*freezable_wq
;
286 /* Pending TX frames */
287 unsigned long tx_frames_map
[BITS_TO_LONGS(WLCORE_MAX_TX_DESCRIPTORS
)];
288 struct sk_buff
*tx_frames
[WLCORE_MAX_TX_DESCRIPTORS
];
294 /* Intermediate buffer, used for packet aggregation */
298 /* Reusable dummy packet template */
299 struct sk_buff
*dummy_packet
;
301 /* Network stack work */
302 struct work_struct netstack_work
;
307 /* Number of valid bytes in the FW log buffer */
310 /* FW log end marker */
313 /* FW memory block size */
314 u32 fw_mem_block_size
;
316 /* Hardware recovery work */
317 struct work_struct recovery_work
;
318 bool watchdog_recovery
;
320 /* Reg domain last configuration */
321 u32 reg_ch_conf_last
[2] __aligned(8);
322 /* Reg domain pending configuration */
323 u32 reg_ch_conf_pending
[2];
325 /* Pointer that holds DMA-friendly block for the mailbox */
328 /* The mbox event mask */
330 /* events to unmask only when ap interface is up */
333 /* Mailbox pointers */
337 /* Are we currently scanning */
338 struct wl12xx_vif
*scan_wlvif
;
339 struct wl1271_scan scan
;
340 struct delayed_work scan_complete_work
;
342 struct ieee80211_vif
*roc_vif
;
343 struct delayed_work roc_complete_work
;
345 struct wl12xx_vif
*sched_vif
;
347 /* The current band */
348 enum nl80211_band band
;
350 struct completion
*elp_compl
;
351 struct delayed_work elp_work
;
356 struct wl1271_stats stats
;
360 u32 buffer_busyword
[WL1271_BUSY_WORD_CNT
];
363 struct wl_fw_status
*fw_status
;
364 struct wl1271_tx_hw_res_if
*tx_res_if
;
366 /* Current chipset configuration */
367 struct wlcore_conf conf
;
375 /* Most recently reported noise in dBm */
378 /* bands supported by this instance of wl12xx */
379 struct ieee80211_supported_band bands
[WLCORE_NUM_BANDS
];
382 * wowlan trigger was configured during suspend.
383 * (currently, only "ANY" trigger is supported)
386 bool irq_wake_enabled
;
389 * AP-mode - links indexed by HLID. The global and broadcast links
392 struct wl1271_link links
[WLCORE_MAX_LINKS
];
394 /* number of currently active links */
395 int active_link_count
;
397 /* Fast/slow links bitmap according to FW */
398 unsigned long fw_fast_lnk_map
;
400 /* AP-mode - a bitmap of links currently in PS mode according to FW */
401 unsigned long ap_fw_ps_map
;
403 /* AP-mode - a bitmap of links currently in PS mode in mac80211 */
404 unsigned long ap_ps_map
;
406 /* Quirks of specific hardware revisions */
409 /* number of currently active RX BA sessions */
410 int ba_rx_session_count
;
412 /* Maximum number of supported RX BA sessions */
413 int ba_rx_session_count_max
;
415 /* AP-mode - number of currently connected stations */
416 int active_sta_count
;
418 /* Flag determining whether AP should broadcast OFDM-only rates */
421 /* last wlvif we transmitted from */
422 struct wl12xx_vif
*last_wlvif
;
424 /* work to fire when Tx is stuck */
425 struct delayed_work tx_watchdog_work
;
427 struct wlcore_ops
*ops
;
428 /* pointer to the lower driver partition table */
429 const struct wlcore_partition_set
*ptable
;
430 /* pointer to the lower driver register table */
432 /* name of the firmwares to load - for PLT, single role, multi-role */
433 const char *plt_fw_name
;
434 const char *sr_fw_name
;
435 const char *mr_fw_name
;
437 u8 scan_templ_id_2_4
;
439 u8 sched_scan_templ_id_2_4
;
440 u8 sched_scan_templ_id_5
;
443 /* per-chip-family private structure */
446 /* number of TX descriptors the HW supports. */
448 /* number of RX descriptors the HW supports. */
450 /* number of links the HW supports */
452 /* max stations a single AP can support */
455 /* translate HW Tx rates to standard rate-indices */
456 const u8
**band_rate_to_idx
;
458 /* size of table for HW rates that can be received from chip */
459 u8 hw_tx_rate_tbl_size
;
461 /* this HW rate and below are considered HT rates for this chip */
464 /* HW HT (11n) capabilities */
465 struct ieee80211_sta_ht_cap ht_cap
[WLCORE_NUM_BANDS
];
467 /* the current dfs region */
468 enum nl80211_dfs_regions dfs_region
;
469 bool radar_debug_mode
;
471 /* size of the private FW status data */
472 size_t fw_status_len
;
473 size_t fw_status_priv_len
;
475 /* RX Data filter rule state - enabled/disabled */
476 unsigned long rx_filter_enabled
[BITS_TO_LONGS(WL1271_MAX_RX_FILTERS
)];
478 /* size of the private static data */
479 size_t static_data_priv_len
;
481 /* the current channel type */
482 enum nl80211_channel_type channel_type
;
484 /* mutex for protecting the tx_flush function */
485 struct mutex flush_mutex
;
487 /* sleep auth value currently configured to FW */
490 /* the number of allocated MAC addresses in this chip */
493 /* minimum FW version required for the driver to work in single-role */
494 unsigned int min_sr_fw_ver
[NUM_FW_VER
];
496 /* minimum FW version required for the driver to work in multi-role */
497 unsigned int min_mr_fw_ver
[NUM_FW_VER
];
499 struct completion nvs_loading_complete
;
501 /* interface combinations supported by the hw */
502 const struct ieee80211_iface_combination
*iface_combinations
;
503 u8 n_iface_combinations
;
505 /* dynamic fw traces */
506 u32 dynamic_fw_traces
;
508 /* time sync zone master */
509 u8 zone_master_mac_addr
[ETH_ALEN
];
512 int wlcore_probe(struct wl1271
*wl
, struct platform_device
*pdev
);
513 int wlcore_remove(struct platform_device
*pdev
);
514 struct ieee80211_hw
*wlcore_alloc_hw(size_t priv_size
, u32 aggr_buf_size
,
516 int wlcore_free_hw(struct wl1271
*wl
);
517 int wlcore_set_key(struct wl1271
*wl
, enum set_key_cmd cmd
,
518 struct ieee80211_vif
*vif
,
519 struct ieee80211_sta
*sta
,
520 struct ieee80211_key_conf
*key_conf
);
521 void wlcore_regdomain_config(struct wl1271
*wl
);
522 void wlcore_update_inconn_sta(struct wl1271
*wl
, struct wl12xx_vif
*wlvif
,
523 struct wl1271_station
*wl_sta
, bool in_conn
);
526 wlcore_set_ht_cap(struct wl1271
*wl
, enum nl80211_band band
,
527 struct ieee80211_sta_ht_cap
*ht_cap
)
529 memcpy(&wl
->ht_cap
[band
], ht_cap
, sizeof(*ht_cap
));
532 /* Tell wlcore not to care about this element when checking the version */
533 #define WLCORE_FW_VER_IGNORE -1
536 wlcore_set_min_fw_ver(struct wl1271
*wl
, unsigned int chip
,
537 unsigned int iftype_sr
, unsigned int major_sr
,
538 unsigned int subtype_sr
, unsigned int minor_sr
,
539 unsigned int iftype_mr
, unsigned int major_mr
,
540 unsigned int subtype_mr
, unsigned int minor_mr
)
542 wl
->min_sr_fw_ver
[FW_VER_CHIP
] = chip
;
543 wl
->min_sr_fw_ver
[FW_VER_IF_TYPE
] = iftype_sr
;
544 wl
->min_sr_fw_ver
[FW_VER_MAJOR
] = major_sr
;
545 wl
->min_sr_fw_ver
[FW_VER_SUBTYPE
] = subtype_sr
;
546 wl
->min_sr_fw_ver
[FW_VER_MINOR
] = minor_sr
;
548 wl
->min_mr_fw_ver
[FW_VER_CHIP
] = chip
;
549 wl
->min_mr_fw_ver
[FW_VER_IF_TYPE
] = iftype_mr
;
550 wl
->min_mr_fw_ver
[FW_VER_MAJOR
] = major_mr
;
551 wl
->min_mr_fw_ver
[FW_VER_SUBTYPE
] = subtype_mr
;
552 wl
->min_mr_fw_ver
[FW_VER_MINOR
] = minor_mr
;
555 /* Firmware image load chunk size */
556 #define CHUNK_SIZE 16384
560 /* Each RX/TX transaction requires an end-of-transaction transfer */
561 #define WLCORE_QUIRK_END_OF_TRANSACTION BIT(0)
563 /* the first start_role(sta) sometimes doesn't work on wl12xx */
564 #define WLCORE_QUIRK_START_STA_FAILS BIT(1)
566 /* wl127x and SPI don't support SDIO block size alignment */
567 #define WLCORE_QUIRK_TX_BLOCKSIZE_ALIGN BIT(2)
569 /* means aggregated Rx packets are aligned to a SDIO block */
570 #define WLCORE_QUIRK_RX_BLOCKSIZE_ALIGN BIT(3)
572 /* Older firmwares did not implement the FW logger over bus feature */
573 #define WLCORE_QUIRK_FWLOG_NOT_IMPLEMENTED BIT(4)
575 /* Older firmwares use an old NVS format */
576 #define WLCORE_QUIRK_LEGACY_NVS BIT(5)
578 /* pad only the last frame in the aggregate buffer */
579 #define WLCORE_QUIRK_TX_PAD_LAST_FRAME BIT(7)
581 /* extra header space is required for TKIP */
582 #define WLCORE_QUIRK_TKIP_HEADER_SPACE BIT(8)
584 /* Some firmwares not support sched scans while connected */
585 #define WLCORE_QUIRK_NO_SCHED_SCAN_WHILE_CONN BIT(9)
587 /* separate probe response templates for one-shot and sched scans */
588 #define WLCORE_QUIRK_DUAL_PROBE_TMPL BIT(10)
590 /* Firmware requires reg domain configuration for active calibration */
591 #define WLCORE_QUIRK_REGDOMAIN_CONF BIT(11)
593 /* The FW only support a zero session id for AP */
594 #define WLCORE_QUIRK_AP_ZERO_SESSION_ID BIT(12)
596 /* TODO: move all these common registers and values elsewhere */
597 #define HW_ACCESS_ELP_CTRL_REG 0x1FFFC
599 /* ELP register commands */
600 #define ELPCTRL_WAKE_UP 0x1
601 #define ELPCTRL_WAKE_UP_WLAN_READY 0x5
602 #define ELPCTRL_SLEEP 0x0
603 /* ELP WLAN_READY bit */
604 #define ELPCTRL_WLAN_READY 0x2
606 /*************************************************************************
608 Interrupt Trigger Register (Host -> WiLink)
610 **************************************************************************/
612 /* Hardware to Embedded CPU Interrupts - first 32-bit register set */
615 * The host sets this bit to inform the Wlan
616 * FW that a TX packet is in the XFER
619 #define INTR_TRIG_TX_PROC0 BIT(2)
622 * The host sets this bit to inform the FW
623 * that it read a packet from RX XFER
626 #define INTR_TRIG_RX_PROC0 BIT(3)
628 #define INTR_TRIG_DEBUG_ACK BIT(4)
630 #define INTR_TRIG_STATE_CHANGED BIT(5)
632 /* Hardware to Embedded CPU Interrupts - second 32-bit register set */
635 * The host sets this bit to inform the FW
636 * that it read a packet from RX XFER
639 #define INTR_TRIG_RX_PROC1 BIT(17)
642 * The host sets this bit to inform the Wlan
643 * hardware that a TX packet is in the XFER
646 #define INTR_TRIG_TX_PROC1 BIT(18)
648 #define ACX_SLV_SOFT_RESET_BIT BIT(1)
649 #define SOFT_RESET_MAX_TIME 1000000
650 #define SOFT_RESET_STALL_TIME 1000
652 #define ECPU_CONTROL_HALT 0x00000101
654 #define WELP_ARM_COMMAND_VAL 0x4
656 #endif /* __WLCORE_H__ */