linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 2/2] ath9k: Add a debugfs file to adjust antenna diversity
@ 2012-09-21  7:01 Sujith Manoharan
  2012-09-21 14:28 ` Ben Greear
  0 siblings, 1 reply; 5+ messages in thread
From: Sujith Manoharan @ 2012-09-21  7:01 UTC (permalink / raw)
  To: linville; +Cc: linux-wireless

Location: /<debugfs>/ieee80211/phy#/ath9k/diversity

Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
---
 drivers/net/wireless/ath/ath9k/ar9003_phy.c |  2 +-
 drivers/net/wireless/ath/ath9k/debug.c      | 52 +++++++++++++++++++++++++++--
 2 files changed, 51 insertions(+), 3 deletions(-)

diff --git a/drivers/net/wireless/ath/ath9k/ar9003_phy.c b/drivers/net/wireless/ath/ath9k/ar9003_phy.c
index fc67844..759f5f5 100644
--- a/drivers/net/wireless/ath/ath9k/ar9003_phy.c
+++ b/drivers/net/wireless/ath/ath9k/ar9003_phy.c
@@ -1360,7 +1360,7 @@ static void ar9003_hw_antctrl_shared_chain_lnadiv(struct ath_hw *ah,
 	if (enable) {
 		REG_SET_BIT(ah, AR_PHY_MC_GAIN_CTRL,
 			    (1 << AR_PHY_ANT_SW_RX_PROT_S));
-		if (IS_CHAN_2GHZ(ah->curchan))
+		if (ah->curchan && IS_CHAN_2GHZ(ah->curchan))
 			REG_SET_BIT(ah, AR_PHY_RESTART,
 				    AR_PHY_RESTART_ENABLE_DIV_M2FLAG);
 		REG_SET_BIT(ah, AR_BTCOEX_WL_LNADIV,
diff --git a/drivers/net/wireless/ath/ath9k/debug.c b/drivers/net/wireless/ath/ath9k/debug.c
index e1041a6..e290d57 100644
--- a/drivers/net/wireless/ath/ath9k/debug.c
+++ b/drivers/net/wireless/ath/ath9k/debug.c
@@ -222,6 +222,54 @@ static const struct file_operations fops_disable_ani = {
 	.llseek = default_llseek,
 };
 
+static ssize_t read_file_ant_diversity(struct file *file, char __user *user_buf,
+				       size_t count, loff_t *ppos)
+{
+	struct ath_softc *sc = file->private_data;
+	struct ath_common *common = ath9k_hw_common(sc->sc_ah);
+	char buf[32];
+	unsigned int len;
+
+	len = sprintf(buf, "%d\n", common->antenna_diversity);
+	return simple_read_from_buffer(user_buf, count, ppos, buf, len);
+}
+
+static ssize_t write_file_ant_diversity(struct file *file,
+					const char __user *user_buf,
+					size_t count, loff_t *ppos)
+{
+	struct ath_softc *sc = file->private_data;
+	struct ath_common *common = ath9k_hw_common(sc->sc_ah);
+	unsigned long antenna_diversity;
+	char buf[32];
+	ssize_t len;
+
+	len = min(count, sizeof(buf) - 1);
+	if (copy_from_user(buf, user_buf, len))
+		return -EFAULT;
+
+	buf[len] = '\0';
+	if (strict_strtoul(buf, 0, &antenna_diversity))
+		return -EINVAL;
+
+	common->antenna_diversity = !!antenna_diversity;
+	ath9k_ps_wakeup(sc);
+	ath_ant_comb_update(sc);
+	ath_dbg(common, CONFIG, "Antenna diversity: %d\n",
+		common->antenna_diversity);
+	ath9k_ps_restore(sc);
+
+	return count;
+}
+
+static const struct file_operations fops_ant_diversity = {
+	.read = read_file_ant_diversity,
+	.write = write_file_ant_diversity,
+	.open = simple_open,
+	.owner = THIS_MODULE,
+	.llseek = default_llseek,
+};
+
 static ssize_t read_file_dma(struct file *file, char __user *user_buf,
 			     size_t count, loff_t *ppos)
 {
@@ -1601,12 +1649,12 @@ int ath9k_init_debug(struct ath_hw *ah)
 	debugfs_create_file("samples", S_IRUSR, sc->debug.debugfs_phy, sc,
 			    &fops_samps);
 #endif
-
 	debugfs_create_u32("gpio_mask", S_IRUSR | S_IWUSR,
 			   sc->debug.debugfs_phy, &sc->sc_ah->gpio_mask);
-
 	debugfs_create_u32("gpio_val", S_IRUSR | S_IWUSR,
 			   sc->debug.debugfs_phy, &sc->sc_ah->gpio_val);
+	debugfs_create_file("diversity", S_IRUSR | S_IWUSR,
+			    sc->debug.debugfs_phy, sc, &fops_ant_diversity);
 
 	return 0;
 }
-- 
1.7.12


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH 2/2] ath9k: Add a debugfs file to adjust antenna diversity
  2012-09-21  7:01 [PATCH 2/2] ath9k: Add a debugfs file to adjust antenna diversity Sujith Manoharan
@ 2012-09-21 14:28 ` Ben Greear
  2012-09-21 16:40   ` Sujith Manoharan
  0 siblings, 1 reply; 5+ messages in thread
From: Ben Greear @ 2012-09-21 14:28 UTC (permalink / raw)
  To: Sujith Manoharan; +Cc: linville, linux-wireless

On 09/21/2012 12:01 AM, Sujith Manoharan wrote:
> Location: /<debugfs>/ieee80211/phy#/ath9k/diversity

Can you document what the various settings mean?

Also, what is the difference between antenna diversity
and selecting the tx/rx chainmask?

Thanks,
Ben

-- 
Ben Greear <greearb@candelatech.com>
Candela Technologies Inc  http://www.candelatech.com



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 2/2] ath9k: Add a debugfs file to adjust antenna diversity
  2012-09-21 14:28 ` Ben Greear
