2 * linux/drivers/leds/leds-ar7.c
4 * Copyright (C) 2007 OpenWrt.org
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22 #include <linux/kernel.h>
23 #include <linux/init.h>
24 #include <linux/platform_device.h>
25 #include <linux/leds.h>
26 #include <linux/err.h>
31 #define DRVNAME "ar7-leds"
32 #define LONGNAME "TI AR7 LEDs driver"
34 MODULE_AUTHOR("Nicolas Thill <nico@openwrt.org>");
35 MODULE_DESCRIPTION(LONGNAME);
36 MODULE_LICENSE("GPL");
38 static void ar7_status_led_set(struct led_classdev *pled,
39 enum led_brightness value)
41 gpio_set_value(AR7_GPIO_BIT_STATUS_LED, value ? 0 : 1);
44 static struct led_classdev ar7_status_led = {
46 .brightness_set = ar7_status_led_set,
50 static int ar7_leds_suspend(struct platform_device *dev,
53 led_classdev_suspend(&ar7_status_led);
57 static int ar7_leds_resume(struct platform_device *dev)
59 led_classdev_resume(&ar7_status_led);
63 #define ar7_leds_suspend NULL
64 #define ar7_leds_resume NULL
65 #endif /* CONFIG_PM */
67 static int ar7_leds_probe(struct platform_device *pdev)
71 rc = led_classdev_register(&pdev->dev, &ar7_status_led);
75 ar7_gpio_enable(AR7_GPIO_BIT_STATUS_LED);
76 gpio_direction_output(AR7_GPIO_BIT_STATUS_LED);
82 static int ar7_leds_remove(struct platform_device *pdev)
84 led_classdev_unregister(&ar7_status_led);
89 static struct platform_device *ar7_leds_device;
91 static struct platform_driver ar7_leds_driver = {
92 .probe = ar7_leds_probe,
93 .remove = ar7_leds_remove,
94 .suspend = ar7_leds_suspend,
95 .resume = ar7_leds_resume,
101 static int __init ar7_leds_init(void)
105 ar7_leds_device = platform_device_alloc(DRVNAME, -1);
106 if (!ar7_leds_device)
109 rc = platform_device_add(ar7_leds_device);
113 rc = platform_driver_register(&ar7_leds_driver);
120 platform_device_put(ar7_leds_device);
125 static void __exit ar7_leds_exit(void)
127 platform_driver_unregister(&ar7_leds_driver);
128 platform_device_unregister(ar7_leds_device);
131 module_init(ar7_leds_init);
132 module_exit(ar7_leds_exit);