1 From 40cbddde06a9f0e1845810b904502f922fc3288f Mon Sep 17 00:00:00 2001
2 From: Koen Kooi <koen@dominion.thruhere.net>
3 Date: Fri, 27 Apr 2012 21:30:00 +0200
4 Subject: [PATCH 3/5] tlc59108: adjust for beagleboard+uLCD7
6 Signed-off-by: Koen Kooi <koen@dominion.thruhere.net>
8 drivers/video/backlight/tlc59108.c | 46 ++++++++++++++++++++++++-----------
9 1 files changed, 31 insertions(+), 15 deletions(-)
11 diff --git a/drivers/video/backlight/tlc59108.c b/drivers/video/backlight/tlc59108.c
12 index 4f4ea34..40a21e7 100644
13 --- a/drivers/video/backlight/tlc59108.c
14 +++ b/drivers/video/backlight/tlc59108.c
16 #include <linux/backlight.h>
19 -#define tlc59108_MODULE_NAME "tlc59108"
20 #define TLC59108_MODE1 0x00
21 -#define TLC59108_PWM2 0x04
22 +#define TLC59108_MODE2 0x01
23 +#define TLC59108_PWM0 0x02
24 +#define TLC59108_PWM1 0x03
25 +#define TLC59108_PWM2 0x04
26 +#define TLC59108_PWM3 0x05
27 +#define TLC59108_PWM4 0x06
28 +#define TLC59108_PWM5 0x07
29 +#define TLC59108_PWM6 0x08
30 +#define TLC59108_PWM7 0x09
31 #define TLC59108_LEDOUT0 0x0c
32 #define TLC59108_LEDOUT1 0x0d
33 #define TLC59108_MAX_BRIGHTNESS 0xFF
34 @@ -43,15 +50,9 @@ struct tlc59108_bl {
36 static void tlc59108_bl_set_backlight(struct tlc59108_bl *data, int brightness)
38 - /* Set Mode1 Register */
39 - i2c_smbus_write_byte_data(data->client, TLC59108_MODE1, 0x00);
41 - /* Set LEDOUT0 Register */
42 - i2c_smbus_write_byte_data(data->client, TLC59108_LEDOUT0, 0x21);
44 /* Set Backlight Duty Cycle*/
45 i2c_smbus_write_byte_data(data->client, TLC59108_PWM2,
47 + 0xff - brightness );
50 static int tlc59108_bl_get_brightness(struct backlight_device *dev)
51 @@ -65,8 +66,18 @@ static int tlc59108_bl_update_status(struct backlight_device *dev)
53 struct backlight_properties *props = &dev->props;
54 struct tlc59108_bl *data = dev_get_drvdata(&dev->dev);
56 int brightness = props->brightness;
58 + if (dev->props.state & BL_CORE_FBBLANK) {
60 + /* Set LEDOUT0 Register */
61 + i2c_smbus_write_byte_data(data->client, TLC59108_LEDOUT0, 0x10);
63 + /* Set LEDOUT0 Register */
64 + i2c_smbus_write_byte_data(data->client, TLC59108_LEDOUT0, 0x30);
67 tlc59108_bl_set_backlight(data, brightness);
70 @@ -77,7 +88,7 @@ static const struct backlight_ops bl_ops = {
71 .update_status = tlc59108_bl_update_status,
74 -static int tlc59108_probe(struct i2c_client *c, const struct i2c_device_id *id)
75 +static int __devinit tlc59108_probe(struct i2c_client *c, const struct i2c_device_id *id)
77 struct backlight_properties props;
78 struct tlc59108_bl *data = kzalloc(sizeof(struct tlc59108_bl),
79 @@ -104,6 +115,11 @@ static int tlc59108_probe(struct i2c_client *c, const struct i2c_device_id *id)
81 backlight_update_status(data->bl);
83 + i2c_smbus_write_byte_data(data->client, TLC59108_MODE1, 0x00);
84 + i2c_smbus_write_byte_data(data->client, TLC59108_PWM2, 0x80);
85 + i2c_smbus_write_byte_data(data->client, TLC59108_LEDOUT1, 0x05);
86 + i2c_smbus_write_byte_data(data->client, TLC59108_LEDOUT1, 0x15);
91 @@ -125,7 +141,7 @@ static int tlc59108_remove(struct i2c_client *c)
94 /* I2C Device ID table */
95 -static const struct i2c_device_id tlc59108_id[] = {
96 +static struct i2c_device_id tlc59108_id[] = {
100 @@ -134,12 +150,12 @@ MODULE_DEVICE_TABLE(i2c, tlc59108_id);
101 /* I2C driver data */
102 static struct i2c_driver tlc59108_driver = {
104 - .owner = THIS_MODULE,
105 - .name = tlc59108_MODULE_NAME,
106 + .owner = THIS_MODULE,
109 + .id_table = tlc59108_id,
110 .probe = tlc59108_probe,
111 .remove = tlc59108_remove,
112 - .id_table = tlc59108_id,
115 static int __init tlc59108_init(void)
116 @@ -157,4 +173,4 @@ module_exit(tlc59108_exit);
118 MODULE_DESCRIPTION("LCD/Backlight control for TLC59108");
119 MODULE_AUTHOR("Senthil Natarajan <senthil.n@ti.com>");
120 -MODULE_LICENSE("GPL v2");
121 +MODULE_LICENSE("GPL");