summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilipp Tomsich <philipp.tomsich@theobroma-systems.com>2016-11-23 14:49:07 +0100
committerPhilipp Tomsich <philipp.tomsich@theobroma-systems.com>2017-03-09 01:40:09 +0100
commit6567c13bc44a2acbc94855ea79ee2d2eaf6196b7 (patch)
tree50c31f10977e32f809c4cd3b12aebbe8229551e9
parentafe9e12820a6016ba530f8b8254bf5c9011c701b (diff)
pangolin: Convert to the LED class for the on-module (power) LED
-rw-r--r--arch/arm/dts/sun6i-a31-pangolin-elcom.dts19
-rw-r--r--board/sunxi/board.c39
2 files changed, 46 insertions, 12 deletions
diff --git a/arch/arm/dts/sun6i-a31-pangolin-elcom.dts b/arch/arm/dts/sun6i-a31-pangolin-elcom.dts
index 8531c1d3c8..4c1ff67f6e 100644
--- a/arch/arm/dts/sun6i-a31-pangolin-elcom.dts
+++ b/arch/arm/dts/sun6i-a31-pangolin-elcom.dts
@@ -63,6 +63,22 @@
chosen {
stdout-path = "serial0:115200n8";
};
+
+ config {
+ u-boot,boot-led = "pangolin:orange:power";
+ };
+
+ leds {
+ compatible = "gpio-leds";
+ pinctrl-names = "default";
+ pinctrl-0 = <&led_pins_pangolin>;
+
+ power {
+ label = "pangolin:orange:power";
+ gpios = <&pio 7 7 GPIO_ACTIVE_HIGH>;
+ };
+
+ };
};
&ehci0 {
@@ -189,7 +205,8 @@
allwinner,drive = <SUN4I_PINCTRL_10_MA>;
allwinner,pull = <SUN4I_PINCTRL_PULL_UP>;
};
- leds_pins_pangolin: led_pins@0 {
+
+ led_pins_pangolin: led_pins@0 {
allwinner,pins = "PH7", "PC16";
allwinner,function = "gpio_out";
allwinner,drive = <SUN4I_PINCTRL_20_MA>;
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)