diff mbox series

mt76: mt7622: add ePA/eLNA support

Message ID 1fb0ff65cb7d8c4f3197a87b43c26c5925e973ea.1615997929.git.ryder.lee@mediatek.com (mailing list archive)
State Rejected
Delegated to: Felix Fietkau
Headers show
Series mt76: mt7622: add ePA/eLNA support | expand

Commit Message

Ryder Lee March 17, 2021, 4:27 p.m. UTC
Switch pinmux to enable ePA/eLNA support.

Signed-off-by: Ryder Lee <ryder.lee@mediatek.com>
---
 .../wireless/mediatek/mt76/mt7615/eeprom.c    | 29 +++++++++++++++++++
 .../wireless/mediatek/mt76/mt7615/eeprom.h    |  4 +++
 2 files changed, 33 insertions(+)
diff mbox series

Patch

diff --git a/drivers/net/wireless/mediatek/mt76/mt7615/eeprom.c b/drivers/net/wireless/mediatek/mt76/mt7615/eeprom.c
index 6dbaaf95ee38..d3182573163c 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7615/eeprom.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7615/eeprom.c
@@ -6,6 +6,7 @@ 
  */
 
 #include <linux/of.h>
+#include <linux/pinctrl/consumer.h>
 #include "mt7615.h"
 #include "eeprom.h"
 
@@ -136,12 +137,40 @@  mt7615_eeprom_parse_hw_band_cap(struct mt7615_dev *dev)
 	}
 }
 
+static void mt7615_eeprom_parse_hw_epa_cap(struct mt7615_dev *dev)
+{
+	struct pinctrl_state *state;
+	struct pinctrl *pinctrl;
+	u8 i, *eeprom = dev->mt76.eeprom.data;
+
+	if (!is_mt7622(&dev->mt76))
+		return;
+
+	i = FIELD_GET(MT_EE_NIC_WIFI_CONF_BAND_PALNA, eeprom[MT_EE_WIFI_CONF]);
+	if (i != MT_EE_NIC_WIFI_CONF_EPA_ELNA &&
+	    i != MT_EE_NIC_WIFI_CONF_IPA_ELNA)
+		return;
+
+	pinctrl = devm_pinctrl_get(dev->mt76.dev);
+	if (IS_ERR(pinctrl))
+		return;
+
+	state = pinctrl_lookup_state(pinctrl, "epa-state");
+	if (IS_ERR(state))
+		goto out;
+
+	pinctrl_select_state(pinctrl, state);
+out:
+	devm_pinctrl_put(pinctrl);
+}
+
 static void mt7615_eeprom_parse_hw_cap(struct mt7615_dev *dev)
 {
 	u8 *eeprom = dev->mt76.eeprom.data;
 	u8 tx_mask, max_nss;
 
 	mt7615_eeprom_parse_hw_band_cap(dev);
+	mt7615_eeprom_parse_hw_epa_cap(dev);
 
 	if (is_mt7663(&dev->mt76)) {
 		max_nss = 2;
diff --git a/drivers/net/wireless/mediatek/mt76/mt7615/eeprom.h b/drivers/net/wireless/mediatek/mt76/mt7615/eeprom.h
index a024dee10362..a609c4bb108c 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7615/eeprom.h
+++ b/drivers/net/wireless/mediatek/mt76/mt7615/eeprom.h
@@ -64,7 +64,11 @@  enum mt7615_eeprom_field {
 #define MT_EE_NIC_CONF_TSSI_2G			BIT(5)
 #define MT_EE_NIC_CONF_TSSI_5G			BIT(6)
 
+#define MT_EE_NIC_WIFI_CONF_BAND_PALNA		GENMASK(3, 2)
+#define MT_EE_NIC_WIFI_CONF_IPA_ELNA		0x1
+#define MT_EE_NIC_WIFI_CONF_EPA_ELNA		0x2
 #define MT_EE_NIC_WIFI_CONF_BAND_SEL		GENMASK(5, 4)
+
 enum mt7615_eeprom_band {
 	MT_EE_DUAL_BAND,
 	MT_EE_5GHZ,