* [PATCH v2 0/3] clk: Fix issues related to CLK_IGNORE_UNUSED failures and amlogic glitch free mux
@ 2024-11-11 3:37 Chuan Liu via B4 Relay
2024-11-11 3:37 ` [PATCH v2 1/3] clk: Fix the CLK_IGNORE_UNUSED failure issue Chuan Liu via B4 Relay
` (2 more replies)
0 siblings, 3 replies; 7+ messages in thread
From: Chuan Liu via B4 Relay @ 2024-11-11 3:37 UTC (permalink / raw)
To: Michael Turquette, Stephen Boyd, Neil Armstrong, Jerome Brunet,
Kevin Hilman, Martin Blumenstingl
Cc: linux-clk, linux-kernel, linux-amlogic, linux-arm-kernel,
Chuan Liu
If CLK_OPS_PARENT_ENABLE is configured for clock,
clk_core_disable_unprepare() is called in clk_disable_unused_subtree().
Even clocks that are configured with CLK_IGNORE_UNUSED are disabled,
resulting in the failure of CLK_IGNORE_UNUSED.
To ensure that amlogic glitch free mux can switch clock channels
properly, add flag CLK_OPS_PARENT_ENABLE to glitch free mux. The issue
that CLK_OPS_PARENT_ENABLE in CCF causes CLK_IGNORE_UNUSED to fail is
also exposed.
glitch free mux channel switchover failure issue(Test vpu_clk on S4):
step 1:
$ cat /sys/kernel/debug/clk/vpu/clk_parent
vpu_0
$ cat /sys/kernel/debug/clk/vpu_0/clk_rate
399999994
$ cat /sys/kernel/debug/clk/vpu_1/clk_rate
666666656
$ echo 1 > /sys/kernel/debug/clk/vpu/clk_prepare_enable
$ cat /sys/kernel/debug/meson-clk-msr/clks/cts_vpu_clk
399987500 +/-12500Hz
step 2:
$ echo 0 > /sys/kernel/debug/clk/vpu/clk_prepare_enable
$ echo 1 > /sys/kernel/debug/clk/vpu/clk_parent
$ cat /sys/kernel/debug/clk/vpu/clk_parent
vpu_1
$ cat /sys/kernel/debug/clk/vpu/clk_rate
666666656
$ echo 1 > /sys/kernel/debug/clk/vpu/clk_prepare_enable
$ cat /sys/kernel/debug/meson-clk-msr/clks/cts_vpu_clk
0 +/-3125Hz
In step2, vpu_0 is disabled, and the vpu is not switched to vpu_1. At
this time, the vpu is still connected to vpu_0 and vpu_0 is disabled at
this time, resulting in the clk-measure not measuring the clock.
Signed-off-by: Chuan Liu <chuan.liu@amlogic.com>
---
Changes in v2:
- The failure of glitch-free mux switching and the suppression of glitch
are split into two patch.
- The glitch-free mux adds support for the meson-8 family.
- Link to v1: https://lore.kernel.org/r/20240929-fix_glitch_free-v1-0-22f9c36b7edf@amlogic.com
---
Chuan Liu (3):
clk: Fix the CLK_IGNORE_UNUSED failure issue
clk: meson: Fix failure of glitch-free mux switching
clk: meson: Fix glitch occurs when setting up glitch-free mux
drivers/clk/clk.c | 67 ++++++++++++++++++++++++++++++++++++--
drivers/clk/meson/a1-peripherals.c | 12 +++----
drivers/clk/meson/axg.c | 16 +++++----
drivers/clk/meson/c3-peripherals.c | 6 ++--
drivers/clk/meson/g12a.c | 18 ++++++----
drivers/clk/meson/gxbb.c | 18 ++++++----
drivers/clk/meson/meson8b.c | 21 ++++++++++--
drivers/clk/meson/s4-peripherals.c | 32 +++++++++---------
8 files changed, 140 insertions(+), 50 deletions(-)
---
base-commit: 664988eb47dd2d6ae1d9e4188ec91832562f8f26
change-id: 20240929-fix_glitch_free-290c88923c31
Best regards,
--
Chuan Liu <chuan.liu@amlogic.com>
_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic
^ permalink raw reply [flat|nested] 7+ messages in thread* [PATCH v2 1/3] clk: Fix the CLK_IGNORE_UNUSED failure issue 2024-11-11 3:37 [PATCH v2 0/3] clk: Fix issues related to CLK_IGNORE_UNUSED failures and amlogic glitch free mux Chuan Liu via B4 Relay @ 2024-11-11 3:37 ` Chuan Liu via B4 Relay 2024-11-12 8:41 ` Jerome Brunet 2024-11-11 3:37 ` [PATCH v2 2/3] clk: meson: Fix failure of glitch-free mux switching Chuan Liu via B4 Relay 2024-11-11 3:37 ` [PATCH v2 3/3] clk: meson: Fix glitch occurs when setting up glitch-free mux Chuan Liu via B4 Relay 2 siblings, 1 reply; 7+ messages in thread From: Chuan Liu via B4 Relay @ 2024-11-11 3:37 UTC (permalink / raw) To: Michael Turquette, Stephen Boyd, Neil Armstrong, Jerome Brunet, Kevin Hilman, Martin Blumenstingl Cc: linux-clk, linux-kernel, linux-amlogic, linux-arm-kernel, Chuan Liu From: Chuan Liu <chuan.liu@amlogic.com> When the clk_disable_unused_subtree() function disables an unused clock, if CLK_OPS_PARENT_ENABLE is configured on the clock, clk_core_prepare_enable() and clk_core_disable_unprepare() are called directly, and these two functions do not determine CLK_IGNORE_UNUSED, This causes the clock to be disabled even if CLK_IGNORE_UNUSED is configured when clk_core_disable_unprepare() is called. Two new functions clk_disable_unprepare_unused() and clk_prepare_enable_unused() are added to resolve the preceding situation. The CLK_IGNORE_UNUSED judgment logic is added to these two functions. To prevent clock configuration CLK_IGNORE_UNUSED from possible failure. Fixes: a4b3518d146f ("clk: core: support clocks which requires parents enable (part 1)") Signed-off-by: Chuan Liu <chuan.liu@amlogic.com> --- drivers/clk/clk.c | 67 +++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 65 insertions(+), 2 deletions(-) diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c index d02451f951cf..6def76c30ce6 100644 --- a/drivers/clk/clk.c +++ b/drivers/clk/clk.c @@ -94,6 +94,7 @@ struct clk_core { struct hlist_node debug_node; #endif struct kref ref; + bool ignore_enabled; }; #define CREATE_TRACE_POINTS @@ -1479,6 +1480,68 @@ static void __init clk_unprepare_unused_subtree(struct clk_core *core) } } +static void __init clk_disable_unprepare_unused(struct clk_core *core) +{ + unsigned long flags; + + lockdep_assert_held(&prepare_lock); + + if (!core) + return; + + if ((core->enable_count == 0) && core->ops->disable && + !core->ignore_enabled) { + flags = clk_enable_lock(); + core->ops->disable(core->hw); + clk_enable_unlock(flags); + } + + if ((core->prepare_count == 0) && core->ops->unprepare && + !core->ignore_enabled) + core->ops->unprepare(core->hw); + + core->ignore_enabled = false; + + clk_disable_unprepare_unused(core->parent); +} + +static int __init clk_prepare_enable_unused(struct clk_core *core) +{ + int ret = 0; + unsigned long flags; + + lockdep_assert_held(&prepare_lock); + + if (!core) + return 0; + + ret = clk_prepare_enable_unused(core->parent); + if (ret) + return ret; + + if ((core->flags & CLK_IGNORE_UNUSED) && clk_core_is_enabled(core)) + core->ignore_enabled = true; + + if ((core->prepare_count == 0) && core->ops->prepare) { + ret = core->ops->prepare(core->hw); + if (ret) + goto disable_unprepare; + } + + if ((core->enable_count == 0) && core->ops->enable) { + flags = clk_enable_lock(); + ret = core->ops->enable(core->hw); + clk_enable_unlock(flags); + if (ret) + goto disable_unprepare; + } + + return 0; +disable_unprepare: + clk_disable_unprepare_unused(core->parent); + return ret; +} + static void __init clk_disable_unused_subtree(struct clk_core *core) { struct clk_core *child; @@ -1490,7 +1553,7 @@ static void __init clk_disable_unused_subtree(struct clk_core *core) clk_disable_unused_subtree(child); if (core->flags & CLK_OPS_PARENT_ENABLE) - clk_core_prepare_enable(core->parent); + clk_prepare_enable_unused(core->parent); flags = clk_enable_lock(); @@ -1517,7 +1580,7 @@ static void __init clk_disable_unused_subtree(struct clk_core *core) unlock_out: clk_enable_unlock(flags); if (core->flags & CLK_OPS_PARENT_ENABLE) - clk_core_disable_unprepare(core->parent); + clk_disable_unprepare_unused(core->parent); } static bool clk_ignore_unused __initdata; -- 2.42.0 _______________________________________________ linux-amlogic mailing list linux-amlogic@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-amlogic ^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH v2 1/3] clk: Fix the CLK_IGNORE_UNUSED failure issue 2024-11-11 3:37 ` [PATCH v2 1/3] clk: Fix the CLK_IGNORE_UNUSED failure issue Chuan Liu via B4 Relay @ 2024-11-12 8:41 ` Jerome Brunet 0 siblings, 0 replies; 7+ messages in thread From: Jerome Brunet @ 2024-11-12 8:41 UTC (permalink / raw) To: Chuan Liu via B4 Relay Cc: Michael Turquette, Stephen Boyd, Neil Armstrong, Kevin Hilman, Martin Blumenstingl, chuan.liu, linux-clk, linux-kernel, linux-amlogic, linux-arm-kernel On Mon 11 Nov 2024 at 11:37, Chuan Liu via B4 Relay <devnull+chuan.liu.amlogic.com@kernel.org> wrote: > From: Chuan Liu <chuan.liu@amlogic.com> > > When the clk_disable_unused_subtree() function disables an unused clock, > if CLK_OPS_PARENT_ENABLE is configured on the clock, > clk_core_prepare_enable() and clk_core_disable_unprepare() are called > directly, and these two functions do not determine CLK_IGNORE_UNUSED, > This causes the clock to be disabled even if CLK_IGNORE_UNUSED is > configured when clk_core_disable_unprepare() is called. > > Two new functions clk_disable_unprepare_unused() and > clk_prepare_enable_unused() are added to resolve the preceding > situation. The CLK_IGNORE_UNUSED judgment logic is added to these two > functions. To prevent clock configuration CLK_IGNORE_UNUSED from > possible failure. > > Fixes: a4b3518d146f ("clk: core: support clocks which requires parents > enable (part 1)") Still don't think a storing the ignored state is necessary, same as v1. > Signed-off-by: Chuan Liu <chuan.liu@amlogic.com> > --- > drivers/clk/clk.c | 67 +++++++++++++++++++++++++++++++++++++++++++++++++++++-- > 1 file changed, 65 insertions(+), 2 deletions(-) > > diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c > index d02451f951cf..6def76c30ce6 100644 > --- a/drivers/clk/clk.c > +++ b/drivers/clk/clk.c > @@ -94,6 +94,7 @@ struct clk_core { > struct hlist_node debug_node; > #endif > struct kref ref; > + bool ignore_enabled; > }; > > #define CREATE_TRACE_POINTS > @@ -1479,6 +1480,68 @@ static void __init clk_unprepare_unused_subtree(struct clk_core *core) > } > } > > +static void __init clk_disable_unprepare_unused(struct clk_core *core) > +{ > + unsigned long flags; > + > + lockdep_assert_held(&prepare_lock); > + > + if (!core) > + return; > + > + if ((core->enable_count == 0) && core->ops->disable && > + !core->ignore_enabled) { > + flags = clk_enable_lock(); > + core->ops->disable(core->hw); > + clk_enable_unlock(flags); > + } > + > + if ((core->prepare_count == 0) && core->ops->unprepare && > + !core->ignore_enabled) > + core->ops->unprepare(core->hw); > + > + core->ignore_enabled = false; > + > + clk_disable_unprepare_unused(core->parent); > +} > + > +static int __init clk_prepare_enable_unused(struct clk_core *core) > +{ > + int ret = 0; > + unsigned long flags; > + > + lockdep_assert_held(&prepare_lock); > + > + if (!core) > + return 0; > + > + ret = clk_prepare_enable_unused(core->parent); > + if (ret) > + return ret; > + > + if ((core->flags & CLK_IGNORE_UNUSED) && clk_core_is_enabled(core)) > + core->ignore_enabled = true; > + > + if ((core->prepare_count == 0) && core->ops->prepare) { > + ret = core->ops->prepare(core->hw); > + if (ret) > + goto disable_unprepare; > + } > + > + if ((core->enable_count == 0) && core->ops->enable) { > + flags = clk_enable_lock(); > + ret = core->ops->enable(core->hw); > + clk_enable_unlock(flags); > + if (ret) > + goto disable_unprepare; > + } > + > + return 0; > +disable_unprepare: > + clk_disable_unprepare_unused(core->parent); > + return ret; > +} > + > static void __init clk_disable_unused_subtree(struct clk_core *core) > { > struct clk_core *child; > @@ -1490,7 +1553,7 @@ static void __init clk_disable_unused_subtree(struct clk_core *core) > clk_disable_unused_subtree(child); > > if (core->flags & CLK_OPS_PARENT_ENABLE) > - clk_core_prepare_enable(core->parent); > + clk_prepare_enable_unused(core->parent); > > flags = clk_enable_lock(); > > @@ -1517,7 +1580,7 @@ static void __init clk_disable_unused_subtree(struct clk_core *core) > unlock_out: > clk_enable_unlock(flags); > if (core->flags & CLK_OPS_PARENT_ENABLE) > - clk_core_disable_unprepare(core->parent); > + clk_disable_unprepare_unused(core->parent); > } > > static bool clk_ignore_unused __initdata; -- Jerome _______________________________________________ linux-amlogic mailing list linux-amlogic@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-amlogic ^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH v2 2/3] clk: meson: Fix failure of glitch-free mux switching 2024-11-11 3:37 [PATCH v2 0/3] clk: Fix issues related to CLK_IGNORE_UNUSED failures and amlogic glitch free mux Chuan Liu via B4 Relay 2024-11-11 3:37 ` [PATCH v2 1/3] clk: Fix the CLK_IGNORE_UNUSED failure issue Chuan Liu via B4 Relay @ 2024-11-11 3:37 ` Chuan Liu via B4 Relay 2024-11-12 8:32 ` Jerome Brunet 2024-11-11 3:37 ` [PATCH v2 3/3] clk: meson: Fix glitch occurs when setting up glitch-free mux Chuan Liu via B4 Relay 2 siblings, 1 reply; 7+ messages in thread From: Chuan Liu via B4 Relay @ 2024-11-11 3:37 UTC (permalink / raw) To: Michael Turquette, Stephen Boyd, Neil Armstrong, Jerome Brunet, Kevin Hilman, Martin Blumenstingl Cc: linux-clk, linux-kernel, linux-amlogic, linux-arm-kernel, Chuan Liu From: Chuan Liu <chuan.liu@amlogic.com> glitch-free mux has two clock channels (channel 0 and channel 1) with the same configuration.Channel 0 of glitch-free mux is not only the clock source for the mux, but also the working clock for glitch free mux. Therefore, when glitch-free mux switches, it is necessary to ensure that channel 0 has a clock input, otherwise glitch free mux will not work and cannot switch to the target channel. So adding flag CLK_OPS_PARENT_ENABLE ensures that both channels 0 and 1 are enabled when mux switches. In fact, we just need to make sure that channel 0 is enabled. The purpose of CLK_OPS_PARENT_ENABLE may not be to solve our situation, but adding this flag does solve our current problem. Fixes: 84af914404db ("clk: meson: a1: add Amlogic A1 Peripherals clock controller driver") Fixes: 14ebb3154b8f ("clk: meson: axg: add Video Clocks") Fixes: f06ac3ed04e8 ("clk: meson: c3: add c3 clock peripherals controller driver") Fixes: 085a4ea93d54 ("clk: meson: g12a: add peripheral clock controller") Fixes: fac9a55b66c9 ("clk: meson-gxbb: Add MALI clocks") Fixes: 74e1f2521f16 ("clk: meson: meson8b: add the GPU clock tree") Fixes: 57b55c76aaf1 ("clk: meson: S4: add support for Amlogic S4 SoC peripheral clock controller") Signed-off-by: Chuan Liu <chuan.liu@amlogic.com> --- drivers/clk/meson/a1-peripherals.c | 4 ++-- drivers/clk/meson/axg.c | 4 ++-- drivers/clk/meson/c3-peripherals.c | 2 +- drivers/clk/meson/g12a.c | 6 +++--- drivers/clk/meson/gxbb.c | 6 +++--- drivers/clk/meson/meson8b.c | 21 ++++++++++++++++++--- drivers/clk/meson/s4-peripherals.c | 12 ++++++------ 7 files changed, 35 insertions(+), 20 deletions(-) diff --git a/drivers/clk/meson/a1-peripherals.c b/drivers/clk/meson/a1-peripherals.c index 7aa6abb2eb1f..4b9686916b17 100644 --- a/drivers/clk/meson/a1-peripherals.c +++ b/drivers/clk/meson/a1-peripherals.c @@ -489,7 +489,7 @@ static struct clk_regmap dspa_sel = { &dspa_b.hw, }, .num_parents = 2, - .flags = CLK_SET_RATE_PARENT, + .flags = CLK_SET_RATE_PARENT | CLK_OPS_PARENT_ENABLE, }, }; @@ -635,7 +635,7 @@ static struct clk_regmap dspb_sel = { &dspb_b.hw, }, .num_parents = 2, - .flags = CLK_SET_RATE_PARENT, + .flags = CLK_SET_RATE_PARENT | CLK_OPS_PARENT_ENABLE, }, }; diff --git a/drivers/clk/meson/axg.c b/drivers/clk/meson/axg.c index 1b08daf579b2..a1217dff40fa 100644 --- a/drivers/clk/meson/axg.c +++ b/drivers/clk/meson/axg.c @@ -1144,7 +1144,7 @@ static struct clk_regmap axg_vpu = { &axg_vpu_1.hw }, .num_parents = 2, - .flags = CLK_SET_RATE_NO_REPARENT, + .flags = CLK_SET_RATE_NO_REPARENT | CLK_OPS_PARENT_ENABLE, }, }; @@ -1260,7 +1260,7 @@ static struct clk_regmap axg_vapb_sel = { &axg_vapb_1.hw }, .num_parents = 2, - .flags = CLK_SET_RATE_NO_REPARENT, + .flags = CLK_SET_RATE_NO_REPARENT | CLK_OPS_PARENT_ENABLE, }, }; diff --git a/drivers/clk/meson/c3-peripherals.c b/drivers/clk/meson/c3-peripherals.c index 7dcbf4ebee07..4566c2aeeb19 100644 --- a/drivers/clk/meson/c3-peripherals.c +++ b/drivers/clk/meson/c3-peripherals.c @@ -1431,7 +1431,7 @@ static struct clk_regmap hcodec = { .ops = &clk_regmap_mux_ops, .parent_data = hcodec_parent_data, .num_parents = ARRAY_SIZE(hcodec_parent_data), - .flags = CLK_SET_RATE_PARENT, + .flags = CLK_SET_RATE_PARENT | CLK_OPS_PARENT_ENABLE, }, }; diff --git a/drivers/clk/meson/g12a.c b/drivers/clk/meson/g12a.c index d3539fe9f7af..4d3b064d09fc 100644 --- a/drivers/clk/meson/g12a.c +++ b/drivers/clk/meson/g12a.c @@ -2812,7 +2812,7 @@ static struct clk_regmap g12a_vpu = { &g12a_vpu_1.hw, }, .num_parents = 2, - .flags = CLK_SET_RATE_NO_REPARENT, + .flags = CLK_SET_RATE_NO_REPARENT | CLK_OPS_PARENT_ENABLE, }, }; @@ -3105,7 +3105,7 @@ static struct clk_regmap g12a_vapb_sel = { &g12a_vapb_1.hw, }, .num_parents = 2, - .flags = CLK_SET_RATE_NO_REPARENT, + .flags = CLK_SET_RATE_NO_REPARENT | CLK_OPS_PARENT_ENABLE, }, }; @@ -4039,7 +4039,7 @@ static struct clk_regmap g12a_mali = { .ops = &clk_regmap_mux_ops, .parent_hws = g12a_mali_parent_hws, .num_parents = 2, - .flags = CLK_SET_RATE_PARENT, + .flags = CLK_SET_RATE_PARENT | CLK_OPS_PARENT_ENABLE, }, }; diff --git a/drivers/clk/meson/gxbb.c b/drivers/clk/meson/gxbb.c index 262c318edbd5..dfa9ffc61b41 100644 --- a/drivers/clk/meson/gxbb.c +++ b/drivers/clk/meson/gxbb.c @@ -1132,7 +1132,7 @@ static struct clk_regmap gxbb_mali = { .ops = &clk_regmap_mux_ops, .parent_hws = gxbb_mali_parent_hws, .num_parents = 2, - .flags = CLK_SET_RATE_PARENT, + .flags = CLK_SET_RATE_PARENT | CLK_OPS_PARENT_ENABLE, }, }; @@ -1613,7 +1613,7 @@ static struct clk_regmap gxbb_vpu = { &gxbb_vpu_1.hw }, .num_parents = 2, - .flags = CLK_SET_RATE_NO_REPARENT, + .flags = CLK_SET_RATE_NO_REPARENT | CLK_OPS_PARENT_ENABLE, }, }; @@ -1748,7 +1748,7 @@ static struct clk_regmap gxbb_vapb_sel = { &gxbb_vapb_1.hw }, .num_parents = 2, - .flags = CLK_SET_RATE_NO_REPARENT, + .flags = CLK_SET_RATE_NO_REPARENT | CLK_OPS_PARENT_ENABLE, }, }; diff --git a/drivers/clk/meson/meson8b.c b/drivers/clk/meson/meson8b.c index e4b474c5f86c..0af76b527e5b 100644 --- a/drivers/clk/meson/meson8b.c +++ b/drivers/clk/meson/meson8b.c @@ -1997,7 +1997,22 @@ static struct clk_regmap meson8b_mali = { &meson8b_mali_1.hw, }, .num_parents = 2, - .flags = CLK_SET_RATE_PARENT, + /* + * glitch-free mux has two clock channels (channel 0 and + * channel 1) with the same configuration.Channel 0 of + * glitch-free mux is not only the clock source for the mux, + * but also the working clock for glitch free mux. Therefore, + * when glitch-free mux switches, it is necessary to ensure that + * channel 0 has a clock input, otherwise glitch free mux will + * not work and cannot switch to the target channel. So adding + * flag CLK_OPS_PARENT_ENABLE ensures that both channels 0 and 1 + * are enabled when mux switches. + * + * In fact, we just need to make sure that channel 0 is enabled. + * The purpose of CLK_OPS_PARENT_ENABLE may not be to solve our + * situation, but adding this flag does solve our current problem. + */ + .flags = CLK_SET_RATE_PARENT | CLK_OPS_PARENT_ENABLE, }, }; @@ -2252,7 +2267,7 @@ static struct clk_regmap meson8b_vpu = { &meson8b_vpu_1.hw, }, .num_parents = 2, - .flags = CLK_SET_RATE_PARENT, + .flags = CLK_SET_RATE_PARENT | CLK_OPS_PARENT_ENABLE, }, }; @@ -2364,7 +2379,7 @@ static struct clk_regmap meson8b_vdec_1 = { &meson8b_vdec_1_2.hw, }, .num_parents = 2, - .flags = CLK_SET_RATE_PARENT, + .flags = CLK_SET_RATE_PARENT | CLK_OPS_PARENT_ENABLE, }, }; diff --git a/drivers/clk/meson/s4-peripherals.c b/drivers/clk/meson/s4-peripherals.c index c930cf0614a0..79e0240d58e6 100644 --- a/drivers/clk/meson/s4-peripherals.c +++ b/drivers/clk/meson/s4-peripherals.c @@ -1404,7 +1404,7 @@ static struct clk_regmap s4_mali_mux = { .ops = &clk_regmap_mux_ops, .parent_hws = s4_mali_parent_hws, .num_parents = 2, - .flags = CLK_SET_RATE_PARENT, + .flags = CLK_SET_RATE_PARENT | CLK_OPS_PARENT_ENABLE, }, }; @@ -1536,7 +1536,7 @@ static struct clk_regmap s4_vdec_mux = { .ops = &clk_regmap_mux_ops, .parent_hws = s4_vdec_mux_parent_hws, .num_parents = ARRAY_SIZE(s4_vdec_mux_parent_hws), - .flags = CLK_SET_RATE_PARENT, + .flags = CLK_SET_RATE_PARENT | CLK_OPS_PARENT_ENABLE, }, }; @@ -1656,7 +1656,7 @@ static struct clk_regmap s4_hevcf_mux = { .ops = &clk_regmap_mux_ops, .parent_hws = s4_hevcf_mux_parent_hws, .num_parents = ARRAY_SIZE(s4_hevcf_mux_parent_hws), - .flags = CLK_SET_RATE_PARENT, + .flags = CLK_SET_RATE_PARENT | CLK_OPS_PARENT_ENABLE, }, }; @@ -1774,7 +1774,7 @@ static struct clk_regmap s4_vpu = { &s4_vpu_1.hw, }, .num_parents = 2, - .flags = CLK_SET_RATE_PARENT, + .flags = CLK_SET_RATE_PARENT | CLK_OPS_PARENT_ENABLE, }, }; @@ -1989,7 +1989,7 @@ static struct clk_regmap s4_vpu_clkc_mux = { .ops = &clk_regmap_mux_ops, .parent_hws = s4_vpu_mux_parent_hws, .num_parents = ARRAY_SIZE(s4_vpu_mux_parent_hws), - .flags = CLK_SET_RATE_PARENT, + .flags = CLK_SET_RATE_PARENT | CLK_OPS_PARENT_ENABLE, }, }; @@ -2115,7 +2115,7 @@ static struct clk_regmap s4_vapb = { &s4_vapb_1.hw }, .num_parents = 2, - .flags = CLK_SET_RATE_PARENT, + .flags = CLK_SET_RATE_PARENT | CLK_OPS_PARENT_ENABLE, }, }; -- 2.42.0 _______________________________________________ linux-amlogic mailing list linux-amlogic@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-amlogic ^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH v2 2/3] clk: meson: Fix failure of glitch-free mux switching 2024-11-11 3:37 ` [PATCH v2 2/3] clk: meson: Fix failure of glitch-free mux switching Chuan Liu via B4 Relay @ 2024-11-12 8:32 ` Jerome Brunet 0 siblings, 0 replies; 7+ messages in thread From: Jerome Brunet @ 2024-11-12 8:32 UTC (permalink / raw) To: Chuan Liu via B4 Relay Cc: Michael Turquette, Stephen Boyd, Neil Armstrong, Kevin Hilman, Martin Blumenstingl, chuan.liu, linux-clk, linux-kernel, linux-amlogic, linux-arm-kernel On Mon 11 Nov 2024 at 11:37, Chuan Liu via B4 Relay <devnull+chuan.liu.amlogic.com@kernel.org> wrote: > From: Chuan Liu <chuan.liu@amlogic.com> > > glitch-free mux has two clock channels (channel 0 and channel 1) with > the same configuration.Channel 0 of glitch-free mux is not only the > clock source for the mux, but also the working clock for glitch free > mux. Therefore, when glitch-free mux switches, it is necessary to ensure > that channel 0 has a clock input, otherwise glitch free mux will not > work and cannot switch to the target channel. So adding flag > CLK_OPS_PARENT_ENABLE ensures that both channels 0 and 1 are enabled > when mux switches. > > In fact, we just need to make sure that channel 0 is enabled. The > purpose of CLK_OPS_PARENT_ENABLE may not be to solve our situation, but > adding this flag does solve our current problem. > > Fixes: 84af914404db ("clk: meson: a1: add Amlogic A1 Peripherals clock > controller driver") Fix your mailer please > Fixes: 14ebb3154b8f ("clk: meson: axg: add Video Clocks") > Fixes: f06ac3ed04e8 ("clk: meson: c3: add c3 clock peripherals controller > driver") > Fixes: 085a4ea93d54 ("clk: meson: g12a: add peripheral clock controller") > Fixes: fac9a55b66c9 ("clk: meson-gxbb: Add MALI clocks") > Fixes: 74e1f2521f16 ("clk: meson: meson8b: add the GPU clock tree") > Fixes: 57b55c76aaf1 ("clk: meson: S4: add support for Amlogic S4 SoC > peripheral clock controller") There is no reason to mix up so many things together. > Signed-off-by: Chuan Liu <chuan.liu@amlogic.com> > --- > drivers/clk/meson/a1-peripherals.c | 4 ++-- > drivers/clk/meson/axg.c | 4 ++-- > drivers/clk/meson/c3-peripherals.c | 2 +- > drivers/clk/meson/g12a.c | 6 +++--- > drivers/clk/meson/gxbb.c | 6 +++--- > drivers/clk/meson/meson8b.c | 21 ++++++++++++++++++--- > drivers/clk/meson/s4-peripherals.c | 12 ++++++------ > 7 files changed, 35 insertions(+), 20 deletions(-) > > diff --git a/drivers/clk/meson/a1-peripherals.c b/drivers/clk/meson/a1-peripherals.c > index 7aa6abb2eb1f..4b9686916b17 100644 > --- a/drivers/clk/meson/a1-peripherals.c > +++ b/drivers/clk/meson/a1-peripherals.c > @@ -489,7 +489,7 @@ static struct clk_regmap dspa_sel = { > &dspa_b.hw, > }, > .num_parents = 2, > - .flags = CLK_SET_RATE_PARENT, > + .flags = CLK_SET_RATE_PARENT | CLK_OPS_PARENT_ENABLE, > }, > }; > > @@ -635,7 +635,7 @@ static struct clk_regmap dspb_sel = { > &dspb_b.hw, > }, > .num_parents = 2, > - .flags = CLK_SET_RATE_PARENT, > + .flags = CLK_SET_RATE_PARENT | CLK_OPS_PARENT_ENABLE, > }, > }; > > diff --git a/drivers/clk/meson/axg.c b/drivers/clk/meson/axg.c > index 1b08daf579b2..a1217dff40fa 100644 > --- a/drivers/clk/meson/axg.c > +++ b/drivers/clk/meson/axg.c > @@ -1144,7 +1144,7 @@ static struct clk_regmap axg_vpu = { > &axg_vpu_1.hw > }, > .num_parents = 2, > - .flags = CLK_SET_RATE_NO_REPARENT, > + .flags = CLK_SET_RATE_NO_REPARENT | CLK_OPS_PARENT_ENABLE, > }, > }; > > @@ -1260,7 +1260,7 @@ static struct clk_regmap axg_vapb_sel = { > &axg_vapb_1.hw > }, > .num_parents = 2, > - .flags = CLK_SET_RATE_NO_REPARENT, > + .flags = CLK_SET_RATE_NO_REPARENT | CLK_OPS_PARENT_ENABLE, > }, > }; > > diff --git a/drivers/clk/meson/c3-peripherals.c b/drivers/clk/meson/c3-peripherals.c > index 7dcbf4ebee07..4566c2aeeb19 100644 > --- a/drivers/clk/meson/c3-peripherals.c > +++ b/drivers/clk/meson/c3-peripherals.c > @@ -1431,7 +1431,7 @@ static struct clk_regmap hcodec = { > .ops = &clk_regmap_mux_ops, > .parent_data = hcodec_parent_data, > .num_parents = ARRAY_SIZE(hcodec_parent_data), > - .flags = CLK_SET_RATE_PARENT, > + .flags = CLK_SET_RATE_PARENT | CLK_OPS_PARENT_ENABLE, > }, > }; > > diff --git a/drivers/clk/meson/g12a.c b/drivers/clk/meson/g12a.c > index d3539fe9f7af..4d3b064d09fc 100644 > --- a/drivers/clk/meson/g12a.c > +++ b/drivers/clk/meson/g12a.c > @@ -2812,7 +2812,7 @@ static struct clk_regmap g12a_vpu = { > &g12a_vpu_1.hw, > }, > .num_parents = 2, > - .flags = CLK_SET_RATE_NO_REPARENT, > + .flags = CLK_SET_RATE_NO_REPARENT | CLK_OPS_PARENT_ENABLE, > }, > }; > > @@ -3105,7 +3105,7 @@ static struct clk_regmap g12a_vapb_sel = { > &g12a_vapb_1.hw, > }, > .num_parents = 2, > - .flags = CLK_SET_RATE_NO_REPARENT, > + .flags = CLK_SET_RATE_NO_REPARENT | CLK_OPS_PARENT_ENABLE, > }, > }; > > @@ -4039,7 +4039,7 @@ static struct clk_regmap g12a_mali = { > .ops = &clk_regmap_mux_ops, > .parent_hws = g12a_mali_parent_hws, > .num_parents = 2, > - .flags = CLK_SET_RATE_PARENT, > + .flags = CLK_SET_RATE_PARENT | CLK_OPS_PARENT_ENABLE, > }, > }; > > diff --git a/drivers/clk/meson/gxbb.c b/drivers/clk/meson/gxbb.c > index 262c318edbd5..dfa9ffc61b41 100644 > --- a/drivers/clk/meson/gxbb.c > +++ b/drivers/clk/meson/gxbb.c > @@ -1132,7 +1132,7 @@ static struct clk_regmap gxbb_mali = { > .ops = &clk_regmap_mux_ops, > .parent_hws = gxbb_mali_parent_hws, > .num_parents = 2, > - .flags = CLK_SET_RATE_PARENT, > + .flags = CLK_SET_RATE_PARENT | CLK_OPS_PARENT_ENABLE, > }, > }; > > @@ -1613,7 +1613,7 @@ static struct clk_regmap gxbb_vpu = { > &gxbb_vpu_1.hw > }, > .num_parents = 2, > - .flags = CLK_SET_RATE_NO_REPARENT, > + .flags = CLK_SET_RATE_NO_REPARENT | CLK_OPS_PARENT_ENABLE, > }, > }; > > @@ -1748,7 +1748,7 @@ static struct clk_regmap gxbb_vapb_sel = { > &gxbb_vapb_1.hw > }, > .num_parents = 2, > - .flags = CLK_SET_RATE_NO_REPARENT, > + .flags = CLK_SET_RATE_NO_REPARENT | CLK_OPS_PARENT_ENABLE, > }, > }; > > diff --git a/drivers/clk/meson/meson8b.c b/drivers/clk/meson/meson8b.c > index e4b474c5f86c..0af76b527e5b 100644 > --- a/drivers/clk/meson/meson8b.c > +++ b/drivers/clk/meson/meson8b.c > @@ -1997,7 +1997,22 @@ static struct clk_regmap meson8b_mali = { > &meson8b_mali_1.hw, > }, > .num_parents = 2, > - .flags = CLK_SET_RATE_PARENT, > + /* > + * glitch-free mux has two clock channels (channel 0 and > + * channel 1) with the same configuration.Channel 0 of > + * glitch-free mux is not only the clock source for the mux, > + * but also the working clock for glitch free mux. Therefore, > + * when glitch-free mux switches, it is necessary to ensure that > + * channel 0 has a clock input, otherwise glitch free mux will > + * not work and cannot switch to the target channel. So adding > + * flag CLK_OPS_PARENT_ENABLE ensures that both channels 0 and 1 > + * are enabled when mux switches. > + * > + * In fact, we just need to make sure that channel 0 is enabled. > + * The purpose of CLK_OPS_PARENT_ENABLE may not be to solve our > + * situation, but adding this flag does solve our current problem. > + */ > + .flags = CLK_SET_RATE_PARENT | CLK_OPS_PARENT_ENABLE, > }, > }; > > @@ -2252,7 +2267,7 @@ static struct clk_regmap meson8b_vpu = { > &meson8b_vpu_1.hw, > }, > .num_parents = 2, > - .flags = CLK_SET_RATE_PARENT, > + .flags = CLK_SET_RATE_PARENT | CLK_OPS_PARENT_ENABLE, > }, > }; > > @@ -2364,7 +2379,7 @@ static struct clk_regmap meson8b_vdec_1 = { > &meson8b_vdec_1_2.hw, > }, > .num_parents = 2, > - .flags = CLK_SET_RATE_PARENT, > + .flags = CLK_SET_RATE_PARENT | CLK_OPS_PARENT_ENABLE, > }, > }; > > diff --git a/drivers/clk/meson/s4-peripherals.c b/drivers/clk/meson/s4-peripherals.c > index c930cf0614a0..79e0240d58e6 100644 > --- a/drivers/clk/meson/s4-peripherals.c > +++ b/drivers/clk/meson/s4-peripherals.c > @@ -1404,7 +1404,7 @@ static struct clk_regmap s4_mali_mux = { > .ops = &clk_regmap_mux_ops, > .parent_hws = s4_mali_parent_hws, > .num_parents = 2, > - .flags = CLK_SET_RATE_PARENT, > + .flags = CLK_SET_RATE_PARENT | CLK_OPS_PARENT_ENABLE, > }, > }; > > @@ -1536,7 +1536,7 @@ static struct clk_regmap s4_vdec_mux = { > .ops = &clk_regmap_mux_ops, > .parent_hws = s4_vdec_mux_parent_hws, > .num_parents = ARRAY_SIZE(s4_vdec_mux_parent_hws), > - .flags = CLK_SET_RATE_PARENT, > + .flags = CLK_SET_RATE_PARENT | CLK_OPS_PARENT_ENABLE, > }, > }; > > @@ -1656,7 +1656,7 @@ static struct clk_regmap s4_hevcf_mux = { > .ops = &clk_regmap_mux_ops, > .parent_hws = s4_hevcf_mux_parent_hws, > .num_parents = ARRAY_SIZE(s4_hevcf_mux_parent_hws), > - .flags = CLK_SET_RATE_PARENT, > + .flags = CLK_SET_RATE_PARENT | CLK_OPS_PARENT_ENABLE, > }, > }; > > @@ -1774,7 +1774,7 @@ static struct clk_regmap s4_vpu = { > &s4_vpu_1.hw, > }, > .num_parents = 2, > - .flags = CLK_SET_RATE_PARENT, > + .flags = CLK_SET_RATE_PARENT | CLK_OPS_PARENT_ENABLE, > }, > }; > > @@ -1989,7 +1989,7 @@ static struct clk_regmap s4_vpu_clkc_mux = { > .ops = &clk_regmap_mux_ops, > .parent_hws = s4_vpu_mux_parent_hws, > .num_parents = ARRAY_SIZE(s4_vpu_mux_parent_hws), > - .flags = CLK_SET_RATE_PARENT, > + .flags = CLK_SET_RATE_PARENT | CLK_OPS_PARENT_ENABLE, > }, > }; > > @@ -2115,7 +2115,7 @@ static struct clk_regmap s4_vapb = { > &s4_vapb_1.hw > }, > .num_parents = 2, > - .flags = CLK_SET_RATE_PARENT, > + .flags = CLK_SET_RATE_PARENT | CLK_OPS_PARENT_ENABLE, > }, > }; -- Jerome _______________________________________________ linux-amlogic mailing list linux-amlogic@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-amlogic ^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH v2 3/3] clk: meson: Fix glitch occurs when setting up glitch-free mux 2024-11-11 3:37 [PATCH v2 0/3] clk: Fix issues related to CLK_IGNORE_UNUSED failures and amlogic glitch free mux Chuan Liu via B4 Relay 2024-11-11 3:37 ` [PATCH v2 1/3] clk: Fix the CLK_IGNORE_UNUSED failure issue Chuan Liu via B4 Relay 2024-11-11 3:37 ` [PATCH v2 2/3] clk: meson: Fix failure of glitch-free mux switching Chuan Liu via B4 Relay @ 2024-11-11 3:37 ` Chuan Liu via B4 Relay 2024-11-12 8:37 ` Jerome Brunet 2 siblings, 1 reply; 7+ messages in thread From: Chuan Liu via B4 Relay @ 2024-11-11 3:37 UTC (permalink / raw) To: Michael Turquette, Stephen Boyd, Neil Armstrong, Jerome Brunet, Kevin Hilman, Martin Blumenstingl Cc: linux-clk, linux-kernel, linux-amlogic, linux-arm-kernel, Chuan Liu From: Chuan Liu <chuan.liu@amlogic.com> glitch-free mux has two clock channels (channel 0 and channel 1) with the same configuration. When the frequency needs to be changed, the two channels ping-pong to ensure clock continuity and suppress glitch. The glitch-free mux configuration with CLK_SET_RATE_GATE enables the mux to perform ping-pong switching to suppress glitches. Fixes: 84af914404db ("clk: meson: a1: add Amlogic A1 Peripherals clock controller driver") Fixes: 14ebb3154b8f ("clk: meson: axg: add Video Clocks") Fixes: f06ac3ed04e8 ("clk: meson: c3: add c3 clock peripherals controller driver") Fixes: 085a4ea93d54 ("clk: meson: g12a: add peripheral clock controller") Fixes: fac9a55b66c9 ("clk: meson-gxbb: Add MALI clocks") Fixes: 57b55c76aaf1 ("clk: meson: S4: add support for Amlogic S4 SoC peripheral clock controller") Signed-off-by: Chuan Liu <chuan.liu@amlogic.com> --- drivers/clk/meson/a1-peripherals.c | 8 ++++---- drivers/clk/meson/axg.c | 12 ++++++++---- drivers/clk/meson/c3-peripherals.c | 4 ++-- drivers/clk/meson/g12a.c | 12 ++++++++---- drivers/clk/meson/gxbb.c | 12 ++++++++---- drivers/clk/meson/s4-peripherals.c | 20 ++++++++++---------- 6 files changed, 40 insertions(+), 28 deletions(-) diff --git a/drivers/clk/meson/a1-peripherals.c b/drivers/clk/meson/a1-peripherals.c index 4b9686916b17..7f515e002adb 100644 --- a/drivers/clk/meson/a1-peripherals.c +++ b/drivers/clk/meson/a1-peripherals.c @@ -423,7 +423,7 @@ static struct clk_regmap dspa_a = { &dspa_a_div.hw }, .num_parents = 1, - .flags = CLK_SET_RATE_PARENT, + .flags = CLK_SET_RATE_PARENT | CLK_SET_RATE_GATE, }, }; @@ -471,7 +471,7 @@ static struct clk_regmap dspa_b = { &dspa_b_div.hw }, .num_parents = 1, - .flags = CLK_SET_RATE_PARENT, + .flags = CLK_SET_RATE_PARENT | CLK_SET_RATE_GATE, }, }; @@ -569,7 +569,7 @@ static struct clk_regmap dspb_a = { &dspb_a_div.hw }, .num_parents = 1, - .flags = CLK_SET_RATE_PARENT, + .flags = CLK_SET_RATE_PARENT | CLK_SET_RATE_GATE, }, }; @@ -617,7 +617,7 @@ static struct clk_regmap dspb_b = { &dspb_b_div.hw }, .num_parents = 1, - .flags = CLK_SET_RATE_PARENT, + .flags = CLK_SET_RATE_PARENT | CLK_SET_RATE_GATE, }, }; diff --git a/drivers/clk/meson/axg.c b/drivers/clk/meson/axg.c index a1217dff40fa..e2d3266f4b45 100644 --- a/drivers/clk/meson/axg.c +++ b/drivers/clk/meson/axg.c @@ -1077,7 +1077,8 @@ static struct clk_regmap axg_vpu_0 = { * We want to avoid CCF to disable the VPU clock if * display has been set by Bootloader */ - .flags = CLK_SET_RATE_PARENT | CLK_IGNORE_UNUSED, + .flags = CLK_SET_RATE_PARENT | CLK_IGNORE_UNUSED | + CLK_SET_RATE_GATE, }, }; @@ -1126,7 +1127,8 @@ static struct clk_regmap axg_vpu_1 = { * We want to avoid CCF to disable the VPU clock if * display has been set by Bootloader */ - .flags = CLK_SET_RATE_PARENT | CLK_IGNORE_UNUSED, + .flags = CLK_SET_RATE_PARENT | CLK_IGNORE_UNUSED | + CLK_SET_RATE_GATE, }, }; @@ -1194,7 +1196,8 @@ static struct clk_regmap axg_vapb_0 = { &axg_vapb_0_div.hw }, .num_parents = 1, - .flags = CLK_SET_RATE_PARENT | CLK_IGNORE_UNUSED, + .flags = CLK_SET_RATE_PARENT | CLK_IGNORE_UNUSED | + CLK_SET_RATE_GATE, }, }; @@ -1242,7 +1245,8 @@ static struct clk_regmap axg_vapb_1 = { &axg_vapb_1_div.hw }, .num_parents = 1, - .flags = CLK_SET_RATE_PARENT | CLK_IGNORE_UNUSED, + .flags = CLK_SET_RATE_PARENT | CLK_IGNORE_UNUSED | + CLK_SET_RATE_GATE, }, }; diff --git a/drivers/clk/meson/c3-peripherals.c b/drivers/clk/meson/c3-peripherals.c index 4566c2aeeb19..27343a73a521 100644 --- a/drivers/clk/meson/c3-peripherals.c +++ b/drivers/clk/meson/c3-peripherals.c @@ -1364,7 +1364,7 @@ static struct clk_regmap hcodec_0 = { &hcodec_0_div.hw }, .num_parents = 1, - .flags = CLK_SET_RATE_PARENT, + .flags = CLK_SET_RATE_PARENT | CLK_SET_RATE_GATE, }, }; @@ -1411,7 +1411,7 @@ static struct clk_regmap hcodec_1 = { &hcodec_1_div.hw }, .num_parents = 1, - .flags = CLK_SET_RATE_PARENT, + .flags = CLK_SET_RATE_PARENT | CLK_SET_RATE_GATE, }, }; diff --git a/drivers/clk/meson/g12a.c b/drivers/clk/meson/g12a.c index 4d3b064d09fc..21a25001e904 100644 --- a/drivers/clk/meson/g12a.c +++ b/drivers/clk/meson/g12a.c @@ -2746,7 +2746,8 @@ static struct clk_regmap g12a_vpu_0 = { .ops = &clk_regmap_gate_ops, .parent_hws = (const struct clk_hw *[]) { &g12a_vpu_0_div.hw }, .num_parents = 1, - .flags = CLK_SET_RATE_PARENT | CLK_IGNORE_UNUSED, + .flags = CLK_SET_RATE_PARENT | CLK_IGNORE_UNUSED | + CLK_SET_RATE_GATE, }, }; @@ -2790,7 +2791,8 @@ static struct clk_regmap g12a_vpu_1 = { .ops = &clk_regmap_gate_ops, .parent_hws = (const struct clk_hw *[]) { &g12a_vpu_1_div.hw }, .num_parents = 1, - .flags = CLK_SET_RATE_PARENT | CLK_IGNORE_UNUSED, + .flags = CLK_SET_RATE_PARENT | CLK_IGNORE_UNUSED | + CLK_SET_RATE_GATE, }, }; @@ -3035,7 +3037,8 @@ static struct clk_regmap g12a_vapb_0 = { &g12a_vapb_0_div.hw }, .num_parents = 1, - .flags = CLK_SET_RATE_PARENT | CLK_IGNORE_UNUSED, + .flags = CLK_SET_RATE_PARENT | CLK_IGNORE_UNUSED | + CLK_SET_RATE_GATE, }, }; @@ -3083,7 +3086,8 @@ static struct clk_regmap g12a_vapb_1 = { &g12a_vapb_1_div.hw }, .num_parents = 1, - .flags = CLK_SET_RATE_PARENT | CLK_IGNORE_UNUSED, + .flags = CLK_SET_RATE_PARENT | CLK_IGNORE_UNUSED | + CLK_SET_RATE_GATE, }, }; diff --git a/drivers/clk/meson/gxbb.c b/drivers/clk/meson/gxbb.c index dfa9ffc61b41..812b3e20c366 100644 --- a/drivers/clk/meson/gxbb.c +++ b/drivers/clk/meson/gxbb.c @@ -1543,7 +1543,8 @@ static struct clk_regmap gxbb_vpu_0 = { .ops = &clk_regmap_gate_ops, .parent_hws = (const struct clk_hw *[]) { &gxbb_vpu_0_div.hw }, .num_parents = 1, - .flags = CLK_SET_RATE_PARENT | CLK_IGNORE_UNUSED, + .flags = CLK_SET_RATE_PARENT | CLK_IGNORE_UNUSED | + CLK_SET_RATE_GATE, }, }; @@ -1591,7 +1592,8 @@ static struct clk_regmap gxbb_vpu_1 = { .ops = &clk_regmap_gate_ops, .parent_hws = (const struct clk_hw *[]) { &gxbb_vpu_1_div.hw }, .num_parents = 1, - .flags = CLK_SET_RATE_PARENT | CLK_IGNORE_UNUSED, + .flags = CLK_SET_RATE_PARENT | CLK_IGNORE_UNUSED | + CLK_SET_RATE_GATE, }, }; @@ -1674,7 +1676,8 @@ static struct clk_regmap gxbb_vapb_0 = { &gxbb_vapb_0_div.hw }, .num_parents = 1, - .flags = CLK_SET_RATE_PARENT | CLK_IGNORE_UNUSED, + .flags = CLK_SET_RATE_PARENT | CLK_IGNORE_UNUSED | + CLK_SET_RATE_GATE, }, }; @@ -1726,7 +1729,8 @@ static struct clk_regmap gxbb_vapb_1 = { &gxbb_vapb_1_div.hw }, .num_parents = 1, - .flags = CLK_SET_RATE_PARENT | CLK_IGNORE_UNUSED, + .flags = CLK_SET_RATE_PARENT | CLK_IGNORE_UNUSED | + CLK_SET_RATE_GATE, }, }; diff --git a/drivers/clk/meson/s4-peripherals.c b/drivers/clk/meson/s4-peripherals.c index 79e0240d58e6..cf10be40141d 100644 --- a/drivers/clk/meson/s4-peripherals.c +++ b/drivers/clk/meson/s4-peripherals.c @@ -1466,7 +1466,7 @@ static struct clk_regmap s4_vdec_p0 = { &s4_vdec_p0_div.hw }, .num_parents = 1, - .flags = CLK_SET_RATE_PARENT, + .flags = CLK_SET_RATE_PARENT | CLK_SET_RATE_GATE, }, }; @@ -1516,7 +1516,7 @@ static struct clk_regmap s4_vdec_p1 = { &s4_vdec_p1_div.hw }, .num_parents = 1, - .flags = CLK_SET_RATE_PARENT, + .flags = CLK_SET_RATE_PARENT | CLK_SET_RATE_GATE, }, }; @@ -1586,7 +1586,7 @@ static struct clk_regmap s4_hevcf_p0 = { &s4_hevcf_p0_div.hw }, .num_parents = 1, - .flags = CLK_SET_RATE_PARENT, + .flags = CLK_SET_RATE_PARENT | CLK_SET_RATE_GATE, }, }; @@ -1636,7 +1636,7 @@ static struct clk_regmap s4_hevcf_p1 = { &s4_hevcf_p1_div.hw }, .num_parents = 1, - .flags = CLK_SET_RATE_PARENT, + .flags = CLK_SET_RATE_PARENT | CLK_SET_RATE_GATE, }, }; @@ -1712,7 +1712,7 @@ static struct clk_regmap s4_vpu_0 = { .ops = &clk_regmap_gate_ops, .parent_hws = (const struct clk_hw *[]) { &s4_vpu_0_div.hw }, .num_parents = 1, - .flags = CLK_SET_RATE_PARENT, + .flags = CLK_SET_RATE_PARENT | CLK_SET_RATE_GATE, }, }; @@ -1756,7 +1756,7 @@ static struct clk_regmap s4_vpu_1 = { .ops = &clk_regmap_gate_ops, .parent_hws = (const struct clk_hw *[]) { &s4_vpu_1_div.hw }, .num_parents = 1, - .flags = CLK_SET_RATE_PARENT, + .flags = CLK_SET_RATE_PARENT | CLK_SET_RATE_GATE, }, }; @@ -1921,7 +1921,7 @@ static struct clk_regmap s4_vpu_clkc_p0 = { &s4_vpu_clkc_p0_div.hw }, .num_parents = 1, - .flags = CLK_SET_RATE_PARENT, + .flags = CLK_SET_RATE_PARENT | CLK_SET_RATE_GATE, }, }; @@ -1969,7 +1969,7 @@ static struct clk_regmap s4_vpu_clkc_p1 = { &s4_vpu_clkc_p1_div.hw }, .num_parents = 1, - .flags = CLK_SET_RATE_PARENT, + .flags = CLK_SET_RATE_PARENT | CLK_SET_RATE_GATE, }, }; @@ -2049,7 +2049,7 @@ static struct clk_regmap s4_vapb_0 = { &s4_vapb_0_div.hw }, .num_parents = 1, - .flags = CLK_SET_RATE_PARENT, + .flags = CLK_SET_RATE_PARENT | CLK_SET_RATE_GATE, }, }; @@ -2097,7 +2097,7 @@ static struct clk_regmap s4_vapb_1 = { &s4_vapb_1_div.hw }, .num_parents = 1, - .flags = CLK_SET_RATE_PARENT, + .flags = CLK_SET_RATE_PARENT | CLK_SET_RATE_GATE, }, }; -- 2.42.0 _______________________________________________ linux-amlogic mailing list linux-amlogic@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-amlogic ^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH v2 3/3] clk: meson: Fix glitch occurs when setting up glitch-free mux 2024-11-11 3:37 ` [PATCH v2 3/3] clk: meson: Fix glitch occurs when setting up glitch-free mux Chuan Liu via B4 Relay @ 2024-11-12 8:37 ` Jerome Brunet 0 siblings, 0 replies; 7+ messages in thread From: Jerome Brunet @ 2024-11-12 8:37 UTC (permalink / raw) To: Chuan Liu via B4 Relay Cc: Michael Turquette, Stephen Boyd, Neil Armstrong, Kevin Hilman, Martin Blumenstingl, chuan.liu, linux-clk, linux-kernel, linux-amlogic, linux-arm-kernel On Mon 11 Nov 2024 at 11:37, Chuan Liu via B4 Relay <devnull+chuan.liu.amlogic.com@kernel.org> wrote: > From: Chuan Liu <chuan.liu@amlogic.com> > > glitch-free mux has two clock channels (channel 0 and channel 1) with > the same configuration. When the frequency needs to be changed, the two > channels ping-pong to ensure clock continuity and suppress glitch. > > The glitch-free mux configuration with CLK_SET_RATE_GATE enables the mux > to perform ping-pong switching to suppress glitches. > > Fixes: 84af914404db ("clk: meson: a1: add Amlogic A1 Peripherals clock > controller driver") > Fixes: 14ebb3154b8f ("clk: meson: axg: add Video Clocks") > Fixes: f06ac3ed04e8 ("clk: meson: c3: add c3 clock peripherals controller > driver") > Fixes: 085a4ea93d54 ("clk: meson: g12a: add peripheral clock controller") > Fixes: fac9a55b66c9 ("clk: meson-gxbb: Add MALI clocks") > Fixes: 57b55c76aaf1 ("clk: meson: S4: add support for Amlogic S4 SoC > peripheral clock controller") Same remarks. > Signed-off-by: Chuan Liu <chuan.liu@amlogic.com> > --- > drivers/clk/meson/a1-peripherals.c | 8 ++++---- > drivers/clk/meson/axg.c | 12 ++++++++---- > drivers/clk/meson/c3-peripherals.c | 4 ++-- > drivers/clk/meson/g12a.c | 12 ++++++++---- > drivers/clk/meson/gxbb.c | 12 ++++++++---- > drivers/clk/meson/s4-peripherals.c | 20 ++++++++++---------- > 6 files changed, 40 insertions(+), 28 deletions(-) > > diff --git a/drivers/clk/meson/a1-peripherals.c b/drivers/clk/meson/a1-peripherals.c > index 4b9686916b17..7f515e002adb 100644 > --- a/drivers/clk/meson/a1-peripherals.c > +++ b/drivers/clk/meson/a1-peripherals.c > @@ -423,7 +423,7 @@ static struct clk_regmap dspa_a = { > &dspa_a_div.hw > }, > .num_parents = 1, > - .flags = CLK_SET_RATE_PARENT, > + .flags = CLK_SET_RATE_PARENT | CLK_SET_RATE_GATE, > }, > }; > > @@ -471,7 +471,7 @@ static struct clk_regmap dspa_b = { > &dspa_b_div.hw > }, > .num_parents = 1, > - .flags = CLK_SET_RATE_PARENT, > + .flags = CLK_SET_RATE_PARENT | CLK_SET_RATE_GATE, > }, > }; > > @@ -569,7 +569,7 @@ static struct clk_regmap dspb_a = { > &dspb_a_div.hw > }, > .num_parents = 1, > - .flags = CLK_SET_RATE_PARENT, > + .flags = CLK_SET_RATE_PARENT | CLK_SET_RATE_GATE, > }, > }; > > @@ -617,7 +617,7 @@ static struct clk_regmap dspb_b = { > &dspb_b_div.hw > }, > .num_parents = 1, > - .flags = CLK_SET_RATE_PARENT, > + .flags = CLK_SET_RATE_PARENT | CLK_SET_RATE_GATE, > }, > }; > > diff --git a/drivers/clk/meson/axg.c b/drivers/clk/meson/axg.c > index a1217dff40fa..e2d3266f4b45 100644 > --- a/drivers/clk/meson/axg.c > +++ b/drivers/clk/meson/axg.c > @@ -1077,7 +1077,8 @@ static struct clk_regmap axg_vpu_0 = { > * We want to avoid CCF to disable the VPU clock if > * display has been set by Bootloader > */ > - .flags = CLK_SET_RATE_PARENT | CLK_IGNORE_UNUSED, > + .flags = CLK_SET_RATE_PARENT | CLK_IGNORE_UNUSED | > + CLK_SET_RATE_GATE, > }, > }; > > @@ -1126,7 +1127,8 @@ static struct clk_regmap axg_vpu_1 = { > * We want to avoid CCF to disable the VPU clock if > * display has been set by Bootloader > */ > - .flags = CLK_SET_RATE_PARENT | CLK_IGNORE_UNUSED, > + .flags = CLK_SET_RATE_PARENT | CLK_IGNORE_UNUSED | > + CLK_SET_RATE_GATE, > }, > }; > > @@ -1194,7 +1196,8 @@ static struct clk_regmap axg_vapb_0 = { > &axg_vapb_0_div.hw > }, > .num_parents = 1, > - .flags = CLK_SET_RATE_PARENT | CLK_IGNORE_UNUSED, > + .flags = CLK_SET_RATE_PARENT | CLK_IGNORE_UNUSED | > + CLK_SET_RATE_GATE, > }, > }; > > @@ -1242,7 +1245,8 @@ static struct clk_regmap axg_vapb_1 = { > &axg_vapb_1_div.hw > }, > .num_parents = 1, > - .flags = CLK_SET_RATE_PARENT | CLK_IGNORE_UNUSED, > + .flags = CLK_SET_RATE_PARENT | CLK_IGNORE_UNUSED | > + CLK_SET_RATE_GATE, > }, > }; > > diff --git a/drivers/clk/meson/c3-peripherals.c b/drivers/clk/meson/c3-peripherals.c > index 4566c2aeeb19..27343a73a521 100644 > --- a/drivers/clk/meson/c3-peripherals.c > +++ b/drivers/clk/meson/c3-peripherals.c > @@ -1364,7 +1364,7 @@ static struct clk_regmap hcodec_0 = { > &hcodec_0_div.hw > }, > .num_parents = 1, > - .flags = CLK_SET_RATE_PARENT, > + .flags = CLK_SET_RATE_PARENT | CLK_SET_RATE_GATE, > }, > }; > > @@ -1411,7 +1411,7 @@ static struct clk_regmap hcodec_1 = { > &hcodec_1_div.hw > }, > .num_parents = 1, > - .flags = CLK_SET_RATE_PARENT, > + .flags = CLK_SET_RATE_PARENT | CLK_SET_RATE_GATE, > }, > }; > > diff --git a/drivers/clk/meson/g12a.c b/drivers/clk/meson/g12a.c > index 4d3b064d09fc..21a25001e904 100644 > --- a/drivers/clk/meson/g12a.c > +++ b/drivers/clk/meson/g12a.c > @@ -2746,7 +2746,8 @@ static struct clk_regmap g12a_vpu_0 = { > .ops = &clk_regmap_gate_ops, > .parent_hws = (const struct clk_hw *[]) { &g12a_vpu_0_div.hw }, > .num_parents = 1, > - .flags = CLK_SET_RATE_PARENT | CLK_IGNORE_UNUSED, > + .flags = CLK_SET_RATE_PARENT | CLK_IGNORE_UNUSED | > + CLK_SET_RATE_GATE, > }, > }; > > @@ -2790,7 +2791,8 @@ static struct clk_regmap g12a_vpu_1 = { > .ops = &clk_regmap_gate_ops, > .parent_hws = (const struct clk_hw *[]) { &g12a_vpu_1_div.hw }, > .num_parents = 1, > - .flags = CLK_SET_RATE_PARENT | CLK_IGNORE_UNUSED, > + .flags = CLK_SET_RATE_PARENT | CLK_IGNORE_UNUSED | > + CLK_SET_RATE_GATE, > }, > }; > > @@ -3035,7 +3037,8 @@ static struct clk_regmap g12a_vapb_0 = { > &g12a_vapb_0_div.hw > }, > .num_parents = 1, > - .flags = CLK_SET_RATE_PARENT | CLK_IGNORE_UNUSED, > + .flags = CLK_SET_RATE_PARENT | CLK_IGNORE_UNUSED | > + CLK_SET_RATE_GATE, > }, > }; > > @@ -3083,7 +3086,8 @@ static struct clk_regmap g12a_vapb_1 = { > &g12a_vapb_1_div.hw > }, > .num_parents = 1, > - .flags = CLK_SET_RATE_PARENT | CLK_IGNORE_UNUSED, > + .flags = CLK_SET_RATE_PARENT | CLK_IGNORE_UNUSED | > + CLK_SET_RATE_GATE, > }, > }; > > diff --git a/drivers/clk/meson/gxbb.c b/drivers/clk/meson/gxbb.c > index dfa9ffc61b41..812b3e20c366 100644 > --- a/drivers/clk/meson/gxbb.c > +++ b/drivers/clk/meson/gxbb.c > @@ -1543,7 +1543,8 @@ static struct clk_regmap gxbb_vpu_0 = { > .ops = &clk_regmap_gate_ops, > .parent_hws = (const struct clk_hw *[]) { &gxbb_vpu_0_div.hw }, > .num_parents = 1, > - .flags = CLK_SET_RATE_PARENT | CLK_IGNORE_UNUSED, > + .flags = CLK_SET_RATE_PARENT | CLK_IGNORE_UNUSED | > + CLK_SET_RATE_GATE, > }, > }; > > @@ -1591,7 +1592,8 @@ static struct clk_regmap gxbb_vpu_1 = { > .ops = &clk_regmap_gate_ops, > .parent_hws = (const struct clk_hw *[]) { &gxbb_vpu_1_div.hw }, > .num_parents = 1, > - .flags = CLK_SET_RATE_PARENT | CLK_IGNORE_UNUSED, > + .flags = CLK_SET_RATE_PARENT | CLK_IGNORE_UNUSED | > + CLK_SET_RATE_GATE, > }, > }; > > @@ -1674,7 +1676,8 @@ static struct clk_regmap gxbb_vapb_0 = { > &gxbb_vapb_0_div.hw > }, > .num_parents = 1, > - .flags = CLK_SET_RATE_PARENT | CLK_IGNORE_UNUSED, > + .flags = CLK_SET_RATE_PARENT | CLK_IGNORE_UNUSED | > + CLK_SET_RATE_GATE, > }, > }; > > @@ -1726,7 +1729,8 @@ static struct clk_regmap gxbb_vapb_1 = { > &gxbb_vapb_1_div.hw > }, > .num_parents = 1, > - .flags = CLK_SET_RATE_PARENT | CLK_IGNORE_UNUSED, > + .flags = CLK_SET_RATE_PARENT | CLK_IGNORE_UNUSED | > + CLK_SET_RATE_GATE, > }, > }; > > diff --git a/drivers/clk/meson/s4-peripherals.c b/drivers/clk/meson/s4-peripherals.c > index 79e0240d58e6..cf10be40141d 100644 > --- a/drivers/clk/meson/s4-peripherals.c > +++ b/drivers/clk/meson/s4-peripherals.c > @@ -1466,7 +1466,7 @@ static struct clk_regmap s4_vdec_p0 = { > &s4_vdec_p0_div.hw > }, > .num_parents = 1, > - .flags = CLK_SET_RATE_PARENT, > + .flags = CLK_SET_RATE_PARENT | CLK_SET_RATE_GATE, > }, > }; > > @@ -1516,7 +1516,7 @@ static struct clk_regmap s4_vdec_p1 = { > &s4_vdec_p1_div.hw > }, > .num_parents = 1, > - .flags = CLK_SET_RATE_PARENT, > + .flags = CLK_SET_RATE_PARENT | CLK_SET_RATE_GATE, > }, > }; > > @@ -1586,7 +1586,7 @@ static struct clk_regmap s4_hevcf_p0 = { > &s4_hevcf_p0_div.hw > }, > .num_parents = 1, > - .flags = CLK_SET_RATE_PARENT, > + .flags = CLK_SET_RATE_PARENT | CLK_SET_RATE_GATE, > }, > }; > > @@ -1636,7 +1636,7 @@ static struct clk_regmap s4_hevcf_p1 = { > &s4_hevcf_p1_div.hw > }, > .num_parents = 1, > - .flags = CLK_SET_RATE_PARENT, > + .flags = CLK_SET_RATE_PARENT | CLK_SET_RATE_GATE, > }, > }; > > @@ -1712,7 +1712,7 @@ static struct clk_regmap s4_vpu_0 = { > .ops = &clk_regmap_gate_ops, > .parent_hws = (const struct clk_hw *[]) { &s4_vpu_0_div.hw }, > .num_parents = 1, > - .flags = CLK_SET_RATE_PARENT, > + .flags = CLK_SET_RATE_PARENT | CLK_SET_RATE_GATE, > }, > }; > > @@ -1756,7 +1756,7 @@ static struct clk_regmap s4_vpu_1 = { > .ops = &clk_regmap_gate_ops, > .parent_hws = (const struct clk_hw *[]) { &s4_vpu_1_div.hw }, > .num_parents = 1, > - .flags = CLK_SET_RATE_PARENT, > + .flags = CLK_SET_RATE_PARENT | CLK_SET_RATE_GATE, > }, > }; > > @@ -1921,7 +1921,7 @@ static struct clk_regmap s4_vpu_clkc_p0 = { > &s4_vpu_clkc_p0_div.hw > }, > .num_parents = 1, > - .flags = CLK_SET_RATE_PARENT, > + .flags = CLK_SET_RATE_PARENT | CLK_SET_RATE_GATE, > }, > }; > > @@ -1969,7 +1969,7 @@ static struct clk_regmap s4_vpu_clkc_p1 = { > &s4_vpu_clkc_p1_div.hw > }, > .num_parents = 1, > - .flags = CLK_SET_RATE_PARENT, > + .flags = CLK_SET_RATE_PARENT | CLK_SET_RATE_GATE, > }, > }; > > @@ -2049,7 +2049,7 @@ static struct clk_regmap s4_vapb_0 = { > &s4_vapb_0_div.hw > }, > .num_parents = 1, > - .flags = CLK_SET_RATE_PARENT, > + .flags = CLK_SET_RATE_PARENT | CLK_SET_RATE_GATE, > }, > }; > > @@ -2097,7 +2097,7 @@ static struct clk_regmap s4_vapb_1 = { > &s4_vapb_1_div.hw > }, > .num_parents = 1, > - .flags = CLK_SET_RATE_PARENT, > + .flags = CLK_SET_RATE_PARENT | CLK_SET_RATE_GATE, > }, > }; -- Jerome _______________________________________________ linux-amlogic mailing list linux-amlogic@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-amlogic ^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2024-11-12 8:48 UTC | newest] Thread overview: 7+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2024-11-11 3:37 [PATCH v2 0/3] clk: Fix issues related to CLK_IGNORE_UNUSED failures and amlogic glitch free mux Chuan Liu via B4 Relay 2024-11-11 3:37 ` [PATCH v2 1/3] clk: Fix the CLK_IGNORE_UNUSED failure issue Chuan Liu via B4 Relay 2024-11-12 8:41 ` Jerome Brunet 2024-11-11 3:37 ` [PATCH v2 2/3] clk: meson: Fix failure of glitch-free mux switching Chuan Liu via B4 Relay 2024-11-12 8:32 ` Jerome Brunet 2024-11-11 3:37 ` [PATCH v2 3/3] clk: meson: Fix glitch occurs when setting up glitch-free mux Chuan Liu via B4 Relay 2024-11-12 8:37 ` Jerome Brunet
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox