Linux-Clk Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH V3 0/4] clk: imx8m: fix glitch/mux
@ 2019-09-09  3:39 Peng Fan
  2019-09-09  3:39 ` [PATCH V3 1/4] clk: imx: pll14xx: avoid glitch when set rate Peng Fan
                   ` (4 more replies)
  0 siblings, 5 replies; 13+ messages in thread
From: Peng Fan @ 2019-09-09  3:39 UTC (permalink / raw)
  To: mturquette, sboyd, shawnguo, s.hauer, festevam
  Cc: kernel, dl-linux-imx, Anson Huang, Jacky Bai, Abel Vesa,
	linux-clk, linux-arm-kernel, linux-kernel, Leonard Crestez,
	Peng Fan

From: Peng Fan <peng.fan@nxp.com>

V3:
 Add cover-letter

V2:
 Added patch [2,3,4]/4 and avoid glitch when prepare

There is two bypass bit in the pll, BYPASS and EXT_BYPASS.
There is also a restriction that to avoid glitch, need set BYPASS
bit when RESETB changed from 0 to 1, otherwise there will be glitch.

However the BYPASS bit is also used as mux bit in imx8mm/imx8mn clk driver.

This means two paths touch the same bit which is wrong. So switch to use
EXT_BYPASS bit as the mux.

Peng Fan (4):
  clk: imx: pll14xx: avoid glitch when set rate
  clk: imx: clk-pll14xx: unbypass PLL by default
  clk: imx: imx8mm: fix pll mux bit
  clk: imx: imx8mn: fix pll mux bit

 drivers/clk/imx/clk-imx8mm.c  | 32 ++++++++++----------------------
 drivers/clk/imx/clk-imx8mn.c  | 32 ++++++++++----------------------
 drivers/clk/imx/clk-pll14xx.c | 27 ++++++++++++++++++++++++++-
 3 files changed, 46 insertions(+), 45 deletions(-)

-- 
2.16.4


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [PATCH V3 1/4] clk: imx: pll14xx: avoid glitch when set rate
  2019-09-09  3:39 [PATCH V3 0/4] clk: imx8m: fix glitch/mux Peng Fan
@ 2019-09-09  3:39 ` Peng Fan
  2019-09-18  6:07   ` Stephen Boyd
  2019-09-09  3:39 ` [PATCH V3 2/4] clk: imx: clk-pll14xx: unbypass PLL by default Peng Fan
                   ` (3 subsequent siblings)
  4 siblings, 1 reply; 13+ messages in thread
From: Peng Fan @ 2019-09-09  3:39 UTC (permalink / raw)
  To: mturquette, sboyd, shawnguo, s.hauer, festevam
  Cc: kernel, dl-linux-imx, Anson Huang, Jacky Bai, Abel Vesa,
	linux-clk, linux-arm-kernel, linux-kernel, Leonard Crestez,
	Peng Fan

From: Peng Fan <peng.fan@nxp.com>

According to PLL1443XA and PLL1416X spec,
"When BYPASS is 0 and RESETB is changed from 0 to 1, FOUT starts to
output unstable clock until lock time passes. PLL1416X/PLL1443XA may
generate a glitch at FOUT."

So set BYPASS when RESETB is changed from 0 to 1 to avoid glitch.
In the end of set rate, BYPASS will be cleared.

When prepare clock, also need to take care to avoid glitch. So
we also follow Spec to set BYPASS before RESETB changed from 0 to 1.
And add a check if the RESETB is already 0, directly return 0;

Fixes: 8646d4dcc7fb ("clk: imx: Add PLLs driver for imx8mm soc")
Reviewed-by: Leonard Crestez <leonard.crestez@nxp.com>
Signed-off-by: Peng Fan <peng.fan@nxp.com>
---

V3:
 None
V2:
  Avoid glitch when prepare
  update commit log

 drivers/clk/imx/clk-pll14xx.c | 22 +++++++++++++++++++++-
 1 file changed, 21 insertions(+), 1 deletion(-)

