diff options
author | Andrew Victor <linux@maxim.org.za> | 2008-09-21 16:31:16 -0400 |
---|---|---|
committer | Russell King <rmk+kernel@arm.linux.org.uk> | 2008-09-21 17:58:38 -0400 |
commit | a7307bf22557e1e029df0ea6f2a2973de4d9c135 (patch) | |
tree | c1db7709cc089b3494ed6a0e97ca0dd5dbeece88 /arch/arm/mach-at91 | |
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>
Diffstat (limited to 'arch/arm/mach-at91')
-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 @@ | |||
30 | #include <linux/fb.h> | 30 | #include <linux/fb.h> |
31 | #include <linux/gpio_keys.h> | 31 | #include <linux/gpio_keys.h> |
32 | #include <linux/input.h> | 32 | #include <linux/input.h> |
33 | #include <linux/leds.h> | ||
33 | 34 | ||
34 | #include <video/atmel_lcdc.h> | 35 | #include <video/atmel_lcdc.h> |
35 | 36 | ||
@@ -339,25 +340,32 @@ static struct atmel_ac97_data ek_ac97_data = { | |||
339 | * LEDs ... these could all be PWM-driven, for variable brightness | 340 | * LEDs ... these could all be PWM-driven, for variable brightness |
340 | */ | 341 | */ |
341 | static struct gpio_led ek_leds[] = { | 342 | static struct gpio_led ek_leds[] = { |
342 | { /* "left" led, green, userled1, pwm1 */ | 343 | { /* "right" led, green, userled2 (could be driven by pwm2) */ |
343 | .name = "ds1", | ||
344 | .gpio = AT91_PIN_PB8, | ||
345 | .active_low = 1, | ||
346 | .default_trigger = "mmc0", | ||
347 | }, | ||
348 | { /* "right" led, green, userled2, pwm2 */ | ||
349 | .name = "ds2", | 344 | .name = "ds2", |
350 | .gpio = AT91_PIN_PC29, | 345 | .gpio = AT91_PIN_PC29, |
351 | .active_low = 1, | 346 | .active_low = 1, |
352 | .default_trigger = "nand-disk", | 347 | .default_trigger = "nand-disk", |
353 | }, | 348 | }, |
354 | { /* "power" led, yellow, pwm0 */ | 349 | { /* "power" led, yellow (could be driven by pwm0) */ |
355 | .name = "ds3", | 350 | .name = "ds3", |
356 | .gpio = AT91_PIN_PB7, | 351 | .gpio = AT91_PIN_PB7, |
357 | .default_trigger = "heartbeat", | 352 | .default_trigger = "heartbeat", |
358 | } | 353 | } |
359 | }; | 354 | }; |
360 | 355 | ||
356 | /* | ||
357 | * PWM Leds | ||
358 | */ | ||
359 | static struct gpio_led ek_pwm_led[] = { | ||
360 | /* For now only DS1 is PWM-driven (by pwm1) */ | ||
361 | { | ||
362 | .name = "ds1", | ||
363 | .gpio = 1, /* is PWM channel number */ | ||
364 | .active_low = 1, | ||
365 | .default_trigger = "none", | ||
366 | } | ||
367 | }; | ||
368 | |||
361 | 369 | ||
362 | static void __init ek_board_init(void) | 370 | static void __init ek_board_init(void) |
363 | { | 371 | { |
@@ -388,6 +396,7 @@ static void __init ek_board_init(void) | |||
388 | at91_add_device_ac97(&ek_ac97_data); | 396 | at91_add_device_ac97(&ek_ac97_data); |
389 | /* LEDs */ | 397 | /* LEDs */ |
390 | at91_gpio_leds(ek_leds, ARRAY_SIZE(ek_leds)); | 398 | at91_gpio_leds(ek_leds, ARRAY_SIZE(ek_leds)); |
399 | at91_pwm_leds(ek_pwm_led, ARRAY_SIZE(ek_pwm_led)); | ||
391 | } | 400 | } |
392 | 401 | ||
393 | MACHINE_START(AT91SAM9263EK, "Atmel AT91SAM9263-EK") | 402 | 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); | |||
175 | /* LEDs */ | 175 | /* LEDs */ |
176 | extern void __init at91_init_leds(u8 cpu_led, u8 timer_led); | 176 | extern void __init at91_init_leds(u8 cpu_led, u8 timer_led); |
177 | extern void __init at91_gpio_leds(struct gpio_led *leds, int nr); | 177 | extern void __init at91_gpio_leds(struct gpio_led *leds, int nr); |
178 | extern void __init at91_pwm_leds(struct gpio_led *leds, int nr); | ||
178 | 179 | ||
179 | /* FIXME: this needs a better location, but gets stuff building again */ | 180 | /* FIXME: this needs a better location, but gets stuff building again */ |
180 | extern int at91_suspend_entering_slow_clock(void); | 181 | 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 @@ | |||
12 | #include <linux/kernel.h> | 12 | #include <linux/kernel.h> |
13 | #include <linux/module.h> | 13 | #include <linux/module.h> |
14 | #include <linux/init.h> | 14 | #include <linux/init.h> |
15 | #include <linux/platform_device.h> | ||
15 | 16 | ||
16 | #include <mach/board.h> | 17 | #include <mach/board.h> |
17 | #include <mach/gpio.h> | 18 | #include <mach/gpio.h> |
@@ -21,8 +22,6 @@ | |||
21 | 22 | ||
22 | #if defined(CONFIG_NEW_LEDS) | 23 | #if defined(CONFIG_NEW_LEDS) |
23 | 24 | ||
24 | #include <linux/platform_device.h> | ||
25 | |||
26 | /* | 25 | /* |
27 | * New cross-platform LED support. | 26 | * New cross-platform LED support. |
28 | */ | 27 | */ |
@@ -57,6 +56,44 @@ void __init at91_gpio_leds(struct gpio_led *leds, int nr) {} | |||
57 | 56 | ||
58 | /* ------------------------------------------------------------------------- */ | 57 | /* ------------------------------------------------------------------------- */ |
59 | 58 | ||
59 | #if defined (CONFIG_LEDS_ATMEL_PWM) | ||
60 | |||
61 | /* | ||
62 | * PWM Leds | ||
63 | */ | ||
64 | |||
65 | static struct gpio_led_platform_data pwm_led_data; | ||
66 | |||
67 | static struct platform_device at91_pwm_leds = { | ||
68 | .name = "leds-atmel-pwm", | ||
69 | .id = -1, | ||
70 | .dev.platform_data = &pwm_led_data, | ||
71 | }; | ||
72 | |||
73 | void __init at91_pwm_leds(struct gpio_led *leds, int nr) | ||
74 | { | ||
75 | int i; | ||
76 | u32 pwm_mask = 0; | ||
77 | |||
78 | if (!nr) | ||
79 | return; | ||
80 | |||
81 | for (i = 0; i < nr; i++) | ||
82 | pwm_mask |= (1 << leds[i].gpio); | ||
83 | |||
84 | pwm_led_data.leds = leds; | ||
85 | pwm_led_data.num_leds = nr; | ||
86 | |||
87 | at91_add_device_pwm(pwm_mask); | ||
88 | platform_device_register(&at91_pwm_leds); | ||
89 | } | ||
90 | #else | ||
91 | void __init at91_pwm_leds(struct gpio_led *leds, int nr){} | ||
92 | #endif | ||
93 | |||
94 | |||
95 | /* ------------------------------------------------------------------------- */ | ||
96 | |||
60 | #if defined(CONFIG_LEDS) | 97 | #if defined(CONFIG_LEDS) |
61 | 98 | ||
62 | #include <asm/leds.h> | 99 | #include <asm/leds.h> |