blob: 95d8b00924d8a39138fabda7866f9a26d82df690 [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>
Simon Glass0034d962021-08-07 07:24:01 -060011#include <dm/ofnode.h>
Kever Yangca09f9a2019-07-22 19:59:24 +080012
13#ifdef CONFIG_SPL_BUILD
14static int setup_led(void)
15{
16#ifdef CONFIG_SPL_LED
17 struct udevice *dev;
18 char *led_name;
19 int ret;
20
Simon Glass0034d962021-08-07 07:24:01 -060021 led_name = ofnode_conf_read_str("u-boot,boot-led");
Kever Yangca09f9a2019-07-22 19:59:24 +080022 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