Skip to content

Commit 900bca3

Browse files
committed
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
2 parents 2fca5cc + d03ebb1 commit 900bca3

File tree

8 files changed

+942
-1
lines changed

8 files changed

+942
-1
lines changed

arch/arm/mach-pxa/include/mach/tosa.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,4 +193,7 @@
193193
#define TOSA_KEY_MAIL KEY_MAIL
194194
#endif
195195

196+
struct spi_device;
197+
extern int tosa_bl_enable(struct spi_device *spi, int enable);
198+
196199
#endif /* _ASM_ARCH_TOSA_H_ */

arch/arm/mach-pxa/tosa.c

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
#include <linux/gpio.h>
3232
#include <linux/pda_power.h>
3333
#include <linux/rfkill.h>
34+
#include <linux/spi/spi.h>
3435

3536
#include <asm/setup.h>
3637
#include <asm/mach-types.h>
@@ -42,6 +43,7 @@
4243
#include <mach/mmc.h>
4344
#include <mach/udc.h>
4445
#include <mach/tosa_bt.h>
46+
#include <mach/pxa2xx_spi.h>
4547

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

777+
static struct pxa2xx_spi_master pxa_ssp_master_info = {
778+
.num_chipselect = 1,
779+
};
780+
781+
static struct spi_board_info spi_board_info[] __initdata = {
782+
{
783+
.modalias = "tosa-lcd",
784+
// .platform_data
785+
.max_speed_hz = 28750,
786+
.bus_num = 2,
787+
.chip_select = 0,
788+
.mode = SPI_MODE_0,
789+
},
790+
};
775791

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

845+
pxa2xx_set_spi_info(2, &pxa_ssp_master_info);
846+
spi_register_board_info(spi_board_info, ARRAY_SIZE(spi_board_info));
847+
829848
clk_add_alias("CLK_CK3P6MI", &tc6393xb_device.dev, "GPIO11_CLK", NULL);
830849

831850
platform_add_devices(devices, ARRAY_SIZE(devices));

drivers/video/backlight/Kconfig

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,15 @@ config LCD_PLATFORM
7575
This driver provides a platform-device registered LCD power
7676
control interface.
7777

78+
config LCD_TOSA
79+
tristate "Sharp SL-6000 LCD Driver"
80+
depends on LCD_CLASS_DEVICE && SPI
81+
depends on MACH_TOSA
82+
default n
83+
help
84+
If you have an Sharp SL-6000 Zaurus say Y to enable a driver
85+
for its LCD.
86+
7887
#
7988
# Backlight
8089
#
@@ -171,6 +180,13 @@ config BACKLIGHT_PWM
171180
If you have a LCD backlight adjustable by PWM, say Y to enable
172181
this driver.
173182

183+
config BACKLIGHT_DA903X
184+
tristate "Backlight Driver for DA9030/DA9034 using WLED"
185+
depends on BACKLIGHT_CLASS_DEVICE && PMIC_DA903X
186+
help
187+
If you have a LCD backlight connected to the WLED output of DA9030
188+
or DA9034 WLED output, say Y here to enable this driver.
189+
174190
config BACKLIGHT_MBP_NVIDIA
175191
tristate "MacBook Pro Nvidia Backlight Driver"
176192
depends on BACKLIGHT_CLASS_DEVICE && X86
@@ -179,3 +195,19 @@ config BACKLIGHT_MBP_NVIDIA
179195
If you have an Apple Macbook Pro with Nvidia graphics hardware say Y
180196
to enable a driver for its backlight
181197

198+
config BACKLIGHT_TOSA
199+
tristate "Sharp SL-6000 Backlight Driver"
200+
depends on BACKLIGHT_CLASS_DEVICE && I2C
201+
depends on MACH_TOSA && LCD_TOSA
202+
default n
203+
help
204+
If you have an Sharp SL-6000 Zaurus say Y to enable a driver
205+
for its backlight
206+
207+
config BACKLIGHT_SAHARA
208+
tristate "Tabletkiosk Sahara Touch-iT Backlight Driver"
209+
depends on BACKLIGHT_CLASS_DEVICE && X86
210+
default n
211+
help
212+
If you have a Tabletkiosk Sahara Touch-iT, say y to enable the
213+
backlight driver.

