Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 900bca34 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: Add driver for Tabletkiosk Sahara TouchIT-213 Tablet PC
  backlight: da903x: Add backlight driver for DA9030/DA9034
  tosa: add support for bl/lcd driver
  backlight: add support for Sharp SL-6000 LCD and backlight drivers
parents 2fca5ccf d03ebb12
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -193,4 +193,7 @@
#define TOSA_KEY_MAIL		KEY_MAIL
#endif

struct spi_device;
extern int tosa_bl_enable(struct spi_device *spi, int enable);

#endif /* _ASM_ARCH_TOSA_H_ */
+20 −1
Original line number Diff line number Diff line
@@ -31,6 +31,7 @@
#include <linux/gpio.h>
#include <linux/pda_power.h>
#include <linux/rfkill.h>
#include <linux/spi/spi.h>

#include <asm/setup.h>
#include <asm/mach-types.h>
@@ -42,6 +43,7 @@
#include <mach/mmc.h>
#include <mach/udc.h>
#include <mach/tosa_bt.h>
#include <mach/pxa2xx_spi.h>

#include <asm/mach/arch.h>
#include <mach/tosa.h>
@@ -612,7 +614,7 @@ static int tosa_tc6393xb_enable(struct platform_device *dev)
	rc = gpio_request(TOSA_GPIO_TC6393XB_SUSPEND, "tc6393xb #suspend");
	if (rc)
		goto err_req_suspend;
	rc = gpio_request(TOSA_GPIO_TC6393XB_L3V_ON, "l3v");
	rc = gpio_request(TOSA_GPIO_TC6393XB_L3V_ON, "tc6393xb l3v");
	if (rc)
		goto err_req_l3v;
	rc = gpio_direction_output(TOSA_GPIO_TC6393XB_L3V_ON, 0);
@@ -772,6 +774,20 @@ static struct platform_device tosa_bt_device = {
	.dev.platform_data = &tosa_bt_data,
};

static struct pxa2xx_spi_master pxa_ssp_master_info = {
	.num_chipselect	= 1,
};

static struct spi_board_info spi_board_info[] __initdata = {
	{
		.modalias	= "tosa-lcd",
		// .platform_data
		.max_speed_hz	= 28750,
		.bus_num	= 2,
		.chip_select	= 0,
		.mode		= SPI_MODE_0,
	},
};

static struct platform_device *devices[] __initdata = {
	&tosascoop_device,
@@ -826,6 +842,9 @@ static void __init tosa_init(void)
	pxa_set_i2c_info(NULL);
	platform_scoop_config = &tosa_pcmcia_config;

	pxa2xx_set_spi_info(2, &pxa_ssp_master_info);
	spi_register_board_info(spi_board_info, ARRAY_SIZE(spi_board_info));

	clk_add_alias("CLK_CK3P6MI", &tc6393xb_device.dev, "GPIO11_CLK", NULL);

