28 if (ar->
bmi.done_sent) {
33 ar->
bmi.done_sent =
true;
35 ret = ath6kl_hif_bmi_write(ar, (
u8 *)&cid,
sizeof(cid));
37 ath6kl_err(
"Unable to send bmi done: %d\n", ret);
50 if (ar->
bmi.done_sent) {
51 ath6kl_err(
"bmi done sent already, cmd %d disallowed\n", cid);
55 ret = ath6kl_hif_bmi_write(ar, (
u8 *)&cid,
sizeof(cid));
57 ath6kl_err(
"Unable to send get target info: %d\n", ret);
62 ret = ath6kl_hif_bmi_read(ar, (
u8 *)targ_info,
65 ret = ath6kl_hif_bmi_read(ar, (
u8 *)&targ_info->
version,
70 ath6kl_err(
"Unable to recv target info: %d\n", ret);
76 ret = ath6kl_hif_bmi_read(ar,
80 ath6kl_err(
"unable to read target info byte count: %d\n",
95 ret = ath6kl_hif_bmi_read(ar,
102 ath6kl_err(
"Unable to read target info (%d bytes): %d\n",
108 ath6kl_dbg(
ATH6KL_DBG_BMI,
"target info (ver: 0x%x type: 0x%x)\n",
119 u32 len_remain, rx_len;
122 if (ar->
bmi.done_sent) {
123 ath6kl_err(
"bmi done sent already, cmd %d disallowed\n", cid);
127 size = ar->
bmi.max_data_size +
sizeof(
cid) +
sizeof(addr) +
sizeof(len);
128 if (size > ar->
bmi.max_cmd_size) {
135 "bmi read memory: device: addr: 0x%x, len: %d\n",
141 rx_len = (len_remain < ar->
bmi.max_data_size) ?
142 len_remain : ar->
bmi.max_data_size;
145 offset +=
sizeof(
cid);
146 memcpy(&(ar->
bmi.cmd_buf[offset]), &addr,
sizeof(addr));
147 offset +=
sizeof(
addr);
148 memcpy(&(ar->
bmi.cmd_buf[offset]), &rx_len,
sizeof(rx_len));
149 offset +=
sizeof(len);
151 ret = ath6kl_hif_bmi_write(ar, ar->
bmi.cmd_buf, offset);
153 ath6kl_err(
"Unable to write to the device: %d\n",
157 ret = ath6kl_hif_bmi_read(ar, ar->
bmi.cmd_buf, rx_len);
159 ath6kl_err(
"Unable to read from the device: %d\n",
163 memcpy(&buf[len - len_remain], ar->
bmi.cmd_buf, rx_len);
164 len_remain -= rx_len; addr += rx_len;
175 u32 len_remain, tx_len;
176 const u32 header =
sizeof(
cid) +
sizeof(addr) +
sizeof(len);
180 if (ar->
bmi.done_sent) {
181 ath6kl_err(
"bmi done sent already, cmd %d disallowed\n", cid);
185 if ((ar->
bmi.max_data_size + header) > ar->
bmi.max_cmd_size) {
190 if (
WARN_ON(ar->
bmi.max_data_size >
sizeof(aligned_buf)))
193 memset(ar->
bmi.cmd_buf, 0, ar->
bmi.max_data_size + header);
196 "bmi write memory: addr: 0x%x, len: %d\n", addr, len);
200 src = &buf[len - len_remain];
202 if (len_remain < (ar->
bmi.max_data_size - header)) {
203 if (len_remain & 3) {
205 len_remain = len_remain +
206 (4 - (len_remain & 3));
207 memcpy(aligned_buf, src, len_remain);
212 tx_len = (ar->
bmi.max_data_size - header);
216 memcpy(&(ar->
bmi.cmd_buf[offset]), &cid,
sizeof(cid));
217 offset +=
sizeof(
cid);
218 memcpy(&(ar->
bmi.cmd_buf[offset]), &addr,
sizeof(addr));
219 offset +=
sizeof(
addr);
220 memcpy(&(ar->
bmi.cmd_buf[offset]), &tx_len,
sizeof(tx_len));
221 offset +=
sizeof(tx_len);
222 memcpy(&(ar->
bmi.cmd_buf[offset]), src, tx_len);
225 ret = ath6kl_hif_bmi_write(ar, ar->
bmi.cmd_buf, offset);
227 ath6kl_err(
"Unable to write to the device: %d\n",
231 len_remain -= tx_len; addr += tx_len;
244 if (ar->
bmi.done_sent) {
245 ath6kl_err(
"bmi done sent already, cmd %d disallowed\n", cid);
249 size =
sizeof(
cid) +
sizeof(addr) +
sizeof(
param);
250 if (size > ar->
bmi.max_cmd_size) {
256 ath6kl_dbg(
ATH6KL_DBG_BMI,
"bmi execute: addr: 0x%x, param: %d)\n",
260 memcpy(&(ar->
bmi.cmd_buf[offset]), &cid,
sizeof(cid));
261 offset +=
sizeof(
cid);
262 memcpy(&(ar->
bmi.cmd_buf[offset]), &addr,
sizeof(addr));
263 offset +=
sizeof(
addr);
264 memcpy(&(ar->
bmi.cmd_buf[offset]), param,
sizeof(*param));
265 offset +=
sizeof(*param);
267 ret = ath6kl_hif_bmi_write(ar, ar->
bmi.cmd_buf, offset);
269 ath6kl_err(
"Unable to write to the device: %d\n", ret);
273 ret = ath6kl_hif_bmi_read(ar, ar->
bmi.cmd_buf,
sizeof(*param));
275 ath6kl_err(
"Unable to read from the device: %d\n", ret);
279 memcpy(param, ar->
bmi.cmd_buf,
sizeof(*param));
291 if (ar->
bmi.done_sent) {
292 ath6kl_err(
"bmi done sent already, cmd %d disallowed\n", cid);
296 size =
sizeof(
cid) +
sizeof(addr);
297 if (size > ar->
bmi.max_cmd_size) {
303 ath6kl_dbg(
ATH6KL_DBG_BMI,
"bmi set app start: addr: 0x%x\n", addr);
306 memcpy(&(ar->
bmi.cmd_buf[offset]), &cid,
sizeof(cid));
307 offset +=
sizeof(
cid);
308 memcpy(&(ar->
bmi.cmd_buf[offset]), &addr,
sizeof(addr));
309 offset +=
sizeof(
addr);
311 ret = ath6kl_hif_bmi_write(ar, ar->
bmi.cmd_buf, offset);
313 ath6kl_err(
"Unable to write to the device: %d\n", ret);
327 if (ar->
bmi.done_sent) {
328 ath6kl_err(
"bmi done sent already, cmd %d disallowed\n", cid);
332 size =
sizeof(
cid) +
sizeof(addr);
333 if (size > ar->
bmi.max_cmd_size) {
339 ath6kl_dbg(
ATH6KL_DBG_BMI,
"bmi read SOC reg: addr: 0x%x\n", addr);
342 memcpy(&(ar->
bmi.cmd_buf[offset]), &cid,
sizeof(cid));
343 offset +=
sizeof(
cid);
344 memcpy(&(ar->
bmi.cmd_buf[offset]), &addr,
sizeof(addr));
345 offset +=
sizeof(
addr);
347 ret = ath6kl_hif_bmi_write(ar, ar->
bmi.cmd_buf, offset);
349 ath6kl_err(
"Unable to write to the device: %d\n", ret);
353 ret = ath6kl_hif_bmi_read(ar, ar->
bmi.cmd_buf,
sizeof(*param));
355 ath6kl_err(
"Unable to read from the device: %d\n", ret);
358 memcpy(param, ar->
bmi.cmd_buf,
sizeof(*param));
370 if (ar->
bmi.done_sent) {
371 ath6kl_err(
"bmi done sent already, cmd %d disallowed\n", cid);
375 size =
sizeof(
cid) +
sizeof(addr) +
sizeof(
param);
376 if (size > ar->
bmi.max_cmd_size) {
383 "bmi write SOC reg: addr: 0x%x, param: %d\n",
387 memcpy(&(ar->
bmi.cmd_buf[offset]), &cid,
sizeof(cid));
388 offset +=
sizeof(
cid);
389 memcpy(&(ar->
bmi.cmd_buf[offset]), &addr,
sizeof(addr));
390 offset +=
sizeof(
addr);
391 memcpy(&(ar->
bmi.cmd_buf[offset]), ¶m,
sizeof(param));
392 offset +=
sizeof(
param);
394 ret = ath6kl_hif_bmi_write(ar, ar->
bmi.cmd_buf, offset);
396 ath6kl_err(
"Unable to write to the device: %d\n", ret);
408 u32 len_remain, tx_len;
412 if (ar->
bmi.done_sent) {
413 ath6kl_err(
"bmi done sent already, cmd %d disallowed\n", cid);
417 size = ar->
bmi.max_data_size + header;
418 if (size > ar->
bmi.max_cmd_size) {
429 tx_len = (len_remain < (ar->
bmi.max_data_size - header)) ?
430 len_remain : (ar->
bmi.max_data_size - header);
433 memcpy(&(ar->
bmi.cmd_buf[offset]), &cid,
sizeof(cid));
434 offset +=
sizeof(
cid);
435 memcpy(&(ar->
bmi.cmd_buf[offset]), &tx_len,
sizeof(tx_len));
436 offset +=
sizeof(tx_len);
437 memcpy(&(ar->
bmi.cmd_buf[offset]), &buf[len - len_remain],
441 ret = ath6kl_hif_bmi_write(ar, ar->
bmi.cmd_buf, offset);
443 ath6kl_err(
"Unable to write to the device: %d\n",
448 len_remain -= tx_len;
461 if (ar->
bmi.done_sent) {
462 ath6kl_err(
"bmi done sent already, cmd %d disallowed\n", cid);
466 size =
sizeof(
cid) +
sizeof(addr);
467 if (size > ar->
bmi.max_cmd_size) {
474 "bmi LZ stream start: addr: 0x%x)\n",
478 memcpy(&(ar->
bmi.cmd_buf[offset]), &cid,
sizeof(cid));
479 offset +=
sizeof(
cid);
480 memcpy(&(ar->
bmi.cmd_buf[offset]), &addr,
sizeof(addr));
481 offset +=
sizeof(
addr);
483 ret = ath6kl_hif_bmi_write(ar, ar->
bmi.cmd_buf, offset);
485 ath6kl_err(
"Unable to start LZ stream to the device: %d\n",
497 u32 last_word_offset = len & ~0x3;
498 u32 unaligned_bytes = len & 0x3;
504 if (unaligned_bytes) {
506 memcpy(&last_word, &buf[last_word_offset], unaligned_bytes);
526 ar->
bmi.done_sent =
false;
535 ar->
bmi.max_cmd_size = ar->
bmi.max_data_size + (
sizeof(
u32) * 3);
538 if (!ar->
bmi.cmd_buf)