aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@woody.linux-foundation.org>2007-10-11 22:20:16 -0400
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-10-11 22:20:16 -0400
commite6005a85acb9609326512ecc784859831cfb24a3 (patch)
tree289fa2d94da15f06726b014d78189b668a89b854 /drivers
parent6f35308c3ffa256bed183adf6f2c0c6c211ca487 (diff)
parent4276fd7349bfd4f557d9777100fdcf1140771b4e (diff)
Merge branch 'for-linus' of git://git.o-hand.com/linux-rpurdie-leds
* 'for-linus' of git://git.o-hand.com/linux-rpurdie-leds: leds: Update Cobalt Qube series front LED support leds: Add Cobalt Raq series LEDs support leds: Rename leds-cobalt driver
Diffstat (limited to 'drivers')
-rw-r--r--drivers/leds/Kconfig13
-rw-r--r--drivers/leds/Makefile3
-rw-r--r--drivers/leds/leds-cobalt-qube.c102
-rw-r--r--drivers/leds/leds-cobalt-raq.c138
-rw-r--r--drivers/leds/leds-cobalt.c43
5 files changed, 252 insertions, 47 deletions
diff --git a/drivers/leds/Kconfig b/drivers/leds/Kconfig
index 4468cb3a8d24..3cb23210b912 100644
--- a/drivers/leds/Kconfig
+++ b/drivers/leds/Kconfig
@@ -87,11 +87,18 @@ config LEDS_H1940
87 help 87 help
88 This option enables support for the LEDs on the h1940. 88 This option enables support for the LEDs on the h1940.
89 89
90config LEDS_COBALT 90config LEDS_COBALT_QUBE
91 tristate "LED Support for Cobalt Server front LED" 91 tristate "LED Support for the Cobalt Qube series front LED"
92 depends on LEDS_CLASS && MIPS_COBALT 92 depends on LEDS_CLASS && MIPS_COBALT
93 help 93 help
94 This option enables support for the front LED on Cobalt Server 94 This option enables support for the front LED on Cobalt Qube series
95
96config 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.
95 102
96config LEDS_GPIO 103config LEDS_GPIO
97 tristate "LED Support for GPIO connected LEDs" 104 tristate "LED Support for GPIO connected LEDs"
diff --git a/drivers/leds/Makefile b/drivers/leds/Makefile
index f8995c9bc2ea..d2ca1abbc3d2 100644
--- a/drivers/leds/Makefile
+++ b/drivers/leds/Makefile
@@ -15,7 +15,8 @@ obj-$(CONFIG_LEDS_AMS_DELTA) += leds-ams-delta.o
15obj-$(CONFIG_LEDS_NET48XX) += leds-net48xx.o 15obj-$(CONFIG_LEDS_NET48XX) += leds-net48xx.o
16obj-$(CONFIG_LEDS_WRAP) += leds-wrap.o 16obj-$(CONFIG_LEDS_WRAP) += leds-wrap.o
17obj-$(CONFIG_LEDS_H1940) += leds-h1940.o 17obj-$(CONFIG_LEDS_H1940) += leds-h1940.o
18obj-$(CONFIG_LEDS_COBALT) += leds-cobalt.o 18obj-$(CONFIG_LEDS_COBALT_QUBE) += leds-cobalt-qube.o
19obj-$(CONFIG_LEDS_COBALT_RAQ) += leds-cobalt-raq.o
19obj-$(CONFIG_LEDS_GPIO) += leds-gpio.o 20obj-$(CONFIG_LEDS_GPIO) += leds-gpio.o
20 21
21# LED Triggers 22# LED Triggers
diff --git a/drivers/leds/leds-cobalt-qube.c b/drivers/leds/leds-cobalt-qube.c
new file mode 100644
index 000000000000..d2b54b53d80a
--- /dev/null
+++ b/drivers/leds/leds-cobalt-qube.c
@@ -0,0 +1,102 @@
1/*
2 * Copyright 2006 - Florian Fainelli <florian@openwrt.org>
3 *
4 * Control the Cobalt Qube/RaQ front LED
5 */
6#include <linux/init.h>
7#include <linux/io.h>
8#include <linux/ioport.h>
9#include <linux/leds.h>
10#include <linux/module.h>
11#include <linux/platform_device.h>
12#include <linux/types.h>
13
14#define LED_FRONT_LEFT 0x01
15#define LED_FRONT_RIGHT 0x02
16
17static void __iomem *led_port;
18static u8 led_value;
19
20static void qube_front_led_set(struct led_classdev *led_cdev,
21 enum led_brightness brightness)
22{
23 if (brightness)
24 led_value = LED_FRONT_LEFT | LED_FRONT_RIGHT;
25 else
26 led_value = ~(LED_FRONT_LEFT | LED_FRONT_RIGHT);
27 writeb(led_value, led_port);
28}
29
30static struct led_classdev qube_front_led = {
31 .name = "qube-front",
32 .brightness = LED_FULL,
33 .brightness_set = qube_front_led_set,
34 .default_trigger = "ide-disk",
35};
36
37static int __devinit cobalt_qube_led_probe(struct platform_device *pdev)
38{
39 struct resource *res;
40 int retval;
41
42 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
43 if (!res)
44 return -EBUSY;
45
46 led_port = ioremap(res->start, res->end - res->start + 1);
47 if (!led_port)
48 return -ENOMEM;
49
50 led_value = LED_FRONT_LEFT | LED_FRONT_RIGHT;
51 writeb(led_value, led_port);
52
53 retval = led_classdev_register(&pdev->dev, &qube_front_led);
54 if (retval)
55 goto err_iounmap;
56
57 return 0;
58
59err_iounmap:
60 iounmap(led_port);
61 led_port = NULL;
62
63 return retval;
64}
65
66static int __devexit cobalt_qube_led_remove(struct platform_device *pdev)
67{
68 led_classdev_unregister(&qube_front_led);
69
70 if (led_port) {
71 iounmap(led_port);
72 led_port = NULL;
73 }
74
75 return 0;
76}
77
78static struct platform_driver cobalt_qube_led_driver = {
79 .probe = cobalt_qube_led_probe,
80 .remove = __devexit_p(cobalt_qube_led_remove),
81 .driver = {
82 .name = "cobalt-qube-leds",
83 .owner = THIS_MODULE,
84 },
85};
86
87static int __init cobalt_qube_led_init(void)
88{
89 return platform_driver_register(&cobalt_qube_led_driver);
90}
91
92static void __exit cobalt_qube_led_exit(void)
93{
94 platform_driver_unregister(&cobalt_qube_led_driver);
95}
96
97module_init(cobalt_qube_led_init);
98module_exit(cobalt_qube_led_exit);
99
100MODULE_LICENSE("GPL");
101MODULE_DESCRIPTION("Front LED support for Cobalt Server");
102MODULE_AUTHOR("Florian Fainelli <florian@openwrt.org>");
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
31static void __iomem *led_port;
32static u8 led_value;
33static DEFINE_SPINLOCK(led_value_lock);
34
35static 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
51static struct led_classdev raq_web_led = {
52 .name = "raq-web",
53 .brightness_set = raq_web_led_set,
54};
55
56static 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
72static 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
78static 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
101err_unregister:
102 led_classdev_unregister(&raq_power_off_led);
103
104err_iounmap:
105 iounmap(led_port);
106 led_port = NULL;
107
108 return retval;
109}
110
111static 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
124static 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
133static int __init cobalt_raq_led_init(void)
134{
135 return platform_driver_register(&cobalt_raq_led_driver);
136}
137
138module_init(cobalt_raq_led_init);
diff --git a/drivers/leds/leds-cobalt.c b/drivers/leds/leds-cobalt.c
deleted file mode 100644
index d16439ce5da7..000000000000
--- a/drivers/leds/leds-cobalt.c
+++ /dev/null
@@ -1,43 +0,0 @@
1/*
2 * Copyright 2006 - Florian Fainelli <florian@openwrt.org>
3 *
4 * Control the Cobalt Qube/RaQ front LED
5 */
6
7#include <linux/module.h>
8#include <linux/types.h>
9#include <linux/kernel.h>
10#include <linux/device.h>
11#include <linux/leds.h>
12#include <asm/mach-cobalt/cobalt.h>
13
14static void cobalt_led_set(struct led_classdev *led_cdev, enum led_brightness brightness)
15{
16 if (brightness)
17 COBALT_LED_PORT = COBALT_LED_BAR_LEFT | COBALT_LED_BAR_RIGHT;
18 else
19 COBALT_LED_PORT = 0;
20}
21
22static struct led_classdev cobalt_led = {
23 .name = "cobalt-front-led",
24 .brightness_set = cobalt_led_set,
25 .default_trigger = "ide-disk",
26};
27
28static int __init cobalt_led_init(void)
29{
30 return led_classdev_register(NULL, &cobalt_led);
31}
32
33static void __exit cobalt_led_exit(void)
34{
35 led_classdev_unregister(&cobalt_led);
36}
37
38module_init(cobalt_led_init);
39module_exit(cobalt_led_exit);
40
41MODULE_LICENSE("GPL");
42MODULE_DESCRIPTION("Front LED support for Cobalt Server");
43MODULE_AUTHOR("Florian Fainelli <florian@openwrt.org>");