Commit 1de24861 authored by Dmitry Baryshkov's avatar Dmitry Baryshkov Committed by Vinod Koul

phy: qcom-qmp-combo: use bulk reset_control API

Switch qcom-qmp-combo driver to use reset_control_bulk_assert / _deassert
functions rather than hardcoding the loops in the driver itself.
Acked-by: default avatarBjorn Andersson <bjorn.andersson@linaro.org>
Tested-by: Bjorn Andersson <bjorn.andersson@linaro.org> # UFS, PCIe and USB on SC8180X
Signed-off-by: default avatarDmitry Baryshkov <dmitry.baryshkov@linaro.org>
Link: https://lore.kernel.org/r/20220607213203.2819885-28-dmitry.baryshkov@linaro.orgSigned-off-by: default avatarVinod Koul <vkoul@kernel.org>
parent 65753f38
...@@ -741,7 +741,7 @@ struct qcom_qmp { ...@@ -741,7 +741,7 @@ struct qcom_qmp {
void __iomem *dp_com; void __iomem *dp_com;
struct clk_bulk_data *clks; struct clk_bulk_data *clks;
struct reset_control **resets; struct reset_control_bulk_data *resets;
struct regulator_bulk_data *vregs; struct regulator_bulk_data *vregs;
struct qmp_phy **phys; struct qmp_phy **phys;
...@@ -1586,7 +1586,7 @@ static int qcom_qmp_phy_combo_com_init(struct qmp_phy *qphy) ...@@ -1586,7 +1586,7 @@ static int qcom_qmp_phy_combo_com_init(struct qmp_phy *qphy)
const struct qmp_phy_cfg *cfg = qphy->cfg; const struct qmp_phy_cfg *cfg = qphy->cfg;
void __iomem *pcs = qphy->pcs; void __iomem *pcs = qphy->pcs;
void __iomem *dp_com = qmp->dp_com; void __iomem *dp_com = qmp->dp_com;
int ret, i; int ret;
mutex_lock(&qmp->phy_mutex); mutex_lock(&qmp->phy_mutex);
if (qmp->init_count++) { if (qmp->init_count++) {
...@@ -1601,22 +1601,16 @@ static int qcom_qmp_phy_combo_com_init(struct qmp_phy *qphy) ...@@ -1601,22 +1601,16 @@ static int qcom_qmp_phy_combo_com_init(struct qmp_phy *qphy)
goto err_unlock; goto err_unlock;
} }
for (i = 0; i < cfg->num_resets; i++) { ret = reset_control_bulk_assert(cfg->num_resets, qmp->resets);
ret = reset_control_assert(qmp->resets[i]);
if (ret) { if (ret) {
dev_err(qmp->dev, "%s reset assert failed\n", dev_err(qmp->dev, "reset assert failed\n");
cfg->reset_list[i]);
goto err_disable_regulators; goto err_disable_regulators;
} }
}
for (i = cfg->num_resets - 1; i >= 0; i--) { ret = reset_control_bulk_deassert(cfg->num_resets, qmp->resets);
ret = reset_control_deassert(qmp->resets[i]);
if (ret) { if (ret) {
dev_err(qmp->dev, "%s reset deassert failed\n", dev_err(qmp->dev, "reset deassert failed\n");
qphy->cfg->reset_list[i]); goto err_disable_regulators;
goto err_assert_reset;
}
} }
ret = clk_bulk_prepare_enable(cfg->num_clks, qmp->clks); ret = clk_bulk_prepare_enable(cfg->num_clks, qmp->clks);
...@@ -1659,8 +1653,7 @@ static int qcom_qmp_phy_combo_com_init(struct qmp_phy *qphy) ...@@ -1659,8 +1653,7 @@ static int qcom_qmp_phy_combo_com_init(struct qmp_phy *qphy)
return 0; return 0;
err_assert_reset: err_assert_reset:
while (++i < cfg->num_resets) reset_control_bulk_assert(cfg->num_resets, qmp->resets);
reset_control_assert(qmp->resets[i]);
err_disable_regulators: err_disable_regulators:
regulator_bulk_disable(cfg->num_vregs, qmp->vregs); regulator_bulk_disable(cfg->num_vregs, qmp->vregs);
err_unlock: err_unlock:
...@@ -1673,7 +1666,6 @@ static int qcom_qmp_phy_combo_com_exit(struct qmp_phy *qphy) ...@@ -1673,7 +1666,6 @@ static int qcom_qmp_phy_combo_com_exit(struct qmp_phy *qphy)
{ {
struct qcom_qmp *qmp = qphy->qmp; struct qcom_qmp *qmp = qphy->qmp;
const struct qmp_phy_cfg *cfg = qphy->cfg; const struct qmp_phy_cfg *cfg = qphy->cfg;
int i = cfg->num_resets;
mutex_lock(&qmp->phy_mutex); mutex_lock(&qmp->phy_mutex);
if (--qmp->init_count) { if (--qmp->init_count) {
...@@ -1683,8 +1675,7 @@ static int qcom_qmp_phy_combo_com_exit(struct qmp_phy *qphy) ...@@ -1683,8 +1675,7 @@ static int qcom_qmp_phy_combo_com_exit(struct qmp_phy *qphy)
reset_control_assert(qmp->ufs_reset); reset_control_assert(qmp->ufs_reset);
while (--i >= 0) reset_control_bulk_assert(cfg->num_resets, qmp->resets);
reset_control_assert(qmp->resets[i]);
clk_bulk_disable_unprepare(cfg->num_clks, qmp->clks); clk_bulk_disable_unprepare(cfg->num_clks, qmp->clks);
...@@ -1994,23 +1985,19 @@ static int qcom_qmp_phy_combo_reset_init(struct device *dev, const struct qmp_ph ...@@ -1994,23 +1985,19 @@ static int qcom_qmp_phy_combo_reset_init(struct device *dev, const struct qmp_ph
{ {
struct qcom_qmp *qmp = dev_get_drvdata(dev); struct qcom_qmp *qmp = dev_get_drvdata(dev);
int i; int i;
int ret;
qmp->resets = devm_kcalloc(dev, cfg->num_resets, qmp->resets = devm_kcalloc(dev, cfg->num_resets,
sizeof(*qmp->resets), GFP_KERNEL); sizeof(*qmp->resets), GFP_KERNEL);
if (!qmp->resets) if (!qmp->resets)
return -ENOMEM; return -ENOMEM;
for (i = 0; i < cfg->num_resets; i++) { for (i = 0; i < cfg->num_resets; i++)
struct reset_control *rst; qmp->resets[i].id = cfg->reset_list[i];
const char *name = cfg->reset_list[i];
rst = devm_reset_control_get_exclusive(dev, name); ret = devm_reset_control_bulk_get_exclusive(dev, cfg->num_resets, qmp->resets);
if (IS_ERR(rst)) { if (ret)
dev_err(dev, "failed to get %s reset\n", name); return dev_err_probe(dev, ret, "failed to get resets\n");
return PTR_ERR(rst);
}
qmp->resets[i] = rst;
}
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment