2 * DIGITAL Shark LED control routines.
4 * Driver for the 3 user LEDs found on the Shark
5 * Based on Versatile and RealView machine LED code
7 * License terms: GNU General Public License (GPL) version 2
10 #include <linux/kernel.h>
11 #include <linux/init.h>
13 #include <linux/ioport.h>
14 #include <linux/slab.h>
15 #include <linux/leds.h>
17 #include <asm/mach-types.h>
19 #if defined(CONFIG_NEW_LEDS) && defined(CONFIG_LEDS_CLASS)
21 struct led_classdev cdev;
26 * The triggers lines up below will only be used if the
27 * LED triggers are compiled in.
33 { "shark:amber0", "default-on", }, /* Bit 5 */
34 { "shark:green", "heartbeat", }, /* Bit 6 */
35 { "shark:amber1", "cpu0" }, /* Bit 7 */
38 static u16 led_reg_read(void)
44 static void led_reg_write(u16 value)
50 static void shark_led_set(struct led_classdev *cdev,
51 enum led_brightness b)
53 struct shark_led *led = container_of(cdev,
54 struct shark_led, cdev);
55 u16 reg = led_reg_read();
65 static enum led_brightness shark_led_get(struct led_classdev *cdev)
67 struct shark_led *led = container_of(cdev,
68 struct shark_led, cdev);
69 u16 reg = led_reg_read();
71 return (reg & led->mask) ? LED_FULL : LED_OFF;
74 static int __init shark_leds_init(void)
79 if (!machine_is_shark())
82 for (i = 0; i < ARRAY_SIZE(shark_leds); i++) {
83 struct shark_led *led;
85 led = kzalloc(sizeof(*led), GFP_KERNEL);
89 led->cdev.name = shark_leds[i].name;
90 led->cdev.brightness_set = shark_led_set;
91 led->cdev.brightness_get = shark_led_get;
92 led->cdev.default_trigger = shark_leds[i].trigger;
94 /* Count in 5 bits offset */
95 led->mask = BIT(i + 5);
97 if (led_classdev_register(NULL, &led->cdev) < 0) {
103 /* Make LEDs independent of power-state */
104 request_region(0x24, 4, "led_reg");
105 reg = led_reg_read();
113 * Since we may have triggers on any subsystem, defer registration
114 * until after subsystem_init.
116 fs_initcall(shark_leds_init);