Commit d910fc78 authored by Linus Torvalds's avatar Linus Torvalds
Browse files

Merge branch 'for-linus' of git://git.o-hand.com/linux-rpurdie-backlight

* 'for-linus' of git://git.o-hand.com/linux-rpurdie-backlight:
  backlight: new driver for ADP5520/ADP5501 MFD PMICs
  backlight: extend event support to also support poll()
  backlight/eeepc-laptop: Update the backlight state when we change brightness
  backlight/acpi: Update the backlight state when we change brightness
  backlight: Allow drivers to update the core, and generate events on changes
  backlight: switch to da903x driver to dev_pm_ops
  backlight: Add support for the Avionic Design Xanthos backlight device.
  backlight: spi driver for LMS283GF05 LCD
  backlight: move hp680-bl's probe function to .devinit.text
  backlight: Add support for new Apple machines.
  backlight: mbp_nvidia_bl: add support for MacBookAir 1,1
  backlight: Add WM831x backlight driver

Trivial conflicts due to '#ifdef CONFIG_PM' differences in
drivers/video/backlight/da903x_bl.c
parents 1d1764c3 a7998cec
......@@ -1986,6 +1986,10 @@ acpi_video_switch_brightness(struct acpi_video_device *device, int event)
result = acpi_video_device_lcd_set_level(device, level_next);
if (!result)
backlight_force_update(device->backlight,
BACKLIGHT_UPDATE_HOTKEY);
out:
if (result)
printk(KERN_ERR PREFIX "Failed to switch the brightness\n");
......
......@@ -624,7 +624,7 @@ static int notify_brn(void)
struct backlight_device *bd = eeepc_backlight_device;
if (bd) {
int old = bd->props.brightness;
bd->props.brightness = read_brightness(bd);
backlight_force_update(bd, BACKLIGHT_UPDATE_HOTKEY);
return old;
}
return -1;
......
......@@ -31,6 +31,13 @@ config LCD_CORGI
Say y here to support the LCD panels usually found on SHARP
corgi (C7x0) and spitz (Cxx00) models.
config LCD_LMS283GF05
tristate "Samsung LMS283GF05 LCD"
depends on LCD_CLASS_DEVICE && SPI_MASTER && GENERIC_GPIO
help
SPI driver for Samsung LMS283GF05. This provides basic support
for powering the LCD up/down through a sysfs interface.
config LCD_LTV350QV
tristate "Samsung LTV350QV LCD Panel"
depends on LCD_CLASS_DEVICE && SPI_MASTER
......@@ -229,3 +236,29 @@ config BACKLIGHT_SAHARA
help
If you have a Tabletkiosk Sahara Touch-iT, say y to enable the
backlight driver.
config BACKLIGHT_WM831X
tristate "WM831x PMIC Backlight Driver"
depends on BACKLIGHT_CLASS_DEVICE && MFD_WM831X
help
If you have a backlight driven by the ISINK and DCDC of a
WM831x PMIC say y to enable the backlight driver for it.
config BACKLIGHT_ADX
tristate "Avionic Design Xanthos Backlight Driver"
depends on BACKLIGHT_CLASS_DEVICE && ARCH_PXA_ADX
default y
help
Say Y to enable the backlight driver on Avionic Design Xanthos-based
boards.
config BACKLIGHT_ADP5520
tristate "Backlight Driver for ADP5520/ADP5501 using WLED"
depends on BACKLIGHT_CLASS_DEVICE && PMIC_ADP5520
help
If you have a LCD backlight connected to the BST/BL_SNK output of
ADP5520 or ADP5501, say Y here to enable this driver.
To compile this driver as a module, choose M here: the module will
be called adp5520_bl.
......@@ -3,6 +3,7 @@
obj-$(CONFIG_LCD_CLASS_DEVICE) += lcd.o
obj-$(CONFIG_LCD_CORGI) += corgi_lcd.o
obj-$(CONFIG_LCD_HP700) += jornada720_lcd.o
obj-$(CONFIG_LCD_LMS283GF05) += lms283gf05.o
obj-$(CONFIG_LCD_LTV350QV) += ltv350qv.o
obj-$(CONFIG_LCD_ILI9320) += ili9320.o
obj-$(CONFIG_LCD_PLATFORM) += platform_lcd.o
......@@ -24,4 +25,7 @@ obj-$(CONFIG_BACKLIGHT_DA903X) += da903x_bl.o
obj-$(CONFIG_BACKLIGHT_MBP_NVIDIA) += mbp_nvidia_bl.o
obj-$(CONFIG_BACKLIGHT_TOSA) += tosa_bl.o
obj-$(CONFIG_BACKLIGHT_SAHARA) += kb3886_bl.o
obj-$(CONFIG_BACKLIGHT_WM831X) += wm831x_bl.o
obj-$(CONFIG_BACKLIGHT_ADX) += adx_bl.o
obj-$(CONFIG_BACKLIGHT_ADP5520) += adp5520_bl.o
/*
* 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>
struct adp5520_bl {
struct device *master;
struct adp5520_backlight_platfrom_data *pdata;
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 */
ret |= adp5520_clr_bits(master, BL_CONTROL,
BL_AUTO_ADJ);
ret |= adp5520_write(master, DAYLIGHT_MAX, brightness);
} else {
/*
* MAX_BRIGHTNESS -> Enable Ambient Light auto adjust
* restore daylight l3 sysfs brightness
*/
ret |= adp5520_write(master, DAYLIGHT_MAX,
data->cached_daylight_max);
ret |= adp5520_set_bits(master, BL_CONTROL,
BL_AUTO_ADJ);
}
} else {
ret |= adp5520_write(master, DAYLIGHT_MAX, brightness);
}
if (data->current_brightness && brightness == 0)
ret |= adp5520_set_bits(master,
MODE_STATUS, DIM_EN);
else if (data->current_brightness == 0 && brightness)
ret |= adp5520_clr_bits(master,
MODE_STATUS, DIM_EN);
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;
error = adp5520_read(data->master, BL_VALUE, &reg_val);
return error ? data->current_brightness : reg_val;
}
static struct backlight_ops adp5520_bl_ops = {
.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;
struct adp5520_backlight_platfrom_data *pdata = data->pdata;
int ret = 0;
ret |= adp5520_write(master, DAYLIGHT_MAX, pdata->l1_daylight_max);
ret |= adp5520_write(master, DAYLIGHT_DIM, pdata->l1_daylight_dim);
if (pdata->en_ambl_sens) {
data->cached_daylight_max = pdata->l1_daylight_max;
ret |= adp5520_write(master, OFFICE_MAX, pdata->l2_office_max);
ret |= adp5520_write(master, OFFICE_DIM, pdata->l2_office_dim);
ret |= adp5520_write(master, DARK_MAX, pdata->l3_dark_max);
ret |= adp5520_write(master, DARK_DIM, pdata->l3_dark_dim);
ret |= adp5520_write(master, L2_TRIP, pdata->l2_trip);
ret |= adp5520_write(master, L2_HYS, pdata->l2_hyst);
ret |= adp5520_write(master, L3_TRIP, pdata->l3_trip);
ret |= adp5520_write(master, L3_HYS, pdata->l3_hyst);
ret |= adp5520_write(master, ALS_CMPR_CFG,
ALS_CMPR_CFG_VAL(pdata->abml_filt, L3_EN));
}
ret |= adp5520_write(master, BL_CONTROL,
BL_CTRL_VAL(pdata->fade_led_law, pdata->en_ambl_sens));
ret |= adp5520_write(master, BL_FADE, FADE_VAL(pdata->fade_in,
pdata->fade_out));
ret |= adp5520_set_bits(master, MODE_STATUS, BL_EN | DIM_EN);
return ret;
}
static ssize_t adp5520_show(struct device *dev, char *buf, int reg)
{
struct adp5520_bl *data = dev_get_drvdata(dev);
int error;
uint8_t reg_val;
mutex_lock(&data->lock);
error = adp5520_read(data->master, reg, &reg_val);
mutex_unlock(&data->lock);
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;
ret = strict_strtoul(buf, 10, &val);
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,
struct device_attribute *attr, char *buf)
{
return adp5520_show(dev, buf, DARK_MAX);
}
static ssize_t adp5520_bl_dark_max_store(struct device *dev,
struct device_attribute *attr, const char *buf, size_t count)
{
return adp5520_store(dev, buf, count, DARK_MAX);
}
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,
struct device_attribute *attr, char *buf)
{
return adp5520_show(dev, buf, OFFICE_MAX);
}
static ssize_t adp5520_bl_office_max_store(struct device *dev,
struct device_attribute *attr, const char *buf, size_t count)
{
return adp5520_store(dev, buf, count, OFFICE_MAX);
}
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)
{
return adp5520_show(dev, buf, DAYLIGHT_MAX);
}
static ssize_t adp5520_bl_daylight_max_store(struct device *dev,
struct device_attribute *attr, const char *buf, size_t count)
{
struct adp5520_bl *data = dev_get_drvdata(dev);
strict_strtoul(buf, 10, &data->cached_daylight_max);
return adp5520_store(dev, buf, count, DAYLIGHT_MAX);
}
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)
{
return adp5520_show(dev, buf, DARK_DIM);
}
static ssize_t adp5520_bl_dark_dim_store(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t count)
{
return adp5520_store(dev, buf, count, DARK_DIM);
}
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)
{
return adp5520_show(dev, buf, OFFICE_DIM);
}
static ssize_t adp5520_bl_office_dim_store(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t count)
{
return adp5520_store(dev, buf, count, OFFICE_DIM);
}
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,
struct device_attribute *attr, char *buf)
{
return adp5520_show(dev, buf, DAYLIGHT_DIM);
}
static ssize_t adp5520_bl_daylight_dim_store(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t count)
{
return adp5520_store(dev, buf, count, DAYLIGHT_DIM);
}
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,
};
static int __devinit adp5520_bl_probe(struct platform_device *pdev)
{
struct backlight_device *bl;
struct adp5520_bl *data;
int ret = 0;
data = kzalloc(sizeof(*data), GFP_KERNEL);
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");
kfree(data);
return -ENODEV;
}
data->id = pdev->id;
data->current_brightness = 0;
mutex_init(&data->lock);
bl = backlight_device_register(pdev->name, data->master,
data, &adp5520_bl_ops);
if (IS_ERR(bl)) {
dev_err(&pdev->dev, "failed to register backlight\n");
kfree(data);
return PTR_ERR(bl);
}
bl->props.max_brightness =
bl->props.brightness = ADP5020_MAX_BRIGHTNESS;
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);
kfree(data);
}
platform_set_drvdata(pdev, bl);
ret |= adp5520_bl_setup(bl);
backlight_update_status(bl);
return ret;
}
static int __devexit adp5520_bl_remove(struct platform_device *pdev)
{
struct backlight_device *bl = platform_get_drvdata(pdev);
struct adp5520_bl *data = bl_get_data(bl);
adp5520_clr_bits(data->master, MODE_STATUS, BL_EN);
if (data->pdata->en_ambl_sens)
sysfs_remove_group(&bl->dev.kobj,
&adp5520_bl_attr_group);
backlight_device_unregister(bl);
kfree(data);
return 0;
}
#ifdef CONFIG_PM
static int adp5520_bl_suspend(struct platform_device *pdev,
pm_message_t state)
{
struct backlight_device *bl = platform_get_drvdata(pdev);
return adp5520_bl_set(bl, 0);
}
static int adp5520_bl_resume(struct platform_device *pdev)
{
struct backlight_device *bl = platform_get_drvdata(pdev);
backlight_update_status(bl);
return 0;
}
#else
#define adp5520_bl_suspend NULL
#define adp5520_bl_resume NULL
#endif
static struct platform_driver adp5520_bl_driver = {
.driver = {
.name = "adp5520-backlight",
.owner = THIS_MODULE,
},
.probe = adp5520_bl_probe,
.remove = __devexit_p(adp5520_bl_remove),
.suspend = adp5520_bl_suspend,
.resume = adp5520_bl_resume,
};
static int __init adp5520_bl_init(void)
{
return platform_driver_register(&adp5520_bl_driver);
}
module_init(adp5520_bl_init);
static void __exit adp5520_bl_exit(void)
{
platform_driver_unregister(&adp5520_bl_driver);
}
module_exit(adp5520_bl_exit);
MODULE_AUTHOR("Michael Hennerich <hennerich@blackfin.uclinux.org>");
MODULE_DESCRIPTION("ADP5520(01) Backlight Driver");
MODULE_LICENSE("GPL");
MODULE_ALIAS("platform:adp5520-backlight");
/*
* linux/drivers/video/backlight/adx.c
*
* Copyright (C) 2009 Avionic Design GmbH
*
* 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.
*
* Written by Thierry Reding <thierry.reding@avionic-design.de>
*/
#include <linux/backlight.h>
#include <linux/fb.h>
#include <linux/io.h>
#include <linux/module.h>
#include <linux/platform_device.h>
/* register definitions */
#define ADX_BACKLIGHT_CONTROL 0x00
#define ADX_BACKLIGHT_CONTROL_ENABLE (1 << 0)
#define ADX_BACKLIGHT_BRIGHTNESS 0x08
#define ADX_BACKLIGHT_STATUS 0x10
#define ADX_BACKLIGHT_ERROR 0x18
struct adxbl {
void __iomem *base;
};
static int adx_backlight_update_status(struct backlight_device *bldev)
{
struct adxbl *bl = bl_get_data(bldev);
u32 value;
value = bldev->props.brightness;
writel(value, bl->base + ADX_BACKLIGHT_BRIGHTNESS);
value = readl(bl->base + ADX_BACKLIGHT_CONTROL);
if (bldev->props.state & BL_CORE_FBBLANK)
value &= ~ADX_BACKLIGHT_CONTROL_ENABLE;
else
value |= ADX_BACKLIGHT_CONTROL_ENABLE;
writel(value, bl->base + ADX_BACKLIGHT_CONTROL);
return 0;
}
static int adx_backlight_get_brightness(struct backlight_device *bldev)
{
struct adxbl *bl = bl_get_data(bldev);
u32 brightness;
brightness = readl(bl->base + ADX_BACKLIGHT_BRIGHTNESS);
return brightness & 0xff;
}
static int adx_backlight_check_fb(struct fb_info *fb)
{
return 1;
}
static struct backlight_ops adx_backlight_ops = {
.options = 0,
.update_status = adx_backlight_update_status,
.get_brightness = adx_backlight_get_brightness,
.check_fb = adx_backlight_check_fb,
};
static int __devinit adx_backlight_probe(struct platform_device *pdev)
{
struct backlight_device *bldev;
struct resource *res;
struct adxbl *bl;
int ret = 0;
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
if (!res) {
ret = -ENXIO;
goto out;
}
res = devm_request_mem_region(&pdev->dev, res->start,
resource_size(res), res->name);
if (!res) {
ret = -ENXIO;
goto out;
}
bl = devm_kzalloc(&pdev->dev, sizeof(*bl), GFP_KERNEL);
if (!bl) {
ret = -ENOMEM;
goto out;
}
bl->base = devm_ioremap_nocache(&pdev->dev, res->start,
resource_size(res));
if (!bl->base) {
ret = -ENXIO;
goto out;
}
bldev = backlight_device_register(dev_name(&pdev->dev), &pdev->dev, bl,
&adx_backlight_ops);
if (!bldev) {
ret = -ENOMEM;
goto out;
}
bldev->props.max_brightness = 0xff;
bldev->props.brightness = 0xff;
bldev->props.power = FB_BLANK_UNBLANK;
platform_set_drvdata(pdev, bldev);
out:
return ret;
}
static int __devexit adx_backlight_remove(struct platform_device *pdev)
{
struct backlight_device *bldev;
int ret = 0;
bldev = platform_get_drvdata(pdev);
bldev->props.power = FB_BLANK_UNBLANK;
bldev->props.brightness = 0xff;
backlight_update_status(bldev);
backlight_device_unregister(bldev);
platform_set_drvdata(pdev, NULL);
return ret;
}
#ifdef CONFIG_PM
static int adx_backlight_suspend(struct platform_device *pdev,
pm_message_t state)
{
return 0;
}
static int adx_backlight_resume(struct platform_device *pdev)
{
return 0;
}
#else
#define adx_backlight_suspend NULL
#define adx_backlight_resume NULL
#endif