diff --git a/drivers/clk/imx/clk-pll14xx.c b/drivers/clk/imx/clk-pll14xx.c
index b7213023b238..656f48b002dd 100644
--- a/drivers/clk/imx/clk-pll14xx.c
+++ b/drivers/clk/imx/clk-pll14xx.c
@@ -191,6 +191,10 @@ static int clk_pll1416x_set_rate(struct clk_hw *hw, unsigned long drate,
 	tmp &= ~RST_MASK;
 	writel_relaxed(tmp, pll->base);
 
+	/* Enable BYPASS */
+	tmp |= BYPASS_MASK;
+	writel(tmp, pll->base);
+
 	div_val = (rate->mdiv << MDIV_SHIFT) | (rate->pdiv << PDIV_SHIFT) |
 		(rate->sdiv << SDIV_SHIFT);
 	writel_relaxed(div_val, pll->base + 0x4);
@@ -250,6 +254,10 @@ static int clk_pll1443x_set_rate(struct clk_hw *hw, unsigned long drate,
 	tmp &= ~RST_MASK;
 	writel_relaxed(tmp, pll->base);
 
+	/* Enable BYPASS */
+	tmp |= BYPASS_MASK;
+	writel_relaxed(tmp, pll->base);
+
 	div_val = (rate->mdiv << MDIV_SHIFT) | (rate->pdiv << PDIV_SHIFT) |
 		(rate->sdiv << SDIV_SHIFT);
 	writel_relaxed(div_val, pll->base + 0x4);
@@ -283,16 +291,28 @@ static int clk_pll14xx_prepare(struct clk_hw *hw)
 {
 	struct clk_pll14xx *pll = to_clk_pll14xx(hw);
 	u32 val;
+	int ret;
 
 	/*
 	 * RESETB = 1 from 0, PLL starts its normal
 	 * operation after lock time
 	 */
 	val = readl_relaxed(pll->base + GNRL_CTL);
+	if (val & RST_MASK)
+		return 0;
+	val |= BYPASS_MASK;
+	writel_relaxed(val, pll->base + GNRL_CTL);
 	val |= RST_MASK;
 	writel_relaxed(val, pll->base + GNRL_CTL);
 
-	return clk_pll14xx_wait_lock(pll);
+	ret = clk_pll14xx_wait_lock(pll);
+	if (ret)
+		return ret;
+
+	val &= ~BYPASS_MASK;
+	writel_relaxed(val, pll->base + GNRL_CTL);
+
+	return 0;
 }
 
 static int clk_pll14xx_is_prepared(struct clk_hw *hw)
-- 
2.16.4


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [PATCH V3 2/4] clk: imx: clk-pll14xx: unbypass PLL by default
  2019-09-09  3:39 [PATCH V3 0/4] clk: imx8m: fix glitch/mux Peng Fan
  2019-09-09  3:39 ` [PATCH V3 1/4] clk: imx: pll14xx: avoid glitch when set rate Peng Fan
@ 2019-09-09  3:39 ` Peng Fan
  2019-09-18  6:07   ` Stephen Boyd
  2019-09-09  3:39 ` [PATCH V3 3/4] clk: imx: imx8mm: fix pll mux bit Peng Fan
                   ` (2 subsequent siblings)
  4 siblings, 1 reply; 13+ messages in thread
From: Peng Fan @ 2019-09-09  3:39 UTC (permalink / raw)
  To: mturquette, sboyd, shawnguo, s.hauer, festevam
  Cc: kernel, dl-linux-imx, Anson Huang, Jacky Bai, Abel Vesa,
	linux-clk, linux-arm-kernel, linux-kernel, Leonard Crestez,
	Peng Fan

From: Peng Fan <peng.fan@nxp.com>

When registering the PLL, unbypass the PLL.
The PLL has two bypass control bit, BYPASS and EXT_BYPASS.
we will expose EXT_BYPASS to clk driver for mux usage, and keep
BYPASS inside pll14xx usage. The PLL has a restriction that
when M/P change, need to RESET/BYPASS pll to avoid glitch, so
we could not expose BYPASS.

To make it easy for clk driver usage, unbypass PLL which does
not hurt current function.

Fixes: 8646d4dcc7fb ("clk: imx: Add PLLs driver for imx8mm soc")
Reviewed-by: Leonard Crestez <leonard.crestez@nxp.com>
Signed-off-by: Peng Fan <peng.fan@nxp.com>
---

V3:
 None
V2:
 New patch


 drivers/clk/imx/clk-pll14xx.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/drivers/clk/imx/clk-pll14xx.c b/drivers/clk/imx/clk-pll14xx.c
index 656f48b002dd..7a815ec76aa5 100644
--- a/drivers/clk/imx/clk-pll14xx.c
+++ b/drivers/clk/imx/clk-pll14xx.c
@@ -368,6 +368,7 @@ struct clk *imx_clk_pll14xx(const char *name, const char *parent_name,
 	struct clk_pll14xx *pll;
 	struct clk *clk;
 	struct clk_init_data init;
+	u32 val;
 
 	pll = kzalloc(sizeof(*pll), GFP_KERNEL);
 	if (!pll)
@@ -399,6 +400,10 @@ struct clk *imx_clk_pll14xx(const char *name, const char *parent_name,
 	pll->rate_table = pll_clk->rate_table;
 	pll->rate_count = pll_clk->rate_count;
 
+	val = readl_relaxed(pll->base + GNRL_CTL);
+	val &= ~BYPASS_MASK;
+	writel_relaxed(val, pll->base + GNRL_CTL);
+
 	clk = clk_register(NULL, &pll->hw);
 	if (IS_ERR(clk)) {
 		pr_err("%s: failed to register pll %s %lu\n",
-- 
2.16.4


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [PATCH V3 3/4] clk: imx: imx8mm: fix pll mux bit
  2019-09-09  3:39 [PATCH V3 0/4] clk: imx8m: fix glitch/mux Peng Fan
  2019-09-09  3:39 ` [PATCH V3 1/4] clk: imx: pll14xx: avoid glitch when set rate Peng Fan
  2019-09-09  3:39 ` [PATCH V3 2/4] clk: imx: clk-pll14xx: unbypass PLL by default Peng Fan
@ 2019-09-09  3:39 ` Peng Fan
  2019-09-18  6:07   ` Stephen Boyd
  2019-09-09  3:39 ` [PATCH V3 4/4] clk: imx: imx8mn: " Peng Fan
  2019-09-17  6:20 ` [PATCH V3 0/4] clk: imx8m: fix glitch/mux Peng Fan
  4 siblings, 1 reply; 13+ messages in thread
From: Peng Fan @ 2019-09-09  3:39 UTC (permalink / raw)
  To: mturquette, sboyd, shawnguo, s.hauer, festevam
  Cc: kernel, dl-linux-imx, Anson Huang, Jacky Bai, Abel Vesa,
	linux-clk, linux-arm-kernel, linux-kernel, Leonard Crestez,
	Peng Fan

From: Peng Fan <peng.fan@nxp.com>

pll BYPASS bit should be kept inside pll driver for glitchless freq
setting following spec. If exposing the bit, that means pll driver and
clk driver has two paths to touch this bit, which is wrong.

So use EXT_BYPASS bit here.

And drop uneeded set parent, because EXT_BYPASS default is 0.

Fixes: ba5625c3e272 ("clk: imx: Add clock driver support for imx8mm")
Suggested-by: Jacky Bai <ping.bai@nxp.com>
Reviewed-by: Leonard Crestez <leonard.crestez@nxp.com>
Signed-off-by: Peng Fan <peng.fan@nxp.com>
---

V3:
 None
V2:
 New patch


 drivers/clk/imx/clk-imx8mm.c | 32 ++++++++++----------------------
 1 file changed, 10 insertions(+), 22 deletions(-)

diff --git a/drivers/clk/imx/clk-imx8mm.c b/drivers/clk/imx/clk-imx8mm.c
index 2758e3f0d15d..067ab876911d 100644
--- a/drivers/clk/imx/clk-imx8mm.c
+++ b/drivers/clk/imx/clk-imx8mm.c
@@ -408,28 +408,16 @@ static int imx8mm_clocks_probe(struct platform_device *pdev)
 	clks[IMX8MM_SYS_PLL3] = imx_clk_pll14xx("sys_pll3", "sys_pll3_ref_sel", base + 0x114, &imx8mm_sys_pll);
 
 	/* PLL bypass out */
-	clks[IMX8MM_AUDIO_PLL1_BYPASS] = imx_clk_mux_flags("audio_pll1_bypass", base, 4, 1, audio_pll1_bypass_sels, ARRAY_SIZE(audio_pll1_bypass_sels), CLK_SET_RATE_PARENT);
-	clks[IMX8MM_AUDIO_PLL2_BYPASS] = imx_clk_mux_flags("audio_pll2_bypass", base + 0x14, 4, 1, audio_pll2_bypass_sels, ARRAY_SIZE(audio_pll2_bypass_sels), CLK_SET_RATE_PARENT);
-	clks[IMX8MM_VIDEO_PLL1_BYPASS] = imx_clk_mux_flags("video_pll1_bypass", base + 0x28, 4, 1, video_pll1_bypass_sels, ARRAY_SIZE(video_pll1_bypass_sels), CLK_SET_RATE_PARENT);
-	clks[IMX8MM_DRAM_PLL_BYPASS] = imx_clk_mux_flags("dram_pll_bypass", base + 0x50, 4, 1, dram_pll_bypass_sels, ARRAY_SIZE(dram_pll_bypass_sels), CLK_SET_RATE_PARENT);
-	clks[IMX8MM_GPU_PLL_BYPASS] = imx_clk_mux_flags("gpu_pll_bypass", base + 0x64, 4, 1, gpu_pll_bypass_sels, ARRAY_SIZE(gpu_pll_bypass_sels), CLK_SET_RATE_PARENT);
-	clks[IMX8MM_VPU_PLL_BYPASS] = imx_clk_mux_flags("vpu_pll_bypass", base + 0x74, 4, 1, vpu_pll_bypass_sels, ARRAY_SIZE(vpu_pll_bypass_sels), CLK_SET_RATE_PARENT);
-	clks[IMX8MM_ARM_PLL_BYPASS] = imx_clk_mux_flags("arm_pll_bypass", base + 0x84, 4, 1, arm_pll_bypass_sels, ARRAY_SIZE(arm_pll_bypass_sels), CLK_SET_RATE_PARENT);
-	clks[IMX8MM_SYS_PLL1_BYPASS] = imx_clk_mux_flags("sys_pll1_bypass", base + 0x94, 4, 1, sys_pll1_bypass_sels, ARRAY_SIZE(sys_pll1_bypass_sels), CLK_SET_RATE_PARENT);
-	clks[IMX8MM_SYS_PLL2_BYPASS] = imx_clk_mux_flags("sys_pll2_bypass", base + 0x104, 4, 1, sys_pll2_bypass_sels, ARRAY_SIZE(sys_pll2_bypass_sels), CLK_SET_RATE_PARENT);
-	clks[IMX8MM_SYS_PLL3_BYPASS] = imx_clk_mux_flags("sys_pll3_bypass", base + 0x114, 4, 1, sys_pll3_bypass_sels, ARRAY_SIZE(sys_pll3_bypass_sels), CLK_SET_RATE_PARENT);
-
-	/* unbypass all the plls */
-	clk_set_parent(clks[IMX8MM_AUDIO_PLL1_BYPASS], clks[IMX8MM_AUDIO_PLL1]);
-	clk_set_parent(clks[IMX8MM_AUDIO_PLL2_BYPASS], clks[IMX8MM_AUDIO_PLL2]);
-	clk_set_parent(clks[IMX8MM_VIDEO_PLL1_BYPASS], clks[IMX8MM_VIDEO_PLL1]);
-	clk_set_parent(clks[IMX8MM_DRAM_PLL_BYPASS], clks[IMX8MM_DRAM_PLL]);
-	clk_set_parent(clks[IMX8MM_GPU_PLL_BYPASS], clks[IMX8MM_GPU_PLL]);
-	clk_set_parent(clks[IMX8MM_VPU_PLL_BYPASS], clks[IMX8MM_VPU_PLL]);
-	clk_set_parent(clks[IMX8MM_ARM_PLL_BYPASS], clks[IMX8MM_ARM_PLL]);
-	clk_set_parent(clks[IMX8MM_SYS_PLL1_BYPASS], clks[IMX8MM_SYS_PLL1]);
-	clk_set_parent(clks[IMX8MM_SYS_PLL2_BYPASS], clks[IMX8MM_SYS_PLL2]);
-	clk_set_parent(clks[IMX8MM_SYS_PLL3_BYPASS], clks[IMX8MM_SYS_PLL3]);
+	clks[IMX8MM_AUDIO_PLL1_BYPASS] = imx_clk_mux_flags("audio_pll1_bypass", base, 16, 1, audio_pll1_bypass_sels, ARRAY_SIZE(audio_pll1_bypass_sels), CLK_SET_RATE_PARENT);
+	clks[IMX8MM_AUDIO_PLL2_BYPASS] = imx_clk_mux_flags("audio_pll2_bypass", base + 0x14, 16, 1, audio_pll2_bypass_sels, ARRAY_SIZE(audio_pll2_bypass_sels), CLK_SET_RATE_PARENT);
+	clks[IMX8MM_VIDEO_PLL1_BYPASS] = imx_clk_mux_flags("video_pll1_bypass", base + 0x28, 16, 1, video_pll1_bypass_sels, ARRAY_SIZE(video_pll1_bypass_sels), CLK_SET_RATE_PARENT);
+	clks[IMX8MM_DRAM_PLL_BYPASS] = imx_clk_mux_flags("dram_pll_bypass", base + 0x50, 16, 1, dram_pll_bypass_sels, ARRAY_SIZE(dram_pll_bypass_sels), CLK_SET_RATE_PARENT);
+	clks[IMX8MM_GPU_PLL_BYPASS] = imx_clk_mux_flags("gpu_pll_bypass", base + 0x64, 28, 1, gpu_pll_bypass_sels, ARRAY_SIZE(gpu_pll_bypass_sels), CLK_SET_RATE_PARENT);
+	clks[IMX8MM_VPU_PLL_BYPASS] = imx_clk_mux_flags("vpu_pll_bypass", base + 0x74, 28, 1, vpu_pll_bypass_sels, ARRAY_SIZE(vpu_pll_bypass_sels), CLK_SET_RATE_PARENT);
+	clks[IMX8MM_ARM_PLL_BYPASS] = imx_clk_mux_flags("arm_pll_bypass", base + 0x84, 28, 1, arm_pll_bypass_sels, ARRAY_SIZE(arm_pll_bypass_sels), CLK_SET_RATE_PARENT);
+	clks[IMX8MM_SYS_PLL1_BYPASS] = imx_clk_mux_flags("sys_pll1_bypass", base + 0x94, 28, 1, sys_pll1_bypass_sels, ARRAY_SIZE(sys_pll1_bypass_sels), CLK_SET_RATE_PARENT);
+	clks[IMX8MM_SYS_PLL2_BYPASS] = imx_clk_mux_flags("sys_pll2_bypass", base + 0x104, 28, 1, sys_pll2_bypass_sels, ARRAY_SIZE(sys_pll2_bypass_sels), CLK_SET_RATE_PARENT);
+	clks[IMX8MM_SYS_PLL3_BYPASS] = imx_clk_mux_flags("sys_pll3_bypass", base + 0x114, 28, 1, sys_pll3_bypass_sels, ARRAY_SIZE(sys_pll3_bypass_sels), CLK_SET_RATE_PARENT);
 
 	/* PLL out gate */
 	clks[IMX8MM_AUDIO_PLL1_OUT] = imx_clk_gate("audio_pll1_out", "audio_pll1_bypass", base, 13);
-- 
2.16.4


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [PATCH V3 4/4] clk: imx: imx8mn: fix pll mux bit
  2019-09-09  3:39 [PATCH V3 0/4] clk: imx8m: fix glitch/mux Peng Fan
                   ` (2 preceding siblings ...)
  2019-09-09  3:39 ` [PATCH V3 3/4] clk: imx: imx8mm: fix pll mux bit Peng Fan
@ 2019-09-09  3:39 ` " Peng Fan
  2019-09-18  6:07   ` Stephen Boyd
  2019-09-17  6:20 ` [PATCH V3 0/4] clk: imx8m: fix glitch/mux Peng Fan
  4 siblings, 1 reply; 13+ messages in thread
From: Peng Fan @ 2019-09-09  3:39 UTC (permalink / raw)
  To: mturquette, sboyd, shawnguo, s.hauer, festevam
  Cc: kernel, dl-linux-imx, Anson Huang, Jacky Bai, Abel Vesa,
	linux-clk, linux-arm-kernel, linux-kernel, Leonard Crestez,
	Peng Fan

From: Peng Fan <peng.fan@nxp.com>

pll BYPASS bit should be kept inside pll driver for glitchless freq
setting following spec. If exposing the bit, that means pll driver and
clk driver has two paths to touch this bit, which is wrong.

So use EXT_BYPASS bit here.

And drop uneeded set parent, because EXT_BYPASS default is 0.

Suggested-by: Jacky Bai <ping.bai@nxp.com>
Reviewed-by: Leonard Crestez <leonard.crestez@nxp.com>
Signed-off-by: Peng Fan <peng.fan@nxp.com>
---

V3:
 None
V2:
 New patch

 drivers/clk/imx/clk-imx8mn.c | 32 ++++++++++----------------------
 1 file changed, 10 insertions(+), 22 deletions(-)

diff --git a/drivers/clk/imx/clk-imx8mn.c b/drivers/clk/imx/clk-imx8mn.c
index f41116d59749..f767d18679ea 100644
--- a/drivers/clk/imx/clk-imx8mn.c
+++ b/drivers/clk/imx/clk-imx8mn.c
@@ -421,28 +421,16 @@ static int imx8mn_clocks_probe(struct platform_device *pdev)
 	clks[IMX8MN_SYS_PLL3] = imx_clk_pll14xx("sys_pll3", "sys_pll3_ref_sel", base + 0x114, &imx8mn_sys_pll);
 
 	/* PLL bypass out */
-	clks[IMX8MN_AUDIO_PLL1_BYPASS] = imx_clk_mux_flags("audio_pll1_bypass", base, 4, 1, audio_pll1_bypass_sels, ARRAY_SIZE(audio_pll1_bypass_sels), CLK_SET_RATE_PARENT);
-	clks[IMX8MN_AUDIO_PLL2_BYPASS] = imx_clk_mux_flags("audio_pll2_bypass", base + 0x14, 4, 1, audio_pll2_bypass_sels, ARRAY_SIZE(audio_pll2_bypass_sels), CLK_SET_RATE_PARENT);
-	clks[IMX8MN_VIDEO_PLL1_BYPASS] = imx_clk_mux_flags("video_pll1_bypass", base + 0x28, 4, 1, video_pll1_bypass_sels, ARRAY_SIZE(video_pll1_bypass_sels), CLK_SET_RATE_PARENT);
-	clks[IMX8MN_DRAM_PLL_BYPASS] = imx_clk_mux_flags("dram_pll_bypass", base + 0x50, 4, 1, dram_pll_bypass_sels, ARRAY_SIZE(dram_pll_bypass_sels), CLK_SET_RATE_PARENT);
-	clks[IMX8MN_GPU_PLL_BYPASS] = imx_clk_mux_flags("gpu_pll_bypass", base + 0x64, 4, 1, gpu_pll_bypass_sels, ARRAY_SIZE(gpu_pll_bypass_sels), CLK_SET_RATE_PARENT);
-	clks[IMX8MN_VPU_PLL_BYPASS] = imx_clk_mux_flags("vpu_pll_bypass", base + 0x74, 4, 1, vpu_pll_bypass_sels, ARRAY_SIZE(vpu_pll_bypass_sels), CLK_SET_RATE_PARENT);
-	clks[IMX8MN_ARM_PLL_BYPASS] = imx_clk_mux_flags("arm_pll_bypass", base + 0x84, 4, 1, arm_pll_bypass_sels, ARRAY_SIZE(arm_pll_bypass_sels), CLK_SET_RATE_PARENT);
-	clks[IMX8MN_SYS_PLL1_BYPASS] = imx_clk_mux_flags("sys_pll1_bypass", base + 0x94, 4, 1, sys_pll1_bypass_sels, ARRAY_SIZE(sys_pll1_bypass_sels), CLK_SET_RATE_PARENT);
-	clks[IMX8MN_SYS_PLL2_BYPASS] = imx_clk_mux_flags("sys_pll2_bypass", base + 0x104, 4, 1, sys_pll2_bypass_sels, ARRAY_SIZE(sys_pll2_bypass_sels), CLK_SET_RATE_PARENT);
-	clks[IMX8MN_SYS_PLL3_BYPASS] = imx_clk_mux_flags("sys_pll3_bypass", base + 0x114, 4, 1, sys_pll3_bypass_sels, ARRAY_SIZE(sys_pll3_bypass_sels), CLK_SET_RATE_PARENT);
-
-	/* unbypass all the plls */
-	clk_set_parent(clks[IMX8MN_AUDIO_PLL1_BYPASS], clks[IMX8MN_AUDIO_PLL1]);
-	clk_set_parent(clks[IMX8MN_AUDIO_PLL2_BYPASS], clks[IMX8MN_AUDIO_PLL2]);
-	clk_set_parent(clks[IMX8MN_VIDEO_PLL1_BYPASS], clks[IMX8MN_VIDEO_PLL1]);
-	clk_set_parent(clks[IMX8MN_DRAM_PLL_BYPASS], clks[IMX8MN_DRAM_PLL]);
-	clk_set_parent(clks[IMX8MN_GPU_PLL_BYPASS], clks[IMX8MN_GPU_PLL]);
-	clk_set_parent(clks[IMX8MN_VPU_PLL_BYPASS], clks[IMX8MN_VPU_PLL]);
-	clk_set_parent(clks[IMX8MN_ARM_PLL_BYPASS], clks[IMX8MN_ARM_PLL]);
-	clk_set_parent(clks[IMX8MN_SYS_PLL1_BYPASS], clks[IMX8MN_SYS_PLL1]);
-	clk_set_parent(clks[IMX8MN_SYS_PLL2_BYPASS], clks[IMX8MN_SYS_PLL2]);
-	clk_set_parent(clks[IMX8MN_SYS_PLL3_BYPASS], clks[IMX8MN_SYS_PLL3]);
+	clks[IMX8MN_AUDIO_PLL1_BYPASS] = imx_clk_mux_flags("audio_pll1_bypass", base, 16, 1, audio_pll1_bypass_sels, ARRAY_SIZE(audio_pll1_bypass_sels), CLK_SET_RATE_PARENT);
+	clks[IMX8MN_AUDIO_PLL2_BYPASS] = imx_clk_mux_flags("audio_pll2_bypass", base + 0x14, 16, 1, audio_pll2_bypass_sels, ARRAY_SIZE(audio_pll2_bypass_sels), CLK_SET_RATE_PARENT);
+	clks[IMX8MN_VIDEO_PLL1_BYPASS] = imx_clk_mux_flags("video_pll1_bypass", base + 0x28, 16, 1, video_pll1_bypass_sels, ARRAY_SIZE(video_pll1_bypass_sels), CLK_SET_RATE_PARENT);
+	clks[IMX8MN_DRAM_PLL_BYPASS] = imx_clk_mux_flags("dram_pll_bypass", base + 0x50, 16, 1, dram_pll_bypass_sels, ARRAY_SIZE(dram_pll_bypass_sels), CLK_SET_RATE_PARENT);
+	clks[IMX8MN_GPU_PLL_BYPASS] = imx_clk_mux_flags("gpu_pll_bypass", base + 0x64, 28, 1, gpu_pll_bypass_sels, ARRAY_SIZE(gpu_pll_bypass_sels), CLK_SET_RATE_PARENT);
+	clks[IMX8MN_VPU_PLL_BYPASS] = imx_clk_mux_flags("vpu_pll_bypass", base + 0x74, 28, 1, vpu_pll_bypass_sels, ARRAY_SIZE(vpu_pll_bypass_sels), CLK_SET_RATE_PARENT);
+	clks[IMX8MN_ARM_PLL_BYPASS] = imx_clk_mux_flags("arm_pll_bypass", base + 0x84, 28, 1, arm_pll_bypass_sels, ARRAY_SIZE(arm_pll_bypass_sels), CLK_SET_RATE_PARENT);
+	clks[IMX8MN_SYS_PLL1_BYPASS] = imx_clk_mux_flags("sys_pll1_bypass", base + 0x94, 28, 1, sys_pll1_bypass_sels, ARRAY_SIZE(sys_pll1_bypass_sels), CLK_SET_RATE_PARENT);
+	clks[IMX8MN_SYS_PLL2_BYPASS] = imx_clk_mux_flags("sys_pll2_bypass", base + 0x104, 28, 1, sys_pll2_bypass_sels, ARRAY_SIZE(sys_pll2_bypass_sels), CLK_SET_RATE_PARENT);
+	clks[IMX8MN_SYS_PLL3_BYPASS] = imx_clk_mux_flags("sys_pll3_bypass", base + 0x114, 28, 1, sys_pll3_bypass_sels, ARRAY_SIZE(sys_pll3_bypass_sels), CLK_SET_RATE_PARENT);
 
 	/* PLL out gate */
 	clks[IMX8MN_AUDIO_PLL1_OUT] = imx_clk_gate("audio_pll1_out", "audio_pll1_bypass", base, 13);
-- 
2.16.4


^ permalink raw reply	[flat|nested] 13+ messages in thread

* RE: [PATCH V3 0/4] clk: imx8m: fix glitch/mux
  2019-09-09  3:39 [PATCH V3 0/4] clk: imx8m: fix glitch/mux Peng Fan
                   ` (3 preceding siblings ...)
  2019-09-09  3:39 ` [PATCH V3 4/4] clk: imx: imx8mn: " Peng Fan
@ 2019-09-17  6:20 ` Peng Fan
  2019-09-17 16:28   ` Stephen Boyd
  4 siblings, 1 reply; 13+ messages in thread
From: Peng Fan @ 2019-09-17  6:20 UTC (permalink / raw)
  To: mturquette, sboyd, shawnguo, s.hauer, festevam
  Cc: kernel, dl-linux-imx, Anson Huang, Jacky Bai, Abel Vesa,
	linux-clk, linux-arm-kernel, linux-kernel, Leonard Crestez

Hi Stephen, Shawn,

> Subject: [PATCH V3 0/4] clk: imx8m: fix glitch/mux

Sorry to ping early. Is there a chance to land this patchset in 5.3 release?

Thanks,
Peng.

> 
> From: Peng Fan <peng.fan@nxp.com>
> 
> V3:
>  Add cover-letter
> 
> V2:
>  Added patch [2,3,4]/4 and avoid glitch when prepare
> 
> There is two bypass bit in the pll, BYPASS and EXT_BYPASS.
> There is also a restriction that to avoid glitch, need set BYPASS bit when
> RESETB changed from 0 to 1, otherwise there will be glitch.
> 
> However the BYPASS bit is also used as mux bit in imx8mm/imx8mn clk driver.
> 
> This means two paths touch the same bit which is wrong. So switch to use
> EXT_BYPASS bit as the mux.
> 
> Peng Fan (4):
>   clk: imx: pll14xx: avoid glitch when set rate
>   clk: imx: clk-pll14xx: unbypass PLL by default
>   clk: imx: imx8mm: fix pll mux bit
>   clk: imx: imx8mn: fix pll mux bit
> 
>  drivers/clk/imx/clk-imx8mm.c  | 32 ++++++++++----------------------
> drivers/clk/imx/clk-imx8mn.c  | 32 ++++++++++----------------------
> drivers/clk/imx/clk-pll14xx.c | 27 ++++++++++++++++++++++++++-
>  3 files changed, 46 insertions(+), 45 deletions(-)
> 
> --
> 2.16.4


^ permalink raw reply	[flat|nested] 13+ messages in thread

* RE: [PATCH V3 0/4] clk: imx8m: fix glitch/mux
  2019-09-17  6:20 ` [PATCH V3 0/4] clk: imx8m: fix glitch/mux Peng Fan
@ 2019-09-17 16:28   ` Stephen Boyd
  2019-09-18  5:45     ` Peng Fan
  0 siblings, 1 reply; 13+ messages in thread
From: Stephen Boyd @ 2019-09-17 16:28 UTC (permalink / raw)
  To: festevam, mturquette, s.hauer, shawnguo, Peng Fan
  Cc: kernel, dl-linux-imx, Anson Huang, Jacky Bai, Abel Vesa,
	linux-clk, linux-arm-kernel, linux-kernel, Leonard Crestez

Quoting Peng Fan (2019-09-16 23:20:15)
> Hi Stephen, Shawn,
> 
> > Subject: [PATCH V3 0/4] clk: imx8m: fix glitch/mux
> 
> Sorry to ping early. Is there a chance to land this patchset in 5.3 release?
> 

No, it won't be in 5.3 because that version is released. Shawn already
sent the PR for 5.4 too so this will most likely be in v5.5 at the
earliest.


^ permalink raw reply	[flat|nested] 13+ messages in thread

* RE: [PATCH V3 0/4] clk: imx8m: fix glitch/mux
  2019-09-17 16:28   ` Stephen Boyd
@ 2019-09-18  5:45     ` Peng Fan
  2019-09-18  5:53       ` Stephen Boyd
  0 siblings, 1 reply; 13+ messages in thread
From: Peng Fan @ 2019-09-18  5:45 UTC (permalink / raw)
  To: Stephen Boyd, festevam, mturquette, s.hauer, shawnguo
  Cc: kernel, dl-linux-imx, Anson Huang, Jacky Bai, Abel Vesa,
	linux-clk, linux-arm-kernel, linux-kernel, Leonard Crestez

Hi Stephen,

> Subject: RE: [PATCH V3 0/4] clk: imx8m: fix glitch/mux
> 
> Quoting Peng Fan (2019-09-16 23:20:15)
> > Hi Stephen, Shawn,
> >
> > > Subject: [PATCH V3 0/4] clk: imx8m: fix glitch/mux
> >
> > Sorry to ping early. Is there a chance to land this patchset in 5.3 release?
> >
> 
> No, it won't be in 5.3 because that version is released. Shawn already sent the
> PR for 5.4 too so this will most likely be in v5.5 at the earliest.

Thanks for the info. But this patchset is bugfix, so hope this could be accepted in 5.4.

Thanks,
Peng.


^ permalink raw reply	[flat|nested] 13+ messages in thread

* RE: [PATCH V3 0/4] clk: imx8m: fix glitch/mux
  2019-09-18  5:45     ` Peng Fan
@ 2019-09-18  5:53       ` Stephen Boyd
  0 siblings, 0 replies; 13+ messages in thread
From: Stephen Boyd @ 2019-09-18  5:53 UTC (permalink / raw)
  To: festevam, mturquette, s.hauer, shawnguo, Peng Fan
  Cc: kernel, dl-linux-imx, Anson Huang, Jacky Bai, Abel Vesa,
	linux-clk, linux-arm-kernel, linux-kernel, Leonard Crestez

Quoting Peng Fan (2019-09-17 22:45:20)
> Hi Stephen,
> 
> > Subject: RE: [PATCH V3 0/4] clk: imx8m: fix glitch/mux
> > 
> > Quoting Peng Fan (2019-09-16 23:20:15)
> > > Hi Stephen, Shawn,
> > >
> > > > Subject: [PATCH V3 0/4] clk: imx8m: fix glitch/mux
> > >
> > > Sorry to ping early. Is there a chance to land this patchset in 5.3 release?
> > >
> > 
> > No, it won't be in 5.3 because that version is released. Shawn already sent the
> > PR for 5.4 too so this will most likely be in v5.5 at the earliest.
> 
> Thanks for the info. But this patchset is bugfix, so hope this could be accepted in 5.4.
> 

Ok. Then let's throw it into 5.4 PR and see what goes wrong.


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH V3 1/4] clk: imx: pll14xx: avoid glitch when set rate
  2019-09-09  3:39 ` [PATCH V3 1/4] clk: imx: pll14xx: avoid glitch when set rate Peng Fan
@ 2019-09-18  6:07   ` Stephen Boyd
  0 siblings, 0 replies; 13+ messages in thread
From: Stephen Boyd @ 2019-09-18  6:07 UTC (permalink / raw)
  To: festevam, mturquette, s.hauer, shawnguo, Peng Fan
  Cc: kernel, dl-linux-imx, Anson Huang, Jacky Bai, Abel Vesa,
	linux-clk, linux-arm-kernel, linux-kernel, Leonard Crestez,
	Peng Fan

Quoting Peng Fan (2019-09-08 20:39:34)
> From: Peng Fan <peng.fan@nxp.com>
> 
> According to PLL1443XA and PLL1416X spec,
> "When BYPASS is 0 and RESETB is changed from 0 to 1, FOUT starts to
> output unstable clock until lock time passes. PLL1416X/PLL1443XA may
> generate a glitch at FOUT."
> 
> So set BYPASS when RESETB is changed from 0 to 1 to avoid glitch.
> In the end of set rate, BYPASS will be cleared.
> 
> When prepare clock, also need to take care to avoid glitch. So
> we also follow Spec to set BYPASS before RESETB changed from 0 to 1.
> And add a check if the RESETB is already 0, directly return 0;
> 
> Fixes: 8646d4dcc7fb ("clk: imx: Add PLLs driver for imx8mm soc")
> Reviewed-by: Leonard Crestez <leonard.crestez@nxp.com>
> Signed-off-by: Peng Fan <peng.fan@nxp.com>
> ---

Applied to clk-next


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH V3 2/4] clk: imx: clk-pll14xx: unbypass PLL by default
  2019-09-09  3:39 ` [PATCH V3 2/4] clk: imx: clk-pll14xx: unbypass PLL by default Peng Fan
@ 2019-09-18  6:07   ` Stephen Boyd
  0 siblings, 0 replies; 13+ messages in thread
