public inbox for linux-wireless@vger.kernel.org
 help / color / mirror / Atom feed
From: Masi Osmani <mas-i@hotmail.de>
To: Christian Lamparter <chunkeey@googlemail.com>
Cc: linux-wireless@vger.kernel.org, Masi Osmani <mas-i@hotmail.de>,
	ath9k-devel@qca.qualcomm.com
Subject: [PATCH 08/10] carl9170: phy: enable antenna diversity for 2-chain devices
Date: Thu, 12 Mar 2026 11:38:03 +0100	[thread overview]
Message-ID: <AM7PPF5613FA0B6344DB5885359FAFC80D69444A@AM7PPF5613FA0B6.EURP251.PROD.OUTLOOK.COM> (raw)
In-Reply-To: <cover.1773277728.git.mas-i@hotmail.de>

Enable fast antenna diversity on devices with two RX chains
(rx_mask == 3).  This programs the MULTICHAIN_GAIN_CTL register
to configure main/alternate LNA settings and enables the
CCK fast antenna diversity bit.

The AR9170 hardware has antenna diversity registers inherited
from the AR9285/AR9287 family, but the carl9170 driver never
programmed them.  For dual-chain devices this improves receive
performance in multipath environments by allowing the baseband
to quickly switch between antenna paths.

The diversity configuration mirrors what ath9k uses for the
AR9285 single-chip design:
- Main LNA: LNA1
- Alt LNA: LNA1+LNA2 (combined)
- Gain table: table 0 for both paths

Signed-off-by: Masi Osmani <mas-i@hotmail.de>
---
 drivers/net/wireless/ath/carl9170/phy.c | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/drivers/net/wireless/ath/carl9170/phy.c b/drivers/net/wireless/ath/carl9170/phy.c
index 290c336..bcd9066 100644
--- a/drivers/net/wireless/ath/carl9170/phy.c
+++ b/drivers/net/wireless/ath/carl9170/phy.c
@@ -536,6 +536,31 @@ static int carl9170_init_phy_from_eeprom(struct ar9170 *ar,
 	carl9170_regwrite(AR9170_PHY_REG_RX_CHAINMASK, ar->eeprom.rx_mask);
 	carl9170_regwrite(AR9170_PHY_REG_CAL_CHAINMASK, ar->eeprom.rx_mask);
 
+	/*
+	 * Enable fast antenna diversity for 2-chain devices.
+	 * Configure main/alt LNA with both chains for best
+	 * multipath performance.
+	 */
+	if (ar->eeprom.rx_mask == 3) {
+		val = carl9170_def_val(AR9170_PHY_REG_MULTICHAIN_GAIN_CTL,
+				       is_2ghz, is_40mhz);
+		val |= AR9170_PHY_9285_ANT_DIV_CTL;
+		SET_VAL(AR9170_PHY_9285_ANT_DIV_ALT_LNACONF, val,
+			AR9170_PHY_9285_ANT_DIV_LNA1_PLUS_LNA2);
+		SET_VAL(AR9170_PHY_9285_ANT_DIV_MAIN_LNACONF, val,
+			AR9170_PHY_9285_ANT_DIV_LNA1);
+		SET_VAL(AR9170_PHY_9285_ANT_DIV_ALT_GAINTB, val,
+			AR9170_PHY_9285_ANT_DIV_GAINTB_0);
+		SET_VAL(AR9170_PHY_9285_ANT_DIV_MAIN_GAINTB, val,
+			AR9170_PHY_9285_ANT_DIV_GAINTB_0);
+		carl9170_regwrite(AR9170_PHY_REG_MULTICHAIN_GAIN_CTL, val);
+
+		val = carl9170_def_val(AR9170_PHY_REG_CCK_DETECT,
+				       is_2ghz, is_40mhz);
+		val |= AR9170_PHY_CCK_DETECT_BB_ENABLE_ANT_FAST_DIV;
+		carl9170_regwrite(AR9170_PHY_REG_CCK_DETECT, val);
+	}
+
 	carl9170_regwrite_finish();
 	return carl9170_regwrite_result();
 }
-- 
2.51.0


  parent reply	other threads:[~2026-03-12 10:38 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <cover.1773277728.git.mas-i@hotmail.de>
2026-03-12 10:37 ` [PATCH 01/10] carl9170: mac80211: enable Short Guard Interval for 20 MHz Masi Osmani
2026-03-21 18:41   ` Christian Lamparter
2026-03-12 10:37 ` [PATCH 02/10] carl9170: mac80211: advertise RX STBC capability Masi Osmani
2026-03-21 18:47   ` Christian Lamparter
2026-03-12 10:37 ` [PATCH 03/10] carl9170: mac80211: document spatial multiplexing power save handler Masi Osmani
2026-03-21 18:57   ` Christian Lamparter
2026-03-12 10:37 ` [PATCH 04/10] carl9170: rx: wire up dropped frame counter Masi Osmani
2026-03-21 19:03   ` Christian Lamparter
2026-03-12 10:38 ` [PATCH 05/10] carl9170: rx: track PHY errors via debugfs Masi Osmani
2026-03-21 20:29   ` Christian Lamparter
2026-03-12 10:38 ` [PATCH 06/10] carl9170: phy: populate per-channel TX power from EEPROM Masi Osmani
2026-03-21 19:24   ` Christian Lamparter
2026-03-12 10:38 ` [PATCH 07/10] carl9170: main: add exponential restart backoff Masi Osmani
2026-03-21 20:42   ` Christian Lamparter
2026-03-12 10:38 ` Masi Osmani [this message]
2026-03-21 19:53   ` [PATCH 08/10] carl9170: phy: enable antenna diversity for 2-chain devices Christian Lamparter
2026-03-12 10:38 ` [PATCH 09/10] carl9170: fw: enable DFS radar detection Masi Osmani
2026-03-21 20:11   ` Christian Lamparter
2026-03-12 10:38 ` [PATCH 10/10] carl9170: phy: add periodic runtime IQ calibration Masi Osmani
2026-03-21 21:25   ` Christian Lamparter

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=AM7PPF5613FA0B6344DB5885359FAFC80D69444A@AM7PPF5613FA0B6.EURP251.PROD.OUTLOOK.COM \
    --to=mas-i@hotmail.de \
    --cc=ath9k-devel@qca.qualcomm.com \
    --cc=chunkeey@googlemail.com \
    --cc=linux-wireless@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox