blob: 54af9e63c09cf9e988aef125ecd7e18d51979417 [file] [log] [blame]
Thomas Gleixnerd2912cb2019-06-04 10:11:33 +02001// SPDX-License-Identifier: GPL-2.0-only
Kristoffer Ericsond39a7a62008-02-07 10:10:28 +00002/*
3 * LED Triggers Core
4 * For the HP Jornada 620/660/680/690 handhelds
5 *
6 * Copyright 2008 Kristoffer Ericson <kristoffer.ericson@gmail.com>
7 * this driver is based on leds-spitz.c by Richard Purdie.
Kristoffer Ericsond39a7a62008-02-07 10:10:28 +00008 */
9
Axel Lin86383b52011-08-25 15:59:15 -070010#include <linux/module.h>
Kristoffer Ericsond39a7a62008-02-07 10:10:28 +000011#include <linux/kernel.h>
Kristoffer Ericsond39a7a62008-02-07 10:10:28 +000012#include <linux/platform_device.h>
13#include <linux/leds.h>
14#include <asm/hd64461.h>
Paul Mundt7639a452008-10-20 13:02:48 +090015#include <mach/hp6xx.h>
Kristoffer Ericsond39a7a62008-02-07 10:10:28 +000016
Németh Márton4d404fd2008-03-09 20:59:57 +000017static void hp6xxled_green_set(struct led_classdev *led_cdev,
18 enum led_brightness value)
Kristoffer Ericsond39a7a62008-02-07 10:10:28 +000019{
20 u8 v8;
21
22 v8 = inb(PKDR);
23 if (value)
24 outb(v8 & (~PKDR_LED_GREEN), PKDR);
25 else
26 outb(v8 | PKDR_LED_GREEN, PKDR);
27}
28
Németh Márton4d404fd2008-03-09 20:59:57 +000029static void hp6xxled_red_set(struct led_classdev *led_cdev,
30 enum led_brightness value)
Kristoffer Ericsond39a7a62008-02-07 10:10:28 +000031{
32 u16 v16;
33
34 v16 = inw(HD64461_GPBDR);
35 if (value)
36 outw(v16 & (~HD64461_GPBDR_LED_RED), HD64461_GPBDR);
37 else
38 outw(v16 | HD64461_GPBDR_LED_RED, HD64461_GPBDR);
39}
40
41static struct led_classdev hp6xx_red_led = {
42 .name = "hp6xx:red",
43 .default_trigger = "hp6xx-charge",
44 .brightness_set = hp6xxled_red_set,
Richard Purdie859cb7f2009-01-08 17:55:03 +000045 .flags = LED_CORE_SUSPENDRESUME,
Kristoffer Ericsond39a7a62008-02-07 10:10:28 +000046};
47
48static struct led_classdev hp6xx_green_led = {
49 .name = "hp6xx:green",
Stephan Linzeb25cb92016-06-10 07:59:56 +020050 .default_trigger = "disk-activity",
Kristoffer Ericsond39a7a62008-02-07 10:10:28 +000051 .brightness_set = hp6xxled_green_set,
Richard Purdie859cb7f2009-01-08 17:55:03 +000052 .flags = LED_CORE_SUSPENDRESUME,
Kristoffer Ericsond39a7a62008-02-07 10:10:28 +000053};
54
Kristoffer Ericsond39a7a62008-02-07 10:10:28 +000055static int hp6xxled_probe(struct platform_device *pdev)
56{
57 int ret;
58
Muhammad Falak R Wanic0fc68b2015-09-06 01:23:37 +053059 ret = devm_led_classdev_register(&pdev->dev, &hp6xx_red_led);
Kristoffer Ericsond39a7a62008-02-07 10:10:28 +000060 if (ret < 0)
61 return ret;
62
Muhammad Falak R Wanic0fc68b2015-09-06 01:23:37 +053063 return devm_led_classdev_register(&pdev->dev, &hp6xx_green_led);
Kristoffer Ericsond39a7a62008-02-07 10:10:28 +000064}
65
66static struct platform_driver hp6xxled_driver = {
67 .probe = hp6xxled_probe,
Kristoffer Ericsond39a7a62008-02-07 10:10:28 +000068 .driver = {
69 .name = "hp6xx-led",
Kristoffer Ericsond39a7a62008-02-07 10:10:28 +000070 },
71};
72
Axel Lin892a8842012-01-10 15:09:24 -080073module_platform_driver(hp6xxled_driver);
Kristoffer Ericsond39a7a62008-02-07 10:10:28 +000074
75MODULE_AUTHOR("Kristoffer Ericson <kristoffer.ericson@gmail.com>");
76MODULE_DESCRIPTION("HP Jornada 6xx LED driver");
77MODULE_LICENSE("GPL");
Axel Lin892a8842012-01-10 15:09:24 -080078MODULE_ALIAS("platform:hp6xx-led");