Skip to content

Commit 5f71b1e

Browse files
Chunfeng Yunvinodkoul
authored andcommitted
phy: phy-mtk-ufs: use clock bulk to get clocks
Use clock bulk helpers to get/enable/disable clocks Reviewed-by: Stanley Chu <[email protected]> Signed-off-by: Chunfeng Yun <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Vinod Koul <[email protected]>
1 parent 1c6de3f commit 5f71b1e

File tree

1 file changed

+11
-33
lines changed

1 file changed

+11
-33
lines changed

drivers/phy/mediatek/phy-mtk-ufs.c

Lines changed: 11 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,12 @@
3131
#define FRC_CDR_ISO_EN BIT(19)
3232
#define CDR_ISO_EN BIT(20)
3333

34+
#define UFSPHY_CLKS_CNT 2
35+
3436
struct ufs_mtk_phy {
3537
struct device *dev;
3638
void __iomem *mmio;
37-
struct clk *mp_clk;
38-
struct clk *unipro_clk;
39+
struct clk_bulk_data clks[UFSPHY_CLKS_CNT];
3940
};
4041

4142
static inline u32 mphy_readl(struct ufs_mtk_phy *phy, u32 reg)
@@ -74,20 +75,11 @@ static struct ufs_mtk_phy *get_ufs_mtk_phy(struct phy *generic_phy)
7475
static int ufs_mtk_phy_clk_init(struct ufs_mtk_phy *phy)
7576
{
7677
struct device *dev = phy->dev;
78+
struct clk_bulk_data *clks = phy->clks;
7779

78-
phy->unipro_clk = devm_clk_get(dev, "unipro");
79-
if (IS_ERR(phy->unipro_clk)) {
80-
dev_err(dev, "failed to get clock: unipro");
81-
return PTR_ERR(phy->unipro_clk);
82-
}
83-
84-
phy->mp_clk = devm_clk_get(dev, "mp");
85-
if (IS_ERR(phy->mp_clk)) {
86-
dev_err(dev, "failed to get clock: mp");
87-
return PTR_ERR(phy->mp_clk);
88-
}
89-
90-
return 0;
80+
clks[0].id = "unipro";
81+
clks[1].id = "mp";
82+
return devm_clk_bulk_get(dev, UFSPHY_CLKS_CNT, clks);
9183
}
9284

9385
static void ufs_mtk_phy_set_active(struct ufs_mtk_phy *phy)
@@ -150,26 +142,13 @@ static int ufs_mtk_phy_power_on(struct phy *generic_phy)
150142
struct ufs_mtk_phy *phy = get_ufs_mtk_phy(generic_phy);
151143
int ret;
152144

153-
ret = clk_prepare_enable(phy->unipro_clk);
154-
if (ret) {
155-
dev_err(phy->dev, "unipro_clk enable failed %d\n", ret);
156-
goto out;
157-
}
158-
159-
ret = clk_prepare_enable(phy->mp_clk);
160-
if (ret) {
161-
dev_err(phy->dev, "mp_clk enable failed %d\n", ret);
162-
goto out_unprepare_unipro_clk;
163-
}
145+
ret = clk_bulk_prepare_enable(UFSPHY_CLKS_CNT, phy->clks);
146+
if (ret)
147+
return ret;
164148

165149
ufs_mtk_phy_set_active(phy);
166150

167151
return 0;
168-
169-
out_unprepare_unipro_clk:
170-
clk_disable_unprepare(phy->unipro_clk);
171-
out:
172-
return ret;
173152
}
174153

175154
static int ufs_mtk_phy_power_off(struct phy *generic_phy)
@@ -178,8 +157,7 @@ static int ufs_mtk_phy_power_off(struct phy *generic_phy)
178157

179158
ufs_mtk_phy_set_deep_hibern(phy);
180159

181-
clk_disable_unprepare(phy->unipro_clk);
182-
clk_disable_unprepare(phy->mp_clk);
160+
clk_bulk_disable_unprepare(UFSPHY_CLKS_CNT, phy->clks);
183161

184162
return 0;
185163
}

0 commit comments

Comments
 (0)