leds: gpio: Configure per-LED pin control
Each gpio-leds DT node DT subnode can have a pinctrl property assigned to it, parse the DT subnode pinctrl properties and configure each pin accordingly. Tested-by: Christoph Niedermaier <cniedermaier@dh-electronics.com> Signed-off-by: Marek Vasut <marex@denx.de> Link: https://lore.kernel.org/r/20230523183151.5460-1-marex@denx.de Signed-off-by: Lee Jones <lee@kernel.org>
This commit is contained in:
parent
bf4a35e920
commit
2d6180147e
@ -13,6 +13,7 @@
|
|||||||
#include <linux/leds.h>
|
#include <linux/leds.h>
|
||||||
#include <linux/module.h>
|
#include <linux/module.h>
|
||||||
#include <linux/of.h>
|
#include <linux/of.h>
|
||||||
|
#include <linux/pinctrl/consumer.h>
|
||||||
#include <linux/platform_device.h>
|
#include <linux/platform_device.h>
|
||||||
#include <linux/property.h>
|
#include <linux/property.h>
|
||||||
#include <linux/slab.h>
|
#include <linux/slab.h>
|
||||||
@ -77,6 +78,7 @@ static int create_gpio_led(const struct gpio_led *template,
|
|||||||
struct fwnode_handle *fwnode, gpio_blink_set_t blink_set)
|
struct fwnode_handle *fwnode, gpio_blink_set_t blink_set)
|
||||||
{
|
{
|
||||||
struct led_init_data init_data = {};
|
struct led_init_data init_data = {};
|
||||||
|
struct pinctrl *pinctrl;
|
||||||
int ret, state;
|
int ret, state;
|
||||||
|
|
||||||
led_dat->cdev.default_trigger = template->default_trigger;
|
led_dat->cdev.default_trigger = template->default_trigger;
|
||||||
@ -119,6 +121,22 @@ static int create_gpio_led(const struct gpio_led *template,
|
|||||||
&init_data);
|
&init_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (ret)
|
||||||
|
return ret;
|
||||||
|
|
||||||
|
pinctrl = devm_pinctrl_get_select_default(led_dat->cdev.dev);
|
||||||
|
if (IS_ERR(pinctrl)) {
|
||||||
|
ret = PTR_ERR(pinctrl);
|
||||||
|
if (ret != -ENODEV) {
|
||||||
|
dev_warn(led_dat->cdev.dev,
|
||||||
|
"Failed to select %pOF pinctrl: %d\n",
|
||||||
|
to_of_node(fwnode), ret);
|
||||||
|
} else {
|
||||||
|
/* pinctrl-%d not present, not an error */
|
||||||
|
ret = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user