drivers/video/backlight/Makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ obj-$(CONFIG_LCD_ILI9320) += ili9320.o
77
obj-$(CONFIG_LCD_PLATFORM) += platform_lcd.o
88
obj-$(CONFIG_LCD_VGG2432A4) += vgg2432a4.o
99
obj-$(CONFIG_LCD_TDO24M) += tdo24m.o
10+
obj-$(CONFIG_LCD_TOSA) += tosa_lcd.o
1011

1112
obj-$(CONFIG_BACKLIGHT_CLASS_DEVICE) += backlight.o
1213
obj-$(CONFIG_BACKLIGHT_ATMEL_PWM) += atmel-pwm-bl.o
@@ -17,5 +18,8 @@ obj-$(CONFIG_BACKLIGHT_OMAP1) += omap1_bl.o
1718
obj-$(CONFIG_BACKLIGHT_PROGEAR) += progear_bl.o
1819
obj-$(CONFIG_BACKLIGHT_CARILLO_RANCH) += cr_bllcd.o
1920
obj-$(CONFIG_BACKLIGHT_PWM) += pwm_bl.o
21+
obj-$(CONFIG_BACKLIGHT_DA903X) += da903x.o
2022
obj-$(CONFIG_BACKLIGHT_MBP_NVIDIA) += mbp_nvidia_bl.o
23+
obj-$(CONFIG_BACKLIGHT_TOSA) += tosa_bl.o
24+
obj-$(CONFIG_BACKLIGHT_SAHARA) += kb3886_bl.o
2125

drivers/video/backlight/da903x.c

