18646d4dcSBai Ping // SPDX-License-Identifier: GPL-2.0 28646d4dcSBai Ping /* 38646d4dcSBai Ping * Copyright 2017-2018 NXP. 48646d4dcSBai Ping */ 58646d4dcSBai Ping 68646d4dcSBai Ping #include <linux/bitops.h> 78646d4dcSBai Ping #include <linux/clk-provider.h> 88646d4dcSBai Ping #include <linux/err.h> 98646d4dcSBai Ping #include <linux/io.h> 108646d4dcSBai Ping #include <linux/iopoll.h> 118646d4dcSBai Ping #include <linux/slab.h> 128646d4dcSBai Ping #include <linux/jiffies.h> 138646d4dcSBai Ping 148646d4dcSBai Ping #include "clk.h" 158646d4dcSBai Ping 168646d4dcSBai Ping #define GNRL_CTL 0x0 178646d4dcSBai Ping #define DIV_CTL 0x4 188646d4dcSBai Ping #define LOCK_STATUS BIT(31) 198646d4dcSBai Ping #define LOCK_SEL_MASK BIT(29) 208646d4dcSBai Ping #define CLKE_MASK BIT(11) 218646d4dcSBai Ping #define RST_MASK BIT(9) 228646d4dcSBai Ping #define BYPASS_MASK BIT(4) 238646d4dcSBai Ping #define MDIV_SHIFT 12 248646d4dcSBai Ping #define MDIV_MASK GENMASK(21, 12) 258646d4dcSBai Ping #define PDIV_SHIFT 4 268646d4dcSBai Ping #define PDIV_MASK GENMASK(9, 4) 278646d4dcSBai Ping #define SDIV_SHIFT 0 288646d4dcSBai Ping #define SDIV_MASK GENMASK(2, 0) 298646d4dcSBai Ping #define KDIV_SHIFT 0 308646d4dcSBai Ping #define KDIV_MASK GENMASK(15, 0) 318646d4dcSBai Ping 328646d4dcSBai Ping #define LOCK_TIMEOUT_US 10000 338646d4dcSBai Ping 348646d4dcSBai Ping struct clk_pll14xx { 358646d4dcSBai Ping struct clk_hw hw; 368646d4dcSBai Ping void __iomem *base; 378646d4dcSBai Ping enum imx_pll14xx_type type; 388646d4dcSBai Ping const struct imx_pll14xx_rate_table *rate_table; 398646d4dcSBai Ping int rate_count; 408646d4dcSBai Ping }; 418646d4dcSBai Ping 428646d4dcSBai Ping #define to_clk_pll14xx(_hw) container_of(_hw, struct clk_pll14xx, hw) 438646d4dcSBai Ping 448646d4dcSBai Ping static const struct imx_pll14xx_rate_table *imx_get_pll_settings( 458646d4dcSBai Ping struct clk_pll14xx *pll, unsigned long rate) 468646d4dcSBai Ping { 478646d4dcSBai Ping const struct imx_pll14xx_rate_table *rate_table = pll->rate_table; 488646d4dcSBai Ping int i; 498646d4dcSBai Ping 508646d4dcSBai Ping for (i = 0; i < pll->rate_count; i++) 518646d4dcSBai Ping if (rate == rate_table[i].rate) 528646d4dcSBai Ping return &rate_table[i]; 538646d4dcSBai Ping 548646d4dcSBai Ping return NULL; 558646d4dcSBai Ping } 568646d4dcSBai Ping 578646d4dcSBai Ping static long clk_pll14xx_round_rate(struct clk_hw *hw, unsigned long rate, 588646d4dcSBai Ping unsigned long *prate) 598646d4dcSBai Ping { 608646d4dcSBai Ping struct clk_pll14xx *pll = to_clk_pll14xx(hw); 618646d4dcSBai Ping const struct imx_pll14xx_rate_table *rate_table = pll->rate_table; 628646d4dcSBai Ping int i; 638646d4dcSBai Ping 648646d4dcSBai Ping /* Assumming rate_table is in descending order */ 658646d4dcSBai Ping for (i = 0; i < pll->rate_count; i++) 668646d4dcSBai Ping if (rate >= rate_table[i].rate) 678646d4dcSBai Ping return rate_table[i].rate; 688646d4dcSBai Ping 698646d4dcSBai Ping /* return minimum supported value */ 708646d4dcSBai Ping return rate_table[i - 1].rate; 718646d4dcSBai Ping } 728646d4dcSBai Ping 738646d4dcSBai Ping static unsigned long clk_pll1416x_recalc_rate(struct clk_hw *hw, 748646d4dcSBai Ping unsigned long parent_rate) 758646d4dcSBai Ping { 768646d4dcSBai Ping struct clk_pll14xx *pll = to_clk_pll14xx(hw); 778646d4dcSBai Ping u32 mdiv, pdiv, sdiv, pll_gnrl, pll_div; 788646d4dcSBai Ping u64 fvco = parent_rate; 798646d4dcSBai Ping 808646d4dcSBai Ping pll_gnrl = readl_relaxed(pll->base); 818646d4dcSBai Ping pll_div = readl_relaxed(pll->base + 4); 828646d4dcSBai Ping mdiv = (pll_div & MDIV_MASK) >> MDIV_SHIFT; 838646d4dcSBai Ping pdiv = (pll_div & PDIV_MASK) >> PDIV_SHIFT; 848646d4dcSBai Ping sdiv = (pll_div & SDIV_MASK) >> SDIV_SHIFT; 858646d4dcSBai Ping 868646d4dcSBai Ping fvco *= mdiv; 878646d4dcSBai Ping do_div(fvco, pdiv << sdiv); 888646d4dcSBai Ping 898646d4dcSBai Ping return fvco; 908646d4dcSBai Ping } 918646d4dcSBai Ping 928646d4dcSBai Ping static unsigned long clk_pll1443x_recalc_rate(struct clk_hw *hw, 938646d4dcSBai Ping unsigned long parent_rate) 948646d4dcSBai Ping { 958646d4dcSBai Ping struct clk_pll14xx *pll = to_clk_pll14xx(hw); 968646d4dcSBai Ping u32 mdiv, pdiv, sdiv, pll_gnrl, pll_div_ctl0, pll_div_ctl1; 978646d4dcSBai Ping short int kdiv; 988646d4dcSBai Ping u64 fvco = parent_rate; 998646d4dcSBai Ping 1008646d4dcSBai Ping pll_gnrl = readl_relaxed(pll->base); 1018646d4dcSBai Ping pll_div_ctl0 = readl_relaxed(pll->base + 4); 1028646d4dcSBai Ping pll_div_ctl1 = readl_relaxed(pll->base + 8); 1038646d4dcSBai Ping mdiv = (pll_div_ctl0 & MDIV_MASK) >> MDIV_SHIFT; 1048646d4dcSBai Ping pdiv = (pll_div_ctl0 & PDIV_MASK) >> PDIV_SHIFT; 1058646d4dcSBai Ping sdiv = (pll_div_ctl0 & SDIV_MASK) >> SDIV_SHIFT; 1068646d4dcSBai Ping kdiv = pll_div_ctl1 & KDIV_MASK; 1078646d4dcSBai Ping 1088646d4dcSBai Ping /* fvco = (m * 65536 + k) * Fin / (p * 65536) */ 1098646d4dcSBai Ping fvco *= (mdiv * 65536 + kdiv); 1108646d4dcSBai Ping pdiv *= 65536; 1118646d4dcSBai Ping 1128646d4dcSBai Ping do_div(fvco, pdiv << sdiv); 1138646d4dcSBai Ping 1148646d4dcSBai Ping return fvco; 1158646d4dcSBai Ping } 1168646d4dcSBai Ping 1178646d4dcSBai Ping static inline bool clk_pll1416x_mp_change(const struct imx_pll14xx_rate_table *rate, 1188646d4dcSBai Ping u32 pll_div) 1198646d4dcSBai Ping { 1208646d4dcSBai Ping u32 old_mdiv, old_pdiv; 1218646d4dcSBai Ping 1228646d4dcSBai Ping old_mdiv = (pll_div >> MDIV_SHIFT) & MDIV_MASK; 1238646d4dcSBai Ping old_pdiv = (pll_div >> PDIV_SHIFT) & PDIV_MASK; 1248646d4dcSBai Ping 1258646d4dcSBai Ping return rate->mdiv != old_mdiv || rate->pdiv != old_pdiv; 1268646d4dcSBai Ping } 1278646d4dcSBai Ping 1288646d4dcSBai Ping static inline bool clk_pll1443x_mpk_change(const struct imx_pll14xx_rate_table *rate, 1298646d4dcSBai Ping u32 pll_div_ctl0, u32 pll_div_ctl1) 1308646d4dcSBai Ping { 1318646d4dcSBai Ping u32 old_mdiv, old_pdiv, old_kdiv; 1328646d4dcSBai Ping 1338646d4dcSBai Ping old_mdiv = (pll_div_ctl0 >> MDIV_SHIFT) & MDIV_MASK; 1348646d4dcSBai Ping old_pdiv = (pll_div_ctl0 >> PDIV_SHIFT) & PDIV_MASK; 1358646d4dcSBai Ping old_kdiv = (pll_div_ctl1 >> KDIV_SHIFT) & KDIV_MASK; 1368646d4dcSBai Ping 1378646d4dcSBai Ping return rate->mdiv != old_mdiv || rate->pdiv != old_pdiv || 1388646d4dcSBai Ping rate->kdiv != old_kdiv; 1398646d4dcSBai Ping } 1408646d4dcSBai Ping 1418646d4dcSBai Ping static inline bool clk_pll1443x_mp_change(const struct imx_pll14xx_rate_table *rate, 1428646d4dcSBai Ping u32 pll_div_ctl0, u32 pll_div_ctl1) 1438646d4dcSBai Ping { 1448646d4dcSBai Ping u32 old_mdiv, old_pdiv, old_kdiv; 1458646d4dcSBai Ping 1468646d4dcSBai Ping old_mdiv = (pll_div_ctl0 >> MDIV_SHIFT) & MDIV_MASK; 1478646d4dcSBai Ping old_pdiv = (pll_div_ctl0 >> PDIV_SHIFT) & PDIV_MASK; 1488646d4dcSBai Ping old_kdiv = (pll_div_ctl1 >> KDIV_SHIFT) & KDIV_MASK; 1498646d4dcSBai Ping 1508646d4dcSBai Ping return rate->mdiv != old_mdiv || rate->pdiv != old_pdiv || 1518646d4dcSBai Ping rate->kdiv != old_kdiv; 1528646d4dcSBai Ping } 1538646d4dcSBai Ping 1548646d4dcSBai Ping static int clk_pll14xx_wait_lock(struct clk_pll14xx *pll) 1558646d4dcSBai Ping { 1568646d4dcSBai Ping u32 val; 1578646d4dcSBai Ping 1588646d4dcSBai Ping return readl_poll_timeout(pll->base, val, val & LOCK_TIMEOUT_US, 0, 1598646d4dcSBai Ping LOCK_TIMEOUT_US); 1608646d4dcSBai Ping } 1618646d4dcSBai Ping 1628646d4dcSBai Ping static int clk_pll1416x_set_rate(struct clk_hw *hw, unsigned long drate, 1638646d4dcSBai Ping unsigned long prate) 1648646d4dcSBai Ping { 1658646d4dcSBai Ping struct clk_pll14xx *pll = to_clk_pll14xx(hw); 1668646d4dcSBai Ping const struct imx_pll14xx_rate_table *rate; 1678646d4dcSBai Ping u32 tmp, div_val; 1688646d4dcSBai Ping int ret; 1698646d4dcSBai Ping 1708646d4dcSBai Ping rate = imx_get_pll_settings(pll, drate); 1718646d4dcSBai Ping if (!rate) { 1728646d4dcSBai Ping pr_err("%s: Invalid rate : %lu for pll clk %s\n", __func__, 1738646d4dcSBai Ping drate, clk_hw_get_name(hw)); 1748646d4dcSBai Ping return -EINVAL; 1758646d4dcSBai Ping } 1768646d4dcSBai Ping 1778646d4dcSBai Ping tmp = readl_relaxed(pll->base + 4); 1788646d4dcSBai Ping 1798646d4dcSBai Ping if (!clk_pll1416x_mp_change(rate, tmp)) { 1808646d4dcSBai Ping tmp &= ~(SDIV_MASK) << SDIV_SHIFT; 1818646d4dcSBai Ping tmp |= rate->sdiv << SDIV_SHIFT; 1828646d4dcSBai Ping writel_relaxed(tmp, pll->base + 4); 1838646d4dcSBai Ping 1848646d4dcSBai Ping return 0; 1858646d4dcSBai Ping } 1868646d4dcSBai Ping 1878646d4dcSBai Ping /* Bypass clock and set lock to pll output lock */ 1888646d4dcSBai Ping tmp = readl_relaxed(pll->base); 1898646d4dcSBai Ping tmp |= LOCK_SEL_MASK; 1908646d4dcSBai Ping writel_relaxed(tmp, pll->base); 1918646d4dcSBai Ping 1928646d4dcSBai Ping /* Enable RST */ 1938646d4dcSBai Ping tmp &= ~RST_MASK; 1948646d4dcSBai Ping writel_relaxed(tmp, pll->base); 1958646d4dcSBai Ping 1968646d4dcSBai Ping div_val = (rate->mdiv << MDIV_SHIFT) | (rate->pdiv << PDIV_SHIFT) | 1978646d4dcSBai Ping (rate->sdiv << SDIV_SHIFT); 1988646d4dcSBai Ping writel_relaxed(div_val, pll->base + 0x4); 1998646d4dcSBai Ping 2008646d4dcSBai Ping /* 2018646d4dcSBai Ping * According to SPEC, t3 - t2 need to be greater than 2028646d4dcSBai Ping * 1us and 1/FREF, respectively. 2038646d4dcSBai Ping * FREF is FIN / Prediv, the prediv is [1, 63], so choose 2048646d4dcSBai Ping * 3us. 2058646d4dcSBai Ping */ 2068646d4dcSBai Ping udelay(3); 2078646d4dcSBai Ping 2088646d4dcSBai Ping /* Disable RST */ 2098646d4dcSBai Ping tmp |= RST_MASK; 2108646d4dcSBai Ping writel_relaxed(tmp, pll->base); 2118646d4dcSBai Ping 2128646d4dcSBai Ping /* Wait Lock */ 2138646d4dcSBai Ping ret = clk_pll14xx_wait_lock(pll); 2148646d4dcSBai Ping if (ret) 2158646d4dcSBai Ping return ret; 2168646d4dcSBai Ping 2178646d4dcSBai Ping /* Bypass */ 2188646d4dcSBai Ping tmp &= ~BYPASS_MASK; 2198646d4dcSBai Ping writel_relaxed(tmp, pll->base); 2208646d4dcSBai Ping 2218646d4dcSBai Ping return 0; 2228646d4dcSBai Ping } 2238646d4dcSBai Ping 2248646d4dcSBai Ping static int clk_pll1443x_set_rate(struct clk_hw *hw, unsigned long drate, 2258646d4dcSBai Ping unsigned long prate) 2268646d4dcSBai Ping { 2278646d4dcSBai Ping struct clk_pll14xx *pll = to_clk_pll14xx(hw); 2288646d4dcSBai Ping const struct imx_pll14xx_rate_table *rate; 2298646d4dcSBai Ping u32 tmp, div_val; 2308646d4dcSBai Ping int ret; 2318646d4dcSBai Ping 2328646d4dcSBai Ping rate = imx_get_pll_settings(pll, drate); 2338646d4dcSBai Ping if (!rate) { 2348646d4dcSBai Ping pr_err("%s: Invalid rate : %lu for pll clk %s\n", __func__, 2358646d4dcSBai Ping drate, clk_hw_get_name(hw)); 2368646d4dcSBai Ping return -EINVAL; 2378646d4dcSBai Ping } 2388646d4dcSBai Ping 2398646d4dcSBai Ping tmp = readl_relaxed(pll->base + 4); 2408646d4dcSBai Ping div_val = readl_relaxed(pll->base + 8); 2418646d4dcSBai Ping 2428646d4dcSBai Ping if (!clk_pll1443x_mpk_change(rate, tmp, div_val)) { 2438646d4dcSBai Ping tmp &= ~(SDIV_MASK) << SDIV_SHIFT; 2448646d4dcSBai Ping tmp |= rate->sdiv << SDIV_SHIFT; 2458646d4dcSBai Ping writel_relaxed(tmp, pll->base + 4); 2468646d4dcSBai Ping 2478646d4dcSBai Ping return 0; 2488646d4dcSBai Ping } 2498646d4dcSBai Ping 2508646d4dcSBai Ping /* Enable RST */ 2518646d4dcSBai Ping tmp = readl_relaxed(pll->base); 2528646d4dcSBai Ping tmp &= ~RST_MASK; 2538646d4dcSBai Ping writel_relaxed(tmp, pll->base); 2548646d4dcSBai Ping 2558646d4dcSBai Ping div_val = (rate->mdiv << MDIV_SHIFT) | (rate->pdiv << PDIV_SHIFT) | 2568646d4dcSBai Ping (rate->sdiv << SDIV_SHIFT); 2578646d4dcSBai Ping writel_relaxed(div_val, pll->base + 0x4); 2588646d4dcSBai Ping writel_relaxed(rate->kdiv << KDIV_SHIFT, pll->base + 0x8); 2598646d4dcSBai Ping 2608646d4dcSBai Ping /* 2618646d4dcSBai Ping * According to SPEC, t3 - t2 need to be greater than 2628646d4dcSBai Ping * 1us and 1/FREF, respectively. 2638646d4dcSBai Ping * FREF is FIN / Prediv, the prediv is [1, 63], so choose 2648646d4dcSBai Ping * 3us. 2658646d4dcSBai Ping */ 2668646d4dcSBai Ping udelay(3); 2678646d4dcSBai Ping 2688646d4dcSBai Ping /* Disable RST */ 2698646d4dcSBai Ping tmp |= RST_MASK; 2708646d4dcSBai Ping writel_relaxed(tmp, pll->base); 2718646d4dcSBai Ping 2728646d4dcSBai Ping /* Wait Lock*/ 2738646d4dcSBai Ping ret = clk_pll14xx_wait_lock(pll); 2748646d4dcSBai Ping if (ret) 2758646d4dcSBai Ping return ret; 2768646d4dcSBai Ping 2778646d4dcSBai Ping /* Bypass */ 2788646d4dcSBai Ping tmp &= ~BYPASS_MASK; 2798646d4dcSBai Ping writel_relaxed(tmp, pll->base); 2808646d4dcSBai Ping 2818646d4dcSBai Ping return 0; 2828646d4dcSBai Ping } 2838646d4dcSBai Ping 2848646d4dcSBai Ping static int clk_pll14xx_prepare(struct clk_hw *hw) 2858646d4dcSBai Ping { 2868646d4dcSBai Ping struct clk_pll14xx *pll = to_clk_pll14xx(hw); 2878646d4dcSBai Ping u32 val; 2888646d4dcSBai Ping 2898646d4dcSBai Ping /* 2908646d4dcSBai Ping * RESETB = 1 from 0, PLL starts its normal 2918646d4dcSBai Ping * operation after lock time 2928646d4dcSBai Ping */ 2938646d4dcSBai Ping val = readl_relaxed(pll->base + GNRL_CTL); 2948646d4dcSBai Ping val |= RST_MASK; 2958646d4dcSBai Ping writel_relaxed(val, pll->base + GNRL_CTL); 2968646d4dcSBai Ping 2978646d4dcSBai Ping return clk_pll14xx_wait_lock(pll); 2988646d4dcSBai Ping } 2998646d4dcSBai Ping 3008646d4dcSBai Ping static int clk_pll14xx_is_prepared(struct clk_hw *hw) 3018646d4dcSBai Ping { 3028646d4dcSBai Ping struct clk_pll14xx *pll = to_clk_pll14xx(hw); 3038646d4dcSBai Ping u32 val; 3048646d4dcSBai Ping 3058646d4dcSBai Ping val = readl_relaxed(pll->base + GNRL_CTL); 3068646d4dcSBai Ping 3078646d4dcSBai Ping return (val & RST_MASK) ? 1 : 0; 3088646d4dcSBai Ping } 3098646d4dcSBai Ping 3108646d4dcSBai Ping static void clk_pll14xx_unprepare(struct clk_hw *hw) 3118646d4dcSBai Ping { 3128646d4dcSBai Ping struct clk_pll14xx *pll = to_clk_pll14xx(hw); 3138646d4dcSBai Ping u32 val; 3148646d4dcSBai Ping 3158646d4dcSBai Ping /* 3168646d4dcSBai Ping * Set RST to 0, power down mode is enabled and 3178646d4dcSBai Ping * every digital block is reset 3188646d4dcSBai Ping */ 3198646d4dcSBai Ping val = readl_relaxed(pll->base + GNRL_CTL); 3208646d4dcSBai Ping val &= ~RST_MASK; 3218646d4dcSBai Ping writel_relaxed(val, pll->base + GNRL_CTL); 3228646d4dcSBai Ping } 3238646d4dcSBai Ping 3248646d4dcSBai Ping static const struct clk_ops clk_pll1416x_ops = { 3258646d4dcSBai Ping .prepare = clk_pll14xx_prepare, 3268646d4dcSBai Ping .unprepare = clk_pll14xx_unprepare, 3278646d4dcSBai Ping .is_prepared = clk_pll14xx_is_prepared, 3288646d4dcSBai Ping .recalc_rate = clk_pll1416x_recalc_rate, 3298646d4dcSBai Ping .round_rate = clk_pll14xx_round_rate, 3308646d4dcSBai Ping .set_rate = clk_pll1416x_set_rate, 3318646d4dcSBai Ping }; 3328646d4dcSBai Ping 3338646d4dcSBai Ping static const struct clk_ops clk_pll1416x_min_ops = { 3348646d4dcSBai Ping .recalc_rate = clk_pll1416x_recalc_rate, 3358646d4dcSBai Ping }; 3368646d4dcSBai Ping 3378646d4dcSBai Ping static const struct clk_ops clk_pll1443x_ops = { 3388646d4dcSBai Ping .prepare = clk_pll14xx_prepare, 3398646d4dcSBai Ping .unprepare = clk_pll14xx_unprepare, 3408646d4dcSBai Ping .is_prepared = clk_pll14xx_is_prepared, 3418646d4dcSBai Ping .recalc_rate = clk_pll1443x_recalc_rate, 3428646d4dcSBai Ping .round_rate = clk_pll14xx_round_rate, 3438646d4dcSBai Ping .set_rate = clk_pll1443x_set_rate, 3448646d4dcSBai Ping }; 3458646d4dcSBai Ping 3468646d4dcSBai Ping struct clk *imx_clk_pll14xx(const char *name, const char *parent_name, 3478646d4dcSBai Ping void __iomem *base, 3488646d4dcSBai Ping const struct imx_pll14xx_clk *pll_clk) 3498646d4dcSBai Ping { 3508646d4dcSBai Ping struct clk_pll14xx *pll; 3518646d4dcSBai Ping struct clk *clk; 3528646d4dcSBai Ping struct clk_init_data init; 3538646d4dcSBai Ping 3548646d4dcSBai Ping pll = kzalloc(sizeof(*pll), GFP_KERNEL); 3558646d4dcSBai Ping if (!pll) 3568646d4dcSBai Ping return ERR_PTR(-ENOMEM); 3578646d4dcSBai Ping 3588646d4dcSBai Ping init.name = name; 3598646d4dcSBai Ping init.flags = pll_clk->flags; 3608646d4dcSBai Ping init.parent_names = &parent_name; 3618646d4dcSBai Ping init.num_parents = 1; 3628646d4dcSBai Ping 3638646d4dcSBai Ping switch (pll_clk->type) { 3648646d4dcSBai Ping case PLL_1416X: 365*f89b9e1bSLeonard Crestez if (!pll_clk->rate_table) 3668646d4dcSBai Ping init.ops = &clk_pll1416x_min_ops; 3678646d4dcSBai Ping else 3688646d4dcSBai Ping init.ops = &clk_pll1416x_ops; 3698646d4dcSBai Ping break; 3708646d4dcSBai Ping case PLL_1443X: 3718646d4dcSBai Ping init.ops = &clk_pll1443x_ops; 3728646d4dcSBai Ping break; 3738646d4dcSBai Ping default: 3748646d4dcSBai Ping pr_err("%s: Unknown pll type for pll clk %s\n", 3758646d4dcSBai Ping __func__, name); 3768646d4dcSBai Ping }; 3778646d4dcSBai Ping 3788646d4dcSBai Ping pll->base = base; 3798646d4dcSBai Ping pll->hw.init = &init; 3808646d4dcSBai Ping pll->type = pll_clk->type; 3818646d4dcSBai Ping pll->rate_table = pll_clk->rate_table; 3828646d4dcSBai Ping pll->rate_count = pll_clk->rate_count; 3838646d4dcSBai Ping 3848646d4dcSBai Ping clk = clk_register(NULL, &pll->hw); 3858646d4dcSBai Ping if (IS_ERR(clk)) { 3868646d4dcSBai Ping pr_err("%s: failed to register pll %s %lu\n", 3878646d4dcSBai Ping __func__, name, PTR_ERR(clk)); 3888646d4dcSBai Ping kfree(pll); 3898646d4dcSBai Ping } 3908646d4dcSBai Ping 3918646d4dcSBai Ping return clk; 3928646d4dcSBai Ping } 393