]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/commitdiff
[ARM] 5259/2: [AT91] PWM LEDs on AT91SAM9263-EK
authorAndrew Victor <linux@maxim.org.za>
Sun, 21 Sep 2008 20:31:16 +0000 (21:31 +0100)
committerRussell King <rmk+kernel@arm.linux.org.uk>
Sun, 21 Sep 2008 21:58:38 +0000 (22:58 +0100)
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>
arch/arm/mach-at91/board-sam9263ek.c
arch/arm/mach-at91/include/mach/board.h
arch/arm/mach-at91/leds.c

index ad71f4a71451821996c09080553f7ba81a982488..2924b6884fe25b9f38e332aa32f213ef868a1e3d 100644 (file)
@@ -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")
index 9df4608b5f6ad477c5b477e89220ca4d6b1f972e..e852609d802f18a94dc4371d2300a5cc3df1b82d 100644 (file)
@@ -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);
index fec03c59ff94f382a9026bf699a95b00bd7804e0..ff76d59392cc19adc112234a4f7539dc0ffe865c 100644 (file)
@@ -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.
  */
@@ -55,6 +54,44 @@ void __init at91_gpio_leds(struct gpio_led *leds, int nr) {}
 #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)