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 <asm/arch/regs-gpio.h>
20 #include <asm/hardware.h>
21 #include <asm/arch/h1940-latch.h>
26 void h1940_greenled_set(struct led_classdev *led_dev, enum led_brightness value)
30 h1940_latch_control(0, H1940_LATCH_LED_FLASH);
31 s3c2410_gpio_setpin(S3C2410_GPA7, 1);
34 h1940_latch_control(0, H1940_LATCH_LED_GREEN);
35 s3c2410_gpio_setpin(S3C2410_GPA7, 1);
39 h1940_latch_control(H1940_LATCH_LED_FLASH, 0);
40 h1940_latch_control(H1940_LATCH_LED_GREEN, 0);
41 s3c2410_gpio_setpin(S3C2410_GPA7, 0);
46 static struct led_classdev h1940_greenled = {
47 .name = "h1940:green",
48 .brightness_set = h1940_greenled_set,
49 .default_trigger = "h1940-charger",
55 void h1940_redled_set(struct led_classdev *led_dev, enum led_brightness value)
59 h1940_latch_control(0, H1940_LATCH_LED_FLASH);
60 s3c2410_gpio_setpin(S3C2410_GPA1, 1);
63 h1940_latch_control(0, H1940_LATCH_LED_RED);
64 s3c2410_gpio_setpin(S3C2410_GPA1, 1);
68 h1940_latch_control(H1940_LATCH_LED_FLASH, 0);
69 h1940_latch_control(H1940_LATCH_LED_RED, 0);
70 s3c2410_gpio_setpin(S3C2410_GPA1, 0);
75 static struct led_classdev h1940_redled = {
77 .brightness_set = h1940_redled_set,
78 .default_trigger = "h1940-charger",
83 * (it can only be blue flashing led)
85 void h1940_blueled_set(struct led_classdev *led_dev, enum led_brightness value)
89 h1940_latch_control(0, H1940_LATCH_LED_FLASH);
90 s3c2410_gpio_setpin(S3C2410_GPA3, 1);
92 h1940_latch_control(H1940_LATCH_LED_FLASH, 0);
93 s3c2410_gpio_setpin(S3C2410_GPA3, 0);
98 static struct led_classdev h1940_blueled = {
100 .brightness_set = h1940_blueled_set,
101 .default_trigger = "h1940-bluetooth",
104 static int __init h1940leds_probe(struct platform_device *pdev)
108 ret = led_classdev_register(&pdev->dev, &h1940_greenled);
112 ret = led_classdev_register(&pdev->dev, &h1940_redled);
116 ret = led_classdev_register(&pdev->dev, &h1940_blueled);
123 led_classdev_unregister(&h1940_redled);
125 led_classdev_unregister(&h1940_greenled);
130 static int h1940leds_remove(struct platform_device *pdev)
132 led_classdev_unregister(&h1940_greenled);
133 led_classdev_unregister(&h1940_redled);
134 led_classdev_unregister(&h1940_blueled);
139 static struct platform_driver h1940leds_driver = {
141 .name = "h1940-leds",
142 .owner = THIS_MODULE,
144 .probe = h1940leds_probe,
145 .remove = h1940leds_remove,
149 static int __init h1940leds_init(void)
151 return platform_driver_register(&h1940leds_driver);
154 static void __exit h1940leds_exit(void)
156 platform_driver_unregister(&h1940leds_driver);
159 module_init(h1940leds_init);
160 module_exit(h1940leds_exit);
162 MODULE_AUTHOR("Arnaud Patard <arnaud.patard@rtp-net.org>");
163 MODULE_DESCRIPTION("LED driver for the iPAQ H1940");
164 MODULE_LICENSE("GPL");
165 MODULE_ALIAS("platform:h1940-leds");