[PATCH 1/4] arm64: dts: imx8mn: Include 32kHz oscillator clock in SPL DTs

Since 50cdd3f74af3 ("clk: imx: clk-imx8mn Fix nand and spi clock parent"), drivers/clk/imx/clk-imx8mn.c clk_get_by_name(dev, "osc_24m", &osc_24m_clk) fails with error -22 EINVAL in SPL. This is because clk_get_by_name() in the end calls fdtdec_parse_phandle_with_args(), which iterates over all phandles in clock-controller@30380000 { clocks = <&osc_32k>, <&osc_24m>, ... } node 'clocks' property in an attempt to find the "osc_24m" clock, but fails to resolve the &osc_32k phandle and returns with -EINVAL.
Include the osc_32k clock in SPL DTs as a low risk fix for v2025.01 release. This way, fdtdec_parse_phandle_with_args() can resolve both the osc_32k and following osc_24m phandle and successfully look up the osc_24m clock.
Fixes: 50cdd3f74af3 ("clk: imx: clk-imx8mn Fix nand and spi clock parent") Signed-off-by: Marek Vasut marex@denx.de --- Cc: "NXP i.MX U-Boot Team" uboot-imx@nxp.com Cc: Bryan Brattlof bb@ti.com Cc: Fabio Estevam festevam@gmail.com Cc: Greg Malysa greg.malysa@timesys.com Cc: Ian Roberts ian.roberts@timesys.com Cc: Ilias Apalodimas ilias.apalodimas@linaro.org Cc: Jonathan Humphreys j-humphreys@ti.com Cc: Masahisa Kojima kojima.masahisa@socionext.com Cc: Nathan Barrett-Morrison nathan.morrison@timesys.com Cc: Rasmus Villemoes rasmus.villemoes@prevas.dk Cc: Simon Glass sjg@chromium.org Cc: Stefano Babic sbabic@denx.de Cc: Sumit Garg sumit.garg@linaro.org Cc: Tim Harvey tharvey@gateworks.com Cc: Tom Rini trini@konsulko.com Cc: u-boot@lists.denx.de --- NOTE: For v2025.01 --- arch/arm/dts/imx8mn-u-boot.dtsi | 5 +++++ 1 file changed, 5 insertions(+)
diff --git a/arch/arm/dts/imx8mn-u-boot.dtsi b/arch/arm/dts/imx8mn-u-boot.dtsi index 6875c6d44ff..6d80d856365 100644 --- a/arch/arm/dts/imx8mn-u-boot.dtsi +++ b/arch/arm/dts/imx8mn-u-boot.dtsi @@ -68,6 +68,11 @@ bootph-all; };
+&osc_32k { + bootph-pre-ram; + bootph-all; +}; + #ifdef CONFIG_FSL_CAAM &sec_jr0 { bootph-pre-ram;

