diff options
author | Richard Purdie <rpurdie@rpsys.net> | 2006-03-31 05:31:09 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2006-03-31 15:18:57 -0500 |
commit | 3179108daaaccbf28b17d6d8b0e06abf0eee6d9f (patch) | |
tree | 6e8f1e9b1d78f1c08bcd7dcfd5f9d4321849d3ec /drivers/leds/leds-corgi.c | |
parent | 181bf8aa68a1d062d7f98abb0f1cb8871910320c (diff) |
[PATCH] LED: add LED device support for the zaurus corgi and spitz models
Adds LED drivers for LEDs found on the Sharp Zaurus c7x0 (corgi, shepherd,
husky) and cxx00 (akita, spitz, borzoi) models.
Signed-off-by: Richard Purdie <rpurdie@rpsys.net>
Cc: Russell King <rmk@arm.linux.org.uk>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'drivers/leds/leds-corgi.c')
-rw-r--r-- | drivers/leds/leds-corgi.c | 121 |
1 files changed, 121 insertions, 0 deletions
diff --git a/drivers/leds/leds-corgi.c b/drivers/leds/leds-corgi.c new file mode 100644 index 000000000000..bb7d84df0121 --- /dev/null +++ b/drivers/leds/leds-corgi.c | |||
@@ -0,0 +1,121 @@ | |||
1 | /* | ||
2 | * LED Triggers Core | ||
3 | * | ||
4 | * Copyright 2005-2006 Openedhand Ltd. | ||
5 | * | ||
6 | * Author: Richard Purdie <rpurdie@openedhand.com> | ||
7 | * | ||
8 | * This program is free software; you can redistribute it and/or modify | ||
9 | * it under the terms of the GNU General Public License version 2 as | ||
10 | * published by the Free Software Foundation. | ||
11 | * | ||
12 | */ | ||
13 | |||
14 | #include <linux/config.h> | ||
15 | #include <linux/kernel.h> | ||
16 | #include <linux/init.h> | ||
17 | #include <linux/platform_device.h> | ||
18 | #include <linux/leds.h> | ||
19 | #include <asm/mach-types.h> | ||
20 | #include <asm/arch/corgi.h> | ||
21 | #include <asm/arch/hardware.h> | ||
22 | #include <asm/arch/pxa-regs.h> | ||
23 | #include <asm/hardware/scoop.h> | ||
24 | |||
25 | static void corgiled_amber_set(struct led_classdev *led_cdev, enum led_brightness value) | ||
26 | { | ||
27 | if (value) | ||
28 | GPSR0 = GPIO_bit(CORGI_GPIO_LED_ORANGE); | ||
29 | else | ||
30 | GPCR0 = GPIO_bit(CORGI_GPIO_LED_ORANGE); | ||
31 | } | ||
32 | |||
33 | static void corgiled_green_set(struct led_classdev *led_cdev, enum led_brightness value) | ||
34 | { | ||
35 | if (value) | ||
36 | set_scoop_gpio(&corgiscoop_device.dev, CORGI_SCP_LED_GREEN); | ||
37 | else | ||
38 | reset_scoop_gpio(&corgiscoop_device.dev, CORGI_SCP_LED_GREEN); | ||
39 | } | ||
40 | |||
41 | static struct led_classdev corgi_amber_led = { | ||
42 | .name = "corgi:amber", | ||
43 | .default_trigger = "sharpsl-charge", | ||
44 | .brightness_set = corgiled_amber_set, | ||
45 | }; | ||
46 | |||
47 | static struct led_classdev corgi_green_led = { | ||
48 | .name = "corgi:green", | ||
49 | .default_trigger = "nand-disk", | ||
50 | .brightness_set = corgiled_green_set, | ||
51 | }; | ||
52 | |||
53 | #ifdef CONFIG_PM | ||
54 | static int corgiled_suspend(struct platform_device *dev, pm_message_t state) | ||
55 | { | ||
56 | #ifdef CONFIG_LEDS_TRIGGERS | ||
57 | if (corgi_amber_led.trigger && strcmp(corgi_amber_led.trigger->name, "sharpsl-charge")) | ||
58 | #endif | ||
59 | led_classdev_suspend(&corgi_amber_led); | ||
60 | led_classdev_suspend(&corgi_green_led); | ||
61 | return 0; | ||
62 | } | ||
63 | |||
64 | static int corgiled_resume(struct platform_device *dev) | ||
65 | { | ||
66 | led_classdev_resume(&corgi_amber_led); | ||
67 | led_classdev_resume(&corgi_green_led); | ||
68 | return 0; | ||
69 | } | ||
70 | #endif | ||
71 | |||
72 | static int corgiled_probe(struct platform_device *pdev) | ||
73 | { | ||
74 | int ret; | ||
75 | |||
76 | ret = led_classdev_register(&pdev->dev, &corgi_amber_led); | ||
77 | if (ret < 0) | ||
78 | return ret; | ||
79 | |||
80 | ret = led_classdev_register(&pdev->dev, &corgi_green_led); | ||
81 | if (ret < 0) | ||
82 | led_classdev_unregister(&corgi_amber_led); | ||
83 | |||
84 | return ret; | ||
85 | } | ||
86 | |||
87 | static int corgiled_remove(struct platform_device *pdev) | ||
88 | { | ||
89 | led_classdev_unregister(&corgi_amber_led); | ||
90 | led_classdev_unregister(&corgi_green_led); | ||
91 | return 0; | ||
92 | } | ||
93 | |||
94 | static struct platform_driver corgiled_driver = { | ||
95 | .probe = corgiled_probe, | ||
96 | .remove = corgiled_remove, | ||
97 | #ifdef CONFIG_PM | ||
98 | .suspend = corgiled_suspend, | ||
99 | .resume = corgiled_resume, | ||
100 | #endif | ||
101 | .driver = { | ||
102 | .name = "corgi-led", | ||
103 | }, | ||
104 | }; | ||
105 | |||
106 | static int __init corgiled_init(void) | ||
107 | { | ||
108 | return platform_driver_register(&corgiled_driver); | ||
109 | } | ||
110 | |||
111 | static void __exit corgiled_exit(void) | ||
112 | { | ||
113 | platform_driver_unregister(&corgiled_driver); | ||
114 | } | ||
115 | |||
116 | module_init(corgiled_init); | ||
117 | module_exit(corgiled_exit); | ||
118 | |||
119 | MODULE_AUTHOR("Richard Purdie <rpurdie@openedhand.com>"); | ||
120 | MODULE_DESCRIPTION("Corgi LED driver"); | ||
121 | MODULE_LICENSE("GPL"); | ||