diff options
author | Kishon Vijay Abraham I <kishon@ti.com> | 2022-01-28 13:41:31 +0530 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2022-02-08 11:00:03 -0500 |
commit | a9382b07d0962a4826b069bde92407e71dc79253 (patch) | |
tree | c6c0a37fbeb8169ae95e2fe25019d0f56e6b5873 | |
parent | 432286c48d06314a90cdc98b2fea1e77f3379bb9 (diff) | |
download | u-boot-a9382b07d0962a4826b069bde92407e71dc79253.tar.gz u-boot-a9382b07d0962a4826b069bde92407e71dc79253.tar.bz2 u-boot-a9382b07d0962a4826b069bde92407e71dc79253.zip |
phy: cadence: Sierra: Move all clk_get_*() to a separate function
No functional change. Group all devm_clk_get_optional() to a
separate function.
Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
Signed-off-by: Aswath Govindraju <a-govindraju@ti.com>
-rw-r--r-- | drivers/phy/cadence/phy-cadence-sierra.c | 57 |
1 files changed, 35 insertions, 22 deletions
diff --git a/drivers/phy/cadence/phy-cadence-sierra.c b/drivers/phy/cadence/phy-cadence-sierra.c index 45d6d6a796..d07cf1d97d 100644 --- a/drivers/phy/cadence/phy-cadence-sierra.c +++ b/drivers/phy/cadence/phy-cadence-sierra.c @@ -448,13 +448,44 @@ static int cdns_regmap_init_blocks(struct cdns_sierra_phy *sp, return 0; } +static int cdns_sierra_phy_get_clocks(struct cdns_sierra_phy *sp, + struct udevice *dev) +{ + struct clk *clk; + int ret; + + clk = devm_clk_get_optional(dev, "phy_clk"); + if (IS_ERR(clk)) { + dev_err(dev, "failed to get clock phy_clk\n"); + return PTR_ERR(clk); + } + sp->clk = clk; + + clk = devm_clk_get_optional(dev, "cmn_refclk_dig_div"); + if (IS_ERR(clk)) { + dev_err(dev, "cmn_refclk_dig_div clock not found\n"); + ret = PTR_ERR(clk); + return ret; + } + sp->cmn_refclk = clk; + + clk = devm_clk_get_optional(dev, "cmn_refclk1_dig_div"); + if (IS_ERR(clk)) { + dev_err(dev, "cmn_refclk1_dig_div clock not found\n"); + ret = PTR_ERR(clk); + return ret; + } + sp->cmn_refclk1 = clk; + + return 0; +} + static int cdns_sierra_phy_probe(struct udevice *dev) { struct cdns_sierra_phy *sp = dev_get_priv(dev); struct cdns_sierra_data *data; unsigned int id_value; int ret, node = 0; - struct clk *clk; ofnode child; sp->dev = dev; @@ -479,11 +510,9 @@ static int cdns_sierra_phy_probe(struct udevice *dev) if (ret) return ret; - sp->clk = devm_clk_get_optional(dev, "phy_clk"); - if (IS_ERR(sp->clk)) { - dev_err(dev, "failed to get clock phy_clk\n"); - return PTR_ERR(sp->clk); - } + ret = cdns_sierra_phy_get_clocks(sp, dev); + if (ret) + return ret; sp->phy_rst = devm_reset_control_get(dev, "sierra_reset"); if (IS_ERR(sp->phy_rst)) { @@ -491,22 +520,6 @@ static int cdns_sierra_phy_probe(struct udevice *dev) return PTR_ERR(sp->phy_rst); } - clk = devm_clk_get_optional(dev, "cmn_refclk_dig_div"); - if (IS_ERR(clk)) { - dev_err(dev, "cmn_refclk clock not found\n"); - ret = PTR_ERR(clk); - return ret; - } - sp->cmn_refclk = clk; - - clk = devm_clk_get_optional(dev, "cmn_refclk1_dig_div"); - if (IS_ERR(clk)) { - dev_err(dev, "cmn_refclk1 clock not found\n"); - ret = PTR_ERR(clk); - return ret; - } - sp->cmn_refclk1 = clk; - ret = clk_prepare_enable(sp->clk); if (ret) return ret; |