* [PATCH] mt76: mt7615: add preliminary support for mtd eeprom parsing
[not found] <cover.1557853278.git.lorenzo@kernel.org>
@ 2019-05-14 17:11 ` Lorenzo Bianconi
2019-05-16 17:03 ` Lorenzo Bianconi
0 siblings, 1 reply; 2+ messages in thread
From: Lorenzo Bianconi @ 2019-05-14 17:11 UTC (permalink / raw)
To: nbd; +Cc: lorenzo.bianconi, linux-wireless, ryder.lee, royluo
Calibration data are often available on a specific mtd partition on
embedded devices. Take into account eeprom calibration data if
available. Calibration free data parsing is currently missing
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
---
.../wireless/mediatek/mt76/mt7615/eeprom.c | 32 +++++++++++++++----
1 file changed, 26 insertions(+), 6 deletions(-)
diff --git a/drivers/net/wireless/mediatek/mt76/mt7615/eeprom.c b/drivers/net/wireless/mediatek/mt76/mt7615/eeprom.c
index dd5ab46a4f66..0313c604ea61 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7615/eeprom.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7615/eeprom.c
@@ -42,13 +42,13 @@ static int mt7615_efuse_read(struct mt7615_dev *dev, u32 base,
static int mt7615_efuse_init(struct mt7615_dev *dev)
{
- u32 base = mt7615_reg_map(dev, MT_EFUSE_BASE);
- int len = MT7615_EEPROM_SIZE;
- int ret, i;
+ u32 val, base = mt7615_reg_map(dev, MT_EFUSE_BASE);
+ int i, len = MT7615_EEPROM_SIZE;
void *buf;
- if (mt76_rr(dev, base + MT_EFUSE_BASE_CTRL) & MT_EFUSE_BASE_CTRL_EMPTY)
- return -EINVAL;
+ val = mt76_rr(dev, base + MT_EFUSE_BASE_CTRL);
+ if (val & MT_EFUSE_BASE_CTRL_EMPTY)
+ return 0;
dev->mt76.otp.data = devm_kzalloc(dev->mt76.dev, len, GFP_KERNEL);
dev->mt76.otp.size = len;
@@ -57,6 +57,8 @@ static int mt7615_efuse_init(struct mt7615_dev *dev)
buf = dev->mt76.otp.data;
for (i = 0; i + 16 <= len; i += 16) {
+ int ret;
+
ret = mt7615_efuse_read(dev, base, i, buf + i);
if (ret)
return ret;
@@ -76,6 +78,18 @@ static int mt7615_eeprom_load(struct mt7615_dev *dev)
return mt7615_efuse_init(dev);
}
+static int mt7615_check_eeprom(struct mt76_dev *dev)
+{
+ u16 val = get_unaligned_le16(dev->eeprom.data);
+
+ switch (val) {
+ case 0x7615:
+ return 0;
+ default:
+ return -EINVAL;
+ }
+}
+
int mt7615_eeprom_init(struct mt7615_dev *dev)
{
int ret;
@@ -84,7 +98,13 @@ int mt7615_eeprom_init(struct mt7615_dev *dev)
if (ret < 0)
return ret;
- memcpy(dev->mt76.eeprom.data, dev->mt76.otp.data, MT7615_EEPROM_SIZE);
+ if (dev->mt76.otp.data) {
+ ret = mt7615_check_eeprom(&dev->mt76);
+ if (ret < 0)
+ memcpy(dev->mt76.eeprom.data, dev->mt76.otp.data,
+ MT7615_EEPROM_SIZE);
+ /* TODO: take into account cal free data */
+ }
dev->mt76.cap.has_2ghz = true;
dev->mt76.cap.has_5ghz = true;
--
2.20.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] mt76: mt7615: add preliminary support for mtd eeprom parsing
2019-05-14 17:11 ` [PATCH] mt76: mt7615: add preliminary support for mtd eeprom parsing Lorenzo Bianconi
@ 2019-05-16 17:03 ` Lorenzo Bianconi
0 siblings, 0 replies; 2+ messages in thread
From: Lorenzo Bianconi @ 2019-05-16 17:03 UTC (permalink / raw)
To: Lorenzo Bianconi; +Cc: nbd, linux-wireless, ryder.lee, royluo
[-- Attachment #1: Type: text/plain, Size: 1422 bytes --]
> Calibration data are often available on a specific mtd partition on
> embedded devices. Take into account eeprom calibration data if
> available. Calibration free data parsing is currently missing
>
> Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
> ---
> .../wireless/mediatek/mt76/mt7615/eeprom.c | 32 +++++++++++++++----
> 1 file changed, 26 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/net/wireless/mediatek/mt76/mt7615/eeprom.c b/drivers/net/wireless/mediatek/mt76/mt7615/eeprom.c
> index dd5ab46a4f66..0313c604ea61 100644
> --- a/drivers/net/wireless/mediatek/mt76/mt7615/eeprom.c
> +++ b/drivers/net/wireless/mediatek/mt76/mt7615/eeprom.c
[...]
> int mt7615_eeprom_init(struct mt7615_dev *dev)
> {
> int ret;
> @@ -84,7 +98,13 @@ int mt7615_eeprom_init(struct mt7615_dev *dev)
> if (ret < 0)
> return ret;
>
> - memcpy(dev->mt76.eeprom.data, dev->mt76.otp.data, MT7615_EEPROM_SIZE);
> + if (dev->mt76.otp.data) {
> + ret = mt7615_check_eeprom(&dev->mt76);
> + if (ret < 0)
> + memcpy(dev->mt76.eeprom.data, dev->mt76.otp.data,
> + MT7615_EEPROM_SIZE);
> + /* TODO: take into account cal free data */
reviewing sdk code it seems we do not have cal free data here, I will post a v2
removing the comment
Regards,
Lorenzo
> + }
>
> dev->mt76.cap.has_2ghz = true;
> dev->mt76.cap.has_5ghz = true;
> --
> 2.20.1
>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2019-05-16 17:03 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <cover.1557853278.git.lorenzo@kernel.org>
2019-05-14 17:11 ` [PATCH] mt76: mt7615: add preliminary support for mtd eeprom parsing Lorenzo Bianconi
2019-05-16 17:03 ` Lorenzo Bianconi
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).