Subject: [PATCH 1/3] ath6kl: Make ath6kl_diag_write32() non-static

So that this can be called from debug.c when adding support
to write chip register.

Signed-off-by: Vasanthakumar Thiagarajan <[email protected]>
---
drivers/net/wireless/ath/ath6kl/core.h | 1 +
drivers/net/wireless/ath/ath6kl/main.c | 2 +-
2 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/drivers/net/wireless/ath/ath6kl/core.h b/drivers/net/wireless/ath/ath6kl/core.h
index faf8015..e69cd5b 100644
--- a/drivers/net/wireless/ath/ath6kl/core.h
+++ b/drivers/net/wireless/ath/ath6kl/core.h
@@ -523,6 +523,7 @@ enum htc_send_full_action ath6kl_tx_queue_full(struct htc_target *target,
struct htc_packet *packet);
void ath6kl_stop_txrx(struct ath6kl *ar);
void ath6kl_cleanup_amsdu_rxbufs(struct ath6kl *ar);
+int ath6kl_diag_write32(struct ath6kl *ar, u32 address, u32 value);
int ath6kl_diag_write(struct ath6kl *ar, u32 address, void *data, u32 length);
int ath6kl_diag_read32(struct ath6kl *ar, u32 address, u32 *value);
int ath6kl_diag_read(struct ath6kl *ar, u32 address, void *data, u32 length);
diff --git a/drivers/net/wireless/ath/ath6kl/main.c b/drivers/net/wireless/ath/ath6kl/main.c
index bda14d1..48e9c2e 100644
--- a/drivers/net/wireless/ath/ath6kl/main.c
+++ b/drivers/net/wireless/ath/ath6kl/main.c
@@ -261,7 +261,7 @@ int ath6kl_diag_read32(struct ath6kl *ar, u32 address, u32 *value)
* Write to the ATH6KL through its diagnostic window. No cooperation from
* the Target is required for this.
*/
-static int ath6kl_diag_write32(struct ath6kl *ar, u32 address, u32 value)
+int ath6kl_diag_write32(struct ath6kl *ar, u32 address, u32 value)
{
int ret;

--
1.7.0.4



Subject: [PATCH 3/3] ath6kl: Add debugfs support to write a chip register

To write a value to register:
echo <register_offset>=<register_value> > <degfs_root>/ieee80211/phyX/ath6kl/register_write

Signed-off-by: Vasanthakumar Thiagarajan <[email protected]>
---
drivers/net/wireless/ath/ath6kl/core.h | 2 +
drivers/net/wireless/ath/ath6kl/debug.c | 66 +++++++++++++++++++++++++++++++
2 files changed, 68 insertions(+), 0 deletions(-)

diff --git a/drivers/net/wireless/ath/ath6kl/core.h b/drivers/net/wireless/ath/ath6kl/core.h
index ae2f591..fdb796f 100644
--- a/drivers/net/wireless/ath/ath6kl/core.h
+++ b/drivers/net/wireless/ath/ath6kl/core.h
@@ -478,6 +478,8 @@ struct ath6kl {
void *fwlog_tmp;
u32 fwlog_mask;
unsigned int dbgfs_diag_reg;
+ u32 diag_reg_addr_wr;
+ u32 diag_reg_val_wr;
} debug;
#endif /* CONFIG_ATH6KL_DEBUG */
};
diff --git a/drivers/net/wireless/ath/ath6kl/debug.c b/drivers/net/wireless/ath/ath6kl/debug.c
index 8bc4753..a121c2b 100644
--- a/drivers/net/wireless/ath/ath6kl/debug.c
+++ b/drivers/net/wireless/ath/ath6kl/debug.c
@@ -759,6 +759,68 @@ static const struct file_operations fops_lrssi_roam_threshold = {
.llseek = default_llseek,
};