Lines changed: 201 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,201 @@
1+
/*
2+
* Backlight driver for Dialog Semiconductor DA9030/DA9034
3+
*
4+
* Copyright (C) 2008 Compulab, Ltd.
5+
* Mike Rapoport <[email protected]>
6+
*
7+
* Copyright (C) 2006-2008 Marvell International Ltd.
8+
* Eric Miao <[email protected]>
9+
*
10+
* This program is free software; you can redistribute it and/or modify
11+
* it under the terms of the GNU General Public License version 2 as
12+
* published by the Free Software Foundation.
13+
*/
14+
15+
#include <linux/kernel.h>
16+
#include <linux/init.h>
17+
#include <linux/platform_device.h>
18+
#include <linux/fb.h>
19+
#include <linux/backlight.h>
20+
#include <linux/mfd/da903x.h>
21+
22+
#define DA9030_WLED_CONTROL 0x25
23+
#define DA9030_WLED_CP_EN (1 << 6)
24+
#define DA9030_WLED_TRIM(x) ((x) & 0x7)
25+
26+
#define DA9034_WLED_CONTROL1 0x3C
27+
#define DA9034_WLED_CONTROL2 0x3D
28+
29+
#define DA9034_WLED_BOOST_EN (1 << 5)
30+
31+
#define DA9030_MAX_BRIGHTNESS 7
32+
#define DA9034_MAX_BRIGHTNESS 0x7f
33+
34+
struct da903x_backlight_data {
35+
struct device *da903x_dev;
36+
int id;
37+
int current_brightness;
38+
};
39+
40+
static int da903x_backlight_set(struct backlight_device *bl, int brightness)
41+
{
42+
struct da903x_backlight_data *data = bl_get_data(bl);
43+
struct device *dev = data->da903x_dev;
44+
uint8_t val;
45+
int ret = 0;
46+
47+
switch (data->id) {
48+
case DA9034_ID_WLED:
49+
ret = da903x_update(dev, DA9034_WLED_CONTROL1,
50+
brightness, 0x7f);
51+
if (ret)
52+
return ret;
53+
54+
if (data->current_brightness && brightness == 0)
55+
ret = da903x_clr_bits(dev,
56+
DA9034_WLED_CONTROL2,
57+
DA9034_WLED_BOOST_EN);
58+
59+
if (data->current_brightness == 0 && brightness)
60+
ret = da903x_set_bits(dev,
61+
DA9034_WLED_CONTROL2,
62+
DA9034_WLED_BOOST_EN);
63+
break;
64+
case DA9030_ID_WLED:
65+
val = DA9030_WLED_TRIM(brightness);
66+
val |= brightness ? DA9030_WLED_CP_EN : 0;
67+
ret = da903x_write(dev, DA9030_WLED_CONTROL, val);
68+
break;
69+
}
70+
71+
if (ret)
72+
return ret;
73+
74+
data->current_brightness = brightness;
75+
return 0;
76+
}
77+
78+
static int da903x_backlight_update_status(struct backlight_device *bl)
79+
{
80+
int brightness = bl->props.brightness;
81+
82+
if (bl->props.power != FB_BLANK_UNBLANK)
83+
brightness = 0;
84+
85+
if (bl->props.fb_blank != FB_BLANK_UNBLANK)
86+
brightness = 0;
87+
88+
return da903x_backlight_set(bl, brightness);
89+
}
90+
91+
static int da903x_backlight_get_brightness(struct backlight_device *bl)
92+
{
93+
struct da903x_backlight_data *data = bl_get_data(bl);
94+
return data->current_brightness;
95+
}
96+
97+
static struct backlight_ops da903x_backlight_ops = {
98+
.update_status = da903x_backlight_update_status,
99+
.get_brightness = da903x_backlight_get_brightness,
100+
};
101+
102+
static int da903x_backlight_probe(struct platform_device *pdev)
103+
{
104+
struct da903x_backlight_data *data;
105+
struct backlight_device *bl;
106+
int max_brightness;
107+
108+
data = kzalloc(sizeof(*data), GFP_KERNEL);
109+
if (data == NULL)
110+
return -ENOMEM;
111+
112+
switch (pdev->id) {
113+
case DA9030_ID_WLED:
114+
max_brightness = DA9030_MAX_BRIGHTNESS;
115+
break;
116+
case DA9034_ID_WLED:
117+
max_brightness = DA9034_MAX_BRIGHTNESS;
118+
break;
119+
default:
120+
dev_err(&pdev->dev, "invalid backlight device ID(%d)\n",
121+
pdev->id);
122+
return -EINVAL;
123+
}
124+
125+
data->id = pdev->id;
126+
data->da903x_dev = pdev->dev.parent;
127+
data->current_brightness = 0;
128+
129+
bl = backlight_device_register(pdev->name, data->da903x_dev,
130+
data, &da903x_backlight_ops);
131+
if (IS_ERR(bl)) {
132+
dev_err(&pdev->dev, "failed to register backlight\n");
133+
return PTR_ERR(bl);
134+
}
135+
136+
bl->props.max_brightness = max_brightness;
137+
bl->props.brightness = max_brightness;
138+
139+
platform_set_drvdata(pdev, bl);
140+
backlight_update_status(bl);
141+
return 0;
142+
}
143+
144+
static int da903x_backlight_remove(struct platform_device *pdev)
145+
{
146+
struct backlight_device *bl = platform_get_drvdata(pdev);
147+
struct da903x_backlight_data *data = bl_get_data(bl);
148+
149+
backlight_device_unregister(bl);
150+
kfree(data);
151+
return 0;
152+
}
153+
154+
#ifdef CONFIG_PM
155+
static int da903x_backlight_suspend(struct platform_device *pdev,
156+
pm_message_t state)
157+
{
158+
struct backlight_device *bl = platform_get_drvdata(pdev);
159+
return da903x_backlight_set(bl, 0);
160+
}
161+
162+
static int da903x_backlight_resume(struct platform_device *pdev)
163+
{
164+
struct backlight_device *bl = platform_get_drvdata(pdev);
165+
166+
backlight_update_status(bl);
167+
return 0;
168+
}
169+
#else
170+
#define da903x_backlight_suspend NULL
171+
#define da903x_backlight_resume NULL
172+
#endif
173+
174+
static struct platform_driver da903x_backlight_driver = {
175+
.driver = {
176+
.name = "da903x-backlight",
177+
.owner = THIS_MODULE,
178+
},
179+
.probe = da903x_backlight_probe,
180+
.remove = da903x_backlight_remove,
181+
.suspend = da903x_backlight_suspend,
182+
.resume = da903x_backlight_resume,
183+
};
184+
185+
static int __init da903x_backlight_init(void)
186+
{
187+
return platform_driver_register(&da903x_backlight_driver);
188+
}
189+
module_init(da903x_backlight_init);
190+
191+
static void __exit da903x_backlight_exit(void)
192+
{
193+
platform_driver_unregister(&da903x_backlight_driver);
194+
}
195+
module_exit(da903x_backlight_exit);
196+
197+
MODULE_DESCRIPTION("Backlight Driver for Dialog Semiconductor DA9030/DA9034");
198+
MODULE_AUTHOR("Eric Miao <[email protected]>"
199+
"Mike Rapoport <[email protected]>");
200+
MODULE_LICENSE("GPL");
201+
MODULE_ALIAS("platform:da903x-backlight");

0 commit comments

Comments
 (0)