summaryrefslogtreecommitdiff
path: root/driver/charger
diff options
context:
space:
mode:
Diffstat (limited to 'driver/charger')
-rw-r--r--driver/charger/rt946x.c18
-rw-r--r--driver/charger/rt946x.h18
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.