@@ -24,8 +24,7 @@
#include "../mt76x02_phy.h"
#define MT_MAP_READS DIV_ROUND_UP(MT_EFUSE_USAGE_MAP_SIZE, 16)
-static int
-mt76x0_efuse_physical_size_check(struct mt76x0_dev *dev)
+int mt76x0_efuse_physical_size_check(struct mt76x0_dev *dev)
{
u8 data[MT_MAP_READS * 16];
int ret, i;
@@ -52,6 +51,7 @@ mt76x0_efuse_physical_size_check(struct mt76x0_dev *dev)
return 0;
}
+EXPORT_SYMBOL_GPL(mt76x0_efuse_physical_size_check);
static void mt76x0_set_chip_cap(struct mt76x0_dev *dev)
{
@@ -281,20 +281,6 @@ int mt76x0_eeprom_init(struct mt76x0_dev *dev)
{
u8 version, fae;
u16 data;
- int ret;
-
- ret = mt76x0_efuse_physical_size_check(dev);
- if (ret)
- return ret;
-
- ret = mt76_eeprom_init(&dev->mt76, MT76X0_EEPROM_SIZE);
- if (ret < 0)
- return ret;
-
- ret = mt76x02_get_efuse_data(&dev->mt76, 0, dev->mt76.eeprom.data,
- MT76X0_EEPROM_SIZE, MT_EE_READ);
- if (ret)
- return ret;
data = mt76x02_eeprom_get(&dev->mt76, MT_EE_VERSION);
version = data >> 8;
@@ -317,5 +303,6 @@ int mt76x0_eeprom_init(struct mt76x0_dev *dev)
return 0;
}
+EXPORT_SYMBOL_GPL(mt76x0_eeprom_init);
MODULE_LICENSE("Dual BSD/GPL");
@@ -35,6 +35,7 @@ int mt76x0_eeprom_init(struct mt76x0_dev *dev);
void mt76x0_read_rx_gain(struct mt76x0_dev *dev);
void mt76x0_get_tx_power_per_rate(struct mt76x0_dev *dev);
void mt76x0_get_power_info(struct mt76x0_dev *dev, u8 *info);
+int mt76x0_efuse_physical_size_check(struct mt76x0_dev *dev);
static inline s8 s6_to_s8(u32 val)
{
@@ -329,11 +329,6 @@ int mt76x0_init_hardware(struct mt76x0_dev *dev)
}
mt76x0_reset_counters(dev);
-
- ret = mt76x0_eeprom_init(dev);
- if (ret)
- return ret;
-
mt76x0_phy_init(dev);
return 0;
@@ -66,6 +66,17 @@ const struct ieee80211_ops mt76x0e_ops = {
.configure_filter = mt76x02_configure_filter,
};
+static int mt76x0e_eeprom_init(struct mt76x0_dev *dev)
+{
+ int err;
+
+ err = mt76x02_eeprom_load(&dev->mt76, MT76X0_EEPROM_SIZE);
+ if (err < 0)
+ return err;
+
+ return mt76x0_eeprom_init(dev);
+}
+
int mt76x0e_register_device(struct mt76x0_dev *dev)
{
int err;
@@ -79,6 +90,10 @@ int mt76x0e_register_device(struct mt76x0_dev *dev)
if (err < 0)
return err;
+ err = mt76x0e_eeprom_init(dev);
+ if (err < 0)
+ return err;
+
err = mt76x02_dma_init(&dev->mt76);
if (err < 0)
return err;
@@ -120,6 +120,26 @@ void mt76x0u_cleanup(struct mt76x0_dev *dev)
mt76u_mcu_deinit(&dev->mt76);
}
+static int mt76x0u_eeprom_init(struct mt76x0_dev *dev)
+{
+ int err;
+
+ err = mt76x0_efuse_physical_size_check(dev);
+ if (err < 0)
+ return err;
+
+ err = mt76_eeprom_init(&dev->mt76, MT76X0_EEPROM_SIZE);
+ if (err < 0)
+ return err;
+
+ err = mt76x02_get_efuse_data(&dev->mt76, 0, dev->mt76.eeprom.data,
+ MT76X0_EEPROM_SIZE, MT_EE_READ);
+ if (err < 0)
+ return err;
+
+ return mt76x0_eeprom_init(dev);
+}
+
int mt76x0u_register_device(struct mt76x0_dev *dev)
{
struct ieee80211_hw *hw = dev->mt76.hw;
@@ -139,6 +159,10 @@ int mt76x0u_register_device(struct mt76x0_dev *dev)
goto err;
}
+ err = mt76x0u_eeprom_init(dev);
+ if (err < 0)
+ return err;
+
err = mt76x0u_mcu_init(dev);
if (err < 0)
goto err;
@@ -259,6 +259,8 @@ static int mt76x02_check_eeprom(struct mt76_dev *dev)
switch (val) {
case 0x7662:
case 0x7612:
+ case 0x7650:
+ case 0x7610:
return 0;
default:
dev_err(dev->dev, "EEPROM data check failed: %04x\n", val);
Add mt76x0e_eeprom_init/mt76x0u_eeprom_init routines to initialize pci/usb eeprom and move eeprom init shared code between pci and usb drivers in mt76x0_eeprom_init Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com> --- .../wireless/mediatek/mt76/mt76x0/eeprom.c | 19 +++------------ .../wireless/mediatek/mt76/mt76x0/eeprom.h | 1 + .../net/wireless/mediatek/mt76/mt76x0/init.c | 5 ---- .../wireless/mediatek/mt76/mt76x0/pci_init.c | 15 ++++++++++++ .../wireless/mediatek/mt76/mt76x0/usb_init.c | 24 +++++++++++++++++++ .../wireless/mediatek/mt76/mt76x02_eeprom.c | 2 ++ 6 files changed, 45 insertions(+), 21 deletions(-)