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
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>
26 static void h1940_greenled_set(struct led_classdev *led_dev,
27 enum led_brightness value)
31 h1940_latch_control(0, H1940_LATCH_LED_FLASH);
32 s3c2410_gpio_setpin(S3C2410_GPA7, 1);
35 h1940_latch_control(0, H1940_LATCH_LED_GREEN);
36 s3c2410_gpio_setpin(S3C2410_GPA7, 1);
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);
47 static struct led_classdev h1940_greenled = {
48 .name = "h1940:green",
49 .brightness_set = h1940_greenled_set,
50 .default_trigger = "h1940-charger",
56 static void h1940_redled_set(struct led_classdev *led_dev,
57 enum led_brightness value)
61 h1940_latch_control(0, H1940_LATCH_LED_FLASH);
62 s3c2410_gpio_setpin(S3C2410_GPA1, 1);
65 h1940_latch_control(0, H1940_LATCH_LED_RED);
66 s3c2410_gpio_setpin(S3C2410_GPA1, 1);
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);
77 static struct led_classdev h1940_redled = {
79 .brightness_set = h1940_redled_set,
80 .default_trigger = "h1940-charger",
85 * (it can only be blue flashing led)
87 static void h1940_blueled_set(struct led_classdev *led_dev,
88 enum led_brightness value)
92 h1940_latch_control(0, H1940_LATCH_LED_FLASH);
93 s3c2410_gpio_setpin(S3C2410_GPA3, 1);
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)
111 ret = led_classdev_register(&pdev->dev, &h1940_greenled);
115 ret = led_classdev_register(&pdev->dev, &h1940_redled);
119 ret = led_classdev_register(&pdev->dev, &h1940_blueled);
126 led_classdev_unregister(&h1940_redled);
128 led_classdev_unregister(&h1940_greenled);
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);
142 static struct platform_driver h1940leds_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");