From: Stephen Boyd @ 2019-09-18  6:07 UTC (permalink / raw)
  To: festevam, mturquette, s.hauer, shawnguo, Peng Fan
  Cc: kernel, dl-linux-imx, Anson Huang, Jacky Bai, Abel Vesa,
	linux-clk, linux-arm-kernel, linux-kernel, Leonard Crestez,
	Peng Fan

Quoting Peng Fan (2019-09-08 20:39:39)
> From: Peng Fan <peng.fan@nxp.com>
> 
> When registering the PLL, unbypass the PLL.
> The PLL has two bypass control bit, BYPASS and EXT_BYPASS.
> we will expose EXT_BYPASS to clk driver for mux usage, and keep
> BYPASS inside pll14xx usage. The PLL has a restriction that
> when M/P change, need to RESET/BYPASS pll to avoid glitch, so
> we could not expose BYPASS.
> 
> To make it easy for clk driver usage, unbypass PLL which does
> not hurt current function.
> 
> Fixes: 8646d4dcc7fb ("clk: imx: Add PLLs driver for imx8mm soc")
> Reviewed-by: Leonard Crestez <leonard.crestez@nxp.com>
> Signed-off-by: Peng Fan <peng.fan@nxp.com>
> ---

Applied to clk-next


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH V3 3/4] clk: imx: imx8mm: fix pll mux bit
  2019-09-09  3:39 ` [PATCH V3 3/4] clk: imx: imx8mm: fix pll mux bit Peng Fan
@ 2019-09-18  6:07   ` Stephen Boyd
  0 siblings, 0 replies; 13+ messages in thread
