Commit 8d98c153 authored by Lorenzo Bianconi's avatar Lorenzo Bianconi Committed by Felix Fietkau

mt76x0: eeprom: load eeprom data from mtd by default

Read eeprom data from mtd memory by default and fall-back
to efuse if it fails
Signed-off-by: default avatarLorenzo Bianconi <lorenzo.bianconi@redhat.com>
Signed-off-by: default avatarFelix Fietkau <nbd@nbd.name>
parent 188fd8c4
...@@ -277,24 +277,54 @@ void mt76x0_get_power_info(struct mt76x0_dev *dev, u8 *info) ...@@ -277,24 +277,54 @@ void mt76x0_get_power_info(struct mt76x0_dev *dev, u8 *info)
info[1] = 5; info[1] = 5;
} }
int mt76x0_eeprom_init(struct mt76x0_dev *dev) static int mt76x0_check_eeprom(struct mt76x0_dev *dev)
{ {
u8 version, fae; u16 val;
u16 data;
int ret;
ret = mt76x0_efuse_physical_size_check(dev); val = get_unaligned_le16(dev->mt76.eeprom.data);
if (ret) if (!val)
return ret; val = get_unaligned_le16(dev->mt76.eeprom.data +
MT_EE_PCI_ID);
ret = mt76_eeprom_init(&dev->mt76, MT76X0_EEPROM_SIZE); switch (val) {
if (ret < 0) case 0x7650:
return ret; case 0x7610:
return 0;
default:
dev_err(dev->mt76.dev, "EEPROM data check failed: %04x\n",
val);
return -EINVAL;
}
}
static int mt76x0_load_eeprom(struct mt76x0_dev *dev)
{
int found;
ret = mt76x02_get_efuse_data(&dev->mt76, 0, dev->mt76.eeprom.data, found = mt76_eeprom_init(&dev->mt76, MT76X0_EEPROM_SIZE);
if (found < 0)
return found;
if (found && !mt76x0_check_eeprom(dev))
return 0;
found = mt76x0_efuse_physical_size_check(dev);
if (found < 0)
return found;
return mt76x02_get_efuse_data(&dev->mt76, 0, dev->mt76.eeprom.data,
MT76X0_EEPROM_SIZE, MT_EE_READ); MT76X0_EEPROM_SIZE, MT_EE_READ);
if (ret) }
return ret;
int mt76x0_eeprom_init(struct mt76x0_dev *dev)
{
u8 version, fae;
u16 data;
int err;
err = mt76x0_load_eeprom(dev);
if (err < 0)
return err;
data = mt76x02_eeprom_get(&dev->mt76, MT_EE_VERSION); data = mt76x02_eeprom_get(&dev->mt76, MT_EE_VERSION);
version = data >> 8; version = data >> 8;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment