4 * Copyright 2005-2006 Openedhand Ltd.
6 * Author: Richard Purdie <rpurdie@openedhand.com>
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.
14 #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>
24 static void corgiled_amber_set(struct led_classdev *led_cdev,
25 enum led_brightness value)
28 GPSR0 = GPIO_bit(CORGI_GPIO_LED_ORANGE);
30 GPCR0 = GPIO_bit(CORGI_GPIO_LED_ORANGE);
33 static void corgiled_green_set(struct led_classdev *led_cdev,
34 enum led_brightness value)
37 set_scoop_gpio(&corgiscoop_device.dev, CORGI_SCP_LED_GREEN);
39 reset_scoop_gpio(&corgiscoop_device.dev, CORGI_SCP_LED_GREEN);
42 static struct led_classdev corgi_amber_led = {
43 .name = "corgi:amber:charge",
44 .default_trigger = "sharpsl-charge",
45 .brightness_set = corgiled_amber_set,
48 static struct led_classdev corgi_green_led = {
49 .name = "corgi:green:mail",
50 .default_trigger = "nand-disk",
51 .brightness_set = corgiled_green_set,
55 static int corgiled_suspend(struct platform_device *dev, pm_message_t state)
57 #ifdef CONFIG_LEDS_TRIGGERS
58 if (corgi_amber_led.trigger &&
59 strcmp(corgi_amber_led.trigger->name, "sharpsl-charge"))
61 led_classdev_suspend(&corgi_amber_led);
62 led_classdev_suspend(&corgi_green_led);
66 static int corgiled_resume(struct platform_device *dev)
68 led_classdev_resume(&corgi_amber_led);
69 led_classdev_resume(&corgi_green_led);
74 static int corgiled_probe(struct platform_device *pdev)
78 ret = led_classdev_register(&pdev->dev, &corgi_amber_led);
82 ret = led_classdev_register(&pdev->dev, &corgi_green_led);
84 led_classdev_unregister(&corgi_amber_led);
89 static int corgiled_remove(struct platform_device *pdev)
91 led_classdev_unregister(&corgi_amber_led);
92 led_classdev_unregister(&corgi_green_led);
96 static struct platform_driver corgiled_driver = {
97 .probe = corgiled_probe,
98 .remove = corgiled_remove,
100 .suspend = corgiled_suspend,
101 .resume = corgiled_resume,
105 .owner = THIS_MODULE,
109 static int __init corgiled_init(void)
111 return platform_driver_register(&corgiled_driver);
114 static void __exit corgiled_exit(void)
116 platform_driver_unregister(&corgiled_driver);
119 module_init(corgiled_init);
120 module_exit(corgiled_exit);
122 MODULE_AUTHOR("Richard Purdie <rpurdie@openedhand.com>");
123 MODULE_DESCRIPTION("Corgi LED driver");
124 MODULE_LICENSE("GPL");
125 MODULE_ALIAS("platform:corgi-led");