diff options
author | Andrew Victor <linux@maxim.org.za> | 2008-09-21 21:31:16 +0100 |
---|---|---|
committer | Russell King <rmk+kernel@arm.linux.org.uk> | 2008-09-21 22:58:38 +0100 |
commit | a7307bf22557e1e029df0ea6f2a2973de4d9c135 (patch) | |
tree | c1db7709cc089b3494ed6a0e97ca0dd5dbeece88 | |
parent | bb1ad68b96a68e577a87ad62fe1aa26d052a52b5 (diff) |
[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>
-rw-r--r-- | arch/arm/mach-at91/board-sam9263ek.c | 25 | ||||
-rw-r--r-- | arch/arm/mach-at91/include/mach/board.h | 1 | ||||
-rw-r--r-- | arch/arm/mach-at91/leds.c | 41 |
3 files changed, 57 insertions, 10 deletions
diff --git a/arch/arm/mach-at91/board-sam9263ek.c b/arch/arm/mach-at91/board-sam9263ek.c index ad71f4a71451..2924b6884fe2 100644 --- a/arch/arm/mach-at91/board-sam9263ek.c +++ b/arch/arm/mach-at91/board-sam9263ek.c @@ -30,6 +30,7 @@ #include <linux/fb.h> #include <linux/gpio_keys.h> #include <linux/input.h> +#include <linux/leds.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 */ static struct gpio_led ek_leds[] = { - { /* "left" led, green, userled1, pwm1 */ - .name = "ds1", - .gpio = AT91_PIN_PB8, - .active_low = 1, - .default_trigger = "mmc0", - }, - { /* "right" led, green, userled2, pwm2 */ + { /* "right" led, green, userled2 (could be driven by pwm2) */ .name = "ds2", .gpio = AT91_PIN_PC29, .active_low = 1, .default_trigger = "nand-disk", }, - { /* "power" led, yellow, pwm0 */ + { /* "power" led, yellow (could be driven by pwm0) */ .name = "ds3", .gpio = AT91_PIN_PB7, .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) { @@ -388,6 +396,7 @@ static void __init ek_board_init(void) at91_add_device_ac97(&ek_ac97_data); /* 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") diff --git a/arch/arm/mach-at91/include/mach/board.h b/arch/arm/mach-at91/include/mach/board.h index 9df4608b5f6a..e852609d802f 100644 --- a/arch/arm/mach-at91/include/mach/board.h +++ b/arch/arm/mach-at91/include/mach/board.h @@ -175,6 +175,7 @@ extern void __init at91_add_device_isi(void); /* LEDs */ 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_pwm_leds(struct gpio_led *leds, int nr); /* FIXME: this needs a better location, but gets stuff building again */ extern int at91_suspend_entering_slow_clock(void); diff --git a/arch/arm/mach-at91/leds.c b/arch/arm/mach-at91/leds.c index fec03c59ff94..ff76d59392cc 100644 --- a/arch/arm/mach-at91/leds.c +++ b/arch/arm/mach-at91/leds.c @@ -12,6 +12,7 @@ #include <linux/kernel.h> #include <linux/module.h> #include <linux/init.h> +#include <linux/platform_device.h> #include <mach/board.h> #include <mach/gpio.h> @@ -21,8 +22,6 @@ #if defined(CONFIG_NEW_LEDS) -#include <linux/platform_device.h> - /* * New cross-platform LED support. */ @@ -57,6 +56,44 @@ void __init at91_gpio_leds(struct gpio_led *leds, int nr) {} /* ------------------------------------------------------------------------- */ +#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) #include <asm/leds.h> |