Loading...
1// SPDX-License-Identifier: GPL-2.0-only
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.
8 */
9
10#include <linux/module.h>
11#include <linux/kernel.h>
12#include <linux/platform_device.h>
13#include <linux/leds.h>
14#include <asm/hd64461.h>
15#include <mach/hp6xx.h>
16
17static void hp6xxled_green_set(struct led_classdev *led_cdev,
18 enum led_brightness value)
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
29static void hp6xxled_red_set(struct led_classdev *led_cdev,
30 enum led_brightness value)
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,
45 .flags = LED_CORE_SUSPENDRESUME,
46};
47
48static struct led_classdev hp6xx_green_led = {
49 .name = "hp6xx:green",
50 .default_trigger = "disk-activity",
51 .brightness_set = hp6xxled_green_set,
52 .flags = LED_CORE_SUSPENDRESUME,
53};
54
55static int hp6xxled_probe(struct platform_device *pdev)
56{
57 int ret;
58
59 ret = devm_led_classdev_register(&pdev->dev, &hp6xx_red_led);
60 if (ret < 0)
61 return ret;
62
63 return devm_led_classdev_register(&pdev->dev, &hp6xx_green_led);
64}
65
66static struct platform_driver hp6xxled_driver = {
67 .probe = hp6xxled_probe,
68 .driver = {
69 .name = "hp6xx-led",
70 },
71};
72
73module_platform_driver(hp6xxled_driver);
74
75MODULE_AUTHOR("Kristoffer Ericson <kristoffer.ericson@gmail.com>");
76MODULE_DESCRIPTION("HP Jornada 6xx LED driver");
77MODULE_LICENSE("GPL");
78MODULE_ALIAS("platform:hp6xx-led");
1/*
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
13#include <linux/module.h>
14#include <linux/kernel.h>
15#include <linux/platform_device.h>
16#include <linux/leds.h>
17#include <asm/hd64461.h>
18#include <mach/hp6xx.h>
19
20static void hp6xxled_green_set(struct led_classdev *led_cdev,
21 enum led_brightness value)
22{
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
32static void hp6xxled_red_set(struct led_classdev *led_cdev,
33 enum led_brightness value)
34{
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,
48 .flags = LED_CORE_SUSPENDRESUME,
49};
50
51static struct led_classdev hp6xx_green_led = {
52 .name = "hp6xx:green",
53 .default_trigger = "disk-activity",
54 .brightness_set = hp6xxled_green_set,
55 .flags = LED_CORE_SUSPENDRESUME,
56};
57
58static int hp6xxled_probe(struct platform_device *pdev)
59{
60 int ret;
61
62 ret = devm_led_classdev_register(&pdev->dev, &hp6xx_red_led);
63 if (ret < 0)
64 return ret;
65
66 return devm_led_classdev_register(&pdev->dev, &hp6xx_green_led);
67}
68
69static struct platform_driver hp6xxled_driver = {
70 .probe = hp6xxled_probe,
71 .driver = {
72 .name = "hp6xx-led",
73 },
74};
75
76module_platform_driver(hp6xxled_driver);
77
78MODULE_AUTHOR("Kristoffer Ericson <kristoffer.ericson@gmail.com>");
79MODULE_DESCRIPTION("HP Jornada 6xx LED driver");
80MODULE_LICENSE("GPL");
81MODULE_ALIAS("platform:hp6xx-led");