blob: 41c49e5daa725154cd1d535928c18e8dc5cb4488 [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Simon Glassec3be542015-08-30 16:55:41 -06002/*
3 * (C) Copyright 2015 Google, Inc
Simon Glassec3be542015-08-30 16:55:41 -06004 */
5
6#include <common.h>
Simon Glassf11478f2019-12-28 10:45:07 -07007#include <hang.h>
Kever Yang4c99fa52020-08-20 17:32:52 +08008#include <led.h>
Simon Glass0f2af882020-05-10 11:40:05 -06009#include <log.h>
Simon Glass3ba929a2020-10-30 21:38:53 -060010#include <asm/global_data.h>
Kever Yangca09f9a2019-07-22 19:59:24 +080011
12#ifdef CONFIG_SPL_BUILD
Kever Yang4c99fa52020-08-20 17:32:52 +080013DECLARE_GLOBAL_DATA_PTR;
Kever Yangca09f9a2019-07-22 19:59:24 +080014static int setup_led(void)
15{
16#ifdef CONFIG_SPL_LED
17 struct udevice *dev;
18 char *led_name;
19 int ret;
20
21 led_name = fdtdec_get_config_string(gd->fdt_blob, "u-boot,boot-led");
22 if (!led_name)
23 return 0;
24 ret = led_get_by_label(led_name, &dev);
25 if (ret) {
26 debug("%s: get=%d\n", __func__, ret);
27 return ret;
28 }
Kever Yang4c99fa52020-08-20 17:32:52 +080029 ret = led_set_state(dev, LEDST_ON);
Kever Yangca09f9a2019-07-22 19:59:24 +080030 if (ret)
31 return ret;
32#endif
33
34 return 0;
35}
36
37void spl_board_init(void)
38{
39 int ret;
40
41 ret = setup_led();
42 if (ret) {
43 debug("LED ret=%d\n", ret);
44 hang();
45 }
46}
47#endif