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)
info[1] = 5;
}
int mt76x0_eeprom_init(struct mt76x0_dev *dev)
static int mt76x0_check_eeprom(struct mt76x0_dev *dev)
{
u8 version, fae;
u16 data;
int ret;
u16 val;
ret = mt76x0_efuse_physical_size_check(dev);
if (ret)
return ret;
val = get_unaligned_le16(dev->mt76.eeprom.data);
if (!val)
val = get_unaligned_le16(dev->mt76.eeprom.data +
MT_EE_PCI_ID);
ret = mt76_eeprom_init(&dev->mt76, MT76X0_EEPROM_SIZE);
if (ret < 0)
return ret;
switch (val) {
case 0x7650:
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);
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);
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