ath6kl: ar6004 sdio support
cover ath6kl: ar6004 sdio support
This patchset adds support for ar6004 sdio and also beginning of ar6004 usb support.
---
Kalle Valo (9):
ath6kl: move bmi calls to hif driver
ath6kl: change bmi sizes being configurable by HIF
ath6kl: move diag commands to hif driver
ath6kl: update ar6004 definitions
ath6kl: firmware boot fixes for ar6004
ath6kl: add hif_type
ath6kl: add USB support
ath6kl: disable HTC for USB devices
ath6kl: enable USB support
Naveen Gangadharan (1):
ath6kl: AR6004 SDIO support
drivers/net/wireless/ath/ath6kl/Kconfig | 25 +- drivers/net/wireless/ath/ath6kl/Makefile | 37 ++ drivers/net/wireless/ath/ath6kl/bmi.c | 245 +++------------- drivers/net/wireless/ath/ath6kl/bmi.h | 6 drivers/net/wireless/ath/ath6kl/core.h | 26 +- drivers/net/wireless/ath/ath6kl/debug.h | 1 drivers/net/wireless/ath/ath6kl/hif-ops.h | 30 ++ drivers/net/wireless/ath/ath6kl/hif.c | 5 drivers/net/wireless/ath/ath6kl/hif.h | 5 drivers/net/wireless/ath/ath6kl/htc.c | 10 + drivers/net/wireless/ath/ath6kl/init.c | 34 ++ drivers/net/wireless/ath/ath6kl/main.c | 76 ----- drivers/net/wireless/ath/ath6kl/sdio.c | 268 ++++++++++++++++++ drivers/net/wireless/ath/ath6kl/target.h | 9 - drivers/net/wireless/ath/ath6kl/usb.c | 431 +++++++++++++++++++++++++++++ 15 files changed, 899 insertions(+), 309 deletions(-) create mode 100644 drivers/net/wireless/ath/ath6kl/usb.c
PATCH 1/10 ath6kl: move bmi calls to hif driver
In preparation for USB support which has it's own method for bmi.
Based on code by Kevin Fang.
--- drivers/net/wireless/ath/ath6kl/bmi.c | 191 ++--------------------------- drivers/net/wireless/ath/ath6kl/hif-ops.h | 10 ++ drivers/net/wireless/ath/ath6kl/hif.h | 2 drivers/net/wireless/ath/ath6kl/sdio.c | 162 +++++++++++++++++++++++++ 4 files changed, 190 insertions(+), 175 deletions(-)
drivers/net/wireless/ath/ath6kl/bmi.c +16 -175
@@ -19,165 +19,6 @@#include "target.h" #include "debug.h" -static int ath6kl_get_bmi_cmd_credits (struct ath6kl *ar) -{ -u32 addr; -unsigned long timeout; -int ret; - - ar->bmi.cmd_credits =0 ; - -/* Read the counter register to get the command credits */ - addr =COUNT_DEC_ADDRESS + (HTC_MAILBOX_NUM_MAX +ENDPOINT1 ) *4 ; - - timeout = jiffies +msecs_to_jiffies (BMI_COMMUNICATION_TIMEOUT ); -while (time_before (jiffies, timeout) && !ar->bmi.cmd_credits) { - -/* -* Hit the credit counter with a 4-byte access, the first byte -* read will hit the counter and cause a decrement, while the -* remaining 3 bytes has no effect. The rationale behind this -* is to make all HIF accesses 4-byte aligned. -*/ - ret =hif_read_write_sync (ar, addr, - (u8 *)&ar->bmi.cmd_credits,4 , -HIF_RD_SYNC_BYTE_INC ); -if (ret) { -ath6kl_err ("Unable to decrement the command credit count register: %d\n" , - ret); -return ret; - } - -/* The counter is only 8 bits. -* Ignore anything in the upper 3 bytes -*/ - ar->bmi.cmd_credits &=0xFF ; - } - -if (!ar->bmi.cmd_credits) { -ath6kl_err ("bmi communication timeout\n" ); -return -ETIMEDOUT ; - } - -return 0 ; -} - -static int ath6kl_bmi_get_rx_lkahd (struct ath6kl *ar) -{ -unsigned long timeout; -u32 rx_word =0 ; -int ret =0 ; - - timeout = jiffies +msecs_to_jiffies (BMI_COMMUNICATION_TIMEOUT ); -while (time_before (jiffies, timeout) && !rx_word) { - ret =hif_read_write_sync (ar,RX_LOOKAHEAD_VALID_ADDRESS , - (u8 *)&rx_word,sizeof (rx_word), -HIF_RD_SYNC_BYTE_INC ); -if (ret) { -ath6kl_err ("unable to read RX_LOOKAHEAD_VALID\n" ); -return ret; - } - -/* all we really want is one bit */ - rx_word &= (1 <<ENDPOINT1 ); - } - -if (!rx_word) { -ath6kl_err ("bmi_recv_buf FIFO empty\n" ); -return -EINVAL ; - } - -return ret; -} - -static int ath6kl_bmi_send_buf (struct ath6kl *ar,u8 *buf,u32 len) -{ -int ret; -u32 addr; - - ret =ath6kl_get_bmi_cmd_credits (ar); -if (ret) -return ret; - - addr = ar->mbox_info.htc_addr; - - ret =hif_read_write_sync (ar, addr, buf, len, -HIF_WR_SYNC_BYTE_INC ); -if (ret) -ath6kl_err ("unable to send the bmi data to the device\n" ); - -return ret; -} - -static int ath6kl_bmi_recv_buf (struct ath6kl *ar,u8 *buf,u32 len) -{ -int ret; -u32 addr; - -/* -* During normal bootup, small reads may be required. -* Rather than issue an HIF Read and then wait as the Target -* adds successive bytes to the FIFO, we wait here until -* we know that response data is available. -* -* This allows us to cleanly timeout on an unexpected -* Target failure rather than risk problems at the HIF level. -* In particular, this avoids SDIO timeouts and possibly garbage -* data on some host controllers. And on an interconnect -* such as Compact Flash (as well as some SDIO masters) which -* does not provide any indication on data timeout, it avoids -* a potential hang or garbage response. -* -* Synchronization is more difficult for reads larger than the -* size of the MBOX FIFO (128B), because the Target is unable -* to push the 129th byte of data until AFTER the Host posts an -* HIF Read and removes some FIFO data. So for large reads the -* Host proceeds to post an HIF Read BEFORE all the data is -* actually available to read. Fortunately, large BMI reads do -* not occur in practice -- they're supported for debug/development. -* -* So Host/Target BMI synchronization is divided into these cases: -* CASE 1: length < 4 -* Should not happen -* -* CASE 2: 4 <= length <= 128 -* Wait for first 4 bytes to be in FIFO -* If CONSERVATIVE_BMI_READ is enabled, also wait for -* a BMI command credit, which indicates that the ENTIRE -* response is available in the the FIFO -* -* CASE 3: length > 128 -* Wait for the first 4 bytes to be in FIFO -* -* For most uses, a small timeout should be sufficient and we will -* usually see a response quickly; but there may be some unusual -* (debug) cases of BMI_EXECUTE where we want an larger timeout. -* For now, we use an unbounded busy loop while waiting for -* BMI_EXECUTE. -* -* If BMI_EXECUTE ever needs to support longer-latency execution, -* especially in production, this code needs to be enhanced to sleep -* and yield. Also note that BMI_COMMUNICATION_TIMEOUT is currently -* a function of Host processor speed. -*/ -if (len >=4 ) {/* NB: Currently, always true */ - ret =ath6kl_bmi_get_rx_lkahd (ar); -if (ret) -return ret; - } - - addr = ar->mbox_info.htc_addr; - ret =hif_read_write_sync (ar, addr, buf, len, -HIF_RD_SYNC_BYTE_INC ); -if (ret) { -ath6kl_err ("Unable to read the bmi data from the device: %d\n" , - ret); -return ret; - } - -return 0 ; -} -int ath6kl_bmi_done (struct ath6kl *ar) {int ret;
@@ -190,7 +31,7 @@ int ath6kl_bmi_done(struct ath6kl *ar) ar->bmi.done_sent = true; - ret =ath6kl_bmi_send_buf (ar, (u8 *)&cid,sizeof (cid)); + ret =ath6kl_hif_bmi_write (ar, (u8 *)&cid,sizeof (cid));if (ret) {ath6kl_err ("Unable to send bmi done: %d\n" , ret);return ret;
@@ -210,13 +51,13 @@ int ath6kl_bmi_get_target_info(struct ath6kl *ar,return -EACCES ; } - ret =ath6kl_bmi_send_buf (ar, (u8 *)&cid,sizeof (cid)); + ret =ath6kl_hif_bmi_write (ar, (u8 *)&cid,sizeof (cid));if (ret) {ath6kl_err ("Unable to send get target info: %d\n" , ret);return ret; } - ret =ath6kl_bmi_recv_buf (ar, (u8 *)&targ_info->version, + ret =ath6kl_hif_bmi_read (ar, (u8 *)&targ_info->version,sizeof (targ_info->version));if (ret) {ath6kl_err ("Unable to recv target info: %d\n" , ret);
@@ -225,7 +66,7 @@ int ath6kl_bmi_get_target_info(struct ath6kl *ar,if (le32_to_cpu (targ_info->version) ==TARGET_VERSION_SENTINAL ) {/* Determine how many bytes are in the Target's targ_info */ - ret =ath6kl_bmi_recv_buf (ar, + ret =ath6kl_hif_bmi_read (ar, (u8 *)&targ_info->byte_count,sizeof (targ_info->byte_count));if (ret) {
@@ -244,7 +85,7 @@ int ath6kl_bmi_get_target_info(struct ath6kl *ar, }/* Read the remainder of the targ_info */ - ret = ath6kl_bmi_recv_buf(ar, + ret = ath6kl_hif_bmi_read(ar, ((u8 *)targ_info) + sizeof(targ_info->byte_count), sizeof(*targ_info) -
@@ -300,13 +141,13 @@ int ath6kl_bmi_read(struct ath6kl *ar, u32 addr, u8 *buf, u32 len)memcpy (&(ar->bmi.cmd_buf[offset]), &rx_len,sizeof (rx_len)); offset +=sizeof (len); - ret =ath6kl_bmi_send_buf (ar, ar->bmi.cmd_buf, offset); + ret =ath6kl_hif_bmi_write (ar, ar->bmi.cmd_buf, offset);if (ret) {ath6kl_err ("Unable to write to the device: %d\n" , ret);return ret; } - ret =ath6kl_bmi_recv_buf (ar, ar->bmi.cmd_buf, rx_len); + ret =ath6kl_hif_bmi_read (ar, ar->bmi.cmd_buf, rx_len);if (ret) {ath6kl_err ("Unable to read from the device: %d\n" , ret);
@@ -371,7 +212,7 @@ int ath6kl_bmi_write(struct ath6kl *ar, u32 addr, u8 *buf, u32 len)memcpy (&(ar->bmi.cmd_buf[offset]), src, tx_len); offset += tx_len; - ret =ath6kl_bmi_send_buf (ar, ar->bmi.cmd_buf, offset); + ret =ath6kl_hif_bmi_write (ar, ar->bmi.cmd_buf, offset);if (ret) {ath6kl_err ("Unable to write to the device: %d\n" , ret);
@@ -413,13 +254,13 @@ int ath6kl_bmi_execute(struct ath6kl *ar, u32 addr, u32 *param)memcpy (&(ar->bmi.cmd_buf[offset]), param,sizeof (*param)); offset +=sizeof (*param); - ret =ath6kl_bmi_send_buf (ar, ar->bmi.cmd_buf, offset); + ret =ath6kl_hif_bmi_write (ar, ar->bmi.cmd_buf, offset);if (ret) {ath6kl_err ("Unable to write to the device: %d\n" , ret);return ret; } - ret =ath6kl_bmi_recv_buf (ar, ar->bmi.cmd_buf,sizeof (*param)); + ret =ath6kl_hif_bmi_read (ar, ar->bmi.cmd_buf,sizeof (*param));if (ret) {ath6kl_err ("Unable to read from the device: %d\n" , ret);return ret;
@@ -457,7 +298,7 @@ int ath6kl_bmi_set_app_start(struct ath6kl *ar, u32 addr)memcpy (&(ar->bmi.cmd_buf[offset]), &addr,sizeof (addr)); offset +=sizeof (addr); - ret =ath6kl_bmi_send_buf (ar, ar->bmi.cmd_buf, offset); + ret =ath6kl_hif_bmi_write (ar, ar->bmi.cmd_buf, offset);if (ret) {ath6kl_err ("Unable to write to the device: %d\n" , ret);return ret;
@@ -493,13 +334,13 @@ int ath6kl_bmi_reg_read(struct ath6kl *ar, u32 addr, u32 *param)memcpy (&(ar->bmi.cmd_buf[offset]), &addr,sizeof (addr)); offset +=sizeof (addr); - ret =ath6kl_bmi_send_buf (ar, ar->bmi.cmd_buf, offset); + ret =ath6kl_hif_bmi_write (ar, ar->bmi.cmd_buf, offset);if (ret) {ath6kl_err ("Unable to write to the device: %d\n" , ret);return ret; } - ret =ath6kl_bmi_recv_buf (ar, ar->bmi.cmd_buf,sizeof (*param)); + ret =ath6kl_hif_bmi_read (ar, ar->bmi.cmd_buf,sizeof (*param));if (ret) {ath6kl_err ("Unable to read from the device: %d\n" , ret);return ret;
@@ -540,7 +381,7 @@ int ath6kl_bmi_reg_write(struct ath6kl *ar, u32 addr, u32 param)memcpy (&(ar->bmi.cmd_buf[offset]), ¶m,sizeof (param)); offset +=sizeof (param); - ret =ath6kl_bmi_send_buf (ar, ar->bmi.cmd_buf, offset); + ret =ath6kl_hif_bmi_write (ar, ar->bmi.cmd_buf, offset);if (ret) {ath6kl_err ("Unable to write to the device: %d\n" , ret);return ret;
@@ -587,7 +428,7 @@ int ath6kl_bmi_lz_data(struct ath6kl *ar, u8 *buf, u32 len) tx_len); offset += tx_len; - ret =ath6kl_bmi_send_buf (ar, ar->bmi.cmd_buf, offset); + ret =ath6kl_hif_bmi_write (ar, ar->bmi.cmd_buf, offset);if (ret) {ath6kl_err ("Unable to write to the device: %d\n" , ret);
@@ -629,7 +470,7 @@ int ath6kl_bmi_lz_stream_start(struct ath6kl *ar, u32 addr)memcpy (&(ar->bmi.cmd_buf[offset]), &addr,sizeof (addr)); offset +=sizeof (addr); - ret =ath6kl_bmi_send_buf (ar, ar->bmi.cmd_buf, offset); + ret =ath6kl_hif_bmi_write (ar, ar->bmi.cmd_buf, offset);if (ret) {ath6kl_err ("Unable to start LZ stream to the device: %d\n" , ret);
drivers/net/wireless/ath/ath6kl/hif-ops.h +10 -0
@@ -91,6 +91,16 @@ static inline int ath6kl_hif_suspend(struct ath6kl *ar,return ar->hif_ops->suspend (ar, wow); } +static inline int ath6kl_hif_bmi_read (struct ath6kl *ar,u8 *buf,u32 len) +{ +return ar->hif_ops->bmi_read (ar, buf, len); +} + +static inline int ath6kl_hif_bmi_write (struct ath6kl *ar,u8 *buf,u32 len) +{ +return ar->hif_ops->bmi_write (ar, buf, len); +} +static inline int ath6kl_hif_resume (struct ath6kl *ar) {ath6kl_dbg (ATH6KL_DBG_HIF ,"hif resume\n" );
drivers/net/wireless/ath/ath6kl/hif.h +2 -0
@@ -244,6 +244,8 @@ struct ath6kl_hif_ops {void (*cleanup_scatter)(struct ath6kl *ar);int (*suspend)(struct ath6kl *ar,struct cfg80211_wowlan *wow);int (*resume)(struct ath6kl *ar); +int (*bmi_read)(struct ath6kl *ar,u8 *buf,u32 len); +int (*bmi_write)(struct ath6kl *ar,u8 *buf,u32 len);int (*power_on)(struct ath6kl *ar);int (*power_off)(struct ath6kl *ar);void (*stop)(struct ath6kl *ar);
drivers/net/wireless/ath/ath6kl/sdio.c +162 -0
174 lines not on this page · raw message
PATCH 2/10 ath6kl: change bmi sizes being configurable by HIF
In reply to Kalle ValoSDIO and USB have different maximum sizes for BMI commands so make that configurable.
--- drivers/net/wireless/ath/ath6kl/bmi.c | 46 +++++++++++++++++++------------- drivers/net/wireless/ath/ath6kl/bmi.h | 6 ---- drivers/net/wireless/ath/ath6kl/core.h | 2 + drivers/net/wireless/ath/ath6kl/sdio.c | 1 + 4 files changed, 30 insertions(+), 25 deletions(-)
drivers/net/wireless/ath/ath6kl/bmi.c +27 -19
@@ -117,8 +117,8 @@ int ath6kl_bmi_read(struct ath6kl *ar, u32 addr, u8 *buf, u32 len)return -EACCES ; } - size =BMI_DATASZ_MAX +sizeof (cid) +sizeof (addr) +sizeof (len); -if (size >MAX_BMI_CMDBUF_SZ ) { + size = ar->bmi.max_data_size +sizeof (cid) +sizeof (addr) +sizeof (len); +if (size > ar->bmi.max_cmd_size) {WARN_ON (1 );return -EINVAL ; }
@@ -131,8 +131,8 @@ int ath6kl_bmi_read(struct ath6kl *ar, u32 addr, u8 *buf, u32 len) len_remain = len;while (len_remain) { - rx_len = (len_remain <BMI_DATASZ_MAX ) ? - len_remain :BMI_DATASZ_MAX ; + rx_len = (len_remain < ar->bmi.max_data_size) ? + len_remain : ar->bmi.max_data_size; offset =0 ;memcpy (&(ar->bmi.cmd_buf[offset]), &cid,sizeof (cid)); offset +=sizeof (cid);
@@ -167,7 +167,7 @@ int ath6kl_bmi_write(struct ath6kl *ar, u32 addr, u8 *buf, u32 len)u32 offset;u32 len_remain, tx_len;const u32 header =sizeof (cid) +sizeof (addr) +sizeof (len); -u8 aligned_buf[BMI_DATASZ_MAX ]; +u8 aligned_buf[400 ];u8 *src;if (ar->bmi.done_sent) {
@@ -175,12 +175,15 @@ int ath6kl_bmi_write(struct ath6kl *ar, u32 addr, u8 *buf, u32 len)return -EACCES ; } -if ((BMI_DATASZ_MAX + header) >MAX_BMI_CMDBUF_SZ ) { +if ((ar->bmi.max_data_size + header) > ar->bmi.max_cmd_size) {WARN_ON (1 );return -EINVAL ; } -memset (ar->bmi.cmd_buf,0 ,BMI_DATASZ_MAX + header); +if (WARN_ON (ar->bmi.max_data_size >sizeof (aligned_buf))) +return -E2BIG ; + +memset (ar->bmi.cmd_buf,0 , ar->bmi.max_data_size + header);ath6kl_dbg (ATH6KL_DBG_BMI ,"bmi write memory: addr: 0x%x, len: %d\n" , addr, len);
@@ -189,7 +192,7 @@ int ath6kl_bmi_write(struct ath6kl *ar, u32 addr, u8 *buf, u32 len)while (len_remain) { src = &buf[len - len_remain]; -if (len_remain < (BMI_DATASZ_MAX - header)) { +if (len_remain < (ar->bmi.max_data_size - header)) {if (len_remain &3 ) {/* align it with 4 bytes */ len_remain = len_remain +
@@ -199,7 +202,7 @@ int ath6kl_bmi_write(struct ath6kl *ar, u32 addr, u8 *buf, u32 len) } tx_len = len_remain; }else { - tx_len = (BMI_DATASZ_MAX - header); + tx_len = (ar->bmi.max_data_size - header); } offset =0 ;
@@ -237,7 +240,7 @@ int ath6kl_bmi_execute(struct ath6kl *ar, u32 addr, u32 *param) } size =sizeof (cid) +sizeof (addr) +sizeof (param); -if (size >MAX_BMI_CMDBUF_SZ ) { +if (size > ar->bmi.max_cmd_size) {WARN_ON (1 );return -EINVAL ; }
@@ -284,7 +287,7 @@ int ath6kl_bmi_set_app_start(struct ath6kl *ar, u32 addr) } size =sizeof (cid) +sizeof (addr); -if (size >MAX_BMI_CMDBUF_SZ ) { +if (size > ar->bmi.max_cmd_size) {WARN_ON (1 );return -EINVAL ; }
@@ -320,7 +323,7 @@ int ath6kl_bmi_reg_read(struct ath6kl *ar, u32 addr, u32 *param) } size =sizeof (cid) +sizeof (addr); -if (size >MAX_BMI_CMDBUF_SZ ) { +if (size > ar->bmi.max_cmd_size) {WARN_ON (1 );return -EINVAL ; }
@@ -363,7 +366,7 @@ int ath6kl_bmi_reg_write(struct ath6kl *ar, u32 addr, u32 param) } size =sizeof (cid) +sizeof (addr) +sizeof (param); -if (size >MAX_BMI_CMDBUF_SZ ) { +if (size > ar->bmi.max_cmd_size) {WARN_ON (1 );return -EINVAL ; }
@@ -404,8 +407,8 @@ int ath6kl_bmi_lz_data(struct ath6kl *ar, u8 *buf, u32 len)return -EACCES ; } - size =BMI_DATASZ_MAX + header; -if (size >MAX_BMI_CMDBUF_SZ ) { + size = ar->bmi.max_data_size + header; +if (size > ar->bmi.max_cmd_size) {WARN_ON (1 );return -EINVAL ; }
@@ -416,8 +419,8 @@ int ath6kl_bmi_lz_data(struct ath6kl *ar, u8 *buf, u32 len) len_remain = len;while (len_remain) { - tx_len = (len_remain < (BMI_DATASZ_MAX - header)) ? - len_remain : (BMI_DATASZ_MAX - header); + tx_len = (len_remain < (ar->bmi.max_data_size - header)) ? + len_remain : (ar->bmi.max_data_size - header); offset =0 ;memcpy (&(ar->bmi.cmd_buf[offset]), &cid,sizeof (cid));
@@ -454,7 +457,7 @@ int ath6kl_bmi_lz_stream_start(struct ath6kl *ar, u32 addr) } size =sizeof (cid) +sizeof (addr); -if (size >MAX_BMI_CMDBUF_SZ ) { +if (size > ar->bmi.max_cmd_size) {WARN_ON (1 );return -EINVAL ; }
@@ -518,8 +521,13 @@ void ath6kl_bmi_reset(struct ath6kl *ar)int ath6kl_bmi_init (struct ath6kl *ar) { - ar->bmi.cmd_buf =kzalloc (MAX_BMI_CMDBUF_SZ ,GFP_ATOMIC ); +if (WARN_ON (ar->bmi.max_data_size ==0 )) +return -EINVAL ; + +/* cmd + addr + len + data_size */ + ar->bmi.max_cmd_size = ar->bmi.max_data_size + (sizeof (u32) *3 ); + ar->bmi.cmd_buf =kzalloc (ar->bmi.max_cmd_size,GFP_ATOMIC );if (!ar->bmi.cmd_buf)return -ENOMEM ;
drivers/net/wireless/ath/ath6kl/bmi.h +0 -6
@@ -44,12 +44,6 @@* BMI handles all required Target-side cache flushing. */ -#define MAX_BMI_CMDBUF_SZ (BMI_DATASZ_MAX + \ - (sizeof(u32) * 3 /* cmd + addr + len */)) - -/* Maximum data size used for BMI transfers */ -#define BMI_DATASZ_MAX 256 -/* BMI Commands */ #define BMI_NO_COMMAND 0
drivers/net/wireless/ath/ath6kl/core.h +2 -0
@@ -272,6 +272,8 @@ struct ath6kl_bmi {u32 cmd_credits;bool done_sent;u8 *cmd_buf; +u32 max_data_size; +u32 max_cmd_size; };struct target_stats {
drivers/net/wireless/ath/ath6kl/sdio.c +1 -0
@@ -1140,6 +1140,7 @@ static int ath6kl_sdio_probe(struct sdio_func *func, ar_sdio->ar = ar; ar->hif_priv = ar_sdio; ar->hif_ops = &ath6kl_sdio_ops; + ar->bmi.max_data_size =256 ;ath6kl_sdio_set_mbox_info (ar);
PATCH 3/10 ath6kl: move diag commands to hif driver
In reply to Kalle ValoThis is preparation for USB support which will have different diag commands.
Based on code by Kevin Fang.
--- drivers/net/wireless/ath/ath6kl/hif-ops.h | 20 ++++++ drivers/net/wireless/ath/ath6kl/hif.h | 2 + drivers/net/wireless/ath/ath6kl/main.c | 76 +--------------------- drivers/net/wireless/ath/ath6kl/sdio.c | 100 +++++++++++++++++++++++++++++ 4 files changed, 126 insertions(+), 72 deletions(-)
drivers/net/wireless/ath/ath6kl/hif-ops.h +20 -0
@@ -91,6 +91,26 @@ static inline int ath6kl_hif_suspend(struct ath6kl *ar,return ar->hif_ops->suspend (ar, wow); } +/* +* Read from the ATH6KL through its diagnostic window. No cooperation from +* the Target is required for this. +*/ +static inline int ath6kl_hif_diag_read32 (struct ath6kl *ar,u32 address, +u32 *value) +{ +return ar->hif_ops->diag_read32 (ar, address, value); +} + +/* +* Write to the ATH6KL through its diagnostic window. No cooperation from +* the Target is required for this. +*/ +static inline int ath6kl_hif_diag_write32 (struct ath6kl *ar,u32 address, +__le32 value) +{ +return ar->hif_ops->diag_write32 (ar, address, value); +} +static inline int ath6kl_hif_bmi_read (struct ath6kl *ar,u8 *buf,u32 len) {return ar->hif_ops->bmi_read (ar, buf, len);
drivers/net/wireless/ath/ath6kl/hif.h +2 -0
@@ -244,6 +244,8 @@ struct ath6kl_hif_ops {void (*cleanup_scatter)(struct ath6kl *ar);int (*suspend)(struct ath6kl *ar,struct cfg80211_wowlan *wow);int (*resume)(struct ath6kl *ar); +int (*diag_read32)(struct ath6kl *ar,u32 address,u32 *value); +int (*diag_write32)(struct ath6kl *ar,u32 address,__le32 value);int (*bmi_read)(struct ath6kl *ar,u8 *buf,u32 len);int (*bmi_write)(struct ath6kl *ar,u8 *buf,u32 len);int (*power_on)(struct ath6kl *ar);
drivers/net/wireless/ath/ath6kl/main.c +4 -72
100 lines not on this page · raw message
drivers/net/wireless/ath/ath6kl/sdio.c +100 -0
112 lines not on this page · raw message
PATCH 4/10 ath6kl: update ar6004 definitions
In reply to Kalle ValoAdd also hw 1.1.
--- drivers/net/wireless/ath/ath6kl/core.h | 18 +++++++++++++----- drivers/net/wireless/ath/ath6kl/target.h | 9 ++++++--- 2 files changed, 19 insertions(+), 8 deletions(-)
drivers/net/wireless/ath/ath6kl/core.h +13 -5
@@ -114,11 +114,19 @@ struct ath6kl_fw_ie {/* AR6004 1.0 definitions */ #define AR6004_REV1_VERSION 0x30000623 -#define AR6004_REV1_FIRMWARE_FILE "ath6k/AR6004/hw6.1/fw.ram.bin" -#define AR6004_REV1_FIRMWARE_2_FILE "ath6k/AR6004/hw6.1/fw-2.bin" -#define AR6004_REV1_BOARD_DATA_FILE "ath6k/AR6004/hw6.1/bdata.bin" -#define AR6004_REV1_DEFAULT_BOARD_DATA_FILE "ath6k/AR6004/hw6.1/bdata.DB132.bin" -#define AR6004_REV1_EPPING_FIRMWARE_FILE "ath6k/AR6004/hw6.1/endpointping.bin" +#define AR6004_REV1_FIRMWARE_2_FILE "ath6k/AR6004/hw1.0/fw-2.bin" +#define AR6004_REV1_FIRMWARE_FILE "ath6k/AR6004/hw1.0/fw.ram.bin" +#define AR6004_REV1_BOARD_DATA_FILE "ath6k/AR6004/hw1.0/bdata.bin" +#define AR6004_REV1_DEFAULT_BOARD_DATA_FILE \ + "ath6k/AR6004/hw1.0/bdata.DB132.bin" + +/* AR6004 1.1 definitions */ +#define AR6004_REV2_VERSION 0x30000001 +#define AR6004_REV2_FIRMWARE_2_FILE "ath6k/AR6004/hw1.1/fw-2.bin" +#define AR6004_REV2_FIRMWARE_FILE "ath6k/AR6004/hw1.1/fw.ram.bin" +#define AR6004_REV2_BOARD_DATA_FILE "ath6k/AR6004/hw1.1/bdata.bin" +#define AR6004_REV2_DEFAULT_BOARD_DATA_FILE \ + "ath6k/AR6004/hw1.1/bdata.DB132.bin"/* Per STA data, used in AP mode */ #define STA_PS_AWAKE BIT(0)
drivers/net/wireless/ath/ath6kl/target.h +6 -3
@@ -20,7 +20,7 @@#define AR6003_BOARD_DATA_SZ 1024#define AR6003_BOARD_EXT_DATA_SZ 768 -#define AR6004_BOARD_DATA_SZ 7168 +#define AR6004_BOARD_DATA_SZ 6144#define AR6004_BOARD_EXT_DATA_SZ 0#define RESET_CONTROL_ADDRESS 0x00000000
@@ -344,9 +344,12 @@ struct host_interest {#define AR6003_REV3_DATASET_PATCH_ADDRESS 0x57FF74#define AR6003_REV3_RAM_RESERVE_SIZE 512 -#define AR6004_REV1_BOARD_DATA_ADDRESS 0x435400 +#define AR6004_REV1_BOARD_DATA_ADDRESS 0x433900#define AR6004_REV1_BOARD_EXT_DATA_ADDRESS 0x437000 -#define AR6004_REV1_RAM_RESERVE_SIZE 11264 +#define AR6004_REV1_RAM_RESERVE_SIZE 19456 + +#define AR6004_REV2_BOARD_DATA_ADDRESS 0x43d400 +#define AR6004_REV2_RAM_RESERVE_SIZE 11264#define ATH6KL_FWLOG_PAYLOAD_SIZE 1500
PATCH 5/10 ath6kl: firmware boot fixes for ar6004
In reply to Kalle ValoThese have changed a bit since last time ar6004 code was commited.
--- drivers/net/wireless/ath/ath6kl/init.c | 34 +++++++++++++++++++++++--------- 1 files changed, 24 insertions(+), 10 deletions(-)
drivers/net/wireless/ath/ath6kl/init.c +24 -10
@@ -821,6 +821,9 @@ static int ath6kl_fetch_fw_api2(struct ath6kl *ar)case AR6004_REV1_VERSION : filename =AR6004_REV1_FIRMWARE_2_FILE ;break ; +case AR6004_REV2_VERSION : + filename =AR6004_REV2_FIRMWARE_2_FILE ; +break ;default :return -EOPNOTSUPP ; }
@@ -995,7 +998,11 @@ static int ath6kl_upload_board_file(struct ath6kl *ar)* writing board data. */ if (ar->target_type ==TARGET_TYPE_AR6004 ) { - board_address =AR6004_REV1_BOARD_DATA_ADDRESS ; +if (ar->version.target_ver ==AR6004_REV1_VERSION ) + board_address =AR6004_REV1_BOARD_DATA_ADDRESS ; +else + board_address =AR6004_REV2_BOARD_DATA_ADDRESS ; + ath6kl_bmi_write(ar, ath6kl_get_hi_item_addr(ar, HI_ITEM(hi_board_data)),
@@ -1013,7 +1020,8 @@ static int ath6kl_upload_board_file(struct ath6kl *ar) HI_ITEM(hi_board_ext_data)), (u8 *) &board_ext_address, 4); -if (board_ext_address ==0 ) { +if (ar->target_type ==TARGET_TYPE_AR6003 && + board_ext_address ==0 ) {ath6kl_err ("Failed to get board file target address.\n" );return -EINVAL ; }
@@ -1033,8 +1041,8 @@ static int ath6kl_upload_board_file(struct ath6kl *ar)break ; } -if (ar->fw_board_len == (board_data_size + - board_ext_data_size)) { +if (board_ext_address && + ar->fw_board_len == (board_data_size + board_ext_data_size)) {/* write extended board data */ ath6kl_dbg(ATH6KL_DBG_BOOT,
@@ -1092,8 +1100,8 @@ static int ath6kl_upload_otp(struct ath6kl *ar)bool from_hw = false;int ret; -if (WARN_ON (ar->fw_otp ==NULL )) -return -ENOENT ; +if (ar->fw_otp ==NULL ) +return 0 ; address = ar->hw.app_load_addr;
@@ -1142,7 +1150,7 @@ static int ath6kl_upload_firmware(struct ath6kl *ar)int ret;if (WARN_ON (ar->fw ==NULL )) -return -ENOENT ; +return 0 ; address = ar->hw.app_load_addr;
@@ -1172,8 +1180,8 @@ static int ath6kl_upload_patch(struct ath6kl *ar)u32 address, param;int ret; -if (WARN_ON (ar->fw_patch ==NULL )) -return -ENOENT ; +if (ar->fw_patch ==NULL ) +return 0 ; address = ar->hw.dataset_patch_addr;
@@ -1346,10 +1354,16 @@ static int ath6kl_init_hw_params(struct ath6kl *ar)break ;case AR6004_REV1_VERSION : ar->hw.dataset_patch_addr =AR6003_REV2_DATASET_PATCH_ADDRESS ; - ar->hw.app_load_addr =AR6003_REV3_APP_LOAD_ADDRESS ; + ar->hw.app_load_addr =0x1234 ; ar->hw.board_ext_data_addr =AR6004_REV1_BOARD_EXT_DATA_ADDRESS ; ar->hw.reserved_ram_size =AR6004_REV1_RAM_RESERVE_SIZE ;break ; +case AR6004_REV2_VERSION : + ar->hw.dataset_patch_addr =AR6003_REV2_DATASET_PATCH_ADDRESS ; + ar->hw.app_load_addr =0x1234 ; + ar->hw.board_ext_data_addr =AR6004_REV1_BOARD_EXT_DATA_ADDRESS ; + ar->hw.reserved_ram_size =AR6004_REV2_RAM_RESERVE_SIZE ; +break ;default :ath6kl_err ("Unsupported hardware version: 0x%x\n" , ar->version.target_ver);
PATCH 6/10 ath6kl: AR6004 SDIO support
In reply to Kalle ValoFrom: Naveen Gangadharan <[email protected]>
Add support for AR6004 SDIO. Tested scan, association (open mode) and ping.
kvalo: change commit log a bit, drop board address changes
--- drivers/net/wireless/ath/ath6kl/hif.h | 1 + drivers/net/wireless/ath/ath6kl/sdio.c | 2 ++ 2 files changed, 3 insertions(+), 0 deletions(-)
drivers/net/wireless/ath/ath6kl/hif.h +1 -0
@@ -35,6 +35,7 @@#define MAX_SCATTER_REQ_TRANSFER_SIZE (32 * 1024)#define MANUFACTURER_ID_AR6003_BASE 0x300 +#define MANUFACTURER_ID_AR6004_BASE 0x400/* SDIO manufacturer ID and Codes */ #define MANUFACTURER_ID_ATH6KL_BASE_MASK 0xFF00#define MANUFACTURER_CODE 0x271/* Atheros */
drivers/net/wireless/ath/ath6kl/sdio.c +2 -0
@@ -1290,6 +1290,8 @@ static void ath6kl_sdio_remove(struct sdio_func *func)static const struct sdio_device_id ath6kl_sdio_devices[] = { {SDIO_DEVICE (MANUFACTURER_CODE , (MANUFACTURER_ID_AR6003_BASE |0x0 ))}, {SDIO_DEVICE (MANUFACTURER_CODE , (MANUFACTURER_ID_AR6003_BASE |0x1 ))}, + {SDIO_DEVICE (MANUFACTURER_CODE , (MANUFACTURER_ID_AR6004_BASE |0x0 ))}, + {SDIO_DEVICE (MANUFACTURER_CODE , (MANUFACTURER_ID_AR6004_BASE |0x1 ))}, {}, };
PATCH 7/10 ath6kl: add hif_type
In reply to Kalle ValoIn some rare cases core code needs to know what hif type is used. Add a field to struct ath6kl to denote that. Hopefully this is just a temporary solution.
--- drivers/net/wireless/ath/ath6kl/core.h | 6 ++++++ drivers/net/wireless/ath/ath6kl/sdio.c | 1 + 2 files changed, 7 insertions(+), 0 deletions(-)
drivers/net/wireless/ath/ath6kl/core.h +6 -0
@@ -391,6 +391,11 @@ struct ath6kl_req_key {u8 key_len; }; +enum ath6kl_hif_type { +ATH6KL_HIF_TYPE_SDIO , +ATH6KL_HIF_TYPE_USB , +}; +#define MAX_NUM_VIF 1/* vif flags info */
@@ -484,6 +489,7 @@ struct ath6kl {int tx_pending[ENDPOINT_MAX ];int total_tx_data_pend;struct htc_target *htc_target; +enum ath6kl_hif_type hif_type;void *hif_priv;struct list_head vif_list;/* Lock to avoid race in vif_list entries among add/del/traverse */
drivers/net/wireless/ath/ath6kl/sdio.c +1 -0
@@ -1238,6 +1238,7 @@ static int ath6kl_sdio_probe(struct sdio_func *func, } ar_sdio->ar = ar; + ar->hif_type =ATH6KL_HIF_TYPE_SDIO ; ar->hif_priv = ar_sdio; ar->hif_ops = &ath6kl_sdio_ops; ar->bmi.max_data_size =256 ;
PATCH 8/10 ath6kl: add USB support
In reply to Kalle ValoAdd USB support for ar6004. Currently only firmware can be booted, no commands can be sent to firmware yet as HTC layer doesn't work with USB yet.
Based on patches by Kevin Fang.
--- drivers/net/wireless/ath/ath6kl/bmi.c | 10 + drivers/net/wireless/ath/ath6kl/debug.h | 1 drivers/net/wireless/ath/ath6kl/usb.c | 431 +++++++++++++++++++++++++++++++ 3 files changed, 440 insertions(+), 2 deletions(-) create mode 100644 drivers/net/wireless/ath/ath6kl/usb.c
drivers/net/wireless/ath/ath6kl/bmi.c +8 -2
@@ -57,8 +57,14 @@ int ath6kl_bmi_get_target_info(struct ath6kl *ar,return ret; } - ret =ath6kl_hif_bmi_read (ar, (u8 *)&targ_info->version, -sizeof (targ_info->version)); +if (ar->hif_type ==ATH6KL_HIF_TYPE_USB ) { + ret =ath6kl_hif_bmi_read (ar, (u8 *)targ_info, +sizeof (*targ_info)); + }else { + ret =ath6kl_hif_bmi_read (ar, (u8 *)&targ_info->version, +sizeof (targ_info->version)); + } +if (ret) {ath6kl_err ("Unable to recv target info: %d\n" , ret);return ret;
drivers/net/wireless/ath/ath6kl/debug.h +1 -0
@@ -41,6 +41,7 @@ enum ATH6K_DEBUG_MASK {ATH6KL_DBG_BOOT =BIT (18 ),/* driver init and fw boot */ ATH6KL_DBG_WMI_DUMP =BIT (19 ),ATH6KL_DBG_SUSPEND =BIT (20 ), +ATH6KL_DBG_USB =BIT (21 ), ATH6KL_DBG_ANY = 0xffffffff /* enable all logs */ };
drivers/net/wireless/ath/ath6kl/usb.c new file +431 -0
431 lines not on this page · raw message
PATCH 9/10 ath6kl: disable HTC for USB devices
In reply to Kalle ValoAs HTC layer doesn't support USB devices return an error if that happens. USB support will be added to HTC in the future, this is just a temporary solution.
--- drivers/net/wireless/ath/ath6kl/hif.c | 5 +++++ drivers/net/wireless/ath/ath6kl/htc.c | 10 +++++++++- 2 files changed, 14 insertions(+), 1 deletions(-)
drivers/net/wireless/ath/ath6kl/hif.c +5 -0
@@ -689,6 +689,11 @@ int ath6kl_hif_setup(struct ath6kl_device *dev)ath6kl_dbg (ATH6KL_DBG_HIF ,"hif block size %d mbox addr 0x%x\n" , dev->htc_cnxt->block_sz, dev->ar->mbox_info.htc_addr); +/* usb doesn't support enabling interrupts */ +/* FIXME: remove check once USB support is implemented */ +if (dev->ar->hif_type ==ATH6KL_HIF_TYPE_USB ) +return 0 ; + status =ath6kl_hif_disable_intrs (dev); fail_setup:
drivers/net/wireless/ath/ath6kl/htc.c +9 -1
@@ -2543,6 +2543,12 @@ int ath6kl_htc_wait_target(struct htc_target *target)struct htc_service_connect_resp resp;int status; +/* FIXME: remove once USB support is implemented */ +if (target->dev->ar->hif_type ==ATH6KL_HIF_TYPE_USB ) { +ath6kl_err ("HTC doesn't support USB yet. Patience!\n" ); +return -EOPNOTSUPP ; + } +/* we should be getting 1 control message that the target is ready */ packet =htc_wait_for_ctrl_msg (target);
@@ -2772,7 +2778,9 @@ void ath6kl_htc_cleanup(struct htc_target *target) {struct htc_packet *packet, *tmp_packet; -ath6kl_hif_cleanup_scatter (target->dev->ar); +/* FIXME: remove check once USB support is implemented */ +if (target->dev->ar->hif_type !=ATH6KL_HIF_TYPE_USB ) +ath6kl_hif_cleanup_scatter (target->dev->ar);list_for_each_entry_safe (packet, tmp_packet, &target->free_ctrl_txbuf, list) {
PATCH 10/10 ath6kl: enable USB support
In reply to Kalle ValoNow two modules are built, ath6kl_sdio.ko and ath6kl_usb.ko. But the USB module isn't fully functional yet as HTC layer is missing support and that's why it's marked as experimental for now.
--- drivers/net/wireless/ath/ath6kl/Kconfig | 25 +++++++++++++++++--- drivers/net/wireless/ath/ath6kl/Makefile | 37 ++++++++++++++++++++---------- drivers/net/wireless/ath/ath6kl/sdio.c | 2 +- 3 files changed, 47 insertions(+), 17 deletions(-)
drivers/net/wireless/ath/ath6kl/Kconfig +21 -4
@@ -1,12 +1,29 @@ config ATH6KL - tristate "Atheros ath6kl support" + tristate "Atheros mobile chipsets support" + +config ATH6KL_SDIO + tristate "Atheros ath6kl SDIO support" + depends on ATH6KL depends on MMC depends on CFG80211 ---help--- This module adds support for wireless adapters based on - Atheros AR6003 chipset running over SDIO. If you choose to - build it as a module, it will be called ath6kl. Pls note - that AR6002 and AR6001 are not supported by this driver. + Atheros AR6003 and AR6004 chipsets running over SDIO. If you + choose to build it as a module, it will be called ath6kl_sdio. + Please note that AR6002 and AR6001 are not supported by this + driver. + +config ATH6KL_USB + tristate "Atheros ath6kl USB support" + depends on ATH6KL + depends on USB + depends on CFG80211 + depends on EXPERIMENTAL + ---help--- + This module adds support for wireless adapters based on + Atheros AR6004 chipset running over USB. This is still under + implementation and it isn't functional. If you choose to + build it as a module, it will be called ath6kl_usb. config ATH6KL_DEBUG bool "Atheros ath6kl debugging"
drivers/net/wireless/ath/ath6kl/Makefile +25 -12
@@ -21,17 +21,30 @@ # Author(s): ="Atheros" #------------------------------------------------------------------------------ -obj-$(CONFIG_ATH6KL) := ath6kl.o -ath6kl-y += debug.o -ath6kl-y += hif.o -ath6kl-y += htc.o -ath6kl-y += bmi.o -ath6kl-y += cfg80211.o -ath6kl-y += init.o -ath6kl-y += main.o -ath6kl-y += txrx.o -ath6kl-y += wmi.o -ath6kl-y += sdio.o -ath6kl-$(CONFIG_NL80211_TESTMODE) += testmode.o +obj-$(CONFIG_ATH6KL_SDIO) := ath6kl_sdio.o +ath6kl_sdio-y += debug.o +ath6kl_sdio-y += hif.o +ath6kl_sdio-y += htc.o +ath6kl_sdio-y += bmi.o +ath6kl_sdio-y += cfg80211.o +ath6kl_sdio-y += init.o +ath6kl_sdio-y += main.o +ath6kl_sdio-y += txrx.o +ath6kl_sdio-y += wmi.o +ath6kl_sdio-y += sdio.o +ath6kl_sdio-$(CONFIG_NL80211_TESTMODE) += testmode.o + +obj-$(CONFIG_ATH6KL_USB) += ath6kl_usb.o +ath6kl_usb-y += debug.o +ath6kl_usb-y += hif.o +ath6kl_usb-y += htc.o +ath6kl_usb-y += bmi.o +ath6kl_usb-y += cfg80211.o +ath6kl_usb-y += init.o +ath6kl_usb-y += main.o +ath6kl_usb-y += txrx.o +ath6kl_usb-y += wmi.o +ath6kl_usb-y += usb.o +ath6kl_usb-$(CONFIG_NL80211_TESTMODE) += testmode.o ccflags-y += -D__CHECK_ENDIAN__
drivers/net/wireless/ath/ath6kl/sdio.c +1 -1
@@ -1299,7 +1299,7 @@ static const struct sdio_device_id ath6kl_sdio_devices[] = {MODULE_DEVICE_TABLE (sdio, ath6kl_sdio_devices);static struct sdio_driver ath6kl_sdio_driver = { - .name ="ath6kl" , + .name ="ath6kl_sdio" , .id_table = ath6kl_sdio_devices, .probe = ath6kl_sdio_probe, .remove = ath6kl_sdio_remove,
Quoted 2 lines · Kalle Valo
This patchset adds support for ar6004 sdio and also beginning of ar6004 usb support.
All 10 applied.
Kalle