Skip to content

Commit 12b5afe

Browse files
committed
drivers: led: gpio: Add pinctrl support
Allow specifying pinmuxing in gpio-leds. A lot of board have on-board LEDs, so allowing specifying pinmux in these nodes helps keep the base GPIO node cleaner, and easier to write overlays for. Signed-off-by: Ayush Singh <ayush@beagleboard.org>
1 parent c35bb0d commit 12b5afe

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

drivers/led/led_gpio.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ LOG_MODULE_REGISTER(led_gpio, CONFIG_LED_LOG_LEVEL);
2222
struct led_gpio_config {
2323
size_t num_leds;
2424
const struct gpio_dt_spec *led;
25+
const struct pinctrl_dev_config *pcfg;
2526
};
2627

2728
static int led_gpio_set_brightness(const struct device *dev, uint32_t led, uint8_t value)
@@ -59,6 +60,12 @@ static int led_gpio_init(const struct device *dev)
5960
err = -ENODEV;
6061
}
6162

63+
err = pinctrl_apply_state(config->pcfg, PINCTRL_STATE_DEFAULT);
64+
if (err < 0 && err != -ENOENT) {
65+
LOG_ERR("failed to apply pinctrl");
66+
return err;
67+
}
68+
6269
for (size_t i = 0; (i < config->num_leds) && !err; i++) {
6370
const struct gpio_dt_spec *led = &config->led[i];
6471

@@ -92,6 +99,7 @@ static const struct gpio_dt_spec gpio_dt_spec_##i[] = { \
9299
static const struct led_gpio_config led_gpio_config_##i = { \
93100
.num_leds = ARRAY_SIZE(gpio_dt_spec_##i), \
94101
.led = gpio_dt_spec_##i, \
102+
.pcfg = PINCTRL_DT_INST_DEV_CONFIG_GET(i), \
95103
}; \
96104
\
97105
DEVICE_DT_INST_DEFINE(i, &led_gpio_init, NULL, \

0 commit comments

Comments
 (0)