Version:  2.0.40 2.2.26 2.4.37 2.6.39 3.0 3.1 3.2 3.3 3.4 3.5 3.6 3.7 3.8 3.9 3.10 3.11 3.12 3.13 3.14 3.15

Linux/drivers/leds/leds-cobalt-qube.c

  1 /*
  2  * Copyright 2006 - Florian Fainelli <florian@openwrt.org>
  3  *
  4  * Control the Cobalt Qube/RaQ front LED
  5  */
  6 #include <linux/io.h>
  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>
 12 
 13 #define LED_FRONT_LEFT  0x01
 14 #define LED_FRONT_RIGHT 0x02
 15 
 16 static void __iomem *led_port;
 17 static u8 led_value;
 18 
 19 static void qube_front_led_set(struct led_classdev *led_cdev,
 20                                enum led_brightness brightness)
 21 {
 22         if (brightness)
 23                 led_value = LED_FRONT_LEFT | LED_FRONT_RIGHT;
 24         else
 25                 led_value = ~(LED_FRONT_LEFT | LED_FRONT_RIGHT);
 26         writeb(led_value, led_port);
 27 }
 28 
 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",
 34 };
 35 
 36 static int cobalt_qube_led_probe(struct platform_device *pdev)
 37 {
 38         struct resource *res;
 39         int retval;
 40 
 41         res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 42         if (!res)
 43                 return -EBUSY;
 44 
 45         led_port = devm_ioremap(&pdev->dev, res->start, resource_size(res));
 46         if (!led_port)
 47                 return -ENOMEM;
 48 
 49         led_value = LED_FRONT_LEFT | LED_FRONT_RIGHT;
 50         writeb(led_value, led_port);
 51 
 52         retval = led_classdev_register(&pdev->dev, &qube_front_led);
 53         if (retval)
 54                 goto err_null;
 55 
 56         return 0;
 57 
 58 err_null:
 59         led_port = NULL;
 60 
 61         return retval;
 62 }
 63 
 64 static int cobalt_qube_led_remove(struct platform_device *pdev)
 65 {
 66         led_classdev_unregister(&qube_front_led);
 67 
 68         if (led_port)
 69                 led_port = NULL;
 70 
 71         return 0;
 72 }
 73 
 74 static struct platform_driver cobalt_qube_led_driver = {
 75         .probe  = cobalt_qube_led_probe,
 76         .remove = cobalt_qube_led_remove,
 77         .driver = {
 78                 .name   = "cobalt-qube-leds",
 79                 .owner  = THIS_MODULE,
 80         },
 81 };
 82 
 83 module_platform_driver(cobalt_qube_led_driver);
 84 
 85 MODULE_LICENSE("GPL");
 86 MODULE_DESCRIPTION("Front LED support for Cobalt Server");
 87 MODULE_AUTHOR("Florian Fainelli <florian@openwrt.org>");
 88 MODULE_ALIAS("platform:cobalt-qube-leds");
 89 

This page was automatically generated by LXR 0.3.1 (source).  •  Linux is a registered trademark of Linus Torvalds  •  Contact us