mirror of
https://github.com/outbackdingo/mt76.git
synced 2026-10-24 13:26:48 +00:00
mt76: add led support using mac80211 led framework
use tpt-trigger as default trigger Signed-off-by: Lorenzo Bianconi <[email protected]> Signed-off-by: Felix Fietkau <[email protected]>
This commit is contained in:
committed by
Felix Fietkau
parent
2f40e4ad49
commit
27c64bcfd7
+45
@@ -76,6 +76,47 @@ static const struct ieee80211_channel mt76_channels_5ghz[] = {
|
||||
CHAN5G(165, 5825),
|
||||
};
|
||||
|
||||
static const struct ieee80211_tpt_blink mt76_tpt_blink[] = {
|
||||
{ .throughput = 0 * 1024, .blink_time = 334 },
|
||||
{ .throughput = 1 * 1024, .blink_time = 260 },
|
||||
{ .throughput = 5 * 1024, .blink_time = 220 },
|
||||
{ .throughput = 10 * 1024, .blink_time = 190 },
|
||||
{ .throughput = 20 * 1024, .blink_time = 170 },
|
||||
{ .throughput = 50 * 1024, .blink_time = 150 },
|
||||
{ .throughput = 70 * 1024, .blink_time = 130 },
|
||||
{ .throughput = 100 * 1024, .blink_time = 110 },
|
||||
{ .throughput = 200 * 1024, .blink_time = 80 },
|
||||
{ .throughput = 300 * 1024, .blink_time = 50 },
|
||||
};
|
||||
|
||||
static int mt76_led_init(struct mt76_dev *dev)
|
||||
{
|
||||
struct device_node *np = dev->dev->of_node;
|
||||
struct ieee80211_hw *hw = dev->hw;
|
||||
int led_pin;
|
||||
|
||||
if (!dev->led_cdev.brightness_set && !dev->led_cdev.blink_set)
|
||||
return 0;
|
||||
|
||||
snprintf(dev->led_name, sizeof(dev->led_name),
|
||||
"mt76-%s", wiphy_name(hw->wiphy));
|
||||
|
||||
dev->led_cdev.name = dev->led_name;
|
||||
dev->led_cdev.default_trigger =
|
||||
ieee80211_create_tpt_led_trigger(hw,
|
||||
IEEE80211_TPT_LEDTRIG_FL_RADIO,
|
||||
mt76_tpt_blink,
|
||||
ARRAY_SIZE(mt76_tpt_blink));
|
||||
|
||||
if (np) {
|
||||
if (!of_property_read_u32(np, "led-sources", &led_pin))
|
||||
dev->led_pin = led_pin;
|
||||
dev->led_al = of_property_read_bool(np, "led-active-low");
|
||||
}
|
||||
|
||||
return devm_led_classdev_register(dev->dev, &dev->led_cdev);
|
||||
}
|
||||
|
||||
static int
|
||||
mt76_init_sband(struct mt76_dev *dev, struct mt76_sband *msband,
|
||||
const struct ieee80211_channel *chan, int n_chan,
|
||||
@@ -252,6 +293,10 @@ int mt76_register_device(struct mt76_dev *dev, bool vht,
|
||||
mt76_check_sband(dev, NL80211_BAND_2GHZ);
|
||||
mt76_check_sband(dev, NL80211_BAND_5GHZ);
|
||||
|
||||
ret = mt76_led_init(dev);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
return ieee80211_register_hw(hw);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(mt76_register_device);
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
#include <linux/io.h>
|
||||
#include <linux/spinlock.h>
|
||||
#include <linux/skbuff.h>
|
||||
#include <linux/leds.h>
|
||||
#include <net/mac80211.h>
|
||||
#include "util.h"
|
||||
|
||||
@@ -222,6 +223,11 @@ struct mt76_dev {
|
||||
struct mt76_hw_cap cap;
|
||||
|
||||
u32 debugfs_reg;
|
||||
|
||||
struct led_classdev led_cdev;
|
||||
char led_name[32];
|
||||
bool led_al;
|
||||
u8 led_pin;
|
||||
};
|
||||
|
||||
enum mt76_phy_type {
|
||||
|
||||
Reference in New Issue
Block a user