blob: 137969fcecbb4f45bc2e24cadf9da9b614faa733 [file] [log] [blame]
Kristoffer Ericsond39a7a62008-02-07 10:10:28 +00001/*
2 * LED Triggers Core
3 * For the HP Jornada 620/660/680/690 handhelds
4 *
5 * Copyright 2008 Kristoffer Ericson <kristoffer.ericson@gmail.com>
6 * this driver is based on leds-spitz.c by Richard Purdie.
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
11 */
12
Axel Lin86383b52011-08-25 15:59:15 -070013#include <linux/module.h>
Kristoffer Ericsond39a7a62008-02-07 10:10:28 +000014#include <linux/kernel.h>
Kristoffer Ericsond39a7a62008-02-07 10:10:28 +000015#include <linux/platform_device.h>
16#include <linux/leds.h>
17#include <asm/hd64461.h>
Paul Mundt7639a452008-10-20 13:02:48 +090018#include <mach/hp6xx.h>
Kristoffer Ericsond39a7a62008-02-07 10:10:28 +000019
Németh Márton4d404fd2008-03-09 20:59:57 +000020static void hp6xxled_green_set(struct led_classdev *led_cdev,
21 enum led_brightness value)
Kristoffer Ericsond39a7a62008-02-07 10:10:28 +000022{
23 u8 v8;
24
25 v8 = inb(PKDR);
26 if (value)
27 outb(v8 & (~PKDR_LED_GREEN), PKDR);
28 else
29 outb(v8 | PKDR_LED_GREEN, PKDR);
30}
31
Németh Márton4d404fd2008-03-09 20:59:57 +000032static void hp6xxled_red_set(struct led_classdev *led_cdev,
33 enum led_brightness value)
Kristoffer Ericsond39a7a62008-02-07 10:10:28 +000034{
35 u16 v16;
36
37 v16 = inw(HD64461_GPBDR);
38 if (value)
39 outw(v16 & (~HD64461_GPBDR_LED_RED), HD64461_GPBDR);
40 else
41 outw(v16 | HD64461_GPBDR_LED_RED, HD64461_GPBDR);
42}
43
44static struct led_classdev hp6xx_red_led = {
45 .name = "hp6xx:red",
46 .default_trigger = "hp6xx-charge",
47 .brightness_set = hp6xxled_red_set,
Richard Purdie859cb7f2009-01-08 17:55:03 +000048 .flags = LED_CORE_SUSPENDRESUME,
Kristoffer Ericsond39a7a62008-02-07 10:10:28 +000049};
50
51static struct led_classdev hp6xx_green_led = {
52 .name = "hp6xx:green",
Stephan Linzeb25cb92016-06-10 07:59:56 +020053 .default_trigger = "disk-activity",
Kristoffer Ericsond39a7a62008-02-07 10:10:28 +000054 .brightness_set = hp6xxled_green_set,
Richard Purdie859cb7f2009-01-08 17:55:03 +000055 .flags = LED_CORE_SUSPENDRESUME,
Kristoffer Ericsond39a7a62008-02-07 10:10:28 +000056};
57
Kristoffer Ericsond39a7a62008-02-07 10:10:28 +000058static int hp6xxled_probe(struct platform_device *pdev)
59{
60 int ret;
61
Muhammad Falak R Wanic0fc68b2015-09-06 01:23:37 +053062 ret = devm_led_classdev_register(&pdev->dev, &hp6xx_red_led);
Kristoffer Ericsond39a7a62008-02-07 10:10:28 +000063 if (ret < 0)
64 return ret;
65
Muhammad Falak R Wanic0fc68b2015-09-06 01:23:37 +053066 return devm_led_classdev_register(&pdev->dev, &hp6xx_green_led);
Kristoffer Ericsond39a7a62008-02-07 10:10:28 +000067}
68
69static struct platform_driver hp6xxled_driver = {
70 .probe = hp6xxled_probe,
Kristoffer Ericsond39a7a62008-02-07 10:10:28 +000071 .driver = {
72 .name = "hp6xx-led",
Kristoffer Ericsond39a7a62008-02-07 10:10:28 +000073 },
74};
75
Axel Lin892a8842012-01-10 15:09:24 -080076module_platform_driver(hp6xxled_driver);
Kristoffer Ericsond39a7a62008-02-07 10:10:28 +000077
78MODULE_AUTHOR("Kristoffer Ericson <kristoffer.ericson@gmail.com>");
79MODULE_DESCRIPTION("HP Jornada 6xx LED driver");
80MODULE_LICENSE("GPL");
Axel Lin892a8842012-01-10 15:09:24 -080081MODULE_ALIAS("platform:hp6xx-led");