blob: a709704b9f933c3af919f07d3fc54cffb0d68f22 [file] [log] [blame]
Richard Purdie31791082006-03-31 02:31:09 -08001/*
2 * LED Triggers Core
3 *
4 * Copyright 2005-2006 Openedhand Ltd.
5 *
6 * Author: Richard Purdie <rpurdie@openedhand.com>
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 */
13
Richard Purdie31791082006-03-31 02:31:09 -080014#include <linux/kernel.h>
15#include <linux/init.h>
16#include <linux/platform_device.h>
17#include <linux/leds.h>
18#include <asm/mach-types.h>
19#include <asm/arch/corgi.h>
20#include <asm/arch/hardware.h>
21#include <asm/arch/pxa-regs.h>
22#include <asm/hardware/scoop.h>
23
Németh Márton4d404fd2008-03-09 20:59:57 +000024static void corgiled_amber_set(struct led_classdev *led_cdev,
25 enum led_brightness value)
Richard Purdie31791082006-03-31 02:31:09 -080026{
27 if (value)
28 GPSR0 = GPIO_bit(CORGI_GPIO_LED_ORANGE);
29 else
30 GPCR0 = GPIO_bit(CORGI_GPIO_LED_ORANGE);
31}
32
Németh Márton4d404fd2008-03-09 20:59:57 +000033static void corgiled_green_set(struct led_classdev *led_cdev,
34 enum led_brightness value)
Richard Purdie31791082006-03-31 02:31:09 -080035{
36 if (value)
37 set_scoop_gpio(&corgiscoop_device.dev, CORGI_SCP_LED_GREEN);
38 else
39 reset_scoop_gpio(&corgiscoop_device.dev, CORGI_SCP_LED_GREEN);
40}
41
42static struct led_classdev corgi_amber_led = {
Richard Purdie6c152be2007-10-31 15:00:07 +010043 .name = "corgi:amber:charge",
Richard Purdie31791082006-03-31 02:31:09 -080044 .default_trigger = "sharpsl-charge",
45 .brightness_set = corgiled_amber_set,
46};
47
48static struct led_classdev corgi_green_led = {
Richard Purdie6c152be2007-10-31 15:00:07 +010049 .name = "corgi:green:mail",
Richard Purdie31791082006-03-31 02:31:09 -080050 .default_trigger = "nand-disk",
51 .brightness_set = corgiled_green_set,
52};
53
54#ifdef CONFIG_PM
55static int corgiled_suspend(struct platform_device *dev, pm_message_t state)
56{
57#ifdef CONFIG_LEDS_TRIGGERS
Németh Márton4d404fd2008-03-09 20:59:57 +000058 if (corgi_amber_led.trigger &&
59 strcmp(corgi_amber_led.trigger->name, "sharpsl-charge"))
Richard Purdie31791082006-03-31 02:31:09 -080060#endif
61 led_classdev_suspend(&corgi_amber_led);
62 led_classdev_suspend(&corgi_green_led);
63 return 0;
64}
65
66static int corgiled_resume(struct platform_device *dev)
67{
68 led_classdev_resume(&corgi_amber_led);
69 led_classdev_resume(&corgi_green_led);
70 return 0;
71}
72#endif
73
74static int corgiled_probe(struct platform_device *pdev)
75{
76 int ret;
77
78 ret = led_classdev_register(&pdev->dev, &corgi_amber_led);
79 if (ret < 0)
80 return ret;
81
82 ret = led_classdev_register(&pdev->dev, &corgi_green_led);
83 if (ret < 0)
84 led_classdev_unregister(&corgi_amber_led);
85
86 return ret;
87}
88
89static int corgiled_remove(struct platform_device *pdev)
90{
91 led_classdev_unregister(&corgi_amber_led);
92 led_classdev_unregister(&corgi_green_led);
93 return 0;
94}
95
96static struct platform_driver corgiled_driver = {
97 .probe = corgiled_probe,
98 .remove = corgiled_remove,
99#ifdef CONFIG_PM
100 .suspend = corgiled_suspend,
101 .resume = corgiled_resume,
102#endif
103 .driver = {
104 .name = "corgi-led",
Kay Sievers3c4ded92008-04-15 14:34:30 -0700105 .owner = THIS_MODULE,
Richard Purdie31791082006-03-31 02:31:09 -0800106 },
107};
108
109static int __init corgiled_init(void)
110{
111 return platform_driver_register(&corgiled_driver);
112}
113
114static void __exit corgiled_exit(void)
115{
Németh Márton4d404fd2008-03-09 20:59:57 +0000116 platform_driver_unregister(&corgiled_driver);
Richard Purdie31791082006-03-31 02:31:09 -0800117}
118
119module_init(corgiled_init);
120module_exit(corgiled_exit);
121
122MODULE_AUTHOR("Richard Purdie <rpurdie@openedhand.com>");
123MODULE_DESCRIPTION("Corgi LED driver");
124MODULE_LICENSE("GPL");
Kay Sievers3c4ded92008-04-15 14:34:30 -0700125MODULE_ALIAS("platform:corgi-led");