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 int (*identify_chip
)(struct wl1271
*wl
);
32 int (*boot
)(struct wl1271
*wl
);
33 void (*trigger_cmd
)(struct wl1271
*wl
);
34 void (*ack_event
)(struct wl1271
*wl
);
35 s8 (*get_pg_ver
)(struct wl1271
*wl
);
36 void (*get_mac
)(struct wl1271
*wl
);
39 enum wlcore_partitions
{
44 PART_TOP_PRCM_ELP_SOC
,
50 struct wlcore_partition
{
55 struct wlcore_partition_set
{
56 struct wlcore_partition mem
;
57 struct wlcore_partition reg
;
58 struct wlcore_partition mem2
;
59 struct wlcore_partition mem3
;
62 enum wlcore_registers
{
63 /* register addresses, used with partition translation */
65 REG_INTERRUPT_NO_CLEAR
,
67 REG_COMMAND_MAILBOX_PTR
,
68 REG_EVENT_MAILBOX_PTR
,
75 /* data access memory addresses, used with partition translation */
79 /* raw data access memory addresses */
80 REG_RAW_FW_STATUS_ADDR
,
86 struct ieee80211_hw
*hw
;
87 bool mac80211_registered
;
93 struct wl1271_if_operations
*if_ops
;
95 void (*set_power
)(bool enable
);
101 enum wl1271_state state
;
102 enum wl12xx_fw_type fw_type
;
109 struct wlcore_partition_set curr_part
;
111 struct wl1271_chip chip
;
122 /* address read from the fuse ROM */
126 /* we have up to 2 MAC addresses */
127 struct mac_address addresses
[2];
131 unsigned long links_map
[BITS_TO_LONGS(WL12XX_MAX_LINKS
)];
132 unsigned long roles_map
[BITS_TO_LONGS(WL12XX_MAX_ROLES
)];
133 unsigned long roc_map
[BITS_TO_LONGS(WL12XX_MAX_ROLES
)];
134 unsigned long rate_policies_map
[
135 BITS_TO_LONGS(WL12XX_MAX_RATE_POLICIES
)];
137 struct list_head wlvif_list
;
142 struct wl1271_acx_mem_map
*target_mem_map
;
144 /* Accounting for allocated / available TX blocks on HW */
146 u32 tx_blocks_available
;
147 u32 tx_allocated_blocks
;
148 u32 tx_results_count
;
150 /* amount of spare TX blocks to use */
153 /* Accounting for allocated / available Tx packets in HW */
154 u32 tx_pkts_freed
[NUM_TX_QUEUES
];
155 u32 tx_allocated_pkts
[NUM_TX_QUEUES
];
157 /* Transmitted TX packets counter for chipset interface */
158 u32 tx_packets_count
;
160 /* Time-offset between host and chipset clocks */
163 /* Frames scheduled for transmission, not handled yet */
164 int tx_queue_count
[NUM_TX_QUEUES
];
165 long stopped_queues_map
;
167 /* Frames received, not handled yet by mac80211 */
168 struct sk_buff_head deferred_rx_queue
;
170 /* Frames sent, not returned yet to mac80211 */
171 struct sk_buff_head deferred_tx_queue
;
173 struct work_struct tx_work
;
174 struct workqueue_struct
*freezable_wq
;
176 /* Pending TX frames */
177 unsigned long tx_frames_map
[BITS_TO_LONGS(ACX_TX_DESCRIPTORS
)];
178 struct sk_buff
*tx_frames
[ACX_TX_DESCRIPTORS
];
184 /* Rx memory pool address */
185 struct wl1271_rx_mem_pool_addr rx_mem_pool_addr
;
187 /* Intermediate buffer, used for packet aggregation */
190 /* Reusable dummy packet template */
191 struct sk_buff
*dummy_packet
;
193 /* Network stack work */
194 struct work_struct netstack_work
;
199 /* Number of valid bytes in the FW log buffer */
202 /* Sysfs FW log entry readers wait queue */
203 wait_queue_head_t fwlog_waitq
;
205 /* Hardware recovery work */
206 struct work_struct recovery_work
;
208 /* Pointer that holds DMA-friendly block for the mailbox */
209 struct event_mailbox
*mbox
;
211 /* The mbox event mask */
214 /* Mailbox pointers */
217 /* Are we currently scanning */
218 struct ieee80211_vif
*scan_vif
;
219 struct wl1271_scan scan
;
220 struct delayed_work scan_complete_work
;
224 /* The current band */
225 enum ieee80211_band band
;
227 struct completion
*elp_compl
;
228 struct delayed_work elp_work
;
233 struct wl1271_stats stats
;
237 u32 buffer_busyword
[WL1271_BUSY_WORD_CNT
];
239 struct wl12xx_fw_status
*fw_status
;
240 struct wl1271_tx_hw_res_if
*tx_res_if
;
242 /* Current chipset configuration */
243 struct conf_drv_settings conf
;
249 /* Most recently reported noise in dBm */
252 /* bands supported by this instance of wl12xx */
253 struct ieee80211_supported_band bands
[IEEE80211_NUM_BANDS
];
258 * wowlan trigger was configured during suspend.
259 * (currently, only "ANY" trigger is supported)
262 bool irq_wake_enabled
;
265 * AP-mode - links indexed by HLID. The global and broadcast links
268 struct wl1271_link links
[WL12XX_MAX_LINKS
];
270 /* AP-mode - a bitmap of links currently in PS mode according to FW */
273 /* AP-mode - a bitmap of links currently in PS mode in mac80211 */
274 unsigned long ap_ps_map
;
276 /* Quirks of specific hardware revisions */
279 /* Platform limitations */
280 unsigned int platform_quirks
;
282 /* number of currently active RX BA sessions */
283 int ba_rx_session_count
;
285 /* AP-mode - number of currently connected stations */
286 int active_sta_count
;
288 /* last wlvif we transmitted from */
289 struct wl12xx_vif
*last_wlvif
;
291 /* work to fire when Tx is stuck */
292 struct delayed_work tx_watchdog_work
;
294 struct wlcore_ops
*ops
;
295 /* pointer to the lower driver partition table */
296 const struct wlcore_partition_set
*ptable
;
297 /* pointer to the lower driver register table */
299 /* name of the firmwares to load - for PLT, single role, multi-role */
300 const char *plt_fw_name
;
301 const char *sr_fw_name
;
302 const char *mr_fw_name
;
304 /* per-chip-family private structure */
308 int __devinit
wlcore_probe(struct wl1271
*wl
, struct platform_device
*pdev
);
309 int __devexit
wlcore_remove(struct platform_device
*pdev
);
310 struct ieee80211_hw
*wlcore_alloc_hw(size_t priv_size
);
311 int wlcore_free_hw(struct wl1271
*wl
);
313 /* Firmware image load chunk size */
314 #define CHUNK_SIZE 16384
318 /* Each RX/TX transaction requires an end-of-transaction transfer */
319 #define WLCORE_QUIRK_END_OF_TRANSACTION BIT(0)
321 /* wl127x and SPI don't support SDIO block size alignment */
322 #define WLCORE_QUIRK_NO_BLOCKSIZE_ALIGNMENT BIT(2)
324 /* Older firmwares did not implement the FW logger over bus feature */
325 #define WLCORE_QUIRK_FWLOG_NOT_IMPLEMENTED BIT(4)
327 /* Older firmwares use an old NVS format */
328 #define WLCORE_QUIRK_LEGACY_NVS BIT(5)
330 /* Some firmwares may not support ELP */
331 #define WLCORE_QUIRK_NO_ELP BIT(6)
333 /* TODO: move to the lower drivers when all usages are abstracted */
334 #define CHIP_ID_1271_PG10 (0x4030101)
335 #define CHIP_ID_1271_PG20 (0x4030111)
336 #define CHIP_ID_1283_PG10 (0x05030101)
337 #define CHIP_ID_1283_PG20 (0x05030111)
339 /* TODO: move all these common registers and values elsewhere */
340 #define HW_ACCESS_ELP_CTRL_REG 0x1FFFC
342 /* ELP register commands */
343 #define ELPCTRL_WAKE_UP 0x1
344 #define ELPCTRL_WAKE_UP_WLAN_READY 0x5
345 #define ELPCTRL_SLEEP 0x0
346 /* ELP WLAN_READY bit */
347 #define ELPCTRL_WLAN_READY 0x2
349 /*************************************************************************
351 Interrupt Trigger Register (Host -> WiLink)
353 **************************************************************************/
355 /* Hardware to Embedded CPU Interrupts - first 32-bit register set */
358 * The host sets this bit to inform the Wlan
359 * FW that a TX packet is in the XFER
362 #define INTR_TRIG_TX_PROC0 BIT(2)
365 * The host sets this bit to inform the FW
366 * that it read a packet from RX XFER
369 #define INTR_TRIG_RX_PROC0 BIT(3)
371 #define INTR_TRIG_DEBUG_ACK BIT(4)
373 #define INTR_TRIG_STATE_CHANGED BIT(5)
375 /* Hardware to Embedded CPU Interrupts - second 32-bit register set */
378 * The host sets this bit to inform the FW
379 * that it read a packet from RX XFER
382 #define INTR_TRIG_RX_PROC1 BIT(17)
385 * The host sets this bit to inform the Wlan
386 * hardware that a TX packet is in the XFER
389 #define INTR_TRIG_TX_PROC1 BIT(18)
391 #define ACX_SLV_SOFT_RESET_BIT BIT(1)
392 #define SOFT_RESET_MAX_TIME 1000000
393 #define SOFT_RESET_STALL_TIME 1000
395 #define ECPU_CONTROL_HALT 0x00000101
397 #define WELP_ARM_COMMAND_VAL 0x4
399 #endif /* __WLCORE_H__ */