aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-ebsa110/leds.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/arm/mach-ebsa110/leds.c')
-rw-r--r--arch/arm/mach-ebsa110/leds.c81
1 files changed, 50 insertions, 31 deletions
diff --git a/arch/arm/mach-ebsa110/leds.c b/arch/arm/mach-ebsa110/leds.c
index 99e14e362500..0398258c20cd 100644
--- a/arch/arm/mach-ebsa110/leds.c
+++ b/arch/arm/mach-ebsa110/leds.c
@@ -1,52 +1,71 @@
1/* 1/*
2 * linux/arch/arm/mach-ebsa110/leds.c 2 * Driver for the LED found on the EBSA110 machine
3 * Based on Versatile and RealView machine LED code
3 * 4 *
4 * Copyright (C) 1998 Russell King 5 * License terms: GNU General Public License (GPL) version 2
5 * 6 * Author: Bryan Wu <bryan.wu@canonical.com>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 *
10 * EBSA-110 LED control routines. We use the led as follows:
11 *
12 * - Red - toggles state every 50 timer interrupts
13 */ 7 */
14#include <linux/module.h> 8#include <linux/kernel.h>
15#include <linux/spinlock.h>
16#include <linux/init.h> 9#include <linux/init.h>
10#include <linux/io.h>
11#include <linux/slab.h>
12#include <linux/leds.h>
17 13
18#include <mach/hardware.h>
19#include <asm/leds.h>
20#include <asm/mach-types.h> 14#include <asm/mach-types.h>
21 15
22#include "core.h" 16#include "core.h"
23 17
24static spinlock_t leds_lock; 18#if defined(CONFIG_NEW_LEDS) && defined(CONFIG_LEDS_CLASS)
25 19static void ebsa110_led_set(struct led_classdev *cdev,
26static void ebsa110_leds_event(led_event_t ledevt) 20 enum led_brightness b)
27{ 21{
28 unsigned long flags; 22 u8 reg = __raw_readb(SOFT_BASE);
29 23
30 spin_lock_irqsave(&leds_lock, flags); 24 if (b != LED_OFF)
25 reg |= 0x80;
26 else
27 reg &= ~0x80;
31 28
32 switch(ledevt) { 29 __raw_writeb(reg, SOFT_BASE);
33 case led_timer: 30}
34 *(volatile unsigned char *)SOFT_BASE ^= 128;
35 break;
36 31
37 default: 32static enum led_brightness ebsa110_led_get(struct led_classdev *cdev)
38 break; 33{
39 } 34 u8 reg = __raw_readb(SOFT_BASE);
40 35
41 spin_unlock_irqrestore(&leds_lock, flags); 36 return (reg & 0x80) ? LED_FULL : LED_OFF;
42} 37}
43 38
44static int __init leds_init(void) 39static int __init ebsa110_leds_init(void)
45{ 40{
46 if (machine_is_ebsa110()) 41
47 leds_event = ebsa110_leds_event; 42 struct led_classdev *cdev;
43 int ret;
44
45 if (!machine_is_ebsa110())
46 return -ENODEV;
47
48 cdev = kzalloc(sizeof(*cdev), GFP_KERNEL);
49 if (!cdev)
50 return -ENOMEM;
51
52 cdev->name = "ebsa110:0";
53 cdev->brightness_set = ebsa110_led_set;
54 cdev->brightness_get = ebsa110_led_get;
55 cdev->default_trigger = "heartbeat";
56
57 ret = led_classdev_register(NULL, cdev);
58 if (ret < 0) {
59 kfree(cdev);
60 return ret;
61 }
48 62
49 return 0; 63 return 0;
50} 64}
51 65
52__initcall(leds_init); 66/*
67 * Since we may have triggers on any subsystem, defer registration
68 * until after subsystem_init.
69 */
70fs_initcall(ebsa110_leds_init);
71#endif