* [PATCH v2 1/3] clk: meson: gxbb: add the missing HDMI divider /4 alias
2026-10-29 12:54 [PATCH v2 0/3] Fix rate rounding for Meson read-only dividers Carlo Caione
@ 2026-10-29 12:54 ` Carlo Caione
2026-10-29 12:54 ` [PATCH v2 2/3] clk: meson: g12a: " Carlo Caione
2026-10-29 12:54 ` [PATCH v2 3/3] clk: meson: regmap: use the current divisor for read-only clocks Carlo Caione
2 siblings, 0 replies; 4+ messages in thread
From: Carlo Caione @ 2026-10-29 12:54 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, HDMI PLL divider values 2 and 3 both select /4, but only value 2
is listed in the table. Reading value 3 therefore gives an unknown
divisor and an incorrect clock rate.
Add value 3 to the table. This also avoids a division by zero when the
read-only rate-rounding helper uses the value read from hardware.
Fixes: 5b1a43950fd3 ("clk: meson: gxbb: Limit the HDMI PLL OD to /4 on GXL/GXM SoCs")
Reviewed-by: Jerome Brunet <jbrunet@baylibre.com>
Signed-off-by: Carlo Caione <ccaione@baylibre.com>
---
drivers/clk/meson/gxbb.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
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] 4+ messages in thread* [PATCH v2 2/3] clk: meson: g12a: add the missing HDMI divider /4 alias
2026-10-29 12:54 [PATCH v2 0/3] Fix rate rounding for Meson read-only dividers Carlo Caione
2026-10-29 12:54 ` [PATCH v2 1/3] clk: meson: gxbb: add the missing HDMI divider /4 alias Carlo Caione
@ 2026-10-29 12:54 ` Carlo Caione
2026-10-29 12:54 ` [PATCH v2 3/3] clk: meson: regmap: use the current divisor for read-only clocks Carlo Caione
2 siblings, 0 replies; 4+ messages in thread
From: Carlo Caione @ 2026-10-29 12:54 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 G12A, HDMI PLL divider values 2 and 3 both select /4, but only value 2
is listed in the table. Reading value 3 therefore gives an unknown
divisor and an incorrect clock rate.
Add value 3 to the table. This also avoids a division by zero when the
read-only rate-rounding helper uses the value read from hardware.
Fixes: 7aa6c24697ef ("clk: meson: g12a: Limit the HDMI PLL OD to /4")
Reviewed-by: Jerome Brunet <jbrunet@baylibre.com>
Signed-off-by: Carlo Caione <ccaione@baylibre.com>
---
drivers/clk/meson/g12a.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
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 */ }
};
--
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] 4+ messages in thread* [PATCH v2 3/3] clk: meson: regmap: use the current divisor for read-only clocks
2026-10-29 12:54 [PATCH v2 0/3] Fix rate rounding for Meson read-only dividers Carlo Caione
2026-10-29 12:54 ` [PATCH v2 1/3] clk: meson: gxbb: add the missing HDMI divider /4 alias Carlo Caione
2026-10-29 12:54 ` [PATCH v2 2/3] clk: meson: g12a: " Carlo Caione
@ 2026-10-29 12:54 ` Carlo Caione
2 siblings, 0 replies; 4+ messages in thread
From: Carlo Caione @ 2026-10-29 12:54 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.
Fixes: ea11dda9e091 ("clk: meson: add regmap clocks")
Reviewed-by: Jerome Brunet <jbrunet@baylibre.com>
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] 4+ messages in thread