ARM: at91: convert old leds drivers to gpio_led and led_trigger drivers
authorBryan Wu <bryan.wu@canonical.com>
Tue, 13 Mar 2012 09:47:33 +0000 (17:47 +0800)
committerBryan Wu <bryan.wu@canonical.com>
Tue, 31 Jul 2012 13:23:32 +0000 (21:23 +0800)
Build with at91 defconfigs successfully

Signed-off-by: Bryan Wu <bryan.wu@canonical.com>
Acked-by: Nicolas Ferre <nicolas.ferre@atmel.com>
13 files changed:
arch/arm/mach-at91/board-csb337.c
arch/arm/mach-at91/board-ecbat91.c
arch/arm/mach-at91/board-eco920.c
arch/arm/mach-at91/board-kafa.c
arch/arm/mach-at91/board-kb9202.c
arch/arm/mach-at91/board-rm9200dk.c
arch/arm/mach-at91/board-rm9200ek.c
arch/arm/mach-at91/board-rsi-ews.c
arch/arm/mach-at91/board-sam9-l9260.c
arch/arm/mach-at91/board-sam9261ek.c
arch/arm/mach-at91/board-yl-9200.c
arch/arm/mach-at91/include/mach/board.h
arch/arm/mach-at91/leds.c

index cd813361cd26be2d61a49de0f536f3be0ac1059d..4993f1bfa1a753493e88521bdd6103716dd84fed 100644 (file)
@@ -219,8 +219,6 @@ static struct gpio_led csb_leds[] = {
 
 static void __init csb337_board_init(void)
 {
-       /* Setup the LEDs */
-       at91_init_leds(AT91_PIN_PB0, AT91_PIN_PB1);
        /* Serial */
        /* DBGU on ttyS0 */
        at91_register_uart(0, 0, 0);
index 89cc3726a9ce1f3b57f5c589b5d495d1a6c5d4db..f9a4ab93b152c5d7b67b61a9ba5013e3a53c5858 100644 (file)
@@ -137,11 +137,20 @@ static struct spi_board_info __initdata ecb_at91spi_devices[] = {
        },
 };
 
+/*
+ * LEDs
+ */
+static struct gpio_led ecb_leds[] = {
+       {       /* D1 */
+               .name                   = "led1",
+               .gpio                   = AT91_PIN_PC7,
+               .active_low             = 1,
+               .default_trigger        = "heartbeat",
+       }
+};
+
 static void __init ecb_at91board_init(void)
 {
-       /* Setup the LEDs */
-       at91_init_leds(AT91_PIN_PC7, AT91_PIN_PC7);
-
        /* Serial */
        /* DBGU on ttyS0. (Rx & Tx only) */
        at91_register_uart(0, 0, 0);
@@ -164,6 +173,9 @@ static void __init ecb_at91board_init(void)
 
        /* SPI */
        at91_add_device_spi(ecb_at91spi_devices, ARRAY_SIZE(ecb_at91spi_devices));
+
+       /* LEDs */
+       at91_gpio_leds(ecb_leds, ARRAY_SIZE(ecb_leds));
 }
 
 MACHINE_START(ECBAT91, "emQbit's ECB_AT91")
index 558546cf63f492bf46d5b290b389e019f428244a..76cc82632ab59c18e32921cbb8bdc9da13f9fbb6 100644 (file)
@@ -92,10 +92,26 @@ static struct spi_board_info eco920_spi_devices[] = {
        },
 };
 
+/*
+ * LEDs
+ */
+static struct gpio_led eco920_leds[] = {
+       {       /* D1 */
+               .name                   = "led1",
+               .gpio                   = AT91_PIN_PB0,
+               .active_low             = 1,
+               .default_trigger        = "heartbeat",
+       },
+       {       /* D2 */
+               .name                   = "led2",
+               .gpio                   = AT91_PIN_PB1,
+               .active_low             = 1,
+               .default_trigger        = "timer",
+       }
+};
+
 static void __init eco920_board_init(void)
 {
-       /* Setup the LEDs */
-       at91_init_leds(AT91_PIN_PB0, AT91_PIN_PB1);
        /* DBGU on ttyS0. (Rx & Tx only */
        at91_register_uart(0, 0, 0);
        at91_add_device_serial();
@@ -126,6 +142,8 @@ static void __init eco920_board_init(void)
        );
 
        at91_add_device_spi(eco920_spi_devices, ARRAY_SIZE(eco920_spi_devices));
+       /* LEDs */
+       at91_gpio_leds(eco920_leds, ARRAY_SIZE(eco920_leds));
 }
 
 MACHINE_START(ECO920, "eco920")
index f260657f32bcf5881b3d2aa98fa9d442f992a4df..8db11f41fe8c676bbc0317aa97d5529c42c5e85c 100644 (file)
@@ -65,11 +65,20 @@ static struct at91_udc_data __initdata kafa_udc_data = {
        .pullup_pin     = AT91_PIN_PB7,
 };
 
