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 /* forward declaration */
44 struct wl1271_tx_hw_descr
;
46 struct wl1271_rx_descriptor
;
49 int (*setup
)(struct wl1271
*wl
);
50 int (*identify_chip
)(struct wl1271
*wl
);
51 int (*identify_fw
)(struct wl1271
*wl
);
52 int (*boot
)(struct wl1271
*wl
);
53 int (*plt_init
)(struct wl1271
*wl
);
54 int (*trigger_cmd
)(struct wl1271
*wl
, int cmd_box_addr
,
55 void *buf
, size_t len
);
56 int (*ack_event
)(struct wl1271
*wl
);
57 int (*wait_for_event
)(struct wl1271
*wl
, enum wlcore_wait_event event
,
59 int (*process_mailbox_events
)(struct wl1271
*wl
);
60 u32 (*calc_tx_blocks
)(struct wl1271
*wl
, u32 len
, u32 spare_blks
);
61 void (*set_tx_desc_blocks
)(struct wl1271
*wl
,
62 struct wl1271_tx_hw_descr
*desc
,
63 u32 blks
, u32 spare_blks
);
64 void (*set_tx_desc_data_len
)(struct wl1271
*wl
,
65 struct wl1271_tx_hw_descr
*desc
,
67 enum wl_rx_buf_align (*get_rx_buf_align
)(struct wl1271
*wl
,
69 int (*prepare_read
)(struct wl1271
*wl
, u32 rx_desc
, u32 len
);
70 u32 (*get_rx_packet_len
)(struct wl1271
*wl
, void *rx_data
,
72 int (*tx_delayed_compl
)(struct wl1271
*wl
);
73 void (*tx_immediate_compl
)(struct wl1271
*wl
);
74 int (*hw_init
)(struct wl1271
*wl
);
75 int (*init_vif
)(struct wl1271
*wl
, struct wl12xx_vif
*wlvif
);
76 u32 (*sta_get_ap_rate_mask
)(struct wl1271
*wl
,
77 struct wl12xx_vif
*wlvif
);
78 int (*get_pg_ver
)(struct wl1271
*wl
, s8
*ver
);
79 int (*get_mac
)(struct wl1271
*wl
);
80 void (*set_tx_desc_csum
)(struct wl1271
*wl
,
81 struct wl1271_tx_hw_descr
*desc
,
83 void (*set_rx_csum
)(struct wl1271
*wl
,
84 struct wl1271_rx_descriptor
*desc
,
86 u32 (*ap_get_mimo_wide_rate_mask
)(struct wl1271
*wl
,
87 struct wl12xx_vif
*wlvif
);
88 int (*debugfs_init
)(struct wl1271
*wl
, struct dentry
*rootdir
);
89 int (*handle_static_data
)(struct wl1271
*wl
,
90 struct wl1271_static_data
*static_data
);
91 int (*scan_start
)(struct wl1271
*wl
, struct wl12xx_vif
*wlvif
,
92 struct cfg80211_scan_request
*req
);
93 int (*scan_stop
)(struct wl1271
*wl
, struct wl12xx_vif
*wlvif
);
94 int (*sched_scan_start
)(struct wl1271
*wl
, struct wl12xx_vif
*wlvif
,
95 struct cfg80211_sched_scan_request
*req
,
96 struct ieee80211_sched_scan_ies
*ies
);
97 void (*sched_scan_stop
)(struct wl1271
*wl
, struct wl12xx_vif
*wlvif
);
98 int (*get_spare_blocks
)(struct wl1271
*wl
, bool is_gem
);
99 int (*set_key
)(struct wl1271
*wl
, enum set_key_cmd cmd
,
100 struct ieee80211_vif
*vif
,
101 struct ieee80211_sta
*sta
,
102 struct ieee80211_key_conf
*key_conf
);
103 int (*channel_switch
)(struct wl1271
*wl
,
104 struct wl12xx_vif
*wlvif
,
105 struct ieee80211_channel_switch
*ch_switch
);
106 u32 (*pre_pkt_send
)(struct wl1271
*wl
, u32 buf_offset
, u32 last_len
);
107 void (*sta_rc_update
)(struct wl1271
*wl
, struct wl12xx_vif
*wlvif
,
108 struct ieee80211_sta
*sta
, u32 changed
);
109 int (*set_peer_cap
)(struct wl1271
*wl
,
110 struct ieee80211_sta_ht_cap
*ht_cap
,
111 bool allow_ht_operation
,
112 u32 rate_set
, u8 hlid
);
113 bool (*lnk_high_prio
)(struct wl1271
*wl
, u8 hlid
,
114 struct wl1271_link
*lnk
);
115 bool (*lnk_low_prio
)(struct wl1271
*wl
, u8 hlid
,
116 struct wl1271_link
*lnk
);
119 enum wlcore_partitions
{
124 PART_TOP_PRCM_ELP_SOC
,
130 struct wlcore_partition
{
135 struct wlcore_partition_set
{
136 struct wlcore_partition mem
;
137 struct wlcore_partition reg
;
138 struct wlcore_partition mem2
;
139 struct wlcore_partition mem3
;
142 enum wlcore_registers
{
143 /* register addresses, used with partition translation */
145 REG_INTERRUPT_NO_CLEAR
,
147 REG_COMMAND_MAILBOX_PTR
,
148 REG_EVENT_MAILBOX_PTR
,
153 REG_CMD_MBOX_ADDRESS
,
155 /* data access memory addresses, used with partition translation */
159 /* raw data access memory addresses */
160 REG_RAW_FW_STATUS_ADDR
,
165 struct wl1271_stats
{
167 unsigned long fw_stats_update
;
170 unsigned int retry_count
;
171 unsigned int excessive_retries
;
176 struct ieee80211_hw
*hw
;
177 bool mac80211_registered
;
180 struct platform_device
*pdev
;
184 struct wl1271_if_operations
*if_ops
;
190 enum wlcore_state state
;
191 enum wl12xx_fw_type fw_type
;
193 enum plt_mode plt_mode
;
200 struct wlcore_partition_set curr_part
;
202 struct wl1271_chip chip
;
213 /* address read from the fuse ROM */
217 /* we have up to 2 MAC addresses */
218 struct mac_address addresses
[WLCORE_NUM_MAC_ADDRESSES
];
222 unsigned long links_map
[BITS_TO_LONGS(WL12XX_MAX_LINKS
)];
223 unsigned long roles_map
[BITS_TO_LONGS(WL12XX_MAX_ROLES
)];
224 unsigned long roc_map
[BITS_TO_LONGS(WL12XX_MAX_ROLES
)];
225 unsigned long rate_policies_map
[
226 BITS_TO_LONGS(WL12XX_MAX_RATE_POLICIES
)];
227 unsigned long klv_templates_map
[
228 BITS_TO_LONGS(WLCORE_MAX_KLV_TEMPLATES
)];
230 u8 session_ids
[WL12XX_MAX_LINKS
];
232 struct list_head wlvif_list
;
237 struct wl1271_acx_mem_map
*target_mem_map
;
239 /* Accounting for allocated / available TX blocks on HW */
241 u32 tx_blocks_available
;
242 u32 tx_allocated_blocks
;
243 u32 tx_results_count
;
245 /* Accounting for allocated / available Tx packets in HW */
246 u32 tx_pkts_freed
[NUM_TX_QUEUES
];
247 u32 tx_allocated_pkts
[NUM_TX_QUEUES
];
249 /* Transmitted TX packets counter for chipset interface */
250 u32 tx_packets_count
;
252 /* Time-offset between host and chipset clocks */
255 /* Frames scheduled for transmission, not handled yet */
256 int tx_queue_count
[NUM_TX_QUEUES
];
257 unsigned long queue_stop_reasons
[
258 NUM_TX_QUEUES
* WLCORE_NUM_MAC_ADDRESSES
];
260 /* Frames received, not handled yet by mac80211 */
261 struct sk_buff_head deferred_rx_queue
;
263 /* Frames sent, not returned yet to mac80211 */
264 struct sk_buff_head deferred_tx_queue
;
266 struct work_struct tx_work
;
267 struct workqueue_struct
*freezable_wq
;
269 /* Pending TX frames */
270 unsigned long tx_frames_map
[BITS_TO_LONGS(WLCORE_MAX_TX_DESCRIPTORS
)];
271 struct sk_buff
*tx_frames
[WLCORE_MAX_TX_DESCRIPTORS
];
277 /* Intermediate buffer, used for packet aggregation */
281 /* Reusable dummy packet template */
282 struct sk_buff
*dummy_packet
;
284 /* Network stack work */
285 struct work_struct netstack_work
;
290 /* Number of valid bytes in the FW log buffer */
293 /* Sysfs FW log entry readers wait queue */
294 wait_queue_head_t fwlog_waitq
;
296 /* Hardware recovery work */
297 struct work_struct recovery_work
;
298 bool watchdog_recovery
;
300 /* Reg domain last configuration */
301 u32 reg_ch_conf_last
[2];
302 /* Reg domain pending configuration */
303 u32 reg_ch_conf_pending
[2];
305 /* Pointer that holds DMA-friendly block for the mailbox */
308 /* The mbox event mask */
311 /* Mailbox pointers */
315 /* Are we currently scanning */
316 struct wl12xx_vif
*scan_wlvif
;
317 struct wl1271_scan scan
;
318 struct delayed_work scan_complete_work
;
320 struct ieee80211_vif
*roc_vif
;
321 struct delayed_work roc_complete_work
;
323 struct wl12xx_vif
*sched_vif
;
325 /* The current band */
326 enum ieee80211_band band
;
328 struct completion
*elp_compl
;
329 struct delayed_work elp_work
;
334 struct wl1271_stats stats
;
338 u32 buffer_busyword
[WL1271_BUSY_WORD_CNT
];
340 struct wl_fw_status_1
*fw_status_1
;
341 struct wl_fw_status_2
*fw_status_2
;
342 struct wl1271_tx_hw_res_if
*tx_res_if
;
344 /* Current chipset configuration */
345 struct wlcore_conf conf
;
353 /* Most recently reported noise in dBm */
356 /* bands supported by this instance of wl12xx */
357 struct ieee80211_supported_band bands
[WLCORE_NUM_BANDS
];
360 * wowlan trigger was configured during suspend.
361 * (currently, only "ANY" trigger is supported)
364 bool irq_wake_enabled
;
367 * AP-mode - links indexed by HLID. The global and broadcast links
370 struct wl1271_link links
[WL12XX_MAX_LINKS
];
372 /* number of currently active links */
373 int active_link_count
;
375 /* Fast/slow links bitmap according to FW */
378 /* AP-mode - a bitmap of links currently in PS mode according to FW */
381 /* AP-mode - a bitmap of links currently in PS mode in mac80211 */
382 unsigned long ap_ps_map
;
384 /* Quirks of specific hardware revisions */
387 /* Platform limitations */
388 unsigned int platform_quirks
;
390 /* number of currently active RX BA sessions */
391 int ba_rx_session_count
;
393 /* Maximum number of supported RX BA sessions */
394 int ba_rx_session_count_max
;
396 /* AP-mode - number of currently connected stations */
397 int active_sta_count
;
399 /* last wlvif we transmitted from */
400 struct wl12xx_vif
*last_wlvif
;
402 /* work to fire when Tx is stuck */
403 struct delayed_work tx_watchdog_work
;
405 struct wlcore_ops
*ops
;
406 /* pointer to the lower driver partition table */
407 const struct wlcore_partition_set
*ptable
;
408 /* pointer to the lower driver register table */
410 /* name of the firmwares to load - for PLT, single role, multi-role */
411 const char *plt_fw_name
;
412 const char *sr_fw_name
;
413 const char *mr_fw_name
;
415 u8 scan_templ_id_2_4
;
417 u8 sched_scan_templ_id_2_4
;
418 u8 sched_scan_templ_id_5
;
421 /* per-chip-family private structure */
424 /* number of TX descriptors the HW supports. */
426 /* number of RX descriptors the HW supports. */
429 /* translate HW Tx rates to standard rate-indices */
430 const u8
**band_rate_to_idx
;
432 /* size of table for HW rates that can be received from chip */
433 u8 hw_tx_rate_tbl_size
;
435 /* this HW rate and below are considered HT rates for this chip */
438 /* HW HT (11n) capabilities */
439 struct ieee80211_sta_ht_cap ht_cap
[WLCORE_NUM_BANDS
];
441 /* size of the private FW status data */
442 size_t fw_status_priv_len
;
444 /* RX Data filter rule state - enabled/disabled */
445 bool rx_filter_enabled
[WL1271_MAX_RX_FILTERS
];
447 /* size of the private static data */
448 size_t static_data_priv_len
;
450 /* the current channel type */
451 enum nl80211_channel_type channel_type
;
453 /* mutex for protecting the tx_flush function */
454 struct mutex flush_mutex
;
456 /* sleep auth value currently configured to FW */
459 /* the number of allocated MAC addresses in this chip */
462 /* minimum FW version required for the driver to work in single-role */
463 unsigned int min_sr_fw_ver
[NUM_FW_VER
];
465 /* minimum FW version required for the driver to work in multi-role */
466 unsigned int min_mr_fw_ver
[NUM_FW_VER
];
468 struct completion nvs_loading_complete
;
470 /* number of concurrent channels the HW supports */
474 int wlcore_probe(struct wl1271
*wl
, struct platform_device
*pdev
);
475 int wlcore_remove(struct platform_device
*pdev
);
476 struct ieee80211_hw
*wlcore_alloc_hw(size_t priv_size
, u32 aggr_buf_size
,
478 int wlcore_free_hw(struct wl1271
*wl
);
479 int wlcore_set_key(struct wl1271
*wl
, enum set_key_cmd cmd
,
480 struct ieee80211_vif
*vif
,
481 struct ieee80211_sta
*sta
,
482 struct ieee80211_key_conf
*key_conf
);
483 void wlcore_regdomain_config(struct wl1271
*wl
);
486 wlcore_set_ht_cap(struct wl1271
*wl
, enum ieee80211_band band
,
487 struct ieee80211_sta_ht_cap
*ht_cap
)
489 memcpy(&wl
->ht_cap
[band
], ht_cap
, sizeof(*ht_cap
));
492 /* Tell wlcore not to care about this element when checking the version */
493 #define WLCORE_FW_VER_IGNORE -1
496 wlcore_set_min_fw_ver(struct wl1271
*wl
, unsigned int chip
,
497 unsigned int iftype_sr
, unsigned int major_sr
,
498 unsigned int subtype_sr
, unsigned int minor_sr
,
499 unsigned int iftype_mr
, unsigned int major_mr
,
500 unsigned int subtype_mr
, unsigned int minor_mr
)
502 wl
->min_sr_fw_ver
[FW_VER_CHIP
] = chip
;
503 wl
->min_sr_fw_ver
[FW_VER_IF_TYPE
] = iftype_sr
;
504 wl
->min_sr_fw_ver
[FW_VER_MAJOR
] = major_sr
;
505 wl
->min_sr_fw_ver
[FW_VER_SUBTYPE
] = subtype_sr
;
506 wl
->min_sr_fw_ver
[FW_VER_MINOR
] = minor_sr
;
508 wl
->min_mr_fw_ver
[FW_VER_CHIP
] = chip
;
509 wl
->min_mr_fw_ver
[FW_VER_IF_TYPE
] = iftype_mr
;
510 wl
->min_mr_fw_ver
[FW_VER_MAJOR
] = major_mr
;
511 wl
->min_mr_fw_ver
[FW_VER_SUBTYPE
] = subtype_mr
;
512 wl
->min_mr_fw_ver
[FW_VER_MINOR
] = minor_mr
;
515 /* Firmware image load chunk size */
516 #define CHUNK_SIZE 16384
520 /* Each RX/TX transaction requires an end-of-transaction transfer */
521 #define WLCORE_QUIRK_END_OF_TRANSACTION BIT(0)
523 /* the first start_role(sta) sometimes doesn't work on wl12xx */
524 #define WLCORE_QUIRK_START_STA_FAILS BIT(1)
526 /* wl127x and SPI don't support SDIO block size alignment */
527 #define WLCORE_QUIRK_TX_BLOCKSIZE_ALIGN BIT(2)
529 /* means aggregated Rx packets are aligned to a SDIO block */
530 #define WLCORE_QUIRK_RX_BLOCKSIZE_ALIGN BIT(3)
532 /* Older firmwares did not implement the FW logger over bus feature */
533 #define WLCORE_QUIRK_FWLOG_NOT_IMPLEMENTED BIT(4)
535 /* Older firmwares use an old NVS format */
536 #define WLCORE_QUIRK_LEGACY_NVS BIT(5)
538 /* pad only the last frame in the aggregate buffer */
539 #define WLCORE_QUIRK_TX_PAD_LAST_FRAME BIT(7)
541 /* extra header space is required for TKIP */
542 #define WLCORE_QUIRK_TKIP_HEADER_SPACE BIT(8)
544 /* Some firmwares not support sched scans while connected */
545 #define WLCORE_QUIRK_NO_SCHED_SCAN_WHILE_CONN BIT(9)
547 /* separate probe response templates for one-shot and sched scans */
548 #define WLCORE_QUIRK_DUAL_PROBE_TMPL BIT(10)
550 /* Firmware requires reg domain configuration for active calibration */
551 #define WLCORE_QUIRK_REGDOMAIN_CONF BIT(11)
553 /* The FW only support a zero session id for AP */
554 #define WLCORE_QUIRK_AP_ZERO_SESSION_ID BIT(12)
556 /* TODO: move all these common registers and values elsewhere */
557 #define HW_ACCESS_ELP_CTRL_REG 0x1FFFC
559 /* ELP register commands */
560 #define ELPCTRL_WAKE_UP 0x1
561 #define ELPCTRL_WAKE_UP_WLAN_READY 0x5
562 #define ELPCTRL_SLEEP 0x0
563 /* ELP WLAN_READY bit */
564 #define ELPCTRL_WLAN_READY 0x2
566 /*************************************************************************
568 Interrupt Trigger Register (Host -> WiLink)
570 **************************************************************************/
572 /* Hardware to Embedded CPU Interrupts - first 32-bit register set */
575 * The host sets this bit to inform the Wlan
576 * FW that a TX packet is in the XFER
579 #define INTR_TRIG_TX_PROC0 BIT(2)
582 * The host sets this bit to inform the FW
583 * that it read a packet from RX XFER
586 #define INTR_TRIG_RX_PROC0 BIT(3)
588 #define INTR_TRIG_DEBUG_ACK BIT(4)
590 #define INTR_TRIG_STATE_CHANGED BIT(5)
592 /* Hardware to Embedded CPU Interrupts - second 32-bit register set */
595 * The host sets this bit to inform the FW
596 * that it read a packet from RX XFER
599 #define INTR_TRIG_RX_PROC1 BIT(17)
602 * The host sets this bit to inform the Wlan
603 * hardware that a TX packet is in the XFER
606 #define INTR_TRIG_TX_PROC1 BIT(18)
608 #define ACX_SLV_SOFT_RESET_BIT BIT(1)
609 #define SOFT_RESET_MAX_TIME 1000000
610 #define SOFT_RESET_STALL_TIME 1000
612 #define ECPU_CONTROL_HALT 0x00000101
614 #define WELP_ARM_COMMAND_VAL 0x4
616 #endif /* __WLCORE_H__ */