arm64: dts: amlogic: t7: fix UART clock and SD card recovery
Subsystems (2)
cover arm64: dts: amlogic: t7: fix UART clock and SD card recovery
Two fixes found while booting mainline on a Khadas VIM4.
The first one wires uart_a to the real UART bus clock. It was pointed at the 24MHz crystal as a placeholder, because the T7 clock controller driver did not exist when these boards were added. That leaves the real clock without a user, so the kernel turns it off when it disables unused clocks at the end of boot, and the board hangs with the console gone.
The second one drops regulator-always-on from the SD card supply. A card that refuses the 1.8V UHS switch can only be recovered by removing its power, which that property prevents, so the card never initialises and the MMC core retries forever.
Both were tested on a Khadas VIM4 booting v7.2 from the SD card.
Lucas Tanure (2):
arm64: dts: amlogic: t7: use the real UART pclk
arm64: dts: amlogic: t7: khadas-vim4: allow the SD card to be power
cycled
arch/arm64/boot/dts/amlogic/amlogic-t7-a311d2-an400.dts | 2 -- arch/arm64/boot/dts/amlogic/amlogic-t7-a311d2-khadas-vim4.dts | 3 --- arch/arm64/boot/dts/amlogic/amlogic-t7.dtsi | 4 ++++ 3 files changed, 4 insertions(+), 5 deletions(-)
--
2.55.0
PATCH 1/2 arm64: dts: amlogic: t7: use the real UART pclk
uart_a lists the 24MHz crystal for all three of its clocks, because the T7 clock controller driver did not exist when these boards were added.
That leaves the real UART bus clock without a user, so the kernel turns it off when it disables unused clocks at the end of boot, and the board hangs.
Point uart_a at the real clocks, the way meson-s4.dtsi does, and drop the placeholders from the two board files.
--- arch/arm64/boot/dts/amlogic/amlogic-t7-a311d2-an400.dts | 2 -- arch/arm64/boot/dts/amlogic/amlogic-t7-a311d2-khadas-vim4.dts | 2 -- arch/arm64/boot/dts/amlogic/amlogic-t7.dtsi | 4 ++++ 3 files changed, 4 insertions(+), 4 deletions(-)
arch/arm64/boot/dts/amlogic/amlogic-t7-a311d2-an400.dts +0 -2
@@ -33,7 +33,5 @@ xtal: xtal-clk { }; &uart_a { - clocks = <&xtal>, <&xtal>, <&xtal>; - clock-names = "xtal", "pclk", "baud"; status = "okay"; };
arch/arm64/boot/dts/amlogic/amlogic-t7-a311d2-khadas-vim4.dts +0 -2
@@ -266,6 +266,4 @@ &sd_emmc_c { &uart_a { status = "okay"; - clocks = <&xtal>, <&xtal>, <&xtal>; - clock-names = "xtal", "pclk", "baud"; };
arch/arm64/boot/dts/amlogic/amlogic-t7.dtsi +4 -0
@@ -587,6 +587,10 @@ uart_a: serial@78000 { compatible = "amlogic,t7-uart", "amlogic,meson-s4-uart"; reg = <0x0 0x78000 0x0 0x18>; interrupts = <GIC_SPI 168 IRQ_TYPE_EDGE_RISING>; + clocks = <&xtal>, + <&clkc_periphs CLKID_SYS_UART_A>, + <&xtal>; + clock-names = "xtal", "pclk", "baud"; status = "disabled"; };
Signature · 1 line
2.55.0
PATCH 2/2 arm64: dts: amlogic: t7: khadas-vim4: allow the SD card to be power cycled
In reply to Lucas TanureSD cards start at 3.3V and switch to 1.8V to reach UHS-I speeds. Some cards refuse that switch, and the SD specification says the only way to recover is to power the card off and start again.
SD_3V3 is marked regulator-always-on, so the supply never goes off, the card stays stuck half way through the switch, and the MMC core retries forever:
mmc1: error -95 whilst initialising SD card
Drop regulator-always-on. regulator-boot-on still turns the supply on at boot, and a card that refuses the switch now falls back to high speed instead of failing to initialise.
--- arch/arm64/boot/dts/amlogic/amlogic-t7-a311d2-khadas-vim4.dts | 1 - 1 file changed, 1 deletion(-)
arch/arm64/boot/dts/amlogic/amlogic-t7-a311d2-khadas-vim4.dts +0 -1
@@ -71,7 +71,6 @@ sd_3v3: regulator-sdcard-3v3 { vin-supply = <&vddao_3v3>; gpio = <&gpio GPIOD_11 GPIO_ACTIVE_LOW>; regulator-boot-on; - regulator-always-on; }; sdio_pwrseq: sdio-pwrseq {
Signature · 1 line
2.55.0
Re: [PATCH 1/2] arm64: dts: amlogic: t7: use the real UART pclk
In reply to Lucas TanureHi Lucas,
Quoted 65 lines · Lucas Tanure
uart_alists the 24MHz crystal for all three of its clocks, because the T7 clock controller driver did not exist when these boards were added.That leaves the real UART bus clock without a user, so the kernel turns it off when it disables unused clocks at the end of boot, and the board hangs.
Point
uart_aat the real clocks, the waymeson-s4.dtsidoes, and drop the placeholders from the two board files.Fixes 4fef056588f5 ("arm64: dts: amlogic-t7-a311d2-khadas-vim4: add initial device-tree")Fixes 6f048cc7a635 ("arm64: dts: add board AN400")Signed-off-by Lucas Tanure<[email protected]>Assisted-by Claude:claude-fable-5--- arch/arm64/boot/dts/amlogic/amlogic-t7-a311d2-an400.dts | 2 -- arch/arm64/boot/dts/amlogic/amlogic-t7-a311d2-khadas-vim4.dts | 2 -- arch/arm64/boot/dts/amlogic/amlogic-t7.dtsi | 4 ++++ 3 files changed, 4 insertions(+), 4 deletions(-)arch/arm64/boot/dts/amlogic/amlogic-t7-a311d2-an400.dts +0
-2@@ -33,7 +33,5 @@ xtal: xtal-clk { }; &uart_a { - clocks = <&xtal>, <&xtal>, <&xtal>; - clock-names = "xtal", "pclk", "baud"; status = "okay";};
diff --gita/arch/arm64/boot/dts/amlogic/amlogic-t7-a311d2-khadas-vim4.dtsb/arch/arm64/boot/dts/amlogic/amlogic-t7-a311d2-khadas-vim4.dtsindexc41525a34b72..677069e58f30100644arch/arm64/boot/dts/amlogic/amlogic-t7-a311d2-khadas-vim4.dts +0
-2@@ -266,6 +266,4 @@ &sd_emmc_c { &uart_a { status = "okay"; - clocks = <&xtal>, <&xtal>, <&xtal>; - clock-names = "xtal", "pclk", "baud";};arch/arm64/boot/dts/amlogic/amlogic-t7.dtsi +4
-0@@ -587,6 +587,10 @@ uart_a: serial@78000 { compatible = "amlogic,t7-uart", "amlogic,meson-s4-uart"; reg = <0x0 0x78000 0x0 0x18>; interrupts = <GIC_SPI 168 IRQ_TYPE_EDGE_RISING>; + clocks = <&xtal>, + <&clkc_periphs CLKID_SYS_UART_A>, + <&xtal>; + clock-names = "xtal", "pclk", "baud";
Quoted 2 lines
status = "disabled";
};I agree with moving the UART clock configuration to the DTSI file. However, it seems a little odd to keep the XTAL clock definition in the DTS, as the alias may not be consistent across different boards, which could result in compilation errors. Could we move the XTAL clock definition to the DTSI as well, similar to other Amlogic SoCs?
Re: [PATCH 1/2] arm64: dts: amlogic: t7: use the real UART pclk
Quoted 69 lines · Xianwei Zhao
Hi Lucas,
Quoted 66 lines · Lucas Tanure
uart_alists the 24MHz crystal for all three of its clocks, because the T7 clock controller driver did not exist when these boards were added.That leaves the real UART bus clock without a user, so the kernel turns it off when it disables unused clocks at the end of boot, and the board hangs.
Point
uart_aat the real clocks, the waymeson-s4.dtsidoes, and drop the placeholders from the two board files.Fixes 4fef056588f5 ("arm64: dts: amlogic-t7-a311d2-khadas-vim4: addinitial device-tree")
Fixes 6f048cc7a635 ("arm64: dts: add board AN400")Signed-off-by Lucas Tanure<[email protected]>Assisted-by Claude:claude-fable-5---
arch/arm64/boot/dts/amlogic/amlogic-t7-a311d2-an400.dts | 2 --arch/arm64/boot/dts/amlogic/amlogic-t7-a311d2-khadas-vim4.dts| 2 -- arch/arm64/boot/dts/amlogic/amlogic-t7.dtsi | 4 ++++3 files changed, 4 insertions(+), 4 deletions(-)arch/arm64/boot/dts/amlogic/amlogic-t7-a311d2-an400.dts +0
-2@@ -33,7 +33,5 @@ xtal: xtal-clk { }; &uart_a { - clocks = <&xtal>, <&xtal>, <&xtal>; - clock-names = "xtal", "pclk", "baud"; status = "okay";};
diff --gita/arch/arm64/boot/dts/amlogic/amlogic-t7-a311d2-khadas-vim4.dtsb/arch/arm64/boot/dts/amlogic/amlogic-t7-a311d2-khadas-vim4.dtsindexc41525a34b72..677069e58f30100644arch/arm64/boot/dts/amlogic/amlogic-t7-a311d2-khadas-vim4.dts +0
-2@@ -266,6 +266,4 @@ &sd_emmc_c { &uart_a { status = "okay"; - clocks = <&xtal>, <&xtal>, <&xtal>; - clock-names = "xtal", "pclk", "baud";};
arch/arm64/boot/dts/amlogic/amlogic-t7.dtsi +0
-0@@ -587,6 +587,10 @@ uart_a: serial@78000 { compatible = "amlogic,t7-uart", "amlogic,meson-s4-uart"; reg = <0x0 0x78000 0x0 0x18>;interrupts = <
GIC_SPI168IRQ_TYPE_EDGE_RISING>;
+ clocks = <&xtal>,
+ <&clkc_periphsCLKID_SYS_UART_A>,
+ <&xtal>;
+ clock-names = "xtal", "pclk", "baud";
Quoted 8 lines
Quoted 2 lines
status = "disabled"; };
I agree with moving the UART clock configuration to the DTSI file. However, it seems a little odd to keep the XTAL clock definition in the DTS, as the alias may not be consistent across different boards, which could result in compilation errors. Could we move the XTAL clock definition to the DTSI as well, similar to other Amlogic SoCs?
It seems similar to changes in this series :
https://lore.kernel.org/all/[email protected]/
What do you think ?
Signature · 7 lines
Best regards, Ronald _______________________________________________ linux-amlogic mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-amlogic
Re: [PATCH 1/2] arm64: dts: amlogic: t7: use the real UART pclk
In reply to Xianwei ZhaoQuoted 64 lines · Xianwei Zhao
Hi Lucas,
Quoted 61 lines · Lucas Tanure
uart_alists the 24MHz crystal for all three of its clocks, because the T7 clock controller driver did not exist when these boards were added.That leaves the real UART bus clock without a user, so the kernel turns it off when it disables unused clocks at the end of boot, and the board hangs.
Point
uart_aat the real clocks, the waymeson-s4.dtsidoes, and drop the placeholders from the two board files.Fixes 4fef056588f5 ("arm64: dts: amlogic-t7-a311d2-khadas-vim4: add initial device-tree")Fixes 6f048cc7a635 ("arm64: dts: add board AN400")Signed-off-by Lucas Tanure<[email protected]>Assisted-by Claude:claude-fable-5---
arch/arm64/boot/dts/amlogic/amlogic-t7-a311d2-an400.dts | 2 --arch/arm64/boot/dts/amlogic/amlogic-t7-a311d2-khadas-vim4.dts| 2 -- arch/arm64/boot/dts/amlogic/amlogic-t7.dtsi | 4 ++++3 files changed, 4 insertions(+), 4 deletions(-)arch/arm64/boot/dts/amlogic/amlogic-t7-a311d2-an400.dts +0
-2@@ -33,7 +33,5 @@ xtal: xtal-clk { }; &uart_a { - clocks = <&xtal>, <&xtal>, <&xtal>; - clock-names = "xtal", "pclk", "baud"; status = "okay";};
diff --gita/arch/arm64/boot/dts/amlogic/amlogic-t7-a311d2-khadas-vim4.dtsb/arch/arm64/boot/dts/amlogic/amlogic-t7-a311d2-khadas-vim4.dtsindexc41525a34b72..677069e58f30100644arch/arm64/boot/dts/amlogic/amlogic-t7-a311d2-khadas-vim4.dts +0
-2@@ -266,6 +266,4 @@ &sd_emmc_c { &uart_a { status = "okay"; - clocks = <&xtal>, <&xtal>, <&xtal>; - clock-names = "xtal", "pclk", "baud";};
arch/arm64/boot/dts/amlogic/amlogic-t7.dtsi +0
-0@@ -587,6 +587,10 @@ uart_a: serial@78000 { compatible = "amlogic,t7-uart", "amlogic,meson-s4-uart"; reg = <0x0 0x78000 0x0 0x18>;interrupts = <
GIC_SPI168IRQ_TYPE_EDGE_RISING>;
+ clocks = <&xtal>,
Quoted 8 lines
Quoted 6 lines
+ <
&clkc_periphsCLKID_SYS_UART_A>,
+ <&xtal>;
+ clock-names = "xtal", "pclk", "baud"; status = "disabled";
};I agree with moving the UART clock configuration to the DTSI file. However, it seems a little odd to keep the XTAL clock definition in the DTS, as the alias may not be consistent across different boards, which could result in compilation errors. Could we move the XTAL clock definition to the DTSI as well, similar to other Amlogic SoCs?
I think keeping it in the board files is actually better here, as the crystal (xtal) physically belongs to the board rather than the SoC. To keep things clean without moving xtal into amlogic-t7.dtsi, I've updated v2 to modify only the board DTS files.
Re: [PATCH 1/2] arm64: dts: amlogic: t7: use the real UART pclk
In reply to Ronald ClaveauQuoted 79 lines · Ronald Claveau
Quoted 69 lines · Xianwei Zhao
Hi Lucas,
Quoted 66 lines · Lucas Tanure
uart_alists the 24MHz crystal for all three of its clocks, because the T7 clock controller driver did not exist when these boards were added.That leaves the real UART bus clock without a user, so the kernel turns it off when it disables unused clocks at the end of boot, and the board hangs.
Point
uart_aat the real clocks, the waymeson-s4.dtsidoes, and drop the placeholders from the two board files.Fixes 4fef056588f5 ("arm64: dts: amlogic-t7-a311d2-khadas-vim4: addinitial device-tree")
Fixes 6f048cc7a635 ("arm64: dts: add board AN400")Signed-off-by Lucas Tanure<[email protected]>Assisted-by Claude:claude-fable-5--- arch/arm64/boot/dts/amlogic/amlogic-t7-a311d2-an400.dts | 2 -- arch/arm64/boot/dts/amlogic/amlogic-t7-a311d2-khadas-vim4.dts | 2 -- arch/arm64/boot/dts/amlogic/amlogic-t7.dtsi | 4 ++++ 3 files changed, 4 insertions(+), 4 deletions(-)arch/arm64/boot/dts/amlogic/amlogic-t7-a311d2-an400.dts +0
-2@@ -33,7 +33,5 @@ xtal: xtal-clk { }; &uart_a { - clocks = <&xtal>, <&xtal>, <&xtal>; - clock-names = "xtal", "pclk", "baud"; status = "okay";};
diff --gita/arch/arm64/boot/dts/amlogic/amlogic-t7-a311d2-khadas-vim4.dtsb/arch/arm64/boot/dts/amlogic/amlogic-t7-a311d2-khadas-vim4.dtsindexc41525a34b72..677069e58f30100644arch/arm64/boot/dts/amlogic/amlogic-t7-a311d2-khadas-vim4.dts +0
-2@@ -266,6 +266,4 @@ &sd_emmc_c { &uart_a { status = "okay"; - clocks = <&xtal>, <&xtal>, <&xtal>; - clock-names = "xtal", "pclk", "baud";};
arch/arm64/boot/dts/amlogic/amlogic-t7.dtsi +4
-0@@ -587,6 +587,10 @@ uart_a: serial@78000 { compatible = "amlogic,t7-uart", "amlogic,meson-s4-uart"; reg = <0x0 0x78000 0x0 0x18>; interrupts = <GIC_SPI 168 IRQ_TYPE_EDGE_RISING>; + clocks = <&xtal>, + <&clkc_periphs CLKID_SYS_UART_A>, + <&xtal>; + clock-names = "xtal", "pclk", "baud";Quoted 8 lines
Quoted 2 lines
status = "disabled"; };
I agree with moving the UART clock configuration to the DTSI file. However, it seems a little odd to keep the XTAL clock definition in the DTS, as the alias may not be consistent across different boards, which could result in compilation errors. Could we move the XTAL clock definition to the DTSI as well, similar to other Amlogic SoCs?
Quoted 6 lines
It seems similar to changes in this series :
https://lore.kernel.org/all/[email protected]/
What do you think ?
Thanks for pointing out that series, though I wasn't aware of it.
And after reading I don't agree with it. The clocks are not redundant, they are there because we agreed sometime ago that xtal belongs to the board files. So I still vote for my change in v2, that I will send in a few minutes.
Re: [PATCH 1/2] arm64: dts: amlogic: t7: use the real UART pclk
Quoted 86 lines · Lucas Tanure
Quoted 85 lines · Ronald Claveau
Quoted 70 lines · Xianwei Zhao
Hi Lucas,
Quoted 67 lines · Lucas Tanure
uart_alists the 24MHz crystal for all three of its clocks, because the T7 clock controller driver did not exist when these boards were added.That leaves the real UART bus clock without a user, so the kernel turns it off when it disables unused clocks at the end of boot, and the board hangs.
Point
uart_aat the real clocks, the waymeson-s4.dtsidoes, and drop the placeholders from the two board files.Fixes 4fef056588f5 ("arm64: dts: amlogic-t7-a311d2-khadas-vim4: addinitial device-tree")
Fixes 6f048cc7a635 ("arm64: dts: add board AN400")Signed-off-by Lucas Tanure<[email protected]>Assisted-by Claude:claude-fable-5---
arch/arm64/boot/dts/amlogic/amlogic-t7-a311d2-an400.dts | 2 --arch/arm64/boot/dts/amlogic/amlogic-t7-a311d2-khadas-vim4.dts| 2 -- arch/arm64/boot/dts/amlogic/amlogic-t7.dtsi | 4
++++3 files changed, 4 insertions(+), 4 deletions(-)arch/arm64/boot/dts/amlogic/amlogic-t7-a311d2-an400.dts +0
-2@@ -33,7 +33,5 @@ xtal: xtal-clk { }; &uart_a { - clocks = <&xtal>, <&xtal>, <&xtal>; - clock-names = "xtal", "pclk", "baud"; status = "okay";};
diff --gita/arch/arm64/boot/dts/amlogic/amlogic-t7-a311d2-khadas-vim4.dtsb/arch/arm64/boot/dts/amlogic/amlogic-t7-a311d2-khadas-vim4.dtsindexc41525a34b72..677069e58f30100644arch/arm64/boot/dts/amlogic/amlogic-t7-a311d2-khadas-vim4.dts +0
-2@@ -266,6 +266,4 @@ &sd_emmc_c { &uart_a { status = "okay"; - clocks = <&xtal>, <&xtal>, <&xtal>; - clock-names = "xtal", "pclk", "baud";};
arch/arm64/boot/dts/amlogic/amlogic-t7.dtsi +0
-0@@ -587,6 +587,10 @@ uart_a: serial@78000 { compatible = "amlogic,t7-uart", "amlogic,meson-s4-uart"; reg = <0x0 0x78000 0x0 0x18>;interrupts = <
GIC_SPI168IRQ_TYPE_EDGE_RISING>;
+ clocks = <&xtal>,
+ <&clkc_periphsCLKID_SYS_UART_A>,
+ <&xtal>;
+ clock-names = "xtal", "pclk", "baud";Quoted 8 lines
Quoted 2 lines
status = "disabled"; };
I agree with moving the UART clock configuration to the DTSI file. However, it seems a little odd to keep the XTAL clock definition in the DTS, as the alias may not be consistent across different boards, which could result in compilation errors. Could we move the XTAL clock definition to the DTSI as well, similar to other Amlogic SoCs?
It seems similar to changes in this series :
https://lore.kernel.org/all/20260420-add-bluetooth-t7-vim4-
[email protected]/
Quoted 7 lines
Quoted 2 lines
What do you think ?
Thanks for pointing out that series, though I wasn't aware of it. And after reading I don't agree with it. The clocks are not redundant, they are there because we agreed sometime ago that xtal belongs to the board files.
So I still vote for my change in v2, that I will send in a few minutes.
I don't get why it would be better to define the exact same clocks in each DTS file.
The xtal recommended characteristics provided at the SOC level can be defined in the DTSI and overridden, if really necessary, in the DTS.
Signature · 2 lines
Best regards, Ronald
Re: [PATCH 1/2] arm64: dts: amlogic: t7: use the real UART pclk
Quoted 95 lines · Ronald Claveau
Quoted 86 lines · Lucas Tanure
Quoted 85 lines · Ronald Claveau
Quoted 70 lines · Xianwei Zhao
Hi Lucas,
Quoted 67 lines · Lucas Tanure
uart_alists the 24MHz crystal for all three of its clocks, because the T7 clock controller driver did not exist when these boards were added.That leaves the real UART bus clock without a user, so the kernel turns it off when it disables unused clocks at the end of boot, and the board hangs.
Point
uart_aat the real clocks, the waymeson-s4.dtsidoes, and drop the placeholders from the two board files.Fixes 4fef056588f5 ("arm64: dts: amlogic-t7-a311d2-khadas-vim4: addinitial device-tree")
Fixes 6f048cc7a635 ("arm64: dts: add board AN400")Signed-off-by Lucas Tanure<[email protected]>Assisted-by Claude:claude-fable-5--- arch/arm64/boot/dts/amlogic/amlogic-t7-a311d2-an400.dts | 2 -- arch/arm64/boot/dts/amlogic/amlogic-t7-a311d2-khadas-vim4.dts | 2 -- arch/arm64/boot/dts/amlogic/amlogic-t7.dtsi | 4 ++++ 3 files changed, 4 insertions(+), 4 deletions(-)arch/arm64/boot/dts/amlogic/amlogic-t7-a311d2-an400.dts +0
-2@@ -33,7 +33,5 @@ xtal: xtal-clk { }; &uart_a { - clocks = <&xtal>, <&xtal>, <&xtal>; - clock-names = "xtal", "pclk", "baud"; status = "okay";};
diff --gita/arch/arm64/boot/dts/amlogic/amlogic-t7-a311d2-khadas-vim4.dtsb/arch/arm64/boot/dts/amlogic/amlogic-t7-a311d2-khadas-vim4.dtsindexc41525a34b72..677069e58f30100644arch/arm64/boot/dts/amlogic/amlogic-t7-a311d2-khadas-vim4.dts +0
-2@@ -266,6 +266,4 @@ &sd_emmc_c { &uart_a { status = "okay"; - clocks = <&xtal>, <&xtal>, <&xtal>; - clock-names = "xtal", "pclk", "baud";};
arch/arm64/boot/dts/amlogic/amlogic-t7.dtsi +4
-0@@ -587,6 +587,10 @@ uart_a: serial@78000 { compatible = "amlogic,t7-uart", "amlogic,meson-s4-uart"; reg = <0x0 0x78000 0x0 0x18>; interrupts = <GIC_SPI 168 IRQ_TYPE_EDGE_RISING>; + clocks = <&xtal>, + <&clkc_periphs CLKID_SYS_UART_A>, + <&xtal>; + clock-names = "xtal", "pclk", "baud";Quoted 8 lines
Quoted 2 lines
status = "disabled"; };
I agree with moving the UART clock configuration to the DTSI file. However, it seems a little odd to keep the XTAL clock definition in the DTS, as the alias may not be consistent across different boards, which could result in compilation errors. Could we move the XTAL clock definition to the DTSI as well, similar to other Amlogic SoCs?
It seems similar to changes in this series :
https://lore.kernel.org/all/20260420-add-bluetooth-t7-vim4-
[email protected]/Quoted 7 lines
Quoted 2 lines
What do you think ?
Thanks for pointing out that series, though I wasn't aware of it. And after reading I don't agree with it. The clocks are not redundant, they are there because we agreed sometime ago that xtal belongs to the board files.
So I still vote for my change in v2, that I will send in a few minutes.
Quoted 6 lines
I don't get why it would be better to define the exact same clocks in each DTS file.
The xtal recommended characteristics provided at the SOC level can be defined in the DTSI and overridden, if really necessary, in the DTS.
Hi Ronald,
The preference for keeping xtal in board-specific .dts files rather than the SoC .dtsi comes down to DT hardware modeling principles and upstream maintainer guidelines:
Hardware Topology: The xtal is physically located on the board PCB, not inside the SoC silicon. The .dtsi file models the SoC silicon internal architecture (clock controllers, IPs, registers), whereas .dts files describe the physical board layout surrounding it.
Avoiding Implicit Assumptions: Defining a default 24MHz xtal in .dtsi assumes every T7 board will use the same oscillator configuration. If a custom board design uses a different crystal frequency or an external clock generator/TCXO, overriding a .dtsi-level node can lead to messy DT overrides or silent clock rate mismatches if forgotten.
Upstream DT Maintainer Policy: Kernel DT maintainers consistently push to keep board-level hardware explicitly declared in the board .dts files to reflect actual physical board components.
That said, I acknowledge the trade-off is minor boilerplate duplication across board DTS files. If the Amlogic SoC maintainers prefer setting a default 24MHz xtal in amlogic-t7.dtsi to match older SoC generations, I am open to updating it—provided the maintainers explicitly prefer that tradeoff over strict DT topology modeling.
Best regards,
Lucas
Re: [PATCH 1/2] arm64: dts: amlogic: t7: use the real UART pclk
Quoted 126 lines · Lucas Tanure
Quoted 98 lines · Ronald Claveau
Quoted 89 lines · Lucas Tanure
Quoted 88 lines · Ronald Claveau
Quoted 73 lines · Xianwei Zhao
Hi Lucas,
Quoted 70 lines · Lucas Tanure
uart_alists the 24MHz crystal for all three of its clocks, because the T7 clock controller driver did not exist when these boards were added.That leaves the real UART bus clock without a user, so the kernel turns it off when it disables unused clocks at the end of boot, and the board hangs.
Point
uart_aat the real clocks, the waymeson-s4.dtsidoes, and drop the placeholders from the two board files.Fixes 4fef056588f5 ("arm64: dts: amlogic-t7-a311d2-khadas-vim4: addinitial device-tree")
Fixes 6f048cc7a635 ("arm64: dts: add board AN400")Signed-off-by Lucas Tanure<[email protected]>Assisted-by Claude:claude-fable-5---
arch/arm64/boot/dts/amlogic/amlogic-t7-a311d2-an400.dts| 2 --arch/arm64/boot/dts/amlogic/amlogic-t7-a311d2-khadas-vim4.dts| 2 --
arch/arm64/boot/dts/amlogic/amlogic-t7.dtsi | 4
++++3 files changed, 4 insertions(+), 4 deletions(-)arch/arm64/boot/dts/amlogic/amlogic-t7-a311d2-an400.dts +0
-2@@ -33,7 +33,5 @@ xtal: xtal-clk { }; &uart_a { - clocks = <&xtal>, <&xtal>, <&xtal>; - clock-names = "xtal", "pclk", "baud"; status = "okay";};
diff --gita/arch/arm64/boot/dts/amlogic/amlogic-t7-a311d2-khadas-vim4.dtsb/arch/arm64/boot/dts/amlogic/amlogic-t7-a311d2-khadas-vim4.dtsindexc41525a34b72..677069e58f30100644arch/arm64/boot/dts/amlogic/amlogic-t7-a311d2-khadas-vim4.dts +0
-2@@ -266,6 +266,4 @@ &sd_emmc_c { &uart_a { status = "okay"; - clocks = <&xtal>, <&xtal>, <&xtal>; - clock-names = "xtal", "pclk", "baud";};
arch/arm64/boot/dts/amlogic/amlogic-t7.dtsi +0
-0@@ -587,6 +587,10 @@ uart_a: serial@78000 { compatible = "amlogic,t7-uart", "amlogic,meson-s4-uart"; reg = <0x0 0x78000 0x0 0x18>;interrupts = <
GIC_SPI168IRQ_TYPE_EDGE_RISING>;
+ clocks = <&xtal>,
+ <&clkc_periphsCLKID_SYS_UART_A>,
+ <&xtal>;
+ clock-names = "xtal", "pclk", "baud"; status = "disabled";Quoted 8 lines
Quoted 1 line
};
I agree with moving the UART clock configuration to the DTSI file. However, it seems a little odd to keep the XTAL clock definition in the
DTS, as the alias may not be consistent across different boards, which could result in compilation errors. Could we move the XTAL clock definition to the DTSI as well, similar to other Amlogic SoCs?It seems similar to changes in this series :
https://lore.kernel.org/all/20260420-add-bluetooth-t7-vim4-
[email protected]/Quoted 7 lines
Quoted 2 lines
What do you think ?
Thanks for pointing out that series, though I wasn't aware of it. And after reading I don't agree with it. The clocks are not redundant, they are there because we agreed sometime ago that xtal belongs to the board files.
So I still vote for my change in v2, that I will send in a few minutes.Quoted 6 lines
I don't get why it would be better to define the exact same clocks in each DTS file.
The xtal recommended characteristics provided at the SOC level can be defined in the DTSI and overridden, if really necessary, in the DTS.
Hi Ronald,
The preference for keeping xtal in board-specific .dts files rather than the SoC .dtsi comes down to DT hardware modeling principles and upstream maintainer guidelines:
Hardware Topology: The xtal is physically located on the board PCB, not inside the SoC silicon. The .dtsi file models the SoC silicon internal architecture (clock controllers, IPs, registers), whereas .dts files describe the physical board layout surrounding it.
Avoiding Implicit Assumptions: Defining a default 24MHz xtal in .dtsi assumes every T7 board will use the same oscillator configuration. If a custom board design uses a different crystal frequency or an external clock generator/TCXO, overriding a .dtsi-level node can lead to messy DT overrides or silent clock rate mismatches if forgotten.
Upstream DT Maintainer Policy: Kernel DT maintainers consistently push to keep board-level hardware explicitly declared in the board .dts files to reflect actual physical board components.
Quoted 6 lines
That said, I acknowledge the trade-off is minor boilerplate duplication across board DTS files. If the Amlogic SoC maintainers prefer setting a default 24MHz xtal in
amlogic-t7.dtsito match older SoC generations, I am open to updating it—provided the maintainers explicitly prefer that tradeoff over strict DT topology modeling.
Hi Lucas,
Thank you for this detailed explanation.
I was referring to the last paragraph of the DTS coding style:
Hardware components that are present on the board shall be placed in the board DTS, not in the SoC or SoM DTSI. A partial exception is a common external reference SoC input clock, which could be coded as a fixed-clock in the SoC DTSI with its frequency provided by each board DTS.
I understand going to strict topology is better, that means we must apply the same rules to new Amlogic SOCs, right ?
Do we need to move other clocks and assigned-clocks properties which use the xtal to the board DTS as well (such as clkc_periphs or sd_emmc)?
Signature · 2 lines
Best regards, Ronald
Neil Armstrong
maintainerRe: [PATCH 1/2] arm64: dts: amlogic: t7: use the real UART pclk
Quoted 136 lines · Ronald Claveau
Quoted 126 lines · Lucas Tanure
Quoted 98 lines · Ronald Claveau
Quoted 89 lines · Lucas Tanure
Quoted 88 lines · Ronald Claveau
Quoted 73 lines · Xianwei Zhao
Hi Lucas,
Quoted 70 lines · Lucas Tanure
uart_alists the 24MHz crystal for all three of its clocks, because the T7 clock controller driver did not exist when these boards were added.That leaves the real UART bus clock without a user, so the kernel turns it off when it disables unused clocks at the end of boot, and the board hangs.
Point
uart_aat the real clocks, the waymeson-s4.dtsidoes, and drop the placeholders from the two board files.Fixes 4fef056588f5 ("arm64: dts: amlogic-t7-a311d2-khadas-vim4: addinitial device-tree")
Fixes 6f048cc7a635 ("arm64: dts: add board AN400")Signed-off-by Lucas Tanure<[email protected]>Assisted-by Claude:claude-fable-5---
arch/arm64/boot/dts/amlogic/amlogic-t7-a311d2-an400.dts
| 2 --
arch/arm64/boot/dts/amlogic/amlogic-t7-a311d2-khadas-vim4.dts
| 2 --arch/arm64/boot/dts/amlogic/amlogic-t7.dtsi | 4 ++++ 3 files changed, 4 insertions(+), 4 deletions(-)arch/arm64/boot/dts/amlogic/amlogic-t7-a311d2-an400.dts +0
-2@@ -33,7 +33,5 @@ xtal: xtal-clk { }; &uart_a { - clocks = <&xtal>, <&xtal>, <&xtal>; - clock-names = "xtal", "pclk", "baud"; status = "okay";};
diff --gita/arch/arm64/boot/dts/amlogic/amlogic-t7-a311d2-khadas-vim4.dtsb/arch/arm64/boot/dts/amlogic/amlogic-t7-a311d2-khadas-vim4.dtsindexc41525a34b72..677069e58f30100644arch/arm64/boot/dts/amlogic/amlogic-t7-a311d2-khadas-vim4.dts +0
-2@@ -266,6 +266,4 @@ &sd_emmc_c { &uart_a { status = "okay"; - clocks = <&xtal>, <&xtal>, <&xtal>; - clock-names = "xtal", "pclk", "baud";};
arch/arm64/boot/dts/amlogic/amlogic-t7.dtsi +4
-0@@ -587,6 +587,10 @@ uart_a: serial@78000 { compatible = "amlogic,t7-uart", "amlogic,meson-s4-uart"; reg = <0x0 0x78000 0x0 0x18>; interrupts = <GIC_SPI 168 IRQ_TYPE_EDGE_RISING>; + clocks = <&xtal>, + <&clkc_periphs CLKID_SYS_UART_A>, + <&xtal>; + clock-names = "xtal", "pclk", "baud";status = "disabled";
Quoted 8 lines
Quoted 1 line
};
I agree with moving the UART clock configuration to the DTSI file. However, it seems a little odd to keep the XTAL clock definition in the
DTS, as the alias may not be consistent across different boards, which could result in compilation errors. Could we move the XTAL clock definition to the DTSI as well, similar to other Amlogic SoCs?It seems similar to changes in this series :
https://lore.kernel.org/all/20260420-add-bluetooth-t7-vim4-
[email protected]/Quoted 7 lines
Quoted 2 lines
What do you think ?
Thanks for pointing out that series, though I wasn't aware of it. And after reading I don't agree with it. The clocks are not redundant, they are there because we agreed sometime ago that xtal belongs to the board files.
So I still vote for my change in v2, that I will send in a few minutes.Quoted 6 lines
I don't get why it would be better to define the exact same clocks in each DTS file.
The xtal recommended characteristics provided at the SOC level can be defined in the DTSI and overridden, if really necessary, in the DTS.
Hi Ronald,
The preference for keeping xtal in board-specific .dts files rather than the SoC .dtsi comes down to DT hardware modeling principles and upstream maintainer guidelines:
Hardware Topology: The xtal is physically located on the board PCB, not inside the SoC silicon. The .dtsi file models the SoC silicon internal architecture (clock controllers, IPs, registers), whereas .dts files describe the physical board layout surrounding it.
Avoiding Implicit Assumptions: Defining a default 24MHz xtal in .dtsi assumes every T7 board will use the same oscillator configuration. If a custom board design uses a different crystal frequency or an external clock generator/TCXO, overriding a .dtsi-level node can lead to messy DT overrides or silent clock rate mismatches if forgotten.
Upstream DT Maintainer Policy: Kernel DT maintainers consistently push to keep board-level hardware explicitly declared in the board .dts files to reflect actual physical board components.
Quoted 6 lines
That said, I acknowledge the trade-off is minor boilerplate duplication across board DTS files. If the Amlogic SoC maintainers prefer setting a default 24MHz xtal in
amlogic-t7.dtsito match older SoC generations, I am open to updating it—provided the maintainers explicitly prefer that tradeoff over strict DT topology modeling.Hi Lucas,
Quoted 7 lines
Thank you for this detailed explanation.
I was referring to the last paragraph of the DTS coding style:Hardware components that are present on the board shall be placed in the board DTS, not in the SoC or SoM DTSI. A partial exception is a common external reference SoC input clock, which could be coded as a fixed-clock in the SoC DTSI with its frequency provided by each board DTS.
This is what was done for qualcomm SoCs, we could do it for Amlogic aswell.
Quoted 7 lines
I understand going to strict topology is better, that means we must apply the same rules to new Amlogic SOCs, right ?
Do we need to move other clocks and assigned-clocks properties which use the xtal to the board DTS as well (such as
clkc_periphsorsd_emmc)?
No since it describes a SoC configuration using XTAL, it should be in the dtsi.
Neil