build/patch/kernel/archive/sunxi-6.5/patches.megous/power-supply-rk818-battery-Don-t-auto-poweroff-the-PMIC-on-low-.patch

64 lines
2.3 KiB
Diff
Raw Normal View History

From 28f809db46f0f76be52826ec2907ada0bfe6b7f2 Mon Sep 17 00:00:00 2001
From: Ondrej Jirman <megi@xff.cz>
Date: Thu, 10 Nov 2022 20:03:47 +0100
Subject: [PATCH 327/464] power: supply: rk818-battery: Don't auto-poweroff the
PMIC on low battery
Just raise the interrupt. This avoids undervoltage shutdowns when
unplugging the USB PSU from USB keyboard. IP5209 stop supplying power
to VOUT during transition from pass-through mode until VOUT boost
is enabled. (about 30ms on the oscilloscope)
Somehow RK818 doesn't like this when EN_VABT_LOW_SHUT_DOWN is enabled
and PMIC shuts down. Emergency shutdown is implemented in keyboard
power manager driver.
Signed-off-by: Ondrej Jirman <megi@xff.cz>
---
drivers/power/supply/rk818_battery.c | 15 +++++++++------
1 file changed, 9 insertions(+), 6 deletions(-)
diff --git a/drivers/power/supply/rk818_battery.c b/drivers/power/supply/rk818_battery.c
index 9323666491db..e3d04a51e145 100644
--- a/drivers/power/supply/rk818_battery.c
+++ b/drivers/power/supply/rk818_battery.c
@@ -3021,6 +3021,7 @@ static void rk818_bat_set_shtd_vol(struct rk818_battery *di)
{
u8 val;
+#if 0
/* set vbat lowest 3.0v shutdown */
val = rk818_bat_read(di, RK818_VB_MON_REG);
val &= ~(VBAT_LOW_VOL_MASK | VBAT_LOW_ACT_MASK);
@@ -3030,6 +3031,13 @@ static void rk818_bat_set_shtd_vol(struct rk818_battery *di)
/* disable low irq */
rk818_bat_set_bits(di, RK818_INT_STS_MSK_REG1,
VB_LOW_INT_EN, VB_LOW_INT_EN);
+#endif
+
+ val = rk818_bat_read(di, RK818_VB_MON_REG);
+ val &= (~(VBAT_LOW_VOL_MASK | VBAT_LOW_ACT_MASK));
+ val |= (RK818_VBAT_LOW_3V4 | EN_VBAT_LOW_IRQ);
+ rk818_bat_write(di, RK818_VB_MON_REG, val);
+ rk818_bat_set_bits(di, RK818_INT_STS_MSK_REG1, VB_LOW_INT_EN, 0);
}
static void rk818_bat_init_fg(struct rk818_battery *di)
@@ -3430,12 +3438,7 @@ static int rk818_battery_resume(struct platform_device *dev)
rk818_bat_save_data(di);
/* set vbat lowest 3.0v shutdown */
- val = rk818_bat_read(di, RK818_VB_MON_REG);
- val &= ~(VBAT_LOW_VOL_MASK | VBAT_LOW_ACT_MASK);
- val |= (RK818_VBAT_LOW_3V0 | EN_VABT_LOW_SHUT_DOWN);
- rk818_bat_write(di, RK818_VB_MON_REG, val);
- rk818_bat_set_bits(di, RK818_INT_STS_MSK_REG1,
- VB_LOW_INT_EN, VB_LOW_INT_EN);
+ rk818_bat_set_shtd_vol(di);
/* charge/lowpower lock: for battery work to update dsoc and rsoc */
// if ((di->sleep_chrg_online) ||
--
2.34.1