Commit 54b8fdeb authored by Lorenzo Bianconi's avatar Lorenzo Bianconi Committed by Felix Fietkau

mt76: move mt76_rates in mt76 module

Move mt76_rates array in mt76 module and remove duplicated code since it
is shared by all drivers
Signed-off-by: default avatarLorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: default avatarFelix Fietkau <nbd@nbd.name>
parent 3de4cb17
...@@ -83,6 +83,22 @@ static const struct ieee80211_tpt_blink mt76_tpt_blink[] = { ...@@ -83,6 +83,22 @@ static const struct ieee80211_tpt_blink mt76_tpt_blink[] = {
{ .throughput = 300 * 1024, .blink_time = 50 }, { .throughput = 300 * 1024, .blink_time = 50 },
}; };
struct ieee80211_rate mt76_rates[] = {
CCK_RATE(0, 10),
CCK_RATE(1, 20),
CCK_RATE(2, 55),
CCK_RATE(3, 110),
OFDM_RATE(11, 60),
OFDM_RATE(15, 90),
OFDM_RATE(10, 120),
OFDM_RATE(14, 180),
OFDM_RATE(9, 240),
OFDM_RATE(13, 360),
OFDM_RATE(8, 480),
OFDM_RATE(12, 540),
};
EXPORT_SYMBOL_GPL(mt76_rates);
static int mt76_led_init(struct mt76_dev *dev) static int mt76_led_init(struct mt76_dev *dev)
{ {
struct device_node *np = dev->dev->of_node; struct device_node *np = dev->dev->of_node;
......
...@@ -738,6 +738,21 @@ enum mt76_phy_type { ...@@ -738,6 +738,21 @@ enum mt76_phy_type {
MT_PHY_TYPE_HE_MU, MT_PHY_TYPE_HE_MU,
}; };
#define CCK_RATE(_idx, _rate) { \
.bitrate = _rate, \
.flags = IEEE80211_RATE_SHORT_PREAMBLE, \
.hw_value = (MT_PHY_TYPE_CCK << 8) | (_idx), \
.hw_value_short = (MT_PHY_TYPE_CCK << 8) | (4 + _idx), \
}
#define OFDM_RATE(_idx, _rate) { \
.bitrate = _rate, \
.hw_value = (MT_PHY_TYPE_OFDM << 8) | (_idx), \
.hw_value_short = (MT_PHY_TYPE_OFDM << 8) | (_idx), \
}
extern struct ieee80211_rate mt76_rates[12];
#define __mt76_rr(dev, ...) (dev)->bus->rr((dev), __VA_ARGS__) #define __mt76_rr(dev, ...) (dev)->bus->rr((dev), __VA_ARGS__)
#define __mt76_wr(dev, ...) (dev)->bus->wr((dev), __VA_ARGS__) #define __mt76_wr(dev, ...) (dev)->bus->wr((dev), __VA_ARGS__)
#define __mt76_rmw(dev, ...) (dev)->bus->rmw((dev), __VA_ARGS__) #define __mt76_rmw(dev, ...) (dev)->bus->rmw((dev), __VA_ARGS__)
......
...@@ -304,34 +304,6 @@ mt7603_init_hardware(struct mt7603_dev *dev) ...@@ -304,34 +304,6 @@ mt7603_init_hardware(struct mt7603_dev *dev)
return 0; return 0;
} }
#define CCK_RATE(_idx, _rate) { \
.bitrate = _rate, \
.flags = IEEE80211_RATE_SHORT_PREAMBLE, \
.hw_value = (MT_PHY_TYPE_CCK << 8) | (_idx), \
.hw_value_short = (MT_PHY_TYPE_CCK << 8) | (4 + _idx), \
}
#define OFDM_RATE(_idx, _rate) { \
.bitrate = _rate, \
.hw_value = (MT_PHY_TYPE_OFDM << 8) | (_idx), \
.hw_value_short = (MT_PHY_TYPE_OFDM << 8) | (_idx), \
}
static struct ieee80211_rate mt7603_rates[] = {
CCK_RATE(0, 10),
CCK_RATE(1, 20),
CCK_RATE(2, 55),
CCK_RATE(3, 110),
OFDM_RATE(11, 60),
OFDM_RATE(15, 90),
OFDM_RATE(10, 120),
OFDM_RATE(14, 180),
OFDM_RATE(9, 240),
OFDM_RATE(13, 360),
OFDM_RATE(8, 480),
OFDM_RATE(12, 540),
};
static const struct ieee80211_iface_limit if_limits[] = { static const struct ieee80211_iface_limit if_limits[] = {
{ {
.max = 1, .max = 1,
...@@ -569,8 +541,8 @@ int mt7603_register_device(struct mt7603_dev *dev) ...@@ -569,8 +541,8 @@ int mt7603_register_device(struct mt7603_dev *dev)
wiphy->reg_notifier = mt7603_regd_notifier; wiphy->reg_notifier = mt7603_regd_notifier;
ret = mt76_register_device(&dev->mt76, true, mt7603_rates, ret = mt76_register_device(&dev->mt76, true, mt76_rates,
ARRAY_SIZE(mt7603_rates)); ARRAY_SIZE(mt76_rates));
if (ret) if (ret)
return ret; return ret;
......
...@@ -174,35 +174,6 @@ bool mt7615_wait_for_mcu_init(struct mt7615_dev *dev) ...@@ -174,35 +174,6 @@ bool mt7615_wait_for_mcu_init(struct mt7615_dev *dev)
} }
EXPORT_SYMBOL_GPL(mt7615_wait_for_mcu_init); EXPORT_SYMBOL_GPL(mt7615_wait_for_mcu_init);
#define CCK_RATE(_idx, _rate) { \
.bitrate = _rate, \
.flags = IEEE80211_RATE_SHORT_PREAMBLE, \
.hw_value = (MT_PHY_TYPE_CCK << 8) | (_idx), \
.hw_value_short = (MT_PHY_TYPE_CCK << 8) | (4 + (_idx)), \
}
#define OFDM_RATE(_idx, _rate) { \
.bitrate = _rate, \
.hw_value = (MT_PHY_TYPE_OFDM << 8) | (_idx), \
.hw_value_short = (MT_PHY_TYPE_OFDM << 8) | (_idx), \
}
struct ieee80211_rate mt7615_rates[] = {
CCK_RATE(0, 10),
CCK_RATE(1, 20),
CCK_RATE(2, 55),
CCK_RATE(3, 110),
OFDM_RATE(11, 60),
OFDM_RATE(15, 90),
OFDM_RATE(10, 120),
OFDM_RATE(14, 180),
OFDM_RATE(9, 240),
OFDM_RATE(13, 360),
OFDM_RATE(8, 480),
OFDM_RATE(12, 540),
};
EXPORT_SYMBOL_GPL(mt7615_rates);
static const struct ieee80211_iface_limit if_limits[] = { static const struct ieee80211_iface_limit if_limits[] = {
{ {
.max = 1, .max = 1,
...@@ -472,8 +443,8 @@ int mt7615_register_ext_phy(struct mt7615_dev *dev) ...@@ -472,8 +443,8 @@ int mt7615_register_ext_phy(struct mt7615_dev *dev)
for (i = 0; i <= MT_TXQ_PSD ; i++) for (i = 0; i <= MT_TXQ_PSD ; i++)
mphy->q_tx[i] = dev->mphy.q_tx[i]; mphy->q_tx[i] = dev->mphy.q_tx[i];
ret = mt76_register_phy(mphy, true, mt7615_rates, ret = mt76_register_phy(mphy, true, mt76_rates,
ARRAY_SIZE(mt7615_rates)); ARRAY_SIZE(mt76_rates));
if (ret) if (ret)
ieee80211_free_hw(mphy->hw); ieee80211_free_hw(mphy->hw);
......
...@@ -147,8 +147,8 @@ int mt7615_register_device(struct mt7615_dev *dev) ...@@ -147,8 +147,8 @@ int mt7615_register_device(struct mt7615_dev *dev)
if (ret) if (ret)
return ret; return ret;
ret = mt76_register_device(&dev->mt76, true, mt7615_rates, ret = mt76_register_device(&dev->mt76, true, mt76_rates,
ARRAY_SIZE(mt7615_rates)); ARRAY_SIZE(mt76_rates));
if (ret) if (ret)
return ret; return ret;
......
...@@ -323,8 +323,8 @@ int mt7663_usb_sdio_register_device(struct mt7615_dev *dev) ...@@ -323,8 +323,8 @@ int mt7663_usb_sdio_register_device(struct mt7615_dev *dev)
hw->max_tx_fragments = 1; hw->max_tx_fragments = 1;
} }
err = mt76_register_device(&dev->mt76, true, mt7615_rates, err = mt76_register_device(&dev->mt76, true, mt76_rates,
ARRAY_SIZE(mt7615_rates)); ARRAY_SIZE(mt76_rates));
if (err < 0) if (err < 0)
return err; return err;
......
...@@ -7,24 +7,18 @@ ...@@ -7,24 +7,18 @@
#include <linux/module.h> #include <linux/module.h>
#include "mt76x02.h" #include "mt76x02.h"
#define CCK_RATE(_idx, _rate) { \ #define MT76x02_CCK_RATE(_idx, _rate) { \
.bitrate = _rate, \ .bitrate = _rate, \
.flags = IEEE80211_RATE_SHORT_PREAMBLE, \ .flags = IEEE80211_RATE_SHORT_PREAMBLE, \
.hw_value = (MT_PHY_TYPE_CCK << 8) | (_idx), \ .hw_value = (MT_PHY_TYPE_CCK << 8) | (_idx), \
.hw_value_short = (MT_PHY_TYPE_CCK << 8) | (8 + (_idx)), \ .hw_value_short = (MT_PHY_TYPE_CCK << 8) | (8 + (_idx)), \
} }
#define OFDM_RATE(_idx, _rate) { \
.bitrate = _rate, \
.hw_value = (MT_PHY_TYPE_OFDM << 8) | (_idx), \
.hw_value_short = (MT_PHY_TYPE_OFDM << 8) | (_idx), \
}
struct ieee80211_rate mt76x02_rates[] = { struct ieee80211_rate mt76x02_rates[] = {
CCK_RATE(0, 10), MT76x02_CCK_RATE(0, 10),
CCK_RATE(1, 20), MT76x02_CCK_RATE(1, 20),
CCK_RATE(2, 55), MT76x02_CCK_RATE(2, 55),
CCK_RATE(3, 110), MT76x02_CCK_RATE(3, 110),
OFDM_RATE(0, 60), OFDM_RATE(0, 60),
OFDM_RATE(1, 90), OFDM_RATE(1, 90),
OFDM_RATE(2, 120), OFDM_RATE(2, 120),
......
...@@ -7,34 +7,6 @@ ...@@ -7,34 +7,6 @@
#include "mcu.h" #include "mcu.h"
#include "eeprom.h" #include "eeprom.h"
#define CCK_RATE(_idx, _rate) { \
.bitrate = _rate, \
.flags = IEEE80211_RATE_SHORT_PREAMBLE, \
.hw_value = (MT_PHY_TYPE_CCK << 8) | (_idx), \
.hw_value_short = (MT_PHY_TYPE_CCK << 8) | (4 + (_idx)), \
}
#define OFDM_RATE(_idx, _rate) { \
.bitrate = _rate, \
.hw_value = (MT_PHY_TYPE_OFDM << 8) | (_idx), \
.hw_value_short = (MT_PHY_TYPE_OFDM << 8) | (_idx), \
}
static struct ieee80211_rate mt7915_rates[] = {
CCK_RATE(0, 10),
CCK_RATE(1, 20),
CCK_RATE(2, 55),
CCK_RATE(3, 110),
OFDM_RATE(11, 60),
OFDM_RATE(15, 90),
OFDM_RATE(10, 120),
OFDM_RATE(14, 180),
OFDM_RATE(9, 240),
OFDM_RATE(13, 360),
OFDM_RATE(8, 480),
OFDM_RATE(12, 540),
};
static const struct ieee80211_iface_limit if_limits[] = { static const struct ieee80211_iface_limit if_limits[] = {
{ {
.max = 1, .max = 1,
...@@ -281,8 +253,8 @@ static int mt7915_register_ext_phy(struct mt7915_dev *dev) ...@@ -281,8 +253,8 @@ static int mt7915_register_ext_phy(struct mt7915_dev *dev)
if (ret) if (ret)
goto error; goto error;
ret = mt76_register_phy(mphy, true, mt7915_rates, ret = mt76_register_phy(mphy, true, mt76_rates,
ARRAY_SIZE(mt7915_rates)); ARRAY_SIZE(mt76_rates));
if (ret) if (ret)
goto error; goto error;
...@@ -731,8 +703,8 @@ int mt7915_register_device(struct mt7915_dev *dev) ...@@ -731,8 +703,8 @@ int mt7915_register_device(struct mt7915_dev *dev)
dev->mt76.test_ops = &mt7915_testmode_ops; dev->mt76.test_ops = &mt7915_testmode_ops;
#endif #endif
ret = mt76_register_device(&dev->mt76, true, mt7915_rates, ret = mt76_register_device(&dev->mt76, true, mt76_rates,
ARRAY_SIZE(mt7915_rates)); ARRAY_SIZE(mt76_rates));
if (ret) if (ret)
return ret; return ret;
......
...@@ -7,34 +7,6 @@ ...@@ -7,34 +7,6 @@
#include "mcu.h" #include "mcu.h"
#include "eeprom.h" #include "eeprom.h"
#define CCK_RATE(_idx, _rate) { \
.bitrate = _rate, \
.flags = IEEE80211_RATE_SHORT_PREAMBLE, \
.hw_value = (MT_PHY_TYPE_CCK << 8) | (_idx), \
.hw_value_short = (MT_PHY_TYPE_CCK << 8) | (4 + (_idx)), \
}
#define OFDM_RATE(_idx, _rate) { \
.bitrate = _rate, \
.hw_value = (MT_PHY_TYPE_OFDM << 8) | (_idx), \
.hw_value_short = (MT_PHY_TYPE_OFDM << 8) | (_idx), \
}
static struct ieee80211_rate mt7921_rates[] = {
CCK_RATE(0, 10),
CCK_RATE(1, 20),
CCK_RATE(2, 55),
CCK_RATE(3, 110),
OFDM_RATE(11, 60),
OFDM_RATE(15, 90),
OFDM_RATE(10, 120),
OFDM_RATE(14, 180),
OFDM_RATE(9, 240),
OFDM_RATE(13, 360),
OFDM_RATE(8, 480),
OFDM_RATE(12, 540),
};
static const struct ieee80211_iface_limit if_limits[] = { static const struct ieee80211_iface_limit if_limits[] = {
{ {
.max = MT7921_MAX_INTERFACES, .max = MT7921_MAX_INTERFACES,
...@@ -260,8 +232,8 @@ int mt7921_register_device(struct mt7921_dev *dev) ...@@ -260,8 +232,8 @@ int mt7921_register_device(struct mt7921_dev *dev)
mt76_set_stream_caps(&dev->mphy, true); mt76_set_stream_caps(&dev->mphy, true);
mt7921_set_stream_he_caps(&dev->phy); mt7921_set_stream_he_caps(&dev->phy);
ret = mt76_register_device(&dev->mt76, true, mt7921_rates, ret = mt76_register_device(&dev->mt76, true, mt76_rates,
ARRAY_SIZE(mt7921_rates)); ARRAY_SIZE(mt76_rates));
if (ret) if (ret)
return ret; return ret;
......
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