led: led_gpio: add "default-state" apply
It follows kernel led gpio initialization. Change-Id: I8c4af429f03bd373e76cd0607306950a2dce33de Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
This commit is contained in:
parent
b3b8e4f06e
commit
19066e9932
|
|
@ -60,11 +60,29 @@ static int led_gpio_probe(struct udevice *dev)
|
||||||
{
|
{
|
||||||
struct led_uc_plat *uc_plat = dev_get_uclass_platdata(dev);
|
struct led_uc_plat *uc_plat = dev_get_uclass_platdata(dev);
|
||||||
struct led_gpio_priv *priv = dev_get_priv(dev);
|
struct led_gpio_priv *priv = dev_get_priv(dev);
|
||||||
|
const char *state;
|
||||||
|
int ret;
|
||||||
|
|
||||||
/* Ignore the top-level LED node */
|
/* Ignore the top-level LED node */
|
||||||
if (!uc_plat->label)
|
if (!uc_plat->label)
|
||||||
return 0;
|
return 0;
|
||||||
return gpio_request_by_name(dev, "gpios", 0, &priv->gpio, GPIOD_IS_OUT);
|
|
||||||
|
ret = gpio_request_by_name(dev, "gpios", 0, &priv->gpio, GPIOD_IS_OUT);
|
||||||
|
if (ret) {
|
||||||
|
printf("Failed to request gpios of led '%s'\n", uc_plat->label);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Apply default state */
|
||||||
|
state = dev_read_prop(dev, "default-state", NULL);
|
||||||
|
if (state) {
|
||||||
|
if (!strcmp(state, "on"))
|
||||||
|
ret = gpio_led_set_state(dev, LEDST_ON);
|
||||||
|
else if (!strcmp(state, "off"))
|
||||||
|
ret = gpio_led_set_state(dev, LEDST_OFF);
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int led_gpio_remove(struct udevice *dev)
|
static int led_gpio_remove(struct udevice *dev)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue