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>
30 #define DRVNAME "ar7-leds"
31 #define LONGNAME "TI AR7 LEDs driver"
33 MODULE_AUTHOR("Nicolas Thill <nico@openwrt.org>");
34 MODULE_DESCRIPTION(LONGNAME
);
35 MODULE_LICENSE("GPL");
37 static void ar7_status_led_set(struct led_classdev
*pled
,
38 enum led_brightness value
)
40 gpio_set_value(AR7_GPIO_BIT_STATUS_LED
, value
? 0 : 1);
43 static struct led_classdev ar7_status_led
= {
45 .brightness_set
= ar7_status_led_set
,
49 static int ar7_leds_suspend(struct platform_device
*dev
,
52 led_classdev_suspend(&ar7_status_led
);
56 static int ar7_leds_resume(struct platform_device
*dev
)
58 led_classdev_resume(&ar7_status_led
);
62 #define ar7_leds_suspend NULL
63 #define ar7_leds_resume NULL
64 #endif /* CONFIG_PM */
66 static int ar7_leds_probe(struct platform_device
*pdev
)
70 rc
= led_classdev_register(&pdev
->dev
, &ar7_status_led
);
74 ar7_gpio_enable(AR7_GPIO_BIT_STATUS_LED
);
75 gpio_direction_output(AR7_GPIO_BIT_STATUS_LED
);
81 static int ar7_leds_remove(struct platform_device
*pdev
)
83 led_classdev_unregister(&ar7_status_led
);
88 static struct platform_device
*ar7_leds_device
;
90 static struct platform_driver ar7_leds_driver
= {
91 .probe
= ar7_leds_probe
,
92 .remove
= ar7_leds_remove
,
93 .suspend
= ar7_leds_suspend
,
94 .resume
= ar7_leds_resume
,
100 static int __init
ar7_leds_init(void)
104 ar7_leds_device
= platform_device_alloc(DRVNAME
, -1);
105 if (!ar7_leds_device
)
108 rc
= platform_device_add(ar7_leds_device
);
112 rc
= platform_driver_register(&ar7_leds_driver
);
119 platform_device_put(ar7_leds_device
);
124 static void __exit
ar7_leds_exit(void)
126 platform_driver_unregister(&ar7_leds_driver
);
127 platform_device_unregister(ar7_leds_device
);
130 module_init(ar7_leds_init
);
131 module_exit(ar7_leds_exit
);