Commit 63cf8d12 authored by Lorenzo Bianconi's avatar Lorenzo Bianconi Committed by Felix Fietkau

mt76: move mt76x02_eeprom_parse_hw_cap in mt76x02-lib module

Move mt76x02_eeprom_parse_hw_cap utility routine in mt76x02-lib
module in order to be reused in mt76x0 driver
Signed-off-by: default avatarLorenzo Bianconi <lorenzo.bianconi@redhat.com>
Signed-off-by: default avatarFelix Fietkau <nbd@nbd.name>
parent 77d0f465
...@@ -71,6 +71,25 @@ int mt76x02_get_efuse_data(struct mt76_dev *dev, u16 base, void *buf, ...@@ -71,6 +71,25 @@ int mt76x02_get_efuse_data(struct mt76_dev *dev, u16 base, void *buf,
} }
EXPORT_SYMBOL_GPL(mt76x02_get_efuse_data); EXPORT_SYMBOL_GPL(mt76x02_get_efuse_data);
void mt76x02_eeprom_parse_hw_cap(struct mt76_dev *dev)
{
u16 val = mt76x02_eeprom_get(dev, MT_EE_NIC_CONF_0);
switch (FIELD_GET(MT_EE_NIC_CONF_0_BOARD_TYPE, val)) {
case BOARD_TYPE_5GHZ:
dev->cap.has_5ghz = true;
break;
case BOARD_TYPE_2GHZ:
dev->cap.has_2ghz = true;
break;
default:
dev->cap.has_2ghz = true;
dev->cap.has_5ghz = true;
break;
}
}
EXPORT_SYMBOL_GPL(mt76x02_eeprom_parse_hw_cap);
bool mt76x02_ext_pa_enabled(struct mt76_dev *dev, enum nl80211_band band) bool mt76x02_ext_pa_enabled(struct mt76_dev *dev, enum nl80211_band band)
{ {
u16 conf0 = mt76x02_eeprom_get(dev, MT_EE_NIC_CONF_0); u16 conf0 = mt76x02_eeprom_get(dev, MT_EE_NIC_CONF_0);
......
...@@ -132,6 +132,11 @@ enum mt76x02_eeprom_modes { ...@@ -132,6 +132,11 @@ enum mt76x02_eeprom_modes {
MT_EE_PHYSICAL_READ, MT_EE_PHYSICAL_READ,
}; };
enum mt76x02_board_type {
BOARD_TYPE_2GHZ = 1,
BOARD_TYPE_5GHZ = 2,
};
static inline bool mt76x02_field_valid(u8 val) static inline bool mt76x02_field_valid(u8 val)
{ {
return val != 0 && val != 0xff; return val != 0 && val != 0xff;
...@@ -165,5 +170,6 @@ void mt76x02_get_rx_gain(struct mt76_dev *dev, enum nl80211_band band, ...@@ -165,5 +170,6 @@ void mt76x02_get_rx_gain(struct mt76_dev *dev, enum nl80211_band band,
u8 mt76x02_get_lna_gain(struct mt76_dev *dev, u8 mt76x02_get_lna_gain(struct mt76_dev *dev,
s8 *lna_2g, s8 *lna_5g, s8 *lna_2g, s8 *lna_5g,
struct ieee80211_channel *chan); struct ieee80211_channel *chan);
void mt76x02_eeprom_parse_hw_cap(struct mt76_dev *dev);
#endif /* __MT76x02_EEPROM_H */ #endif /* __MT76x02_EEPROM_H */
...@@ -40,25 +40,6 @@ mt76x2_eeprom_get_macaddr(struct mt76x2_dev *dev) ...@@ -40,25 +40,6 @@ mt76x2_eeprom_get_macaddr(struct mt76x2_dev *dev)
return 0; return 0;
} }
void mt76x2_eeprom_parse_hw_cap(struct mt76x2_dev *dev)
{
u16 val = mt76x02_eeprom_get(&dev->mt76, MT_EE_NIC_CONF_0);
switch (FIELD_GET(MT_EE_NIC_CONF_0_BOARD_TYPE, val)) {
case BOARD_TYPE_5GHZ:
dev->mt76.cap.has_5ghz = true;
break;
case BOARD_TYPE_2GHZ:
dev->mt76.cap.has_2ghz = true;
break;
default:
dev->mt76.cap.has_2ghz = true;
dev->mt76.cap.has_5ghz = true;
break;
}
}
EXPORT_SYMBOL_GPL(mt76x2_eeprom_parse_hw_cap);
static bool static bool
mt76x2_has_cal_free_data(struct mt76x2_dev *dev, u8 *efuse) mt76x2_has_cal_free_data(struct mt76x2_dev *dev, u8 *efuse)
{ {
...@@ -566,7 +547,7 @@ int mt76x2_eeprom_init(struct mt76x2_dev *dev) ...@@ -566,7 +547,7 @@ int mt76x2_eeprom_init(struct mt76x2_dev *dev)
if (ret) if (ret)
return ret; return ret;
mt76x2_eeprom_parse_hw_cap(dev); mt76x02_eeprom_parse_hw_cap(&dev->mt76);
mt76x2_eeprom_get_macaddr(dev); mt76x2_eeprom_get_macaddr(dev);
mt76_eeprom_override(&dev->mt76); mt76_eeprom_override(&dev->mt76);
dev->mt76.macaddr[0] &= ~BIT(1); dev->mt76.macaddr[0] &= ~BIT(1);
......
...@@ -19,11 +19,6 @@ ...@@ -19,11 +19,6 @@
#include "mt76x02_eeprom.h" #include "mt76x02_eeprom.h"
enum mt76x2_board_type {
BOARD_TYPE_2GHZ = 1,
BOARD_TYPE_5GHZ = 2,
};
enum mt76x2_cal_channel_group { enum mt76x2_cal_channel_group {
MT_CH_5G_JAPAN, MT_CH_5G_JAPAN,
MT_CH_5G_UNII_1, MT_CH_5G_UNII_1,
...@@ -64,7 +59,6 @@ void mt76x2_get_power_info(struct mt76x2_dev *dev, ...@@ -64,7 +59,6 @@ void mt76x2_get_power_info(struct mt76x2_dev *dev,
struct ieee80211_channel *chan); struct ieee80211_channel *chan);
int mt76x2_get_temp_comp(struct mt76x2_dev *dev, struct mt76x2_temp_comp *t); int mt76x2_get_temp_comp(struct mt76x2_dev *dev, struct mt76x2_temp_comp *t);
void mt76x2_read_rx_gain(struct mt76x2_dev *dev); void mt76x2_read_rx_gain(struct mt76x2_dev *dev);
void mt76x2_eeprom_parse_hw_cap(struct mt76x2_dev *dev);
static inline bool static inline bool
mt76x2_temp_tx_alc_enabled(struct mt76x2_dev *dev) mt76x2_temp_tx_alc_enabled(struct mt76x2_dev *dev)
......
...@@ -129,7 +129,7 @@ static int mt76x2u_init_eeprom(struct mt76x2_dev *dev) ...@@ -129,7 +129,7 @@ static int mt76x2u_init_eeprom(struct mt76x2_dev *dev)
put_unaligned_le32(val, dev->mt76.eeprom.data + i); put_unaligned_le32(val, dev->mt76.eeprom.data + i);
} }
mt76x2_eeprom_parse_hw_cap(dev); mt76x02_eeprom_parse_hw_cap(&dev->mt76);
return 0; return 0;
} }
......
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