blob: 8e67ab4b13273c04d8c48827285c740a9212877d [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
Simon Glassf11478f2019-12-28 10:45:07 -07006#include <hang.h>
Kever Yang4c99fa52020-08-20 17:32:52 +08007#include <led.h>
Simon Glass0f2af882020-05-10 11:40:05 -06008#include <log.h>
Simon Glass3ba929a2020-10-30 21:38:53 -06009#include <asm/global_data.h>
Simon Glass0034d962021-08-07 07:24:01 -060010#include <dm/ofnode.h>
Kever Yangca09f9a2019-07-22 19:59:24 +080011
12#ifdef CONFIG_SPL_BUILD
13static int setup_led(void)
14{
15#ifdef CONFIG_SPL_LED
16 struct udevice *dev;
17 char *led_name;
18 int ret;
19
Simon Glass0034d962021-08-07 07:24:01 -060020 led_name = ofnode_conf_read_str("u-boot,boot-led");
Kever Yangca09f9a2019-07-22 19:59:24 +080021 if (!led_name)
22 return 0;
23 ret = led_get_by_label(led_name, &dev);
24 if (ret) {
25 debug("%s: get=%d\n", __func__, ret);
26 return ret;
27 }
Kever Yang4c99fa52020-08-20 17:32:52 +080028 ret = led_set_state(dev, LEDST_ON);
Kever Yangca09f9a2019-07-22 19:59:24 +080029 if (ret)
30 return ret;
31#endif
32
33 return 0;
34}
35
36void spl_board_init(void)
37{
38 int ret;
39
40 ret = setup_led();
41 if (ret) {
42 debug("LED ret=%d\n", ret);
43 hang();
44 }
45}
46#endif