Thomas Gleixner | d2912cb | 2019-06-04 10:11:33 +0200 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0-only |
Kristoffer Ericson | d39a7a6 | 2008-02-07 10:10:28 +0000 | [diff] [blame] | 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. |
Kristoffer Ericson | d39a7a6 | 2008-02-07 10:10:28 +0000 | [diff] [blame] | 8 | */ |
| 9 | |
Axel Lin | 86383b5 | 2011-08-25 15:59:15 -0700 | [diff] [blame] | 10 | #include <linux/module.h> |
Kristoffer Ericson | d39a7a6 | 2008-02-07 10:10:28 +0000 | [diff] [blame] | 11 | #include <linux/kernel.h> |
Kristoffer Ericson | d39a7a6 | 2008-02-07 10:10:28 +0000 | [diff] [blame] | 12 | #include <linux/platform_device.h> |
| 13 | #include <linux/leds.h> |
| 14 | #include <asm/hd64461.h> |
Paul Mundt | 7639a45 | 2008-10-20 13:02:48 +0900 | [diff] [blame] | 15 | #include <mach/hp6xx.h> |
Kristoffer Ericson | d39a7a6 | 2008-02-07 10:10:28 +0000 | [diff] [blame] | 16 | |
Németh Márton | 4d404fd | 2008-03-09 20:59:57 +0000 | [diff] [blame] | 17 | static void hp6xxled_green_set(struct led_classdev *led_cdev, |
| 18 | enum led_brightness value) |
Kristoffer Ericson | d39a7a6 | 2008-02-07 10:10:28 +0000 | [diff] [blame] | 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 | |
Németh Márton | 4d404fd | 2008-03-09 20:59:57 +0000 | [diff] [blame] | 29 | static void hp6xxled_red_set(struct led_classdev *led_cdev, |
| 30 | enum led_brightness value) |
Kristoffer Ericson | d39a7a6 | 2008-02-07 10:10:28 +0000 | [diff] [blame] | 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 | |
| 41 | static struct led_classdev hp6xx_red_led = { |
| 42 | .name = "hp6xx:red", |
| 43 | .default_trigger = "hp6xx-charge", |
| 44 | .brightness_set = hp6xxled_red_set, |
Richard Purdie | 859cb7f | 2009-01-08 17:55:03 +0000 | [diff] [blame] | 45 | .flags = LED_CORE_SUSPENDRESUME, |
Kristoffer Ericson | d39a7a6 | 2008-02-07 10:10:28 +0000 | [diff] [blame] | 46 | }; |
| 47 | |
| 48 | static struct led_classdev hp6xx_green_led = { |
| 49 | .name = "hp6xx:green", |
Stephan Linz | eb25cb9 | 2016-06-10 07:59:56 +0200 | [diff] [blame] | 50 | .default_trigger = "disk-activity", |
Kristoffer Ericson | d39a7a6 | 2008-02-07 10:10:28 +0000 | [diff] [blame] | 51 | .brightness_set = hp6xxled_green_set, |
Richard Purdie | 859cb7f | 2009-01-08 17:55:03 +0000 | [diff] [blame] | 52 | .flags = LED_CORE_SUSPENDRESUME, |
Kristoffer Ericson | d39a7a6 | 2008-02-07 10:10:28 +0000 | [diff] [blame] | 53 | }; |
| 54 | |
Kristoffer Ericson | d39a7a6 | 2008-02-07 10:10:28 +0000 | [diff] [blame] | 55 | static int hp6xxled_probe(struct platform_device *pdev) |
| 56 | { |
| 57 | int ret; |
| 58 | |
Muhammad Falak R Wani | c0fc68b | 2015-09-06 01:23:37 +0530 | [diff] [blame] | 59 | ret = devm_led_classdev_register(&pdev->dev, &hp6xx_red_led); |
Kristoffer Ericson | d39a7a6 | 2008-02-07 10:10:28 +0000 | [diff] [blame] | 60 | if (ret < 0) |
| 61 | return ret; |
| 62 | |
Muhammad Falak R Wani | c0fc68b | 2015-09-06 01:23:37 +0530 | [diff] [blame] | 63 | return devm_led_classdev_register(&pdev->dev, &hp6xx_green_led); |
Kristoffer Ericson | d39a7a6 | 2008-02-07 10:10:28 +0000 | [diff] [blame] | 64 | } |
| 65 | |
| 66 | static struct platform_driver hp6xxled_driver = { |
| 67 | .probe = hp6xxled_probe, |
Kristoffer Ericson | d39a7a6 | 2008-02-07 10:10:28 +0000 | [diff] [blame] | 68 | .driver = { |
| 69 | .name = "hp6xx-led", |
Kristoffer Ericson | d39a7a6 | 2008-02-07 10:10:28 +0000 | [diff] [blame] | 70 | }, |
| 71 | }; |
| 72 | |
Axel Lin | 892a884 | 2012-01-10 15:09:24 -0800 | [diff] [blame] | 73 | module_platform_driver(hp6xxled_driver); |
Kristoffer Ericson | d39a7a6 | 2008-02-07 10:10:28 +0000 | [diff] [blame] | 74 | |
| 75 | MODULE_AUTHOR("Kristoffer Ericson <kristoffer.ericson@gmail.com>"); |
| 76 | MODULE_DESCRIPTION("HP Jornada 6xx LED driver"); |
| 77 | MODULE_LICENSE("GPL"); |
Axel Lin | 892a884 | 2012-01-10 15:09:24 -0800 | [diff] [blame] | 78 | MODULE_ALIAS("platform:hp6xx-led"); |