diff options
author | Yilun Lin <yllin@google.com> | 2019-05-30 14:10:51 +0800 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2019-06-17 04:57:53 +0000 |
commit | 4c69831f59ad7fd335c9c8e0dc3dc5bb5f5eebda (patch) | |
tree | e956fafb56a99264e3f8232b19ebefbd395bb9c8 | |
parent | 470a9586fd8d897a847e52a65debc00001c1d565 (diff) | |
download | chrome-ec-4c69831f59ad7fd335c9c8e0dc3dc5bb5f5eebda.tar.gz |
rt946x: Add API for backlight LED dim.
Add mt6370_backlight_set_dim() for setting backlight LED dim.
TEST=None
BUG=b:133655155
BRANCH=None
Change-Id: Ia5b80734f72c6fb8750c33f62133fc1cdd71f213
Signed-off-by: Yilun Lin <yllin@google.com>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1635137
Tested-by: Yilun Lin <yllin@chromium.org>
Commit-Queue: Yilun Lin <yllin@chromium.org>
Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
Auto-Submit: Yilun Lin <yllin@chromium.org>
-rw-r--r-- | driver/charger/rt946x.c | 18 | ||||
-rw-r--r-- | driver/charger/rt946x.h | 18 |
2 files changed, 36 insertions, 0 deletions
diff --git a/driver/charger/rt946x.c b/driver/charger/rt946x.c index 3d5722ae09..d38690892a 100644 --- a/driver/charger/rt946x.c +++ b/driver/charger/rt946x.c @@ -1114,6 +1114,24 @@ int mt6370_db_set_voltages(int vbst, int vpos, int vneg) return rv; } +/* MT6370 BACKLIGHT LED */ + +int mt6370_backlight_set_dim(uint16_t dim) +{ + int rv; + + /* datasheet suggests that update BLDIM2 first then BLDIM */ + rv = rt946x_write8(MT6370_BACKLIGHT_BLDIM2, dim & MT6370_MASK_BLDIM2); + + if (rv) + return rv; + + rv = rt946x_write8(MT6370_BACKLIGHT_BLDIM, + (dim >> MT6370_SHIFT_BLDIM_MSB) & MT6370_MASK_BLDIM); + + return rv; +} + /* MT6370 RGB LED */ int mt6370_led_set_dim_mode(enum mt6370_led_index index, diff --git a/driver/charger/rt946x.h b/driver/charger/rt946x.h index ee35fae901..d9ec30a596 100644 --- a/driver/charger/rt946x.h +++ b/driver/charger/rt946x.h @@ -138,6 +138,7 @@ /* backlight */ #define MT6370_BACKLIGHT_BLEN 0xA0 #define MT6370_BACKLIGHT_BLPWM 0xA2 +#define MT6370_BACKLIGHT_BLDIM2 0xA4 #define MT6370_BACKLIGHT_BLDIM 0xA5 /* Display bias */ @@ -558,6 +559,15 @@ #define MT6370_MASK_BLPWM_BLED_PWM BIT(MT6370_SHIFT_BLPWM_BLED_PWM) +/* ========== BLDIM2 0xA4 (mt6370) ============ */ +#define MT6370_MASK_BLDIM2 0x7 + +/* ========== BLDIM 0xA5 (mt6370) ============ */ +#define MT6370_SHIFT_BLDIM_MSB 3 +#define MT6370_MASK_BLDIM 0xff + +#define MT6370_BLDIM_DEFAULT 0x7ff + /* ========== CHGSTAT2 0xD1 (mt6370) ============ */ #ifdef CONFIG_CHARGER_MT6370 #define MT6370_SHIFT_CHG_VBUSOV_STAT 7 @@ -668,6 +678,14 @@ enum mt6370_led_pwm_freq { int mt6370_db_external_control(int en); /** + * Set backlight LED dim. + * + * dim: A value from 0 to 2047. + * return: EC_SUCCESS on success, and EC_ERROR_* otherwise. + */ +int mt6370_backlight_set_dim(uint16_t dim); + +/** * MT6370 display bias voltage settings. * * Set disaply bias voltages for the panel. |