clk: meson: three small clk-pll fixes
Martin Blumenstingl
reviewercover clk: meson: three small clk-pll fixes
Hi Jerome,
while working on some changes for the 32-bit SoCs I hit a corner-case in the HDMI PLL: there's some rate doubling going. The PLL only locks in a specific rate range but the M/N table is not aware of that. This means for now (I am planning to fix that) that we can end up in a ituation where the PLL doesn't lock and meson_clk_pll_set_rate() is supposed to still behave in this case. So here's three small patches for that.
For me it's fine to queue these patches for -next. I am not aware of any breakage upstream, only some of my pending patches prefer to have these fixes.
Slightly unrelated: if you know anything about that clock doubling then please let me know!
Best regards,
Martin
Martin Blumenstingl (3):
clk: meson: clk-pll: fix initializing the old rate (fallback) for a
PLL
clk: meson: clk-pll: make "ret" a signed integer
clk: meson: clk-pll: propagate the error from meson_clk_pll_set_rate()
drivers/clk/meson/clk-pll.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
Signature · 7 lines
2.29.2 _______________________________________________ linux-amlogic mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-amlogic
Martin Blumenstingl
reviewerPATCH 1/3 clk: meson: clk-pll: fix initializing the old rate (fallback) for a PLL
The "rate" parameter in meson_clk_pll_set_rate() contains the new rate. Retrieve the old rate with clk_hw_get_rate() so we don't inifinitely try to switch from the new rate to the same ratte again.
--- drivers/clk/meson/clk-pll.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/clk/meson/clk-pll.c +1 -1
@@ -371,7 +371,7 @@ static int meson_clk_pll_set_rate(struct clk_hw *hw, unsigned long rate,if (parent_rate ==0 || rate ==0 )return -EINVAL ; - old_rate = rate; + old_rate =clk_hw_get_rate (hw); ret =meson_clk_get_pll_settings (rate, parent_rate, &m, &n, pll);if (ret)
Signature · 7 lines
2.29.2 _______________________________________________ linux-amlogic mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-amlogic
Jerome Brunet
maintainerRe: [PATCH 1/3] clk: meson: clk-pll: fix initializing the old rate (fallback) for a PLL
Quoted 3 lines · Martin Blumenstingl
The "rate" parameter in
meson_clk_pll_set_rate()contains the new rate. Retrieve the old rate withclk_hw_get_rate()so we don't inifinitely try to switch from the new rate to the same ratte again.
Small typo above fixed while applying
Quoted 12 lines
Fixes 7a29a869434e8b ("clk: meson: Add support for Meson clock controller")Signed-off-by Martin Blumenstingl <[email protected]>--- drivers/clk/meson/clk-pll.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/clk/meson/clk-pll.c +0
-0
drivers/clk/meson/clk-pll.c static int meson_clk_pll_set_rate(struct clk_hw *hw, unsigned long rate, · line 377
Quoted 8 lines
drivers/clk/meson/clk-pll.c +1
-1@@ -371,7 +371,7 @@ static int meson_clk_pll_set_rate(struct clk_hw *hw, unsigned long rate,if (parent_rate ==0 || rate ==0 )return -EINVAL ; - old_rate = rate; + old_rate =clk_hw_get_rate (hw); ret =meson_clk_get_pll_settings (rate, parent_rate, &m, &n, pll);if (ret)
_______________________________________________
linux-amlogic mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-amlogic
Martin Blumenstingl
reviewerPATCH 2/3 clk: meson: clk-pll: make "ret" a signed integer
In reply to Martin BlumenstinglThe error codes returned by meson_clk_get_pll_settings() are all negative. Make "ret" a signed integer in meson_clk_pll_set_rate() to make it match with the clk_ops.set_rate API as well as the data type returned by meson_clk_get_pll_settings().
--- drivers/clk/meson/clk-pll.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/clk/meson/clk-pll.c +2 -1
@@ -365,8 +365,9 @@ static int meson_clk_pll_set_rate(struct clk_hw *hw, unsigned long rate, {struct clk_regmap *clk =to_clk_regmap (hw);struct meson_clk_pll_data *pll =meson_clk_pll_data (clk); -unsigned int enabled, m, n, frac =0 , ret; +unsigned int enabled, m, n, frac =0 ;unsigned long old_rate; +int ret;if (parent_rate ==0 || rate ==0 )return -EINVAL ;
Signature · 7 lines
2.29.2 _______________________________________________ linux-amlogic mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-amlogic
Martin Blumenstingl
reviewerPATCH 3/3 clk: meson: clk-pll: propagate the error from meson_clk_pll_set_rate()
In reply to Martin BlumenstinglPopagate the error code from meson_clk_pll_set_rate() when the PLL does not lock with the new settings.
--- drivers/clk/meson/clk-pll.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/clk/meson/clk-pll.c +3 -2
@@ -394,7 +394,8 @@ static int meson_clk_pll_set_rate(struct clk_hw *hw, unsigned long rate,if (!enabled)return 0 ; -if (meson_clk_pll_enable (hw)) { + ret =meson_clk_pll_enable (hw); +if (ret) {pr_warn ("%s: pll did not lock, trying to restore old rate %lu\n" , __func__, old_rate);/*
@@ -406,7 +407,7 @@ static int meson_clk_pll_set_rate(struct clk_hw *hw, unsigned long rate,meson_clk_pll_set_rate (hw, old_rate, parent_rate); } -return 0 ; +return ret; }/*
Signature · 7 lines
2.29.2 _______________________________________________ linux-amlogic mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-amlogic
Quoted 22 lines · Martin Blumenstingl
Hi Jerome,
while working on some changes for the 32-bit SoCs I hit a corner-case in the HDMI PLL: there's some rate doubling going. The PLL only locks in a specific rate range but the M/N table is not aware of that. This means for now (I am planning to fix that) that we can end up in a ituation where the PLL doesn't lock and
meson_clk_pll_set_rate()is supposed to still behave in this case. So here's three small patches for that.For me it's fine to queue these patches for -next. I am not aware of any breakage upstream, only some of my pending patches prefer to have these fixes.
Slightly unrelated: if you know anything about that clock doubling then please let me know!
Best regards,
Martin
Quoted 8 lines
Martin Blumenstingl (3):
clk: meson: clk-pll: fix initializing the old rate (fallback) for a
PLL
clk: meson: clk-pll: make "ret" a signed integer
clk: meson: clk-pll: propagate the error frommeson_clk_pll_set_rate()drivers/clk/meson/clk-pll.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
Applied, Thx
_______________________________________________
linux-amlogic mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-amlogic