2009-09-17 12:29:52 -06:00
|
|
|
/*
|
|
|
|
* Backlight driver for Analog Devices ADP5520/ADP5501 MFD PMICs
|
|
|
|
*
|
|
|
|
* Copyright 2009 Analog Devices Inc.
|
|
|
|
*
|
|
|
|
* Licensed under the GPL-2 or later.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/kernel.h>
|
|
|
|
#include <linux/init.h>
|
|
|
|
#include <linux/platform_device.h>
|
|
|
|
#include <linux/fb.h>
|
|
|
|
#include <linux/backlight.h>
|
|
|
|
#include <linux/mfd/adp5520.h>
|
include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h
percpu.h is included by sched.h and module.h and thus ends up being
included when building most .c files. percpu.h includes slab.h which
in turn includes gfp.h making everything defined by the two files
universally available and complicating inclusion dependencies.
percpu.h -> slab.h dependency is about to be removed. Prepare for
this change by updating users of gfp and slab facilities include those
headers directly instead of assuming availability. As this conversion
needs to touch large number of source files, the following script is
used as the basis of conversion.
http://userweb.kernel.org/~tj/misc/slabh-sweep.py
The script does the followings.
* Scan files for gfp and slab usages and update includes such that
only the necessary includes are there. ie. if only gfp is used,
gfp.h, if slab is used, slab.h.
* When the script inserts a new include, it looks at the include
blocks and try to put the new include such that its order conforms
to its surrounding. It's put in the include block which contains
core kernel includes, in the same order that the rest are ordered -
alphabetical, Christmas tree, rev-Xmas-tree or at the end if there
doesn't seem to be any matching order.
* If the script can't find a place to put a new include (mostly
because the file doesn't have fitting include block), it prints out
an error message indicating which .h file needs to be added to the
file.
The conversion was done in the following steps.
1. The initial automatic conversion of all .c files updated slightly
over 4000 files, deleting around 700 includes and adding ~480 gfp.h
and ~3000 slab.h inclusions. The script emitted errors for ~400
files.
2. Each error was manually checked. Some didn't need the inclusion,
some needed manual addition while adding it to implementation .h or
embedding .c file was more appropriate for others. This step added
inclusions to around 150 files.
3. The script was run again and the output was compared to the edits
from #2 to make sure no file was left behind.
4. Several build tests were done and a couple of problems were fixed.
e.g. lib/decompress_*.c used malloc/free() wrappers around slab
APIs requiring slab.h to be added manually.
5. The script was run on all .h files but without automatically
editing them as sprinkling gfp.h and slab.h inclusions around .h
files could easily lead to inclusion dependency hell. Most gfp.h
inclusion directives were ignored as stuff from gfp.h was usually
wildly available and often used in preprocessor macros. Each
slab.h inclusion directive was examined and added manually as
necessary.
6. percpu.h was updated not to include slab.h.
7. Build test were done on the following configurations and failures
were fixed. CONFIG_GCOV_KERNEL was turned off for all tests (as my
distributed build env didn't work with gcov compiles) and a few
more options had to be turned off depending on archs to make things
build (like ipr on powerpc/64 which failed due to missing writeq).
* x86 and x86_64 UP and SMP allmodconfig and a custom test config.
* powerpc and powerpc64 SMP allmodconfig
* sparc and sparc64 SMP allmodconfig
* ia64 SMP allmodconfig
* s390 SMP allmodconfig
* alpha SMP allmodconfig
* um on x86_64 SMP allmodconfig
8. percpu.h modifications were reverted so that it could be applied as
a separate patch and serve as bisection point.
Given the fact that I had only a couple of failures from tests on step
6, I'm fairly confident about the coverage of this conversion patch.
If there is a breakage, it's likely to be something in one of the arch
headers which should be easily discoverable easily on most builds of
the specific arch.
Signed-off-by: Tejun Heo <tj@kernel.org>
Guess-its-ok-by: Christoph Lameter <cl@linux-foundation.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
2010-03-24 02:04:11 -06:00
|
|
|
#include <linux/slab.h>
|
2011-07-03 14:17:28 -06:00
|
|
|
#include <linux/module.h>
|
2009-09-17 12:29:52 -06:00
|
|
|
|
|
|
|
struct adp5520_bl {
|
|
|
|
struct device *master;
|
2009-10-10 11:54:04 -06:00
|
|
|
struct adp5520_backlight_platform_data *pdata;
|
2009-09-17 12:29:52 -06:00
|
|
|
struct mutex lock;
|
|
|
|
unsigned long cached_daylight_max;
|
|
|
|
int id;
|
|
|
|
int current_brightness;
|
|
|
|
};
|
|
|
|
|
|
|
|
static int adp5520_bl_set(struct backlight_device *bl, int brightness)
|
|
|
|
{
|
|
|
|
struct adp5520_bl *data = bl_get_data(bl);
|
|
|
|
struct device *master = data->master;
|
|
|
|
int ret = 0;
|
|
|
|
|
|
|
|
if (data->pdata->en_ambl_sens) {
|
|
|
|
if ((brightness > 0) && (brightness < ADP5020_MAX_BRIGHTNESS)) {
|
|
|
|
/* Disable Ambient Light auto adjust */
|
2009-10-10 11:54:04 -06:00
|
|
|
ret |= adp5520_clr_bits(master, ADP5520_BL_CONTROL,
|
|
|
|
ADP5520_BL_AUTO_ADJ);
|
|
|
|
ret |= adp5520_write(master, ADP5520_DAYLIGHT_MAX,
|
|
|
|
brightness);
|
2009-09-17 12:29:52 -06:00
|
|
|
} else {
|
|
|
|
/*
|
|
|
|
* MAX_BRIGHTNESS -> Enable Ambient Light auto adjust
|
|
|
|
* restore daylight l3 sysfs brightness
|
|
|
|
*/
|
2009-10-10 11:54:04 -06:00
|
|
|
ret |= adp5520_write(master, ADP5520_DAYLIGHT_MAX,
|
2009-09-17 12:29:52 -06:00
|
|
|
data->cached_daylight_max);
|
2009-10-10 11:54:04 -06:00
|
|
|
ret |= adp5520_set_bits(master, ADP5520_BL_CONTROL,
|
|
|
|
ADP5520_BL_AUTO_ADJ);
|
2009-09-17 12:29:52 -06:00
|
|
|
}
|
|
|
|
} else {
|
2009-10-10 11:54:04 -06:00
|
|
|
ret |= adp5520_write(master, ADP5520_DAYLIGHT_MAX, brightness);
|
2009-09-17 12:29:52 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
if (data->current_brightness && brightness == 0)
|
|
|
|
ret |= adp5520_set_bits(master,
|
2009-10-10 11:54:04 -06:00
|
|
|
ADP5520_MODE_STATUS, ADP5520_DIM_EN);
|
2009-09-17 12:29:52 -06:00
|
|
|
else if (data->current_brightness == 0 && brightness)
|
|
|
|
ret |= adp5520_clr_bits(master,
|
2009-10-10 11:54:04 -06:00
|
|
|
ADP5520_MODE_STATUS, ADP5520_DIM_EN);
|
2009-09-17 12:29:52 -06:00
|
|
|
|
|
|
|
if (!ret)
|
|
|
|
data->current_brightness = brightness;
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int adp5520_bl_update_status(struct backlight_device *bl)
|
|
|
|
{
|
|
|
|
int brightness = bl->props.brightness;
|
|
|
|
if (bl->props.power != FB_BLANK_UNBLANK)
|
|
|
|
brightness = 0;
|
|
|
|
|
|
|
|
if (bl->props.fb_blank != FB_BLANK_UNBLANK)
|
|
|
|
brightness = 0;
|
|
|
|
|
|
|
|
return adp5520_bl_set(bl, brightness);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int adp5520_bl_get_brightness(struct backlight_device *bl)
|
|
|
|
{
|
|
|
|
struct adp5520_bl *data = bl_get_data(bl);
|
|
|
|
int error;
|
|
|
|
uint8_t reg_val;
|
|
|
|
|
2009-10-10 11:54:04 -06:00
|
|
|
error = adp5520_read(data->master, ADP5520_BL_VALUE, ®_val);
|
2009-09-17 12:29:52 -06:00
|
|
|
|
|
|
|
return error ? data->current_brightness : reg_val;
|
|
|
|
}
|
|
|
|
|
2009-12-13 16:58:57 -07:00
|
|
|
static const struct backlight_ops adp5520_bl_ops = {
|
2009-09-17 12:29:52 -06:00
|
|
|
.update_status = adp5520_bl_update_status,
|
|
|
|
.get_brightness = adp5520_bl_get_brightness,
|
|
|
|
};
|
|
|
|
|
|
|
|
static int adp5520_bl_setup(struct backlight_device *bl)
|
|
|
|
{
|
|
|
|
struct adp5520_bl *data = bl_get_data(bl);
|
|
|
|
struct device *master = data->master;
|
2009-10-10 11:54:04 -06:00
|
|
|
struct adp5520_backlight_platform_data *pdata = data->pdata;
|
2009-09-17 12:29:52 -06:00
|
|
|
int ret = 0;
|
|
|
|
|
2009-10-10 11:54:04 -06:00
|
|
|
ret |= adp5520_write(master, ADP5520_DAYLIGHT_MAX,
|
|
|
|
pdata->l1_daylight_max);
|
|
|
|
ret |= adp5520_write(master, ADP5520_DAYLIGHT_DIM,
|
|
|
|
pdata->l1_daylight_dim);
|
2009-09-17 12:29:52 -06:00
|
|
|
|
|
|
|
if (pdata->en_ambl_sens) {
|
|
|
|
data->cached_daylight_max = pdata->l1_daylight_max;
|
2009-10-10 11:54:04 -06:00
|
|
|
ret |= adp5520_write(master, ADP5520_OFFICE_MAX,
|
|
|
|
pdata->l2_office_max);
|
|
|
|
ret |= adp5520_write(master, ADP5520_OFFICE_DIM,
|
|
|
|
pdata->l2_office_dim);
|
|
|
|
ret |= adp5520_write(master, ADP5520_DARK_MAX,
|
|
|
|
pdata->l3_dark_max);
|
|
|
|
ret |= adp5520_write(master, ADP5520_DARK_DIM,
|
|
|
|
pdata->l3_dark_dim);
|
|
|
|
ret |= adp5520_write(master, ADP5520_L2_TRIP,
|
|
|
|
pdata->l2_trip);
|
|
|
|
ret |= adp5520_write(master, ADP5520_L2_HYS,
|
|
|
|
pdata->l2_hyst);
|
|
|
|
ret |= adp5520_write(master, ADP5520_L3_TRIP,
|
|
|
|
pdata->l3_trip);
|
|
|
|
ret |= adp5520_write(master, ADP5520_L3_HYS,
|
|
|
|
pdata->l3_hyst);
|
|
|
|
ret |= adp5520_write(master, ADP5520_ALS_CMPR_CFG,
|
|
|
|
ALS_CMPR_CFG_VAL(pdata->abml_filt,
|
|
|
|
ADP5520_L3_EN));
|
2009-09-17 12:29:52 -06:00
|
|
|
}
|
|
|
|
|
2009-10-10 11:54:04 -06:00
|
|
|
ret |= adp5520_write(master, ADP5520_BL_CONTROL,
|
|
|
|
BL_CTRL_VAL(pdata->fade_led_law,
|
|
|
|
pdata->en_ambl_sens));
|
2009-09-17 12:29:52 -06:00
|
|
|
|
2009-10-10 11:54:04 -06:00
|
|
|
ret |= adp5520_write(master, ADP5520_BL_FADE, FADE_VAL(pdata->fade_in,
|
2009-09-17 12:29:52 -06:00
|
|
|
pdata->fade_out));
|
|
|
|
|
2009-10-10 11:54:04 -06:00
|
|
|
ret |= adp5520_set_bits(master, ADP5520_MODE_STATUS,
|
|
|
|
ADP5520_BL_EN | ADP5520_DIM_EN);
|
2009-09-17 12:29:52 -06:00
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ssize_t adp5520_show(struct device *dev, char *buf, int reg)
|
|
|
|
{
|
|
|
|
struct adp5520_bl *data = dev_get_drvdata(dev);
|
2013-04-29 17:17:49 -06:00
|
|
|
int ret;
|
2009-09-17 12:29:52 -06:00
|
|
|
uint8_t reg_val;
|
|
|
|
|
|
|
|
mutex_lock(&data->lock);
|
2013-04-29 17:17:49 -06:00
|
|
|
ret = adp5520_read(data->master, reg, ®_val);
|
2009-09-17 12:29:52 -06:00
|
|
|
mutex_unlock(&data->lock);
|
|
|
|
|
2013-04-29 17:17:49 -06:00
|
|
|
if (ret < 0)
|
|
|
|
return ret;
|
|
|
|
|
2009-09-17 12:29:52 -06:00
|
|
|
return sprintf(buf, "%u\n", reg_val);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ssize_t adp5520_store(struct device *dev, const char *buf,
|
|
|
|
size_t count, int reg)
|
|
|
|
{
|
|
|
|
struct adp5520_bl *data = dev_get_drvdata(dev);
|
|
|
|
unsigned long val;
|
|
|
|
int ret;
|
|
|
|
|
2012-05-29 16:07:15 -06:00
|
|
|
ret = kstrtoul(buf, 10, &val);
|
2009-09-17 12:29:52 -06:00
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
mutex_lock(&data->lock);
|
|
|
|
adp5520_write(data->master, reg, val);
|
|
|
|
mutex_unlock(&data->lock);
|
|
|
|
|
|
|
|
return count;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ssize_t adp5520_bl_dark_max_show(struct device *dev,
|
2009-10-10 11:54:04 -06:00
|
|
|
struct device_attribute *attr, char *buf)
|
2009-09-17 12:29:52 -06:00
|
|
|
{
|
2009-10-10 11:54:04 -06:00
|
|
|
return adp5520_show(dev, buf, ADP5520_DARK_MAX);
|
2009-09-17 12:29:52 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
static ssize_t adp5520_bl_dark_max_store(struct device *dev,
|
2009-10-10 11:54:04 -06:00
|
|
|
struct device_attribute *attr,
|
|
|
|
const char *buf, size_t count)
|
2009-09-17 12:29:52 -06:00
|
|
|
{
|
2009-10-10 11:54:04 -06:00
|
|
|
return adp5520_store(dev, buf, count, ADP5520_DARK_MAX);
|
2009-09-17 12:29:52 -06:00
|
|
|
}
|
|
|
|
static DEVICE_ATTR(dark_max, 0664, adp5520_bl_dark_max_show,
|
|
|
|
adp5520_bl_dark_max_store);
|
|
|
|
|
|
|
|
static ssize_t adp5520_bl_office_max_show(struct device *dev,
|
2009-10-10 11:54:04 -06:00
|
|
|
struct device_attribute *attr, char *buf)
|
2009-09-17 12:29:52 -06:00
|
|
|
{
|
2009-10-10 11:54:04 -06:00
|
|
|
return adp5520_show(dev, buf, ADP5520_OFFICE_MAX);
|
2009-09-17 12:29:52 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
static ssize_t adp5520_bl_office_max_store(struct device *dev,
|
2009-10-10 11:54:04 -06:00
|
|
|
struct device_attribute *attr,
|
|
|
|
const char *buf, size_t count)
|
2009-09-17 12:29:52 -06:00
|
|
|
{
|
2009-10-10 11:54:04 -06:00
|
|
|
return adp5520_store(dev, buf, count, ADP5520_OFFICE_MAX);
|
2009-09-17 12:29:52 -06:00
|
|
|
}
|
|
|
|
static DEVICE_ATTR(office_max, 0664, adp5520_bl_office_max_show,
|
|
|
|
adp5520_bl_office_max_store);
|
|
|
|
|
|
|
|
static ssize_t adp5520_bl_daylight_max_show(struct device *dev,
|
|
|
|
struct device_attribute *attr, char *buf)
|
|
|
|
{
|
2009-10-10 11:54:04 -06:00
|
|
|
return adp5520_show(dev, buf, ADP5520_DAYLIGHT_MAX);
|
2009-09-17 12:29:52 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
static ssize_t adp5520_bl_daylight_max_store(struct device *dev,
|
2009-10-10 11:54:04 -06:00
|
|
|
struct device_attribute *attr,
|
|
|
|
const char *buf, size_t count)
|
2009-09-17 12:29:52 -06:00
|
|
|
{
|
|
|
|
struct adp5520_bl *data = dev_get_drvdata(dev);
|
2011-05-24 18:11:12 -06:00
|
|
|
int ret;
|
|
|
|
|
2012-05-29 16:07:15 -06:00
|
|
|
ret = kstrtoul(buf, 10, &data->cached_daylight_max);
|
2011-05-24 18:11:12 -06:00
|
|
|
if (ret < 0)
|
|
|
|
return ret;
|
2009-09-17 12:29:52 -06:00
|
|
|
|
2009-10-10 11:54:04 -06:00
|
|
|
return adp5520_store(dev, buf, count, ADP5520_DAYLIGHT_MAX);
|
2009-09-17 12:29:52 -06:00
|
|
|
}
|
|
|
|
static DEVICE_ATTR(daylight_max, 0664, adp5520_bl_daylight_max_show,
|
|
|
|
adp5520_bl_daylight_max_store);
|
|
|
|
|
|
|
|
static ssize_t adp5520_bl_dark_dim_show(struct device *dev,
|
|
|
|
struct device_attribute *attr, char *buf)
|
|
|
|
{
|
2009-10-10 11:54:04 -06:00
|
|
|
return adp5520_show(dev, buf, ADP5520_DARK_DIM);
|
2009-09-17 12:29:52 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
static ssize_t adp5520_bl_dark_dim_store(struct device *dev,
|
2009-10-10 11:54:04 -06:00
|
|
|
struct device_attribute *attr,
|
|
|
|
const char *buf, size_t count)
|
2009-09-17 12:29:52 -06:00
|
|
|
{
|
2009-10-10 11:54:04 -06:00
|
|
|
return adp5520_store(dev, buf, count, ADP5520_DARK_DIM);
|
2009-09-17 12:29:52 -06:00
|
|
|
}
|
|
|
|
static DEVICE_ATTR(dark_dim, 0664, adp5520_bl_dark_dim_show,
|
|
|
|
adp5520_bl_dark_dim_store);
|
|
|
|
|
|
|
|
static ssize_t adp5520_bl_office_dim_show(struct device *dev,
|
|
|
|
struct device_attribute *attr, char *buf)
|
|
|
|
{
|
2009-10-10 11:54:04 -06:00
|
|
|
return adp5520_show(dev, buf, ADP5520_OFFICE_DIM);
|
2009-09-17 12:29:52 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
static ssize_t adp5520_bl_office_dim_store(struct device *dev,
|
2009-10-10 11:54:04 -06:00
|
|
|
struct device_attribute *attr,
|
|
|
|
const char *buf, size_t count)
|
2009-09-17 12:29:52 -06:00
|
|
|
{
|
2009-10-10 11:54:04 -06:00
|
|
|
return adp5520_store(dev, buf, count, ADP5520_OFFICE_DIM);
|
2009-09-17 12:29:52 -06:00
|
|
|
}
|
|
|
|
static DEVICE_ATTR(office_dim, 0664, adp5520_bl_office_dim_show,
|
|
|
|
adp5520_bl_office_dim_store);
|
|
|
|
|
|
|
|
static ssize_t adp5520_bl_daylight_dim_show(struct device *dev,
|
2009-10-10 11:54:04 -06:00
|
|
|
struct device_attribute *attr, char *buf)
|
2009-09-17 12:29:52 -06:00
|
|
|
{
|
2009-10-10 11:54:04 -06:00
|
|
|
return adp5520_show(dev, buf, ADP5520_DAYLIGHT_DIM);
|
2009-09-17 12:29:52 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
static ssize_t adp5520_bl_daylight_dim_store(struct device *dev,
|
2009-10-10 11:54:04 -06:00
|
|
|
struct device_attribute *attr,
|
|
|
|
const char *buf, size_t count)
|
2009-09-17 12:29:52 -06:00
|
|
|
{
|
2009-10-10 11:54:04 -06:00
|
|
|
return adp5520_store(dev, buf, count, ADP5520_DAYLIGHT_DIM);
|
2009-09-17 12:29:52 -06:00
|
|
|
}
|
|
|
|
static DEVICE_ATTR(daylight_dim, 0664, adp5520_bl_daylight_dim_show,
|
|
|
|
adp5520_bl_daylight_dim_store);
|
|
|
|
|
|
|
|
static struct attribute *adp5520_bl_attributes[] = {
|
|
|
|
&dev_attr_dark_max.attr,
|
|
|
|
&dev_attr_dark_dim.attr,
|
|
|
|
&dev_attr_office_max.attr,
|
|
|
|
&dev_attr_office_dim.attr,
|
|
|
|
&dev_attr_daylight_max.attr,
|
|
|
|
&dev_attr_daylight_dim.attr,
|
|
|
|
NULL
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct attribute_group adp5520_bl_attr_group = {
|
|
|
|
.attrs = adp5520_bl_attributes,
|
|
|
|
};
|
|
|
|
|
2012-11-19 11:21:46 -07:00
|
|
|
static int adp5520_bl_probe(struct platform_device *pdev)
|
2009-09-17 12:29:52 -06:00
|
|
|
{
|
2010-02-17 14:39:44 -07:00
|
|
|
struct backlight_properties props;
|
2009-09-17 12:29:52 -06:00
|
|
|
struct backlight_device *bl;
|
|
|
|
struct adp5520_bl *data;
|
|
|
|
int ret = 0;
|
|
|
|
|
2012-03-23 16:02:01 -06:00
|
|
|
data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL);
|
2009-09-17 12:29:52 -06:00
|
|
|
if (data == NULL)
|
|
|
|
return -ENOMEM;
|
|
|
|
|
|
|
|
data->master = pdev->dev.parent;
|
|
|
|
data->pdata = pdev->dev.platform_data;
|
|
|
|
|
|
|
|
if (data->pdata == NULL) {
|
|
|
|
dev_err(&pdev->dev, "missing platform data\n");
|
|
|
|
return -ENODEV;
|
|
|
|
}
|
|
|
|
|
|
|
|
data->id = pdev->id;
|
|
|
|
data->current_brightness = 0;
|
|
|
|
|
|
|
|
mutex_init(&data->lock);
|
|
|
|
|
2010-02-17 14:39:44 -07:00
|
|
|
memset(&props, 0, sizeof(struct backlight_properties));
|
2011-03-22 17:30:21 -06:00
|
|
|
props.type = BACKLIGHT_RAW;
|
2010-02-17 14:39:44 -07:00
|
|
|
props.max_brightness = ADP5020_MAX_BRIGHTNESS;
|
|
|
|
bl = backlight_device_register(pdev->name, data->master, data,
|
|
|
|
&adp5520_bl_ops, &props);
|
2009-09-17 12:29:52 -06:00
|
|
|
if (IS_ERR(bl)) {
|
|
|
|
dev_err(&pdev->dev, "failed to register backlight\n");
|
|
|
|
return PTR_ERR(bl);
|
|
|
|
}
|
|
|
|
|
2010-02-17 14:39:44 -07:00
|
|
|
bl->props.brightness = ADP5020_MAX_BRIGHTNESS;
|
2009-09-17 12:29:52 -06:00
|
|
|
if (data->pdata->en_ambl_sens)
|
|
|
|
ret = sysfs_create_group(&bl->dev.kobj,
|
|
|
|
&adp5520_bl_attr_group);
|
|
|
|
|
|
|
|
if (ret) {
|
|
|
|
dev_err(&pdev->dev, "failed to register sysfs\n");
|
|
|
|
backlight_device_unregister(bl);
|
|
|
|
}
|
|
|
|
|
|
|
|
platform_set_drvdata(pdev, bl);
|
|
|
|
ret |= adp5520_bl_setup(bl);
|
|
|
|
backlight_update_status(bl);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2012-11-19 11:26:34 -07:00
|
|
|
static int adp5520_bl_remove(struct platform_device *pdev)
|
2009-09-17 12:29:52 -06:00
|
|
|
{
|
|
|
|
struct backlight_device *bl = platform_get_drvdata(pdev);
|
|
|
|
struct adp5520_bl *data = bl_get_data(bl);
|
|
|
|
|
2009-10-10 11:54:04 -06:00
|
|
|
adp5520_clr_bits(data->master, ADP5520_MODE_STATUS, ADP5520_BL_EN);
|
2009-09-17 12:29:52 -06:00
|
|
|
|
|
|
|
if (data->pdata->en_ambl_sens)
|
|
|
|
sysfs_remove_group(&bl->dev.kobj,
|
|
|
|
&adp5520_bl_attr_group);
|
|
|
|
|
|
|
|
backlight_device_unregister(bl);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2013-04-29 17:17:38 -06:00
|
|
|
#ifdef CONFIG_PM_SLEEP
|
|
|
|
static int adp5520_bl_suspend(struct device *dev)
|
2009-09-17 12:29:52 -06:00
|
|
|
{
|
2013-04-29 17:17:38 -06:00
|
|
|
struct backlight_device *bl = dev_get_drvdata(dev);
|
|
|
|
|
2009-09-17 12:29:52 -06:00
|
|
|
return adp5520_bl_set(bl, 0);
|
|
|
|
}
|
|
|
|
|
2013-04-29 17:17:38 -06:00
|
|
|
static int adp5520_bl_resume(struct device *dev)
|
2009-09-17 12:29:52 -06:00
|
|
|
{
|
2013-04-29 17:17:38 -06:00
|
|
|
struct backlight_device *bl = dev_get_drvdata(dev);
|
2009-09-17 12:29:52 -06:00
|
|
|
|
|
|
|
backlight_update_status(bl);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2013-04-29 17:17:38 -06:00
|
|
|
static SIMPLE_DEV_PM_OPS(adp5520_bl_pm_ops, adp5520_bl_suspend,
|
|
|
|
adp5520_bl_resume);
|
|
|
|
|
2009-09-17 12:29:52 -06:00
|
|
|
static struct platform_driver adp5520_bl_driver = {
|
|
|
|
.driver = {
|
|
|
|
.name = "adp5520-backlight",
|
|
|
|
.owner = THIS_MODULE,
|
2013-04-29 17:17:38 -06:00
|
|
|
.pm = &adp5520_bl_pm_ops,
|
2009-09-17 12:29:52 -06:00
|
|
|
},
|
|
|
|
.probe = adp5520_bl_probe,
|
2012-11-19 11:21:09 -07:00
|
|
|
.remove = adp5520_bl_remove,
|
2009-09-17 12:29:52 -06:00
|
|
|
};
|
|
|
|
|
2012-01-10 16:09:11 -07:00
|
|
|
module_platform_driver(adp5520_bl_driver);
|
2009-09-17 12:29:52 -06:00
|
|
|
|
|
|
|
MODULE_AUTHOR("Michael Hennerich <hennerich@blackfin.uclinux.org>");
|
|
|
|
MODULE_DESCRIPTION("ADP5520(01) Backlight Driver");
|
|
|
|
MODULE_LICENSE("GPL");
|
|
|
|
MODULE_ALIAS("platform:adp5520-backlight");
|