* [PATCH 0/2] Fix rate rounding for Meson read-only dividers
@ 2026-10-26 13:29 Carlo Caione
2026-10-26 13:29 ` [PATCH 1/2] clk: meson: add the missing HDMI divider /4 alias Carlo Caione
2026-10-26 13:29 ` [PATCH 2/2] clk: meson: regmap: use the current divisor for read-only clocks Carlo Caione
0 siblings, 2 replies; 5+ messages in thread
From: Carlo Caione @ 2026-10-26 13:29 UTC (permalink / raw)
To: Neil Armstrong, Jerome Brunet, Stephen Boyd, Brian Masney,
Kevin Hilman, Martin Blumenstingl
Cc: linux-amlogic, linux-clk, linux-arm-kernel, linux-kernel, Carlo Caione
Meson read-only dividers can round a requested rate using a divisor they
cannot program. The clock core may then adjust child clocks using the
wrong parent rate.
This series uses the divisor already set in hardware. The first patch
adds a missing /4 entry to the GXL and G12A HDMI divider tables so that
all their register values can be read correctly.
Signed-off-by: Carlo Caione <ccaione@baylibre.com>
---
Carlo Caione (2):
clk: meson: add the missing HDMI divider /4 alias
clk: meson: regmap: use the current divisor for read-only clocks
drivers/clk/meson/clk-regmap.c | 34 +++++++++++++++++++++-------------
drivers/clk/meson/g12a.c | 3 ++-
drivers/clk/meson/gxbb.c | 3 ++-
3 files changed, 25 insertions(+), 15 deletions(-)
---
base-commit: 363f97a1ce635b86be7fd263d56a040fbd87bdbb
change-id: 20261026-upstream-clk-regmap-ro-divider-f9ee3532fbe1
Best regards,
--
Carlo Caione <ccaione@baylibre.com>
_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic
^ permalink raw reply [flat|nested] 5+ messages in thread* [PATCH 1/2] clk: meson: add the missing HDMI divider /4 alias 2026-10-26 13:29 [PATCH 0/2] Fix rate rounding for Meson read-only dividers Carlo Caione @ 2026-10-26 13:29 ` Carlo Caione 2026-10-29 11:07 ` Jerome Brunet 2026-10-26 13:29 ` [PATCH 2/2] clk: meson: regmap: use the current divisor for read-only clocks Carlo Caione 1 sibling, 1 reply; 5+ messages in thread From: Carlo Caione @ 2026-10-26 13:29 UTC (permalink / raw) To: Neil Armstrong, Jerome Brunet, Stephen Boyd, Brian Masney, Kevin Hilman, Martin Blumenstingl Cc: linux-amlogic, linux-clk, linux-arm-kernel, linux-kernel, Carlo Caione On GXL and G12A, HDMI PLL divider values 2 and 3 both select /4, but only value 2 is listed in the tables. Reading value 3 therefore gives an unknown divisor and an incorrect clock rate. Add value 3 to both tables. This also avoids a division by zero when the read-only rate-rounding helper uses the value read from hardware. Signed-off-by: Carlo Caione <ccaione@baylibre.com> --- drivers/clk/meson/g12a.c | 3 ++- drivers/clk/meson/gxbb.c | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/clk/meson/g12a.c b/drivers/clk/meson/g12a.c index d0d4c7b6dc82..b23b9514fa91 100644 --- a/drivers/clk/meson/g12a.c +++ b/drivers/clk/meson/g12a.c @@ -779,12 +779,13 @@ static struct clk_regmap g12a_hdmi_pll_dco = { /* * G12/SM1 hdmi OD dividers are POWER_OF_TWO dividers but limited to /4. - * A divider value of 3 should map to /8 but instead map /4 so ignore it. + * Divider values 2 and 3 both select /4. */ static const struct clk_div_table g12a_hdmi_pll_od_div_table[] = { { .val = 0, .div = 1 }, { .val = 1, .div = 2 }, { .val = 2, .div = 4 }, + { .val = 3, .div = 4 }, { /* sentinel */ } }; diff --git a/drivers/clk/meson/gxbb.c b/drivers/clk/meson/gxbb.c index 7a7b104182ff..8cb6404c0efd 100644 --- a/drivers/clk/meson/gxbb.c +++ b/drivers/clk/meson/gxbb.c @@ -350,12 +350,13 @@ static struct clk_regmap gxbb_hdmi_pll = { /* * GXL hdmi OD dividers are POWER_OF_TWO dividers but limited to /4. - * A divider value of 3 should map to /8 but instead map /4 so ignore it. + * Divider values 2 and 3 both select /4. */ static const struct clk_div_table gxl_hdmi_pll_od_div_table[] = { { .val = 0, .div = 1 }, { .val = 1, .div = 2 }, { .val = 2, .div = 4 }, + { .val = 3, .div = 4 }, { /* sentinel */ } }; -- 2.56.0 _______________________________________________ linux-amlogic mailing list linux-amlogic@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-amlogic ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 1/2] clk: meson: add the missing HDMI divider /4 alias 2026-10-26 13:29 ` [PATCH 1/2] clk: meson: add the missing HDMI divider /4 alias Carlo Caione @ 2026-10-29 11:07 ` Jerome Brunet 0 siblings, 0 replies; 5+ messages in thread From: Jerome Brunet @ 2026-10-29 11:07 UTC (permalink / raw) To: Carlo Caione Cc: Neil Armstrong, Jerome Brunet, Stephen Boyd, Brian Masney, Kevin Hilman, Martin Blumenstingl, linux-amlogic, linux-clk, linux-arm-kernel, linux-kernel > On GXL and G12A, HDMI PLL divider values 2 and 3 both select /4, but > only value 2 is listed in the tables. Reading value 3 therefore gives > an unknown divisor and an incorrect clock rate. > > Add value 3 to both tables. This also avoids a division by zero when > the read-only rate-rounding helper uses the value read from hardware. > > Signed-off-by: Carlo Caione <ccaione@baylibre.com> > --- > drivers/clk/meson/g12a.c | 3 ++- > drivers/clk/meson/gxbb.c | 3 ++- > 2 files changed, 4 insertions(+), 2 deletions(-) > > diff --git a/drivers/clk/meson/g12a.c b/drivers/clk/meson/g12a.c > index d0d4c7b6dc82..b23b9514fa91 100644 > --- a/drivers/clk/meson/g12a.c > +++ b/drivers/clk/meson/g12a.c > @@ -779,12 +779,13 @@ static struct clk_regmap g12a_hdmi_pll_dco = { > > /* > * G12/SM1 hdmi OD dividers are POWER_OF_TWO dividers but limited to /4. > - * A divider value of 3 should map to /8 but instead map /4 so ignore it. > + * Divider values 2 and 3 both select /4. > */ > static const struct clk_div_table g12a_hdmi_pll_od_div_table[] = { > { .val = 0, .div = 1 }, > { .val = 1, .div = 2 }, > { .val = 2, .div = 4 }, > + { .val = 3, .div = 4 }, > { /* sentinel */ } > }; > > diff --git a/drivers/clk/meson/gxbb.c b/drivers/clk/meson/gxbb.c > index 7a7b104182ff..8cb6404c0efd 100644 > --- a/drivers/clk/meson/gxbb.c > +++ b/drivers/clk/meson/gxbb.c > @@ -350,12 +350,13 @@ static struct clk_regmap gxbb_hdmi_pll = { > > /* > * GXL hdmi OD dividers are POWER_OF_TWO dividers but limited to /4. > - * A divider value of 3 should map to /8 but instead map /4 so ignore it. > + * Divider values 2 and 3 both select /4. > */ > static const struct clk_div_table gxl_hdmi_pll_od_div_table[] = { > { .val = 0, .div = 1 }, > { .val = 1, .div = 2 }, > { .val = 2, .div = 4 }, > + { .val = 3, .div = 4 }, > { /* sentinel */ } > }; > Could you split the 2 changes so you can add an approriate fixes tag on them ? A part from this Reviewed-by: Jerome Brunet <jbrunet@baylibre.com> -- Jerome _______________________________________________ linux-amlogic mailing list linux-amlogic@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-amlogic ^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 2/2] clk: meson: regmap: use the current divisor for read-only clocks 2026-10-26 13:29 [PATCH 0/2] Fix rate rounding for Meson read-only dividers Carlo Caione 2026-10-26 13:29 ` [PATCH 1/2] clk: meson: add the missing HDMI divider /4 alias Carlo Caione @ 2026-10-26 13:29 ` Carlo Caione 2026-10-29 11:07 ` Jerome Brunet 1 sibling, 1 reply; 5+ messages in thread From: Carlo Caione @ 2026-10-26 13:29 UTC (permalink / raw) To: Neil Armstrong, Jerome Brunet, Stephen Boyd, Brian Masney, Kevin Hilman, Martin Blumenstingl Cc: linux-amlogic, linux-clk, linux-arm-kernel, linux-kernel, Carlo Caione None of the Meson clocks using clk_regmap_divider_ro_ops set CLK_DIVIDER_READ_ONLY. Without that flag, the shared rounding callback can choose a new divisor even though these ops cannot program it. The clock core may then adjust child clocks using the wrong parent rate. Make the read-only ops always round using the current hardware divisor. Parent rate changes remain allowed with CLK_SET_RATE_PARENT. Signed-off-by: Carlo Caione <ccaione@baylibre.com> --- drivers/clk/meson/clk-regmap.c | 34 +++++++++++++++++++++------------- 1 file changed, 21 insertions(+), 13 deletions(-) diff --git a/drivers/clk/meson/clk-regmap.c b/drivers/clk/meson/clk-regmap.c index 1ed56fe63cae..002e16865109 100644 --- a/drivers/clk/meson/clk-regmap.c +++ b/drivers/clk/meson/clk-regmap.c @@ -120,26 +120,34 @@ static unsigned long clk_regmap_div_recalc_rate(struct clk_hw *hw, div->width); } -static int clk_regmap_div_determine_rate(struct clk_hw *hw, - struct clk_rate_request *req) +static int clk_regmap_div_ro_determine_rate(struct clk_hw *hw, + struct clk_rate_request *req) { struct clk_regmap *clk = to_clk_regmap(hw); struct clk_regmap_div_data *div = clk_get_regmap_div_data(clk); unsigned int val; int ret; - /* if read only, just return current value */ - if (div->flags & CLK_DIVIDER_READ_ONLY) { - ret = regmap_read(clk->map, div->offset, &val); - if (ret) - return ret; + ret = regmap_read(clk->map, div->offset, &val); + if (ret) + return ret; - val >>= div->shift; - val &= clk_div_mask(div->width); + val >>= div->shift; + val &= clk_div_mask(div->width); - return divider_ro_determine_rate(hw, req, div->table, - div->width, div->flags, val); - } + return divider_ro_determine_rate(hw, req, div->table, div->width, + div->flags, val); +} + +static int clk_regmap_div_determine_rate(struct clk_hw *hw, + struct clk_rate_request *req) +{ + struct clk_regmap *clk = to_clk_regmap(hw); + struct clk_regmap_div_data *div = clk_get_regmap_div_data(clk); + + /* if read only, just return current value */ + if (div->flags & CLK_DIVIDER_READ_ONLY) + return clk_regmap_div_ro_determine_rate(hw, req); return divider_determine_rate(hw, req, div->table, div->width, div->flags); @@ -176,7 +184,7 @@ EXPORT_SYMBOL_NS_GPL(clk_regmap_divider_ops, "CLK_MESON"); const struct clk_ops clk_regmap_divider_ro_ops = { .init = clk_regmap_init, .recalc_rate = clk_regmap_div_recalc_rate, - .determine_rate = clk_regmap_div_determine_rate, + .determine_rate = clk_regmap_div_ro_determine_rate, }; EXPORT_SYMBOL_NS_GPL(clk_regmap_divider_ro_ops, "CLK_MESON"); -- 2.56.0 _______________________________________________ linux-amlogic mailing list linux-amlogic@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-amlogic ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 2/2] clk: meson: regmap: use the current divisor for read-only clocks 2026-10-26 13:29 ` [PATCH 2/2] clk: meson: regmap: use the current divisor for read-only clocks Carlo Caione @ 2026-10-29 11:07 ` Jerome Brunet 0 siblings, 0 replies; 5+ messages in thread From: Jerome Brunet @ 2026-10-29 11:07 UTC (permalink / raw) To: Carlo Caione Cc: Neil Armstrong, Jerome Brunet, Stephen Boyd, Brian Masney, Kevin Hilman, Martin Blumenstingl, linux-amlogic, linux-clk, linux-arm-kernel, linux-kernel > None of the Meson clocks using clk_regmap_divider_ro_ops set > CLK_DIVIDER_READ_ONLY. Without that flag, the shared rounding callback > can choose a new divisor even though these ops cannot program it. The > clock core may then adjust child clocks using the wrong parent rate. > > Make the read-only ops always round using the current hardware divisor. > Parent rate changes remain allowed with CLK_SET_RATE_PARENT. > > Signed-off-by: Carlo Caione <ccaione@baylibre.com> Fixes tag maybe ? With this Reviewed-by: Jerome Brunet <jbrunet@baylibre.com> -- Jerome _______________________________________________ linux-amlogic mailing list linux-amlogic@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-amlogic ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2026-10-29 11:08 UTC | newest] Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2026-10-26 13:29 [PATCH 0/2] Fix rate rounding for Meson read-only dividers Carlo Caione 2026-10-26 13:29 ` [PATCH 1/2] clk: meson: add the missing HDMI divider /4 alias Carlo Caione 2026-10-29 11:07 ` Jerome Brunet 2026-10-26 13:29 ` [PATCH 2/2] clk: meson: regmap: use the current divisor for read-only clocks Carlo Caione 2026-10-29 11:07 ` Jerome Brunet
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®