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 | |
| 6 | #include <common.h> |
Simon Glass | f11478f | 2019-12-28 10:45:07 -0700 | [diff] [blame] | 7 | #include <hang.h> |
Kever Yang | 4c99fa5 | 2020-08-20 17:32:52 +0800 | [diff] [blame] | 8 | #include <led.h> |
Simon Glass | 0f2af88 | 2020-05-10 11:40:05 -0600 | [diff] [blame] | 9 | #include <log.h> |
Simon Glass | 3ba929a | 2020-10-30 21:38:53 -0600 | [diff] [blame] | 10 | #include <asm/global_data.h> |
Simon Glass | 0034d96 | 2021-08-07 07:24:01 -0600 | [diff] [blame] | 11 | #include <dm/ofnode.h> |
Kever Yang | ca09f9a | 2019-07-22 19:59:24 +0800 | [diff] [blame] | 12 | |
| 13 | #ifdef CONFIG_SPL_BUILD |
| 14 | static int setup_led(void) |
| 15 | { |
| 16 | #ifdef CONFIG_SPL_LED |
| 17 | struct udevice *dev; |
| 18 | char *led_name; |
| 19 | int ret; |
| 20 | |
Simon Glass | 0034d96 | 2021-08-07 07:24:01 -0600 | [diff] [blame] | 21 | led_name = ofnode_conf_read_str("u-boot,boot-led"); |
Kever Yang | ca09f9a | 2019-07-22 19:59:24 +0800 | [diff] [blame] | 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 Yang | 4c99fa5 | 2020-08-20 17:32:52 +0800 | [diff] [blame] | 29 | ret = led_set_state(dev, LEDST_ON); |
Kever Yang | ca09f9a | 2019-07-22 19:59:24 +0800 | [diff] [blame] | 30 | if (ret) |
| 31 | return ret; |
| 32 | #endif |
| 33 | |
| 34 | return 0; |
| 35 | } |
| 36 | |
| 37 | void 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 |