^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) // SPDX-License-Identifier: GPL-2.0-only
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) * LED Triggers Core
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) * For the HP Jornada 620/660/680/690 handhelds
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) * Copyright 2008 Kristoffer Ericson <kristoffer.ericson@gmail.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) * this driver is based on leds-spitz.c by Richard Purdie.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) #include <linux/module.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) #include <linux/kernel.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) #include <linux/platform_device.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) #include <linux/leds.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) #include <asm/hd64461.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) #include <mach/hp6xx.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) static void hp6xxled_green_set(struct led_classdev *led_cdev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) enum led_brightness value)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) u8 v8;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) v8 = inb(PKDR);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) if (value)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) outb(v8 & (~PKDR_LED_GREEN), PKDR);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) outb(v8 | PKDR_LED_GREEN, PKDR);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) static void hp6xxled_red_set(struct led_classdev *led_cdev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) enum led_brightness value)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) u16 v16;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) v16 = inw(HD64461_GPBDR);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) if (value)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) outw(v16 & (~HD64461_GPBDR_LED_RED), HD64461_GPBDR);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) outw(v16 | HD64461_GPBDR_LED_RED, HD64461_GPBDR);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) static struct led_classdev hp6xx_red_led = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) .name = "hp6xx:red",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) .default_trigger = "hp6xx-charge",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) .brightness_set = hp6xxled_red_set,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) .flags = LED_CORE_SUSPENDRESUME,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) static struct led_classdev hp6xx_green_led = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) .name = "hp6xx:green",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) .default_trigger = "disk-activity",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) .brightness_set = hp6xxled_green_set,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) .flags = LED_CORE_SUSPENDRESUME,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) static int hp6xxled_probe(struct platform_device *pdev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) ret = devm_led_classdev_register(&pdev->dev, &hp6xx_red_led);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) if (ret < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) return devm_led_classdev_register(&pdev->dev, &hp6xx_green_led);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) static struct platform_driver hp6xxled_driver = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) .probe = hp6xxled_probe,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) .driver = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) .name = "hp6xx-led",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) module_platform_driver(hp6xxled_driver);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) MODULE_AUTHOR("Kristoffer Ericson <kristoffer.ericson@gmail.com>");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) MODULE_DESCRIPTION("HP Jornada 6xx LED driver");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) MODULE_LICENSE("GPL");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) MODULE_ALIAS("platform:hp6xx-led");