+/*
+ * LEDs
+ */
+static struct gpio_led kafa_leds[] = {
+       {       /* D1 */
+               .name                   = "led1",
+               .gpio                   = AT91_PIN_PB4,
+               .active_low             = 1,
+               .default_trigger        = "heartbeat",
+       },
+};
+
 static void __init kafa_board_init(void)
 {
-       /* Set up the LEDs */
-       at91_init_leds(AT91_PIN_PB4, AT91_PIN_PB4);
-
        /* Serial */
        /* DBGU on ttyS0. (Rx & Tx only) */
        at91_register_uart(0, 0, 0);
@@ -87,6 +96,8 @@ static void __init kafa_board_init(void)
        at91_add_device_i2c(NULL, 0);
        /* SPI */
        at91_add_device_spi(NULL, 0);
+       /* LEDs */
+       at91_gpio_leds(kafa_leds, ARRAY_SIZE(kafa_leds));
 }
 
 MACHINE_START(KAFA, "Sperry-Sun KAFA")
index ba39db5482b955617689e7f65adb39e245915738..4e362b8ec8cc751f88fab93deef726c9dbfcb0fc 100644 (file)
@@ -95,11 +95,26 @@ static struct atmel_nand_data __initdata kb9202_nand_data = {
        .num_parts      = ARRAY_SIZE(kb9202_nand_partition),
 };
 
+/*
+ * LEDs
+ */
+static struct gpio_led kb9202_leds[] = {
+       {       /* D1 */
+               .name                   = "led1",
+               .gpio                   = AT91_PIN_PC19,
+               .active_low             = 1,
+               .default_trigger        = "heartbeat",
+       },
+       {       /* D2 */
+               .name                   = "led2",
+               .gpio                   = AT91_PIN_PC18,
+               .active_low             = 1,
+               .default_trigger        = "timer",
+       }
+};
+
 static void __init kb9202_board_init(void)
 {
-       /* Set up the LEDs */
-       at91_init_leds(AT91_PIN_PC19, AT91_PIN_PC18);
-
        /* Serial */
        /* DBGU on ttyS0. (Rx & Tx only) */
        at91_register_uart(0, 0, 0);
@@ -127,6 +142,8 @@ static void __init kb9202_board_init(void)
        at91_add_device_spi(NULL, 0);
        /* NAND */
        at91_add_device_nand(&kb9202_nand_data);
+       /* LEDs */
+       at91_gpio_leds(kb9202_leds, ARRAY_SIZE(kb9202_leds));
 }
 
 MACHINE_START(KB9200, "KB920x")
