sandbox: led: use new function to configure default state
authorPatrick Delaunay <patrick.delaunay@st.com>
Fri, 27 Jul 2018 14:37:09 +0000 (16:37 +0200)
committerTom Rini <trini@konsulko.com>
Fri, 10 Aug 2018 14:27:32 +0000 (10:27 -0400)
Initialize the led with the default state defined in device tree
in board_init and solve issue with test for led default state.

Reviewed-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
board/sandbox/sandbox.c
common/board_r.c
test/dm/led.c

index 195f620..0e87674 100644 (file)
@@ -6,6 +6,7 @@
 #include <common.h>
 #include <cros_ec.h>
 #include <dm.h>
+#include <led.h>
 #include <os.h>
 #include <asm/test.h>
 #include <asm/u-boot-sandbox.h>
@@ -47,6 +48,14 @@ int dram_init(void)
        return 0;
 }
 
+int board_init(void)
+{
+       if (IS_ENABLED(CONFIG_LED))
+               led_default_state();
+
+       return 0;
+}
+
 #ifdef CONFIG_BOARD_LATE_INIT
 int board_late_init(void)
 {
index 64f2574..9402c0e 100644 (file)
@@ -690,7 +690,8 @@ static init_fnc_t init_sequence_r[] = {
 #ifdef CONFIG_DM
        initr_dm,
 #endif
-#if defined(CONFIG_ARM) || defined(CONFIG_NDS32) || defined(CONFIG_RISCV)
+#if defined(CONFIG_ARM) || defined(CONFIG_NDS32) || defined(CONFIG_RISCV) || \
+       defined(CONFIG_SANDBOX)
        board_init,     /* Setup chipselects */
 #endif
        /*
index 0071f21..00de7b3 100644 (file)
@@ -32,6 +32,9 @@ static int dm_test_led_default_state(struct unit_test_state *uts)
 {
        struct udevice *dev;
 
+       /* configure the default state (auto-probe) */
+       led_default_state();
+
        /* Check that we handle the default-state property correctly. */
        ut_assertok(led_get_by_label("sandbox:default_on", &dev));
        ut_asserteq(LEDST_ON, led_get_state(dev));