Skip to contentSkip to conversation

Correct "div4" clocks in Exynos7885

PATCH Applied David Virag 2 participants 7 messages May 26, 2022 – Jul 10, 2022

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

cover Correct "div4" clocks in Exynos7885

The div4 clocks in Exynos7885 were mistakenly set to have the wrong parents making them and their children display 2x the actual clockrate. This in turn lead to the DTSI getting the wrong clocks for UART, since that's the configuration it worked properly with. This was noticed by Sam Protsenko [1] but since it worked this way and not the other way around, I didn't think much of it.

[1] https://lore.kernel.org/linux-samsung-soc/CAPLW+4k3Vmg0W0jVsTChHTG8+eeg=5QF+actz1Tk0vNV9w-y-A@mail.gmail.com/

David Virag (2):
clk: samsung: exynos7885: Correct "div4" clock parents
arm64: dts: exynos: Correct UART clocks on Exynos7885

 arch/arm64/boot/dts/exynos/exynos7885.dtsi | 12 ++++++------
 drivers/clk/samsung/clk-exynos7885.c       |  4 ++--
 2 files changed, 8 insertions(+), 8 deletions(-)
Signature · 1 line
2.35.1
#1 lore raw

PATCH 1/2 clk: samsung: exynos7885: Correct "div4" clock parents

"div4" DIVs which divide PLLs by 4 are actually dividing "div2" DIVs by 2 to achieve a by 4 division, thus their parents are the respective "div2" DIVs. These DIVs were mistakenly set to have the PLLs as parents. This leads to the kernel thinking "div4"s and everything under them run at 2x the clock speed. Fix this.

Fixes 45bd8166a1d8 ("clk: samsung: Add initial Exynos7885 clock driver")
---
 drivers/clk/samsung/clk-exynos7885.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/clk/samsung/clk-exynos7885.c +2 -2
index a7b106302706..368c50badd15 100644
@@ -182,7 +182,7 @@ static const struct samsung_div_clock top_div_clks[] __initconst = {
 	    CLK_CON_DIV_PLL_SHARED0_DIV2, 0, 1),
 	DIV(CLK_DOUT_SHARED0_DIV3, "dout_shared0_div3", "fout_shared0_pll",
 	    CLK_CON_DIV_PLL_SHARED0_DIV3, 0, 2),
