blob: 95d8b00924d8a39138fabda7866f9a26d82df690 [file] [log] [blame]
Tom Rini83d290c2018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Simon Glass17aa5482015-08-30 16:55:41 -06002/*
3 * (C) Copyright 2015 Google, Inc
Simon Glass17aa5482015-08-30 16:55:41 -06004 */
5
6#include <common.h>
Simon Glassdb41d652019-12-28 10:45:07 -07007#include <hang.h>
Kever Yangb5b81f22020-08-20 17:32:52 +08008#include <led.h>
Simon Glassf7ae49f2020-05-10 11:40:05 -06009#include <log.h>
Simon Glass401d1c42020-10-30 21:38:53 -060010#include <asm/global_data.h>
Simon Glass7de8bd02021-08-07 07:24:01 -060011#include <dm/ofnode.h>
Kever Yang57d55db2019-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 Glass7de8bd02021-08-07 07:24:01 -060021 led_name = ofnode_conf_read_str("u-boot,boot-led");
Kever Yang57d55db2019-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 Yangb5b81f22020-08-20 17:32:52 +080029 ret = led_set_state(dev, LEDST_ON);
Kever Yang57d55db2019-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