Lines Matching +full:offset +full:- +full:x
2 * Copyright (c) 2004-2011 Atheros Communications Inc.
3 * Copyright (c) 2011-2012 Qualcomm Atheros, Inc.
19 #include "hif-ops.h"
28 if (ar->bmi.done_sent) { in ath6kl_bmi_done()
33 ar->bmi.done_sent = true; in ath6kl_bmi_done()
50 if (ar->bmi.done_sent) { in ath6kl_bmi_get_target_info()
52 return -EACCES; in ath6kl_bmi_get_target_info()
61 if (ar->hif_type == ATH6KL_HIF_TYPE_USB) { in ath6kl_bmi_get_target_info()
65 ret = ath6kl_hif_bmi_read(ar, (u8 *)&targ_info->version, in ath6kl_bmi_get_target_info()
66 sizeof(targ_info->version)); in ath6kl_bmi_get_target_info()
74 if (le32_to_cpu(targ_info->version) == TARGET_VERSION_SENTINAL) { in ath6kl_bmi_get_target_info()
77 (u8 *)&targ_info->byte_count, in ath6kl_bmi_get_target_info()
78 sizeof(targ_info->byte_count)); in ath6kl_bmi_get_target_info()
89 if (le32_to_cpu(targ_info->byte_count) != sizeof(*targ_info)) { in ath6kl_bmi_get_target_info()
91 return -EINVAL; in ath6kl_bmi_get_target_info()
97 sizeof(targ_info->byte_count), in ath6kl_bmi_get_target_info()
98 sizeof(*targ_info) - in ath6kl_bmi_get_target_info()
99 sizeof(targ_info->byte_count)); in ath6kl_bmi_get_target_info()
103 targ_info->byte_count, ret); in ath6kl_bmi_get_target_info()
108 ath6kl_dbg(ATH6KL_DBG_BMI, "target info (ver: 0x%x type: 0x%x)\n", in ath6kl_bmi_get_target_info()
109 targ_info->version, targ_info->type); in ath6kl_bmi_get_target_info()
118 u32 offset; in ath6kl_bmi_read() local
122 if (ar->bmi.done_sent) { in ath6kl_bmi_read()
124 return -EACCES; in ath6kl_bmi_read()
127 size = ar->bmi.max_data_size + sizeof(cid) + sizeof(addr) + sizeof(len); in ath6kl_bmi_read()
128 if (size > ar->bmi.max_cmd_size) { in ath6kl_bmi_read()
130 return -EINVAL; in ath6kl_bmi_read()
132 memset(ar->bmi.cmd_buf, 0, size); in ath6kl_bmi_read()
135 "bmi read memory: device: addr: 0x%x, len: %d\n", in ath6kl_bmi_read()
141 rx_len = (len_remain < ar->bmi.max_data_size) ? in ath6kl_bmi_read()
142 len_remain : ar->bmi.max_data_size; in ath6kl_bmi_read()
143 offset = 0; in ath6kl_bmi_read()
144 memcpy(&(ar->bmi.cmd_buf[offset]), &cid, sizeof(cid)); in ath6kl_bmi_read()
145 offset += sizeof(cid); in ath6kl_bmi_read()
146 memcpy(&(ar->bmi.cmd_buf[offset]), &addr, sizeof(addr)); in ath6kl_bmi_read()
147 offset += sizeof(addr); in ath6kl_bmi_read()
148 memcpy(&(ar->bmi.cmd_buf[offset]), &rx_len, sizeof(rx_len)); in ath6kl_bmi_read()
149 offset += sizeof(len); in ath6kl_bmi_read()
151 ret = ath6kl_hif_bmi_write(ar, ar->bmi.cmd_buf, offset); in ath6kl_bmi_read()
157 ret = ath6kl_hif_bmi_read(ar, ar->bmi.cmd_buf, rx_len); in ath6kl_bmi_read()
163 memcpy(&buf[len - len_remain], ar->bmi.cmd_buf, rx_len); in ath6kl_bmi_read()
164 len_remain -= rx_len; addr += rx_len; in ath6kl_bmi_read()
174 u32 offset; in ath6kl_bmi_write() local
180 if (ar->bmi.done_sent) { in ath6kl_bmi_write()
182 return -EACCES; in ath6kl_bmi_write()
185 if ((ar->bmi.max_data_size + header) > ar->bmi.max_cmd_size) { in ath6kl_bmi_write()
187 return -EINVAL; in ath6kl_bmi_write()
190 if (WARN_ON(ar->bmi.max_data_size > sizeof(aligned_buf))) in ath6kl_bmi_write()
191 return -E2BIG; in ath6kl_bmi_write()
193 memset(ar->bmi.cmd_buf, 0, ar->bmi.max_data_size + header); in ath6kl_bmi_write()
196 "bmi write memory: addr: 0x%x, len: %d\n", addr, len); in ath6kl_bmi_write()
200 src = &buf[len - len_remain]; in ath6kl_bmi_write()
202 if (len_remain < (ar->bmi.max_data_size - header)) { in ath6kl_bmi_write()
206 (4 - (len_remain & 3)); in ath6kl_bmi_write()
212 tx_len = (ar->bmi.max_data_size - header); in ath6kl_bmi_write()
215 offset = 0; in ath6kl_bmi_write()
216 memcpy(&(ar->bmi.cmd_buf[offset]), &cid, sizeof(cid)); in ath6kl_bmi_write()
217 offset += sizeof(cid); in ath6kl_bmi_write()
218 memcpy(&(ar->bmi.cmd_buf[offset]), &addr, sizeof(addr)); in ath6kl_bmi_write()
219 offset += sizeof(addr); in ath6kl_bmi_write()
220 memcpy(&(ar->bmi.cmd_buf[offset]), &tx_len, sizeof(tx_len)); in ath6kl_bmi_write()
221 offset += sizeof(tx_len); in ath6kl_bmi_write()
222 memcpy(&(ar->bmi.cmd_buf[offset]), src, tx_len); in ath6kl_bmi_write()
223 offset += tx_len; in ath6kl_bmi_write()
225 ret = ath6kl_hif_bmi_write(ar, ar->bmi.cmd_buf, offset); in ath6kl_bmi_write()
231 len_remain -= tx_len; addr += tx_len; in ath6kl_bmi_write()
241 u32 offset; in ath6kl_bmi_execute() local
244 if (ar->bmi.done_sent) { in ath6kl_bmi_execute()
246 return -EACCES; in ath6kl_bmi_execute()
250 if (size > ar->bmi.max_cmd_size) { in ath6kl_bmi_execute()
252 return -EINVAL; in ath6kl_bmi_execute()
254 memset(ar->bmi.cmd_buf, 0, size); in ath6kl_bmi_execute()
256 ath6kl_dbg(ATH6KL_DBG_BMI, "bmi execute: addr: 0x%x, param: %d)\n", in ath6kl_bmi_execute()
259 offset = 0; in ath6kl_bmi_execute()
260 memcpy(&(ar->bmi.cmd_buf[offset]), &cid, sizeof(cid)); in ath6kl_bmi_execute()
261 offset += sizeof(cid); in ath6kl_bmi_execute()
262 memcpy(&(ar->bmi.cmd_buf[offset]), &addr, sizeof(addr)); in ath6kl_bmi_execute()
263 offset += sizeof(addr); in ath6kl_bmi_execute()
264 memcpy(&(ar->bmi.cmd_buf[offset]), param, sizeof(*param)); in ath6kl_bmi_execute()
265 offset += sizeof(*param); in ath6kl_bmi_execute()
267 ret = ath6kl_hif_bmi_write(ar, ar->bmi.cmd_buf, offset); in ath6kl_bmi_execute()
273 ret = ath6kl_hif_bmi_read(ar, ar->bmi.cmd_buf, sizeof(*param)); in ath6kl_bmi_execute()
279 memcpy(param, ar->bmi.cmd_buf, sizeof(*param)); in ath6kl_bmi_execute()
288 u32 offset; in ath6kl_bmi_set_app_start() local
291 if (ar->bmi.done_sent) { in ath6kl_bmi_set_app_start()
293 return -EACCES; in ath6kl_bmi_set_app_start()
297 if (size > ar->bmi.max_cmd_size) { in ath6kl_bmi_set_app_start()
299 return -EINVAL; in ath6kl_bmi_set_app_start()
301 memset(ar->bmi.cmd_buf, 0, size); in ath6kl_bmi_set_app_start()
303 ath6kl_dbg(ATH6KL_DBG_BMI, "bmi set app start: addr: 0x%x\n", addr); in ath6kl_bmi_set_app_start()
305 offset = 0; in ath6kl_bmi_set_app_start()
306 memcpy(&(ar->bmi.cmd_buf[offset]), &cid, sizeof(cid)); in ath6kl_bmi_set_app_start()
307 offset += sizeof(cid); in ath6kl_bmi_set_app_start()
308 memcpy(&(ar->bmi.cmd_buf[offset]), &addr, sizeof(addr)); in ath6kl_bmi_set_app_start()
309 offset += sizeof(addr); in ath6kl_bmi_set_app_start()
311 ret = ath6kl_hif_bmi_write(ar, ar->bmi.cmd_buf, offset); in ath6kl_bmi_set_app_start()
324 u32 offset; in ath6kl_bmi_reg_read() local
327 if (ar->bmi.done_sent) { in ath6kl_bmi_reg_read()
329 return -EACCES; in ath6kl_bmi_reg_read()
333 if (size > ar->bmi.max_cmd_size) { in ath6kl_bmi_reg_read()
335 return -EINVAL; in ath6kl_bmi_reg_read()
337 memset(ar->bmi.cmd_buf, 0, size); in ath6kl_bmi_reg_read()
339 ath6kl_dbg(ATH6KL_DBG_BMI, "bmi read SOC reg: addr: 0x%x\n", addr); in ath6kl_bmi_reg_read()
341 offset = 0; in ath6kl_bmi_reg_read()
342 memcpy(&(ar->bmi.cmd_buf[offset]), &cid, sizeof(cid)); in ath6kl_bmi_reg_read()
343 offset += sizeof(cid); in ath6kl_bmi_reg_read()
344 memcpy(&(ar->bmi.cmd_buf[offset]), &addr, sizeof(addr)); in ath6kl_bmi_reg_read()
345 offset += sizeof(addr); in ath6kl_bmi_reg_read()
347 ret = ath6kl_hif_bmi_write(ar, ar->bmi.cmd_buf, offset); in ath6kl_bmi_reg_read()
353 ret = ath6kl_hif_bmi_read(ar, ar->bmi.cmd_buf, sizeof(*param)); in ath6kl_bmi_reg_read()
358 memcpy(param, ar->bmi.cmd_buf, sizeof(*param)); in ath6kl_bmi_reg_read()
367 u32 offset; in ath6kl_bmi_reg_write() local
370 if (ar->bmi.done_sent) { in ath6kl_bmi_reg_write()
372 return -EACCES; in ath6kl_bmi_reg_write()
376 if (size > ar->bmi.max_cmd_size) { in ath6kl_bmi_reg_write()
378 return -EINVAL; in ath6kl_bmi_reg_write()
380 memset(ar->bmi.cmd_buf, 0, size); in ath6kl_bmi_reg_write()
383 "bmi write SOC reg: addr: 0x%x, param: %d\n", in ath6kl_bmi_reg_write()
386 offset = 0; in ath6kl_bmi_reg_write()
387 memcpy(&(ar->bmi.cmd_buf[offset]), &cid, sizeof(cid)); in ath6kl_bmi_reg_write()
388 offset += sizeof(cid); in ath6kl_bmi_reg_write()
389 memcpy(&(ar->bmi.cmd_buf[offset]), &addr, sizeof(addr)); in ath6kl_bmi_reg_write()
390 offset += sizeof(addr); in ath6kl_bmi_reg_write()
391 memcpy(&(ar->bmi.cmd_buf[offset]), ¶m, sizeof(param)); in ath6kl_bmi_reg_write()
392 offset += sizeof(param); in ath6kl_bmi_reg_write()
394 ret = ath6kl_hif_bmi_write(ar, ar->bmi.cmd_buf, offset); in ath6kl_bmi_reg_write()
407 u32 offset; in ath6kl_bmi_lz_data() local
412 if (ar->bmi.done_sent) { in ath6kl_bmi_lz_data()
414 return -EACCES; in ath6kl_bmi_lz_data()
417 size = ar->bmi.max_data_size + header; in ath6kl_bmi_lz_data()
418 if (size > ar->bmi.max_cmd_size) { in ath6kl_bmi_lz_data()
420 return -EINVAL; in ath6kl_bmi_lz_data()
422 memset(ar->bmi.cmd_buf, 0, size); in ath6kl_bmi_lz_data()
429 tx_len = (len_remain < (ar->bmi.max_data_size - header)) ? in ath6kl_bmi_lz_data()
430 len_remain : (ar->bmi.max_data_size - header); in ath6kl_bmi_lz_data()
432 offset = 0; in ath6kl_bmi_lz_data()
433 memcpy(&(ar->bmi.cmd_buf[offset]), &cid, sizeof(cid)); in ath6kl_bmi_lz_data()
434 offset += sizeof(cid); in ath6kl_bmi_lz_data()
435 memcpy(&(ar->bmi.cmd_buf[offset]), &tx_len, sizeof(tx_len)); in ath6kl_bmi_lz_data()
436 offset += sizeof(tx_len); in ath6kl_bmi_lz_data()
437 memcpy(&(ar->bmi.cmd_buf[offset]), &buf[len - len_remain], in ath6kl_bmi_lz_data()
439 offset += tx_len; in ath6kl_bmi_lz_data()
441 ret = ath6kl_hif_bmi_write(ar, ar->bmi.cmd_buf, offset); in ath6kl_bmi_lz_data()
448 len_remain -= tx_len; in ath6kl_bmi_lz_data()
458 u32 offset; in ath6kl_bmi_lz_stream_start() local
461 if (ar->bmi.done_sent) { in ath6kl_bmi_lz_stream_start()
463 return -EACCES; in ath6kl_bmi_lz_stream_start()
467 if (size > ar->bmi.max_cmd_size) { in ath6kl_bmi_lz_stream_start()
469 return -EINVAL; in ath6kl_bmi_lz_stream_start()
471 memset(ar->bmi.cmd_buf, 0, size); in ath6kl_bmi_lz_stream_start()
474 "bmi LZ stream start: addr: 0x%x)\n", in ath6kl_bmi_lz_stream_start()
477 offset = 0; in ath6kl_bmi_lz_stream_start()
478 memcpy(&(ar->bmi.cmd_buf[offset]), &cid, sizeof(cid)); in ath6kl_bmi_lz_stream_start()
479 offset += sizeof(cid); in ath6kl_bmi_lz_stream_start()
480 memcpy(&(ar->bmi.cmd_buf[offset]), &addr, sizeof(addr)); in ath6kl_bmi_lz_stream_start()
481 offset += sizeof(addr); in ath6kl_bmi_lz_stream_start()
483 ret = ath6kl_hif_bmi_write(ar, ar->bmi.cmd_buf, offset); in ath6kl_bmi_lz_stream_start()
526 ar->bmi.done_sent = false; in ath6kl_bmi_reset()
531 if (WARN_ON(ar->bmi.max_data_size == 0)) in ath6kl_bmi_init()
532 return -EINVAL; in ath6kl_bmi_init()
535 ar->bmi.max_cmd_size = ar->bmi.max_data_size + (sizeof(u32) * 3); in ath6kl_bmi_init()
537 ar->bmi.cmd_buf = kzalloc(ar->bmi.max_cmd_size, GFP_KERNEL); in ath6kl_bmi_init()
538 if (!ar->bmi.cmd_buf) in ath6kl_bmi_init()
539 return -ENOMEM; in ath6kl_bmi_init()
546 kfree(ar->bmi.cmd_buf); in ath6kl_bmi_cleanup()
547 ar->bmi.cmd_buf = NULL; in ath6kl_bmi_cleanup()