From e9fe1252b6516dfdd7ded04ae4d0eeff667555dd Mon Sep 17 00:00:00 2001 From: Bryan Wu Date: Thu, 30 Jun 2011 22:56:17 +0800 Subject: [PATCH] --- yaml --- r: 326981 b: refs/heads/master c: 3dd6b990d1abde274bb47e681c98addb61edb395 h: refs/heads/master i: 326979: 6369dfffe7c8f8b264359cdd1afc739d7c857553 v: v3 --- [refs] | 2 +- trunk/arch/arm/mach-ebsa110/Makefile | 4 +- trunk/arch/arm/mach-ebsa110/leds.c | 81 +++++++++++++++++----------- 3 files changed, 52 insertions(+), 35 deletions(-) diff --git a/[refs] b/[refs] index 7a4f0d3cfe4c..f563562716e3 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: 8ee8ef2996df477aa1623bd213b1548ab1b9c07c +refs/heads/master: 3dd6b990d1abde274bb47e681c98addb61edb395 diff --git a/trunk/arch/arm/mach-ebsa110/Makefile b/trunk/arch/arm/mach-ebsa110/Makefile index 6520ac835802..935e4af01a27 100644 --- a/trunk/arch/arm/mach-ebsa110/Makefile +++ b/trunk/arch/arm/mach-ebsa110/Makefile @@ -4,9 +4,7 @@ # Object file lists. -obj-y := core.o io.o +obj-y := core.o io.o leds.o obj-m := obj-n := obj- := - -obj-$(CONFIG_LEDS) += leds.o diff --git a/trunk/arch/arm/mach-ebsa110/leds.c b/trunk/arch/arm/mach-ebsa110/leds.c index 99e14e362500..0398258c20cd 100644 --- a/trunk/arch/arm/mach-ebsa110/leds.c +++ b/trunk/arch/arm/mach-ebsa110/leds.c @@ -1,52 +1,71 @@ /* - * linux/arch/arm/mach-ebsa110/leds.c + * Driver for the LED found on the EBSA110 machine + * Based on Versatile and RealView machine LED code * - * Copyright (C) 1998 Russell King - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation. - * - * EBSA-110 LED control routines. We use the led as follows: - * - * - Red - toggles state every 50 timer interrupts + * License terms: GNU General Public License (GPL) version 2 + * Author: Bryan Wu */ -#include -#include +#include #include +#include +#include +#include -#include -#include #include #include "core.h" -static spinlock_t leds_lock; - -static void ebsa110_leds_event(led_event_t ledevt) +#if defined(CONFIG_NEW_LEDS) && defined(CONFIG_LEDS_CLASS) +static void ebsa110_led_set(struct led_classdev *cdev, + enum led_brightness b) { - unsigned long flags; + u8 reg = __raw_readb(SOFT_BASE); - spin_lock_irqsave(&leds_lock, flags); + if (b != LED_OFF) + reg |= 0x80; + else + reg &= ~0x80; - switch(ledevt) { - case led_timer: - *(volatile unsigned char *)SOFT_BASE ^= 128; - break; + __raw_writeb(reg, SOFT_BASE); +} - default: - break; - } +static enum led_brightness ebsa110_led_get(struct led_classdev *cdev) +{ + u8 reg = __raw_readb(SOFT_BASE); - spin_unlock_irqrestore(&leds_lock, flags); + return (reg & 0x80) ? LED_FULL : LED_OFF; } -static int __init leds_init(void) +static int __init ebsa110_leds_init(void) { - if (machine_is_ebsa110()) - leds_event = ebsa110_leds_event; + + struct led_classdev *cdev; + int ret; + + if (!machine_is_ebsa110()) + return -ENODEV; + + cdev = kzalloc(sizeof(*cdev), GFP_KERNEL); + if (!cdev) + return -ENOMEM; + + cdev->name = "ebsa110:0"; + cdev->brightness_set = ebsa110_led_set; + cdev->brightness_get = ebsa110_led_get; + cdev->default_trigger = "heartbeat"; + + ret = led_classdev_register(NULL, cdev); + if (ret < 0) { + kfree(cdev); + return ret; + } return 0; } -__initcall(leds_init); +/* + * Since we may have triggers on any subsystem, defer registration + * until after subsystem_init. + */ +fs_initcall(ebsa110_leds_init); +#endif