2 * drivers/leds/leds-cm-x270.c
4 * Copyright 2007 CompuLab Ltd.
5 * Author: Mike Rapoport <mike@compulab.co.il>
7 * Based on leds-corgi.c
8 * Author: Richard Purdie <rpurdie@openedhand.com>
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License version 2 as
12 * published by the Free Software Foundation.
16 #include <linux/kernel.h>
17 #include <linux/init.h>
18 #include <linux/platform_device.h>
19 #include <linux/leds.h>
21 #include <asm/arch/hardware.h>
22 #include <asm/arch/pxa-regs.h>
24 #define GPIO_RED_LED (93)
25 #define GPIO_GREEN_LED (94)
27 static void cmx270_red_set(struct led_classdev *led_cdev,
28 enum led_brightness value)
31 GPCR(GPIO_RED_LED) = GPIO_bit(GPIO_RED_LED);
33 GPSR(GPIO_RED_LED) = GPIO_bit(GPIO_RED_LED);
36 static void cmx270_green_set(struct led_classdev *led_cdev,
37 enum led_brightness value)
40 GPCR(GPIO_GREEN_LED) = GPIO_bit(GPIO_GREEN_LED);
42 GPSR(GPIO_GREEN_LED) = GPIO_bit(GPIO_GREEN_LED);
45 static struct led_classdev cmx270_red_led = {
46 .name = "cm-x270:red",
47 .default_trigger = "nand-disk",
48 .brightness_set = cmx270_red_set,
51 static struct led_classdev cmx270_green_led = {
52 .name = "cm-x270:green",
53 .default_trigger = "heartbeat",
54 .brightness_set = cmx270_green_set,
58 static int cmx270led_suspend(struct platform_device *dev, pm_message_t state)
60 led_classdev_suspend(&cmx270_red_led);
61 led_classdev_suspend(&cmx270_green_led);
65 static int cmx270led_resume(struct platform_device *dev)
67 led_classdev_resume(&cmx270_red_led);
68 led_classdev_resume(&cmx270_green_led);
73 static int cmx270led_probe(struct platform_device *pdev)
77 ret = led_classdev_register(&pdev->dev, &cmx270_red_led);
81 ret = led_classdev_register(&pdev->dev, &cmx270_green_led);
83 led_classdev_unregister(&cmx270_red_led);
88 static int cmx270led_remove(struct platform_device *pdev)
90 led_classdev_unregister(&cmx270_red_led);
91 led_classdev_unregister(&cmx270_green_led);
95 static struct platform_driver cmx270led_driver = {
96 .probe = cmx270led_probe,
97 .remove = cmx270led_remove,
99 .suspend = cmx270led_suspend,
100 .resume = cmx270led_resume,
103 .name = "cm-x270-led",
107 static int __init cmx270led_init(void)
109 return platform_driver_register(&cmx270led_driver);
112 static void __exit cmx270led_exit(void)
114 platform_driver_unregister(&cmx270led_driver);
117 module_init(cmx270led_init);
118 module_exit(cmx270led_exit);
120 MODULE_AUTHOR("Mike Rapoport <mike@compulab.co.il>");
121 MODULE_DESCRIPTION("CM-x270 LED driver");
122 MODULE_LICENSE("GPL");