From: Casey Connolly Date: Thu, 8 Jan 2026 20:28:48 +0000 (+0100) Subject: power: regulator: qcom-rpmh: correctly map pmic mode X-Git-Tag: v2026.04-rc1~31^2~5 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=deb2b9c4033b5c3cc684ca62c79db61a7ca3d199;p=thirdparty%2Fu-boot.git power: regulator: qcom-rpmh: correctly map pmic mode Currently we don't properly map between the regulator mode ID enum and the appropriate register values in the mode map, as a result we always unintentionally vote for retention mode if we actually attempt to set it. In the set_mode path we did find the appropriate entry in the mode map but we wrote the id instead of the register values. Clean this up and properly map id -> mode and vice versa. Link: https://patch.msgid.link/20260108-rpmh-regulator-fixes-v1-6-d1b5b300b665@linaro.org Signed-off-by: Casey Connolly --- diff --git a/drivers/power/regulator/qcom-rpmh-regulator.c b/drivers/power/regulator/qcom-rpmh-regulator.c index cabdf089819..3f0f1845469 100644 --- a/drivers/power/regulator/qcom-rpmh-regulator.c +++ b/drivers/power/regulator/qcom-rpmh-regulator.c @@ -369,9 +369,11 @@ static int rpmh_regulator_vrm_set_mode_bypass(struct rpmh_vreg *vreg, } if (bypassed) - cmd.data = PMIC4_BOB_MODE_PASS; + // XXX: should have a version check for PMIC4 but we don't have any yet + // and we don't use bypass mode + cmd.data = PMIC5_BOB_MODE_PASS; else - cmd.data = pmic_mode->id; + cmd.data = pmic_mode->register_value; return rpmh_regulator_send_request(vreg, &cmd, true); } @@ -399,15 +401,23 @@ static int rpmh_regulator_vrm_get_pmic_mode(struct rpmh_vreg *vreg, int *pmic_mo struct tcs_cmd cmd = { .addr = vreg->addr + RPMH_REGULATOR_REG_VRM_MODE, }; - int ret; + struct dm_regulator_mode *pmic_mode_map = vreg->hw_data->pmic_mode_map; + int ret, register_value; ret = rpmh_regulator_read_data(vreg, &cmd); if (!ret) - *pmic_mode = cmd.data & RPMH_REGULATOR_MODE_MASK; + register_value = cmd.data & RPMH_REGULATOR_MODE_MASK; else return -EINVAL; - return 0; + for (int i = 0; i < vreg->hw_data->n_modes; i++) { + if (pmic_mode_map[i].register_value == register_value) { + *pmic_mode = pmic_mode_map[i].id; + return 0; + } + } + + return -EINVAL; } static int rpmh_regulator_vrm_get_mode(struct udevice *rdev)