2019-05-17 21:41:13

by Lorenzo Bianconi

[permalink] [raw]
Subject: [PATCH] mt76: mt7615: select wifi band according to eeprom

Select supported band according to the value read from
eeprom mtd/otp partition

Signed-off-by: Lorenzo Bianconi <[email protected]>
---
.../wireless/mediatek/mt76/mt7615/eeprom.c | 24 ++++++++++++++++---
.../wireless/mediatek/mt76/mt7615/eeprom.h | 9 +++++++
2 files changed, 30 insertions(+), 3 deletions(-)

diff --git a/drivers/net/wireless/mediatek/mt76/mt7615/eeprom.c b/drivers/net/wireless/mediatek/mt76/mt7615/eeprom.c
index 1712f66520a8..714590878d65 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7615/eeprom.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7615/eeprom.c
@@ -90,6 +90,26 @@ static int mt7615_check_eeprom(struct mt76_dev *dev)
}
}

+static void mt7615_eeprom_parse_hw_cap(struct mt7615_dev *dev)
+{
+ u8 val, *eeprom = dev->mt76.eeprom.data;
+
+ val = FIELD_GET(MT_EE_NIC_WIFI_CONF_BAND_SEL,
+ eeprom[MT_EE_WIFI_CONF]);
+ switch (val) {
+ case MT_EE_5GHZ:
+ dev->mt76.cap.has_5ghz = true;
+ break;
+ case MT_EE_2GHZ:
+ dev->mt76.cap.has_2ghz = true;
+ break;
+ default:
+ dev->mt76.cap.has_2ghz = true;
+ dev->mt76.cap.has_5ghz = true;
+ break;
+ }
+}
+
int mt7615_eeprom_init(struct mt7615_dev *dev)
{
int ret;
@@ -103,9 +123,7 @@ int mt7615_eeprom_init(struct mt7615_dev *dev)
memcpy(dev->mt76.eeprom.data, dev->mt76.otp.data,
MT7615_EEPROM_SIZE);

- dev->mt76.cap.has_2ghz = true;
- dev->mt76.cap.has_5ghz = true;
-
+ mt7615_eeprom_parse_hw_cap(dev);
memcpy(dev->mt76.macaddr, dev->mt76.eeprom.data + MT_EE_MAC_ADDR,
ETH_ALEN);

diff --git a/drivers/net/wireless/mediatek/mt76/mt7615/eeprom.h b/drivers/net/wireless/mediatek/mt76/mt7615/eeprom.h
index a4cf16688171..b422e395d6ee 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7615/eeprom.h
+++ b/drivers/net/wireless/mediatek/mt76/mt7615/eeprom.h
@@ -11,8 +11,17 @@ enum mt7615_eeprom_field {
MT_EE_VERSION = 0x002,
MT_EE_MAC_ADDR = 0x004,
MT_EE_NIC_CONF_0 = 0x034,
+ MT_EE_WIFI_CONF = 0x03e,

__MT_EE_MAX = 0x3bf
};

+#define MT_EE_NIC_WIFI_CONF_BAND_SEL GENMASK(5, 4)
+enum mt7615_eeprom_band {
+ MT_EE_DUAL_BAND,
+ MT_EE_5GHZ,
+ MT_EE_2GHZ,
+ MT_EE_DBDC,
+};
+
#endif
--
2.20.1


2019-05-17 21:42:03

by Lorenzo Bianconi

[permalink] [raw]
Subject: Re: [PATCH] mt76: mt7615: select wifi band according to eeprom

>
> Select supported band according to the value read from
> eeprom mtd/otp partition
>

I forgot to mention this patch is based on 'mt76: mt7615: add support
for mtd eeprom parsing'
https://patchwork.kernel.org/patch/10947385/

Regards,
Lorenzo

> Signed-off-by: Lorenzo Bianconi <[email protected]>
> ---
> .../wireless/mediatek/mt76/mt7615/eeprom.c | 24 ++++++++++++++++---
> .../wireless/mediatek/mt76/mt7615/eeprom.h | 9 +++++++
> 2 files changed, 30 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/net/wireless/mediatek/mt76/mt7615/eeprom.c b/drivers/net/wireless/mediatek/mt76/mt7615/eeprom.c
> index 1712f66520a8..714590878d65 100644
> --- a/drivers/net/wireless/mediatek/mt76/mt7615/eeprom.c
> +++ b/drivers/net/wireless/mediatek/mt76/mt7615/eeprom.c
> @@ -90,6 +90,26 @@ static int mt7615_check_eeprom(struct mt76_dev *dev)
> }
> }
>
> +static void mt7615_eeprom_parse_hw_cap(struct mt7615_dev *dev)
> +{
> + u8 val, *eeprom = dev->mt76.eeprom.data;
> +
> + val = FIELD_GET(MT_EE_NIC_WIFI_CONF_BAND_SEL,
> + eeprom[MT_EE_WIFI_CONF]);
> + switch (val) {
> + case MT_EE_5GHZ:
> + dev->mt76.cap.has_5ghz = true;
> + break;
> + case MT_EE_2GHZ:
> + dev->mt76.cap.has_2ghz = true;
> + break;
> + default:
> + dev->mt76.cap.has_2ghz = true;
> + dev->mt76.cap.has_5ghz = true;
> + break;
> + }
> +}
> +
> int mt7615_eeprom_init(struct mt7615_dev *dev)
> {
> int ret;
> @@ -103,9 +123,7 @@ int mt7615_eeprom_init(struct mt7615_dev *dev)
> memcpy(dev->mt76.eeprom.data, dev->mt76.otp.data,
> MT7615_EEPROM_SIZE);
>
> - dev->mt76.cap.has_2ghz = true;
> - dev->mt76.cap.has_5ghz = true;
> -
> + mt7615_eeprom_parse_hw_cap(dev);
> memcpy(dev->mt76.macaddr, dev->mt76.eeprom.data + MT_EE_MAC_ADDR,
> ETH_ALEN);
>
> diff --git a/drivers/net/wireless/mediatek/mt76/mt7615/eeprom.h b/drivers/net/wireless/mediatek/mt76/mt7615/eeprom.h
> index a4cf16688171..b422e395d6ee 100644
> --- a/drivers/net/wireless/mediatek/mt76/mt7615/eeprom.h
> +++ b/drivers/net/wireless/mediatek/mt76/mt7615/eeprom.h
> @@ -11,8 +11,17 @@ enum mt7615_eeprom_field {
> MT_EE_VERSION = 0x002,
> MT_EE_MAC_ADDR = 0x004,
> MT_EE_NIC_CONF_0 = 0x034,
> + MT_EE_WIFI_CONF = 0x03e,
>
> __MT_EE_MAX = 0x3bf
> };
>
> +#define MT_EE_NIC_WIFI_CONF_BAND_SEL GENMASK(5, 4)
> +enum mt7615_eeprom_band {
> + MT_EE_DUAL_BAND,
> + MT_EE_5GHZ,
> + MT_EE_2GHZ,
> + MT_EE_DBDC,
> +};
> +
> #endif
> --
> 2.20.1
>

2019-06-07 18:52:52

by Felix Fietkau

[permalink] [raw]
Subject: Re: [PATCH] mt76: mt7615: select wifi band according to eeprom

On 2019-05-17 23:32, Lorenzo Bianconi wrote:
> Select supported band according to the value read from
> eeprom mtd/otp partition
>
> Signed-off-by: Lorenzo Bianconi <[email protected]>

Applied, thanks.

- Felix