Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0-only
0002 /*
0003  * LED Triggers Core
0004  * For the HP Jornada 620/660/680/690 handhelds
0005  *
0006  * Copyright 2008 Kristoffer Ericson <kristoffer.ericson@gmail.com>
0007  *     this driver is based on leds-spitz.c by Richard Purdie.
0008  */
0009 
0010 #include <linux/module.h>
0011 #include <linux/kernel.h>
0012 #include <linux/platform_device.h>
0013 #include <linux/leds.h>
0014 #include <asm/hd64461.h>
0015 #include <mach/hp6xx.h>
0016 
0017 static void hp6xxled_green_set(struct led_classdev *led_cdev,
0018                    enum led_brightness value)
0019 {
0020     u8 v8;
0021 
0022     v8 = inb(PKDR);
0023     if (value)
0024         outb(v8 & (~PKDR_LED_GREEN), PKDR);
0025     else
0026         outb(v8 | PKDR_LED_GREEN, PKDR);
0027 }
0028 
0029 static void hp6xxled_red_set(struct led_classdev *led_cdev,
0030                  enum led_brightness value)
0031 {
0032     u16 v16;
0033 
0034     v16 = inw(HD64461_GPBDR);
0035     if (value)
0036         outw(v16 & (~HD64461_GPBDR_LED_RED), HD64461_GPBDR);
0037     else
0038         outw(v16 | HD64461_GPBDR_LED_RED, HD64461_GPBDR);
0039 }
0040 
0041 static struct led_classdev hp6xx_red_led = {
0042     .name           = "hp6xx:red",
0043     .default_trigger    = "hp6xx-charge",
0044     .brightness_set     = hp6xxled_red_set,
0045     .flags          = LED_CORE_SUSPENDRESUME,
0046 };
0047 
0048 static struct led_classdev hp6xx_green_led = {
0049     .name           = "hp6xx:green",
0050     .default_trigger    = "disk-activity",
0051     .brightness_set     = hp6xxled_green_set,
0052     .flags          = LED_CORE_SUSPENDRESUME,
0053 };
0054 
0055 static int hp6xxled_probe(struct platform_device *pdev)
0056 {
0057     int ret;
0058 
0059     ret = devm_led_classdev_register(&pdev->dev, &hp6xx_red_led);
0060     if (ret < 0)
0061         return ret;
0062 
0063     return devm_led_classdev_register(&pdev->dev, &hp6xx_green_led);
0064 }
0065 
0066 static struct platform_driver hp6xxled_driver = {
0067     .probe      = hp6xxled_probe,
0068     .driver     = {
0069         .name       = "hp6xx-led",
0070     },
0071 };
0072 
0073 module_platform_driver(hp6xxled_driver);
0074 
0075 MODULE_AUTHOR("Kristoffer Ericson <kristoffer.ericson@gmail.com>");
0076 MODULE_DESCRIPTION("HP Jornada 6xx LED driver");
0077 MODULE_LICENSE("GPL");
0078 MODULE_ALIAS("platform:hp6xx-led");