diff options
author | Philipp Tomsich <philipp.tomsich@theobroma-systems.com> | 2016-11-23 14:49:07 +0100 |
---|---|---|
committer | Philipp Tomsich <philipp.tomsich@theobroma-systems.com> | 2017-03-09 01:40:09 +0100 |
commit | 6567c13bc44a2acbc94855ea79ee2d2eaf6196b7 (patch) | |
tree | 50c31f10977e32f809c4cd3b12aebbe8229551e9 /board | |
parent | afe9e12820a6016ba530f8b8254bf5c9011c701b (diff) |
pangolin: Convert to the LED class for the on-module (power) LED
Diffstat (limited to 'board')
-rw-r--r-- | board/sunxi/board.c | 39 |
1 files changed, 28 insertions, 11 deletions
diff --git a/board/sunxi/board.c b/board/sunxi/board.c index a663e352b3..05fa829167 100644 --- a/board/sunxi/board.c +++ b/board/sunxi/board.c @@ -11,6 +11,8 @@ * SPDX-License-Identifier: GPL-2.0+ */ +#define DEBUG + #include <common.h> #include <mmc.h> #include <axp_pmic.h> @@ -78,6 +80,31 @@ static int soft_i2c_board_init(void) static int soft_i2c_board_init(void) { return 0; } #endif +static int setup_led(void) +{ +#if defined(CONFIG_LED) + struct udevice *dev; + char *led_name; + int ret; + + led_name = fdtdec_get_config_string(gd->fdt_blob, "u-boot,boot-led"); + if (!led_name) { + debug("%s: 'u-boot,boot-led' not defined\n", __func__); + return 0; + } + ret = led_get_by_label(led_name, &dev); + if (ret) { + debug("%s: get=%d\n", __func__, ret); + return ret; + } + ret = led_set_on(dev, 1); + if (ret) + return ret; +#endif + + return 0; +} + /* add board specific code here */ int board_init(void) { @@ -126,8 +153,6 @@ int board_init(void) sunxi_gpio_set_cfgpin(SUNXI_GPA(7), SUNXI_GPIO_OUTPUT); gpio_direction_output(SUNXI_GPA(7), 0); #endif - gpio_request(SUNXI_GPH(7), "LED"); - sunxi_gpio_set_cfgpin(SUNXI_GPH(7), SUNXI_GPIO_OUTPUT); gpio_direction_output(SUNXI_GPC(3), 0); gpio_direction_output(SUNXI_GPC(26), 0); @@ -137,15 +162,7 @@ int board_init(void) gpio_direction_output(SUNXI_GPA(7), 1); #endif - // Blink LED - int i; - for(i=0;i<=2;i++) - { - mdelay(30); - gpio_direction_output(SUNXI_GPH(7), 0); - mdelay(30); - gpio_direction_output(SUNXI_GPH(7), 1); - } + setup_led(); ret = axp_gpio_init(); if (ret) |