Re: [PATCH 2/3] phy: qcom: qmp-pcie: add current load vote/devote for PCIe PHY

Konrad Dybcio
2024-12-05T16:31:51Z

On 4.12.2024 11:52 AM, Ziyue Zhang wrote:
> On some platform (eg.qcs615), the current that phy consumes will exceed
> the maximum current the regulator can provide in LPM mode, leading to
> over current protection and system boot up stuck. Fix this issue by
> setting regulator load to an expected value getting from phy device tree
> node during init so that the regulator can scale up to HPM to allow a
> larger current load.
> This change will also set load to zero during deinit to let regulator
> scale down to LPM mode to reduce itself's power consumptionif PCIe
> suspend.
>
> Signed-off-by: Ziyue Zhang <quic_ziyuzhan@quicinc.com>
> ---
> drivers/phy/qualcomm/phy-qcom-qmp-pcie.c | 35 ++++++++++++++++++++++--
> 1 file changed, 33 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/phy/qualcomm/phy-qcom-qmp-pcie.c b/drivers/phy/qualcomm/phy-qcom-qmp-pcie.c
> index c8e39c147ba4..782d51ab5cf1 100644
> --- a/drivers/phy/qualcomm/phy-qcom-qmp-pcie.c
> +++ b/drivers/phy/qualcomm/phy-qcom-qmp-pcie.c
> @@ -39,6 +39,7 @@
> #include "phy-qcom-qmp-pcie-qhp.h"
>
> #define PHY_INIT_COMPLETE_TIMEOUT 10000
> +#define MAX_PROP_SIZE 32
>
> /* set of registers with offsets different per-PHY */
> enum qphy_reg_layout {
> @@ -2905,6 +2906,7 @@ struct qmp_pcie {
> struct reset_control_bulk_data *resets;
> struct reset_control *nocsr_reset;
> struct regulator_bulk_data *vregs;
> + u32 *max_current_load;
>
> struct phy *phy;
> int mode;
> @@ -4087,6 +4089,17 @@ static int qmp_pcie_init(struct phy *phy)
> const struct qmp_phy_cfg *cfg = qmp->cfg;
> int ret;
>
> + for (int i = 0; i < cfg->num_vregs; i++) {
> + if (qmp->max_current_load[i]) {
> + ret = regulator_set_load(qmp->vregs[i].consumer, qmp->max_current_load[i]);

I think it's better if we just put this info in the driver, like with
e.g. the DSI PHY

Konrad