Merge branch 'master' of git://git.denx.de/u-boot-spi
[platform/kernel/u-boot.git] / board / sandbox / sandbox.c
index b41e9de..397e756 100644 (file)
@@ -1,11 +1,12 @@
+// SPDX-License-Identifier: GPL-2.0+
 /*
  * Copyright (c) 2011 The Chromium OS Authors.
- * SPDX-License-Identifier:    GPL-2.0+
  */
 
 #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,15 +48,26 @@ 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)
 {
-       if (cros_ec_get_error()) {
+       struct udevice *dev;
+       int ret;
+
+       ret = uclass_first_device_err(UCLASS_CROS_EC, &dev);
+       if (ret && ret != -ENODEV) {
                /* Force console on */
                gd->flags &= ~GD_FLG_SILENT;
 
-               printf("cros-ec communications failure %d\n",
-                      cros_ec_get_error());
+               printf("cros-ec communications failure %d\n", ret);
                puts("\nPlease reset with Power+Refresh\n\n");
                panic("Cannot init cros-ec device");
                return -1;