Linux-ARM-Kernel Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3 0/4] clk: ti: fapll/dm816x: clock tree and calculation fixes
@ 2026-11-13 21:30 Ettore Chimenti
  2026-11-13 21:30 ` [PATCH v3 1/4] clk: ti: fapll: remove ti_dt_clk_name helper Ettore Chimenti
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: Ettore Chimenti @ 2026-11-13 21:30 UTC (permalink / raw)
  To: Tero Kristo, Stephen Boyd, Brian Masney, Jerome Brunet,
	Tony Lindgren, Aaro Koskinen, Andreas Kemnade, Kevin Hilman,
	Roger Quadros, Russell King, Andrew Goodbody, Rouven Czerwinski
  Cc: linux-omap, linux-clk, linux-kernel, linux-arm-kernel,
	Ettore Chimenti

During TI DM8168-EVM board testing we found that the clock hierarchy and
clock calculation was broken already on 6.12:

    main_pll_clk1       <--- main PLL should be parent of other PLLs.
       sysclk1_ck                   
       main_pll_clk7            
		...
       main_pll_clk6            
		...
       main_pll_clk5            
		...
       main_pll_clk4            
		...

This series brings fixes and additions for TI DM816x / FAPLL clock tree
and frequency calculation.

Summary:
- Fix clock tree hierarchy by not using ti_dt_clk_name() helper, that
  causes the first PLL as the parent of all clocks in DM816x.
- Correct rate calculation logic in fapll driver (1/2^24, was 1/10^7).
- Add sys_ck alias required for DM816x clock lookup, fixing a boot
  error.
- Add error logging for clocks failing registration to ease debugging.

Fixing clock tree hierarchy is critical as it fixes DM8168-EVM boot
failure in 7.3-rc7. These fixes are affecting DM816x SoCs only.

Signed-off-by: Ettore Chimenti <ettore.chimenti@linaro.org>
---
Changes in v3:
- Picked up Brian's review suggestions to extend commit message.
- Added constant macros in speed calculations, removing "magic numbers".
- Link to v2: https://patch.msgid.link/20261028-patch-ektor5-dm8168-clk-v2-0-dc6bf0fabae4@linaro.org

Changes in v2:
- Fixed off-by-one error in clock calculation (Sashiko).
- Fixed clock calculation also in the set rate path.
- Added Fixes tag to clock calculation fix patch.
- Link to v1: https://patch.msgid.link/20261015-patch-ektor5-dm8168-clk-v1-0-8b99c5cd5541@linaro.org

---
Andrew Goodbody (1):
      clk: ti: fapll: Fix clock speed calculation

Ettore Chimenti (1):
      ARM: OMAP2+: ti81xx: use non-scalable voltage domains

Rouven Czerwinski (2):
      clk: ti: fapll: remove ti_dt_clk_name helper
      clk: ti: fapll: print clock name that fails to register

 arch/arm/mach-omap2/voltagedomains3xxx_data.c |  2 +-
 drivers/clk/ti/fapll.c                        | 26 +++++++++++++-------------
 2 files changed, 14 insertions(+), 14 deletions(-)
---
base-commit: 2800868f63227c8237d70c41e70d441c919620d6
change-id: 20261014-patch-ektor5-dm8168-clk-e426101415b0

Best regards,
--  
Ettore Chimenti <ettore.chimenti@linaro.org>



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

* [PATCH v3 1/4] clk: ti: fapll: remove ti_dt_clk_name helper
  2026-11-13 21:30 [PATCH v3 0/4] clk: ti: fapll/dm816x: clock tree and calculation fixes Ettore Chimenti
@ 2026-11-13 21:30 ` Ettore Chimenti
  2026-11-13 21:30 ` [PATCH v3 2/4] clk: ti: fapll: Fix clock speed calculation Ettore Chimenti
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 6+ messages in thread
From: Ettore Chimenti @ 2026-11-13 21:30 UTC (permalink / raw)
  To: Tero Kristo, Stephen Boyd, Brian Masney, Jerome Brunet,
	Tony Lindgren, Aaro Koskinen, Andreas Kemnade, Kevin Hilman,
	Roger Quadros, Russell King, Andrew Goodbody, Rouven Czerwinski
  Cc: linux-omap, linux-clk, linux-kernel, linux-arm-kernel,
	Ettore Chimenti

From: Rouven Czerwinski <rouven.czerwinski@linaro.org>

The fapll driver uses multiple `clock-output-names`, so we cannot use the
DT helper in this driver because that would assign the first clock
output name as the parent name. Otherwise, the clock hierarchy would
look like this:

        main_pll_clk1       <--- main PLL should be parent of other PLLs.
           sysclk1_ck
           main_pll_clk7
                    ...
           main_pll_clk6
                    ...
           main_pll_clk5
                    ...
           main_pll_clk4
                    ...

Reverting to not using `ti_dt_clk_name()` solves this problem, assigning
the correct parent.  This change do not affect other SoCs as the only
consumer is DM816x.

Fixes: 9e56a7d4263c ("clk: ti: Update pll and clockdomain clocks to use ti_dt_clk_name()")
Signed-off-by: Rouven Czerwinski <rouven.czerwinski@linaro.org>
Tested-by: Andrew Goodbody <andrew.goodbody@linaro.org>
Signed-off-by: Ettore Chimenti <ettore.chimenti@linaro.org>
---
 drivers/clk/ti/fapll.c | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)

diff --git a/drivers/clk/ti/fapll.c b/drivers/clk/ti/fapll.c
index e54b1df3436e..ae2f6fed10f6 100644
--- a/drivers/clk/ti/fapll.c
+++ b/drivers/clk/ti/fapll.c
@@ -10,8 +10,6 @@
 #include <linux/of_address.h>
 #include <linux/clk/ti.h>
 
-#include "clock.h"
-
 /* FAPLL Control Register PLL_CTRL */
 #define FAPLL_MAIN_MULT_N_SHIFT	16
 #define FAPLL_MAIN_DIV_P_SHIFT	8
@@ -541,7 +539,6 @@ static void __init ti_fapll_setup(struct device_node *node)
 	struct clk_init_data *init = NULL;
 	const char *parent_name[2];
 	struct clk *pll_clk;
-	const char *name;
 	int i;
 
 	fd = kzalloc_obj(*fd);
@@ -559,8 +556,7 @@ static void __init ti_fapll_setup(struct device_node *node)
 		goto free;
 
 	init->ops = &ti_fapll_ops;
-	name = ti_dt_clk_name(node);
-	init->name = name;
+	init->name = node->name;
 
 	init->num_parents = of_clk_get_parent_count(node);
 	if (init->num_parents != 2) {
@@ -592,7 +588,7 @@ static void __init ti_fapll_setup(struct device_node *node)
 	if (fapll_is_ddr_pll(fd->base))
 		fd->bypass_bit_inverted = true;
 
-	fd->name = name;
+	fd->name = node->name;
 	fd->hw.init = init;
 
 	/* Register the parent PLL */
@@ -639,7 +635,7 @@ static void __init ti_fapll_setup(struct device_node *node)
 				freq = NULL;
 		}
 		synth_clk = ti_fapll_synth_setup(fd, freq, div, output_instance,
-						 output_name, name, pll_clk);
+						 output_name, node->name, pll_clk);
 		if (IS_ERR(synth_clk))
 			continue;
 

-- 
2.56.1



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

* [PATCH v3 2/4] clk: ti: fapll: Fix clock speed calculation
  2026-11-13 21:30 [PATCH v3 0/4] clk: ti: fapll/dm816x: clock tree and calculation fixes Ettore Chimenti
  2026-11-13 21:30 ` [PATCH v3 1/4] clk: ti: fapll: remove ti_dt_clk_name helper Ettore Chimenti