@ 2012-09-21 16:40   ` Sujith Manoharan
  2012-09-21 18:16     ` Ben Greear
  0 siblings, 1 reply; 5+ messages in thread
From: Sujith Manoharan @ 2012-09-21 16:40 UTC (permalink / raw)
  To: Ben Greear; +Cc: Sujith Manoharan, linville, linux-wireless

Ben Greear wrote:
> Can you document what the various settings mean?

1 = Enable, 0 = Disable. :)

> Also, what is the difference between antenna diversity
> and selecting the tx/rx chainmask?

Diversity is used to select which antenna to receive on based on RSSI.
(See antenna.c)

Sujith

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 2/2] ath9k: Add a debugfs file to adjust antenna diversity
  2012-09-21 16:40   ` Sujith Manoharan
@ 2012-09-21 18:16     ` Ben Greear
  2012-09-21 18:22       ` Sujith Manoharan
  0 siblings, 1 reply; 5+ messages in thread
From: Ben Greear @ 2012-09-21 18:16 UTC (permalink / raw)
  To: Sujith Manoharan; +Cc: linville, linux-wireless

On 09/21/2012 09:40 AM, Sujith Manoharan wrote:
> Ben Greear wrote:
>> Can you document what the various settings mean?
>
> 1 = Enable, 0 = Disable. :)
>
>> Also, what is the difference between antenna diversity
>> and selecting the tx/rx chainmask?
>
> Diversity is used to select which antenna to receive on based on RSSI.
> (See antenna.c)

Ok, that sounds interesting.

With the chainmask stuff, it turns out it was bad to set it through
debugfs...  Can diversity be enabled/disabled through debugfs
without worry?

Thanks,
Ben


-- 
Ben Greear <greearb@candelatech.com>
Candela Technologies Inc  http://www.candelatech.com


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 2/2] ath9k: Add a debugfs file to adjust antenna diversity
  2012-09-21 18:16     ` Ben Greear
@ 2012-09-21 18:22       ` Sujith Manoharan
  0 siblings, 0 replies; 5+ messages in thread
From: Sujith Manoharan @ 2012-09-21 18:22 UTC (permalink / raw)
  To: Ben Greear; +Cc: Sujith Manoharan, linville, linux-wireless

Ben Greear wrote:
> Ok, that sounds interesting.
> 
> With the chainmask stuff, it turns out it was bad to set it through
> debugfs...  Can diversity be enabled/disabled through debugfs
> without worry?

I'll send a v2 with various checks to allow tweaking diversity
only when the chipset supports it etc. :)

Sujith

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2012-09-21 18:24 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-09-21  7:01 [PATCH 2/2] ath9k: Add a debugfs file to adjust antenna diversity Sujith Manoharan
2012-09-21 14:28 ` Ben Greear
2012-09-21 16:40   ` Sujith Manoharan
2012-09-21 18:16     ` Ben Greear
2012-09-21 18:22       ` Sujith Manoharan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).