Currently the U-Boot SPL build uses the same DTBs that were generated during U-Boot proper build, and calls 'fdtgrep' on those DTBs to filter out uninteresting nodes and properties. Those U-Boot proper DTBs are built from DTS which are first preprocessed by CPP, but that CPP is invoked in U-Boot proper build context and effectively ignores the CONFIG_SPL_BUILD macro. In case the CONFIG_SPL_BUILD macro is used in any .dts file, the content of the macro is removed by CPP.
Fix this by building a separate set of DTBs for the SPL, which are preprocessed by CPP with -DCONFIG_SPL_BUILD set. Use the same way for the other PLs.
Signed-off-by: Marek Vasut marex@denx.de --- Cc: "NXP i.MX U-Boot Team" uboot-imx@nxp.com Cc: Bryan Brattlof bb@ti.com Cc: Fabio Estevam festevam@gmail.com Cc: Greg Malysa greg.malysa@timesys.com Cc: Ian Roberts ian.roberts@timesys.com Cc: Ilias Apalodimas ilias.apalodimas@linaro.org Cc: Jonathan Humphreys j-humphreys@ti.com Cc: Masahisa Kojima kojima.masahisa@socionext.com Cc: Nathan Barrett-Morrison nathan.morrison@timesys.com Cc: Rasmus Villemoes rasmus.villemoes@prevas.dk Cc: Simon Glass sjg@chromium.org Cc: Stefano Babic sbabic@denx.de Cc: Sumit Garg sumit.garg@linaro.org Cc: Tim Harvey tharvey@gateworks.com Cc: Tom Rini trini@konsulko.com Cc: u-boot@lists.denx.de --- NOTE: For v2025.04 --- dts/Makefile | 5 ++++- scripts/Makefile.lib | 11 +++++++++++ scripts/Makefile.xpl | 7 ++++++- 3 files changed, 21 insertions(+), 2 deletions(-)
diff --git a/dts/Makefile b/dts/Makefile index 86bf8dc2156..53cab9a37a4 100644 --- a/dts/Makefile +++ b/dts/Makefile @@ -32,7 +32,10 @@ else DTB := $(dt_dir)/$(DEVICE_TREE).dtb endif
-$(obj)/dt-$(SPL_NAME).dtb: dts/dt.dtb $(objtree)/tools/fdtgrep FORCE +$(obj)/dt-$(SPL_NAME).tmp.dtb: $(patsubst %.dtb,%.dts,$(DTB)) FORCE + $(call if_changed,dtc) + +$(obj)/dt-$(SPL_NAME).dtb: $(obj)/dt-$(SPL_NAME).tmp.dtb $(objtree)/tools/fdtgrep FORCE mkdir -p $(dir $@) $(call if_changed,fdtgrep)
diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib index 54403040f00..a42965edc6f 100644 --- a/scripts/Makefile.lib +++ b/scripts/Makefile.lib @@ -202,6 +202,16 @@ endif dtsi_include_list = $(strip $(u_boot_dtsi_options_debug) \ $(notdir $(firstword $(u_boot_dtsi_options))))
+ifeq ($(CONFIG_SPL_BUILD),y) +dtc_cpp_xpl_flags = -DCONFIG_XPL_BUILD -DCONFIG_SPL_BUILD +else ifeq ($(CONFIG_TPL_BUILD),y) +dtc_cpp_xpl_flags = -DCONFIG_XPL_BUILD -DCONFIG_TPL_BUILD +else ifeq ($(CONFIG_VPL_BUILD),y) +dtc_cpp_xpl_flags = -DCONFIG_XPL_BUILD -DCONFIG_VPL_BUILD +else +dtc_cpp_xpl_flags = +endif + # Modified for U-Boot upstream_dtsi_include = $(addprefix -I, $(srctree)/dts/upstream/src/ \ $(sort $(dir $(wildcard $(srctree)/dts/upstream/src/$(ARCH)/*/*))) \ @@ -214,6 +224,7 @@ dtc_cpp_flags = -Wp,-MD,$(depfile).pre.tmp -nostdinc \ -I$(srctree)/arch/$(ARCH)/dts/include \ -I$(srctree)/include \ $(upstream_dtsi_include) \ + $(dtc_cpp_xpl_flags) \ -D__ASSEMBLY__ \ -undef -D__DTS__
diff --git a/scripts/Makefile.xpl b/scripts/Makefile.xpl index dca5f4539d0..c0bd8dd7f97 100644 --- a/scripts/Makefile.xpl +++ b/scripts/Makefile.xpl @@ -590,11 +590,16 @@ endif
SPL_OF_LIST_TARGETS = $(patsubst %,dts/%.dtb,$(subst ",,$(CONFIG_SPL_OF_LIST))) SHRUNK_ARCH_DTB = $(addprefix $(obj)/,$(SPL_OF_LIST_TARGETS)) +SPL_TMP_OF_LIST_TARGETS = $(patsubst %,dts/%.spl.dtb,$(subst ",,$(CONFIG_SPL_OF_LIST))) +SHRUNK_ARCH_TMP_DTB = $(addprefix $(obj)/,$(SPL_TMP_OF_LIST_TARGETS)) $(sort $(dir $(SHRUNK_ARCH_DTB))): $(shell [ -d $@ ] || mkdir -p $@)
.SECONDEXPANSION: -$(SHRUNK_ARCH_DTB): $$(patsubst $(obj)/dts/%, $(dt_dir)/%, $$@) $(dir $(SHRUNK_ARCH_DTB)) +$(SHRUNK_ARCH_TMP_DTB): $$(patsubst %.spl.dtb,%.dts,$$(patsubst $(obj)/dts/%, $(dt_dir)/%, $$@)) $(dir $(SHRUNK_ARCH_TMP_DTB)) + $(call if_changed,dtc) + +$(SHRUNK_ARCH_DTB): $$(patsubst %.dtb,%.spl.dtb,$$@) $(dir $(SHRUNK_ARCH_DTB)) $(call if_changed,fdtgrep)
targets += $(SPL_OF_LIST_TARGETS)

