[MTD] [NAND] Blackfin NFC Driver: mark bf5xx_nand_add_partition() as __devinit
[linux-2.6/mini2440.git] / drivers / leds / leds-hp6xx.c
blobe4ce1fd46338122b6e93b39f102a81be4ea621cb
1 /*
2 * LED Triggers Core
3 * For the HP Jornada 620/660/680/690 handhelds
5 * Copyright 2008 Kristoffer Ericson <kristoffer.ericson@gmail.com>
6 * this driver is based on leds-spitz.c by Richard Purdie.
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.
13 #include <linux/kernel.h>
14 #include <linux/init.h>
15 #include <linux/platform_device.h>
16 #include <linux/leds.h>
17 #include <asm/hd64461.h>
18 #include <mach/hp6xx.h>
20 static void hp6xxled_green_set(struct led_classdev *led_cdev,
21 enum led_brightness value)
23 u8 v8;
25 v8 = inb(PKDR);
26 if (value)
27 outb(v8 & (~PKDR_LED_GREEN), PKDR);
28 else
29 outb(v8 | PKDR_LED_GREEN, PKDR);
32 static void hp6xxled_red_set(struct led_classdev *led_cdev,
33 enum led_brightness value)
35 u16 v16;
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);
44 static 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,
51 static struct led_classdev hp6xx_green_led = {
52 .name = "hp6xx:green",
53 .default_trigger = "ide-disk",
54 .brightness_set = hp6xxled_green_set,
55 .flags = LED_CORE_SUSPENDRESUME,
58 static int hp6xxled_probe(struct platform_device *pdev)
60 int ret;
62 ret = led_classdev_register(&pdev->dev, &hp6xx_red_led);
63 if (ret < 0)
64 return ret;
66 ret = led_classdev_register(&pdev->dev, &hp6xx_green_led);
67 if (ret < 0)
68 led_classdev_unregister(&hp6xx_red_led);
70 return ret;
73 static int hp6xxled_remove(struct platform_device *pdev)
75 led_classdev_unregister(&hp6xx_red_led);
76 led_classdev_unregister(&hp6xx_green_led);
78 return 0;
81 /* work with hotplug and coldplug */
82 MODULE_ALIAS("platform:hp6xx-led");
84 static struct platform_driver hp6xxled_driver = {
85 .probe = hp6xxled_probe,
86 .remove = hp6xxled_remove,
87 .driver = {
88 .name = "hp6xx-led",
89 .owner = THIS_MODULE,
93 static int __init hp6xxled_init(void)
95 return platform_driver_register(&hp6xxled_driver);
98 static void __exit hp6xxled_exit(void)
100 platform_driver_unregister(&hp6xxled_driver);
103 module_init(hp6xxled_init);
104 module_exit(hp6xxled_exit);
106 MODULE_AUTHOR("Kristoffer Ericson <kristoffer.ericson@gmail.com>");
107 MODULE_DESCRIPTION("HP Jornada 6xx LED driver");
108 MODULE_LICENSE("GPL");