aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/ath/carl9170/fwdesc.h
diff options
context:
space:
mode:
authorChristian Lamparter <chunkeey@googlemail.com>2010-09-05 19:06:57 -0400
committerJohn W. Linville <linville@tuxdriver.com>2010-09-14 16:03:41 -0400
commitaae9af605a41cb3e9bbad15df72076423a22f903 (patch)
tree76789d6e9b04c6023a41ca4bb4dbd465f3a03897 /drivers/net/wireless/ath/carl9170/fwdesc.h
parentfe8ee9ad80b28382111f0aab01690b09982e5691 (diff)
carl9170: Register maps, tx/rx descriptor formats and eeprom layout
Signed-off-by: Christian Lamparter <chunkeey@googlemail.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless/ath/carl9170/fwdesc.h')
-rw-r--r--drivers/net/wireless/ath/carl9170/fwdesc.h237
1 files changed, 237 insertions, 0 deletions
diff --git a/drivers/net/wireless/ath/carl9170/fwdesc.h b/drivers/net/wireless/ath/carl9170/fwdesc.h
new file mode 100644
index 000000000000..7cd811708fe5
--- /dev/null
+++ b/drivers/net/wireless/ath/carl9170/fwdesc.h
@@ -0,0 +1,237 @@
1/*
2 * Shared CARL9170 Header
3 *
4 * Firmware descriptor format
5 *
6 * Copyright 2009, 2010, Christian Lamparter <chunkeey@googlemail.com>
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; see the file COPYING. If not, see
19 * http://www.gnu.org/licenses/.
20 */
21
22#ifndef __CARL9170_SHARED_FWDESC_H
23#define __CARL9170_SHARED_FWDESC_H
24
25/* NOTE: Don't mess with the order of the flags! */
26enum carl9170fw_feature_list {
27 /* Always set */
28 CARL9170FW_DUMMY_FEATURE,
29
30 /*
31 * Indicates that this image has special boot block which prevents
32 * legacy drivers to drive the firmware.
33 */
34 CARL9170FW_MINIBOOT,
35
36 /* usb registers are initialized by the firmware */
37 CARL9170FW_USB_INIT_FIRMWARE,
38
39 /* command traps & notifications are send through EP2 */
40 CARL9170FW_USB_RESP_EP2,
41
42 /* usb download (app -> fw) stream */
43 CARL9170FW_USB_DOWN_STREAM,
44
45 /* usb upload (fw -> app) stream */
46 CARL9170FW_USB_UP_STREAM,
47
48 /* unusable - reserved to flag non-functional debug firmwares */
49 CARL9170FW_UNUSABLE,
50
51 /* AR9170_CMD_RF_INIT, AR9170_CMD_FREQ_START, AR9170_CMD_FREQUENCY */
52 CARL9170FW_COMMAND_PHY,
53
54 /* AR9170_CMD_EKEY, AR9170_CMD_DKEY */
55 CARL9170FW_COMMAND_CAM,
56
57 /* Firmware has a software Content After Beacon Queueing mechanism */
58 CARL9170FW_WLANTX_CAB,
59
60 /* The firmware is capable of responding to incoming BAR frames */
61 CARL9170FW_HANDLE_BACK_REQ,
62
63 /* GPIO Interrupt | CARL9170_RSP_GPIO */
64 CARL9170FW_GPIO_INTERRUPT,
65
66 /* Firmware PSM support | CARL9170_CMD_PSM */
67 CARL9170FW_PSM,
68
69 /* KEEP LAST */
70 __CARL9170FW_FEATURE_NUM
71};
72
73#define OTUS_MAGIC "OTAR"
74#define MOTD_MAGIC "MOTD"
75#define FIX_MAGIC "FIX\0"
76#define DBG_MAGIC "DBG\0"
77#define CHK_MAGIC "CHK\0"
78#define LAST_MAGIC "LAST"
79
80#define CARL9170FW_SET_DAY(d) (((d) - 1) % 31)
81#define CARL9170FW_SET_MONTH(m) ((((m) - 1) % 12) * 31)
82#define CARL9170FW_SET_YEAR(y) (((y) - 10) * 372)
83
84#define CARL9170FW_GET_DAY(d) (((d) % 31) + 1)
85#define CARL9170FW_GET_MONTH(m) ((((m) / 31) % 12) + 1)
86#define CARL9170FW_GET_YEAR(y) ((y) / 372 + 10)
87
88struct carl9170fw_desc_head {
89 u8 magic[4];
90 __le16 length;
91 u8 min_ver;
92 u8 cur_ver;
93} __packed;
94#define CARL9170FW_DESC_HEAD_SIZE \
95 (sizeof(struct carl9170fw_desc_head))
96
97#define CARL9170FW_OTUS_DESC_MIN_VER 6
98#define CARL9170FW_OTUS_DESC_CUR_VER 6
99struct carl9170fw_otus_desc {
100 struct carl9170fw_desc_head head;
101 __le32 feature_set;
102 __le32 fw_address;
103 __le32 bcn_addr;
104 __le16 bcn_len;
105 __le16 miniboot_size;
106 __le16 tx_frag_len;
107 __le16 rx_max_frame_len;
108 u8 tx_descs;
109 u8 cmd_bufs;
110 u8 api_ver;
111 u8 vif_num;
112} __packed;
113#define CARL9170FW_OTUS_DESC_SIZE \
114 (sizeof(struct carl9170fw_otus_desc))
115
116#define CARL9170FW_MOTD_STRING_LEN 24
117#define CARL9170FW_MOTD_RELEASE_LEN 20
118#define CARL9170FW_MOTD_DESC_MIN_VER 1
119#define CARL9170FW_MOTD_DESC_CUR_VER 2
120struct carl9170fw_motd_desc {
121 struct carl9170fw_desc_head head;
122 __le32 fw_year_month_day;
123 char desc[CARL9170FW_MOTD_STRING_LEN];
124 char release[CARL9170FW_MOTD_RELEASE_LEN];
125} __packed;
126#define CARL9170FW_MOTD_DESC_SIZE \
127 (sizeof(struct carl9170fw_motd_desc))
128
129#define CARL9170FW_FIX_DESC_MIN_VER 1
130#define CARL9170FW_FIX_DESC_CUR_VER 2
131struct carl9170fw_fix_entry {
132 __le32 address;
133 __le32 mask;
134 __le32 value;
135} __packed;
136
137struct carl9170fw_fix_desc {
138 struct carl9170fw_desc_head head;
139 struct carl9170fw_fix_entry data[0];
140} __packed;
141#define CARL9170FW_FIX_DESC_SIZE \
142 (sizeof(struct carl9170fw_fix_desc))
143
144#define CARL9170FW_DBG_DESC_MIN_VER 1
145#define CARL9170FW_DBG_DESC_CUR_VER 2
146struct carl9170fw_dbg_desc {
147 struct carl9170fw_desc_head head;
148
149 __le32 bogoclock_addr;
150 __le32 counter_addr;
151 __le32 rx_total_addr;
152 __le32 rx_overrun_addr;
153
154 /* Put your debugging definitions here */
155} __packed;
156#define CARL9170FW_DBG_DESC_SIZE \
157 (sizeof(struct carl9170fw_dbg_desc))
158
159#define CARL9170FW_CHK_DESC_MIN_VER 1
160#define CARL9170FW_CHK_DESC_CUR_VER 2
161struct carl9170fw_chk_desc {
162 struct carl9170fw_desc_head head;
163 __le32 fw_crc32;
164 __le32 hdr_crc32;
165} __packed;
166#define CARL9170FW_CHK_DESC_SIZE \
167 (sizeof(struct carl9170fw_chk_desc))
168
169#define CARL9170FW_LAST_DESC_MIN_VER 1
170#define CARL9170FW_LAST_DESC_CUR_VER 2
171struct carl9170fw_last_desc {
172 struct carl9170fw_desc_head head;
173} __packed;
174#define CARL9170FW_LAST_DESC_SIZE \
175 (sizeof(struct carl9170fw_fix_desc))
176
177#define CARL9170FW_DESC_MAX_LENGTH 8192
178
179#define CARL9170FW_FILL_DESC(_magic, _length, _min_ver, _cur_ver) \
180 .head = { \
181 .magic = _magic, \
182 .length = cpu_to_le16(_length), \
183 .min_ver = _min_ver, \
184 .cur_ver = _cur_ver, \
185 }
186
187static inline void carl9170fw_fill_desc(struct carl9170fw_desc_head *head,
188 u8 magic[4], __le16 length,
189 u8 min_ver, u8 cur_ver)
190{
191 head->magic[0] = magic[0];
192 head->magic[1] = magic[1];
193 head->magic[2] = magic[2];
194 head->magic[3] = magic[3];
195
196 head->length = length;
197 head->min_ver = min_ver;
198 head->cur_ver = cur_ver;
199}
200
201#define carl9170fw_for_each_hdr(desc, fw_desc) \
202 for (desc = fw_desc; \
203 memcmp(desc->magic, LAST_MAGIC, 4) && \
204 le16_to_cpu(desc->length) >= CARL9170FW_DESC_HEAD_SIZE && \
205 le16_to_cpu(desc->length) < CARL9170FW_DESC_MAX_LENGTH; \
206 desc = (void *)((unsigned long)desc + le16_to_cpu(desc->length)))
207
208#define CHECK_HDR_VERSION(head, _min_ver) \
209 (((head)->cur_ver < _min_ver) || ((head)->min_ver > _min_ver)) \
210
211static inline bool carl9170fw_supports(__le32 list, u8 feature)
212{
213 return le32_to_cpu(list) & BIT(feature);
214}
215
216static inline bool carl9170fw_desc_cmp(const struct carl9170fw_desc_head *head,
217 const u8 descid[4], u16 min_len,
218 u8 compatible_revision)
219{
220 if (descid[0] == head->magic[0] && descid[1] == head->magic[1] &&
221 descid[2] == head->magic[2] && descid[3] == head->magic[3] &&
222 !CHECK_HDR_VERSION(head, compatible_revision) &&
223 (le16_to_cpu(head->length) >= min_len))
224 return true;
225
226 return false;
227}
228
229#define CARL9170FW_MIN_SIZE 32
230#define CARL9170FW_MAX_SIZE 16384
231
232static inline bool carl9170fw_size_check(unsigned int len)
233{
234 return (len <= CARL9170FW_MAX_SIZE && len >= CARL9170FW_MIN_SIZE);
235}
236
237#endif /* __CARL9170_SHARED_FWDESC_H */