Commit | Line | Data |
---|---|---|
1da177e4 | 1 | /* |
3dd6b990 BW |
2 | * Driver for the LED found on the EBSA110 machine |
3 | * Based on Versatile and RealView machine LED code | |
1da177e4 | 4 | * |
3dd6b990 BW |
5 | * License terms: GNU General Public License (GPL) version 2 |
6 | * Author: Bryan Wu <bryan.wu@canonical.com> | |
1da177e4 | 7 | */ |
3dd6b990 | 8 | #include <linux/kernel.h> |
1da177e4 | 9 | #include <linux/init.h> |
3dd6b990 BW |
10 | #include <linux/io.h> |
11 | #include <linux/slab.h> | |
12 | #include <linux/leds.h> | |
1da177e4 | 13 | |
1da177e4 LT |
14 | #include <asm/mach-types.h> |
15 | ||
bcbbf908 RK |
16 | #include "core.h" |
17 | ||
3dd6b990 BW |
18 | #if defined(CONFIG_NEW_LEDS) && defined(CONFIG_LEDS_CLASS) |
19 | static void ebsa110_led_set(struct led_classdev *cdev, | |
20 | enum led_brightness b) | |
1da177e4 | 21 | { |
3dd6b990 | 22 | u8 reg = __raw_readb(SOFT_BASE); |
1da177e4 | 23 | |
3dd6b990 BW |
24 | if (b != LED_OFF) |
25 | reg |= 0x80; | |
26 | else | |
27 | reg &= ~0x80; | |
1da177e4 | 28 | |
3dd6b990 BW |
29 | __raw_writeb(reg, SOFT_BASE); |
30 | } | |
1da177e4 | 31 | |
3dd6b990 BW |
32 | static enum led_brightness ebsa110_led_get(struct led_classdev *cdev) |
33 | { | |
34 | u8 reg = __raw_readb(SOFT_BASE); | |
1da177e4 | 35 | |
3dd6b990 | 36 | return (reg & 0x80) ? LED_FULL : LED_OFF; |
1da177e4 LT |
37 | } |
38 | ||
3dd6b990 | 39 | static int __init ebsa110_leds_init(void) |
1da177e4 | 40 | { |
3dd6b990 BW |
41 | |
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 | } | |
1da177e4 LT |
62 | |
63 | return 0; | |
64 | } | |
65 | ||
3dd6b990 BW |
66 | /* |
67 | * Since we may have triggers on any subsystem, defer registration | |
68 | * until after subsystem_init. | |
69 | */ | |
70 | fs_initcall(ebsa110_leds_init); | |
71 | #endif |