aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/leds
diff options
context:
space:
mode:
authorSamu Onkalo <samu.p.onkalo@nokia.com>2010-11-24 15:57:04 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2010-11-24 16:50:43 -0500
commit2e4840edb7c485211993919a6a50d93c108198b8 (patch)
tree018af5ec842fade7064f1fd00bc9c2186e6037a7 /drivers/leds
parent09c76b0f6e8fcd78f2d194acb1f07e41789cc29b (diff)
drivers/leds/leds-lp5523.c: adjust delays and add comments to them
Delays were little bit too long. Adjust delay times and add some comments to them. Signed-off-by: Samu Onkalo <samu.p.onkalo@nokia.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')
-rw-r--r--drivers/leds/leds-lp5523.c31
1 files changed, 17 insertions, 14 deletions
diff --git a/drivers/leds/leds-lp5523.c b/drivers/leds/leds-lp5523.c
index 053e1f8b6c0b..4248d78cec37 100644
--- a/drivers/leds/leds-lp5523.c
+++ b/drivers/leds/leds-lp5523.c
@@ -205,11 +205,14 @@ static int lp5523_configure(struct i2c_client *client)
205 205
206 lp5523_write(client, LP5523_REG_RESET, 0xff); 206 lp5523_write(client, LP5523_REG_RESET, 0xff);
207 207
208 usleep_range(10000, 100000); 208 usleep_range(10000, 20000); /*
209 * Exact value is not available. 10 - 20ms
210 * appears to be enough for reset.
211 */
209 212
210 ret |= lp5523_write(client, LP5523_REG_ENABLE, LP5523_ENABLE); 213 ret |= lp5523_write(client, LP5523_REG_ENABLE, LP5523_ENABLE);
211 /* Chip startup time after reset is 500 us */ 214 /* Chip startup time is 500 us, 1 - 2 ms gives some margin */
212 usleep_range(1000, 10000); 215 usleep_range(1000, 2000);
213 216
214 ret |= lp5523_write(client, LP5523_REG_CONFIG, 217 ret |= lp5523_write(client, LP5523_REG_CONFIG,
215 LP5523_AUTO_INC | LP5523_PWR_SAVE | 218 LP5523_AUTO_INC | LP5523_PWR_SAVE |
@@ -246,8 +249,8 @@ static int lp5523_configure(struct i2c_client *client)
246 return -1; 249 return -1;
247 } 250 }
248 251
249 /* Wait 3ms and check the engine status */ 252 /* Let the programs run for couple of ms and check the engine status */
250 usleep_range(3000, 20000); 253 usleep_range(3000, 6000);
251 lp5523_read(client, LP5523_REG_STATUS, &status); 254 lp5523_read(client, LP5523_REG_STATUS, &status);
252 status &= LP5523_ENG_STATUS_MASK; 255 status &= LP5523_ENG_STATUS_MASK;
253 256
@@ -452,10 +455,10 @@ static ssize_t lp5523_selftest(struct device *dev,
452 /* Measure VDD (i.e. VBAT) first (channel 16 corresponds to VDD) */ 455 /* Measure VDD (i.e. VBAT) first (channel 16 corresponds to VDD) */
453 lp5523_write(chip->client, LP5523_REG_LED_TEST_CTRL, 456 lp5523_write(chip->client, LP5523_REG_LED_TEST_CTRL,
454 LP5523_EN_LEDTEST | 16); 457 LP5523_EN_LEDTEST | 16);
455 usleep_range(3000, 10000); 458 usleep_range(3000, 6000); /* ADC conversion time is typically 2.7 ms */
456 ret = lp5523_read(chip->client, LP5523_REG_STATUS, &status); 459 ret = lp5523_read(chip->client, LP5523_REG_STATUS, &status);
457 if (!(status & LP5523_LEDTEST_DONE)) 460 if (!(status & LP5523_LEDTEST_DONE))
458 usleep_range(3000, 10000); 461 usleep_range(3000, 6000); /* Was not ready. Wait little bit */
459 462
460 ret |= lp5523_read(chip->client, LP5523_REG_LED_TEST_ADC, &vdd); 463 ret |= lp5523_read(chip->client, LP5523_REG_LED_TEST_ADC, &vdd);
461 vdd--; /* There may be some fluctuation in measurement */ 464 vdd--; /* There may be some fluctuation in measurement */
@@ -471,16 +474,16 @@ static ssize_t lp5523_selftest(struct device *dev,
471 chip->pdata->led_config[i].led_current); 474 chip->pdata->led_config[i].led_current);
472 475
473 lp5523_write(chip->client, LP5523_REG_LED_PWM_BASE + i, 0xff); 476 lp5523_write(chip->client, LP5523_REG_LED_PWM_BASE + i, 0xff);
474 /* let current stabilize 2ms before measurements start */ 477 /* let current stabilize 2 - 4ms before measurements start */
475 usleep_range(2000, 10000); 478 usleep_range(2000, 4000);
476 lp5523_write(chip->client, 479 lp5523_write(chip->client,
477 LP5523_REG_LED_TEST_CTRL, 480 LP5523_REG_LED_TEST_CTRL,
478 LP5523_EN_LEDTEST | i); 481 LP5523_EN_LEDTEST | i);
479 /* ledtest takes 2.7ms */ 482 /* ADC conversion time is 2.7 ms typically */
480 usleep_range(3000, 10000); 483 usleep_range(3000, 6000);
481 ret = lp5523_read(chip->client, LP5523_REG_STATUS, &status); 484 ret = lp5523_read(chip->client, LP5523_REG_STATUS, &status);
482 if (!(status & LP5523_LEDTEST_DONE)) 485 if (!(status & LP5523_LEDTEST_DONE))
483 usleep_range(3000, 10000); 486 usleep_range(3000, 6000);/* Was not ready. Wait. */
484 ret |= lp5523_read(chip->client, LP5523_REG_LED_TEST_ADC, &adc); 487 ret |= lp5523_read(chip->client, LP5523_REG_LED_TEST_ADC, &adc);
485 488
486 if (adc >= vdd || adc < LP5523_ADC_SHORTCIRC_LIM) 489 if (adc >= vdd || adc < LP5523_ADC_SHORTCIRC_LIM)
@@ -933,9 +936,9 @@ static int lp5523_probe(struct i2c_client *client,
933 936
934 if (pdata->enable) { 937 if (pdata->enable) {
935 pdata->enable(0); 938 pdata->enable(0);
936 usleep_range(1000, 10000); 939 usleep_range(1000, 2000); /* Keep enable down at least 1ms */
937 pdata->enable(1); 940 pdata->enable(1);
938 usleep_range(1000, 10000); /* Spec says min 500us */ 941 usleep_range(1000, 2000); /* 500us abs min. */
939 } 942 }
940 943
941 ret = lp5523_detect(client); 944 ret = lp5523_detect(client);