2021-03-17 16:30:52

by Ryder Lee

[permalink] [raw]
Subject: [PATCH] mt76: mt7622: add ePA/eLNA support

Switch pinmux to enable ePA/eLNA support.

Signed-off-by: Ryder Lee <[email protected]>
---
.../wireless/mediatek/mt76/mt7615/eeprom.c | 29 +++++++++++++++++++
.../wireless/mediatek/mt76/mt7615/eeprom.h | 4 +++
2 files changed, 33 insertions(+)

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,
--
2.18.0