2 * LEDs driver for PCEngines WRAP
4 * Copyright (C) 2006 Kristian Kielhofner <kris@krisk.org>
6 * Based on leds-net48xx.c
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 <linux/err.h>
19 #include <linux/scx200_gpio.h>
21 #define DRVNAME "wrap-led"
22 #define WRAP_POWER_LED_GPIO 2
23 #define WRAP_ERROR_LED_GPIO 3
24 #define WRAP_EXTRA_LED_GPIO 18
26 static struct platform_device
*pdev
;
28 static void wrap_power_led_set(struct led_classdev
*led_cdev
,
29 enum led_brightness value
)
32 scx200_gpio_set_low(WRAP_POWER_LED_GPIO
);
34 scx200_gpio_set_high(WRAP_POWER_LED_GPIO
);
37 static void wrap_error_led_set(struct led_classdev
*led_cdev
,
38 enum led_brightness value
)
41 scx200_gpio_set_low(WRAP_ERROR_LED_GPIO
);
43 scx200_gpio_set_high(WRAP_ERROR_LED_GPIO
);
46 static void wrap_extra_led_set(struct led_classdev
*led_cdev
,
47 enum led_brightness value
)
50 scx200_gpio_set_low(WRAP_EXTRA_LED_GPIO
);
52 scx200_gpio_set_high(WRAP_EXTRA_LED_GPIO
);
55 static struct led_classdev wrap_power_led
= {
56 .name
= "wrap::power",
57 .brightness_set
= wrap_power_led_set
,
60 static struct led_classdev wrap_error_led
= {
61 .name
= "wrap::error",
62 .brightness_set
= wrap_error_led_set
,
65 static struct led_classdev wrap_extra_led
= {
66 .name
= "wrap::extra",
67 .brightness_set
= wrap_extra_led_set
,
71 static int wrap_led_suspend(struct platform_device
*dev
,
74 led_classdev_suspend(&wrap_power_led
);
75 led_classdev_suspend(&wrap_error_led
);
76 led_classdev_suspend(&wrap_extra_led
);
80 static int wrap_led_resume(struct platform_device
*dev
)
82 led_classdev_resume(&wrap_power_led
);
83 led_classdev_resume(&wrap_error_led
);
84 led_classdev_resume(&wrap_extra_led
);
88 #define wrap_led_suspend NULL
89 #define wrap_led_resume NULL
92 static int wrap_led_probe(struct platform_device
*pdev
)
96 ret
= led_classdev_register(&pdev
->dev
, &wrap_power_led
);
100 ret
= led_classdev_register(&pdev
->dev
, &wrap_error_led
);
104 ret
= led_classdev_register(&pdev
->dev
, &wrap_extra_led
);
111 led_classdev_unregister(&wrap_error_led
);
113 led_classdev_unregister(&wrap_power_led
);
118 static int wrap_led_remove(struct platform_device
*pdev
)
120 led_classdev_unregister(&wrap_power_led
);
121 led_classdev_unregister(&wrap_error_led
);
122 led_classdev_unregister(&wrap_extra_led
);
126 static struct platform_driver wrap_led_driver
= {
127 .probe
= wrap_led_probe
,
128 .remove
= wrap_led_remove
,
129 .suspend
= wrap_led_suspend
,
130 .resume
= wrap_led_resume
,
133 .owner
= THIS_MODULE
,
137 static int __init
wrap_led_init(void)
141 if (!scx200_gpio_present()) {
146 ret
= platform_driver_register(&wrap_led_driver
);
150 pdev
= platform_device_register_simple(DRVNAME
, -1, NULL
, 0);
153 platform_driver_unregister(&wrap_led_driver
);
161 static void __exit
wrap_led_exit(void)
163 platform_device_unregister(pdev
);
164 platform_driver_unregister(&wrap_led_driver
);
167 module_init(wrap_led_init
);
168 module_exit(wrap_led_exit
);
170 MODULE_AUTHOR("Kristian Kielhofner <kris@krisk.org>");
171 MODULE_DESCRIPTION("PCEngines WRAP LED driver");
172 MODULE_LICENSE("GPL");