diff options
author | Yoichi Yuasa <yoichi_yuasa@tripeaks.co.jp> | 2007-09-27 04:51:05 -0400 |
---|---|---|
committer | Richard Purdie <rpurdie@rpsys.net> | 2007-10-11 17:24:00 -0400 |
commit | 97da7aaf46fedcf1a38a88e5ffc2c40df23e8013 (patch) | |
tree | 4847421ab5c0b1a609d50b591b78217efbd344ac /drivers | |
parent | f3b6b6cd00d294d50e1c3eee85964c69d898de45 (diff) |
leds: Add Cobalt Raq series LEDs support
Add Cobalt Raq series LEDs support.
Signed-off-by: Yoichi Yuasa <yoichi_yuasa@tripeaks.co.jp>
Acked-by: Ralf Baechle <ralf@linux-mips.org>
Signed-off-by: Richard Purdie <rpurdie@rpsys.net>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/leds/Kconfig | 7 | ||||
-rw-r--r-- | drivers/leds/Makefile | 1 | ||||
-rw-r--r-- | drivers/leds/leds-cobalt-raq.c | 138 |
3 files changed, 146 insertions, 0 deletions
diff --git a/drivers/leds/Kconfig b/drivers/leds/Kconfig index 9b79bcd9bf11..3cb23210b912 100644 --- a/drivers/leds/Kconfig +++ b/drivers/leds/Kconfig | |||
@@ -93,6 +93,13 @@ config LEDS_COBALT_QUBE | |||
93 | help | 93 | help |
94 | This option enables support for the front LED on Cobalt Qube series | 94 | This option enables support for the front LED on Cobalt Qube series |
95 | 95 | ||
96 | config LEDS_COBALT_RAQ | ||
97 | bool "LED Support for the Cobalt Raq series" | ||
98 | depends on LEDS_CLASS && MIPS_COBALT | ||
99 | select LEDS_TRIGGERS | ||
100 | help | ||
101 | This option enables support for the Cobalt Raq series LEDs. | ||
102 | |||
96 | config LEDS_GPIO | 103 | config LEDS_GPIO |
97 | tristate "LED Support for GPIO connected LEDs" | 104 | tristate "LED Support for GPIO connected LEDs" |
98 | depends on LEDS_CLASS && GENERIC_GPIO | 105 | depends on LEDS_CLASS && GENERIC_GPIO |
diff --git a/drivers/leds/Makefile b/drivers/leds/Makefile index 9b2684a20888..d2ca1abbc3d2 100644 --- a/drivers/leds/Makefile +++ b/drivers/leds/Makefile | |||
@@ -16,6 +16,7 @@ obj-$(CONFIG_LEDS_NET48XX) += leds-net48xx.o | |||
16 | obj-$(CONFIG_LEDS_WRAP) += leds-wrap.o | 16 | obj-$(CONFIG_LEDS_WRAP) += leds-wrap.o |
17 | obj-$(CONFIG_LEDS_H1940) += leds-h1940.o | 17 | obj-$(CONFIG_LEDS_H1940) += leds-h1940.o |
18 | obj-$(CONFIG_LEDS_COBALT_QUBE) += leds-cobalt-qube.o | 18 | obj-$(CONFIG_LEDS_COBALT_QUBE) += leds-cobalt-qube.o |
19 | obj-$(CONFIG_LEDS_COBALT_RAQ) += leds-cobalt-raq.o | ||
19 | obj-$(CONFIG_LEDS_GPIO) += leds-gpio.o | 20 | obj-$(CONFIG_LEDS_GPIO) += leds-gpio.o |
20 | 21 | ||
21 | # LED Triggers | 22 | # LED Triggers |
diff --git a/drivers/leds/leds-cobalt-raq.c b/drivers/leds/leds-cobalt-raq.c new file mode 100644 index 000000000000..6ebfff341e6c --- /dev/null +++ b/drivers/leds/leds-cobalt-raq.c | |||
@@ -0,0 +1,138 @@ | |||
1 | /* | ||
2 | * LEDs driver for the Cobalt Raq series. | ||
3 | * | ||
4 | * Copyright (C) 2007 Yoichi Yuasa <yoichi_yuasa@tripeaks.co.jp> | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or modify | ||
7 | * it under the terms of the GNU General Public License as published by | ||
8 | * the Free Software Foundation; either version 2 of the License, or | ||
9 | * (at your option) any later version. | ||
10 | * | ||
11 | * This program is distributed in the hope that it will be useful, | ||
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
14 | * GNU General Public License for more details. | ||
15 | * | ||
16 | * You should have received a copy of the GNU General Public License | ||
17 | * along with this program; if not, write to the Free Software | ||
18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
19 | */ | ||
20 | #include <linux/init.h> | ||
21 | #include <linux/io.h> | ||
22 | #include <linux/ioport.h> | ||
23 | #include <linux/leds.h> | ||
24 | #include <linux/platform_device.h> | ||
25 | #include <linux/spinlock.h> | ||
26 | #include <linux/types.h> | ||
27 | |||
28 | #define LED_WEB 0x04 | ||
29 | #define LED_POWER_OFF 0x08 | ||
30 | |||
31 | static void __iomem *led_port; | ||
32 | static u8 led_value; | ||
33 | static DEFINE_SPINLOCK(led_value_lock); | ||
34 | |||
35 | static void raq_web_led_set(struct led_classdev *led_cdev, | ||
36 | enum led_brightness brightness) | ||
37 | { | ||
38 | unsigned long flags; | ||
39 | |||
40 | spin_lock_irqsave(&led_value_lock, flags); | ||
41 | |||
42 | if (brightness) | ||
43 | led_value |= LED_WEB; | ||
44 | else | ||
45 | led_value &= ~LED_WEB; | ||
46 | writeb(led_value, led_port); | ||
47 | |||
48 | spin_unlock_irqrestore(&led_value_lock, flags); | ||
49 | } | ||
50 | |||
51 | static struct led_classdev raq_web_led = { | ||
52 | .name = "raq-web", | ||
53 | .brightness_set = raq_web_led_set, | ||
54 | }; | ||
55 | |||
56 | static void raq_power_off_led_set(struct led_classdev *led_cdev, | ||
57 | enum led_brightness brightness) | ||
58 | { | ||
59 | unsigned long flags; | ||
60 | |||
61 | spin_lock_irqsave(&led_value_lock, flags); | ||
62 | |||
63 | if (brightness) | ||
64 | led_value |= LED_POWER_OFF; | ||
65 | else | ||
66 | led_value &= ~LED_POWER_OFF; | ||
67 | writeb(led_value, led_port); | ||
68 | |||
69 | spin_unlock_irqrestore(&led_value_lock, flags); | ||
70 | } | ||
71 | |||
72 | static struct led_classdev raq_power_off_led = { | ||
73 | .name = "raq-power-off", | ||
74 | .brightness_set = raq_power_off_led_set, | ||
75 | .default_trigger = "power-off", | ||
76 | }; | ||
77 | |||
78 | static int __devinit cobalt_raq_led_probe(struct platform_device *pdev) | ||
79 | { | ||
80 | struct resource *res; | ||
81 | int retval; | ||
82 | |||
83 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | ||
84 | if (!res) | ||
85 | return -EBUSY; | ||
86 | |||
87 | led_port = ioremap(res->start, res->end - res->start + 1); | ||
88 | if (!led_port) | ||
89 | return -ENOMEM; | ||
90 | |||
91 | retval = led_classdev_register(&pdev->dev, &raq_power_off_led); | ||
92 | if (retval) | ||
93 | goto err_iounmap; | ||
94 | |||
95 | retval = led_classdev_register(&pdev->dev, &raq_web_led); | ||
96 | if (retval) | ||
97 | goto err_unregister; | ||
98 | |||
99 | return 0; | ||
100 | |||
101 | err_unregister: | ||
102 | led_classdev_unregister(&raq_power_off_led); | ||
103 | |||
104 | err_iounmap: | ||
105 | iounmap(led_port); | ||
106 | led_port = NULL; | ||
107 | |||
108 | return retval; | ||
109 | } | ||
110 | |||
111 | static int __devexit cobalt_raq_led_remove(struct platform_device *pdev) | ||
112 | { | ||
113 | led_classdev_unregister(&raq_power_off_led); | ||
114 | led_classdev_unregister(&raq_web_led); | ||
115 | |||
116 | if (led_port) { | ||
117 | iounmap(led_port); | ||
118 | led_port = NULL; | ||
119 | } | ||
120 | |||
121 | return 0; | ||
122 | } | ||
123 | |||
124 | static struct platform_driver cobalt_raq_led_driver = { | ||
125 | .probe = cobalt_raq_led_probe, | ||
126 | .remove = __devexit_p(cobalt_raq_led_remove), | ||
127 | .driver = { | ||
128 | .name = "cobalt-raq-leds", | ||
129 | .owner = THIS_MODULE, | ||
130 | }, | ||
131 | }; | ||
132 | |||
133 | static int __init cobalt_raq_led_init(void) | ||
134 | { | ||
135 | return platform_driver_register(&cobalt_raq_led_driver); | ||
136 | } | ||
137 | |||
138 | module_init(cobalt_raq_led_init); | ||