diff --git a/drivers/power/supply/qcom/smb5-iio.c b/drivers/power/supply/qcom/smb5-iio.c index 62eeafd92b66..c3cdd4416588 100644 --- a/drivers/power/supply/qcom/smb5-iio.c +++ b/drivers/power/supply/qcom/smb5-iio.c @@ -314,10 +314,14 @@ int smb5_iio_set_prop(struct smb_charger *chg, int channel, int val) rc = smblib_set_prop_pr_swap_in_progress(chg, val); break; case PSY_IIO_PD_VOLTAGE_MAX: +#ifdef QCOM_BASE rc = smblib_set_prop_pd_voltage_max(chg, val); +#endif break; case PSY_IIO_PD_VOLTAGE_MIN: +#ifdef QCOM_BASE rc = smblib_set_prop_pd_voltage_min(chg, val); +#endif break; case PSY_IIO_CONNECTOR_HEALTH: chg->connector_health = val; diff --git a/drivers/power/supply/qcom/smb5-lib.c b/drivers/power/supply/qcom/smb5-lib.c index eab526c66c0a..1446086625c4 100644 --- a/drivers/power/supply/qcom/smb5-lib.c +++ b/drivers/power/supply/qcom/smb5-lib.c @@ -7401,6 +7401,23 @@ static void smblib_pd_contract_work(struct work_struct *work) if (!chg->pd || !chg->pd_active) return; + if (!chg->pd_voltage_max_uv) { + rc = of_property_read_u32(chg->dev->of_node, + "qcom,pd-voltage-max-uv", + &chg->pd_voltage_max_uv); + if (rc < 0) { + chg->pd_voltage_max_uv = MICRO_5V; + smblib_err(chg, "Failed to get pd_voltage_max_uv" + "from device tree, rc = %d\n", rc); + } + + if (chg->pd_voltage_max_uv < MICRO_5V) + chg->pd_voltage_max_uv = MICRO_5V; + else if (chg->pd_voltage_max_uv > MICRO_12V) + chg->pd_voltage_max_uv = MICRO_12V; + } + chg->voltage_max_uv = chg->pd_voltage_max_uv; + chg->pd_contract_uv = usbpd_select_pdo_match(chg->pd); if (chg->pd_contract_uv == -ENOTSUPP) diff --git a/drivers/power/supply/qcom/smb5-lib.h b/drivers/power/supply/qcom/smb5-lib.h index 1ab71148c767..48df4a16c97c 100644 --- a/drivers/power/supply/qcom/smb5-lib.h +++ b/drivers/power/supply/qcom/smb5-lib.h @@ -613,6 +613,7 @@ struct smb_charger { /* USB PD interactions */ struct usbpd *pd; int pd_contract_uv; + int pd_voltage_max_uv; struct delayed_work pd_contract_work; /* battery profile */