@ 2026-11-13 21:30 ` Ettore Chimenti
  2026-11-13 21:30 ` [PATCH v3 3/4] clk: ti: fapll: print clock name that fails to register Ettore Chimenti
  2026-11-13 21:30 ` [PATCH v3 4/4] ARM: OMAP2+: ti81xx: use non-scalable voltage domains Ettore Chimenti
  3 siblings, 0 replies; 6+ messages in thread
From: Ettore Chimenti @ 2026-11-13 21:30 UTC (permalink / raw)
  To: Tero Kristo, Stephen Boyd, Brian Masney, Jerome Brunet,
	Tony Lindgren, Aaro Koskinen, Andreas Kemnade, Kevin Hilman,
	Roger Quadros, Russell King, Andrew Goodbody, Rouven Czerwinski
  Cc: linux-omap, linux-clk, linux-kernel, linux-arm-kernel,
	Ettore Chimenti

From: Andrew Goodbody <andrew.goodbody@linaro.org>

The fractional part of the divider was being treated as 1/10000000
whereas it is in fact 1/2^24 (1/16777216). This led to incorrect clock
speeds being reported when a fractional divider was in use. Correct it.
As well as fixing the clock speed calculation when read, also update the
calculation on set in a similar manner.

Fixes: 163152cbbe32 ("clk: ti: Add support for FAPLL on dm816x")
Signed-off-by: Andrew Goodbody <andrew.goodbody@linaro.org>
Signed-off-by: Ettore Chimenti <ettore.chimenti@linaro.org>
---
 drivers/clk/ti/fapll.c | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/drivers/clk/ti/fapll.c b/drivers/clk/ti/fapll.c
index ae2f6fed10f6..bb9986508578 100644
--- a/drivers/clk/ti/fapll.c
+++ b/drivers/clk/ti/fapll.c
@@ -54,6 +54,9 @@
 #define SYNTH_MAX_INT_DIV	0xf
 #define SYNTH_MAX_DIV_M		0xff
 
+#define SYNTH_FRAC_DIV_BITS	24
+#define SYNTH_FRAC_DIV_SCALE	BIT(SYNTH_FRAC_DIV_BITS)
+
 struct fapll_data {
 	struct clk_hw hw;
 	void __iomem *base;
@@ -336,8 +339,9 @@ static unsigned long ti_fapll_synth_recalc_rate(struct clk_hw *hw,
 		v = readl_relaxed(synth->freq);
 		synth_int_div = (v >> 24) & 0xf;
 		synth_frac_div = v & 0xffffff;
-		synth_div_freq = (synth_int_div * 10000000) + synth_frac_div;
-		rate *= 10000000;
+		synth_div_freq = (synth_int_div * SYNTH_FRAC_DIV_SCALE)
+				  + synth_frac_div;
+		rate *= SYNTH_FRAC_DIV_SCALE;
 		do_div(rate, synth_div_freq);
 		rate *= SYNTH_PHASE_K;
 	}
@@ -378,10 +382,10 @@ static u32 ti_fapll_synth_set_frac_rate(struct fapll_synth *synth,
 	for (; post_div_m < SYNTH_MAX_DIV_M; post_div_m++) {
 		synth_int_div = DIV_ROUND_UP_ULL((u64)parent_rate *
 						 SYNTH_PHASE_K *
-						 10000000,
+						 SYNTH_FRAC_DIV_SCALE,
 						 rate * post_div_m);
-		synth_frac_div = synth_int_div % 10000000;
-		synth_int_div /= 10000000;
+		synth_frac_div = synth_int_div % SYNTH_FRAC_DIV_SCALE;
+		synth_int_div /= SYNTH_FRAC_DIV_SCALE;
 
 		if (synth_int_div <= SYNTH_MAX_INT_DIV)
 			break;

-- 
2.56.1



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

* [PATCH v3 3/4] clk: ti: fapll: print clock name that fails to register
  2026-11-13 21:30 [PATCH v3 0/4] clk: ti: fapll/dm816x: clock tree and calculation fixes Ettore Chimenti
  2026-11-13 21:30 ` [PATCH v3 1/4] clk: ti: fapll: remove ti_dt_clk_name helper Ettore Chimenti
  2026-11-13 21:30 ` [PATCH v3 2/4] clk: ti: fapll: Fix clock speed calculation Ettore Chimenti
@ 2026-11-13 21:30 ` Ettore Chimenti
  2026-11-13 21:30 ` [PATCH v3 4/4] ARM: OMAP2+: ti81xx: use non-scalable voltage domains Ettore Chimenti
  3 siblings, 0 replies; 6+ messages in thread
From: Ettore Chimenti @ 2026-11-13 21:30 UTC (permalink / raw)
  To: Tero Kristo, Stephen Boyd, Brian Masney, Jerome Brunet,
	Tony Lindgren, Aaro Koskinen, Andreas Kemnade, Kevin Hilman,
	Roger Quadros, Russell King, Andrew Goodbody, Rouven Czerwinski
  Cc: linux-omap, linux-clk, linux-kernel, linux-arm-kernel,
	Ettore Chimenti

From: Rouven Czerwinski <rouven.czerwinski@linaro.org>

Improve the error message when a clock fails to register by including
the clock's name and its parent's name for better debugging.

Signed-off-by: Rouven Czerwinski <rouven.czerwinski@linaro.org>
Signed-off-by: Ettore Chimenti <ettore.chimenti@linaro.org>
---
 drivers/clk/ti/fapll.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/clk/ti/fapll.c b/drivers/clk/ti/fapll.c
index bb9986508578..7d6a4dd4fc8c 100644
--- a/drivers/clk/ti/fapll.c
+++ b/drivers/clk/ti/fapll.c
@@ -524,7 +524,7 @@ static struct clk * __init ti_fapll_synth_setup(struct fapll_data *fd,
 
 	clk = clk_register(NULL, &synth->hw);
 	if (IS_ERR(clk)) {
-		pr_err("failed to register clock\n");
+		pr_err("failed to register clock '%s' for parent '%s'\n", name, parent);
 		goto free;
 	}
 

-- 
2.56.1



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

* [PATCH v3 4/4] ARM: OMAP2+: ti81xx: use non-scalable voltage domains
  2026-11-13 21:30 [PATCH v3 0/4] clk: ti: fapll/dm816x: clock tree and calculation fixes Ettore Chimenti
                   ` (2 preceding siblings ...)
  2026-11-13 21:30 ` [PATCH v3 3/4] clk: ti: fapll: print clock name that fails to register Ettore Chimenti
@ 2026-11-13 21:30 ` Ettore Chimenti
  2026-11-13 22:02   ` Andreas Kemnade
  3 siblings, 1 reply; 6+ messages in thread
From: Ettore Chimenti @ 2026-11-13 21:30 UTC (permalink / raw)
  To: Tero Kristo, Stephen Boyd, Brian Masney, Jerome Brunet,
	Tony Lindgren, Aaro Koskinen, Andreas Kemnade, Kevin Hilman,
	Roger Quadros, Russell King, Andrew Goodbody, Rouven Czerwinski
  Cc: linux-omap, linux-clk, linux-kernel, linux-arm-kernel,
	Ettore Chimenti

TI81xx SoCs reuse omap3xxx_voltagedomains_init(), which registers the
OMAP34xx/36xx voltage domains for every SoC except AM35xx. Those
domains are marked scalable and reference OMAP3 Voltage Controller and
Voltage Processor instances, which do not exist on DM814x/DM816x, and
no PMIC data is registered for these SoCs either.

As a result, omap_voltage_late_init() tries to set them up on every
boot and bails out early with:

  omap_voltage_late_init: Could not get sys clk.

Adding a "sys_ck" clock alias would only push the failure further into
omap_vc_init_channel() and omap_vp_init(), which then complain about
missing PMIC data.

TI81xx has no voltage scaling support in mainline, so, as done for
AM35xx in commit ddf536d0d7e1 ("ARM: OMAP: AM3517/3505: fix crash on
boot due to incorrect voltagedomain data"), register the non-scalable
voltage domains instead. They still provide the "mpu_iva", "core" and
"wkup" domains needed by the powerdomain data, and
omap_voltage_late_init() now skips them.

Signed-off-by: Ettore Chimenti <ettore.chimenti@linaro.org>
---
 arch/arm/mach-omap2/voltagedomains3xxx_data.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm/mach-omap2/voltagedomains3xxx_data.c b/arch/arm/mach-omap2/voltagedomains3xxx_data.c
index e98a3f289c27..478f5eb2a17f 100644
--- a/arch/arm/mach-omap2/voltagedomains3xxx_data.c
+++ b/arch/arm/mach-omap2/voltagedomains3xxx_data.c
@@ -119,7 +119,7 @@ void __init omap3xxx_voltagedomains_init(void)
 	omap3_voltdm_mpu.vc_param = &omap3_mpu_vc_data;
 	omap3_voltdm_core.vc_param = &omap3_core_vc_data;
 
-	if (soc_is_am35xx())
+	if (soc_is_am35xx() || soc_is_ti81xx())
 		voltdms = voltagedomains_am35xx;
 	else
 		voltdms = voltagedomains_omap3;

-- 
2.56.1



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

* Re: [PATCH v3 4/4] ARM: OMAP2+: ti81xx: use non-scalable voltage domains
  2026-11-13 21:30 ` [PATCH v3 4/4] ARM: OMAP2+: ti81xx: use non-scalable voltage domains Ettore Chimenti