Hi Marek,
On Thu, 21 Nov 2024 at 18:59, Marek Vasut marex@denx.de wrote:
Currently the U-Boot SPL build uses the same DTBs that were generated during U-Boot proper build, and calls 'fdtgrep' on those DTBs to filter out uninteresting nodes and properties. Those U-Boot proper DTBs are built from DTS which are first preprocessed by CPP, but that CPP is invoked in U-Boot proper build context and effectively ignores the CONFIG_SPL_BUILD macro. In case the CONFIG_SPL_BUILD macro is used in any .dts file, the content of the macro is removed by CPP.
Fix this by building a separate set of DTBs for the SPL, which are preprocessed by CPP with -DCONFIG_SPL_BUILD set. Use the same way for the other PLs.
Signed-off-by: Marek Vasut marex@denx.de
Cc: "NXP i.MX U-Boot Team" uboot-imx@nxp.com Cc: Bryan Brattlof bb@ti.com Cc: Fabio Estevam festevam@gmail.com Cc: Greg Malysa greg.malysa@timesys.com Cc: Ian Roberts ian.roberts@timesys.com Cc: Ilias Apalodimas ilias.apalodimas@linaro.org Cc: Jonathan Humphreys j-humphreys@ti.com Cc: Masahisa Kojima kojima.masahisa@socionext.com Cc: Nathan Barrett-Morrison nathan.morrison@timesys.com Cc: Rasmus Villemoes rasmus.villemoes@prevas.dk Cc: Simon Glass sjg@chromium.org Cc: Stefano Babic sbabic@denx.de Cc: Sumit Garg sumit.garg@linaro.org Cc: Tim Harvey tharvey@gateworks.com Cc: Tom Rini trini@konsulko.com Cc: u-boot@lists.denx.de
NOTE: For v2025.04
dts/Makefile | 5 ++++- scripts/Makefile.lib | 11 +++++++++++ scripts/Makefile.xpl | 7 ++++++- 3 files changed, 21 insertions(+), 2 deletions(-)
As mentioned on the other patch, this should be handled in fdtgrep
Regards, Simon

On 11/26/24 1:32 AM, Simon Glass wrote:
Hi Marek,
On Thu, 21 Nov 2024 at 18:59, Marek Vasut marex@denx.de wrote:
Currently the U-Boot SPL build uses the same DTBs that were generated during U-Boot proper build, and calls 'fdtgrep' on those DTBs to filter out uninteresting nodes and properties. Those U-Boot proper DTBs are built from DTS which are first preprocessed by CPP, but that CPP is invoked in U-Boot proper build context and effectively ignores the CONFIG_SPL_BUILD macro. In case the CONFIG_SPL_BUILD macro is used in any .dts file, the content of the macro is removed by CPP.
Fix this by building a separate set of DTBs for the SPL, which are preprocessed by CPP with -DCONFIG_SPL_BUILD set. Use the same way for the other PLs.
Signed-off-by: Marek Vasut marex@denx.de
Cc: "NXP i.MX U-Boot Team" uboot-imx@nxp.com Cc: Bryan Brattlof bb@ti.com Cc: Fabio Estevam festevam@gmail.com Cc: Greg Malysa greg.malysa@timesys.com Cc: Ian Roberts ian.roberts@timesys.com Cc: Ilias Apalodimas ilias.apalodimas@linaro.org Cc: Jonathan Humphreys j-humphreys@ti.com Cc: Masahisa Kojima kojima.masahisa@socionext.com Cc: Nathan Barrett-Morrison nathan.morrison@timesys.com Cc: Rasmus Villemoes rasmus.villemoes@prevas.dk Cc: Simon Glass sjg@chromium.org Cc: Stefano Babic sbabic@denx.de Cc: Sumit Garg sumit.garg@linaro.org Cc: Tim Harvey tharvey@gateworks.com Cc: Tom Rini trini@konsulko.com Cc: u-boot@lists.denx.de
NOTE: For v2025.04
dts/Makefile | 5 ++++- scripts/Makefile.lib | 11 +++++++++++ scripts/Makefile.xpl | 7 ++++++- 3 files changed, 21 insertions(+), 2 deletions(-)
As mentioned on the other patch, this should be handled in fdtgrep
Adam already replied to you regarding this part in 3/4 , please continue the discussion there.