+static ssize_t ath6kl_regwrite_read(struct file *file,
+ char __user *user_buf,
+ size_t count, loff_t *ppos)
+{
+ struct ath6kl *ar = file->private_data;
+ u8 buf[32];
+ unsigned int len = 0;
+
+ len = scnprintf(buf, sizeof(buf), "Addr: 0x%x Val: 0x%x\n",
+ ar->debug.diag_reg_addr_wr, ar->debug.diag_reg_val_wr);
+
+ return simple_read_from_buffer(user_buf, count, ppos, buf, len);
+}
+
+static ssize_t ath6kl_regwrite_write(struct file *file,
+ const char __user *user_buf,
+ size_t count, loff_t *ppos)
+{
+ struct ath6kl *ar = file->private_data;
+ char buf[32];
+ char *sptr, *token;
+ unsigned int len = 0;
+ u32 reg_addr, reg_val;
+
+ len = min(count, sizeof(buf) - 1);
+ if (copy_from_user(buf, user_buf, len))
+ return -EFAULT;
+
+ buf[len] = '\0';
+ sptr = buf;
+
+ token = strsep(&sptr, "=");
+ if (!token)
+ return -EINVAL;
+
+ if (kstrtou32(token, 0, &reg_addr))
+ return -EINVAL;
+
+ if (!ath6kl_dbg_is_diag_reg_valid(reg_addr))
+ return -EINVAL;
+
+ if (kstrtou32(sptr, 0, &reg_val))
+ return -EINVAL;
+
+ ar->debug.diag_reg_addr_wr = reg_addr;
+ ar->debug.diag_reg_val_wr = reg_val;
+
+ if (ath6kl_diag_write32(ar, ar->debug.diag_reg_addr_wr,
+ cpu_to_le32(ar->debug.diag_reg_val_wr)))
+ return -EIO;
+
+ return count;
+}
+
+static const struct file_operations fops_diag_reg_write = {
+ .read = ath6kl_regwrite_read,
+ .write = ath6kl_regwrite_write,
+ .open = ath6kl_debugfs_open,
+ .owner = THIS_MODULE,
+ .llseek = default_llseek,
+};
+
int ath6kl_debug_init(struct ath6kl *ar)
{
ar->debug.fwlog_buf.buf = vmalloc(ATH6KL_FWLOG_SIZE);
@@ -807,6 +869,10 @@ int ath6kl_debug_init(struct ath6kl *ar)

debugfs_create_file("lrssi_roam_threshold", S_IRUSR | S_IWUSR,
ar->debugfs_phy, ar, &fops_lrssi_roam_threshold);
+
+ debugfs_create_file("register_write", S_IRUSR | S_IWUSR,
+ ar->debugfs_phy, ar, &fops_diag_reg_write);
+
return 0;
}

--
1.7.0.4


2011-09-05 08:22:20

by Kalle Valo

[permalink] [raw]
Subject: Re: [PATCH 1/3] ath6kl: Make ath6kl_diag_write32() non-static

On 09/02/2011 04:46 PM, Vasanthakumar Thiagarajan wrote:
> So that this can be called from debug.c when adding support
> to write chip register.

Thanks, all three applied. But I did a minor to change to patch 3:

Author: Vasanthakumar Thiagarajan <[email protected]>
Date: Mon Sep 5 11:19:46 2011 +0300

ath6kl: Add debugfs support to write a chip register

To write a value to register:
echo <register_offset>=<register_value> >
<degfs_root>/ieee80211/phyX/ath6kl/reg_write

kvalo: rename file to reg_write to follow the style of other debugfs
files

Signed-off-by: Vasanthakumar Thiagarajan <[email protected]>
Signed-off-by: Kalle Valo <[email protected]>

Kalle

Subject: [PATCH 2/3] ath6kl: Fix endianness in register write