@ 2026-11-13 22:02   ` Andreas Kemnade
  0 siblings, 0 replies; 6+ messages in thread
From: Andreas Kemnade @ 2026-11-13 22:02 UTC (permalink / raw)
  To: Ettore Chimenti
  Cc: Tero Kristo, Stephen Boyd, Brian Masney, Jerome Brunet,
	Tony Lindgren, Aaro Koskinen, Kevin Hilman, Roger Quadros,
	Russell King, Andrew Goodbody, Rouven Czerwinski, linux-omap,
	linux-clk, linux-kernel, linux-arm-kernel

On Fri, 13 Nov 2026 22:30:50 +0100
Ettore Chimenti <ettore.chimenti@linaro.org> wrote:

> TI81xx SoCs reuse omap3xxx_voltagedomains_init(), which registers the
> OMAP34xx/36xx voltage domains for every SoC except AM35xx. Those
> domains are marked scalable and reference OMAP3 Voltage Controller and
> Voltage Processor instances, which do not exist on DM814x/DM816x, and
> no PMIC data is registered for these SoCs either.
> 
> As a result, omap_voltage_late_init() tries to set them up on every
> boot and bails out early with:
> 
>   omap_voltage_late_init: Could not get sys clk.
> 
> Adding a "sys_ck" clock alias would only push the failure further into
> omap_vc_init_channel() and omap_vp_init(), which then complain about
> missing PMIC data.
> 
> TI81xx has no voltage scaling support in mainline, so, as done for
> AM35xx in commit ddf536d0d7e1 ("ARM: OMAP: AM3517/3505: fix crash on
> boot due to incorrect voltagedomain data"), register the non-scalable
> voltage domains instead. They still provide the "mpu_iva", "core" and
> "wkup" domains needed by the powerdomain data, and
> omap_voltage_late_init() now skips them.
> 
> Signed-off-by: Ettore Chimenti <ettore.chimenti@linaro.org>

Reviewed-by: Andreas Kemnade <andreas@kemnade.info>
> ---
>  arch/arm/mach-omap2/voltagedomains3xxx_data.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/arch/arm/mach-omap2/voltagedomains3xxx_data.c b/arch/arm/mach-omap2/voltagedomains3xxx_data.c
> index e98a3f289c27..478f5eb2a17f 100644
> --- a/arch/arm/mach-omap2/voltagedomains3xxx_data.c
> +++ b/arch/arm/mach-omap2/voltagedomains3xxx_data.c
> @@ -119,7 +119,7 @@ void __init omap3xxx_voltagedomains_init(void)
>  	omap3_voltdm_mpu.vc_param = &omap3_mpu_vc_data;
>  	omap3_voltdm_core.vc_param = &omap3_core_vc_data;
>  
> -	if (soc_is_am35xx())
> +	if (soc_is_am35xx() || soc_is_ti81xx())
>  		voltdms = voltagedomains_am35xx;
>  	else
>  		voltdms = voltagedomains_omap3;
> 



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

end of thread, other threads:[~2026-11-13 22:03 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-13 21:30 [PATCH v3 0/4] clk: ti: fapll/dm816x: clock tree and calculation fixes Ettore Chimenti
2026-11-13 21:30 ` [PATCH v3 1/4] clk: ti: fapll: remove ti_dt_clk_name helper Ettore Chimenti
2026-11-13 21:30 ` [PATCH v3 2/4] clk: ti: fapll: Fix clock speed calculation Ettore Chimenti
2026-11-13 21:30 ` [PATCH v3 3/4] clk: ti: fapll: print clock name that fails to register Ettore Chimenti
2026-11-13 21:30 ` [PATCH v3 4/4] ARM: OMAP2+: ti81xx: use non-scalable voltage domains Ettore Chimenti
2026-11-13 22:02   ` Andreas Kemnade

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox