sched: wakeup preempt when small overlap
[linux-2.6/mini2440.git] / drivers / leds / leds-h1940.c
blob11b77a70bbcb5e3d563e20f25f2493075de626c3
1 /*
2 * drivers/leds/leds-h1940.c
3 * Copyright (c) Arnaud Patard <arnaud.patard@rtp-net.org>
5 * This file is subject to the terms and conditions of the GNU General Public
6 * License. See the file COPYING in the main directory of this archive for
7 * more details.
9 * H1940 leds driver
13 #include <linux/module.h>
14 #include <linux/platform_device.h>
15 #include <linux/delay.h>
16 #include <linux/string.h>
17 #include <linux/ctype.h>
18 #include <linux/leds.h>
19 #include <mach/regs-gpio.h>
20 #include <mach/hardware.h>
21 #include <mach/h1940-latch.h>
24 * Green led.
26 static void h1940_greenled_set(struct led_classdev *led_dev,
27 enum led_brightness value)
29 switch (value) {
30 case LED_HALF:
31 h1940_latch_control(0, H1940_LATCH_LED_FLASH);
32 s3c2410_gpio_setpin(S3C2410_GPA7, 1);
33 break;
34 case LED_FULL:
35 h1940_latch_control(0, H1940_LATCH_LED_GREEN);
36 s3c2410_gpio_setpin(S3C2410_GPA7, 1);
37 break;
38 default:
39 case LED_OFF:
40 h1940_latch_control(H1940_LATCH_LED_FLASH, 0);
41 h1940_latch_control(H1940_LATCH_LED_GREEN, 0);
42 s3c2410_gpio_setpin(S3C2410_GPA7, 0);
43 break;
47 static struct led_classdev h1940_greenled = {
48 .name = "h1940:green",
49 .brightness_set = h1940_greenled_set,
50 .default_trigger = "h1940-charger",
54 * Red led.
56 static void h1940_redled_set(struct led_classdev *led_dev,
57 enum led_brightness value)
59 switch (value) {
60 case LED_HALF:
61 h1940_latch_control(0, H1940_LATCH_LED_FLASH);
62 s3c2410_gpio_setpin(S3C2410_GPA1, 1);
63 break;
64 case LED_FULL:
65 h1940_latch_control(0, H1940_LATCH_LED_RED);
66 s3c2410_gpio_setpin(S3C2410_GPA1, 1);
67 break;
68 default:
69 case LED_OFF:
70 h1940_latch_control(H1940_LATCH_LED_FLASH, 0);
71 h1940_latch_control(H1940_LATCH_LED_RED, 0);
72 s3c2410_gpio_setpin(S3C2410_GPA1, 0);
73 break;
77 static struct led_classdev h1940_redled = {
78 .name = "h1940:red",
79 .brightness_set = h1940_redled_set,
80 .default_trigger = "h1940-charger",
84 * Blue led.
85 * (it can only be blue flashing led)
87 static void h1940_blueled_set(struct led_classdev *led_dev,
88 enum led_brightness value)
90 if (value) {
91 /* flashing Blue */
92 h1940_latch_control(0, H1940_LATCH_LED_FLASH);
93 s3c2410_gpio_setpin(S3C2410_GPA3, 1);
94 } else {
95 h1940_latch_control(H1940_LATCH_LED_FLASH, 0);
96 s3c2410_gpio_setpin(S3C2410_GPA3, 0);
101 static struct led_classdev h1940_blueled = {
102 .name = "h1940:blue",
103 .brightness_set = h1940_blueled_set,
104 .default_trigger = "h1940-bluetooth",
107 static int __init h1940leds_probe(struct platform_device *pdev)
109 int ret;
111 ret = led_classdev_register(&pdev->dev, &h1940_greenled);
112 if (ret)
113 goto err_green;
115 ret = led_classdev_register(&pdev->dev, &h1940_redled);
116 if (ret)
117 goto err_red;
119 ret = led_classdev_register(&pdev->dev, &h1940_blueled);
120 if (ret)
121 goto err_blue;
123 return 0;
125 err_blue:
126 led_classdev_unregister(&h1940_redled);
127 err_red:
128 led_classdev_unregister(&h1940_greenled);
129 err_green:
130 return ret;
133 static int h1940leds_remove(struct platform_device *pdev)
135 led_classdev_unregister(&h1940_greenled);
136 led_classdev_unregister(&h1940_redled);
137 led_classdev_unregister(&h1940_blueled);
138 return 0;
142 static struct platform_driver h1940leds_driver = {
143 .driver = {
144 .name = "h1940-leds",
145 .owner = THIS_MODULE,
147 .probe = h1940leds_probe,
148 .remove = h1940leds_remove,
152 static int __init h1940leds_init(void)
154 return platform_driver_register(&h1940leds_driver);
157 static void __exit h1940leds_exit(void)
159 platform_driver_unregister(&h1940leds_driver);
162 module_init(h1940leds_init);
163 module_exit(h1940leds_exit);
165 MODULE_AUTHOR("Arnaud Patard <arnaud.patard@rtp-net.org>");
166 MODULE_DESCRIPTION("LED driver for the iPAQ H1940");
167 MODULE_LICENSE("GPL");
168 MODULE_ALIAS("platform:h1940-leds");