	platform_add_devices(devices, ARRAY_SIZE(devices));
+32 −0
Original line number Diff line number Diff line
@@ -75,6 +75,15 @@ config LCD_PLATFORM
	  This driver provides a platform-device registered LCD power
	  control interface.

config LCD_TOSA
	tristate "Sharp SL-6000 LCD Driver"
	depends on LCD_CLASS_DEVICE && SPI
	depends on MACH_TOSA
	default n
	help
	  If you have an Sharp SL-6000 Zaurus say Y to enable a driver
	  for its LCD.

#
# Backlight
#
@@ -171,6 +180,13 @@ config BACKLIGHT_PWM
	  If you have a LCD backlight adjustable by PWM, say Y to enable
	  this driver.

config BACKLIGHT_DA903X
	tristate "Backlight Driver for DA9030/DA9034 using WLED"
	depends on BACKLIGHT_CLASS_DEVICE && PMIC_DA903X
	help
	  If you have a LCD backlight connected to the WLED output of DA9030
	  or DA9034 WLED output, say Y here to enable this driver.

config BACKLIGHT_MBP_NVIDIA
       tristate "MacBook Pro Nvidia Backlight Driver"
       depends on BACKLIGHT_CLASS_DEVICE && X86
@@ -179,3 +195,19 @@ config BACKLIGHT_MBP_NVIDIA
         If you have an Apple Macbook Pro with Nvidia graphics hardware say Y
	 to enable a driver for its backlight

config BACKLIGHT_TOSA
	tristate "Sharp SL-6000 Backlight Driver"
	depends on BACKLIGHT_CLASS_DEVICE && I2C
	depends on MACH_TOSA && LCD_TOSA
	default n
	help
	  If you have an Sharp SL-6000 Zaurus say Y to enable a driver
	  for its backlight

config BACKLIGHT_SAHARA
	tristate "Tabletkiosk Sahara Touch-iT Backlight Driver"
	depends on BACKLIGHT_CLASS_DEVICE && X86
	default n
	help
	  If you have a Tabletkiosk Sahara Touch-iT, say y to enable the
	  backlight driver.
+4 −0
Original line number Diff line number Diff line
@@ -7,6 +7,7 @@ obj-$(CONFIG_LCD_ILI9320) += ili9320.o
obj-$(CONFIG_LCD_PLATFORM)	   += platform_lcd.o
obj-$(CONFIG_LCD_VGG2432A4)	   += vgg2432a4.o
obj-$(CONFIG_LCD_TDO24M)	   += tdo24m.o
obj-$(CONFIG_LCD_TOSA)		   += tosa_lcd.o

obj-$(CONFIG_BACKLIGHT_CLASS_DEVICE) += backlight.o
obj-$(CONFIG_BACKLIGHT_ATMEL_PWM)    += atmel-pwm-bl.o
@@ -17,5 +18,8 @@ obj-$(CONFIG_BACKLIGHT_OMAP1) += omap1_bl.o
obj-$(CONFIG_BACKLIGHT_PROGEAR) += progear_bl.o
obj-$(CONFIG_BACKLIGHT_CARILLO_RANCH) += cr_bllcd.o
obj-$(CONFIG_BACKLIGHT_PWM)	+= pwm_bl.o
obj-$(CONFIG_BACKLIGHT_DA903X)	+= da903x.o
obj-$(CONFIG_BACKLIGHT_MBP_NVIDIA) += mbp_nvidia_bl.o
obj-$(CONFIG_BACKLIGHT_TOSA)	+= tosa_bl.o
obj-$(CONFIG_BACKLIGHT_SAHARA)	+= kb3886_bl.o
+201 −0
Original line number Diff line number Diff line
/*
 * Backlight driver for Dialog Semiconductor DA9030/DA9034
 *
 * Copyright (C) 2008 Compulab, Ltd.
 * 	Mike Rapoport <mike@compulab.co.il>
 *
 * Copyright (C) 2006-2008 Marvell International Ltd.
 * 	Eric Miao <eric.miao@marvell.com>
 *
 * 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.
 */

#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/platform_device.h>
#include <linux/fb.h>
#include <linux/backlight.h>
#include <linux/mfd/da903x.h>

#define DA9030_WLED_CONTROL	0x25
#define DA9030_WLED_CP_EN	(1 << 6)
#define DA9030_WLED_TRIM(x)	((x) & 0x7)

#define DA9034_WLED_CONTROL1	0x3C
#define DA9034_WLED_CONTROL2	0x3D

#define DA9034_WLED_BOOST_EN	(1 << 5)

#define DA9030_MAX_BRIGHTNESS	7
#define DA9034_MAX_BRIGHTNESS	0x7f

struct da903x_backlight_data {
	struct device *da903x_dev;
	int id;
	int current_brightness;
};

static int da903x_backlight_set(struct backlight_device *bl, int brightness)
{
	struct da903x_backlight_data *data = bl_get_data(bl);
	struct device *dev = data->da903x_dev;
	uint8_t val;
	int ret = 0;

	switch (data->id) {
	case DA9034_ID_WLED:
		ret = da903x_update(dev, DA9034_WLED_CONTROL1,
				brightness, 0x7f);
		if (ret)
			return ret;

		if (data->current_brightness && brightness == 0)
			ret = da903x_clr_bits(dev,
					DA9034_WLED_CONTROL2,
					DA9034_WLED_BOOST_EN);

		if (data->current_brightness == 0 && brightness)
			ret = da903x_set_bits(dev,
					DA9034_WLED_CONTROL2,
					DA9034_WLED_BOOST_EN);
		break;
	case DA9030_ID_WLED:
		val = DA9030_WLED_TRIM(brightness);
		val |= brightness ? DA9030_WLED_CP_EN : 0;
		ret = da903x_write(dev, DA9030_WLED_CONTROL, val);
		break;
	}

	if (ret)
		return ret;

	data->current_brightness = brightness;
	return 0;
}

static int da903x_backlight_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 da903x_backlight_set(bl, brightness);
}

