GPIO LEDS
From ArmadeusWiki
Revision as of 19:12, 2 May 2012 by GaelJ (Talk | contribs) (New page: How to use leds-gpio driver to manage states of connected leds of your Armadeus board. ==Introduction== You can manage a led connected to a GPIO pin. The managing is similar with the sta...)
How to use leds-gpio driver to manage states of connected leds of your Armadeus board.
Introduction
You can manage a led connected to a GPIO pin. The managing is similar with the standard GPIO sysfs driver, but you have some new features like triggers.
Configuration
First, you need to enable the leds-gpio driver in your kernel.
Device Drivers ---> --- LED support [*] LED Class Support <*> LED Support for GPIO connected LEDs [*] Platform device bindings for GPIO LEDs
Then, in your apf27-dev.c, you need to define your LED before the variable platform_devices[].
/* GPIO LED */
#if 1
/* PORTF_14 used as leds-gpio (GPIO used as LED) */
static struct gpio_led apf27_gpio_leds[] = {
{
.name = "portf14",
.default_trigger = "none",
.gpio = (GPIO_PORTF | 14),
//.active_low = 1,
//.retain_state_suspended = 1,
//.default_state = LEDS_GPIO_DEFSTATE_ON,
},
};
static struct gpio_led_platform_data apf27_gpio_leds_platform_data = {
.leds = apf27_gpio_leds,
.num_leds = ARRAY_SIZE(apf27_gpio_leds),
};
static struct platform_device apf27_gpio_leds_device = {
.name = "leds-gpio",
.id = 0,
.dev = {
.platform_data = &apf27_gpio_leds_platform_data,
},
};
# define LEDS_GPIO &apf27_gpio_leds_device,
#else
# define LEDS_GPIO
#endif
Add the button to get it recognized by the card.
static struct platform_device *platform_devices[] __initdata = {
ALSA_SOUND
LEDS_GPIO
};
# ls /sys/class/leds/portf14/ brightness max_brightness subsystem uevent device power trigger