summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Boichat <drinkcat@chromium.org>2018-07-05 13:29:24 +0800
committerchrome-bot <chrome-bot@chromium.org>2018-09-20 21:30:00 -0700
commit6cb09dc09f5e3891f6155fac9ae6779cb861d6d1 (patch)
treeb36861d81368dfb9a77d7710e8db3f434299d6c8
parenta4cbba34efffa8a97b0b67f2d2d8437457e4a21b (diff)
downloadchrome-ec-6cb09dc09f5e3891f6155fac9ae6779cb861d6d1.tar.gz
driver/led/lm3630a: Only set brightness after 100+ms.
On whiskers, after setting up the banks, the backlight blinks for a short duration (~100ms). This can be prevented by setting the brightness only ~100ms after setting up the rest of the registers. We probably do not want to sleep for too long in the init function, so set the brightness in a deferred function. BRANCH=nocturne BUG=b:111010124 TEST=Connect whiskers, see that backlight does not blink. TEST=Backlight control is still functional. Change-Id: Ie7490ea1f9f6731ede3efba63e6793525c5ea786 Signed-off-by: Nicolas Boichat <drinkcat@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1126698 Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
-rw-r--r--driver/led/lm3630a.c22
1 files changed, 16 insertions, 6 deletions
diff --git a/driver/led/lm3630a.c b/driver/led/lm3630a.c
index b65294c543..8eb12bb8d3 100644
--- a/driver/led/lm3630a.c
+++ b/driver/led/lm3630a.c
@@ -5,6 +5,7 @@
* TI LM3630A LED driver.
*/
+#include "hooks.h"
#include "i2c.h"
#include "lm3630a.h"
#include "timer.h"
@@ -23,6 +24,17 @@ static inline int lm3630a_read(uint8_t reg, int *val)
return i2c_read8(I2C_PORT_KBLIGHT, LM3630A_I2C_ADDR, reg, val);
}
+static void deferred_lm3630a_poweron(void)
+{
+ /*
+ * Set full brightness so that PWM will control. This needs to happen
+ * after setting the control register, because enabling the banks
+ * resets the value to 0.
+ */
+ lm3630a_write(LM3630A_REG_A_BRIGHTNESS, 0xff);
+}
+DECLARE_DEFERRED(deferred_lm3630a_poweron);
+
int lm3630a_poweron(void)
{
int ret = 0;
@@ -51,13 +63,11 @@ int lm3630a_poweron(void)
LM3630A_CTRL_BIT_LED2_ON_A);
/*
- * Set full brightness so that PWM will control. This needs to happen
- * after setting the control register, because enabling the banks
- * resets the value to 0 (the short sleep prevents a race between the
- * chip resetting the value to 0 and our command).
+ * Only set the brightness after ~100 ms. Without this, LED may blink
+ * for a short duration, as the PWM sampler sometimes appears to be
+ * confused, and slowly dim from a large initial PWM input value.
*/
- usleep(100);
- ret |= lm3630a_write(LM3630A_REG_A_BRIGHTNESS, 0xff);
+ hook_call_deferred(&deferred_lm3630a_poweron_data, 100 * MSEC);
return ret;
}