aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/video/backlight
diff options
context:
space:
mode:
authorClaudio Nieder <private@claudio.ch>2008-10-20 18:35:40 -0400
committerRichard Purdie <rpurdie@linux.intel.com>2008-10-20 19:19:49 -0400
commitd03ebb12981e80de99e9b482639ec3b5795741f3 (patch)
tree60232ad1b7d50992146a33e0205902f52a16cf29 /drivers/video/backlight
parent923ae48b5a92591c844ebdb21276b56093f4e5da (diff)
backlight: Add driver for Tabletkiosk Sahara TouchIT-213 Tablet PC
[akpm@linux-foundation.org: coding-style fixes] [rpurdie@linux.intel.com: minor tweaks] Signed-off-by: Claudio Nieder <private@claudio.ch> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Richard Purdie <rpurdie@linux.intel.com>
Diffstat (limited to 'drivers/video/backlight')
-rw-r--r--drivers/video/backlight/Kconfig7
-rw-r--r--drivers/video/backlight/Makefile2
-rw-r--r--drivers/video/backlight/kb3886_bl.c204
3 files changed, 212 insertions, 1 deletions
diff --git a/drivers/video/backlight/Kconfig b/drivers/video/backlight/Kconfig
index 5ff97250aa12..51c94a5971b4 100644
--- a/drivers/video/backlight/Kconfig
+++ b/drivers/video/backlight/Kconfig
@@ -204,3 +204,10 @@ config BACKLIGHT_TOSA
204 If you have an Sharp SL-6000 Zaurus say Y to enable a driver 204 If you have an Sharp SL-6000 Zaurus say Y to enable a driver
205 for its backlight 205 for its backlight
206 206
207config 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.
diff --git a/drivers/video/backlight/Makefile b/drivers/video/backlight/Makefile
index 9c818231f1fb..103427de6703 100644
--- a/drivers/video/backlight/Makefile
+++ b/drivers/video/backlight/Makefile
@@ -21,5 +21,5 @@ obj-$(CONFIG_BACKLIGHT_PWM) += pwm_bl.o
21obj-$(CONFIG_BACKLIGHT_DA903X) += da903x.o 21obj-$(CONFIG_BACKLIGHT_DA903X) += da903x.o
22obj-$(CONFIG_BACKLIGHT_MBP_NVIDIA) += mbp_nvidia_bl.o 22obj-$(CONFIG_BACKLIGHT_MBP_NVIDIA) += mbp_nvidia_bl.o
23obj-$(CONFIG_BACKLIGHT_TOSA) += tosa_bl.o 23obj-$(CONFIG_BACKLIGHT_TOSA) += tosa_bl.o
24 24obj-$(CONFIG_BACKLIGHT_SAHARA) += kb3886_bl.o
25 25
diff --git a/drivers/video/backlight/kb3886_bl.c b/drivers/video/backlight/kb3886_bl.c
new file mode 100644
index 000000000000..a38fda1742dd
--- /dev/null
+++ b/drivers/video/backlight/kb3886_bl.c
@@ -0,0 +1,204 @@
1/*
2 * Backlight Driver for the KB3886 Backlight
3 *
4 * Copyright (c) 2007-2008 Claudio Nieder
5 *
6 * Based on corgi_bl.c by Richard Purdie and kb3886 driver by Robert Woerle
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
11 *
12 */
13
14#include <linux/module.h>
15#include <linux/kernel.h>
16#include <linux/init.h>
17#include <linux/platform_device.h>
18#include <linux/mutex.h>
19#include <linux/fb.h>
20#include <linux/backlight.h>
21#include <linux/delay.h>
22#include <linux/dmi.h>
23
24#define KB3886_PARENT 0x64
25#define KB3886_IO 0x60
26#define KB3886_ADC_DAC_PWM 0xC4
27#define KB3886_PWM0_WRITE 0x81
28#define KB3886_PWM0_READ 0x41
29
30static DEFINE_MUTEX(bl_mutex);
31
32static void kb3886_bl_set_intensity(int intensity)
33{
34 mutex_lock(&bl_mutex);
35 intensity = intensity&0xff;
36 outb(KB3886_ADC_DAC_PWM, KB3886_PARENT);
37 msleep(10);
38 outb(KB3886_PWM0_WRITE, KB3886_IO);
39 msleep(10);
40 outb(intensity, KB3886_IO);
41 mutex_unlock(&bl_mutex);
42}
43
44struct kb3886bl_machinfo {
45 int max_intensity;
46 int default_intensity;
47 int limit_mask;
48 void (*set_bl_intensity)(int intensity);
49};
50
51static struct kb3886bl_machinfo kb3886_bl_machinfo = {
52 .max_intensity = 0xff,
53 .default_intensity = 0xa0,
54 .limit_mask = 0x7f,
55 .set_bl_intensity = kb3886_bl_set_intensity,
56};
57
58static struct platform_device kb3886bl_device = {
59 .name = "kb3886-bl",
60 .dev = {
61 .platform_data = &kb3886_bl_machinfo,
62 },
63 .id = -1,
64};
65
66static struct platform_device *devices[] __initdata = {
67 &kb3886bl_device,
68};
69
70/*
71 * Back to driver
72 */
73
74static int kb3886bl_intensity;
75static struct backlight_device *kb3886_backlight_device;
76static struct kb3886bl_machinfo *bl_machinfo;
77
78static unsigned long kb3886bl_flags;
79#define KB3886BL_SUSPENDED 0x01
80
81static struct dmi_system_id __initdata kb3886bl_device_table[] = {
82 {
83 .ident = "Sahara Touch-iT",
84 .matches = {
85 DMI_MATCH(DMI_SYS_VENDOR, "SDV"),
86 DMI_MATCH(DMI_PRODUCT_NAME, "iTouch T201"),
87 },
88 },
89 { }
90};
91
92static int kb3886bl_send_intensity(struct backlight_device *bd)
93{
94 int intensity = bd->props.brightness;
95
96 if (bd->props.power != FB_BLANK_UNBLANK)
97 intensity = 0;
98 if (bd->props.fb_blank != FB_BLANK_UNBLANK)
99 intensity = 0;
100 if (kb3886bl_flags & KB3886BL_SUSPENDED)
101 intensity = 0;
102
103 bl_machinfo->set_bl_intensity(intensity);
104
105 kb3886bl_intensity = intensity;
106 return 0;
107}
108
109#ifdef CONFIG_PM
110static int kb3886bl_suspend(struct platform_device *pdev, pm_message_t state)
111{
112 struct backlight_device *bd = platform_get_drvdata(pdev);
113
114 kb3886bl_flags |= KB3886BL_SUSPENDED;
115 backlight_update_status(bd);
116 return 0;
117}
118
119static int kb3886bl_resume(struct platform_device *pdev)
120{
121 struct backlight_device *bd = platform_get_drvdata(pdev);
122
123 kb3886bl_flags &= ~KB3886BL_SUSPENDED;
124 backlight_update_status(bd);
125 return 0;
126}
127#else
128#define kb3886bl_suspend NULL
129#define kb3886bl_resume NULL
130#endif
131
132static int kb3886bl_get_intensity(struct backlight_device *bd)
133{
134 return kb3886bl_intensity;
135}
136
137static struct backlight_ops kb3886bl_ops = {
138 .get_brightness = kb3886bl_get_intensity,
139 .update_status = kb3886bl_send_intensity,
140};
141
142static int kb3886bl_probe(struct platform_device *pdev)
143{
144 struct kb3886bl_machinfo *machinfo = pdev->dev.platform_data;
145
146 bl_machinfo = machinfo;
147 if (!machinfo->limit_mask)
148 machinfo->limit_mask = -1;
149
150 kb3886_backlight_device = backlight_device_register("kb3886-bl",
151 &pdev->dev, NULL, &kb3886bl_ops);
152 if (IS_ERR(kb3886_backlight_device))
153 return PTR_ERR(kb3886_backlight_device);
154
155 platform_set_drvdata(pdev, kb3886_backlight_device);
156
157 kb3886_backlight_device->props.max_brightness = machinfo->max_intensity;
158 kb3886_backlight_device->props.power = FB_BLANK_UNBLANK;
159 kb3886_backlight_device->props.brightness = machinfo->default_intensity;
160 backlight_update_status(kb3886_backlight_device);
161
162 return 0;
163}
164
165static int kb3886bl_remove(struct platform_device *pdev)
166{
167 struct backlight_device *bd = platform_get_drvdata(pdev);
168
169 backlight_device_unregister(bd);
170
171 return 0;
172}
173
174static struct platform_driver kb3886bl_driver = {
175 .probe = kb3886bl_probe,
176 .remove = kb3886bl_remove,
177 .suspend = kb3886bl_suspend,
178 .resume = kb3886bl_resume,
179 .driver = {
180 .name = "kb3886-bl",
181 },
182};
183
184static int __init kb3886_init(void)
185{
186 if (!dmi_check_system(kb3886bl_device_table))
187 return -ENODEV;
188
189 platform_add_devices(devices, ARRAY_SIZE(devices));
190 return platform_driver_register(&kb3886bl_driver);
191}
192
193static void __exit kb3886_exit(void)
194{
195 platform_driver_unregister(&kb3886bl_driver);
196}
197
198module_init(kb3886_init);
199module_exit(kb3886_exit);
200
201MODULE_AUTHOR("Claudio Nieder <private@claudio.ch>");
202MODULE_DESCRIPTION("Tabletkiosk Sahara Touch-iT Backlight Driver");
203MODULE_LICENSE("GPL");
204MODULE_ALIAS("dmi:*:svnSDV:pniTouchT201:*");