From d2b3f630dd8846c7833126763cf3ec7983133906 Mon Sep 17 00:00:00 2001 From: hanwckf Date: Sat, 27 Jul 2019 21:49:36 +0800 Subject: [PATCH] aw2013: set default state --- .../boot/dts/marvell/armada-3720-catdrive.dts | 1 + linux-marvell/drivers/leds/leds-aw2013.c | 26 +++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/linux-marvell/arch/arm64/boot/dts/marvell/armada-3720-catdrive.dts b/linux-marvell/arch/arm64/boot/dts/marvell/armada-3720-catdrive.dts index 6b8d0d655d..ed8779a275 100644 --- a/linux-marvell/arch/arm64/boot/dts/marvell/armada-3720-catdrive.dts +++ b/linux-marvell/arch/arm64/boot/dts/marvell/armada-3720-catdrive.dts @@ -138,6 +138,7 @@ aw2013,hold-time-ms = <1>; aw2013,fall-time-ms = <2>; aw2013,off-time-ms = <1>; + default-state = "on"; }; aw2013,blue { diff --git a/linux-marvell/drivers/leds/leds-aw2013.c b/linux-marvell/drivers/leds/leds-aw2013.c index 81a3a7d4b2..50b4c4ecde 100755 --- a/linux-marvell/drivers/leds/leds-aw2013.c +++ b/linux-marvell/drivers/leds/leds-aw2013.c @@ -627,6 +627,30 @@ static int aw2013_led_parse_child_node(struct aw2013_led *led_array, return rc; } +static int aw2013_led_default_set(struct aw2013_led *led_array, + struct device_node *node) +{ + struct aw2013_led *led; + struct device_node *temp; + int parsed_leds = 0; + const char* state; + + for_each_child_of_node(node, temp) { + led = &led_array[parsed_leds]; + state = of_get_property(temp, "default-state", NULL); + if (state) { + if (!strcmp(state, "on")) { + aw2013_set_brightness(&led->cdev, led->cdev.max_brightness); + } else { + aw2013_set_brightness(&led->cdev, LED_OFF); + } + } + parsed_leds++; + } + + return 0; +} + static int aw2013_led_probe(struct i2c_client *client, const struct i2c_device_id *id) { @@ -681,6 +705,8 @@ static int aw2013_led_probe(struct i2c_client *client, goto fail_parsed_node; } + aw2013_led_default_set(led_array, node); + return 0; fail_parsed_node: