aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSven Wegener <sven.wegener@stealer.net>2021-06-12 21:56:22 +0200
committerDaniel Golle <daniel@makrotopia.org>2022-09-18 15:39:41 +0100
commit26cd0c1ee93c9c986367927394776071e28d3f86 (patch)
tree0850baaaa1b36dca6c2e50355e3d7638711e5185
parentb5665a004526aff62b07d7c729f8ef9e9d98a8e7 (diff)
downloadupstream-26cd0c1ee93c9c986367927394776071e28d3f86.tar.gz
upstream-26cd0c1ee93c9c986367927394776071e28d3f86.tar.bz2
upstream-26cd0c1ee93c9c986367927394776071e28d3f86.zip
mediatek: add support for reset gpio
Some versions of the ledbar MCU have a reset pin. It needs to be correctly initialized or we might keep the MCU in reset state. Signed-off-by: Sven Wegener <sven.wegener@stealer.net> (cherry picked from commit 84e4bbf5f049cdb862eb25c446bd6973ed4238aa)
-rw-r--r--target/linux/mediatek/files-5.10/drivers/leds/leds-ubnt-ledbar.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/target/linux/mediatek/files-5.10/drivers/leds/leds-ubnt-ledbar.c b/target/linux/mediatek/files-5.10/drivers/leds/leds-ubnt-ledbar.c
index c62e233e6d..1d687b7686 100644
--- a/target/linux/mediatek/files-5.10/drivers/leds/leds-ubnt-ledbar.c
+++ b/target/linux/mediatek/files-5.10/drivers/leds/leds-ubnt-ledbar.c
@@ -39,6 +39,7 @@ struct ubnt_ledbar {
struct led_classdev led_green;
struct led_classdev led_blue;
struct gpio_desc *enable_gpio;
+ struct gpio_desc *reset_gpio;
};
static void ubnt_ledbar_perform_transaction(struct ubnt_ledbar *ledbar,
@@ -96,6 +97,20 @@ out_gpio:
return ret;
}
+static void ubnt_ledbar_reset(struct ubnt_ledbar *ledbar)
+{
+ if (!ledbar->reset_gpio)
+ return;
+
+ mutex_lock(&ledbar->lock);
+
+ gpiod_set_value(ledbar->reset_gpio, 1);
+ msleep(10);
+ gpiod_set_value(ledbar->reset_gpio, 0);
+
+ mutex_unlock(&ledbar->lock);
+}
+
#define UBNT_LEDBAR_CONTROL_RGBS(name) \
static int ubnt_ledbar_set_##name##_brightness(struct led_classdev *led_cdev,\
enum led_brightness value) \
@@ -154,12 +169,23 @@ static int ubnt_ledbar_probe(struct i2c_client *client,
return ret;
}
+ ledbar->reset_gpio = devm_gpiod_get_optional(&client->dev, "reset", GPIOD_OUT_LOW);
+
+ if (IS_ERR(ledbar->reset_gpio)) {
+ ret = PTR_ERR(ledbar->reset_gpio);
+ dev_err(&client->dev, "Failed to get reset gpio: %d\n", ret);
+ return ret;
+ }
+
ledbar->client = client;
mutex_init(&ledbar->lock);
i2c_set_clientdata(client, ledbar);
+ // Reset and initialize the MCU
+ ubnt_ledbar_reset(ledbar);
+
ledbar->led_red.brightness_set_blocking = ubnt_ledbar_set_red_brightness;
ubnt_ledbar_init_led(of_get_child_by_name(np, "red"), ledbar, &ledbar->led_red);