aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/net/wireless/ath9k/ath9k.h1
-rw-r--r--drivers/net/wireless/ath9k/core.h1
-rw-r--r--drivers/net/wireless/ath9k/debug.c49
-rw-r--r--drivers/net/wireless/ath9k/hw.c7
4 files changed, 58 insertions, 0 deletions
diff --git a/drivers/net/wireless/ath9k/ath9k.h b/drivers/net/wireless/ath9k/ath9k.h
index f158cba01407..f44aab50a2d6 100644
--- a/drivers/net/wireless/ath9k/ath9k.h
+++ b/drivers/net/wireless/ath9k/ath9k.h
@@ -899,6 +899,7 @@ void ath9k_hw_getbssidmask(struct ath_hal *ah, u8 *mask);
899bool ath9k_hw_setbssidmask(struct ath_hal *ah, const u8 *mask); 899bool ath9k_hw_setbssidmask(struct ath_hal *ah, const u8 *mask);
900void ath9k_hw_write_associd(struct ath_hal *ah, const u8 *bssid, u16 assocId); 900void ath9k_hw_write_associd(struct ath_hal *ah, const u8 *bssid, u16 assocId);
901u64 ath9k_hw_gettsf64(struct ath_hal *ah); 901u64 ath9k_hw_gettsf64(struct ath_hal *ah);
902void ath9k_hw_settsf64(struct ath_hal *ah, u64 tsf64);
902void ath9k_hw_reset_tsf(struct ath_hal *ah); 903void ath9k_hw_reset_tsf(struct ath_hal *ah);
903bool ath9k_hw_set_tsfadjust(struct ath_hal *ah, u32 setting); 904bool ath9k_hw_set_tsfadjust(struct ath_hal *ah, u32 setting);
904bool ath9k_hw_setslottime(struct ath_hal *ah, u32 us); 905bool ath9k_hw_setslottime(struct ath_hal *ah, u32 us);
diff --git a/drivers/net/wireless/ath9k/core.h b/drivers/net/wireless/ath9k/core.h
index 29251f8dabb0..acbd8881ef83 100644
--- a/drivers/net/wireless/ath9k/core.h
+++ b/drivers/net/wireless/ath9k/core.h
@@ -141,6 +141,7 @@ struct ath9k_debug {
141 struct dentry *debugfs_phy; 141 struct dentry *debugfs_phy;
142 struct dentry *debugfs_dma; 142 struct dentry *debugfs_dma;
143 struct dentry *debugfs_interrupt; 143 struct dentry *debugfs_interrupt;
144 struct dentry *debugfs_tsf;
144 struct ath_stats stats; 145 struct ath_stats stats;
145}; 146};
146 147
diff --git a/drivers/net/wireless/ath9k/debug.c b/drivers/net/wireless/ath9k/debug.c
index a80ed576830f..05e1f82cc7a1 100644
--- a/drivers/net/wireless/ath9k/debug.c
+++ b/drivers/net/wireless/ath9k/debug.c
@@ -222,6 +222,49 @@ static const struct file_operations fops_interrupt = {
222 .owner = THIS_MODULE 222 .owner = THIS_MODULE
223}; 223};
224 224
225
226static ssize_t read_file_tsf(struct file *file, char __user *user_buf,
227 size_t count, loff_t *ppos)
228{
229 struct ath_softc *sc = file->private_data;
230 char buf[100];
231 snprintf(buf, sizeof(buf), "0x%016llx\n",
232 (unsigned long long)ath9k_hw_gettsf64(sc->sc_ah));
233 return simple_read_from_buffer(user_buf, count, ppos, buf, 19);
234}
235
236static ssize_t write_file_tsf(struct file *file,
237 const char __user *user_buf,
238 size_t count, loff_t *ppos)
239{
240 struct ath_softc *sc = file->private_data;
241 char buf[21];
242 unsigned long long tsf;
243
244 if (copy_from_user(buf, user_buf, min(count, sizeof(buf) - 1)))
245 return -EFAULT;
246 buf[sizeof(buf) - 1] = '\0';
247
248 if (strncmp(buf, "reset", 5) == 0) {
249 ath9k_hw_reset_tsf(sc->sc_ah);
250 printk(KERN_INFO "debugfs reset TSF\n");
251 } else {
252 tsf = simple_strtoul(buf, NULL, 0);
253 ath9k_hw_settsf64(sc->sc_ah, tsf);
254 printk(KERN_INFO "debugfs set TSF to %#018llx\n", tsf);
255 }
256
257 return count;
258}
259
260static const struct file_operations fops_tsf = {
261 .read = read_file_tsf,
262 .write = write_file_tsf,
263 .open = ath9k_debugfs_open,
264 .owner = THIS_MODULE
265};
266
267
225int ath9k_init_debug(struct ath_softc *sc) 268int ath9k_init_debug(struct ath_softc *sc)
226{ 269{
227 sc->sc_debug.debug_mask = ath9k_debug; 270 sc->sc_debug.debug_mask = ath9k_debug;
@@ -247,6 +290,11 @@ int ath9k_init_debug(struct ath_softc *sc)
247 if (!sc->sc_debug.debugfs_interrupt) 290 if (!sc->sc_debug.debugfs_interrupt)
248 goto err; 291 goto err;
249 292
293 sc->sc_debug.debugfs_tsf = debugfs_create_file("tsf", S_IRUGO,
294 sc->sc_debug.debugfs_phy, sc, &fops_tsf);
295 if (!sc->sc_debug.debugfs_tsf)
296 goto err;
297
250 return 0; 298 return 0;
251err: 299err:
252 ath9k_exit_debug(sc); 300 ath9k_exit_debug(sc);
@@ -255,6 +303,7 @@ err:
255 303
256void ath9k_exit_debug(struct ath_softc *sc) 304void ath9k_exit_debug(struct ath_softc *sc)
257{ 305{
306 debugfs_remove(sc->sc_debug.debugfs_tsf);
258 debugfs_remove(sc->sc_debug.debugfs_interrupt); 307 debugfs_remove(sc->sc_debug.debugfs_interrupt);
259 debugfs_remove(sc->sc_debug.debugfs_dma); 308 debugfs_remove(sc->sc_debug.debugfs_dma);
260 debugfs_remove(sc->sc_debug.debugfs_phy); 309 debugfs_remove(sc->sc_debug.debugfs_phy);
diff --git a/drivers/net/wireless/ath9k/hw.c b/drivers/net/wireless/ath9k/hw.c
index f2922bab7761..1a49743151ba 100644
--- a/drivers/net/wireless/ath9k/hw.c
+++ b/drivers/net/wireless/ath9k/hw.c
@@ -3755,6 +3755,13 @@ u64 ath9k_hw_gettsf64(struct ath_hal *ah)
3755 return tsf; 3755 return tsf;
3756} 3756}
3757 3757
3758void ath9k_hw_settsf64(struct ath_hal *ah, u64 tsf64)
3759{
3760 REG_WRITE(ah, AR_TSF_L32, 0x00000000);
3761 REG_WRITE(ah, AR_TSF_U32, (tsf64 >> 32) & 0xffffffff);
3762 REG_WRITE(ah, AR_TSF_L32, tsf64 & 0xffffffff);
3763}
3764
3758void ath9k_hw_reset_tsf(struct ath_hal *ah) 3765void ath9k_hw_reset_tsf(struct ath_hal *ah)
3759{ 3766{
3760 int count; 3767 int count;