aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/video
diff options
context:
space:
mode:
authorKim, Milo <Milo.Kim@ti.com>2013-02-21 19:44:06 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2013-02-21 20:22:25 -0500
commit26e8ccc223ebfd2047a96074f142544dc7062cfe (patch)
tree5bb294732ee8502a139d578d61d1faaae2031618 /drivers/video
parent68853bc2b360c06094477523f7d28efd2d9e3bf3 (diff)
backlight: lp855x_bl: support new LP8557 device
LP8557 is one of LP855x family device, but it has different register map and initialization process. To support this device, device specific configuration is done through the lp855x_device_config structure. Few register definitions are fixed for better readability. BRIGHTNESS_CTRL -> LP855X_BRIGHTNESS_CTRL DEVICE_CTRL -> LP855X_DEVICE_CTRL EEPROM_START -> LP855X_EEPROM_START EEPROM_END -> LP855X_EEPROM_END EPROM_START -> LP8556_EPROM_START EPROM_END -> LP8556_EPROM_END And LP8557 register definitions are added. New register function, lp855x_update_bit() is added. Signed-off-by: Milo(Woogyom) Kim <milo.kim@ti.com> Acked-by: Jingoo Han <jg1.han@samsung.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/video')
-rw-r--r--drivers/video/backlight/Kconfig2
-rw-r--r--drivers/video/backlight/lp855x_bl.c87
2 files changed, 73 insertions, 16 deletions
diff --git a/drivers/video/backlight/Kconfig b/drivers/video/backlight/Kconfig
index a942a2488480..be27b551473f 100644
--- a/drivers/video/backlight/Kconfig
+++ b/drivers/video/backlight/Kconfig
@@ -381,7 +381,7 @@ config BACKLIGHT_LP855X
381 tristate "Backlight driver for TI LP855X" 381 tristate "Backlight driver for TI LP855X"
382 depends on BACKLIGHT_CLASS_DEVICE && I2C 382 depends on BACKLIGHT_CLASS_DEVICE && I2C
383 help 383 help
384 This supports TI LP8550, LP8551, LP8552, LP8553 and LP8556 384 This supports TI LP8550, LP8551, LP8552, LP8553, LP8556 and LP8557
385 backlight driver. 385 backlight driver.
386 386
387config BACKLIGHT_OT200 387config BACKLIGHT_OT200
diff --git a/drivers/video/backlight/lp855x_bl.c b/drivers/video/backlight/lp855x_bl.c
index 050cfbb53667..edd2041b1527 100644
--- a/drivers/video/backlight/lp855x_bl.c
+++ b/drivers/video/backlight/lp855x_bl.c
@@ -17,13 +17,23 @@
17#include <linux/platform_data/lp855x.h> 17#include <linux/platform_data/lp855x.h>
18#include <linux/pwm.h> 18#include <linux/pwm.h>
19 19
20/* Registers */ 20/* LP8550/1/2/3/6 Registers */
21#define BRIGHTNESS_CTRL 0x00 21#define LP855X_BRIGHTNESS_CTRL 0x00
22#define DEVICE_CTRL 0x01 22#define LP855X_DEVICE_CTRL 0x01
23#define EEPROM_START 0xA0 23#define LP855X_EEPROM_START 0xA0
24#define EEPROM_END 0xA7 24#define LP855X_EEPROM_END 0xA7
25#define EPROM_START 0xA0 25#define LP8556_EPROM_START 0xA0
26#define EPROM_END 0xAF 26#define LP8556_EPROM_END 0xAF
27
28/* LP8557 Registers */
29#define LP8557_BL_CMD 0x00
30#define LP8557_BL_MASK 0x01
31#define LP8557_BL_ON 0x01
32#define LP8557_BL_OFF 0x00
33#define LP8557_BRIGHTNESS_CTRL 0x04
34#define LP8557_CONFIG 0x10
35#define LP8557_EPROM_START 0x10
36#define LP8557_EPROM_END 0x1E
27 37
28#define BUF_SIZE 20 38#define BUF_SIZE 20
29#define DEFAULT_BL_NAME "lcd-backlight" 39#define DEFAULT_BL_NAME "lcd-backlight"
@@ -75,6 +85,24 @@ static int lp855x_write_byte(struct lp855x *lp, u8 reg, u8 data)
75 return i2c_smbus_write_byte_data(lp->client, reg, data); 85 return i2c_smbus_write_byte_data(lp->client, reg, data);
76} 86}
77 87
88static int lp855x_update_bit(struct lp855x *lp, u8 reg, u8 mask, u8 data)
89{
90 int ret;
91 u8 tmp;
92
93 ret = i2c_smbus_read_byte_data(lp->client, reg);
94 if (ret < 0) {
95 dev_err(lp->dev, "failed to read 0x%.2x\n", reg);
96 return ret;
97 }
98
99 tmp = (u8)ret;
100 tmp &= ~mask;
101 tmp |= data & mask;
102
103 return lp855x_write_byte(lp, reg, tmp);
104}
105
78static bool lp855x_is_valid_rom_area(struct lp855x *lp, u8 addr) 106static bool lp855x_is_valid_rom_area(struct lp855x *lp, u8 addr)
79{ 107{
80 u8 start, end; 108 u8 start, end;
@@ -84,12 +112,16 @@ static bool lp855x_is_valid_rom_area(struct lp855x *lp, u8 addr)
84 case LP8551: 112 case LP8551:
85 case LP8552: 113 case LP8552:
86 case LP8553: 114 case LP8553:
87 start = EEPROM_START; 115 start = LP855X_EEPROM_START;
88 end = EEPROM_END; 116 end = LP855X_EEPROM_END;
89 break; 117 break;
90 case LP8556: 118 case LP8556:
91 start = EPROM_START; 119 start = LP8556_EPROM_START;
92 end = EPROM_END; 120 end = LP8556_EPROM_END;
121 break;
122 case LP8557:
123 start = LP8557_EPROM_START;
124 end = LP8557_EPROM_END;
93 break; 125 break;
94 default: 126 default:
95 return false; 127 return false;
@@ -98,9 +130,30 @@ static bool lp855x_is_valid_rom_area(struct lp855x *lp, u8 addr)
98 return (addr >= start && addr <= end); 130 return (addr >= start && addr <= end);
99} 131}
100 132
133static int lp8557_bl_off(struct lp855x *lp)
134{
135 /* BL_ON = 0 before updating EPROM settings */
136 return lp855x_update_bit(lp, LP8557_BL_CMD, LP8557_BL_MASK,
137 LP8557_BL_OFF);
138}
139
140static int lp8557_bl_on(struct lp855x *lp)
141{
142 /* BL_ON = 1 after updating EPROM settings */
143 return lp855x_update_bit(lp, LP8557_BL_CMD, LP8557_BL_MASK,
144 LP8557_BL_ON);
145}
146
101static struct lp855x_device_config lp855x_dev_cfg = { 147static struct lp855x_device_config lp855x_dev_cfg = {
102 .reg_brightness = BRIGHTNESS_CTRL, 148 .reg_brightness = LP855X_BRIGHTNESS_CTRL,
103 .reg_devicectrl = DEVICE_CTRL, 149 .reg_devicectrl = LP855X_DEVICE_CTRL,
150};
151
152static struct lp855x_device_config lp8557_dev_cfg = {
153 .reg_brightness = LP8557_BRIGHTNESS_CTRL,
154 .reg_devicectrl = LP8557_CONFIG,
155 .pre_init_device = lp8557_bl_off,
156 .post_init_device = lp8557_bl_on,
104}; 157};
105 158
106/* 159/*
@@ -123,6 +176,9 @@ static int lp855x_configure(struct lp855x *lp)
123 case LP8550 ... LP8556: 176 case LP8550 ... LP8556:
124 lp->cfg = &lp855x_dev_cfg; 177 lp->cfg = &lp855x_dev_cfg;
125 break; 178 break;
179 case LP8557:
180 lp->cfg = &lp8557_dev_cfg;
181 break;
126 default: 182 default:
127 return -EINVAL; 183 return -EINVAL;
128 } 184 }
@@ -210,7 +266,7 @@ static int lp855x_bl_update_status(struct backlight_device *bl)
210 266
211 } else if (mode == REGISTER_BASED) { 267 } else if (mode == REGISTER_BASED) {
212 u8 val = bl->props.brightness; 268 u8 val = bl->props.brightness;
213 lp855x_write_byte(lp, BRIGHTNESS_CTRL, val); 269 lp855x_write_byte(lp, lp->cfg->reg_brightness, val);
214 } 270 }
215 271
216 return 0; 272 return 0;
@@ -224,7 +280,7 @@ static int lp855x_bl_get_brightness(struct backlight_device *bl)
224 if (mode == REGISTER_BASED) { 280 if (mode == REGISTER_BASED) {
225 u8 val = 0; 281 u8 val = 0;
226 282
227 lp855x_read_byte(lp, BRIGHTNESS_CTRL, &val); 283 lp855x_read_byte(lp, lp->cfg->reg_brightness, &val);
228 bl->props.brightness = val; 284 bl->props.brightness = val;
229 } 285 }
230 286
@@ -376,6 +432,7 @@ static const struct i2c_device_id lp855x_ids[] = {
376 {"lp8552", LP8552}, 432 {"lp8552", LP8552},
377 {"lp8553", LP8553}, 433 {"lp8553", LP8553},
378 {"lp8556", LP8556}, 434 {"lp8556", LP8556},
435 {"lp8557", LP8557},
379 { } 436 { }
380}; 437};
381MODULE_DEVICE_TABLE(i2c, lp855x_ids); 438MODULE_DEVICE_TABLE(i2c, lp855x_ids);