Kristoffer Ericson | d39a7a6 | 2008-02-07 10:10:28 +0000 | [diff] [blame] | 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 | |
Axel Lin | 86383b5 | 2011-08-25 15:59:15 -0700 | [diff] [blame] | 13 | #include <linux/module.h> |
Kristoffer Ericson | d39a7a6 | 2008-02-07 10:10:28 +0000 | [diff] [blame] | 14 | #include <linux/kernel.h> |
Kristoffer Ericson | d39a7a6 | 2008-02-07 10:10:28 +0000 | [diff] [blame] | 15 | #include <linux/platform_device.h> |
| 16 | #include <linux/leds.h> |
| 17 | #include <asm/hd64461.h> |
Paul Mundt | 7639a45 | 2008-10-20 13:02:48 +0900 | [diff] [blame] | 18 | #include <mach/hp6xx.h> |
Kristoffer Ericson | d39a7a6 | 2008-02-07 10:10:28 +0000 | [diff] [blame] | 19 | |
Németh Márton | 4d404fd | 2008-03-09 20:59:57 +0000 | [diff] [blame] | 20 | static void hp6xxled_green_set(struct led_classdev *led_cdev, |
| 21 | enum led_brightness value) |
Kristoffer Ericson | d39a7a6 | 2008-02-07 10:10:28 +0000 | [diff] [blame] | 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 | |
Németh Márton | 4d404fd | 2008-03-09 20:59:57 +0000 | [diff] [blame] | 32 | static void hp6xxled_red_set(struct led_classdev *led_cdev, |
| 33 | enum led_brightness value) |
Kristoffer Ericson | d39a7a6 | 2008-02-07 10:10:28 +0000 | [diff] [blame] | 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 | |
| 44 | static struct led_classdev hp6xx_red_led = { |
| 45 | .name = "hp6xx:red", |
| 46 | .default_trigger = "hp6xx-charge", |
| 47 | .brightness_set = hp6xxled_red_set, |
Richard Purdie | 859cb7f | 2009-01-08 17:55:03 +0000 | [diff] [blame] | 48 | .flags = LED_CORE_SUSPENDRESUME, |
Kristoffer Ericson | d39a7a6 | 2008-02-07 10:10:28 +0000 | [diff] [blame] | 49 | }; |
| 50 | |
| 51 | static struct led_classdev hp6xx_green_led = { |
| 52 | .name = "hp6xx:green", |
| 53 | .default_trigger = "ide-disk", |
| 54 | .brightness_set = hp6xxled_green_set, |
Richard Purdie | 859cb7f | 2009-01-08 17:55:03 +0000 | [diff] [blame] | 55 | .flags = LED_CORE_SUSPENDRESUME, |
Kristoffer Ericson | d39a7a6 | 2008-02-07 10:10:28 +0000 | [diff] [blame] | 56 | }; |
| 57 | |
Kristoffer Ericson | d39a7a6 | 2008-02-07 10:10:28 +0000 | [diff] [blame] | 58 | static int hp6xxled_probe(struct platform_device *pdev) |
| 59 | { |
| 60 | int ret; |
| 61 | |
| 62 | ret = led_classdev_register(&pdev->dev, &hp6xx_red_led); |
| 63 | if (ret < 0) |
| 64 | return ret; |
| 65 | |
| 66 | ret = led_classdev_register(&pdev->dev, &hp6xx_green_led); |
| 67 | if (ret < 0) |
| 68 | led_classdev_unregister(&hp6xx_red_led); |
| 69 | |
| 70 | return ret; |
| 71 | } |
| 72 | |
| 73 | static int hp6xxled_remove(struct platform_device *pdev) |
| 74 | { |
| 75 | led_classdev_unregister(&hp6xx_red_led); |
| 76 | led_classdev_unregister(&hp6xx_green_led); |
| 77 | |
| 78 | return 0; |
| 79 | } |
| 80 | |
| 81 | static struct platform_driver hp6xxled_driver = { |
| 82 | .probe = hp6xxled_probe, |
| 83 | .remove = hp6xxled_remove, |
Kristoffer Ericson | d39a7a6 | 2008-02-07 10:10:28 +0000 | [diff] [blame] | 84 | .driver = { |
| 85 | .name = "hp6xx-led", |
Kristoffer Ericson | d39a7a6 | 2008-02-07 10:10:28 +0000 | [diff] [blame] | 86 | }, |
| 87 | }; |
| 88 | |
Axel Lin | 892a884 | 2012-01-10 15:09:24 -0800 | [diff] [blame] | 89 | module_platform_driver(hp6xxled_driver); |
Kristoffer Ericson | d39a7a6 | 2008-02-07 10:10:28 +0000 | [diff] [blame] | 90 | |
| 91 | MODULE_AUTHOR("Kristoffer Ericson <kristoffer.ericson@gmail.com>"); |
| 92 | MODULE_DESCRIPTION("HP Jornada 6xx LED driver"); |
| 93 | MODULE_LICENSE("GPL"); |
Axel Lin | 892a884 | 2012-01-10 15:09:24 -0800 | [diff] [blame] | 94 | MODULE_ALIAS("platform:hp6xx-led"); |