aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/leds/leds-cobalt-qube.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/leds/leds-cobalt-qube.c')
-rw-r--r--drivers/leds/leds-cobalt-qube.c95
1 files changed, 77 insertions, 18 deletions
diff --git a/drivers/leds/leds-cobalt-qube.c b/drivers/leds/leds-cobalt-qube.c
index d16439ce5da7..d2b54b53d80a 100644
--- a/drivers/leds/leds-cobalt-qube.c
+++ b/drivers/leds/leds-cobalt-qube.c
@@ -3,40 +3,99 @@
3 * 3 *
4 * Control the Cobalt Qube/RaQ front LED 4 * Control the Cobalt Qube/RaQ front LED
5 */ 5 */
6 6#include <linux/init.h>
7#include <linux/io.h>
8#include <linux/ioport.h>
9#include <linux/leds.h>
7#include <linux/module.h> 10#include <linux/module.h>
11#include <linux/platform_device.h>
8#include <linux/types.h> 12#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 13
14static void cobalt_led_set(struct led_classdev *led_cdev, enum led_brightness brightness) 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)
15{ 22{
16 if (brightness) 23 if (brightness)
17 COBALT_LED_PORT = COBALT_LED_BAR_LEFT | COBALT_LED_BAR_RIGHT; 24 led_value = LED_FRONT_LEFT | LED_FRONT_RIGHT;
18 else 25 else
19 COBALT_LED_PORT = 0; 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;
20} 76}
21 77
22static struct led_classdev cobalt_led = { 78static struct platform_driver cobalt_qube_led_driver = {
23 .name = "cobalt-front-led", 79 .probe = cobalt_qube_led_probe,
24 .brightness_set = cobalt_led_set, 80 .remove = __devexit_p(cobalt_qube_led_remove),
25 .default_trigger = "ide-disk", 81 .driver = {
82 .name = "cobalt-qube-leds",
83 .owner = THIS_MODULE,
84 },
26}; 85};
27 86
28static int __init cobalt_led_init(void) 87static int __init cobalt_qube_led_init(void)
29{ 88{
30 return led_classdev_register(NULL, &cobalt_led); 89 return platform_driver_register(&cobalt_qube_led_driver);
31} 90}
32 91
33static void __exit cobalt_led_exit(void) 92static void __exit cobalt_qube_led_exit(void)
34{ 93{
35 led_classdev_unregister(&cobalt_led); 94 platform_driver_unregister(&cobalt_qube_led_driver);
36} 95}
37 96
38module_init(cobalt_led_init); 97module_init(cobalt_qube_led_init);
39module_exit(cobalt_led_exit); 98module_exit(cobalt_qube_led_exit);
40 99
41MODULE_LICENSE("GPL"); 100MODULE_LICENSE("GPL");
42MODULE_DESCRIPTION("Front LED support for Cobalt Server"); 101MODULE_DESCRIPTION("Front LED support for Cobalt Server");