From 0b3ee6dd15b31bfdfba4e96bc76bf6e949fa03c3 Mon Sep 17 00:00:00 2001 From: marcost2 Date: Sun, 25 May 2025 19:45:00 -0300 Subject: [PATCH] power: bq2597x_mmi_iio: Read cp_switch status * Commit c22b699 fixed the logic for the state machine, but inadvertently brought up an issue on Rhodep * Unlike with bq2598x, the cp_switch status is not propagated to the dicrete_turbo_charger sm * This causes much of the same issue we saw in Miami, as such propagate the switch status to the sm Change-Id: Ibc68c1c8746fddd85a23fa7b5cb053cbbcc5eeec --- drivers/power/bq2597x_mmi_iio/bq2597x_mmi_iio.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/power/bq2597x_mmi_iio/bq2597x_mmi_iio.c b/drivers/power/bq2597x_mmi_iio/bq2597x_mmi_iio.c index 51df178465ac..5ad8829b4abf 100644 --- a/drivers/power/bq2597x_mmi_iio/bq2597x_mmi_iio.c +++ b/drivers/power/bq2597x_mmi_iio/bq2597x_mmi_iio.c @@ -96,6 +96,7 @@ enum { #define BAT_THERM_FAULT_SHIFT 12 #define BUS_THERM_FAULT_SHIFT 13 #define DIE_THERM_FAULT_SHIFT 14 +#define CP_SWITCH_SHIFT 18 #define BAT_OVP_FAULT_MASK (1 << BAT_OVP_FAULT_SHIFT) #define BAT_OCP_FAULT_MASK (1 << BAT_OCP_FAULT_SHIFT) @@ -233,6 +234,8 @@ struct bq2597x { bool therm_shutdown_flag; bool therm_shutdown_stat; + bool cp_switch; + bool vbat_reg; bool ibat_reg; @@ -2045,7 +2048,8 @@ static int bq2597x_iio_read_raw(struct iio_dev *indio_dev, | (bq->bus_ocp_fault << BUS_OCP_FAULT_SHIFT) | (bq->bat_therm_fault << BAT_THERM_FAULT_SHIFT) | (bq->bus_therm_fault << BUS_THERM_FAULT_SHIFT) - | (bq->die_therm_fault << DIE_THERM_FAULT_SHIFT)); + | (bq->die_therm_fault << DIE_THERM_FAULT_SHIFT) + | (bq->cp_switch << CP_SWITCH_SHIFT)); break; default: @@ -2176,6 +2180,8 @@ static void bq2597x_check_alarm_status(struct bq2597x *bq) if (!ret && (stat & 0x02)) pr_err("Reg[0A]CONV_OCP = 0x%02X\n", stat); + bq->cp_switch = !!(stat & BQ2597X_CONV_SWITCHING_STAT_MASK); + mutex_unlock(&bq->data_lock); if (changed)