2 * Copyright 2006 - Florian Fainelli <florian@openwrt.org>
4 * Control the Cobalt Qube/RaQ front LED
7 #include <linux/ioport.h>
8 #include <linux/leds.h>
9 #include <linux/module.h>
10 #include <linux/platform_device.h>
11 #include <linux/types.h>
13 #define LED_FRONT_LEFT 0x01
14 #define LED_FRONT_RIGHT 0x02
16 static void __iomem
*led_port
;
19 static void qube_front_led_set(struct led_classdev
*led_cdev
,
20 enum led_brightness brightness
)
23 led_value
= LED_FRONT_LEFT
| LED_FRONT_RIGHT
;
25 led_value
= ~(LED_FRONT_LEFT
| LED_FRONT_RIGHT
);
26 writeb(led_value
, led_port
);
29 static struct led_classdev qube_front_led
= {
30 .name
= "qube::front",
31 .brightness
= LED_FULL
,
32 .brightness_set
= qube_front_led_set
,
33 .default_trigger
= "default-on",
36 static int cobalt_qube_led_probe(struct platform_device
*pdev
)
41 res
= platform_get_resource(pdev
, IORESOURCE_MEM
, 0);
45 led_port
= devm_ioremap(&pdev
->dev
, res
->start
, resource_size(res
));
49 led_value
= LED_FRONT_LEFT
| LED_FRONT_RIGHT
;
50 writeb(led_value
, led_port
);
52 retval
= led_classdev_register(&pdev
->dev
, &qube_front_led
);
64 static int cobalt_qube_led_remove(struct platform_device
*pdev
)
66 led_classdev_unregister(&qube_front_led
);
74 static struct platform_driver cobalt_qube_led_driver
= {
75 .probe
= cobalt_qube_led_probe
,
76 .remove
= cobalt_qube_led_remove
,
78 .name
= "cobalt-qube-leds",
82 module_platform_driver(cobalt_qube_led_driver
);
84 MODULE_LICENSE("GPL");
85 MODULE_DESCRIPTION("Front LED support for Cobalt Server");
86 MODULE_AUTHOR("Florian Fainelli <florian@openwrt.org>");
87 MODULE_ALIAS("platform:cobalt-qube-leds");