-	DIV(CLK_DOUT_SHARED0_DIV4, "dout_shared0_div4", "fout_shared0_pll",
+	DIV(CLK_DOUT_SHARED0_DIV4, "dout_shared0_div4", "dout_shared0_div2",
 	    CLK_CON_DIV_PLL_SHARED0_DIV4, 0, 1),
 	DIV(CLK_DOUT_SHARED0_DIV5, "dout_shared0_div5", "fout_shared0_pll",
 	    CLK_CON_DIV_PLL_SHARED0_DIV5, 0, 3),
@@ -190,7 +190,7 @@ static const struct samsung_div_clock top_div_clks[] __initconst = {
 	    CLK_CON_DIV_PLL_SHARED1_DIV2, 0, 1),
 	DIV(CLK_DOUT_SHARED1_DIV3, "dout_shared1_div3", "fout_shared1_pll",
 	    CLK_CON_DIV_PLL_SHARED1_DIV3, 0, 2),
-	DIV(CLK_DOUT_SHARED1_DIV4, "dout_shared1_div4", "fout_shared1_pll",
+	DIV(CLK_DOUT_SHARED1_DIV4, "dout_shared1_div4", "dout_shared1_div2",
 	    CLK_CON_DIV_PLL_SHARED1_DIV4, 0, 1),
 
 	/* CORE */
Signature · 1 line
2.35.1
Acked-by on v1 1/2
#2 lore raw

Re: [PATCH 1/2] clk: samsung: exynos7885: Correct "div4" clock parents

Quoted 11 lines · David Virag

"div4" DIVs which divide PLLs by 4 are actually dividing "div2" DIVs by 2 to achieve a by 4 division, thus their parents are the respective "div2" DIVs. These DIVs were mistakenly set to have the PLLs as parents. This leads to the kernel thinking "div4"s and everything under them run at 2x the clock speed. Fix this.

Fixes 45bd8166a1d8 ("clk: samsung: Add initial Exynos7885 clock driver")
---
 drivers/clk/samsung/clk-exynos7885.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Best regards,
Krzysztof

#3 lore raw

Re: [PATCH 1/2] clk: samsung: exynos7885: Correct "div4" clock parents

Quoted 7 lines · Krzysztof Kozlowski
Quoted 6 lines · David Virag

"div4" DIVs which divide PLLs by 4 are actually dividing "div2" DIVs by 2 to achieve a by 4 division, thus their parents are the respective "div2" DIVs. These DIVs were mistakenly set to have the PLLs as parents. This leads to the kernel thinking "div4"s and everything under them run at 2x the clock speed. Fix this.

Quoted 5 lines
Quoted 5 lines
Fixes 45bd8166a1d8 ("clk: samsung: Add initial Exynos7885 clock driver")
---
 drivers/clk/samsung/clk-exynos7885.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Sylwester,

This goes to v5.20?

Best regards,
Krzysztof

#4 lore raw

Re: [PATCH 1/2] clk: samsung: exynos7885: Correct "div4" clock parents

Quoted 19 lines · Krzysztof Kozlowski
Quoted 11 lines · Krzysztof Kozlowski
Quoted 10 lines · David Virag

"div4" DIVs which divide PLLs by 4 are actually dividing "div2" DIVs by
2 to achieve a by 4 division, thus their parents are the respective
"div2" DIVs. These DIVs were mistakenly set to have the PLLs as parents.
This leads to the kernel thinking "div4"s and everything under them run
at 2x the clock speed. Fix this.

Quoted 6 lines
Quoted 6 lines
Fixes 45bd8166a1d8 ("clk: samsung: Add initial Exynos7885 clock

driver")

---
 drivers/clk/samsung/clk-exynos7885.c | 4 ++--

 1 file changed, 2 insertions(+), 2 deletions(-)
Quoted 6 lines

Sylwester,

This goes to v5.20?

Best regards,
Krzysztof

Hi Krzysztof and Sylwester,

What is going on with this patch? What will happen to it? From what I've seen, Sylwester doesn't seem to be too active lately. I just don't want it to get lost. With only one of the patches applied, UART is partially broken on 7885. Don't want to make unnecessary noise, but this patch should probably be applied sooner than later.

Best regards,
David

#5 lore raw

PATCH 2/2 arm64: dts: exynos: Correct UART clocks on Exynos7885

In reply to David Virag

The clocks in the serial UART nodes were swapped by mistake on Exynos7885. This only worked correctly because of a mistake in the clock driver which has been fixed. With the fixed clock driver in place, the baudrate of the UARTs get miscalculated. Fix this by correcting the clocks in the dtsi.

Fixes 06874015327b ("arm64: dts: exynos: Add initial device tree support for Exynos7885 SoC")
---
 arch/arm64/boot/dts/exynos/exynos7885.dtsi | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
arch/arm64/boot/dts/exynos/exynos7885.dtsi +6 -6
index 3170661f5b67..9c233c56558c 100644
@@ -280,8 +280,8 @@ serial_0: serial@13800000 {
 			interrupts = <GIC_SPI 246 IRQ_TYPE_LEVEL_HIGH>;
 			pinctrl-names = "default";
 			pinctrl-0 = <&uart0_bus>;
-			clocks = <&cmu_peri CLK_GOUT_UART0_EXT_UCLK>,
-				 <&cmu_peri CLK_GOUT_UART0_PCLK>;
+			clocks = <&cmu_peri CLK_GOUT_UART0_PCLK>,
+				 <&cmu_peri CLK_GOUT_UART0_EXT_UCLK>;
 			clock-names = "uart", "clk_uart_baud0";
 			samsung,uart-fifosize = <64>;
 			status = "disabled";
@@ -293,8 +293,8 @@ serial_1: serial@13810000 {
 			interrupts = <GIC_SPI 247 IRQ_TYPE_LEVEL_HIGH>;
 			pinctrl-names = "default";
 			pinctrl-0 = <&uart1_bus>;
-			clocks = <&cmu_peri CLK_GOUT_UART1_EXT_UCLK>,
-				 <&cmu_peri CLK_GOUT_UART1_PCLK>;
+			clocks = <&cmu_peri CLK_GOUT_UART1_PCLK>,
+				 <&cmu_peri CLK_GOUT_UART1_EXT_UCLK>;
 			clock-names = "uart", "clk_uart_baud0";
 			samsung,uart-fifosize = <256>;
 			status = "disabled";
@@ -306,8 +306,8 @@ serial_2: serial@13820000 {
 			interrupts = <GIC_SPI 279 IRQ_TYPE_LEVEL_HIGH>;
 			pinctrl-names = "default";
 			pinctrl-0 = <&uart2_bus>;
-			clocks = <&cmu_peri CLK_GOUT_UART2_EXT_UCLK>,
-				 <&cmu_peri CLK_GOUT_UART2_PCLK>;
+			clocks = <&cmu_peri CLK_GOUT_UART2_PCLK>,
+				 <&cmu_peri CLK_GOUT_UART2_EXT_UCLK>;
 			clock-names = "uart", "clk_uart_baud0";
 			samsung,uart-fifosize = <256>;
 			status = "disabled";
Signature · 1 line
2.35.1
#6 lore raw

Re: (subset) [PATCH 2/2] arm64: dts: exynos: Correct UART clocks on Exynos7885

Quoted 8 lines · David Virag

The clocks in the serial UART nodes were swapped by mistake on Exynos7885. This only worked correctly because of a mistake in the clock driver which has been fixed. With the fixed clock driver in place, the baudrate of the UARTs get miscalculated. Fix this by correcting the clocks in the dtsi.

[...]

Applied, thanks!

[2/2] arm64: dts: exynos: Correct UART clocks on Exynos7885

      https://git.kernel.org/krzk/linux/c/f84d83d8165570380f55f4ce578bfb131a9266c5

Best regards,

Signature · 1 line
Krzysztof Kozlowski <[email protected]>