blob: fb2416a38303ce87aab0766dac1c9997ecca506a [file] [log] [blame]
Dirk Opfer6d0cf3e2006-03-31 02:31:12 -08001/*
2 * LED Triggers Core
3 *
4 * Copyright 2005 Dirk Opfer
5 *
6 * Author: Dirk Opfer <Dirk@Opfer-Online.de>
7 * based on spitz.c
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2 as
11 * published by the Free Software Foundation.
12 *
13 */
14
Dirk Opfer6d0cf3e2006-03-31 02:31:12 -080015#include <linux/kernel.h>
16#include <linux/init.h>
17#include <linux/platform_device.h>
18#include <linux/leds.h>
19#include <asm/hardware/scoop.h>
20#include <asm/mach-types.h>
21#include <asm/arch/hardware.h>
22#include <asm/arch/pxa-regs.h>
23#include <asm/arch/tosa.h>
24
25static void tosaled_amber_set(struct led_classdev *led_cdev,
26 enum led_brightness value)
27{
28 if (value)
29 set_scoop_gpio(&tosascoop_jc_device.dev,
30 TOSA_SCOOP_JC_CHRG_ERR_LED);
31 else
32 reset_scoop_gpio(&tosascoop_jc_device.dev,
33 TOSA_SCOOP_JC_CHRG_ERR_LED);
34}
35
36static void tosaled_green_set(struct led_classdev *led_cdev,
37 enum led_brightness value)
38{
39 if (value)
40 set_scoop_gpio(&tosascoop_jc_device.dev,
41 TOSA_SCOOP_JC_NOTE_LED);
42 else
43 reset_scoop_gpio(&tosascoop_jc_device.dev,
44 TOSA_SCOOP_JC_NOTE_LED);
45}
46
47static struct led_classdev tosa_amber_led = {
48 .name = "tosa:amber",
49 .default_trigger = "sharpsl-charge",
50 .brightness_set = tosaled_amber_set,
51};
52
53static struct led_classdev tosa_green_led = {
54 .name = "tosa:green",
55 .default_trigger = "nand-disk",
56 .brightness_set = tosaled_green_set,
57};
58
59#ifdef CONFIG_PM
60static int tosaled_suspend(struct platform_device *dev, pm_message_t state)
61{
62#ifdef CONFIG_LEDS_TRIGGERS
63 if (tosa_amber_led.trigger && strcmp(tosa_amber_led.trigger->name,
64 "sharpsl-charge"))
65#endif
66 led_classdev_suspend(&tosa_amber_led);
67 led_classdev_suspend(&tosa_green_led);
68 return 0;
69}
70
71static int tosaled_resume(struct platform_device *dev)
72{
73 led_classdev_resume(&tosa_amber_led);
74 led_classdev_resume(&tosa_green_led);
75 return 0;
76}
77#else
78#define tosaled_suspend NULL
79#define tosaled_resume NULL
80#endif
81
82static int tosaled_probe(struct platform_device *pdev)
83{
84 int ret;
85
86 ret = led_classdev_register(&pdev->dev, &tosa_amber_led);
87 if (ret < 0)
88 return ret;
89
90 ret = led_classdev_register(&pdev->dev, &tosa_green_led);
91 if (ret < 0)
92 led_classdev_unregister(&tosa_amber_led);
93
94 return ret;
95}
96
97static int tosaled_remove(struct platform_device *pdev)
98{
99 led_classdev_unregister(&tosa_amber_led);
100 led_classdev_unregister(&tosa_green_led);
101
102 return 0;
103}
104
105static struct platform_driver tosaled_driver = {
106 .probe = tosaled_probe,
107 .remove = tosaled_remove,
108 .suspend = tosaled_suspend,
109 .resume = tosaled_resume,
110 .driver = {
111 .name = "tosa-led",
112 },
113};
114
115static int __init tosaled_init(void)
116{
117 return platform_driver_register(&tosaled_driver);
118}
119
120static void __exit tosaled_exit(void)
121{
122 platform_driver_unregister(&tosaled_driver);
123}
124
125module_init(tosaled_init);
126module_exit(tosaled_exit);
127
128MODULE_AUTHOR("Dirk Opfer <Dirk@Opfer-Online.de>");
129MODULE_DESCRIPTION("Tosa LED driver");
130MODULE_LICENSE("GPL");