Skip to content

Commit

Permalink
[ARM] 4758/1: [AT91] LEDs
Browse files Browse the repository at this point in the history
Move the LED initialization code out of the various *_devices.c files,
and into leds.c.
Also add support for NEW_LEDs.

Patch from David Brownell.

Signed-off-by: Andrew Victor <linux@maxim.org.za>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
  • Loading branch information
Andrew Victor authored and Russell King committed Jan 26, 2008
1 parent c8f385a commit a04ff1a
Show file tree
Hide file tree
Showing 8 changed files with 70 additions and 114 deletions.
2 changes: 1 addition & 1 deletion arch/arm/mach-at91/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ obj-$(CONFIG_MACH_AT91SAM9RLEK) += board-sam9rlek.o
obj-$(CONFIG_MACH_AT91EB01) += board-eb01.o

# Drivers
obj-$(CONFIG_LEDS) += leds.o
obj-y += leds.o

# Power Management
obj-$(CONFIG_PM) += pm.o
Expand Down
22 changes: 0 additions & 22 deletions arch/arm/mach-at91/at91rm9200_devices.c
Original file line number Diff line number Diff line change
Expand Up @@ -613,28 +613,6 @@ static void __init at91_add_device_watchdog(void) {}
#endif


/* --------------------------------------------------------------------
* LEDs
* -------------------------------------------------------------------- */

#if defined(CONFIG_LEDS)
u8 at91_leds_cpu;
u8 at91_leds_timer;

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


/* --------------------------------------------------------------------
* SSC -- Synchronous Serial Controller
* -------------------------------------------------------------------- */
Expand Down
22 changes: 0 additions & 22 deletions arch/arm/mach-at91/at91sam9260_devices.c
Original file line number Diff line number Diff line change
Expand Up @@ -584,28 +584,6 @@ static void __init at91_add_device_watchdog(void) {}
#endif


/* --------------------------------------------------------------------
* LEDs
* -------------------------------------------------------------------- */

#if defined(CONFIG_LEDS)
u8 at91_leds_cpu;
u8 at91_leds_timer;

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


/* --------------------------------------------------------------------
* SSC -- Synchronous Serial Controller
* -------------------------------------------------------------------- */
Expand Down
22 changes: 0 additions & 22 deletions arch/arm/mach-at91/at91sam9261_devices.c
Original file line number Diff line number Diff line change
Expand Up @@ -596,28 +596,6 @@ static void __init at91_add_device_watchdog(void) {}
#endif


/* --------------------------------------------------------------------
* LEDs
* -------------------------------------------------------------------- */

#if defined(CONFIG_LEDS)
u8 at91_leds_cpu;
u8 at91_leds_timer;

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


/* --------------------------------------------------------------------
* SSC -- Synchronous Serial Controller
* -------------------------------------------------------------------- */
Expand Down
22 changes: 0 additions & 22 deletions arch/arm/mach-at91/at91sam9263_devices.c
Original file line number Diff line number Diff line change
Expand Up @@ -843,28 +843,6 @@ static void __init at91_add_device_watchdog(void) {}
#endif


/* --------------------------------------------------------------------
* LEDs
* -------------------------------------------------------------------- */

#if defined(CONFIG_LEDS)
u8 at91_leds_cpu;
u8 at91_leds_timer;

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


/* --------------------------------------------------------------------
* SSC -- Synchronous Serial Controller
* -------------------------------------------------------------------- */
Expand Down
22 changes: 0 additions & 22 deletions arch/arm/mach-at91/at91sam9rl_devices.c
Original file line number Diff line number Diff line change
Expand Up @@ -449,28 +449,6 @@ static void __init at91_add_device_watchdog(void) {}
#endif


/* --------------------------------------------------------------------
* LEDs
* -------------------------------------------------------------------- */

#if defined(CONFIG_LEDS)
u8 at91_leds_cpu;
u8 at91_leds_timer;

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


/* --------------------------------------------------------------------
* SSC -- Synchronous Serial Controller
* -------------------------------------------------------------------- */
Expand Down
68 changes: 67 additions & 1 deletion arch/arm/mach-at91/leds.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,62 @@
#include <linux/init.h>

#include <asm/mach-types.h>
#include <asm/leds.h>
#include <asm/arch/board.h>
#include <asm/arch/gpio.h>


/* ------------------------------------------------------------------------- */

#if defined(CONFIG_NEW_LEDS)

#include <linux/platform_device.h>

/*
* New cross-platform LED support.
*/

static struct gpio_led_platform_data led_data;

static struct platform_device at91_leds = {
.name = "leds-gpio",
.id = -1,
.dev.platform_data = &led_data,
};

void __init at91_gpio_leds(struct gpio_led *leds, int nr)
{
int i;

if (!nr)
return;

for (i = 0; i < nr; i++)
at91_set_gpio_output(leds[i].gpio, leds[i].active_low);

led_data.leds = leds;
led_data.num_leds = nr;
platform_device_register(&at91_leds);
}

#else
void __init at91_gpio_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);
Expand Down Expand Up @@ -93,3 +144,18 @@ static int __init leds_init(void)
}

__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
4 changes: 2 additions & 2 deletions include/asm-arm/arch-at91/board.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
#include <linux/mtd/partitions.h>
#include <linux/device.h>
#include <linux/i2c.h>
#include <linux/leds.h>
#include <linux/spi/spi.h>

/* USB Device */
Expand Down Expand Up @@ -157,9 +158,8 @@ extern void __init at91_add_device_ac97(struct atmel_ac97_data *data);
extern void __init at91_add_device_isi(void);

/* LEDs */
extern u8 at91_leds_cpu;
extern u8 at91_leds_timer;
extern void __init at91_init_leds(u8 cpu_led, u8 timer_led);
extern void __init at91_gpio_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);
Expand Down

0 comments on commit a04ff1a

Please sign in to comment.