aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/video/backlight
diff options
context:
space:
mode:
authorKim, Milo <Milo.Kim@ti.com>2013-04-29 19:18:03 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2013-04-29 21:28:18 -0400
commit0b8185733966c1863b6b90ca2697327118ce5032 (patch)
tree746742b89c6eb0b9f20058139afc2ec93c3bd122 /drivers/video/backlight
parent600ffd33d09e3803d81607d3404a8cad709160e4 (diff)
backlight: lp855x: move backlight mode platform data
The brightness of LP855x devices is controlled by I2C register or PWM input . This mode was selected through the platform data, but it can be chosen by the driver internally without platform data configuration. How to decide the control mode: If the PWM period has specific value, the mode is PWM input. On the other hand, the mode is register-based. This mode selection is done on the _probe(). Move 'mode' from a header file to the driver private data structure, 'lp855 x'. And correlated code was replaced. Signed-off-by: Milo(Woogyom) Kim <milo.kim@ti.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/video/backlight')
-rw-r--r--drivers/video/backlight/lp855x_bl.c21
1 files changed, 15 insertions, 6 deletions
diff --git a/drivers/video/backlight/lp855x_bl.c b/drivers/video/backlight/lp855x_bl.c
index df937ce5c2ec..b94dc00cea3f 100644
--- a/drivers/video/backlight/lp855x_bl.c
+++ b/drivers/video/backlight/lp855x_bl.c
@@ -38,6 +38,11 @@
38#define DEFAULT_BL_NAME "lcd-backlight" 38#define DEFAULT_BL_NAME "lcd-backlight"
39#define MAX_BRIGHTNESS 255 39#define MAX_BRIGHTNESS 255
40 40
41enum lp855x_brightness_ctrl_mode {
42 PWM_BASED = 1,
43 REGISTER_BASED,
44};
45
41struct lp855x; 46struct lp855x;
42 47
43/* 48/*
@@ -57,6 +62,7 @@ struct lp855x_device_config {
57struct lp855x { 62struct lp855x {
58 const char *chipname; 63 const char *chipname;
59 enum lp855x_chip_id chip_id; 64 enum lp855x_chip_id chip_id;
65 enum lp855x_brightness_ctrl_mode mode;
60 struct lp855x_device_config *cfg; 66 struct lp855x_device_config *cfg;
61 struct i2c_client *client; 67 struct i2c_client *client;
62 struct backlight_device *bl; 68 struct backlight_device *bl;
@@ -238,18 +244,17 @@ static void lp855x_pwm_ctrl(struct lp855x *lp, int br, int max_br)
238static int lp855x_bl_update_status(struct backlight_device *bl) 244static int lp855x_bl_update_status(struct backlight_device *bl)
239{ 245{
240 struct lp855x *lp = bl_get_data(bl); 246 struct lp855x *lp = bl_get_data(bl);
241 enum lp855x_brightness_ctrl_mode mode = lp->pdata->mode;
242 247
243 if (bl->props.state & BL_CORE_SUSPENDED) 248 if (bl->props.state & BL_CORE_SUSPENDED)
244 bl->props.brightness = 0; 249 bl->props.brightness = 0;
245 250
246 if (mode == PWM_BASED) { 251 if (lp->mode == PWM_BASED) {
247 int br = bl->props.brightness; 252 int br = bl->props.brightness;
248 int max_br = bl->props.max_brightness; 253 int max_br = bl->props.max_brightness;
249 254
250 lp855x_pwm_ctrl(lp, br, max_br); 255 lp855x_pwm_ctrl(lp, br, max_br);
251 256
252 } else if (mode == REGISTER_BASED) { 257 } else if (lp->mode == REGISTER_BASED) {
253 u8 val = bl->props.brightness; 258 u8 val = bl->props.brightness;
254 lp855x_write_byte(lp, lp->cfg->reg_brightness, val); 259 lp855x_write_byte(lp, lp->cfg->reg_brightness, val);
255 } 260 }
@@ -310,12 +315,11 @@ static ssize_t lp855x_get_bl_ctl_mode(struct device *dev,
310 struct device_attribute *attr, char *buf) 315 struct device_attribute *attr, char *buf)
311{ 316{
312 struct lp855x *lp = dev_get_drvdata(dev); 317 struct lp855x *lp = dev_get_drvdata(dev);
313 enum lp855x_brightness_ctrl_mode mode = lp->pdata->mode;
314 char *strmode = NULL; 318 char *strmode = NULL;
315 319
316 if (mode == PWM_BASED) 320 if (lp->mode == PWM_BASED)
317 strmode = "pwm based"; 321 strmode = "pwm based";
318 else if (mode == REGISTER_BASED) 322 else if (lp->mode == REGISTER_BASED)
319 strmode = "register based"; 323 strmode = "register based";
320 324
321 return scnprintf(buf, PAGE_SIZE, "%s\n", strmode); 325 return scnprintf(buf, PAGE_SIZE, "%s\n", strmode);
@@ -352,6 +356,11 @@ static int lp855x_probe(struct i2c_client *cl, const struct i2c_device_id *id)
352 if (!lp) 356 if (!lp)
353 return -ENOMEM; 357 return -ENOMEM;
354 358
359 if (pdata->period_ns > 0)
360 lp->mode = PWM_BASED;
361 else
362 lp->mode = REGISTER_BASED;
363
355 lp->client = cl; 364 lp->client = cl;
356 lp->dev = &cl->dev; 365 lp->dev = &cl->dev;
357 lp->pdata = pdata; 366 lp->pdata = pdata;