aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/leds/leds-lp5521.c
diff options
context:
space:
mode:
authorKim, Milo <Milo.Kim@ti.com>2012-03-23 18:02:09 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2012-03-23 19:58:34 -0400
commit32a2f747ddf58b0f9ad786c4f3853b1ca7750cf9 (patch)
tree981798d42d5ab757e31482174be8359d60b78cf7 /drivers/leds/leds-lp5521.c
parent011af7bc7cd188a0310e2d26cdc2cc5d90148b0c (diff)
drivers/leds/leds-lp5521.c: redefinition of register bits
For better readability, values of LP5521_REG_ENABLE register were redefined= . Additional definitions: LP5521_ENABLE_DEFAULT and LP5521_ENABLE_RUN_PROGRAM= . Use definition rather than hard code value. : 0x3F -> 'LP5521_CMD_DIRECT' Signed-off-by: Milo(Woogyom) Kim <milo.kim@ti.com> Acked-by: Linus Walleij <linus.walleij@linaro.org> Cc: Arun MURTHY <arun.murthy@stericsson.com> Cc: Srinidhi Kasagar <srinidhi.kasagar@stericsson.com> Cc: Richard Purdie <rpurdie@rpsys.net> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/leds/leds-lp5521.c')
-rw-r--r--drivers/leds/leds-lp5521.c21
1 files changed, 10 insertions, 11 deletions
diff --git a/drivers/leds/leds-lp5521.c b/drivers/leds/leds-lp5521.c
index 007c7c921e7e..de7b8fe676df 100644
--- a/drivers/leds/leds-lp5521.c
+++ b/drivers/leds/leds-lp5521.c
@@ -81,6 +81,10 @@
81#define LP5521_MASTER_ENABLE 0x40 /* Chip master enable */ 81#define LP5521_MASTER_ENABLE 0x40 /* Chip master enable */
82#define LP5521_LOGARITHMIC_PWM 0x80 /* Logarithmic PWM adjustment */ 82#define LP5521_LOGARITHMIC_PWM 0x80 /* Logarithmic PWM adjustment */
83#define LP5521_EXEC_RUN 0x2A 83#define LP5521_EXEC_RUN 0x2A
84#define LP5521_ENABLE_DEFAULT \
85 (LP5521_MASTER_ENABLE | LP5521_LOGARITHMIC_PWM)
86#define LP5521_ENABLE_RUN_PROGRAM \
87 (LP5521_ENABLE_DEFAULT | LP5521_EXEC_RUN)
84 88
85/* Status */ 89/* Status */
86#define LP5521_EXT_CLK_USED 0x08 90#define LP5521_EXT_CLK_USED 0x08
@@ -237,7 +241,7 @@ static int lp5521_configure(struct i2c_client *client)
237 lp5521_init_engine(chip); 241 lp5521_init_engine(chip);
238 242
239 /* Set all PWMs to direct control mode */ 243 /* Set all PWMs to direct control mode */
240 ret = lp5521_write(client, LP5521_REG_OP_MODE, 0x3F); 244 ret = lp5521_write(client, LP5521_REG_OP_MODE, LP5521_CMD_DIRECT);
241 245
242 cfg = chip->pdata->update_config ? 246 cfg = chip->pdata->update_config ?
243 : (LP5521_PWRSAVE_EN | LP5521_CP_MODE_AUTO | LP5521_R_TO_BATT); 247 : (LP5521_PWRSAVE_EN | LP5521_CP_MODE_AUTO | LP5521_R_TO_BATT);
@@ -250,8 +254,7 @@ static int lp5521_configure(struct i2c_client *client)
250 254
251 /* Set engines are set to run state when OP_MODE enables engines */ 255 /* Set engines are set to run state when OP_MODE enables engines */
252 ret |= lp5521_write(client, LP5521_REG_ENABLE, 256 ret |= lp5521_write(client, LP5521_REG_ENABLE,
253 LP5521_MASTER_ENABLE | LP5521_LOGARITHMIC_PWM | 257 LP5521_ENABLE_RUN_PROGRAM);
254 LP5521_EXEC_RUN);
255 /* enable takes 500us. 1 - 2 ms leaves some margin */ 258 /* enable takes 500us. 1 - 2 ms leaves some margin */
256 usleep_range(1000, 2000); 259 usleep_range(1000, 2000);
257 260
@@ -302,8 +305,7 @@ static int lp5521_detect(struct i2c_client *client)
302 int ret; 305 int ret;
303 u8 buf; 306 u8 buf;
304 307
305 ret = lp5521_write(client, LP5521_REG_ENABLE, 308 ret = lp5521_write(client, LP5521_REG_ENABLE, LP5521_ENABLE_DEFAULT);
306 LP5521_MASTER_ENABLE | LP5521_LOGARITHMIC_PWM);
307 if (ret) 309 if (ret)
308 return ret; 310 return ret;
309 /* enable takes 500us. 1 - 2 ms leaves some margin */ 311 /* enable takes 500us. 1 - 2 ms leaves some margin */
@@ -311,7 +313,7 @@ static int lp5521_detect(struct i2c_client *client)
311 ret = lp5521_read(client, LP5521_REG_ENABLE, &buf); 313 ret = lp5521_read(client, LP5521_REG_ENABLE, &buf);
312 if (ret) 314 if (ret)
313 return ret; 315 return ret;
314 if (buf != (LP5521_MASTER_ENABLE | LP5521_LOGARITHMIC_PWM)) 316 if (buf != LP5521_ENABLE_DEFAULT)
315 return -ENODEV; 317 return -ENODEV;
316 318
317 return 0; 319 return 0;
@@ -576,8 +578,7 @@ static void lp5521_run_led_pattern(int mode, struct lp5521_chip *chip)
576 return; 578 return;
577 579
578 if (mode == PATTERN_OFF) { 580 if (mode == PATTERN_OFF) {
579 lp5521_write(cl, LP5521_REG_ENABLE, 581 lp5521_write(cl, LP5521_REG_ENABLE, LP5521_ENABLE_DEFAULT);
580 LP5521_MASTER_ENABLE | LP5521_LOGARITHMIC_PWM);
581 usleep_range(1000, 2000); 582 usleep_range(1000, 2000);
582 lp5521_write(cl, LP5521_REG_OP_MODE, LP5521_CMD_DIRECT); 583 lp5521_write(cl, LP5521_REG_OP_MODE, LP5521_CMD_DIRECT);
583 } else { 584 } else {
@@ -599,9 +600,7 @@ static void lp5521_run_led_pattern(int mode, struct lp5521_chip *chip)
599 600
600 lp5521_write(cl, LP5521_REG_OP_MODE, LP5521_CMD_RUN); 601 lp5521_write(cl, LP5521_REG_OP_MODE, LP5521_CMD_RUN);
601 usleep_range(1000, 2000); 602 usleep_range(1000, 2000);
602 lp5521_write(cl, LP5521_REG_ENABLE, 603 lp5521_write(cl, LP5521_REG_ENABLE, LP5521_ENABLE_RUN_PROGRAM);
603 LP5521_MASTER_ENABLE | LP5521_LOGARITHMIC_PWM |
604 LP5521_EXEC_RUN);
605 } 604 }
606} 605}
607 606