diff --git a/Makefile b/Makefile index dd51d0ee..38247f73 100644 --- a/Makefile +++ b/Makefile @@ -13,4 +13,4 @@ mt76x2e-y := \ mt7603e-y := \ mt7603_pci.o mt7603_main.o mt7603_init.o mt7603_mcu.o \ - mt7603_core.o mt7603_dma.o mt7603_mac.o + mt7603_core.o mt7603_dma.o mt7603_mac.o mt7603_eeprom.o diff --git a/mt7603.h b/mt7603.h index af9c799a..3698b8ed 100644 --- a/mt7603.h +++ b/mt7603.h @@ -152,6 +152,7 @@ irqreturn_t mt7603_irq_handler(int irq, void *dev_instance); int mt7603_register_device(struct mt7603_dev *dev); void mt7603_unregister_device(struct mt7603_dev *dev); +int mt7603_eeprom_init(struct mt7603_dev *dev); int mt7603_dma_init(struct mt7603_dev *dev); void mt7603_dma_cleanup(struct mt7603_dev *dev); int mt7603_mcu_init(struct mt7603_dev *dev); diff --git a/mt7603_eeprom.c b/mt7603_eeprom.c new file mode 100644 index 00000000..6b0e0a02 --- /dev/null +++ b/mt7603_eeprom.c @@ -0,0 +1,44 @@ +/* + * Copyright (C) 2016 Felix Fietkau + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 + * as published by the Free Software Foundation + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + +#include "mt7603.h" +#include "mt7603_eeprom.h" + +static int +mt7603_eeprom_load(struct mt7603_dev *dev) +{ + int ret; + + ret = mt76_eeprom_init(&dev->mt76, MT7603_EEPROM_SIZE); + if (ret < 0) + return ret; + + return 0; +} + +int mt7603_eeprom_init(struct mt7603_dev *dev) +{ + int ret; + + ret = mt7603_eeprom_load(dev); + if (ret < 0) + return ret; + + dev->mt76.cap.has_2ghz = true; + memcpy(dev->mt76.macaddr, dev->mt76.eeprom.data + MT_EE_MAC_ADDR, + ETH_ALEN); + + mt76_eeprom_override(&dev->mt76); + + return 0; +} diff --git a/mt7603_init.c b/mt7603_init.c index 4d6fd47d..469d5696 100644 --- a/mt7603_init.c +++ b/mt7603_init.c @@ -270,15 +270,10 @@ mt7603_init_hardware(struct mt7603_dev *dev) mt76_wr(dev, MT_INT_SOURCE_CSR, ~0); - ret = mt76_eeprom_init(&dev->mt76, MT7603_EEPROM_SIZE); + ret = mt7603_eeprom_init(dev); if (ret < 0) return ret; - dev->mt76.cap.has_2ghz = true; - memcpy(dev->mt76.macaddr, dev->mt76.eeprom.data + MT_EE_MAC_ADDR, - ETH_ALEN); - mt76_eeprom_override(&dev->mt76); - ret = mt7603_dma_init(dev); if (ret) return ret;