From: Stephen Boyd @ 2019-09-18  6:07 UTC (permalink / raw)
  To: festevam, mturquette, s.hauer, shawnguo, Peng Fan
  Cc: kernel, dl-linux-imx, Anson Huang, Jacky Bai, Abel Vesa,
	linux-clk, linux-arm-kernel, linux-kernel, Leonard Crestez,
	Peng Fan

Quoting Peng Fan (2019-09-08 20:39:44)
> From: Peng Fan <peng.fan@nxp.com>
> 
> pll BYPASS bit should be kept inside pll driver for glitchless freq
> setting following spec. If exposing the bit, that means pll driver and
> clk driver has two paths to touch this bit, which is wrong.
> 
> So use EXT_BYPASS bit here.
> 
> And drop uneeded set parent, because EXT_BYPASS default is 0.
> 
> Fixes: ba5625c3e272 ("clk: imx: Add clock driver support for imx8mm")
> Suggested-by: Jacky Bai <ping.bai@nxp.com>
> Reviewed-by: Leonard Crestez <leonard.crestez@nxp.com>
> Signed-off-by: Peng Fan <peng.fan@nxp.com>
> ---

Applied to clk-next


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH V3 4/4] clk: imx: imx8mn: fix pll mux bit
  2019-09-09  3:39 ` [PATCH V3 4/4] clk: imx: imx8mn: " Peng Fan
@ 2019-09-18  6:07   ` Stephen Boyd
  0 siblings, 0 replies; 13+ messages in thread