Signed-off-by: Vasanthakumar Thiagarajan <[email protected]>
---
drivers/net/wireless/ath/ath6kl/core.h | 2 +-
drivers/net/wireless/ath/ath6kl/main.c | 10 ++++++----
2 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/drivers/net/wireless/ath/ath6kl/core.h b/drivers/net/wireless/ath/ath6kl/core.h
index e69cd5b..ae2f591 100644
--- a/drivers/net/wireless/ath/ath6kl/core.h
+++ b/drivers/net/wireless/ath/ath6kl/core.h
@@ -523,7 +523,7 @@ enum htc_send_full_action ath6kl_tx_queue_full(struct htc_target *target,
struct htc_packet *packet);
void ath6kl_stop_txrx(struct ath6kl *ar);
void ath6kl_cleanup_amsdu_rxbufs(struct ath6kl *ar);
-int ath6kl_diag_write32(struct ath6kl *ar, u32 address, u32 value);
+int ath6kl_diag_write32(struct ath6kl *ar, u32 address, __le32 value);
int ath6kl_diag_write(struct ath6kl *ar, u32 address, void *data, u32 length);
int ath6kl_diag_read32(struct ath6kl *ar, u32 address, u32 *value);
int ath6kl_diag_read(struct ath6kl *ar, u32 address, void *data, u32 length);
diff --git a/drivers/net/wireless/ath/ath6kl/main.c b/drivers/net/wireless/ath/ath6kl/main.c
index 48e9c2e..3cefca6 100644
--- a/drivers/net/wireless/ath/ath6kl/main.c
+++ b/drivers/net/wireless/ath/ath6kl/main.c
@@ -261,7 +261,7 @@ int ath6kl_diag_read32(struct ath6kl *ar, u32 address, u32 *value)
* Write to the ATH6KL through its diagnostic window. No cooperation from
* the Target is required for this.
*/
-int ath6kl_diag_write32(struct ath6kl *ar, u32 address, u32 value)
+int ath6kl_diag_write32(struct ath6kl *ar, u32 address, __le32 value)
{
int ret;

@@ -298,7 +298,8 @@ int ath6kl_diag_read(struct ath6kl *ar, u32 address, void *data, u32 length)

int ath6kl_diag_write(struct ath6kl *ar, u32 address, void *data, u32 length)
{
- u32 count, *buf = data;
+ u32 count;
+ __le32 *buf = data;
int ret;

if (WARN_ON(length % 4))
@@ -397,13 +398,14 @@ static void ath6kl_reset_device(struct ath6kl *ar, u32 target_type,
{
int status = 0;
u32 address;
- u32 data;
+ __le32 data;

if (target_type != TARGET_TYPE_AR6003 &&
target_type != TARGET_TYPE_AR6004)
return;

- data = cold_reset ? RESET_CONTROL_COLD_RST : RESET_CONTROL_MBOX_RST;
+ data = cold_reset ? cpu_to_le32(RESET_CONTROL_COLD_RST) :
+ cpu_to_le32(RESET_CONTROL_MBOX_RST);

switch (target_type) {
case TARGET_TYPE_AR6003:
--
1.7.0.4


Subject: Re: [PATCH 1/3] ath6kl: Make ath6kl_diag_write32() non-static

On Mon, Sep 05, 2011 at 11:22:13AM +0300, Kalle Valo wrote:
> On 09/02/2011 04:46 PM, Vasanthakumar Thiagarajan wrote:
> > So that this can be called from debug.c when adding support
> > to write chip register.
>
> Thanks, all three applied. But I did a minor to change to patch 3:
>
> Author: Vasanthakumar Thiagarajan <[email protected]>
> Date: Mon Sep 5 11:19:46 2011 +0300
>
> ath6kl: Add debugfs support to write a chip register
>
> To write a value to register:
> echo <register_offset>=<register_value> >
> <degfs_root>/ieee80211/phyX/ath6kl/reg_write
>
> kvalo: rename file to reg_write to follow the style of other debugfs
> files

Thanks.

Vasanth