Skip to content

Commit

Permalink
ARM: mach-footbridge: retire custom LED code
Browse files Browse the repository at this point in the history
Signed-off-by: Bryan Wu <bryan.wu@canonical.com>
  • Loading branch information
Bryan Wu committed Aug 1, 2012
1 parent 3dd6b99 commit cf6856d
Show file tree
Hide file tree
Showing 5 changed files with 179 additions and 294 deletions.
4 changes: 0 additions & 4 deletions arch/arm/mach-footbridge/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,11 @@ pci-$(CONFIG_ARCH_EBSA285_HOST) += ebsa285-pci.o
pci-$(CONFIG_ARCH_NETWINDER) += netwinder-pci.o
pci-$(CONFIG_ARCH_PERSONAL_SERVER) += personal-pci.o

leds-$(CONFIG_ARCH_EBSA285) += ebsa285-leds.o
leds-$(CONFIG_ARCH_NETWINDER) += netwinder-leds.o

obj-$(CONFIG_ARCH_CATS) += cats-hw.o isa-timer.o
obj-$(CONFIG_ARCH_EBSA285) += ebsa285.o dc21285-timer.o
obj-$(CONFIG_ARCH_NETWINDER) += netwinder-hw.o isa-timer.o
obj-$(CONFIG_ARCH_PERSONAL_SERVER) += personal.o dc21285-timer.o

obj-$(CONFIG_PCI) +=$(pci-y)
obj-$(CONFIG_LEDS) +=$(leds-y)

obj-$(CONFIG_ISA) += isa.o isa-rtc.o
138 changes: 0 additions & 138 deletions arch/arm/mach-footbridge/ebsa285-leds.c

This file was deleted.

81 changes: 81 additions & 0 deletions arch/arm/mach-footbridge/ebsa285.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
*/
#include <linux/init.h>
#include <linux/spinlock.h>
#include <linux/slab.h>
#include <linux/leds.h>

#include <asm/hardware/dec21285.h>
#include <asm/mach-types.h>
Expand All @@ -13,6 +15,85 @@

#include "common.h"

/* LEDs */
#if defined(CONFIG_NEW_LEDS) && defined(CONFIG_LEDS_CLASS)
struct ebsa285_led {
struct led_classdev cdev;
u8 mask;
};

/*
* The triggers lines up below will only be used if the
* LED triggers are compiled in.
*/
static const struct {
const char *name;
const char *trigger;
} ebsa285_leds[] = {
{ "ebsa285:amber", "heartbeat", },
{ "ebsa285:green", "cpu0", },
{ "ebsa285:red",},
};

static void ebsa285_led_set(struct led_classdev *cdev,
enum led_brightness b)
{
struct ebsa285_led *led = container_of(cdev,
struct ebsa285_led, cdev);

if (b != LED_OFF)
*XBUS_LEDS |= led->mask;
else
*XBUS_LEDS &= ~led->mask;
}

static enum led_brightness ebsa285_led_get(struct led_classdev *cdev)
{
struct ebsa285_led *led = container_of(cdev,
struct ebsa285_led, cdev);

return (*XBUS_LEDS & led->mask) ? LED_FULL : LED_OFF;
}

static int __init ebsa285_leds_init(void)
{
int i;

if (machine_is_ebsa285())
return -ENODEV;

/* 3 LEDS All ON */
*XBUS_LEDS |= XBUS_LED_AMBER | XBUS_LED_GREEN | XBUS_LED_RED;

for (i = 0; i < ARRAY_SIZE(ebsa285_leds); i++) {
struct ebsa285_led *led;

led = kzalloc(sizeof(*led), GFP_KERNEL);
if (!led)
break;

led->cdev.name = ebsa285_leds[i].name;
led->cdev.brightness_set = ebsa285_led_set;
led->cdev.brightness_get = ebsa285_led_get;
led->cdev.default_trigger = ebsa285_leds[i].trigger;
led->mask = BIT(i);

if (led_classdev_register(NULL, &led->cdev) < 0) {
kfree(led);
break;
}
}

return 0;
}

/*
* Since we may have triggers on any subsystem, defer registration
* until after subsystem_init.
*/
fs_initcall(ebsa285_leds_init);
#endif