Since 50cdd3f74af3 ("clk: imx: clk-imx8mn Fix nand and spi clock parent"), drivers/clk/imx/clk-imx8mn.c clk_get_by_name(dev, "osc_24m", &osc_24m_clk) fails with error -22 EINVAL in SPL. This is because clk_get_by_name() in the end calls fdtdec_parse_phandle_with_args(), which iterates over all phandles in clock-controller@30380000 { clocks = <&osc_32k>, <&osc_24m>, ... } node 'clocks' property in an attempt to find the "osc_24m" clock, but fails to resolve the &osc_32k phandle and returns with -EINVAL.
Remove the clocks property phandles which cannot be resolved because their matching nodes are removed from SPL DTs, so fdtdec_parse_phandle_with_args() can resolve all the remaining valid nodes and successfully look up the osc_24m clock.
Fixes: 50cdd3f74af3 ("clk: imx: clk-imx8mn Fix nand and spi clock parent") Signed-off-by: Marek Vasut marex@denx.de --- Cc: "NXP i.MX U-Boot Team" uboot-imx@nxp.com Cc: Bryan Brattlof bb@ti.com Cc: Fabio Estevam festevam@gmail.com Cc: Greg Malysa greg.malysa@timesys.com Cc: Ian Roberts ian.roberts@timesys.com Cc: Ilias Apalodimas ilias.apalodimas@linaro.org Cc: Jonathan Humphreys j-humphreys@ti.com Cc: Masahisa Kojima kojima.masahisa@socionext.com Cc: Nathan Barrett-Morrison nathan.morrison@timesys.com Cc: Rasmus Villemoes rasmus.villemoes@prevas.dk Cc: Simon Glass sjg@chromium.org Cc: Stefano Babic sbabic@denx.de Cc: Sumit Garg sumit.garg@linaro.org Cc: Tim Harvey tharvey@gateworks.com Cc: Tom Rini trini@konsulko.com Cc: u-boot@lists.denx.de --- NOTE: For v2025.04 --- arch/arm/dts/imx8mn-u-boot.dtsi | 4 ++++ 1 file changed, 4 insertions(+)
diff --git a/arch/arm/dts/imx8mn-u-boot.dtsi b/arch/arm/dts/imx8mn-u-boot.dtsi index 6d80d856365..38e1934aee8 100644 --- a/arch/arm/dts/imx8mn-u-boot.dtsi +++ b/arch/arm/dts/imx8mn-u-boot.dtsi @@ -51,6 +51,10 @@ /delete-property/ assigned-clocks; /delete-property/ assigned-clock-parents; /delete-property/ assigned-clock-rates; +#ifdef CONFIG_SPL_BUILD + clocks = <&osc_24m>; + clock-names = "osc_24m"; +#endif };
#ifdef CONFIG_FSL_CAAM