static int da903x_backlight_get_brightness(struct backlight_device *bl)
{
	struct da903x_backlight_data *data = bl_get_data(bl);
	return data->current_brightness;
}

static struct backlight_ops da903x_backlight_ops = {
	.update_status	= da903x_backlight_update_status,
	.get_brightness	= da903x_backlight_get_brightness,
};

static int da903x_backlight_probe(struct platform_device *pdev)
{
	struct da903x_backlight_data *data;
	struct backlight_device *bl;
	int max_brightness;

	data = kzalloc(sizeof(*data), GFP_KERNEL);
	if (data == NULL)
		return -ENOMEM;

	switch (pdev->id) {
	case DA9030_ID_WLED:
		max_brightness = DA9030_MAX_BRIGHTNESS;
		break;
	case DA9034_ID_WLED:
		max_brightness = DA9034_MAX_BRIGHTNESS;
		break;
	default:
		dev_err(&pdev->dev, "invalid backlight device ID(%d)\n",
				pdev->id);
		return -EINVAL;
	}

	data->id = pdev->id;
	data->da903x_dev = pdev->dev.parent;
	data->current_brightness = 0;

	bl = backlight_device_register(pdev->name, data->da903x_dev,
			data, &da903x_backlight_ops);
	if (IS_ERR(bl)) {
		dev_err(&pdev->dev, "failed to register backlight\n");
		return PTR_ERR(bl);
	}

	bl->props.max_brightness = max_brightness;
	bl->props.brightness = max_brightness;

	platform_set_drvdata(pdev, bl);
	backlight_update_status(bl);
	return 0;
}

static int da903x_backlight_remove(struct platform_device *pdev)
{
	struct backlight_device *bl = platform_get_drvdata(pdev);
	struct da903x_backlight_data *data = bl_get_data(bl);

	backlight_device_unregister(bl);
	kfree(data);
	return 0;
}

#ifdef CONFIG_PM
static int da903x_backlight_suspend(struct platform_device *pdev,
				 pm_message_t state)
{
	struct backlight_device *bl = platform_get_drvdata(pdev);
	return da903x_backlight_set(bl, 0);
}

static int da903x_backlight_resume(struct platform_device *pdev)
{
	struct backlight_device *bl = platform_get_drvdata(pdev);

	backlight_update_status(bl);
	return 0;
}
#else
#define da903x_backlight_suspend	NULL
#define da903x_backlight_resume		NULL
#endif

static struct platform_driver da903x_backlight_driver = {
	.driver		= {
		.name	= "da903x-backlight",
		.owner	= THIS_MODULE,
	},
	.probe		= da903x_backlight_probe,
	.remove		= da903x_backlight_remove,
	.suspend	= da903x_backlight_suspend,
	.resume		= da903x_backlight_resume,
};

static int __init da903x_backlight_init(void)
{
	return platform_driver_register(&da903x_backlight_driver);
}
module_init(da903x_backlight_init);

static void __exit da903x_backlight_exit(void)
{
	platform_driver_unregister(&da903x_backlight_driver);
}
module_exit(da903x_backlight_exit);

MODULE_DESCRIPTION("Backlight Driver for Dialog Semiconductor DA9030/DA9034");
MODULE_AUTHOR("Eric Miao <eric.miao@marvell.com>"
	      "Mike Rapoport <mike@compulab.co.il>");
MODULE_LICENSE("GPL");
MODULE_ALIAS("platform:da903x-backlight");
Loading