Skip to content

Commit 0c4916a

Browse files
Nitin Rawatvinodkoul
authored andcommitted
phy: qcom-qmp-ufs: Add regulator load voting for UFS QMP PHY
On certain SoCs, power regulators are shared between the QMP UFS PHY and other IP blocks. To ensure proper operation, the regulator framework must be informed of the UFS PHY's load requirements. This is essential because the regulator's operating mode—whether Low Power or High Power—depends on the maximum expected load at any given time, which the regulator driver needs to manage accordingly. To support this, replace devm_regulator_bulk_get() with devm_regulator_bulk_get_const() and inline the qmp_ufs_vreg_init() function. additionally replace the array of regulator names with a bulk regulator data structure, and utilize the init_load_uA field provided by the regulator framework. This ensures that regulator_set_load() is automatically invoked before the first enable operation. Reviewed-by: Manivannan Sadhasivam <[email protected]> Reviewed-by: Dmitry Baryshkov <[email protected]> Signed-off-by: Nitin Rawat <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Vinod Koul <[email protected]>
1 parent 3840427 commit 0c4916a

File tree

1 file changed

+8
-21
lines changed

1 file changed

+8
-21
lines changed

drivers/phy/qualcomm/phy-qcom-qmp-ufs.c

Lines changed: 8 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1107,7 +1107,7 @@ struct qmp_phy_cfg {
11071107
const struct qmp_phy_cfg_tbls tbls_hs_overlay[NUM_OVERLAY];
11081108

11091109
/* regulators to be requested */
1110-
const char * const *vreg_list;
1110+
const struct regulator_bulk_data *vreg_list;
11111111
int num_vregs;
11121112

11131113
/* array of registers with different offsets */
@@ -1164,9 +1164,10 @@ static inline void qphy_clrbits(void __iomem *base, u32 offset, u32 val)
11641164
readl(base + offset);
11651165
}
11661166

1167-
/* list of regulators */
1168-
static const char * const qmp_phy_vreg_l[] = {
1169-
"vdda-phy", "vdda-pll",
1167+
/* Default regulator bulk data (no load used) */
1168+
static const struct regulator_bulk_data qmp_phy_vreg_l[] = {
1169+
{ .supply = "vdda-phy" },
1170+
{ .supply = "vdda-pll" },
11701171
};
11711172

11721173
static const struct qmp_ufs_offsets qmp_ufs_offsets = {
@@ -1890,22 +1891,6 @@ static const struct phy_ops qcom_qmp_ufs_phy_ops = {
18901891
.owner = THIS_MODULE,
18911892
};
18921893

1893-
static int qmp_ufs_vreg_init(struct qmp_ufs *qmp)
1894-
{
1895-
const struct qmp_phy_cfg *cfg = qmp->cfg;
1896-
struct device *dev = qmp->dev;
1897-
int num = cfg->num_vregs;
1898-
int i;
1899-
1900-
qmp->vregs = devm_kcalloc(dev, num, sizeof(*qmp->vregs), GFP_KERNEL);
1901-
if (!qmp->vregs)
1902-
return -ENOMEM;
1903-
1904-
for (i = 0; i < num; i++)
1905-
qmp->vregs[i].supply = cfg->vreg_list[i];
1906-
1907-
return devm_regulator_bulk_get(dev, num, qmp->vregs);
1908-
}
19091894

19101895
static int qmp_ufs_clk_init(struct qmp_ufs *qmp)
19111896
{
@@ -2068,7 +2053,9 @@ static int qmp_ufs_probe(struct platform_device *pdev)
20682053
if (ret)
20692054
return ret;
20702055

2071-
ret = qmp_ufs_vreg_init(qmp);
2056+
ret = devm_regulator_bulk_get_const(dev, qmp->cfg->num_vregs,
2057+
qmp->cfg->vreg_list,
2058+
&qmp->vregs);
20722059
if (ret)
20732060
return ret;
20742061

0 commit comments

Comments
 (0)