Hi Marek,
On Thu, 21 Nov 2024 at 18:59, Marek Vasut marex@denx.de wrote:
Since 50cdd3f74af3 ("clk: imx: clk-imx8mn Fix nand and spi clock parent"), drivers/clk/imx/clk-imx8mn.c clk_get_by_name(dev, "osc_24m", &osc_24m_clk) fails with error -22 EINVAL in SPL. This is because clk_get_by_name() in the end calls fdtdec_parse_phandle_with_args(), which iterates over all phandles in clock-controller@30380000 { clocks = <&osc_32k>, <&osc_24m>, ... } node 'clocks' property in an attempt to find the "osc_24m" clock, but fails to resolve the &osc_32k phandle and returns with -EINVAL.
Remove the clocks property phandles which cannot be resolved because their matching nodes are removed from SPL DTs, so fdtdec_parse_phandle_with_args() can resolve all the remaining valid nodes and successfully look up the osc_24m clock.
Fixes: 50cdd3f74af3 ("clk: imx: clk-imx8mn Fix nand and spi clock parent") Signed-off-by: Marek Vasut marex@denx.de
Cc: "NXP i.MX U-Boot Team" uboot-imx@nxp.com Cc: Bryan Brattlof bb@ti.com Cc: Fabio Estevam festevam@gmail.com Cc: Greg Malysa greg.malysa@timesys.com Cc: Ian Roberts ian.roberts@timesys.com Cc: Ilias Apalodimas ilias.apalodimas@linaro.org Cc: Jonathan Humphreys j-humphreys@ti.com Cc: Masahisa Kojima kojima.masahisa@socionext.com Cc: Nathan Barrett-Morrison nathan.morrison@timesys.com Cc: Rasmus Villemoes rasmus.villemoes@prevas.dk Cc: Simon Glass sjg@chromium.org Cc: Stefano Babic sbabic@denx.de Cc: Sumit Garg sumit.garg@linaro.org Cc: Tim Harvey tharvey@gateworks.com Cc: Tom Rini trini@konsulko.com Cc: u-boot@lists.denx.de
NOTE: For v2025.04
arch/arm/dts/imx8mn-u-boot.dtsi | 4 ++++ 1 file changed, 4 insertions(+)
diff --git a/arch/arm/dts/imx8mn-u-boot.dtsi b/arch/arm/dts/imx8mn-u-boot.dtsi index 6d80d856365..38e1934aee8 100644 --- a/arch/arm/dts/imx8mn-u-boot.dtsi +++ b/arch/arm/dts/imx8mn-u-boot.dtsi @@ -51,6 +51,10 @@ /delete-property/ assigned-clocks; /delete-property/ assigned-clock-parents; /delete-property/ assigned-clock-rates; +#ifdef CONFIG_SPL_BUILD
clocks = <&osc_24m>;
clock-names = "osc_24m";
+#endif };
#ifdef CONFIG_FSL_CAAM
2.45.2
We should not be checking U-Boot CONFIG things in .dts sources, since there is no way it could go upstream.
get_phandle_argc() shows how this is done in dtoc. It seems we will need similar logic in fdtgrep to handle this. You'll be pleased to hear it is written in C :-)
BTW the bootph tags should be able to go upstream and be dropped from the .dtsi - the only thing in the dtsi these days in the Binman definition, which is barely started upstream.
Regards, Simon

