ARM: mm: Recreate kernel mappings in early_paging_init()
[linux/fpc-iii.git] / drivers / leds / leds-cobalt-qube.c
blob8abcb66db01c2c587f7e85c91e296e324947027e
1 /*
2 * Copyright 2006 - Florian Fainelli <florian@openwrt.org>
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>
14 #define LED_FRONT_LEFT 0x01
15 #define LED_FRONT_RIGHT 0x02
17 static void __iomem *led_port;
18 static u8 led_value;
20 static void qube_front_led_set(struct led_classdev *led_cdev,
21 enum led_brightness brightness)
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);
30 static struct led_classdev qube_front_led = {
31 .name = "qube::front",
32 .brightness = LED_FULL,
33 .brightness_set = qube_front_led_set,
34 .default_trigger = "default-on",
37 static int cobalt_qube_led_probe(struct platform_device *pdev)
39 struct resource *res;
40 int retval;
42 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
43 if (!res)
44 return -EBUSY;
46 led_port = devm_ioremap(&pdev->dev, res->start, resource_size(res));
47 if (!led_port)
48 return -ENOMEM;
50 led_value = LED_FRONT_LEFT | LED_FRONT_RIGHT;
51 writeb(led_value, led_port);
53 retval = led_classdev_register(&pdev->dev, &qube_front_led);
54 if (retval)
55 goto err_null;
57 return 0;
59 err_null:
60 led_port = NULL;
62 return retval;
65 static int cobalt_qube_led_remove(struct platform_device *pdev)
67 led_classdev_unregister(&qube_front_led);
69 if (led_port)
70 led_port = NULL;
72 return 0;
75 static struct platform_driver cobalt_qube_led_driver = {
76 .probe = cobalt_qube_led_probe,
77 .remove = cobalt_qube_led_remove,
78 .driver = {
79 .name = "cobalt-qube-leds",
80 .owner = THIS_MODULE,
84 module_platform_driver(cobalt_qube_led_driver);
86 MODULE_LICENSE("GPL");
87 MODULE_DESCRIPTION("Front LED support for Cobalt Server");
88 MODULE_AUTHOR("Florian Fainelli <florian@openwrt.org>");
89 MODULE_ALIAS("platform:cobalt-qube-leds");