Luciano Coelho | b2ba99f | 2011-11-20 23:32:10 +0200 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of wlcore |
| 3 | * |
| 4 | * Copyright (C) 2011 Texas Instruments Inc. |
| 5 | * |
| 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. |
| 9 | * |
| 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. |
| 14 | * |
| 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 |
| 18 | * 02110-1301 USA |
| 19 | * |
| 20 | */ |
| 21 | |
| 22 | #ifndef __WLCORE_H__ |
| 23 | #define __WLCORE_H__ |
| 24 | |
Luciano Coelho | c31be25a7 | 2011-11-21 19:25:24 +0200 | [diff] [blame] | 25 | #include <linux/platform_device.h> |
| 26 | |
Luciano Coelho | 8388569 | 2012-05-10 12:13:42 +0300 | [diff] [blame] | 27 | #include "wlcore_i.h" |
Luciano Coelho | c31be25a7 | 2011-11-21 19:25:24 +0200 | [diff] [blame] | 28 | #include "event.h" |
Luciano Coelho | 7140df6 | 2012-05-10 12:14:10 +0300 | [diff] [blame] | 29 | #include "boot.h" |
Luciano Coelho | c31be25a7 | 2011-11-21 19:25:24 +0200 | [diff] [blame] | 30 | |
Arik Nemtsov | 72b0624 | 2011-12-07 21:21:51 +0200 | [diff] [blame] | 31 | /* The maximum number of Tx descriptors in all chip families */ |
| 32 | #define WLCORE_MAX_TX_DESCRIPTORS 32 |
| 33 | |
Arik Nemtsov | f4afbed | 2012-08-02 20:37:21 +0300 | [diff] [blame] | 34 | /* |
| 35 | * We always allocate this number of mac addresses. If we don't |
| 36 | * have enough allocated addresses, the LAA bit is used |
| 37 | */ |
| 38 | #define WLCORE_NUM_MAC_ADDRESSES 3 |
| 39 | |
Arik Nemtsov | cd70f6a | 2011-12-12 12:11:43 +0200 | [diff] [blame] | 40 | /* forward declaration */ |
| 41 | struct wl1271_tx_hw_descr; |
| 42 | enum wl_rx_buf_align; |
Arik Nemtsov | 169da04 | 2012-05-10 12:13:28 +0300 | [diff] [blame] | 43 | struct wl1271_rx_descriptor; |
Arik Nemtsov | 4158149 | 2011-12-12 12:18:17 +0200 | [diff] [blame] | 44 | |
Luciano Coelho | c31be25a7 | 2011-11-21 19:25:24 +0200 | [diff] [blame] | 45 | struct wlcore_ops { |
Ido Yariv | 3992eb2 | 2012-09-02 12:29:27 +0300 | [diff] [blame] | 46 | int (*setup)(struct wl1271 *wl); |
Luciano Coelho | 6f7dd16 | 2011-11-29 16:27:31 +0200 | [diff] [blame] | 47 | int (*identify_chip)(struct wl1271 *wl); |
Luciano Coelho | 80cd661 | 2011-12-06 22:24:57 +0200 | [diff] [blame] | 48 | int (*identify_fw)(struct wl1271 *wl); |
Luciano Coelho | dd5512eb | 2012-04-11 11:03:14 +0300 | [diff] [blame] | 49 | int (*boot)(struct wl1271 *wl); |
Luciano Coelho | c331b34 | 2012-05-10 12:13:49 +0300 | [diff] [blame] | 50 | int (*plt_init)(struct wl1271 *wl); |
Ido Yariv | eb96f84 | 2012-06-18 13:21:55 +0300 | [diff] [blame] | 51 | int (*trigger_cmd)(struct wl1271 *wl, int cmd_box_addr, |
| 52 | void *buf, size_t len); |
Ido Yariv | b0f0ad39 | 2012-06-20 00:48:23 +0300 | [diff] [blame] | 53 | int (*ack_event)(struct wl1271 *wl); |
Arik Nemtsov | b3b4b4b | 2011-12-12 11:41:44 +0200 | [diff] [blame] | 54 | u32 (*calc_tx_blocks)(struct wl1271 *wl, u32 len, u32 spare_blks); |
Arik Nemtsov | 4a3b97ee | 2011-12-12 11:44:27 +0200 | [diff] [blame] | 55 | void (*set_tx_desc_blocks)(struct wl1271 *wl, |
| 56 | struct wl1271_tx_hw_descr *desc, |
| 57 | u32 blks, u32 spare_blks); |
Arik Nemtsov | 6f266e9 | 2011-12-12 11:47:09 +0200 | [diff] [blame] | 58 | void (*set_tx_desc_data_len)(struct wl1271 *wl, |
| 59 | struct wl1271_tx_hw_descr *desc, |
| 60 | struct sk_buff *skb); |
Arik Nemtsov | cd70f6a | 2011-12-12 12:11:43 +0200 | [diff] [blame] | 61 | enum wl_rx_buf_align (*get_rx_buf_align)(struct wl1271 *wl, |
| 62 | u32 rx_desc); |
Ido Yariv | eb96f84 | 2012-06-18 13:21:55 +0300 | [diff] [blame] | 63 | int (*prepare_read)(struct wl1271 *wl, u32 rx_desc, u32 len); |
Arik Nemtsov | 4158149 | 2011-12-12 12:18:17 +0200 | [diff] [blame] | 64 | u32 (*get_rx_packet_len)(struct wl1271 *wl, void *rx_data, |
| 65 | u32 data_len); |
Ido Yariv | 045b9b5 | 2012-06-18 12:31:16 +0300 | [diff] [blame] | 66 | int (*tx_delayed_compl)(struct wl1271 *wl); |
Arik Nemtsov | 53d67a5 | 2011-12-12 11:32:37 +0200 | [diff] [blame] | 67 | void (*tx_immediate_compl)(struct wl1271 *wl); |
Luciano Coelho | 9d68d1e | 2011-12-02 00:47:45 +0200 | [diff] [blame] | 68 | int (*hw_init)(struct wl1271 *wl); |
Arik Nemtsov | 8a9affc | 2011-12-13 12:15:09 +0200 | [diff] [blame] | 69 | int (*init_vif)(struct wl1271 *wl, struct wl12xx_vif *wlvif); |
Arik Nemtsov | fa7930a | 2011-12-13 13:18:17 +0200 | [diff] [blame] | 70 | u32 (*sta_get_ap_rate_mask)(struct wl1271 *wl, |
| 71 | struct wl12xx_vif *wlvif); |
Ido Yariv | 6134323 | 2012-06-18 15:50:21 +0300 | [diff] [blame] | 72 | int (*get_pg_ver)(struct wl1271 *wl, s8 *ver); |
| 73 | int (*get_mac)(struct wl1271 *wl); |
Arik Nemtsov | 2fc28de | 2012-05-10 12:13:27 +0300 | [diff] [blame] | 74 | void (*set_tx_desc_csum)(struct wl1271 *wl, |
| 75 | struct wl1271_tx_hw_descr *desc, |
| 76 | struct sk_buff *skb); |
Arik Nemtsov | 169da04 | 2012-05-10 12:13:28 +0300 | [diff] [blame] | 77 | void (*set_rx_csum)(struct wl1271 *wl, |
| 78 | struct wl1271_rx_descriptor *desc, |
| 79 | struct sk_buff *skb); |
Arik Nemtsov | ebc7e57 | 2012-05-10 12:13:34 +0300 | [diff] [blame] | 80 | u32 (*ap_get_mimo_wide_rate_mask)(struct wl1271 *wl, |
| 81 | struct wl12xx_vif *wlvif); |
Luciano Coelho | 4987257 | 2012-05-10 12:14:06 +0300 | [diff] [blame] | 82 | int (*debugfs_init)(struct wl1271 *wl, struct dentry *rootdir); |
Luciano Coelho | 7140df6 | 2012-05-10 12:14:10 +0300 | [diff] [blame] | 83 | int (*handle_static_data)(struct wl1271 *wl, |
| 84 | struct wl1271_static_data *static_data); |
Arik Nemtsov | 32bb2c0 | 2012-05-18 07:46:37 +0300 | [diff] [blame] | 85 | int (*get_spare_blocks)(struct wl1271 *wl, bool is_gem); |
Arik Nemtsov | a1c597f | 2012-05-18 07:46:40 +0300 | [diff] [blame] | 86 | int (*set_key)(struct wl1271 *wl, enum set_key_cmd cmd, |
| 87 | struct ieee80211_vif *vif, |
| 88 | struct ieee80211_sta *sta, |
| 89 | struct ieee80211_key_conf *key_conf); |
Ido Reis | 9fccc82 | 2012-05-13 14:53:40 +0300 | [diff] [blame] | 90 | u32 (*pre_pkt_send)(struct wl1271 *wl, u32 buf_offset, u32 last_len); |
Luciano Coelho | c31be25a7 | 2011-11-21 19:25:24 +0200 | [diff] [blame] | 91 | }; |
| 92 | |
Luciano Coelho | 25a43d7 | 2011-11-21 20:37:14 +0200 | [diff] [blame] | 93 | enum wlcore_partitions { |
| 94 | PART_DOWN, |
| 95 | PART_WORK, |
| 96 | PART_BOOT, |
| 97 | PART_DRPW, |
| 98 | PART_TOP_PRCM_ELP_SOC, |
| 99 | PART_PHY_INIT, |
| 100 | |
| 101 | PART_TABLE_LEN, |
| 102 | }; |
| 103 | |
| 104 | struct wlcore_partition { |
| 105 | u32 size; |
| 106 | u32 start; |
| 107 | }; |
| 108 | |
| 109 | struct wlcore_partition_set { |
| 110 | struct wlcore_partition mem; |
| 111 | struct wlcore_partition reg; |
| 112 | struct wlcore_partition mem2; |
| 113 | struct wlcore_partition mem3; |
| 114 | }; |
| 115 | |
Luciano Coelho | 0078213 | 2011-11-29 13:38:37 +0200 | [diff] [blame] | 116 | enum wlcore_registers { |
| 117 | /* register addresses, used with partition translation */ |
| 118 | REG_ECPU_CONTROL, |
| 119 | REG_INTERRUPT_NO_CLEAR, |
| 120 | REG_INTERRUPT_ACK, |
| 121 | REG_COMMAND_MAILBOX_PTR, |
| 122 | REG_EVENT_MAILBOX_PTR, |
| 123 | REG_INTERRUPT_TRIG, |
| 124 | REG_INTERRUPT_MASK, |
| 125 | REG_PC_ON_RECOVERY, |
| 126 | REG_CHIP_ID_B, |
| 127 | REG_CMD_MBOX_ADDRESS, |
| 128 | |
| 129 | /* data access memory addresses, used with partition translation */ |
| 130 | REG_SLV_MEM_DATA, |
| 131 | REG_SLV_REG_DATA, |
| 132 | |
| 133 | /* raw data access memory addresses */ |
| 134 | REG_RAW_FW_STATUS_ADDR, |
| 135 | |
| 136 | REG_TABLE_LEN, |
| 137 | }; |
| 138 | |
Luciano Coelho | 4987257 | 2012-05-10 12:14:06 +0300 | [diff] [blame] | 139 | struct wl1271_stats { |
| 140 | void *fw_stats; |
| 141 | unsigned long fw_stats_update; |
| 142 | size_t fw_stats_len; |
| 143 | |
| 144 | unsigned int retry_count; |
| 145 | unsigned int excessive_retries; |
| 146 | }; |
| 147 | |
Luciano Coelho | c31be25a7 | 2011-11-21 19:25:24 +0200 | [diff] [blame] | 148 | struct wl1271 { |
Ido Yariv | 6f8d6b2 | 2012-09-02 01:32:47 +0300 | [diff] [blame] | 149 | bool initialized; |
Luciano Coelho | c31be25a7 | 2011-11-21 19:25:24 +0200 | [diff] [blame] | 150 | struct ieee80211_hw *hw; |
| 151 | bool mac80211_registered; |
| 152 | |
| 153 | struct device *dev; |
Ido Yariv | 3992eb2 | 2012-09-02 12:29:27 +0300 | [diff] [blame] | 154 | struct platform_device *pdev; |
Luciano Coelho | c31be25a7 | 2011-11-21 19:25:24 +0200 | [diff] [blame] | 155 | |
| 156 | void *if_priv; |
| 157 | |
| 158 | struct wl1271_if_operations *if_ops; |
| 159 | |
| 160 | void (*set_power)(bool enable); |
| 161 | int irq; |
Luciano Coelho | c31be25a7 | 2011-11-21 19:25:24 +0200 | [diff] [blame] | 162 | |
| 163 | spinlock_t wl_lock; |
| 164 | |
Ido Yariv | 4cc5338 | 2012-07-24 19:18:49 +0300 | [diff] [blame] | 165 | enum wlcore_state state; |
Luciano Coelho | c31be25a7 | 2011-11-21 19:25:24 +0200 | [diff] [blame] | 166 | enum wl12xx_fw_type fw_type; |
| 167 | bool plt; |
Yair Shapira | 7019c80 | 2012-07-11 18:48:04 +0300 | [diff] [blame] | 168 | enum plt_mode plt_mode; |
Yair Shapira | ff32431 | 2012-07-11 18:48:06 +0300 | [diff] [blame] | 169 | u8 fem_manuf; |
Luciano Coelho | c31be25a7 | 2011-11-21 19:25:24 +0200 | [diff] [blame] | 170 | u8 last_vif_count; |
| 171 | struct mutex mutex; |
| 172 | |
| 173 | unsigned long flags; |
| 174 | |
Luciano Coelho | 25a43d7 | 2011-11-21 20:37:14 +0200 | [diff] [blame] | 175 | struct wlcore_partition_set curr_part; |
Luciano Coelho | c31be25a7 | 2011-11-21 19:25:24 +0200 | [diff] [blame] | 176 | |
| 177 | struct wl1271_chip chip; |
| 178 | |
| 179 | int cmd_box_addr; |
Luciano Coelho | c31be25a7 | 2011-11-21 19:25:24 +0200 | [diff] [blame] | 180 | |
| 181 | u8 *fw; |
| 182 | size_t fw_len; |
| 183 | void *nvs; |
| 184 | size_t nvs_len; |
| 185 | |
| 186 | s8 hw_pg_ver; |
| 187 | |
| 188 | /* address read from the fuse ROM */ |
| 189 | u32 fuse_oui_addr; |
| 190 | u32 fuse_nic_addr; |
| 191 | |
| 192 | /* we have up to 2 MAC addresses */ |
Arik Nemtsov | f4afbed | 2012-08-02 20:37:21 +0300 | [diff] [blame] | 193 | struct mac_address addresses[WLCORE_NUM_MAC_ADDRESSES]; |
Luciano Coelho | c31be25a7 | 2011-11-21 19:25:24 +0200 | [diff] [blame] | 194 | int channel; |
| 195 | u8 system_hlid; |
| 196 | |
| 197 | unsigned long links_map[BITS_TO_LONGS(WL12XX_MAX_LINKS)]; |
| 198 | unsigned long roles_map[BITS_TO_LONGS(WL12XX_MAX_ROLES)]; |
| 199 | unsigned long roc_map[BITS_TO_LONGS(WL12XX_MAX_ROLES)]; |
| 200 | unsigned long rate_policies_map[ |
| 201 | BITS_TO_LONGS(WL12XX_MAX_RATE_POLICIES)]; |
Eliad Peller | 001e39a | 2012-08-16 13:52:47 +0300 | [diff] [blame] | 202 | unsigned long klv_templates_map[ |
| 203 | BITS_TO_LONGS(WLCORE_MAX_KLV_TEMPLATES)]; |
Luciano Coelho | c31be25a7 | 2011-11-21 19:25:24 +0200 | [diff] [blame] | 204 | |
| 205 | struct list_head wlvif_list; |
| 206 | |
| 207 | u8 sta_count; |
| 208 | u8 ap_count; |
| 209 | |
| 210 | struct wl1271_acx_mem_map *target_mem_map; |
| 211 | |
| 212 | /* Accounting for allocated / available TX blocks on HW */ |
| 213 | u32 tx_blocks_freed; |
| 214 | u32 tx_blocks_available; |
| 215 | u32 tx_allocated_blocks; |
| 216 | u32 tx_results_count; |
| 217 | |
Luciano Coelho | c31be25a7 | 2011-11-21 19:25:24 +0200 | [diff] [blame] | 218 | /* Accounting for allocated / available Tx packets in HW */ |
| 219 | u32 tx_pkts_freed[NUM_TX_QUEUES]; |
| 220 | u32 tx_allocated_pkts[NUM_TX_QUEUES]; |
| 221 | |
| 222 | /* Transmitted TX packets counter for chipset interface */ |
| 223 | u32 tx_packets_count; |
| 224 | |
| 225 | /* Time-offset between host and chipset clocks */ |
| 226 | s64 time_offset; |
| 227 | |
| 228 | /* Frames scheduled for transmission, not handled yet */ |
| 229 | int tx_queue_count[NUM_TX_QUEUES]; |
Arik Nemtsov | 6639611 | 2012-05-18 07:46:38 +0300 | [diff] [blame] | 230 | unsigned long queue_stop_reasons[NUM_TX_QUEUES]; |
Luciano Coelho | c31be25a7 | 2011-11-21 19:25:24 +0200 | [diff] [blame] | 231 | |
| 232 | /* Frames received, not handled yet by mac80211 */ |
| 233 | struct sk_buff_head deferred_rx_queue; |
| 234 | |
| 235 | /* Frames sent, not returned yet to mac80211 */ |
| 236 | struct sk_buff_head deferred_tx_queue; |
| 237 | |
| 238 | struct work_struct tx_work; |
| 239 | struct workqueue_struct *freezable_wq; |
| 240 | |
| 241 | /* Pending TX frames */ |
Arik Nemtsov | 72b0624 | 2011-12-07 21:21:51 +0200 | [diff] [blame] | 242 | unsigned long tx_frames_map[BITS_TO_LONGS(WLCORE_MAX_TX_DESCRIPTORS)]; |
| 243 | struct sk_buff *tx_frames[WLCORE_MAX_TX_DESCRIPTORS]; |
Luciano Coelho | c31be25a7 | 2011-11-21 19:25:24 +0200 | [diff] [blame] | 244 | int tx_frames_cnt; |
| 245 | |
| 246 | /* FW Rx counter */ |
| 247 | u32 rx_counter; |
| 248 | |
Luciano Coelho | c31be25a7 | 2011-11-21 19:25:24 +0200 | [diff] [blame] | 249 | /* Intermediate buffer, used for packet aggregation */ |
| 250 | u8 *aggr_buf; |
Igal Chernobelsky | 26a309c | 2012-07-29 18:21:12 +0300 | [diff] [blame] | 251 | u32 aggr_buf_size; |
Luciano Coelho | c31be25a7 | 2011-11-21 19:25:24 +0200 | [diff] [blame] | 252 | |
| 253 | /* Reusable dummy packet template */ |
| 254 | struct sk_buff *dummy_packet; |
| 255 | |
| 256 | /* Network stack work */ |
| 257 | struct work_struct netstack_work; |
| 258 | |
| 259 | /* FW log buffer */ |
| 260 | u8 *fwlog; |
| 261 | |
| 262 | /* Number of valid bytes in the FW log buffer */ |
| 263 | ssize_t fwlog_size; |
| 264 | |
| 265 | /* Sysfs FW log entry readers wait queue */ |
| 266 | wait_queue_head_t fwlog_waitq; |
| 267 | |
| 268 | /* Hardware recovery work */ |
| 269 | struct work_struct recovery_work; |
Yoni Divinsky | afbe371 | 2012-05-16 11:34:18 +0300 | [diff] [blame] | 270 | bool watchdog_recovery; |
Luciano Coelho | c31be25a7 | 2011-11-21 19:25:24 +0200 | [diff] [blame] | 271 | |
| 272 | /* Pointer that holds DMA-friendly block for the mailbox */ |
| 273 | struct event_mailbox *mbox; |
| 274 | |
| 275 | /* The mbox event mask */ |
| 276 | u32 event_mask; |
| 277 | |
| 278 | /* Mailbox pointers */ |
| 279 | u32 mbox_ptr[2]; |
| 280 | |
| 281 | /* Are we currently scanning */ |
| 282 | struct ieee80211_vif *scan_vif; |
| 283 | struct wl1271_scan scan; |
| 284 | struct delayed_work scan_complete_work; |
| 285 | |
Bartosz.Markowski@tieto.com | 5f561f6 | 2012-04-26 10:35:07 +0300 | [diff] [blame] | 286 | /* Connection loss work */ |
| 287 | struct delayed_work connection_loss_work; |
| 288 | |
Luciano Coelho | c31be25a7 | 2011-11-21 19:25:24 +0200 | [diff] [blame] | 289 | bool sched_scanning; |
| 290 | |
| 291 | /* The current band */ |
| 292 | enum ieee80211_band band; |
| 293 | |
| 294 | struct completion *elp_compl; |
| 295 | struct delayed_work elp_work; |
| 296 | |
| 297 | /* in dBm */ |
| 298 | int power_level; |
| 299 | |
| 300 | struct wl1271_stats stats; |
| 301 | |
| 302 | __le32 buffer_32; |
| 303 | u32 buffer_cmd; |
| 304 | u32 buffer_busyword[WL1271_BUSY_WORD_CNT]; |
| 305 | |
Arik Nemtsov | 0afd04e | 2012-05-10 12:13:54 +0300 | [diff] [blame] | 306 | struct wl_fw_status_1 *fw_status_1; |
| 307 | struct wl_fw_status_2 *fw_status_2; |
Luciano Coelho | c31be25a7 | 2011-11-21 19:25:24 +0200 | [diff] [blame] | 308 | struct wl1271_tx_hw_res_if *tx_res_if; |
| 309 | |
| 310 | /* Current chipset configuration */ |
Luciano Coelho | e87288f | 2011-12-05 16:12:54 +0200 | [diff] [blame] | 311 | struct wlcore_conf conf; |
Luciano Coelho | c31be25a7 | 2011-11-21 19:25:24 +0200 | [diff] [blame] | 312 | |
| 313 | bool sg_enabled; |
| 314 | |
| 315 | bool enable_11a; |
| 316 | |
| 317 | /* Most recently reported noise in dBm */ |
| 318 | s8 noise; |
| 319 | |
| 320 | /* bands supported by this instance of wl12xx */ |
Arik Nemtsov | 091185d | 2012-07-03 09:11:03 +0300 | [diff] [blame] | 321 | struct ieee80211_supported_band bands[WLCORE_NUM_BANDS]; |
Luciano Coelho | c31be25a7 | 2011-11-21 19:25:24 +0200 | [diff] [blame] | 322 | |
Luciano Coelho | c31be25a7 | 2011-11-21 19:25:24 +0200 | [diff] [blame] | 323 | /* |
| 324 | * wowlan trigger was configured during suspend. |
| 325 | * (currently, only "ANY" trigger is supported) |
| 326 | */ |
| 327 | bool wow_enabled; |
| 328 | bool irq_wake_enabled; |
| 329 | |
| 330 | /* |
| 331 | * AP-mode - links indexed by HLID. The global and broadcast links |
| 332 | * are always active. |
| 333 | */ |
| 334 | struct wl1271_link links[WL12XX_MAX_LINKS]; |
| 335 | |
| 336 | /* AP-mode - a bitmap of links currently in PS mode according to FW */ |
| 337 | u32 ap_fw_ps_map; |
| 338 | |
| 339 | /* AP-mode - a bitmap of links currently in PS mode in mac80211 */ |
| 340 | unsigned long ap_ps_map; |
| 341 | |
| 342 | /* Quirks of specific hardware revisions */ |
| 343 | unsigned int quirks; |
| 344 | |
| 345 | /* Platform limitations */ |
| 346 | unsigned int platform_quirks; |
| 347 | |
| 348 | /* number of currently active RX BA sessions */ |
| 349 | int ba_rx_session_count; |
| 350 | |
| 351 | /* AP-mode - number of currently connected stations */ |
| 352 | int active_sta_count; |
| 353 | |
| 354 | /* last wlvif we transmitted from */ |
| 355 | struct wl12xx_vif *last_wlvif; |
| 356 | |
| 357 | /* work to fire when Tx is stuck */ |
| 358 | struct delayed_work tx_watchdog_work; |
| 359 | |
| 360 | struct wlcore_ops *ops; |
Luciano Coelho | 25a43d7 | 2011-11-21 20:37:14 +0200 | [diff] [blame] | 361 | /* pointer to the lower driver partition table */ |
| 362 | const struct wlcore_partition_set *ptable; |
Luciano Coelho | 0078213 | 2011-11-29 13:38:37 +0200 | [diff] [blame] | 363 | /* pointer to the lower driver register table */ |
| 364 | const int *rtable; |
Luciano Coelho | 6f7dd16 | 2011-11-29 16:27:31 +0200 | [diff] [blame] | 365 | /* name of the firmwares to load - for PLT, single role, multi-role */ |
| 366 | const char *plt_fw_name; |
| 367 | const char *sr_fw_name; |
| 368 | const char *mr_fw_name; |
Arik Nemtsov | 96e0c68 | 2011-12-07 21:09:03 +0200 | [diff] [blame] | 369 | |
| 370 | /* per-chip-family private structure */ |
| 371 | void *priv; |
Arik Nemtsov | 72b0624 | 2011-12-07 21:21:51 +0200 | [diff] [blame] | 372 | |
| 373 | /* number of TX descriptors the HW supports. */ |
| 374 | u32 num_tx_desc; |
Arik Nemtsov | 0afd04e | 2012-05-10 12:13:54 +0300 | [diff] [blame] | 375 | /* number of RX descriptors the HW supports. */ |
| 376 | u32 num_rx_desc; |
Arik Nemtsov | 3edab30 | 2011-12-07 23:38:47 +0200 | [diff] [blame] | 377 | |
Arik Nemtsov | 43a8bc5 | 2011-12-08 00:43:48 +0200 | [diff] [blame] | 378 | /* translate HW Tx rates to standard rate-indices */ |
| 379 | const u8 **band_rate_to_idx; |
| 380 | |
| 381 | /* size of table for HW rates that can be received from chip */ |
| 382 | u8 hw_tx_rate_tbl_size; |
| 383 | |
| 384 | /* this HW rate and below are considered HT rates for this chip */ |
| 385 | u8 hw_min_ht_rate; |
Arik Nemtsov | 4a589a6 | 2011-12-13 13:20:44 +0200 | [diff] [blame] | 386 | |
| 387 | /* HW HT (11n) capabilities */ |
Arik Nemtsov | 091185d | 2012-07-03 09:11:03 +0300 | [diff] [blame] | 388 | struct ieee80211_sta_ht_cap ht_cap[WLCORE_NUM_BANDS]; |
Arik Nemtsov | 6bac40a | 2011-12-12 12:08:25 +0200 | [diff] [blame] | 389 | |
| 390 | /* size of the private FW status data */ |
| 391 | size_t fw_status_priv_len; |
Eyal Shapira | dbe0a8c | 2012-03-14 06:32:09 +0200 | [diff] [blame] | 392 | |
| 393 | /* RX Data filter rule state - enabled/disabled */ |
| 394 | bool rx_filter_enabled[WL1271_MAX_RX_FILTERS]; |
Arik Nemtsov | 83d08d3 | 2012-05-10 12:13:30 +0300 | [diff] [blame] | 395 | |
Luciano Coelho | 7140df6 | 2012-05-10 12:14:10 +0300 | [diff] [blame] | 396 | /* size of the private static data */ |
| 397 | size_t static_data_priv_len; |
| 398 | |
Arik Nemtsov | 83d08d3 | 2012-05-10 12:13:30 +0300 | [diff] [blame] | 399 | /* the current channel type */ |
| 400 | enum nl80211_channel_type channel_type; |
Arik Nemtsov | 2c38849 | 2012-05-18 07:46:39 +0300 | [diff] [blame] | 401 | |
| 402 | /* mutex for protecting the tx_flush function */ |
| 403 | struct mutex flush_mutex; |
Luciano Coelho | 26b5858 | 2012-02-28 19:13:28 +0200 | [diff] [blame] | 404 | |
| 405 | /* sleep auth value currently configured to FW */ |
| 406 | int sleep_auth; |
Arik Nemtsov | 4a1ccce | 2012-06-25 17:46:40 +0300 | [diff] [blame] | 407 | |
Arik Nemtsov | f4afbed | 2012-08-02 20:37:21 +0300 | [diff] [blame] | 408 | /* the number of allocated MAC addresses in this chip */ |
| 409 | int num_mac_addr; |
| 410 | |
Arik Nemtsov | 4a1ccce | 2012-06-25 17:46:40 +0300 | [diff] [blame] | 411 | /* the minimum FW version required for the driver to work */ |
| 412 | unsigned int min_fw_ver[NUM_FW_VER]; |
Ido Yariv | 6f8d6b2 | 2012-09-02 01:32:47 +0300 | [diff] [blame] | 413 | |
| 414 | struct completion nvs_loading_complete; |
Luciano Coelho | c31be25a7 | 2011-11-21 19:25:24 +0200 | [diff] [blame] | 415 | }; |
Luciano Coelho | ffeb501 | 2011-11-21 18:55:51 +0200 | [diff] [blame] | 416 | |
Bill Pemberton | b74324d | 2012-12-03 09:56:42 -0500 | [diff] [blame] | 417 | int wlcore_probe(struct wl1271 *wl, struct platform_device *pdev); |
| 418 | int wlcore_remove(struct platform_device *pdev); |
Igal Chernobelsky | 26a309c | 2012-07-29 18:21:12 +0300 | [diff] [blame] | 419 | struct ieee80211_hw *wlcore_alloc_hw(size_t priv_size, u32 aggr_buf_size); |
Luciano Coelho | ffeb501 | 2011-11-21 18:55:51 +0200 | [diff] [blame] | 420 | int wlcore_free_hw(struct wl1271 *wl); |
Arik Nemtsov | a1c597f | 2012-05-18 07:46:40 +0300 | [diff] [blame] | 421 | int wlcore_set_key(struct wl1271 *wl, enum set_key_cmd cmd, |
| 422 | struct ieee80211_vif *vif, |
| 423 | struct ieee80211_sta *sta, |
| 424 | struct ieee80211_key_conf *key_conf); |
Luciano Coelho | ffeb501 | 2011-11-21 18:55:51 +0200 | [diff] [blame] | 425 | |
Arik Nemtsov | fa2adfc | 2012-06-13 19:09:25 +0300 | [diff] [blame] | 426 | static inline void |
| 427 | wlcore_set_ht_cap(struct wl1271 *wl, enum ieee80211_band band, |
| 428 | struct ieee80211_sta_ht_cap *ht_cap) |
| 429 | { |
| 430 | memcpy(&wl->ht_cap[band], ht_cap, sizeof(*ht_cap)); |
| 431 | } |
| 432 | |
Arik Nemtsov | 4a1ccce | 2012-06-25 17:46:40 +0300 | [diff] [blame] | 433 | static inline void |
| 434 | wlcore_set_min_fw_ver(struct wl1271 *wl, unsigned int chip, |
| 435 | unsigned int iftype, unsigned int major, |
| 436 | unsigned int subtype, unsigned int minor) |
| 437 | { |
| 438 | wl->min_fw_ver[FW_VER_CHIP] = chip; |
| 439 | wl->min_fw_ver[FW_VER_IF_TYPE] = iftype; |
| 440 | wl->min_fw_ver[FW_VER_MAJOR] = major; |
| 441 | wl->min_fw_ver[FW_VER_SUBTYPE] = subtype; |
| 442 | wl->min_fw_ver[FW_VER_MINOR] = minor; |
| 443 | } |
| 444 | |
Luciano Coelho | 0078213 | 2011-11-29 13:38:37 +0200 | [diff] [blame] | 445 | /* Firmware image load chunk size */ |
| 446 | #define CHUNK_SIZE 16384 |
| 447 | |
Luciano Coelho | 6f7dd16 | 2011-11-29 16:27:31 +0200 | [diff] [blame] | 448 | /* Quirks */ |
| 449 | |
| 450 | /* Each RX/TX transaction requires an end-of-transaction transfer */ |
| 451 | #define WLCORE_QUIRK_END_OF_TRANSACTION BIT(0) |
| 452 | |
| 453 | /* wl127x and SPI don't support SDIO block size alignment */ |
Arik Nemtsov | f83985bb | 2011-12-13 12:11:26 +0200 | [diff] [blame] | 454 | #define WLCORE_QUIRK_TX_BLOCKSIZE_ALIGN BIT(2) |
Luciano Coelho | 6f7dd16 | 2011-11-29 16:27:31 +0200 | [diff] [blame] | 455 | |
Arik Nemtsov | 5766435 | 2011-12-12 12:09:12 +0200 | [diff] [blame] | 456 | /* means aggregated Rx packets are aligned to a SDIO block */ |
| 457 | #define WLCORE_QUIRK_RX_BLOCKSIZE_ALIGN BIT(3) |
| 458 | |
Luciano Coelho | 6f7dd16 | 2011-11-29 16:27:31 +0200 | [diff] [blame] | 459 | /* Older firmwares did not implement the FW logger over bus feature */ |
| 460 | #define WLCORE_QUIRK_FWLOG_NOT_IMPLEMENTED BIT(4) |
| 461 | |
Luciano Coelho | d203e59 | 2011-11-30 12:30:01 +0200 | [diff] [blame] | 462 | /* Older firmwares use an old NVS format */ |
| 463 | #define WLCORE_QUIRK_LEGACY_NVS BIT(5) |
| 464 | |
Luciano Coelho | 441101f | 2011-11-30 15:07:20 +0200 | [diff] [blame] | 465 | /* Some firmwares may not support ELP */ |
| 466 | #define WLCORE_QUIRK_NO_ELP BIT(6) |
| 467 | |
Ido Reis | 9fccc82 | 2012-05-13 14:53:40 +0300 | [diff] [blame] | 468 | /* pad only the last frame in the aggregate buffer */ |
| 469 | #define WLCORE_QUIRK_TX_PAD_LAST_FRAME BIT(7) |
| 470 | |
Arik Nemtsov | 2c0133a | 2012-05-18 07:46:36 +0300 | [diff] [blame] | 471 | /* extra header space is required for TKIP */ |
| 472 | #define WLCORE_QUIRK_TKIP_HEADER_SPACE BIT(8) |
| 473 | |
Victor Goldenshtein | 01b3c0e | 2012-06-14 09:47:40 +0300 | [diff] [blame] | 474 | /* Some firmwares not support sched scans while connected */ |
| 475 | #define WLCORE_QUIRK_NO_SCHED_SCAN_WHILE_CONN BIT(9) |
| 476 | |
Yoni Divinsky | 3df74f4 | 2012-06-27 13:01:44 +0300 | [diff] [blame] | 477 | /* separate probe response templates for one-shot and sched scans */ |
| 478 | #define WLCORE_QUIRK_DUAL_PROBE_TMPL BIT(10) |
| 479 | |
Luciano Coelho | 0078213 | 2011-11-29 13:38:37 +0200 | [diff] [blame] | 480 | /* TODO: move to the lower drivers when all usages are abstracted */ |
| 481 | #define CHIP_ID_1271_PG10 (0x4030101) |
| 482 | #define CHIP_ID_1271_PG20 (0x4030111) |
| 483 | #define CHIP_ID_1283_PG10 (0x05030101) |
| 484 | #define CHIP_ID_1283_PG20 (0x05030111) |
| 485 | |
| 486 | /* TODO: move all these common registers and values elsewhere */ |
| 487 | #define HW_ACCESS_ELP_CTRL_REG 0x1FFFC |
| 488 | |
| 489 | /* ELP register commands */ |
| 490 | #define ELPCTRL_WAKE_UP 0x1 |
| 491 | #define ELPCTRL_WAKE_UP_WLAN_READY 0x5 |
| 492 | #define ELPCTRL_SLEEP 0x0 |
| 493 | /* ELP WLAN_READY bit */ |
| 494 | #define ELPCTRL_WLAN_READY 0x2 |
| 495 | |
| 496 | /************************************************************************* |
| 497 | |
| 498 | Interrupt Trigger Register (Host -> WiLink) |
| 499 | |
| 500 | **************************************************************************/ |
| 501 | |
| 502 | /* Hardware to Embedded CPU Interrupts - first 32-bit register set */ |
| 503 | |
| 504 | /* |
Luciano Coelho | 0078213 | 2011-11-29 13:38:37 +0200 | [diff] [blame] | 505 | * The host sets this bit to inform the Wlan |
| 506 | * FW that a TX packet is in the XFER |
| 507 | * Buffer #0. |
| 508 | */ |
| 509 | #define INTR_TRIG_TX_PROC0 BIT(2) |
| 510 | |
| 511 | /* |
| 512 | * The host sets this bit to inform the FW |
| 513 | * that it read a packet from RX XFER |
| 514 | * Buffer #0. |
| 515 | */ |
| 516 | #define INTR_TRIG_RX_PROC0 BIT(3) |
| 517 | |
| 518 | #define INTR_TRIG_DEBUG_ACK BIT(4) |
| 519 | |
| 520 | #define INTR_TRIG_STATE_CHANGED BIT(5) |
| 521 | |
| 522 | /* Hardware to Embedded CPU Interrupts - second 32-bit register set */ |
| 523 | |
| 524 | /* |
| 525 | * The host sets this bit to inform the FW |
| 526 | * that it read a packet from RX XFER |
| 527 | * Buffer #1. |
| 528 | */ |
| 529 | #define INTR_TRIG_RX_PROC1 BIT(17) |
| 530 | |
| 531 | /* |
| 532 | * The host sets this bit to inform the Wlan |
| 533 | * hardware that a TX packet is in the XFER |
| 534 | * Buffer #1. |
| 535 | */ |
| 536 | #define INTR_TRIG_TX_PROC1 BIT(18) |
| 537 | |
| 538 | #define ACX_SLV_SOFT_RESET_BIT BIT(1) |
| 539 | #define SOFT_RESET_MAX_TIME 1000000 |
| 540 | #define SOFT_RESET_STALL_TIME 1000 |
| 541 | |
| 542 | #define ECPU_CONTROL_HALT 0x00000101 |
Luciano Coelho | b2ba99f | 2011-11-20 23:32:10 +0200 | [diff] [blame] | 543 | |
Luciano Coelho | 6f7dd16 | 2011-11-29 16:27:31 +0200 | [diff] [blame] | 544 | #define WELP_ARM_COMMAND_VAL 0x4 |
| 545 | |
Luciano Coelho | b2ba99f | 2011-11-20 23:32:10 +0200 | [diff] [blame] | 546 | #endif /* __WLCORE_H__ */ |