MACHINE_START(EBSA285, "EBSA285")
/* Maintainer: Russell King */
.atag_offset = 0x100,
Expand Down
112 changes: 98 additions & 14 deletions arch/arm/mach-footbridge/netwinder-hw.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@
#include <linux/init.h>
#include <linux/io.h>
#include <linux/spinlock.h>
#include <linux/slab.h>
#include <linux/leds.h>

#include <asm/hardware/dec21285.h>
#include <asm/leds.h>
#include <asm/mach-types.h>
#include <asm/setup.h>
#include <asm/system_misc.h>
Expand All @@ -27,13 +28,6 @@
#define GP1_IO_BASE 0x338
#define GP2_IO_BASE 0x33a


#ifdef CONFIG_LEDS
#define DEFAULT_LEDS 0
#else
#define DEFAULT_LEDS GPIO_GREEN_LED
#endif

/*
* Winbond WB83977F accessibility stuff
*/
Expand Down Expand Up @@ -611,15 +605,9 @@ static void __init rwa010_init(void)
static int __init nw_hw_init(void)
{
if (machine_is_netwinder()) {
unsigned long flags;

wb977_init();
cpld_init();
rwa010_init();

raw_spin_lock_irqsave(&nw_gpio_lock, flags);
nw_gpio_modify_op(GPIO_RED_LED|GPIO_GREEN_LED, DEFAULT_LEDS);
raw_spin_unlock_irqrestore(&nw_gpio_lock, flags);
}
return 0;
}
Expand Down Expand Up @@ -672,6 +660,102 @@ static void netwinder_restart(char mode, const char *cmd)
}
}

/* LEDs */
#if defined(CONFIG_NEW_LEDS) && defined(CONFIG_LEDS_CLASS)
struct netwinder_led {
struct led_classdev cdev;
u8 mask;
};

/*
* The triggers lines up below will only be used if the
* LED triggers are compiled in.
*/
static const struct {
const char *name;
const char *trigger;
} netwinder_leds[] = {
{ "netwinder:green", "heartbeat", },
{ "netwinder:red", "cpu0", },
};

/*
* The LED control in Netwinder is reversed:
* - setting bit means turn off LED
* - clearing bit means turn on LED
*/
static void netwinder_led_set(struct led_classdev *cdev,
enum led_brightness b)
{
struct netwinder_led *led = container_of(cdev,
struct netwinder_led, cdev);
unsigned long flags;
u32 reg;

spin_lock_irqsave(&nw_gpio_lock, flags);
reg = nw_gpio_read();
if (b != LED_OFF)
reg &= ~led->mask;
else
reg |= led->mask;
nw_gpio_modify_op(led->mask, reg);
spin_unlock_irqrestore(&nw_gpio_lock, flags);
}

static enum led_brightness netwinder_led_get(struct led_classdev *cdev)
{
struct netwinder_led *led = container_of(cdev,
struct netwinder_led, cdev);
unsigned long flags;
u32 reg;

spin_lock_irqsave(&nw_gpio_lock, flags);
reg = nw_gpio_read();
spin_unlock_irqrestore(&nw_gpio_lock, flags);

return (reg & led->mask) ? LED_OFF : LED_FULL;
}

static int __init netwinder_leds_init(void)
{
int i;

if (!machine_is_netwinder())
return -ENODEV;

for (i = 0; i < ARRAY_SIZE(netwinder_leds); i++) {
struct netwinder_led *led;

led = kzalloc(sizeof(*led), GFP_KERNEL);
if (!led)
break;

led->cdev.name = netwinder_leds[i].name;
led->cdev.brightness_set = netwinder_led_set;
led->cdev.brightness_get = netwinder_led_get;
led->cdev.default_trigger = netwinder_leds[i].trigger;

if (i == 0)
led->mask = GPIO_GREEN_LED;
else
led->mask = GPIO_RED_LED;

if (led_classdev_register(NULL, &led->cdev) < 0) {
kfree(led);
break;
}
}

return 0;
}

/*
* Since we may have triggers on any subsystem, defer registration
* until after subsystem_init.
*/
fs_initcall(netwinder_leds_init);
#endif

MACHINE_START(NETWINDER, "Rebel-NetWinder")
/* Maintainer: Russell King/Rebel.com */
.atag_offset = 0x100,
Expand Down
Loading

0 comments on commit cf6856d

Please sign in to comment.