On Fri, Nov 22, 2024 at 8:33 AM Simon Glass sjg@chromium.org wrote:
Hi Marek,
On Thu, 21 Nov 2024 at 18:59, Marek Vasut marex@denx.de wrote:
Since 50cdd3f74af3 ("clk: imx: clk-imx8mn Fix nand and spi clock parent"), drivers/clk/imx/clk-imx8mn.c clk_get_by_name(dev, "osc_24m", &osc_24m_clk) fails with error -22 EINVAL in SPL. This is because clk_get_by_name() in the end calls fdtdec_parse_phandle_with_args(), which iterates over all phandles in clock-controller@30380000 { clocks = <&osc_32k>, <&osc_24m>, ... } node 'clocks' property in an attempt to find the "osc_24m" clock, but fails to resolve the &osc_32k phandle and returns with -EINVAL.
Remove the clocks property phandles which cannot be resolved because their matching nodes are removed from SPL DTs, so fdtdec_parse_phandle_with_args() can resolve all the remaining valid nodes and successfully look up the osc_24m clock.
Fixes: 50cdd3f74af3 ("clk: imx: clk-imx8mn Fix nand and spi clock parent") Signed-off-by: Marek Vasut marex@denx.de
Cc: "NXP i.MX U-Boot Team" uboot-imx@nxp.com Cc: Bryan Brattlof bb@ti.com Cc: Fabio Estevam festevam@gmail.com Cc: Greg Malysa greg.malysa@timesys.com Cc: Ian Roberts ian.roberts@timesys.com Cc: Ilias Apalodimas ilias.apalodimas@linaro.org Cc: Jonathan Humphreys j-humphreys@ti.com Cc: Masahisa Kojima kojima.masahisa@socionext.com Cc: Nathan Barrett-Morrison nathan.morrison@timesys.com Cc: Rasmus Villemoes rasmus.villemoes@prevas.dk Cc: Simon Glass sjg@chromium.org Cc: Stefano Babic sbabic@denx.de Cc: Sumit Garg sumit.garg@linaro.org Cc: Tim Harvey tharvey@gateworks.com Cc: Tom Rini trini@konsulko.com Cc: u-boot@lists.denx.de
NOTE: For v2025.04
arch/arm/dts/imx8mn-u-boot.dtsi | 4 ++++ 1 file changed, 4 insertions(+)
diff --git a/arch/arm/dts/imx8mn-u-boot.dtsi b/arch/arm/dts/imx8mn-u-boot.dtsi index 6d80d856365..38e1934aee8 100644 --- a/arch/arm/dts/imx8mn-u-boot.dtsi +++ b/arch/arm/dts/imx8mn-u-boot.dtsi @@ -51,6 +51,10 @@ /delete-property/ assigned-clocks; /delete-property/ assigned-clock-parents; /delete-property/ assigned-clock-rates; +#ifdef CONFIG_SPL_BUILD
clocks = <&osc_24m>;
clock-names = "osc_24m";
+#endif };
#ifdef CONFIG_FSL_CAAM
2.45.2
We should not be checking U-Boot CONFIG things in .dts sources, since there is no way it could go upstream.
This file has the -u-boot.dtsi ending, so doesn't that mean it would be unique to U-Boot and not be pushed to Linux?
adam
get_phandle_argc() shows how this is done in dtoc. It seems we will need similar logic in fdtgrep to handle this. You'll be pleased to hear it is written in C :-)
BTW the bootph tags should be able to go upstream and be dropped from the .dtsi - the only thing in the dtsi these days in the Binman definition, which is barely started upstream.
Regards, Simon

