2 * Copyright (c) 2010 Atheros Communications Inc.
4 * Permission to use, copy, modify, and/or distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
21 struct wmi_event_txrate {
34 struct wmi_fw_version {
40 struct wmi_event_swba {
46 * 64 - HTC header - WMI header - 1 / txstatus
47 * And some other hdr. space is also accounted for.
48 * 13 seems to be the magic number.
50 #define HTC_MAX_TX_STATUS 13
52 #define ATH9K_HTC_TXSTAT_ACK BIT(0)
53 #define ATH9K_HTC_TXSTAT_FILT BIT(1)
54 #define ATH9K_HTC_TXSTAT_RTC_CTS BIT(2)
55 #define ATH9K_HTC_TXSTAT_MCS BIT(3)
56 #define ATH9K_HTC_TXSTAT_CW40 BIT(4)
57 #define ATH9K_HTC_TXSTAT_SGI BIT(5)
60 * Legacy rates are indicated as indices.
61 * HT rates are indicated as dot11 numbers.
62 * This allows us to resrict the rate field
65 #define ATH9K_HTC_TXSTAT_RATE 0x0f
66 #define ATH9K_HTC_TXSTAT_RATE_S 0
68 #define ATH9K_HTC_TXSTAT_EPID 0xf0
69 #define ATH9K_HTC_TXSTAT_EPID_S 4
71 struct __wmi_event_txstatus {
73 u8 ts_rate; /* Also holds EP ID */
77 struct wmi_event_txstatus {
79 struct __wmi_event_txstatus txstatus[HTC_MAX_TX_STATUS];
83 WMI_ECHO_CMDID = 0x0001,
84 WMI_ACCESS_MEMORY_CMDID,
86 /* Commands to Target */
88 WMI_DISABLE_INTR_CMDID,
89 WMI_ENABLE_INTR_CMDID,
92 WMI_STOP_TX_DMA_CMDID,
93 WMI_ABORT_TX_DMA_CMDID,
95 WMI_DRAIN_TXQ_ALL_CMDID,
100 WMI_NODE_CREATE_CMDID,
101 WMI_NODE_REMOVE_CMDID,
102 WMI_VAP_REMOVE_CMDID,
103 WMI_VAP_CREATE_CMDID,
106 WMI_RC_STATE_CHANGE_CMDID,
107 WMI_RC_RATE_UPDATE_CMDID,
108 WMI_TARGET_IC_UPDATE_CMDID,
110 WMI_TX_AGGR_ENABLE_CMDID,
111 WMI_TGT_DETACH_CMDID,
112 WMI_AGGR_LIMIT_CMD = 0x0026,
116 WMI_TGT_RDY_EVENTID = 0x1001,
123 WMI_TXSTATUS_EVENTID,
126 #define MAX_CMD_NUMBER 62
128 struct register_write {
134 struct ath9k_htc_priv *drv_priv;
135 struct htc_target *htc;
136 enum htc_endpoint_id ctrl_epid;
137 struct mutex op_mutex;
138 struct completion cmd_wait;
139 enum wmi_cmd_id last_cmd_id;
140 struct sk_buff_head wmi_event_queue;
141 struct tasklet_struct wmi_event_tasklet;
150 struct register_write multi_write[MAX_CMD_NUMBER];
152 struct mutex multi_write_mutex;
155 struct wmi *ath9k_init_wmi(struct ath9k_htc_priv *priv);
156 void ath9k_deinit_wmi(struct ath9k_htc_priv *priv);
157 int ath9k_wmi_connect(struct htc_target *htc, struct wmi *wmi,
158 enum htc_endpoint_id *wmi_ctrl_epid);
159 int ath9k_wmi_cmd(struct wmi *wmi, enum wmi_cmd_id cmd_id,
160 u8 *cmd_buf, u32 cmd_len,
161 u8 *rsp_buf, u32 rsp_len,
163 void ath9k_wmi_event_tasklet(unsigned long data);
164 void ath9k_fatal_work(struct work_struct *work);
165 void ath9k_wmi_event_drain(struct ath9k_htc_priv *priv);
167 #define WMI_CMD(_wmi_cmd) \
169 ret = ath9k_wmi_cmd(priv->wmi, _wmi_cmd, NULL, 0, \
171 sizeof(cmd_rsp), HZ*2); \
174 #define WMI_CMD_BUF(_wmi_cmd, _buf) \
176 ret = ath9k_wmi_cmd(priv->wmi, _wmi_cmd, \
177 (u8 *) _buf, sizeof(*_buf), \
178 &cmd_rsp, sizeof(cmd_rsp), HZ*2); \