Skip to content

Commit 394cdb6

Browse files
wqyoungbebarino
authored andcommitted
clk: zynqmp: pll: add set_pll_mode to check condition in zynqmp_pll_enable
If there is a IOCTL_SET_PLL_FRAC_MODE request sent to ATF ever, we shouldn't skip invoking PM_CLOCK_ENABLE fn even though this pll has been enabled. In ATF implementation, it will only assign the mode to the variable (struct pm_pll *)pll->mode when handling IOCTL_SET_PLL_FRAC_MODE call. Invoking PM_CLOCK_ENABLE can force ATF send request to PWU to set the pll mode to PLL's register. There is a scenario that happens in enabling VPLL_INT(clk_id:96): 1) VPLL_INT has been enabled during booting. 2) A driver calls clk_set_rate and according to the rate, the VPLL_INT should be set to FRAC mode. Then zynqmp_pll_set_mode is called to pass IOCTL_SET_PLL_FRAC_MODE to ATF. Note that at this point ATF just stores the mode to a variable. 3) This driver calls clk_prepare_enable and zynqmp_pll_enable is called to try to enable VPLL_INT pll. Because of 1), the function zynqmp_pll_enable just returns without doing anything after checking that this pll has been enabled. In the scenario above, the pll mode of VPLL_INT will never be set successfully. So adding set_pll_mode to check condition to fix it. Fixes: 3fde0e1 ("drivers: clk: Add ZynqMP clock driver") Signed-off-by: Quanyang Wang <[email protected]> Tested-by: Laurent Pinchart <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Stephen Boyd <[email protected]>
1 parent d7fd3f9 commit 394cdb6

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

drivers/clk/zynqmp/pll.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,12 @@
1414
* struct zynqmp_pll - PLL clock
1515
* @hw: Handle between common and hardware-specific interfaces
1616
* @clk_id: PLL clock ID
17+
* @set_pll_mode: Whether an IOCTL_SET_PLL_FRAC_MODE request be sent to ATF
1718
*/
1819
struct zynqmp_pll {
1920
struct clk_hw hw;
2021
u32 clk_id;
22+
bool set_pll_mode;
2123
};
2224

2325
#define to_zynqmp_pll(_hw) container_of(_hw, struct zynqmp_pll, hw)
@@ -81,6 +83,8 @@ static inline void zynqmp_pll_set_mode(struct clk_hw *hw, bool on)
8183
if (ret)
8284
pr_warn_once("%s() PLL set frac mode failed for %s, ret = %d\n",
8385
__func__, clk_name, ret);
86+
else
87+
clk->set_pll_mode = true;
8488
}
8589

8690
/**
@@ -240,9 +244,15 @@ static int zynqmp_pll_enable(struct clk_hw *hw)
240244
u32 clk_id = clk->clk_id;
241245
int ret;
242246

243-
if (zynqmp_pll_is_enabled(hw))
247+
/*
248+
* Don't skip enabling clock if there is an IOCTL_SET_PLL_FRAC_MODE request
249+
* that has been sent to ATF.
250+
*/
251+
if (zynqmp_pll_is_enabled(hw) && (!clk->set_pll_mode))
244252
return 0;
245253

254+
clk->set_pll_mode = false;
255+
246256
ret = zynqmp_pm_clock_enable(clk_id);
247257
if (ret)
248258
pr_warn_once("%s() clock enable failed for %s, ret = %d\n",

0 commit comments

Comments
 (0)