Hi Adam,
On Fri, Nov 22, 2024, 14:44 Adam Ford aford173@gmail.com wrote:
On Fri, Nov 22, 2024 at 8:33 AM Simon Glass sjg@chromium.org wrote:
Hi Marek,
On Thu, 21 Nov 2024 at 18:59, Marek Vasut marex@denx.de wrote:
Since 50cdd3f74af3 ("clk: imx: clk-imx8mn Fix nand and spi clock parent"), drivers/clk/imx/clk-imx8mn.c clk_get_by_name(dev, "osc_24m", &osc_24m_clk) fails with error -22 EINVAL in SPL. This is because clk_get_by_name() in the end calls fdtdec_parse_phandle_with_args(), which iterates over all phandles in clock-controller@30380000 { clocks = <&osc_32k>, <&osc_24m>, ... } node 'clocks' property in an attempt to find the "osc_24m" clock, but fails to resolve the &osc_32k phandle and returns with -EINVAL.
Remove the clocks property phandles which cannot be resolved because their matching nodes are removed from SPL DTs, so fdtdec_parse_phandle_with_args() can resolve all the remaining valid nodes and successfully look up the osc_24m clock.
Fixes: 50cdd3f74af3 ("clk: imx: clk-imx8mn Fix nand and spi clock parent") Signed-off-by: Marek Vasut marex@denx.de
Cc: "NXP i.MX U-Boot Team" uboot-imx@nxp.com Cc: Bryan Brattlof bb@ti.com Cc: Fabio Estevam festevam@gmail.com Cc: Greg Malysa greg.malysa@timesys.com Cc: Ian Roberts ian.roberts@timesys.com Cc: Ilias Apalodimas ilias.apalodimas@linaro.org Cc: Jonathan Humphreys j-humphreys@ti.com Cc: Masahisa Kojima kojima.masahisa@socionext.com Cc: Nathan Barrett-Morrison nathan.morrison@timesys.com Cc: Rasmus Villemoes rasmus.villemoes@prevas.dk Cc: Simon Glass sjg@chromium.org Cc: Stefano Babic sbabic@denx.de Cc: Sumit Garg sumit.garg@linaro.org Cc: Tim Harvey tharvey@gateworks.com Cc: Tom Rini trini@konsulko.com Cc: u-boot@lists.denx.de
NOTE: For v2025.04
arch/arm/dts/imx8mn-u-boot.dtsi | 4 ++++ 1 file changed, 4 insertions(+)
diff --git a/arch/arm/dts/imx8mn-u-boot.dtsi b/arch/arm/dts/imx8mn-u-boot.dtsi index 6d80d856365..38e1934aee8 100644 --- a/arch/arm/dts/imx8mn-u-boot.dtsi +++ b/arch/arm/dts/imx8mn-u-boot.dtsi @@ -51,6 +51,10 @@ /delete-property/ assigned-clocks; /delete-property/ assigned-clock-parents; /delete-property/ assigned-clock-rates; +#ifdef CONFIG_SPL_BUILD
clocks = <&osc_24m>;
clock-names = "osc_24m";
+#endif };
#ifdef CONFIG_FSL_CAAM
2.45.2
We should not be checking U-Boot CONFIG things in .dts sources, since there is no way it could go upstream.
This file has the -u-boot.dtsi ending, so doesn't that mean it would be unique to U-Boot and not be pushed to Linux?
No, we upstream all bindings so we should only have things in there on a temporary basis.
The correct solution is to enhance fdtgrep which I think I explained on the other thread. Let me know if I can assist with that.
Regards, Simon
adam
get_phandle_argc() shows how this is done in dtoc. It seems we will need similar logic in fdtgrep to handle this. You'll be pleased to hear it is written in C :-)
BTW the bootph tags should be able to go upstream and be dropped from the .dtsi - the only thing in the dtsi these days in the Binman definition, which is barely started upstream.
Regards, Simon

The 32 kHz oscillator was included in DT as a temporary workaround for the v2025.01 release. With a more appropriate fix in place for v2025.04, the workaround can be reverted.
Signed-off-by: Marek Vasut marex@denx.de --- Cc: "NXP i.MX U-Boot Team" uboot-imx@nxp.com Cc: Bryan Brattlof bb@ti.com Cc: Fabio Estevam festevam@gmail.com Cc: Greg Malysa greg.malysa@timesys.com Cc: Ian Roberts ian.roberts@timesys.com Cc: Ilias Apalodimas ilias.apalodimas@linaro.org Cc: Jonathan Humphreys j-humphreys@ti.com Cc: Masahisa Kojima kojima.masahisa@socionext.com Cc: Nathan Barrett-Morrison nathan.morrison@timesys.com Cc: Rasmus Villemoes rasmus.villemoes@prevas.dk Cc: Simon Glass sjg@chromium.org Cc: Stefano Babic sbabic@denx.de Cc: Sumit Garg sumit.garg@linaro.org Cc: Tim Harvey tharvey@gateworks.com Cc: Tom Rini trini@konsulko.com Cc: u-boot@lists.denx.de --- NOTE: For v2025.04 --- arch/arm/dts/imx8mn-u-boot.dtsi | 5 ----- 1 file changed, 5 deletions(-)
diff --git a/arch/arm/dts/imx8mn-u-boot.dtsi b/arch/arm/dts/imx8mn-u-boot.dtsi index 38e1934aee8..b0cb96f0829 100644 --- a/arch/arm/dts/imx8mn-u-boot.dtsi +++ b/arch/arm/dts/imx8mn-u-boot.dtsi @@ -72,11 +72,6 @@ bootph-all; };
-&osc_32k { - bootph-pre-ram; - bootph-all; -}; - #ifdef CONFIG_FSL_CAAM &sec_jr0 { bootph-pre-ram;

