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>
30 /* The maximum number of Tx descriptors in all chip families */
31 #define WLCORE_MAX_TX_DESCRIPTORS 32
33 /* forward declaration */
34 struct wl1271_tx_hw_descr
;
38 int (*identify_chip
)(struct wl1271
*wl
);
39 int (*boot
)(struct wl1271
*wl
);
40 void (*trigger_cmd
)(struct wl1271
*wl
);
41 void (*ack_event
)(struct wl1271
*wl
);
42 u32 (*calc_tx_blocks
)(struct wl1271
*wl
, u32 len
, u32 spare_blks
);
43 void (*set_tx_desc_blocks
)(struct wl1271
*wl
,
44 struct wl1271_tx_hw_descr
*desc
,
45 u32 blks
, u32 spare_blks
);
46 void (*set_tx_desc_data_len
)(struct wl1271
*wl
,
47 struct wl1271_tx_hw_descr
*desc
,
49 enum wl_rx_buf_align (*get_rx_buf_align
)(struct wl1271
*wl
,
51 void (*prepare_read
)(struct wl1271
*wl
, u32 rx_desc
, u32 len
);
52 u32 (*get_rx_packet_len
)(struct wl1271
*wl
, void *rx_data
,
54 void (*tx_delayed_compl
)(struct wl1271
*wl
);
55 void (*tx_immediate_compl
)(struct wl1271
*wl
);
56 s8 (*get_pg_ver
)(struct wl1271
*wl
);
57 void (*get_mac
)(struct wl1271
*wl
);
60 enum wlcore_partitions
{
65 PART_TOP_PRCM_ELP_SOC
,
71 struct wlcore_partition
{
76 struct wlcore_partition_set
{
77 struct wlcore_partition mem
;
78 struct wlcore_partition reg
;
79 struct wlcore_partition mem2
;
80 struct wlcore_partition mem3
;
83 enum wlcore_registers
{
84 /* register addresses, used with partition translation */
86 REG_INTERRUPT_NO_CLEAR
,
88 REG_COMMAND_MAILBOX_PTR
,
89 REG_EVENT_MAILBOX_PTR
,
96 /* data access memory addresses, used with partition translation */
100 /* raw data access memory addresses */
101 REG_RAW_FW_STATUS_ADDR
,
107 struct ieee80211_hw
*hw
;
108 bool mac80211_registered
;
114 struct wl1271_if_operations
*if_ops
;
116 void (*set_power
)(bool enable
);
122 enum wl1271_state state
;
123 enum wl12xx_fw_type fw_type
;
130 struct wlcore_partition_set curr_part
;
132 struct wl1271_chip chip
;
143 /* address read from the fuse ROM */
147 /* we have up to 2 MAC addresses */
148 struct mac_address addresses
[2];
152 unsigned long links_map
[BITS_TO_LONGS(WL12XX_MAX_LINKS
)];
153 unsigned long roles_map
[BITS_TO_LONGS(WL12XX_MAX_ROLES
)];
154 unsigned long roc_map
[BITS_TO_LONGS(WL12XX_MAX_ROLES
)];
155 unsigned long rate_policies_map
[
156 BITS_TO_LONGS(WL12XX_MAX_RATE_POLICIES
)];
158 struct list_head wlvif_list
;
163 struct wl1271_acx_mem_map
*target_mem_map
;
165 /* Accounting for allocated / available TX blocks on HW */
167 u32 tx_blocks_available
;
168 u32 tx_allocated_blocks
;
169 u32 tx_results_count
;
171 /* Accounting for allocated / available Tx packets in HW */
172 u32 tx_pkts_freed
[NUM_TX_QUEUES
];
173 u32 tx_allocated_pkts
[NUM_TX_QUEUES
];
175 /* Transmitted TX packets counter for chipset interface */
176 u32 tx_packets_count
;
178 /* Time-offset between host and chipset clocks */
181 /* Frames scheduled for transmission, not handled yet */
182 int tx_queue_count
[NUM_TX_QUEUES
];
183 long stopped_queues_map
;
185 /* Frames received, not handled yet by mac80211 */
186 struct sk_buff_head deferred_rx_queue
;
188 /* Frames sent, not returned yet to mac80211 */
189 struct sk_buff_head deferred_tx_queue
;
191 struct work_struct tx_work
;
192 struct workqueue_struct
*freezable_wq
;
194 /* Pending TX frames */
195 unsigned long tx_frames_map
[BITS_TO_LONGS(WLCORE_MAX_TX_DESCRIPTORS
)];
196 struct sk_buff
*tx_frames
[WLCORE_MAX_TX_DESCRIPTORS
];
202 /* Rx memory pool address */
203 struct wl1271_rx_mem_pool_addr rx_mem_pool_addr
;
205 /* Intermediate buffer, used for packet aggregation */
208 /* Reusable dummy packet template */
209 struct sk_buff
*dummy_packet
;
211 /* Network stack work */
212 struct work_struct netstack_work
;
217 /* Number of valid bytes in the FW log buffer */
220 /* Sysfs FW log entry readers wait queue */
221 wait_queue_head_t fwlog_waitq
;
223 /* Hardware recovery work */
224 struct work_struct recovery_work
;
226 /* Pointer that holds DMA-friendly block for the mailbox */
227 struct event_mailbox
*mbox
;
229 /* The mbox event mask */
232 /* Mailbox pointers */
235 /* Are we currently scanning */
236 struct ieee80211_vif
*scan_vif
;
237 struct wl1271_scan scan
;
238 struct delayed_work scan_complete_work
;
242 /* The current band */
243 enum ieee80211_band band
;
245 struct completion
*elp_compl
;
246 struct delayed_work elp_work
;
251 struct wl1271_stats stats
;
255 u32 buffer_busyword
[WL1271_BUSY_WORD_CNT
];
257 struct wl12xx_fw_status
*fw_status
;
258 struct wl1271_tx_hw_res_if
*tx_res_if
;
260 /* Current chipset configuration */
261 struct conf_drv_settings conf
;
267 /* Most recently reported noise in dBm */
270 /* bands supported by this instance of wl12xx */
271 struct ieee80211_supported_band bands
[IEEE80211_NUM_BANDS
];
276 * wowlan trigger was configured during suspend.
277 * (currently, only "ANY" trigger is supported)
280 bool irq_wake_enabled
;
283 * AP-mode - links indexed by HLID. The global and broadcast links
286 struct wl1271_link links
[WL12XX_MAX_LINKS
];
288 /* AP-mode - a bitmap of links currently in PS mode according to FW */
291 /* AP-mode - a bitmap of links currently in PS mode in mac80211 */
292 unsigned long ap_ps_map
;
294 /* Quirks of specific hardware revisions */
297 /* Platform limitations */
298 unsigned int platform_quirks
;
300 /* number of currently active RX BA sessions */
301 int ba_rx_session_count
;
303 /* AP-mode - number of currently connected stations */
304 int active_sta_count
;
306 /* last wlvif we transmitted from */
307 struct wl12xx_vif
*last_wlvif
;
309 /* work to fire when Tx is stuck */
310 struct delayed_work tx_watchdog_work
;
312 struct wlcore_ops
*ops
;
313 /* pointer to the lower driver partition table */
314 const struct wlcore_partition_set
*ptable
;
315 /* pointer to the lower driver register table */
317 /* name of the firmwares to load - for PLT, single role, multi-role */
318 const char *plt_fw_name
;
319 const char *sr_fw_name
;
320 const char *mr_fw_name
;
322 /* per-chip-family private structure */
325 /* number of TX descriptors the HW supports. */
328 /* spare Tx blocks for normal/GEM operating modes */
332 /* translate HW Tx rates to standard rate-indices */
333 const u8
**band_rate_to_idx
;
335 /* size of table for HW rates that can be received from chip */
336 u8 hw_tx_rate_tbl_size
;
338 /* this HW rate and below are considered HT rates for this chip */
342 int __devinit
wlcore_probe(struct wl1271
*wl
, struct platform_device
*pdev
);
343 int __devexit
wlcore_remove(struct platform_device
*pdev
);
344 struct ieee80211_hw
*wlcore_alloc_hw(size_t priv_size
);
345 int wlcore_free_hw(struct wl1271
*wl
);
347 /* Firmware image load chunk size */
348 #define CHUNK_SIZE 16384
352 /* Each RX/TX transaction requires an end-of-transaction transfer */
353 #define WLCORE_QUIRK_END_OF_TRANSACTION BIT(0)
355 /* wl127x and SPI don't support SDIO block size alignment */
356 #define WLCORE_QUIRK_TX_BLOCKSIZE_ALIGN BIT(2)
358 /* means aggregated Rx packets are aligned to a SDIO block */
359 #define WLCORE_QUIRK_RX_BLOCKSIZE_ALIGN BIT(3)
361 /* Older firmwares did not implement the FW logger over bus feature */
362 #define WLCORE_QUIRK_FWLOG_NOT_IMPLEMENTED BIT(4)
364 /* Older firmwares use an old NVS format */
365 #define WLCORE_QUIRK_LEGACY_NVS BIT(5)
367 /* Some firmwares may not support ELP */
368 #define WLCORE_QUIRK_NO_ELP BIT(6)
370 /* TODO: move to the lower drivers when all usages are abstracted */
371 #define CHIP_ID_1271_PG10 (0x4030101)
372 #define CHIP_ID_1271_PG20 (0x4030111)
373 #define CHIP_ID_1283_PG10 (0x05030101)
374 #define CHIP_ID_1283_PG20 (0x05030111)
376 /* TODO: move all these common registers and values elsewhere */
377 #define HW_ACCESS_ELP_CTRL_REG 0x1FFFC
379 /* ELP register commands */
380 #define ELPCTRL_WAKE_UP 0x1
381 #define ELPCTRL_WAKE_UP_WLAN_READY 0x5
382 #define ELPCTRL_SLEEP 0x0
383 /* ELP WLAN_READY bit */
384 #define ELPCTRL_WLAN_READY 0x2
386 /*************************************************************************
388 Interrupt Trigger Register (Host -> WiLink)
390 **************************************************************************/
392 /* Hardware to Embedded CPU Interrupts - first 32-bit register set */
395 * The host sets this bit to inform the Wlan
396 * FW that a TX packet is in the XFER
399 #define INTR_TRIG_TX_PROC0 BIT(2)
402 * The host sets this bit to inform the FW
403 * that it read a packet from RX XFER
406 #define INTR_TRIG_RX_PROC0 BIT(3)
408 #define INTR_TRIG_DEBUG_ACK BIT(4)
410 #define INTR_TRIG_STATE_CHANGED BIT(5)
412 /* Hardware to Embedded CPU Interrupts - second 32-bit register set */
415 * The host sets this bit to inform the FW
416 * that it read a packet from RX XFER
419 #define INTR_TRIG_RX_PROC1 BIT(17)
422 * The host sets this bit to inform the Wlan
423 * hardware that a TX packet is in the XFER
426 #define INTR_TRIG_TX_PROC1 BIT(18)
428 #define ACX_SLV_SOFT_RESET_BIT BIT(1)
429 #define SOFT_RESET_MAX_TIME 1000000
430 #define SOFT_RESET_STALL_TIME 1000
432 #define ECPU_CONTROL_HALT 0x00000101
434 #define WELP_ARM_COMMAND_VAL 0x4
436 #endif /* __WLCORE_H__ */