Commit addb44be authored by Kalle Valo's avatar Kalle Valo

ath6kl: cleanup diagnose window read and write functions

Just to make them a bit easier to read and unify naming. 32 suffix
in the function name means that it will be a 32 bit transfer. If there's
no number a buffer is transfered instead.

Use void pointers to get rid of ugly casts.

Don't provide target address as a pointer, pass it by value. Same for
the value used in write32().
Signed-off-by: default avatarKalle Valo <kvalo@qca.qualcomm.com>
parent 939f1cce
...@@ -507,9 +507,9 @@ enum htc_send_full_action ath6kl_tx_queue_full(struct htc_target *target, ...@@ -507,9 +507,9 @@ enum htc_send_full_action ath6kl_tx_queue_full(struct htc_target *target,
struct htc_packet *packet); struct htc_packet *packet);
void ath6kl_stop_txrx(struct ath6kl *ar); void ath6kl_stop_txrx(struct ath6kl *ar);
void ath6kl_cleanup_amsdu_rxbufs(struct ath6kl *ar); void ath6kl_cleanup_amsdu_rxbufs(struct ath6kl *ar);
int ath6kl_access_datadiag(struct ath6kl *ar, u32 address, int ath6kl_diag_write(struct ath6kl *ar, u32 address, void *data, u32 length);
u8 *data, u32 length, bool read); int ath6kl_diag_read32(struct ath6kl *ar, u32 address, u32 *value);
int ath6kl_read_reg_diag(struct ath6kl *ar, u32 *address, u32 *data); int ath6kl_diag_read(struct ath6kl *ar, u32 address, void *data, u32 length);
void ath6kl_init_profile_info(struct ath6kl *ar); void ath6kl_init_profile_info(struct ath6kl *ar);
void ath6kl_tx_data_cleanup(struct ath6kl *ar); void ath6kl_tx_data_cleanup(struct ath6kl *ar);
void ath6kl_stop_endpoint(struct net_device *dev, bool keep_profile, void ath6kl_stop_endpoint(struct net_device *dev, bool keep_profile,
......
...@@ -133,14 +133,13 @@ static int ath6kl_set_host_app_area(struct ath6kl *ar) ...@@ -133,14 +133,13 @@ static int ath6kl_set_host_app_area(struct ath6kl *ar)
address = ath6kl_get_hi_item_addr(ar, HI_ITEM(hi_app_host_interest)); address = ath6kl_get_hi_item_addr(ar, HI_ITEM(hi_app_host_interest));
address = TARG_VTOP(ar->target_type, address); address = TARG_VTOP(ar->target_type, address);
if (ath6kl_read_reg_diag(ar, &address, &data)) if (ath6kl_diag_read32(ar, address, &data))
return -EIO; return -EIO;
address = TARG_VTOP(ar->target_type, data); address = TARG_VTOP(ar->target_type, data);
host_app_area.wmi_protocol_ver = WMI_PROTOCOL_VERSION; host_app_area.wmi_protocol_ver = WMI_PROTOCOL_VERSION;
if (ath6kl_access_datadiag(ar, address, if (ath6kl_diag_write(ar, address, (u8 *) &host_app_area,
(u8 *)&host_app_area, sizeof(struct host_app_area)))
sizeof(struct host_app_area), false))
return -EIO; return -EIO;
return 0; return 0;
...@@ -377,7 +376,7 @@ static void ath6kl_dump_target_assert_info(struct ath6kl *ar) ...@@ -377,7 +376,7 @@ static void ath6kl_dump_target_assert_info(struct ath6kl *ar)
address = TARG_VTOP(ar->target_type, address); address = TARG_VTOP(ar->target_type, address);
/* read RAM location through diagnostic window */ /* read RAM location through diagnostic window */
status = ath6kl_read_reg_diag(ar, &address, &regdump_loc); status = ath6kl_diag_read32(ar, address, &regdump_loc);
if (status || !regdump_loc) { if (status || !regdump_loc) {
ath6kl_err("failed to get ptr to register dump area\n"); ath6kl_err("failed to get ptr to register dump area\n");
...@@ -389,11 +388,8 @@ static void ath6kl_dump_target_assert_info(struct ath6kl *ar) ...@@ -389,11 +388,8 @@ static void ath6kl_dump_target_assert_info(struct ath6kl *ar)
regdump_loc = TARG_VTOP(ar->target_type, regdump_loc); regdump_loc = TARG_VTOP(ar->target_type, regdump_loc);
/* fetch register dump data */ /* fetch register dump data */
status = ath6kl_access_datadiag(ar, status = ath6kl_diag_read(ar, regdump_loc, (u8 *)&regdump_val[0],
regdump_loc, REG_DUMP_COUNT_AR6003 * (sizeof(u32)));
(u8 *)&regdump_val[0],
REG_DUMP_COUNT_AR6003 * (sizeof(u32)),
true);
if (status) { if (status) {
ath6kl_err("failed to get register dump\n"); ath6kl_err("failed to get register dump\n");
......
...@@ -229,74 +229,84 @@ static int ath6kl_set_addrwin_reg(struct ath6kl *ar, u32 reg_addr, u32 addr) ...@@ -229,74 +229,84 @@ static int ath6kl_set_addrwin_reg(struct ath6kl *ar, u32 reg_addr, u32 addr)
} }
/* /*
* Read from the ATH6KL through its diagnostic window. No cooperation from * Read from the hardware through its diagnostic window. No cooperation
* the Target is required for this. * from the firmware is required for this.
*/ */
int ath6kl_read_reg_diag(struct ath6kl *ar, u32 *address, u32 *data) int ath6kl_diag_read32(struct ath6kl *ar, u32 address, u32 *value)
{ {
int status; int ret;
/* set window register to start read cycle */ /* set window register to start read cycle */
status = ath6kl_set_addrwin_reg(ar, WINDOW_READ_ADDR_ADDRESS, ret = ath6kl_set_addrwin_reg(ar, WINDOW_READ_ADDR_ADDRESS, address);
*address); if (ret)
return ret;
if (status)
return status;
/* read the data */ /* read the data */
status = hif_read_write_sync(ar, WINDOW_DATA_ADDRESS, (u8 *)data, ret = hif_read_write_sync(ar, WINDOW_DATA_ADDRESS, (u8 *) value,
sizeof(u32), HIF_RD_SYNC_BYTE_INC); sizeof(*value), HIF_RD_SYNC_BYTE_INC);
if (status) { if (ret) {
ath6kl_err("failed to read from window data addr\n"); ath6kl_warn("failed to read32 through diagnose window: %d\n",
return status; ret);
return ret;
} }
return status; return 0;
} }
/* /*
* Write to the ATH6KL through its diagnostic window. No cooperation from * Write to the ATH6KL through its diagnostic window. No cooperation from
* the Target is required for this. * the Target is required for this.
*/ */
static int ath6kl_write_reg_diag(struct ath6kl *ar, u32 *address, u32 *data) static int ath6kl_diag_write32(struct ath6kl *ar, u32 address, u32 value)
{ {
int status; int ret;
/* set write data */ /* set write data */
status = hif_read_write_sync(ar, WINDOW_DATA_ADDRESS, (u8 *)data, ret = hif_read_write_sync(ar, WINDOW_DATA_ADDRESS, (u8 *) &value,
sizeof(u32), HIF_WR_SYNC_BYTE_INC); sizeof(value), HIF_WR_SYNC_BYTE_INC);
if (status) { if (ret) {
ath6kl_err("failed to write 0x%x to window data addr\n", *data); ath6kl_err("failed to write 0x%x during diagnose window to 0x%d\n",
return status; address, value);
return ret;
} }
/* set window register, which starts the write cycle */ /* set window register, which starts the write cycle */
return ath6kl_set_addrwin_reg(ar, WINDOW_WRITE_ADDR_ADDRESS, return ath6kl_set_addrwin_reg(ar, WINDOW_WRITE_ADDR_ADDRESS,
*address); address);
} }
int ath6kl_access_datadiag(struct ath6kl *ar, u32 address, int ath6kl_diag_read(struct ath6kl *ar, u32 address, void *data, u32 length)
u8 *data, u32 length, bool read)
{ {
u32 count; u32 count, *buf = data;
int status = 0; int ret;
for (count = 0; count < length; count += 4, address += 4) { if (WARN_ON(length % 4))
if (read) { return -EINVAL;
status = ath6kl_read_reg_diag(ar, &address,
(u32 *) &data[count]); for (count = 0; count < length / 4; count++, address += 4) {
if (status) ret = ath6kl_diag_read32(ar, address, &buf[count]);
break; if (ret)
} else { return ret;
status = ath6kl_write_reg_diag(ar, &address,
(u32 *) &data[count]);
if (status)
break;
} }
return 0;
}
int ath6kl_diag_write(struct ath6kl *ar, u32 address, void *data, u32 length)
{
u32 count, *buf = data;
int ret;
if (WARN_ON(length % 4))
return -EINVAL;
for (count = 0; count < length / 4; count++, address += 4) {
ret = ath6kl_diag_write32(ar, address, buf[count]);
if (ret)
return ret;
} }
return status; return 0;
} }
/* FIXME: move to a better place, target.h? */ /* FIXME: move to a better place, target.h? */
...@@ -328,7 +338,7 @@ static void ath6kl_reset_device(struct ath6kl *ar, u32 target_type, ...@@ -328,7 +338,7 @@ static void ath6kl_reset_device(struct ath6kl *ar, u32 target_type,
break; break;
} }
status = ath6kl_write_reg_diag(ar, &address, &data); status = ath6kl_diag_write32(ar, address, data);
if (status) if (status)
ath6kl_err("failed to reset target\n"); ath6kl_err("failed to reset target\n");
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment