]>
Commit | Line | Data |
---|---|---|
d006af40 AF |
1 | From e989473bea15beef8d480b822a619e7b8fca860c Mon Sep 17 00:00:00 2001 |
2 | From: "Manjunathappa, Prakash" <prakash.pm@ti.com> | |
3 | Date: Mon, 1 Aug 2011 18:25:11 +0530 | |
4 | Subject: [PATCH 2/5] backlight: Add TLC59108 backlight control driver | |
5 | ||
6 | This patch adds support for I2C configurable TLC59108 backlight | |
7 | control driver. | |
8 | ||
9 | Signed-off-by: Manjunathappa, Prakash <prakash.pm@ti.com> | |
10 | Signed-off-by: Vaibhav Hiremath <hvaibhav@ti.com> | |
11 | --- | |
12 | drivers/video/backlight/Kconfig | 8 ++ | |
13 | drivers/video/backlight/Makefile | 1 + | |
14 | drivers/video/backlight/tlc59108.c | 160 ++++++++++++++++++++++++++++++++++++ | |
15 | 3 files changed, 169 insertions(+) | |
16 | create mode 100644 drivers/video/backlight/tlc59108.c | |
17 | ||
18 | diff --git a/drivers/video/backlight/Kconfig b/drivers/video/backlight/Kconfig | |
19 | index db10d01..04a2275 100644 | |
20 | --- a/drivers/video/backlight/Kconfig | |
21 | +++ b/drivers/video/backlight/Kconfig | |
22 | @@ -418,6 +418,14 @@ config BACKLIGHT_AS3711 | |
23 | If you have an Austrian Microsystems AS3711 say Y to enable the | |
24 | backlight driver. | |
25 | ||
26 | +config BACKLIGHT_TLC59108 | |
27 | + tristate "TLC59108 LCD Backlight Driver" | |
28 | + depends on I2C && BACKLIGHT_CLASS_DEVICE | |
29 | + default n | |
30 | + help | |
31 | + If you have an LCD Panel with backlight control via TLC59108, | |
32 | + say Y to enable its LCD control driver. | |
33 | + | |
34 | endif # BACKLIGHT_CLASS_DEVICE | |
35 | ||
36 | endif # BACKLIGHT_LCD_SUPPORT | |
37 | diff --git a/drivers/video/backlight/Makefile b/drivers/video/backlight/Makefile | |
38 | index 96c4d62..3687852 100644 | |
39 | --- a/drivers/video/backlight/Makefile | |
40 | +++ b/drivers/video/backlight/Makefile | |
41 | @@ -41,6 +41,7 @@ obj-$(CONFIG_BACKLIGHT_LP855X) += lp855x_bl.o | |
42 | obj-$(CONFIG_BACKLIGHT_LP8788) += lp8788_bl.o | |
43 | obj-$(CONFIG_BACKLIGHT_MAX8925) += max8925_bl.o | |
44 | obj-$(CONFIG_BACKLIGHT_OMAP1) += omap1_bl.o | |
45 | +obj-$(CONFIG_BACKLIGHT_TLC59108) += tlc59108.o | |
46 | obj-$(CONFIG_BACKLIGHT_OT200) += ot200_bl.o | |
47 | obj-$(CONFIG_BACKLIGHT_PANDORA) += pandora_bl.o | |
48 | obj-$(CONFIG_BACKLIGHT_PCF50633) += pcf50633-backlight.o | |
49 | diff --git a/drivers/video/backlight/tlc59108.c b/drivers/video/backlight/tlc59108.c | |
50 | new file mode 100644 | |
51 | index 0000000..4f4ea34 | |
52 | --- /dev/null | |
53 | +++ b/drivers/video/backlight/tlc59108.c | |
54 | @@ -0,0 +1,160 @@ | |
55 | +/* | |
56 | + * ti81xxhdmi_tlc59108.c | |
57 | + * | |
58 | + * Copyright (C) 2011 Texas Instruments | |
59 | + * Author: Senthil Natarajan | |
60 | + * | |
61 | + * tlc59108 HDMI Driver | |
62 | + * | |
63 | + * This program is free software; you can redistribute it and/or modify it | |
64 | + * under the terms of the GNU General Public License version 2 as published by | |
65 | + * the Free Software Foundation. | |
66 | + * | |
67 | + * This program is distributed in the hope that it will be useful, but WITHOUT | |
68 | + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
69 | + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | |
70 | + * more details. | |
71 | + * | |
72 | + * You should have received a copy of the GNU General Public License along with | |
73 | + * this program. If not, see <http://www.gnu.org/licenses/>. | |
74 | + * History: | |
75 | + * | |
76 | + * Senthil Natarajan<senthil.n@ti.com> July 2011 I2C driver for tlc59108 | |
77 | + * backlight control | |
78 | + */ | |
79 | + | |
80 | +#include <linux/i2c.h> | |
81 | +#include <linux/kernel.h> | |
82 | +#include <linux/module.h> | |
83 | +#include <linux/backlight.h> | |
84 | +#include <linux/fb.h> | |
85 | + | |
86 | +#define tlc59108_MODULE_NAME "tlc59108" | |
87 | +#define TLC59108_MODE1 0x00 | |
88 | +#define TLC59108_PWM2 0x04 | |
89 | +#define TLC59108_LEDOUT0 0x0c | |
90 | +#define TLC59108_LEDOUT1 0x0d | |
91 | +#define TLC59108_MAX_BRIGHTNESS 0xFF | |
92 | + | |
93 | +struct tlc59108_bl { | |
94 | + struct i2c_client *client; | |
95 | + struct backlight_device *bl; | |
96 | +}; | |
97 | + | |
98 | +static void tlc59108_bl_set_backlight(struct tlc59108_bl *data, int brightness) | |
99 | +{ | |
100 | + /* Set Mode1 Register */ | |
101 | + i2c_smbus_write_byte_data(data->client, TLC59108_MODE1, 0x00); | |
102 | + | |
103 | + /* Set LEDOUT0 Register */ | |
104 | + i2c_smbus_write_byte_data(data->client, TLC59108_LEDOUT0, 0x21); | |
105 | + | |
106 | + /* Set Backlight Duty Cycle*/ | |
107 | + i2c_smbus_write_byte_data(data->client, TLC59108_PWM2, | |
108 | + brightness & 0xff); | |
109 | +} | |
110 | + | |
111 | +static int tlc59108_bl_get_brightness(struct backlight_device *dev) | |
112 | +{ | |
113 | + struct backlight_properties *props = &dev->props; | |
114 | + | |
115 | + return props->brightness; | |
116 | +} | |
117 | + | |
118 | +static int tlc59108_bl_update_status(struct backlight_device *dev) | |
119 | +{ | |
120 | + struct backlight_properties *props = &dev->props; | |
121 | + struct tlc59108_bl *data = dev_get_drvdata(&dev->dev); | |
122 | + int brightness = props->brightness; | |
123 | + | |
124 | + tlc59108_bl_set_backlight(data, brightness); | |
125 | + | |
126 | + return 0; | |
127 | +} | |
128 | + | |
129 | +static const struct backlight_ops bl_ops = { | |
130 | + .get_brightness = tlc59108_bl_get_brightness, | |
131 | + .update_status = tlc59108_bl_update_status, | |
132 | +}; | |
133 | + | |
134 | +static int tlc59108_probe(struct i2c_client *c, const struct i2c_device_id *id) | |
135 | +{ | |
136 | + struct backlight_properties props; | |
137 | + struct tlc59108_bl *data = kzalloc(sizeof(struct tlc59108_bl), | |
138 | + GFP_KERNEL); | |
139 | + int ret = 0; | |
140 | + | |
141 | + if (!data) | |
142 | + return -ENOMEM; | |
143 | + | |
144 | + i2c_set_clientdata(c, data); | |
145 | + data->client = c; | |
146 | + | |
147 | + memset(&props, 0, sizeof(struct backlight_properties)); | |
148 | + props.max_brightness = TLC59108_MAX_BRIGHTNESS; | |
149 | + props.type = BACKLIGHT_RAW; | |
150 | + data->bl = backlight_device_register("tlc59108-bl", &c->dev, data, | |
151 | + &bl_ops, &props); | |
152 | + if (IS_ERR(data->bl)) { | |
153 | + ret = PTR_ERR(data->bl); | |
154 | + goto err_reg; | |
155 | + } | |
156 | + | |
157 | + data->bl->props.brightness = TLC59108_MAX_BRIGHTNESS; | |
158 | + | |
159 | + backlight_update_status(data->bl); | |
160 | + | |
161 | + return 0; | |
162 | + | |
163 | +err_reg: | |
164 | + data->bl = NULL; | |
165 | + kfree(data); | |
166 | + return ret; | |
167 | +} | |
168 | + | |
169 | +static int tlc59108_remove(struct i2c_client *c) | |
170 | +{ | |
171 | + struct tlc59108_bl *data = i2c_get_clientdata(c); | |
172 | + | |
173 | + backlight_device_unregister(data->bl); | |
174 | + data->bl = NULL; | |
175 | + | |
176 | + kfree(data); | |
177 | + | |
178 | + return 0; | |
179 | +} | |
180 | + | |
181 | +/* I2C Device ID table */ | |
182 | +static const struct i2c_device_id tlc59108_id[] = { | |
183 | + { "tlc59108", 0 }, | |
184 | + { } | |
185 | +}; | |
186 | +MODULE_DEVICE_TABLE(i2c, tlc59108_id); | |
187 | + | |
188 | +/* I2C driver data */ | |
189 | +static struct i2c_driver tlc59108_driver = { | |
190 | + .driver = { | |
191 | + .owner = THIS_MODULE, | |
192 | + .name = tlc59108_MODULE_NAME, | |
193 | + }, | |
194 | + .probe = tlc59108_probe, | |
195 | + .remove = tlc59108_remove, | |
196 | + .id_table = tlc59108_id, | |
197 | +}; | |
198 | + | |
199 | +static int __init tlc59108_init(void) | |
200 | +{ | |
201 | + return i2c_add_driver(&tlc59108_driver); | |
202 | +} | |
203 | + | |
204 | +static void __exit tlc59108_exit(void) | |
205 | +{ | |
206 | + i2c_del_driver(&tlc59108_driver); | |
207 | +} | |
208 | + | |
209 | +module_init(tlc59108_init); | |
210 | +module_exit(tlc59108_exit); | |
211 | + | |
212 | +MODULE_DESCRIPTION("LCD/Backlight control for TLC59108"); | |
213 | +MODULE_AUTHOR("Senthil Natarajan <senthil.n@ti.com>"); | |
214 | +MODULE_LICENSE("GPL v2"); | |
215 | -- | |
216 | 1.7.10.4 | |
217 |