On Thu, Nov 21, 2024 at 7:59 PM Marek Vasut marex@denx.de wrote:
Since 50cdd3f74af3 ("clk: imx: clk-imx8mn Fix nand and spi clock parent"), drivers/clk/imx/clk-imx8mn.c clk_get_by_name(dev, "osc_24m", &osc_24m_clk) fails with error -22 EINVAL in SPL. This is because clk_get_by_name() in the end calls fdtdec_parse_phandle_with_args(), which iterates over all phandles in clock-controller@30380000 { clocks = <&osc_32k>, <&osc_24m>, ... } node 'clocks' property in an attempt to find the "osc_24m" clock, but fails to resolve the &osc_32k phandle and returns with -EINVAL.
Thanks for doing this.
Include the osc_32k clock in SPL DTs as a low risk fix for v2025.01 release. This way, fdtdec_parse_phandle_with_args() can resolve both the osc_32k and following osc_24m phandle and successfully look up the osc_24m clock.
Fixes: 50cdd3f74af3 ("clk: imx: clk-imx8mn Fix nand and spi clock parent") Signed-off-by: Marek Vasut marex@denx.de
Tested-by: Adam Ford aford173@gmail.com #imx8mn-beacon
Cc: "NXP i.MX U-Boot Team" uboot-imx@nxp.com Cc: Bryan Brattlof bb@ti.com Cc: Fabio Estevam festevam@gmail.com Cc: Greg Malysa greg.malysa@timesys.com Cc: Ian Roberts ian.roberts@timesys.com Cc: Ilias Apalodimas ilias.apalodimas@linaro.org Cc: Jonathan Humphreys j-humphreys@ti.com Cc: Masahisa Kojima kojima.masahisa@socionext.com Cc: Nathan Barrett-Morrison nathan.morrison@timesys.com Cc: Rasmus Villemoes rasmus.villemoes@prevas.dk Cc: Simon Glass sjg@chromium.org Cc: Stefano Babic sbabic@denx.de Cc: Sumit Garg sumit.garg@linaro.org Cc: Tim Harvey tharvey@gateworks.com Cc: Tom Rini trini@konsulko.com Cc: u-boot@lists.denx.de
NOTE: For v2025.01
arch/arm/dts/imx8mn-u-boot.dtsi | 5 +++++ 1 file changed, 5 insertions(+)
diff --git a/arch/arm/dts/imx8mn-u-boot.dtsi b/arch/arm/dts/imx8mn-u-boot.dtsi index 6875c6d44ff..6d80d856365 100644 --- a/arch/arm/dts/imx8mn-u-boot.dtsi +++ b/arch/arm/dts/imx8mn-u-boot.dtsi @@ -68,6 +68,11 @@ bootph-all; };
+&osc_32k {
bootph-pre-ram;
bootph-all;
+};
#ifdef CONFIG_FSL_CAAM &sec_jr0 { bootph-pre-ram; -- 2.45.2

On Thu, Nov 21, 2024 at 10:59 PM Marek Vasut marex@denx.de wrote:
Since 50cdd3f74af3 ("clk: imx: clk-imx8mn Fix nand and spi clock parent"), drivers/clk/imx/clk-imx8mn.c clk_get_by_name(dev, "osc_24m", &osc_24m_clk) fails with error -22 EINVAL in SPL. This is because clk_get_by_name() in the end calls fdtdec_parse_phandle_with_args(), which iterates over all phandles in clock-controller@30380000 { clocks = <&osc_32k>, <&osc_24m>, ... } node 'clocks' property in an attempt to find the "osc_24m" clock, but fails to resolve the &osc_32k phandle and returns with -EINVAL.
Include the osc_32k clock in SPL DTs as a low risk fix for v2025.01 release. This way, fdtdec_parse_phandle_with_args() can resolve both the osc_32k and following osc_24m phandle and successfully look up the osc_24m clock.
Fixes: 50cdd3f74af3 ("clk: imx: clk-imx8mn Fix nand and spi clock parent") Signed-off-by: Marek Vasut marex@denx.de
Applied only this one for -master, thanks.
participants (4)
-
Adam Ford
-
Fabio Estevam
-
Marek Vasut
-
Simon Glass