Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Simon Glass | ec3be54 | 2015-08-30 16:55:41 -0600 | [diff] [blame] | 2 | /* |
3 | * (C) Copyright 2015 Google, Inc | ||||
Simon Glass | ec3be54 | 2015-08-30 16:55:41 -0600 | [diff] [blame] | 4 | */ |
5 | |||||
Simon Glass | f11478f | 2019-12-28 10:45:07 -0700 | [diff] [blame] | 6 | #include <hang.h> |
Kever Yang | 4c99fa5 | 2020-08-20 17:32:52 +0800 | [diff] [blame] | 7 | #include <led.h> |
Simon Glass | 0f2af88 | 2020-05-10 11:40:05 -0600 | [diff] [blame] | 8 | #include <log.h> |
Simon Glass | 3ba929a | 2020-10-30 21:38:53 -0600 | [diff] [blame] | 9 | #include <asm/global_data.h> |
Simon Glass | 0034d96 | 2021-08-07 07:24:01 -0600 | [diff] [blame] | 10 | #include <dm/ofnode.h> |
Kever Yang | ca09f9a | 2019-07-22 19:59:24 +0800 | [diff] [blame] | 11 | |
Simon Glass | 49c24a8 | 2024-09-29 19:49:47 -0600 | [diff] [blame] | 12 | #ifdef CONFIG_XPL_BUILD |
Kever Yang | ca09f9a | 2019-07-22 19:59:24 +0800 | [diff] [blame] | 13 | static int setup_led(void) |
14 | { | ||||
15 | #ifdef CONFIG_SPL_LED | ||||
16 | struct udevice *dev; | ||||
17 | char *led_name; | ||||
18 | int ret; | ||||
19 | |||||
Simon Glass | 0034d96 | 2021-08-07 07:24:01 -0600 | [diff] [blame] | 20 | led_name = ofnode_conf_read_str("u-boot,boot-led"); |
Kever Yang | ca09f9a | 2019-07-22 19:59:24 +0800 | [diff] [blame] | 21 | 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 Yang | 4c99fa5 | 2020-08-20 17:32:52 +0800 | [diff] [blame] | 28 | ret = led_set_state(dev, LEDST_ON); |
Kever Yang | ca09f9a | 2019-07-22 19:59:24 +0800 | [diff] [blame] | 29 | if (ret) |
30 | return ret; | ||||
31 | #endif | ||||
32 | |||||
33 | return 0; | ||||
34 | } | ||||
35 | |||||
36 | void 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 |