From: Stephen Boyd @ 2019-09-18  6:07 UTC (permalink / raw)
  To: festevam, mturquette, s.hauer, shawnguo, Peng Fan
  Cc: kernel, dl-linux-imx, Anson Huang, Jacky Bai, Abel Vesa,
	linux-clk, linux-arm-kernel, linux-kernel, Leonard Crestez,
	Peng Fan

Quoting Peng Fan (2019-09-08 20:39:50)
> From: Peng Fan <peng.fan@nxp.com>
> 
> pll BYPASS bit should be kept inside pll driver for glitchless freq
> setting following spec. If exposing the bit, that means pll driver and
> clk driver has two paths to touch this bit, which is wrong.
> 
> So use EXT_BYPASS bit here.
> 
> And drop uneeded set parent, because EXT_BYPASS default is 0.
> 
> Suggested-by: Jacky Bai <ping.bai@nxp.com>
> Reviewed-by: Leonard Crestez <leonard.crestez@nxp.com>
> Signed-off-by: Peng Fan <peng.fan@nxp.com>
> ---

Applied to clk-next


^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, back to index

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-09  3:39 [PATCH V3 0/4] clk: imx8m: fix glitch/mux Peng Fan
2019-09-09  3:39 ` [PATCH V3 1/4] clk: imx: pll14xx: avoid glitch when set rate Peng Fan
2019-09-18  6:07   ` Stephen Boyd
2019-09-09  3:39 ` [PATCH V3 2/4] clk: imx: clk-pll14xx: unbypass PLL by default Peng Fan
2019-09-18  6:07   ` Stephen Boyd
2019-09-09  3:39 ` [PATCH V3 3/4] clk: imx: imx8mm: fix pll mux bit Peng Fan
2019-09-18  6:07   ` Stephen Boyd
2019-09-09  3:39 ` [PATCH V3 4/4] clk: imx: imx8mn: " Peng Fan
2019-09-18  6:07   ` Stephen Boyd
2019-09-17  6:20 ` [PATCH V3 0/4] clk: imx8m: fix glitch/mux Peng Fan
2019-09-17 16:28   ` Stephen Boyd
2019-09-18  5:45     ` Peng Fan
2019-09-18  5:53       ` Stephen Boyd

Linux-Clk Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-clk/0 linux-clk/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-clk linux-clk/ https://lore.kernel.org/linux-clk \
		linux-clk@vger.kernel.org linux-clk@archiver.kernel.org
	public-inbox-index linux-clk


Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-clk


AGPL code for this site: git clone https://public-inbox.org/ public-inbox