[ARM] 5259/2: [AT91] PWM LEDs on AT91SAM9263-EK
Use the PWM controller and leds-atmel-pwm.c driver to drive a LED on the Atmel AT91SAM9263-EK board. Signed-off-by: Sedji Gaouaou <sedji.gaouaou@atmel.com> Signed-off-by: Andrew Victor <linux@maxim.org.za> Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
This commit is contained in:
parent
bb1ad68b96
commit
a7307bf225
|
@ -30,6 +30,7 @@
|
||||||
#include <linux/fb.h>
|
#include <linux/fb.h>
|
||||||
#include <linux/gpio_keys.h>
|
#include <linux/gpio_keys.h>
|
||||||
#include <linux/input.h>
|
#include <linux/input.h>
|
||||||
|
#include <linux/leds.h>
|
||||||
|
|
||||||
#include <video/atmel_lcdc.h>
|
#include <video/atmel_lcdc.h>
|
||||||
|
|
||||||
|
@ -339,25 +340,32 @@ static struct atmel_ac97_data ek_ac97_data = {
|
||||||
* LEDs ... these could all be PWM-driven, for variable brightness
|
* LEDs ... these could all be PWM-driven, for variable brightness
|
||||||
*/
|
*/
|
||||||
static struct gpio_led ek_leds[] = {
|
static struct gpio_led ek_leds[] = {
|
||||||
{ /* "left" led, green, userled1, pwm1 */
|
{ /* "right" led, green, userled2 (could be driven by pwm2) */
|
||||||
.name = "ds1",
|
|
||||||
.gpio = AT91_PIN_PB8,
|
|
||||||
.active_low = 1,
|
|
||||||
.default_trigger = "mmc0",
|
|
||||||
},
|
|
||||||
{ /* "right" led, green, userled2, pwm2 */
|
|
||||||
.name = "ds2",
|
.name = "ds2",
|
||||||
.gpio = AT91_PIN_PC29,
|
.gpio = AT91_PIN_PC29,
|
||||||
.active_low = 1,
|
.active_low = 1,
|
||||||
.default_trigger = "nand-disk",
|
.default_trigger = "nand-disk",
|
||||||
},
|
},
|
||||||
{ /* "power" led, yellow, pwm0 */
|
{ /* "power" led, yellow (could be driven by pwm0) */
|
||||||
.name = "ds3",
|
.name = "ds3",
|
||||||
.gpio = AT91_PIN_PB7,
|
.gpio = AT91_PIN_PB7,
|
||||||
.default_trigger = "heartbeat",
|
.default_trigger = "heartbeat",
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
* PWM Leds
|
||||||
|
*/
|
||||||
|
static struct gpio_led ek_pwm_led[] = {
|
||||||
|
/* For now only DS1 is PWM-driven (by pwm1) */
|
||||||
|
{
|
||||||
|
.name = "ds1",
|
||||||
|
.gpio = 1, /* is PWM channel number */
|
||||||
|
.active_low = 1,
|
||||||
|
.default_trigger = "none",
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
static void __init ek_board_init(void)
|
static void __init ek_board_init(void)
|
||||||
{
|
{
|
||||||
|
@ -388,6 +396,7 @@ static void __init ek_board_init(void)
|
||||||
at91_add_device_ac97(&ek_ac97_data);
|
at91_add_device_ac97(&ek_ac97_data);
|
||||||
/* LEDs */
|
/* LEDs */
|
||||||
at91_gpio_leds(ek_leds, ARRAY_SIZE(ek_leds));
|
at91_gpio_leds(ek_leds, ARRAY_SIZE(ek_leds));
|
||||||
|
at91_pwm_leds(ek_pwm_led, ARRAY_SIZE(ek_pwm_led));
|
||||||
}
|
}
|
||||||
|
|
||||||
MACHINE_START(AT91SAM9263EK, "Atmel AT91SAM9263-EK")
|
MACHINE_START(AT91SAM9263EK, "Atmel AT91SAM9263-EK")
|
||||||
|
|
|
@ -175,6 +175,7 @@ extern void __init at91_add_device_isi(void);
|
||||||
/* LEDs */
|
/* LEDs */
|
||||||
extern void __init at91_init_leds(u8 cpu_led, u8 timer_led);
|
extern void __init at91_init_leds(u8 cpu_led, u8 timer_led);
|
||||||
extern void __init at91_gpio_leds(struct gpio_led *leds, int nr);
|
extern void __init at91_gpio_leds(struct gpio_led *leds, int nr);
|
||||||
|
extern void __init at91_pwm_leds(struct gpio_led *leds, int nr);
|
||||||
|
|
||||||
/* FIXME: this needs a better location, but gets stuff building again */
|
/* FIXME: this needs a better location, but gets stuff building again */
|
||||||
extern int at91_suspend_entering_slow_clock(void);
|
extern int at91_suspend_entering_slow_clock(void);
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
#include <linux/kernel.h>
|
#include <linux/kernel.h>
|
||||||
#include <linux/module.h>
|
#include <linux/module.h>
|
||||||
#include <linux/init.h>
|
#include <linux/init.h>
|
||||||
|
#include <linux/platform_device.h>
|
||||||
|
|
||||||
#include <mach/board.h>
|
#include <mach/board.h>
|
||||||
#include <mach/gpio.h>
|
#include <mach/gpio.h>
|
||||||
|
@ -21,8 +22,6 @@
|
||||||
|
|
||||||
#if defined(CONFIG_NEW_LEDS)
|
#if defined(CONFIG_NEW_LEDS)
|
||||||
|
|
||||||
#include <linux/platform_device.h>
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* New cross-platform LED support.
|
* New cross-platform LED support.
|
||||||
*/
|
*/
|
||||||
|
@ -55,6 +54,44 @@ void __init at91_gpio_leds(struct gpio_led *leds, int nr) {}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
/* ------------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
#if defined (CONFIG_LEDS_ATMEL_PWM)
|
||||||
|
|
||||||
|
/*
|
||||||
|
* PWM Leds
|
||||||
|
*/
|
||||||
|
|
||||||
|
static struct gpio_led_platform_data pwm_led_data;
|
||||||
|
|
||||||
|
static struct platform_device at91_pwm_leds = {
|
||||||
|
.name = "leds-atmel-pwm",
|
||||||
|
.id = -1,
|
||||||
|
.dev.platform_data = &pwm_led_data,
|
||||||
|
};
|
||||||
|
|
||||||
|
void __init at91_pwm_leds(struct gpio_led *leds, int nr)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
u32 pwm_mask = 0;
|
||||||
|
|
||||||
|
if (!nr)
|
||||||
|
return;
|
||||||
|
|
||||||
|
for (i = 0; i < nr; i++)
|
||||||
|
pwm_mask |= (1 << leds[i].gpio);
|
||||||
|
|
||||||
|
pwm_led_data.leds = leds;
|
||||||
|
pwm_led_data.num_leds = nr;
|
||||||
|
|
||||||
|
at91_add_device_pwm(pwm_mask);
|
||||||
|
platform_device_register(&at91_pwm_leds);
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
void __init at91_pwm_leds(struct gpio_led *leds, int nr){}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/* ------------------------------------------------------------------------- */
|
/* ------------------------------------------------------------------------- */
|
||||||
|
|
||||||
#if defined(CONFIG_LEDS)
|
#if defined(CONFIG_LEDS)
|
||||||
|
|
Loading…
Reference in New Issue