[PATCH 2/6] raspberry-pi: add leds support

Antony Pavlov antonynpavlov at gmail.com
Mon Jan 12 23:58:40 PST 2015


On Tue, 13 Jan 2015 07:26:12 +0100
Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com> wrote:

I have planned to switch raspberry pi to device tree support as Linux does.

IMHO POWER LED is not GPIO controlable, please see these schematics

   http://www.raspberrypi.org/wp-content/uploads/2012/04/Raspberry-Pi-Schematics-R1.0.pdf
   http://www.raspberrypi.org/documentation/hardware/raspberrypi/schematics/Raspberry-Pi-B-Plus-V1.2-Schematics.pdf


> Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com>
> ---
>  arch/arm/boards/raspberry-pi/rpi.c | 55 ++++++++++++++++++++++++++++++++++++++
>  1 file changed, 55 insertions(+)
> 
> diff --git a/arch/arm/boards/raspberry-pi/rpi.c b/arch/arm/boards/raspberry-pi/rpi.c
> index ae1e92a..7d866cc 100644
> --- a/arch/arm/boards/raspberry-pi/rpi.c
> +++ b/arch/arm/boards/raspberry-pi/rpi.c
> @@ -21,6 +21,8 @@
>  #include <linux/clkdev.h>
>  #include <envfs.h>
>  #include <malloc.h>
> +#include <gpio.h>
> +#include <led.h>
>  #include <asm/armlinux.h>
>  #include <generated/mach-types.h>
>  
> @@ -87,6 +89,49 @@ static int rpi_register_clkdev(u32 clock_id, const char *name)
>  }
>  
>  
> +static struct gpio_led leds[] = {
> +	{
> +		.gpio	= -EINVAL,
> +		.led	= {
> +			.name = "ACT",
> +		},
> +	}, {
> +		.gpio	= -EINVAL,
> +		.led	= {
> +			.name = "PWR",
> +		},
> +	},
> +};
> +
> +static void rpi_add_led(void)
> +{
> +	int i;
> +	struct gpio_led *l;
> +
> +	for (i = 0; i < ARRAY_SIZE(leds); i++) {
> +		l = &leds[i];
> +
> +		if (gpio_is_valid(l->gpio))
> +			led_gpio_register(l);
> +	}
> +
> +	l = &leds[0];
> +	if (gpio_is_valid(l->gpio))
> +		led_set_trigger(LED_TRIGGER_HEARTBEAT, &l->led);
> +}
> +
> +static void rpi_b_plus_init(void)
> +{
> +	leds[0].gpio = 47;
> +	leds[1].gpio = 35;
> +}
> +
> +static void rpi_b_init(void)
> +{
> +	leds[0].gpio = 16;
> +	leds[0].active_low = 1;
> +}
> +
>  #define RPI_MODEL(_id, _name, _init)	\
>  	[_id] = {				\
>  		.name			= _name,\
> @@ -160,6 +205,15 @@ unknown_rev:
>  	barebox_set_model("RaspberryPi (BCM2835/ARM1176JZF-S)");
>  }
>  
> +static void rpi_model_init(void)
> +{
> +	rpi_set_usbethaddr();
> +	if (models[rpi_board_rev].init) {
> +		models[rpi_board_rev].init();
> +		rpi_add_led();
> +	}
> +}
> +
>  static int rpi_mem_init(void)
>  {
>  	u32 size = 0;
> @@ -220,6 +274,7 @@ static int rpi_env_init(void)
>  
>  static int rpi_devices_init(void)
>  {
> +	rpi_model_init();
>  	bcm2835_register_mci();
>  	bcm2835_register_fb();
>  	armlinux_set_architecture(MACH_TYPE_BCM2708);
> -- 
> 2.1.3
> 
> 
> _______________________________________________
> barebox mailing list
> barebox at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox


-- 
-- 
Best regards,
  Antony Pavlov



More information about the barebox mailing list