2 * Copyright (c) 2004-2011 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 * Bootloader Messaging Interface (BMI)
23 * BMI is a very simple messaging interface used during initialization
24 * to read memory, write memory, execute code, and to define an
25 * application entry PC.
27 * It is used to download an application to ATH6KL, to provide
28 * patches to code that is already resident on ATH6KL, and generally
29 * to examine and modify state. The Host has an opportunity to use
30 * BMI only once during bootup. Once the Host issues a BMI_DONE
31 * command, this opportunity ends.
33 * The Host writes BMI requests to mailbox0, and reads BMI responses
34 * from mailbox0. BMI requests all begin with a command
35 * (see below for specific commands), and are followed by
36 * command-specific data.
39 * The Host can only issue a command once the Target gives it a
40 * "BMI Command Credit", using ATH6KL Counter #4. As soon as the
41 * Target has completed a command, it issues another BMI Command
42 * Credit (so the Host can issue the next command).
44 * BMI handles all required Target-side cache flushing.
47 #define MAX_BMI_CMDBUF_SZ (BMI_DATASZ_MAX + \
48 (sizeof(u32) * 3 /* cmd + addr + len */))
50 /* Maximum data size used for BMI transfers */
51 #define BMI_DATASZ_MAX 256
55 #define BMI_NO_COMMAND 0
59 * Semantics: Host is done using BMI
61 * u32 command (BMI_DONE)
62 * Response format: none
65 #define BMI_READ_MEMORY 2
67 * Semantics: Host reads ATH6KL memory
69 * u32 command (BMI_READ_MEMORY)
71 * u32 length, at most BMI_DATASZ_MAX
76 #define BMI_WRITE_MEMORY 3
78 * Semantics: Host writes ATH6KL memory
80 * u32 command (BMI_WRITE_MEMORY)
82 * u32 length, at most BMI_DATASZ_MAX
84 * Response format: none
89 * Semantics: Causes ATH6KL to execute code
91 * u32 command (BMI_EXECUTE)
98 #define BMI_SET_APP_START 5
100 * Semantics: Set Target application starting address
102 * u32 command (BMI_SET_APP_START)
104 * Response format: none
107 #define BMI_READ_SOC_REGISTER 6
109 * Semantics: Read a 32-bit Target SOC register.
111 * u32 command (BMI_READ_REGISTER)
117 #define BMI_WRITE_SOC_REGISTER 7
119 * Semantics: Write a 32-bit Target SOC register.
121 * u32 command (BMI_WRITE_REGISTER)
125 * Response format: none
128 #define BMI_GET_TARGET_ID 8
129 #define BMI_GET_TARGET_INFO 8
131 * Semantics: Fetch the 4-byte Target information
133 * u32 command (BMI_GET_TARGET_ID/INFO)
134 * Response format1 (old firmware):
135 * u32 TargetVersionID
136 * Response format2 (newer firmware):
137 * u32 TARGET_VERSION_SENTINAL
138 * struct bmi_target_info;
141 #define TARGET_VERSION_SENTINAL 0xffffffff
142 #define TARGET_TYPE_AR6003 3
143 #define TARGET_TYPE_AR6004 5
144 #define BMI_ROMPATCH_INSTALL 9
146 * Semantics: Install a ROM Patch.
148 * u32 command (BMI_ROMPATCH_INSTALL)
149 * u32 Target ROM Address
150 * u32 Target RAM Address or Value (depending on Target Type)
152 * u32 Activate? 1-->activate;
153 * 0-->install but do not activate
158 #define BMI_ROMPATCH_UNINSTALL 10
160 * Semantics: Uninstall a previously-installed ROM Patch,
161 * automatically deactivating, if necessary.
163 * u32 command (BMI_ROMPATCH_UNINSTALL)
166 * Response format: none
169 #define BMI_ROMPATCH_ACTIVATE 11
171 * Semantics: Activate a list of previously-installed ROM Patches.
173 * u32 command (BMI_ROMPATCH_ACTIVATE)
175 * u32 PatchID[rompatch_count]
177 * Response format: none
180 #define BMI_ROMPATCH_DEACTIVATE 12
182 * Semantics: Deactivate a list of active ROM Patches.
184 * u32 command (BMI_ROMPATCH_DEACTIVATE)
186 * u32 PatchID[rompatch_count]
188 * Response format: none
192 #define BMI_LZ_STREAM_START 13
194 * Semantics: Begin an LZ-compressed stream of input
195 * which is to be uncompressed by the Target to an
196 * output buffer at address. The output buffer must
197 * be sufficiently large to hold the uncompressed
198 * output from the compressed input stream. This BMI
199 * command should be followed by a series of 1 or more
200 * BMI_LZ_DATA commands.
201 * u32 command (BMI_LZ_STREAM_START)
203 * Note: Not supported on all versions of ROM firmware.
206 #define BMI_LZ_DATA 14
208 * Semantics: Host writes ATH6KL memory with LZ-compressed
209 * data which is uncompressed by the Target. This command
210 * must be preceded by a BMI_LZ_STREAM_START command. A series
211 * of BMI_LZ_DATA commands are considered part of a single
212 * input stream until another BMI_LZ_STREAM_START is issued.
214 * u32 command (BMI_LZ_DATA)
215 * u32 length (of compressed data),
216 * at most BMI_DATASZ_MAX
217 * u8 CompressedData[length]
218 * Response format: none
219 * Note: Not supported on all versions of ROM firmware.
222 #define BMI_COMMUNICATION_TIMEOUT 1000 /* in msec */
225 struct ath6kl_bmi_target_info {
226 __le32 byte_count; /* size of this structure */
227 __le32 version; /* target version id */
228 __le32 type; /* target type */
231 int ath6kl_bmi_init(struct ath6kl *ar);
232 void ath6kl_bmi_cleanup(struct ath6kl *ar);
233 void ath6kl_bmi_reset(struct ath6kl *ar);
235 int ath6kl_bmi_done(struct ath6kl *ar);
236 int ath6kl_bmi_get_target_info(struct ath6kl *ar,
237 struct ath6kl_bmi_target_info *targ_info);
238 int ath6kl_bmi_read(struct ath6kl *ar, u32 addr, u8 *buf, u32 len);
239 int ath6kl_bmi_write(struct ath6kl *ar, u32 addr, u8 *buf, u32 len);
240 int ath6kl_bmi_execute(struct ath6kl *ar,
241 u32 addr, u32 *param);
242 int ath6kl_bmi_set_app_start(struct ath6kl *ar,
244 int ath6kl_bmi_reg_read(struct ath6kl *ar, u32 addr, u32 *param);
245 int ath6kl_bmi_reg_write(struct ath6kl *ar, u32 addr, u32 param);
246 int ath6kl_bmi_lz_data(struct ath6kl *ar,
248 int ath6kl_bmi_lz_stream_start(struct ath6kl *ar,
250 int ath6kl_bmi_fast_download(struct ath6kl *ar,
251 u32 addr, u8 *buf, u32 len);