aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/ath
diff options
context:
space:
mode:
authorVasanthakumar Thiagarajan <vasanth@atheros.com>2011-03-01 08:30:55 -0500
committerJohn W. Linville <linville@tuxdriver.com>2011-03-04 14:05:17 -0500
commit582d00641b03efa892b3d2cfe6b45c1fe6d422a1 (patch)
tree9a9d96cbe404dc0e40d3ceb6a9aef2ad26ca23e3 /drivers/net/wireless/ath
parent6410db593e8c1b2b79a2f18554310d6da9415584 (diff)
ath9k: Add a debugfs interface to dump chip registers
/<debugfs_root>/ieee80211/phyX/ath9k/regdump is the interface to dump the registers. Signed-off-by: Felix Fietkau <nbd@openwrt.org> Signed-off-by: Vasanthakumar Thiagarajan <vasanth@atheros.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless/ath')
-rw-r--r--drivers/net/wireless/ath/ath9k/debug.c54
1 files changed, 54 insertions, 0 deletions
diff --git a/drivers/net/wireless/ath/ath9k/debug.c b/drivers/net/wireless/ath/ath9k/debug.c
index 5cfcf8c235a4..d404aa0ac76a 100644
--- a/drivers/net/wireless/ath/ath9k/debug.c
+++ b/drivers/net/wireless/ath/ath9k/debug.c
@@ -15,6 +15,7 @@
15 */ 15 */
16 16
17#include <linux/slab.h> 17#include <linux/slab.h>
18#include <linux/vmalloc.h>
18#include <asm/unaligned.h> 19#include <asm/unaligned.h>
19 20
20#include "ath9k.h" 21#include "ath9k.h"
@@ -30,6 +31,19 @@ static int ath9k_debugfs_open(struct inode *inode, struct file *file)
30 return 0; 31 return 0;
31} 32}
32 33
34static ssize_t ath9k_debugfs_read_buf(struct file *file, char __user *user_buf,
35 size_t count, loff_t *ppos)
36{
37 u8 *buf = file->private_data;
38 return simple_read_from_buffer(user_buf, count, ppos, buf, strlen(buf));
39}
40
41static int ath9k_debugfs_release_buf(struct inode *inode, struct file *file)
42{
43 vfree(file->private_data);
44 return 0;
45}
46
33#ifdef CONFIG_ATH_DEBUG 47#ifdef CONFIG_ATH_DEBUG
34 48
35static ssize_t read_file_debug(struct file *file, char __user *user_buf, 49static ssize_t read_file_debug(struct file *file, char __user *user_buf,
@@ -1027,6 +1041,42 @@ static const struct file_operations fops_regval = {
1027 .llseek = default_llseek, 1041 .llseek = default_llseek,
1028}; 1042};
1029 1043
1044#define REGDUMP_LINE_SIZE 20
1045
1046static int open_file_regdump(struct inode *inode, struct file *file)
1047{
1048 struct ath_softc *sc = inode->i_private;
1049 unsigned int len = 0;
1050 u8 *buf;
1051 int i;
1052 unsigned long num_regs, regdump_len, max_reg_offset;
1053
1054 max_reg_offset = AR_SREV_9300_20_OR_LATER(sc->sc_ah) ? 0x16bd4 : 0xb500;
1055 num_regs = max_reg_offset / 4 + 1;
1056 regdump_len = num_regs * REGDUMP_LINE_SIZE + 1;
1057 buf = vmalloc(regdump_len);
1058 if (!buf)
1059 return -ENOMEM;
1060
1061 ath9k_ps_wakeup(sc);
1062 for (i = 0; i < num_regs; i++)
1063 len += scnprintf(buf + len, regdump_len - len,
1064 "0x%06x 0x%08x\n", i << 2, REG_READ(sc->sc_ah, i << 2));
1065 ath9k_ps_restore(sc);
1066
1067 file->private_data = buf;
1068
1069 return 0;
1070}
1071
1072static const struct file_operations fops_regdump = {
1073 .open = open_file_regdump,
1074 .read = ath9k_debugfs_read_buf,
1075 .release = ath9k_debugfs_release_buf,
1076 .owner = THIS_MODULE,
1077 .llseek = default_llseek,/* read accesses f_pos */
1078};
1079
1030int ath9k_init_debug(struct ath_hw *ah) 1080int ath9k_init_debug(struct ath_hw *ah)
1031{ 1081{
1032 struct ath_common *common = ath9k_hw_common(ah); 1082 struct ath_common *common = ath9k_hw_common(ah);
@@ -1091,6 +1141,10 @@ int ath9k_init_debug(struct ath_hw *ah)
1091 sc->debug.debugfs_phy, &ah->config.cwm_ignore_extcca)) 1141 sc->debug.debugfs_phy, &ah->config.cwm_ignore_extcca))
1092 goto err; 1142 goto err;
1093 1143
1144 if (!debugfs_create_file("regdump", S_IRUSR, sc->debug.debugfs_phy,
1145 sc, &fops_regdump))
1146 goto err;
1147
1094 sc->debug.regidx = 0; 1148 sc->debug.regidx = 0;
1095 return 0; 1149 return 0;
1096err: 1150err: