leds: Simple GPIO driver to control the AUO backlight

This is a simple driver that controls the AUO backlight and
registers to the LED class driver.

This code is not long term code.  Once new displays are available
this code can be disabled and removed.

Change-Id: I91f4fdfe25060440643597f5419f67a87ef72a96
Signed-off-by: Dan Murphy <wldm10@motorola.com>
This commit is contained in:
Dan Murphy
2010-05-18 13:20:22 -05:00
committed by Colin Cross
parent f8ffb66d1a
commit b65bd1539f
4 changed files with 175 additions and 0 deletions

View File

@@ -138,6 +138,12 @@ config LEDS_PCA9532
LED controller. It is generally only useful
as a platform driver
config LEDS_AUO_PANEL
tristate "Support for AUO display backlight driver"
depends on LEDS_CLASS
help
This option enables support for AUO display backlight driver
config LEDS_GPIO
tristate "LED Support for GPIO connected LEDs"
depends on GENERIC_GPIO

View File

@@ -38,6 +38,7 @@ obj-$(CONFIG_LEDS_ADP5520) += leds-adp5520.o
obj-$(CONFIG_LEDS_DELL_NETBOOKS) += dell-led.o
obj-$(CONFIG_LEDS_MC13783) += leds-mc13783.o
obj-$(CONFIG_LEDS_NS2) += leds-ns2.o
obj-$(CONFIG_LEDS_AUO_PANEL) += leds-auo-panel-backlight.o
# LED SPI Drivers
obj-$(CONFIG_LEDS_DAC124S085) += leds-dac124s085.o

View File

@@ -0,0 +1,128 @@
/*
* Copyright (C) 2010 Motorola, Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
* 02111-1307, USA
*/
#include <linux/leds.h>
#include <linux/leds-auo-panel-backlight.h>
#include <linux/platform_device.h>
#include <linux/slab.h>
#include <linux/types.h>
struct auo_panel_data {
struct led_classdev led_dev;
struct auo_panel_bl_platform_data *auo_pdata;
struct mutex lock;
int led_on;
};
static uint32_t auo_panel_debug;
module_param_named(auo_bl_debug, auo_panel_debug, uint, 0664);
static void ld_auo_panel_brightness_set(struct led_classdev *led_cdev,
enum led_brightness value)
{
struct auo_panel_data *auo_data =
container_of(led_cdev, struct auo_panel_data, led_dev);
mutex_lock(&auo_data->lock);
if (value == LED_OFF) {
if (auo_data->led_on == 1) {
if (auo_data->auo_pdata->bl_disable) {
auo_data->auo_pdata->bl_disable();
auo_data->led_on = 0;
}
}
} else {
if (auo_data->led_on == 0) {
if (auo_data->auo_pdata->bl_enable) {
auo_data->auo_pdata->bl_enable();
auo_data->led_on = 1;
}
}
}
mutex_unlock(&auo_data->lock);
}
static int __devinit ld_auo_panel_bl_probe(struct platform_device *pdev)
{
struct auo_panel_data *auo_data;
int error = 0;
if (pdev->dev.platform_data == NULL) {
pr_err("%s: platform data required\n", __func__);
return -ENODEV;
}
auo_data = kzalloc(sizeof(struct auo_panel_data), GFP_KERNEL);
if (auo_data == NULL)
return -ENOMEM;
auo_data->led_dev.name = LD_AUO_PANEL_BL_LED_DEV;
auo_data->led_dev.brightness_set = ld_auo_panel_brightness_set;
auo_data->auo_pdata = pdev->dev.platform_data;
error = led_classdev_register(&pdev->dev, &auo_data->led_dev);
if (error < 0) {
pr_err("%s: Register led class failed: %d\n", __func__, error);
error = -ENODEV;
kfree(auo_data);
return error;
}
mutex_init(&auo_data->lock);
mutex_lock(&auo_data->lock);
auo_data->led_on = 1;
mutex_unlock(&auo_data->lock);
platform_set_drvdata(pdev, auo_data);
return 0;
}
static int __devexit ld_auo_panel_remove(struct platform_device *pdev)
{
struct auo_panel_data *auo_data = pdev->dev.platform_data;
led_classdev_unregister(&auo_data->led_dev);
kfree(auo_data);
return 0;
}
static struct platform_driver auo_led_driver = {
.probe = ld_auo_panel_bl_probe,
.remove = __devexit_p(ld_auo_panel_remove),
.driver = {
.name = LD_AUO_PANEL_BL_NAME,
.owner = THIS_MODULE,
},
};
static int __init ld_auo_panel_init(void)
{
return platform_driver_register(&auo_led_driver);
}
static void __exit ld_auo_panel_exit(void)
{
platform_driver_unregister(&auo_led_driver);
}
module_init(ld_auo_panel_init);
module_exit(ld_auo_panel_exit);
MODULE_DESCRIPTION("Lighting driver for the AUO display panel");
MODULE_AUTHOR("Dan Murphy <wldm10@Motorola.com>");
MODULE_LICENSE("GPL");

View File

@@ -0,0 +1,40 @@
/*
* Copyright (C) 2009 Motorola, Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
* 02111-1307, USA
*/
#ifndef _LINUX_LED_LD_AUO_PANEL_BL_H__
#define _LINUX_LED_LD_AUO_PANEL_BL_H__
#define MANUAL 0
#define AUTOMATIC 1
#define MANUAL_SENSOR 2
#define LD_AUO_PANEL_BL_LED_DEV "lcd-backlight"
#define LD_AUO_PANEL_BL_NAME "auo_panel_bl_led"
#ifdef __KERNEL__
struct auo_panel_bl_platform_data {
void (*bl_enable) (void);
void (*bl_disable) (void);
void (*pwm_enable) (void);
void (*pwm_disable) (void);
};
#endif /* __KERNEL__ */
#endif /* _LINUX_LED_LD_AUO_PANEL_BL_H__ */