diff options
author | Kim, Milo <Milo.Kim@ti.com> | 2013-03-20 20:37:04 -0400 |
---|---|---|
committer | Bryan Wu <cooloney@gmail.com> | 2013-04-01 14:04:53 -0400 |
commit | 81f2a5b4a0570a662efd629c176fc1d67e56f7e3 (patch) | |
tree | 673895fad2c6e0baaecfa8ac74e3f28cb47062ef /drivers/leds | |
parent | 53b4192266436e75dea96c8ef495eadd6f3df981 (diff) |
leds: lp55xx: configure the clock detection
Now LP55xx provides automatic clock detection API, lp55xx_is_extclk_used().
The clock configuration can be done by the driver itself.
(a) Concept
The default value is set by each driver with clock selection.
The internal clock selection bit is updated in case that the external clock
is not detected or clock rate is not 32KHz.
(b) Change on LP55xx platform data
The clock configuration is done automatically, so no need to define
'update_config' in the platform side.
Correlated information are removed in the documentations and header.
(c) Definitions moved from header to driver files
CONFIG register values are moved each driver, LP5521 and LP5562.
Not necessary definitions are removed also.
Signed-off-by: Milo(Woogyom) Kim <milo.kim@ti.com>
Signed-off-by: Bryan Wu <cooloney@gmail.com>
Diffstat (limited to 'drivers/leds')
-rw-r--r-- | drivers/leds/leds-lp5521.c | 19 | ||||
-rw-r--r-- | drivers/leds/leds-lp5562.c | 14 |
2 files changed, 27 insertions, 6 deletions
diff --git a/drivers/leds/leds-lp5521.c b/drivers/leds/leds-lp5521.c index 7f10304219ea..19752c928aa2 100644 --- a/drivers/leds/leds-lp5521.c +++ b/drivers/leds/leds-lp5521.c | |||
@@ -68,6 +68,18 @@ | |||
68 | #define LP5521_ENABLE_RUN_PROGRAM \ | 68 | #define LP5521_ENABLE_RUN_PROGRAM \ |
69 | (LP5521_ENABLE_DEFAULT | LP5521_EXEC_RUN) | 69 | (LP5521_ENABLE_DEFAULT | LP5521_EXEC_RUN) |
70 | 70 | ||
71 | /* CONFIG register */ | ||
72 | #define LP5521_PWM_HF 0x40 /* PWM: 0 = 256Hz, 1 = 558Hz */ | ||
73 | #define LP5521_PWRSAVE_EN 0x20 /* 1 = Power save mode */ | ||
74 | #define LP5521_CP_MODE_OFF 0 /* Charge pump (CP) off */ | ||
75 | #define LP5521_CP_MODE_BYPASS 8 /* CP forced to bypass mode */ | ||
76 | #define LP5521_CP_MODE_1X5 0x10 /* CP forced to 1.5x mode */ | ||
77 | #define LP5521_CP_MODE_AUTO 0x18 /* Automatic mode selection */ | ||
78 | #define LP5521_R_TO_BATT 0x04 /* R out: 0 = CP, 1 = Vbat */ | ||
79 | #define LP5521_CLK_INT 0x01 /* Internal clock */ | ||
80 | #define LP5521_DEFAULT_CFG \ | ||
81 | (LP5521_PWM_HF | LP5521_PWRSAVE_EN | LP5521_CP_MODE_AUTO) | ||
82 | |||
71 | /* Status */ | 83 | /* Status */ |
72 | #define LP5521_EXT_CLK_USED 0x08 | 84 | #define LP5521_EXT_CLK_USED 0x08 |
73 | 85 | ||
@@ -296,8 +308,11 @@ static int lp5521_post_init_device(struct lp55xx_chip *chip) | |||
296 | /* Set all PWMs to direct control mode */ | 308 | /* Set all PWMs to direct control mode */ |
297 | ret = lp55xx_write(chip, LP5521_REG_OP_MODE, LP5521_CMD_DIRECT); | 309 | ret = lp55xx_write(chip, LP5521_REG_OP_MODE, LP5521_CMD_DIRECT); |
298 | 310 | ||
299 | val = chip->pdata->update_config ? | 311 | /* Update configuration for the clock setting */ |
300 | : (LP5521_PWRSAVE_EN | LP5521_CP_MODE_AUTO | LP5521_R_TO_BATT); | 312 | val = LP5521_DEFAULT_CFG; |
313 | if (!lp55xx_is_extclk_used(chip)) | ||
314 | val |= LP5521_CLK_INT; | ||
315 | |||
301 | ret = lp55xx_write(chip, LP5521_REG_CONFIG, val); | 316 | ret = lp55xx_write(chip, LP5521_REG_CONFIG, val); |
302 | if (ret) | 317 | if (ret) |
303 | return ret; | 318 | return ret; |
diff --git a/drivers/leds/leds-lp5562.c b/drivers/leds/leds-lp5562.c index f8b927788c3a..513f2390ca2d 100644 --- a/drivers/leds/leds-lp5562.c +++ b/drivers/leds/leds-lp5562.c | |||
@@ -71,8 +71,10 @@ | |||
71 | 71 | ||
72 | /* CONFIG Register 08h */ | 72 | /* CONFIG Register 08h */ |
73 | #define LP5562_REG_CONFIG 0x08 | 73 | #define LP5562_REG_CONFIG 0x08 |
74 | #define LP5562_DEFAULT_CFG \ | 74 | #define LP5562_PWM_HF 0x40 |
75 | (LP5562_PWM_HF | LP5562_PWRSAVE_EN | LP5562_CLK_INT) | 75 | #define LP5562_PWRSAVE_EN 0x20 |
76 | #define LP5562_CLK_INT 0x01 /* Internal clock */ | ||
77 | #define LP5562_DEFAULT_CFG (LP5562_PWM_HF | LP5562_PWRSAVE_EN) | ||
76 | 78 | ||
77 | /* RESET Register 0Dh */ | 79 | /* RESET Register 0Dh */ |
78 | #define LP5562_REG_RESET 0x0D | 80 | #define LP5562_REG_RESET 0x0D |
@@ -280,7 +282,7 @@ static void lp5562_firmware_loaded(struct lp55xx_chip *chip) | |||
280 | static int lp5562_post_init_device(struct lp55xx_chip *chip) | 282 | static int lp5562_post_init_device(struct lp55xx_chip *chip) |
281 | { | 283 | { |
282 | int ret; | 284 | int ret; |
283 | u8 update_cfg = chip->pdata->update_config ? : LP5562_DEFAULT_CFG; | 285 | u8 cfg = LP5562_DEFAULT_CFG; |
284 | 286 | ||
285 | /* Set all PWMs to direct control mode */ | 287 | /* Set all PWMs to direct control mode */ |
286 | ret = lp55xx_write(chip, LP5562_REG_OP_MODE, LP5562_CMD_DIRECT); | 288 | ret = lp55xx_write(chip, LP5562_REG_OP_MODE, LP5562_CMD_DIRECT); |
@@ -289,7 +291,11 @@ static int lp5562_post_init_device(struct lp55xx_chip *chip) | |||
289 | 291 | ||
290 | lp5562_wait_opmode_done(); | 292 | lp5562_wait_opmode_done(); |
291 | 293 | ||
292 | ret = lp55xx_write(chip, LP5562_REG_CONFIG, update_cfg); | 294 | /* Update configuration for the clock setting */ |
295 | if (!lp55xx_is_extclk_used(chip)) | ||
296 | cfg |= LP5562_CLK_INT; | ||
297 | |||
298 | ret = lp55xx_write(chip, LP5562_REG_CONFIG, cfg); | ||
293 | if (ret) | 299 | if (ret) |
294 | return ret; | 300 | return ret; |
295 | 301 | ||