2 * Copyright (C) 2010 Motorola, Inc.
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
19 #include <linux/leds.h>
20 #include <linux/leds-auo-panel-backlight.h>
21 #include <linux/platform_device.h>
22 #include <linux/slab.h>
23 #include <linux/types.h>
25 struct auo_panel_data {
26 struct led_classdev led_dev;
27 struct auo_panel_bl_platform_data *auo_pdata;
32 static uint32_t auo_panel_debug;
33 module_param_named(auo_bl_debug, auo_panel_debug, uint, 0664);
35 static void ld_auo_panel_brightness_set(struct led_classdev *led_cdev,
36 enum led_brightness value)
38 struct auo_panel_data *auo_data =
39 container_of(led_cdev, struct auo_panel_data, led_dev);
41 mutex_lock(&auo_data->lock);
42 if (value == LED_OFF) {
43 if (auo_data->led_on == 1) {
44 if (auo_data->auo_pdata->bl_disable) {
45 auo_data->auo_pdata->bl_disable();
50 if (auo_data->led_on == 0) {
51 if (auo_data->auo_pdata->bl_enable) {
52 auo_data->auo_pdata->bl_enable();
57 mutex_unlock(&auo_data->lock);
60 static int __devinit ld_auo_panel_bl_probe(struct platform_device *pdev)
62 struct auo_panel_data *auo_data;
65 if (pdev->dev.platform_data == NULL) {
66 pr_err("%s: platform data required\n", __func__);
69 auo_data = kzalloc(sizeof(struct auo_panel_data), GFP_KERNEL);
73 auo_data->led_dev.name = LD_AUO_PANEL_BL_LED_DEV;
74 auo_data->led_dev.brightness_set = ld_auo_panel_brightness_set;
76 auo_data->auo_pdata = pdev->dev.platform_data;
78 error = led_classdev_register(&pdev->dev, &auo_data->led_dev);
80 pr_err("%s: Register led class failed: %d\n", __func__, error);
85 mutex_init(&auo_data->lock);
87 mutex_lock(&auo_data->lock);
89 mutex_unlock(&auo_data->lock);
91 platform_set_drvdata(pdev, auo_data);
96 static int __devexit ld_auo_panel_remove(struct platform_device *pdev)
98 struct auo_panel_data *auo_data = pdev->dev.platform_data;
99 led_classdev_unregister(&auo_data->led_dev);
104 static struct platform_driver auo_led_driver = {
105 .probe = ld_auo_panel_bl_probe,
106 .remove = __devexit_p(ld_auo_panel_remove),
108 .name = LD_AUO_PANEL_BL_NAME,
109 .owner = THIS_MODULE,
112 static int __init ld_auo_panel_init(void)
114 return platform_driver_register(&auo_led_driver);
117 static void __exit ld_auo_panel_exit(void)
119 platform_driver_unregister(&auo_led_driver);
123 module_init(ld_auo_panel_init);
124 module_exit(ld_auo_panel_exit);
126 MODULE_DESCRIPTION("Lighting driver for the AUO display panel");
127 MODULE_AUTHOR("Dan Murphy <wldm10@Motorola.com>");
128 MODULE_LICENSE("GPL");