Merge branch '6.8/scsi-staging' into 6.8/scsi-fixes
[linux-block.git] / drivers / leds / leds-hp6xx.c
CommitLineData
d2912cb1 1// SPDX-License-Identifier: GPL-2.0-only
d39a7a63
KE
2/*
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.
d39a7a63
KE
8 */
9
86383b55 10#include <linux/module.h>
d39a7a63 11#include <linux/kernel.h>
d39a7a63
KE
12#include <linux/platform_device.h>
13#include <linux/leds.h>
14#include <asm/hd64461.h>
7639a454 15#include <mach/hp6xx.h>
d39a7a63 16
4d404fd5
NM
17static void hp6xxled_green_set(struct led_classdev *led_cdev,
18 enum led_brightness value)
d39a7a63
KE
19{
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
4d404fd5
NM
29static void hp6xxled_red_set(struct led_classdev *led_cdev,
30 enum led_brightness value)
d39a7a63
KE
31{
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,
859cb7f2 45 .flags = LED_CORE_SUSPENDRESUME,
d39a7a63
KE
46};
47
48static struct led_classdev hp6xx_green_led = {
49 .name = "hp6xx:green",
eb25cb99 50 .default_trigger = "disk-activity",
d39a7a63 51 .brightness_set = hp6xxled_green_set,
859cb7f2 52 .flags = LED_CORE_SUSPENDRESUME,
d39a7a63
KE
53};
54
d39a7a63
KE
55static int hp6xxled_probe(struct platform_device *pdev)
56{
57 int ret;
58
c0fc68ba 59 ret = devm_led_classdev_register(&pdev->dev, &hp6xx_red_led);
d39a7a63
KE
60 if (ret < 0)
61 return ret;
62
c0fc68ba 63 return devm_led_classdev_register(&pdev->dev, &hp6xx_green_led);
d39a7a63
KE
64}
65
66static struct platform_driver hp6xxled_driver = {
67 .probe = hp6xxled_probe,
d39a7a63
KE
68 .driver = {
69 .name = "hp6xx-led",
70 },
71};
72
892a8843 73module_platform_driver(hp6xxled_driver);
d39a7a63
KE
74
75MODULE_AUTHOR("Kristoffer Ericson <kristoffer.ericson@gmail.com>");
76MODULE_DESCRIPTION("HP Jornada 6xx LED driver");
77MODULE_LICENSE("GPL");
892a8843 78MODULE_ALIAS("platform:hp6xx-led");