index afd7a4713766cec538c1736daf0895f691d6ebf3..7417b7c835c877b0247c356d2425d20006f6cc3d 100644 (file)
@@ -176,9 +176,6 @@ static struct gpio_led dk_leds[] = {
 
 static void __init dk_board_init(void)
 {
-       /* Setup the LEDs */
-       at91_init_leds(AT91_PIN_PB2, AT91_PIN_PB2);
-
        /* Serial */
        /* DBGU on ttyS0. (Rx & Tx only) */
        at91_register_uart(0, 0, 0);
index 2b15b8adec4ccb9c671fab7e2423a59f2860ad89..18b2ec0cf24ca203c22caf1908c9ce07d585959a 100644 (file)
@@ -147,9 +147,6 @@ static struct gpio_led ek_leds[] = {
 
 static void __init ek_board_init(void)
 {
-       /* Setup the LEDs */
-       at91_init_leds(AT91_PIN_PB1, AT91_PIN_PB2);
-
        /* Serial */
        /* DBGU on ttyS0. (Rx & Tx only) */
        at91_register_uart(0, 0, 0);
index 24ab9be7510fbe5f6cdd3296be794fd7affa8cdc..32342b8304b4b27cbaa34bb1b3173737f7955b44 100644 (file)
@@ -184,9 +184,6 @@ static struct platform_device rsiews_nor_flash = {
  */
 static void __init rsi_ews_board_init(void)
 {
-       /* Setup the LEDs */
-       at91_init_leds(AT91_PIN_PB6, AT91_PIN_PB9);
-
        /* Serial */
        /* DBGU on ttyS0. (Rx & Tx only) */
        /* This one is for debugging */
index cdd21f2595d2220de8fc828f636d240e0d0b1476..ef982f8f71c0a6d4f5d88fc8f6089af7e9127b8a 100644 (file)
@@ -165,11 +165,26 @@ static struct at91_mmc_data __initdata ek_mmc_data = {
        .vcc_pin        = -EINVAL,
 };
 
+/*
+ * LEDs
+ */
+static struct gpio_led ek_leds[] = {
+       {       /* D1 */
+               .name                   = "led1",
+               .gpio                   = AT91_PIN_PA9,
+               .active_low             = 1,
+               .default_trigger        = "heartbeat",
+       },
+       {       /* D2 */
+               .name                   = "led2",
+               .gpio                   = AT91_PIN_PA6,
+               .active_low             = 1,
+               .default_trigger        = "timer",
+       }
+};
+
 static void __init ek_board_init(void)
 {
-       /* Setup the LEDs */
-       at91_init_leds(AT91_PIN_PA9, AT91_PIN_PA6);
-
        /* Serial */
        /* DBGU on ttyS0. (Rx & Tx only) */
        at91_register_uart(0, 0, 0);
@@ -196,6 +211,8 @@ static void __init ek_board_init(void)
        at91_add_device_mmc(0, &ek_mmc_data);
        /* I2C */
        at91_add_device_i2c(NULL, 0);
+       /* LEDs */
+       at91_gpio_leds(ek_leds, ARRAY_SIZE(ek_leds));
 }
 
 MACHINE_START(SAM9_L9260, "Olimex SAM9-L9260")
index 2736453821b0d55e9782d065107c176102ca4c35..0b4501c7b7272e5525eba7a47d737d16e92ae73a 100644 (file)
@@ -568,9 +568,6 @@ static struct gpio_led ek_leds[] = {
 
 static void __init ek_board_init(void)
 {
-       /* Setup the LEDs */
-       at91_init_leds(AT91_PIN_PA13, AT91_PIN_PA14);
-
        /* Serial */
        /* DBGU on ttyS0. (Rx & Tx only) */
        at91_register_uart(0, 0, 0);
index d56665ea4b55d3a8259228d8801fe20a547b9bab..cc05dd15bfcdff391d3ec23567179d4193e05bff 100644 (file)
@@ -540,9 +540,6 @@ void __init yl9200_add_device_video(void) {}
 
 static void __init yl9200_board_init(void)
 {
-       /* Setup the LEDs D2=PB17 (timer), D3=PB16 (cpu) */
-       at91_init_leds(AT91_PIN_PB16, AT91_PIN_PB17);
-
        /* Serial */
        /* DBGU on ttyS0. (Rx & Tx only) */
        at91_register_uart(0, 0, 0);
index 369afc2ffc5b972934872aa9266c8a8b774e9bec..c55a4364ffb433867aa150485880f7467081625f 100644 (file)
@@ -187,7 +187,6 @@ struct at91_can_data {
 extern void __init at91_add_device_can(struct at91_can_data *data);
 
  /* 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);
 
index 8dfafe76ffe6298f822ad2b4d3ea64ebf0243337..1b1e62b5f41be1e8b3249cb0961c19b43bbcf417 100644 (file)
@@ -90,108 +90,3 @@ void __init at91_pwm_leds(struct gpio_led *leds, int nr)
 #else
 void __init at91_pwm_leds(struct gpio_led *leds, int nr){}
 #endif
-
-
-/* ------------------------------------------------------------------------- */
-
-#if defined(CONFIG_LEDS)
-
-#include <asm/leds.h>
-
-/*
- * Old ARM-specific LED framework; not fully functional when generic time is
- * in use.
- */
-
-static u8 at91_leds_cpu;
-static u8 at91_leds_timer;
-
-static inline void at91_led_on(unsigned int led)
-{
-       at91_set_gpio_value(led, 0);
-}
-
-static inline void at91_led_off(unsigned int led)
-{
-       at91_set_gpio_value(led, 1);
-}
-
-static inline void at91_led_toggle(unsigned int led)
-{
-       unsigned long is_off = at91_get_gpio_value(led);
-       if (is_off)
-               at91_led_on(led);
-       else
-               at91_led_off(led);
-}
-
-
-/*
- * Handle LED events.
- */
-static void at91_leds_event(led_event_t evt)
-{
-       unsigned long flags;
-
-       local_irq_save(flags);
-
-       switch(evt) {
-       case led_start:         /* System startup */
-               at91_led_on(at91_leds_cpu);
-               break;
-
-       case led_stop:          /* System stop / suspend */
-               at91_led_off(at91_leds_cpu);
-               break;
-
-#ifdef CONFIG_LEDS_TIMER
-       case led_timer:         /* Every 50 timer ticks */
-               at91_led_toggle(at91_leds_timer);
-               break;
-#endif
-
-#ifdef CONFIG_LEDS_CPU
-       case led_idle_start:    /* Entering idle state */
-               at91_led_off(at91_leds_cpu);
-               break;
-
-       case led_idle_end:      /* Exit idle state */
-               at91_led_on(at91_leds_cpu);
-               break;
-#endif
-
-       default:
-               break;
-       }
-
-       local_irq_restore(flags);
-}
-
-
-static int __init leds_init(void)
-{
-       if (!at91_leds_timer || !at91_leds_cpu)
-               return -ENODEV;
-
-       leds_event = at91_leds_event;
-
-       leds_event(led_start);
-       return 0;
-}
-
-__initcall(leds_init);
-
-
-void __init at91_init_leds(u8 cpu_led, u8 timer_led)
-{
-       /* Enable GPIO to access the LEDs */
-       at91_set_gpio_output(cpu_led, 1);
-       at91_set_gpio_output(timer_led, 1);
-
-       at91_leds_cpu   = cpu_led;
-       at91_leds_timer = timer_led;
-}
-
-#else
-void __init at91_init_leds(u8 cpu_led, u8 timer_led) {}
-#endif