2 * Copyright (c) 2004-2011 Atheros Communications Inc.
3 * Copyright (c) 2011 Qualcomm Atheros, Inc.
5 * Permission to use, copy, modify, and/or distribute this software for any
6 * purpose with or without fee is hereby granted, provided that the above
7 * copyright notice and this permission notice appear in all copies.
9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
22 * Bootloader Messaging Interface (BMI)
24 * BMI is a very simple messaging interface used during initialization
25 * to read memory, write memory, execute code, and to define an
26 * application entry PC.
28 * It is used to download an application to ATH6KL, to provide
29 * patches to code that is already resident on ATH6KL, and generally
30 * to examine and modify state. The Host has an opportunity to use
31 * BMI only once during bootup. Once the Host issues a BMI_DONE
32 * command, this opportunity ends.
34 * The Host writes BMI requests to mailbox0, and reads BMI responses
35 * from mailbox0. BMI requests all begin with a command
36 * (see below for specific commands), and are followed by
37 * command-specific data.
40 * The Host can only issue a command once the Target gives it a
41 * "BMI Command Credit", using ATH6KL Counter #4. As soon as the
42 * Target has completed a command, it issues another BMI Command
43 * Credit (so the Host can issue the next command).
45 * BMI handles all required Target-side cache flushing.
50 #define BMI_NO_COMMAND 0
54 * Semantics: Host is done using BMI
56 * u32 command (BMI_DONE)
57 * Response format: none
60 #define BMI_READ_MEMORY 2
62 * Semantics: Host reads ATH6KL memory
64 * u32 command (BMI_READ_MEMORY)
66 * u32 length, at most BMI_DATASZ_MAX
71 #define BMI_WRITE_MEMORY 3
73 * Semantics: Host writes ATH6KL memory
75 * u32 command (BMI_WRITE_MEMORY)
77 * u32 length, at most BMI_DATASZ_MAX
79 * Response format: none
84 * Semantics: Causes ATH6KL to execute code
86 * u32 command (BMI_EXECUTE)
93 #define BMI_SET_APP_START 5
95 * Semantics: Set Target application starting address
97 * u32 command (BMI_SET_APP_START)
99 * Response format: none
102 #define BMI_READ_SOC_REGISTER 6
104 * Semantics: Read a 32-bit Target SOC register.
106 * u32 command (BMI_READ_REGISTER)
112 #define BMI_WRITE_SOC_REGISTER 7
114 * Semantics: Write a 32-bit Target SOC register.
116 * u32 command (BMI_WRITE_REGISTER)
120 * Response format: none
123 #define BMI_GET_TARGET_ID 8
124 #define BMI_GET_TARGET_INFO 8
126 * Semantics: Fetch the 4-byte Target information
128 * u32 command (BMI_GET_TARGET_ID/INFO)
129 * Response format1 (old firmware):
130 * u32 TargetVersionID
131 * Response format2 (newer firmware):
132 * u32 TARGET_VERSION_SENTINAL
133 * struct bmi_target_info;
136 #define TARGET_VERSION_SENTINAL 0xffffffff
137 #define TARGET_TYPE_AR6003 3
138 #define TARGET_TYPE_AR6004 5
139 #define BMI_ROMPATCH_INSTALL 9
141 * Semantics: Install a ROM Patch.
143 * u32 command (BMI_ROMPATCH_INSTALL)
144 * u32 Target ROM Address
145 * u32 Target RAM Address or Value (depending on Target Type)
147 * u32 Activate? 1-->activate;
148 * 0-->install but do not activate
153 #define BMI_ROMPATCH_UNINSTALL 10
155 * Semantics: Uninstall a previously-installed ROM Patch,
156 * automatically deactivating, if necessary.
158 * u32 command (BMI_ROMPATCH_UNINSTALL)
161 * Response format: none
164 #define BMI_ROMPATCH_ACTIVATE 11
166 * Semantics: Activate a list of previously-installed ROM Patches.
168 * u32 command (BMI_ROMPATCH_ACTIVATE)
170 * u32 PatchID[rompatch_count]
172 * Response format: none
175 #define BMI_ROMPATCH_DEACTIVATE 12
177 * Semantics: Deactivate a list of active ROM Patches.
179 * u32 command (BMI_ROMPATCH_DEACTIVATE)
181 * u32 PatchID[rompatch_count]
183 * Response format: none
187 #define BMI_LZ_STREAM_START 13
189 * Semantics: Begin an LZ-compressed stream of input
190 * which is to be uncompressed by the Target to an
191 * output buffer at address. The output buffer must
192 * be sufficiently large to hold the uncompressed
193 * output from the compressed input stream. This BMI
194 * command should be followed by a series of 1 or more
195 * BMI_LZ_DATA commands.
196 * u32 command (BMI_LZ_STREAM_START)
198 * Note: Not supported on all versions of ROM firmware.
201 #define BMI_LZ_DATA 14
203 * Semantics: Host writes ATH6KL memory with LZ-compressed
204 * data which is uncompressed by the Target. This command
205 * must be preceded by a BMI_LZ_STREAM_START command. A series
206 * of BMI_LZ_DATA commands are considered part of a single
207 * input stream until another BMI_LZ_STREAM_START is issued.
209 * u32 command (BMI_LZ_DATA)
210 * u32 length (of compressed data),
211 * at most BMI_DATASZ_MAX
212 * u8 CompressedData[length]
213 * Response format: none
214 * Note: Not supported on all versions of ROM firmware.
217 #define BMI_COMMUNICATION_TIMEOUT 1000 /* in msec */
220 struct ath6kl_bmi_target_info
{
221 __le32 byte_count
; /* size of this structure */
222 __le32 version
; /* target version id */
223 __le32 type
; /* target type */
226 #define ath6kl_bmi_write_hi32(ar, item, val) \
231 addr = ath6kl_get_hi_item_addr(ar, HI_ITEM(item)); \
232 v = cpu_to_le32(val); \
233 ath6kl_bmi_write(ar, addr, (u8 *) &v, sizeof(v)); \
236 #define ath6kl_bmi_read_hi32(ar, item, val) \
238 u32 addr, *check_type = val; \
242 (void) (check_type == val); \
243 addr = ath6kl_get_hi_item_addr(ar, HI_ITEM(item)); \
244 ret = ath6kl_bmi_read(ar, addr, (u8 *) &tmp, 4); \
245 *val = le32_to_cpu(tmp); \
249 int ath6kl_bmi_init(struct ath6kl
*ar
);
250 void ath6kl_bmi_cleanup(struct ath6kl
*ar
);
251 void ath6kl_bmi_reset(struct ath6kl
*ar
);
253 int ath6kl_bmi_done(struct ath6kl
*ar
);
254 int ath6kl_bmi_get_target_info(struct ath6kl
*ar
,
255 struct ath6kl_bmi_target_info
*targ_info
);
256 int ath6kl_bmi_read(struct ath6kl
*ar
, u32 addr
, u8
*buf
, u32 len
);
257 int ath6kl_bmi_write(struct ath6kl
*ar
, u32 addr
, u8
*buf
, u32 len
);
258 int ath6kl_bmi_execute(struct ath6kl
*ar
,
259 u32 addr
, u32
*param
);
260 int ath6kl_bmi_set_app_start(struct ath6kl
*ar
,
262 int ath6kl_bmi_reg_read(struct ath6kl
*ar
, u32 addr
, u32
*param
);
263 int ath6kl_bmi_reg_write(struct ath6kl
*ar
, u32 addr
, u32 param
);
264 int ath6kl_bmi_lz_data(struct ath6kl
*ar
,
266 int ath6kl_bmi_lz_stream_start(struct ath6kl
*ar
,
268 int ath6kl_bmi_fast_download(struct ath6kl
*ar
,
269 u32 addr
, u8
*buf
, u32 len
);