diff options
author | Yilun Lin <yllin@google.com> | 2019-05-15 18:37:26 +0800 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2019-06-03 01:11:05 -0700 |
commit | b18ea4eb30e9279c12a1962dc494429863e7363f (patch) | |
tree | 3e732281999f6a1102b2dee457fcbc19de9efe8e /driver | |
parent | 49436b18d2a77b994fe76d8c2f070000e2cdb58a (diff) | |
download | chrome-ec-b18ea4eb30e9279c12a1962dc494429863e7363f.tar.gz |
charger/rt946x: Add display bias API mt6370_db_set_voltages.
Add mt6370_db_set_voltages to control VBST, VPOS, and VNEG.
TEST=Test with CL:1632132 on krane:
i2cxfer r 0 0x68 0xb1; see output 0x36
i2cxfer r 0 0x68 0xb2; see output 0x68
i2cxfer r 0 0x68 0xb3; see output 0x64
i2cxfer r 0 0x68 0xb4; see output 0x64
BUG=b:125644770
BRANCH=None
Change-Id: Ia66ba91a2af3a651a71195dd8a2d531bf1ba06e9
Signed-off-by: Yilun Lin <yllin@google.com>
Reviewed-on: https://chromium-review.googlesource.com/1613257
Commit-Ready: Yilun Lin <yllin@chromium.org>
Tested-by: Yilun Lin <yllin@chromium.org>
Legacy-Commit-Queue: Commit Bot <commit-bot@chromium.org>
Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
Diffstat (limited to 'driver')
-rw-r--r-- | driver/charger/rt946x.c | 31 | ||||
-rw-r--r-- | driver/charger/rt946x.h | 57 |
2 files changed, 84 insertions, 4 deletions
diff --git a/driver/charger/rt946x.c b/driver/charger/rt946x.c index 226b4b4d0a..d3d9309129 100644 --- a/driver/charger/rt946x.c +++ b/driver/charger/rt946x.c @@ -1059,6 +1059,37 @@ int mt6370_db_external_control(int en) en << MT6370_SHIFT_DB_EXT_EN); } +int mt6370_db_set_voltages(int vbst, int vpos, int vneg) +{ + int rv; + + /* set display bias VBST */ + rv = rt946x_update_bits(MT6370_REG_DBVBST, MT6370_MASK_DB_VBST, + rt946x_closest_reg(MT6370_DB_VBST_MIN, + MT6370_DB_VBST_MAX, + MT6370_DB_VBST_STEP, vbst)); + + /* set display bias VPOS */ + rv |= rt946x_update_bits(MT6370_REG_DBVPOS, MT6370_MASK_DB_VPOS, + rt946x_closest_reg(MT6370_DB_VPOS_MIN, + MT6370_DB_VPOS_MAX, + MT6370_DB_VPOS_STEP, vpos)); + + /* set display bias VNEG */ + rv |= rt946x_update_bits(MT6370_REG_DBVNEG, MT6370_MASK_DB_VNEG, + rt946x_closest_reg(MT6370_DB_VNEG_MIN, + MT6370_DB_VNEG_MAX, + MT6370_DB_VNEG_STEP, vneg)); + + /* Enable VNEG/VPOS discharge when VNEG/VPOS rails disabled. */ + rv |= rt946x_update_bits( + MT6370_REG_DBCTRL2, + MT6370_MASK_DB_VNEG_DISC | MT6370_MASK_DB_VPOS_DISC, + MT6370_MASK_DB_VNEG_DISC | MT6370_MASK_DB_VPOS_DISC); + + 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 aad6d74032..2b8c50ce19 100644 --- a/driver/charger/rt946x.h +++ b/driver/charger/rt946x.h @@ -135,14 +135,20 @@ #define MT6370_REG_RGBCHRINDDIM 0x92 #define MT6370_REG_RGBCHRINDCTRL 0x93 -/* Display bias */ -#define MT6370_REG_DBCTRL1 0XB0 - -#define RT946X_REG_DPDMIRQ 0xC6 /* backlight */ #define MT6370_BACKLIGHT_BLEN 0xA0 #define MT6370_BACKLIGHT_BLPWM 0xA2 #define MT6370_BACKLIGHT_BLDIM 0xA5 + +/* Display bias */ +#define MT6370_REG_DBCTRL1 0XB0 +#define MT6370_REG_DBCTRL2 0XB1 +#define MT6370_REG_DBVBST 0XB2 +#define MT6370_REG_DBVPOS 0XB3 +#define MT6370_REG_DBVNEG 0XB4 + +#define RT946X_REG_DPDMIRQ 0xC6 + /* status event */ #define MT6370_REG_CHGSTAT1 0xD0 #define RT946X_REG_CHGSTATC MT6370_REG_CHGSTAT1 @@ -493,6 +499,37 @@ #define MT6370_MASK_DB_FREQ_PM 1 #define MT6370_MASK_DB_PERIODIC_MODE 1 +/* ========== DBCTRL1 (mt6370) ============ */ +#define MT6370_MASK_DB_VNEG_DISC BIT(2) +#define MT6370_MASK_DB_VPOS_DISC BIT(5) + +/* ========== DBVBST (mt6370) ============ */ +#define MT6370_SHIFT_DB_VBST 0 + +#define MT6370_MASK_DB_VBST 0x3f + +#define MT6370_DB_VBST_MAX 6200 +#define MT6370_DB_VBST_MIN 4000 +#define MT6370_DB_VBST_STEP 50 + +/* ========== DBVPOS (mt6370) ============ */ +#define MT6370_SHIFT_DB_VPOS 0 + +#define MT6370_MASK_DB_VPOS 0x3f + +#define MT6370_DB_VPOS_MAX 6000 +#define MT6370_DB_VPOS_MIN 4000 +#define MT6370_DB_VPOS_STEP 50 + +/* ========== DBVNEG (mt6370) ============ */ +#define MT6370_SHIFT_DB_VNEG 0 + +#define MT6370_MASK_DB_VNEG 0x3f + +#define MT6370_DB_VNEG_MAX 6000 +#define MT6370_DB_VNEG_MIN 4000 +#define MT6370_DB_VNEG_STEP 50 + /* ========== BLEN 0xA0 (mt6370) ============ */ #define MT6370_SHIFT_BLED_EXT_EN 7 #define MT6370_SHIFT_BLED_EN 6 @@ -623,6 +660,18 @@ enum mt6370_led_pwm_freq { /* Enable display bias external pin control. */ int mt6370_db_external_control(int en); +/** + * MT6370 display bias voltage settings. + * + * Set disaply bias voltages for the panel. + * + * vbst: VBST config in mv. + * vpos: VPOS config in mv. + * vneg: VNEG config in mv. + * return: EC_SUCCESS on succes, and EC_ERROR_* otherwise. + */ +int mt6370_db_set_voltages(int vbst, int vpos, int vneg); + /* Set LED brightness */ int mt6370_led_set_brightness(enum mt6370_led_index index, uint8_t brightness); |