arm64: allwinner: a64: fix video output on Pinebook
Subsystems (3)
v2 cover arm64: allwinner: a64: fix video output on Pinebook
Since commit ca1170b69968 ("clk: sunxi-ng: a64: force select PLL_MIPI in TCON0 mux"), TCON0 clock parent is always set to PLL_MIPI, but unfortunately it breaks video output on Pinebook.
I did an experiment: I manually configured PLL_MIPI and PLL_VIDEO0_2X to the same clock rate and flipped the switch with devmem. Experiment clearly showed that whenever PLL_MIPI is selected as TCON0 clock parent, the video output stops working.
To fix the issue, I partially reverted mentioned commit and added explicit TCON0 clock parent assignment to device tree. By default, it will be PLL_MIPI, and the only users with RGB output - Pinebook and Teres-I will override it in their dts.
v2:
- split device tree binding change into its own patch
- add rationale into commit message and into comment in the code
- gather the tags
Vasily Khoruzhick (4):
dt-bindings: clock: sunxi: Export PLL_VIDEO_2X and PLL_MIPI
clk: sunxi-ng: a64: drop redundant CLK_PLL_VIDEO0_2X and CLK_PLL_MIPI
arm64: dts: allwinner: a64: explicitly assign clock parent for TCON0
clk: sunxi-ng: a64: stop force-selecting PLL-MIPI as TCON0 parent
.../boot/dts/allwinner/sun50i-a64-pinebook.dts | 2 ++ .../arm64/boot/dts/allwinner/sun50i-a64-teres-i.dts | 2 ++ arch/arm64/boot/dts/allwinner/sun50i-a64.dtsi | 2 ++ drivers/clk/sunxi-ng/ccu-sun50i-a64.c | 13 ++++--------- drivers/clk/sunxi-ng/ccu-sun50i-a64.h | 2 -- include/dt-bindings/clock/sun50i-a64-ccu.h | 2 ++ 6 files changed, 12 insertions(+), 11 deletions(-)
Signature · 1 line
2.47.1
PATCH v2 1/4 dt-bindings: clock: sunxi: Export PLL_VIDEO_2X and PLL_MIPI
Export PLL_VIDEO_2X and PLL_MIPI, these will be used to explicitly select TCON0 clock parent in dts
--- include/dt-bindings/clock/sun50i-a64-ccu.h | 2 ++ 1 file changed, 2 insertions(+)
include/dt-bindings/clock/sun50i-a64-ccu.h +2 -0
@@ -44,7 +44,9 @@#define _DT_BINDINGS_CLK_SUN50I_A64_H_#define CLK_PLL_VIDEO0 7 +#define CLK_PLL_VIDEO0_2X 8#define CLK_PLL_PERIPH0 11 +#define CLK_PLL_MIPI 17#define CLK_CPUX 21#define CLK_BUS_MIPI_DSI 28
Signature · 1 line
2.47.1
Re: [PATCH v2 1/4] dt-bindings: clock: sunxi: Export PLL_VIDEO_2X and PLL_MIPI
Quoted 6 lines · Vasily Khoruzhick
Export
PLL_VIDEO_2XandPLL_MIPI, these will be used to explicitly select TCON0 clock parent in dtsFixes ca1170b69968 ("clk: sunxi-ng: a64: force select PLL_MIPI in TCON0 mux")Reviewed-by Dragan Simic <[email protected]>Reviewed-by Chen-Yu Tsai <[email protected]>
Where did this happen?
Quoted 2 lines
And these? I cannot find traces on the list.
Best regards,
Krzysztof
Krzysztof Kozlowski
Acked-byRe: [PATCH v2 1/4] dt-bindings: clock: sunxi: Export PLL_VIDEO_2X and PLL_MIPI
Quoted 8 lines · Krzysztof Kozlowski
Quoted 6 lines · Vasily Khoruzhick
Export
PLL_VIDEO_2XandPLL_MIPI, these will be used to explicitly select TCON0 clock parent in dtsFixes ca1170b69968 ("clk: sunxi-ng: a64: force select PLL_MIPI in TCON0 mux")Reviewed-by Dragan Simic <[email protected]>Reviewed-by Chen-Yu Tsai <[email protected]>
Quoted 6 lines
Where did this happen?
Quoted 2 lines
And these? I cannot find traces on the list.
I found them, cover letter.
Best regards,
Krzysztof
Re: [PATCH v2 1/4] dt-bindings: clock: sunxi: Export PLL_VIDEO_2X and PLL_MIPI
Quoted 10 lines · Krzysztof Kozlowski
Quoted 8 lines · Krzysztof Kozlowski
Quoted 6 lines · Vasily Khoruzhick
Export
PLL_VIDEO_2XandPLL_MIPI, these will be used to explicitly select TCON0 clock parent in dtsFixes ca1170b69968 ("clk: sunxi-ng: a64: force select PLL_MIPI in TCON0 mux")Reviewed-by Dragan Simic <[email protected]>Reviewed-by Chen-Yu Tsai <[email protected]>
Quoted 8 lines
Quoted 6 lines
Where did this happen?
Quoted 2 lines
And these? I cannot find traces on the list.
I found them, cover letter.
Yeah, most of the tags are replies to v1 cover letter. Stuart's Tested-by comes from IRC. However all the mentioned people are on CC list, it's not like I'm trying to sneak in counterfeit tags :)
Quoted 4 lines
Best regards,
Krzysztof
Re: [PATCH v2 1/4] dt-bindings: clock: sunxi: Export PLL_VIDEO_2X and PLL_MIPI
In reply to Vasily KhoruzhickQuoted 19 lines · Vasily Khoruzhick
Export
PLL_VIDEO_2XandPLL_MIPI, these will be used to explicitly select TCON0 clock parent in dtsFixes ca1170b69968 ("clk: sunxi-ng: a64: force select PLL_MIPI in TCON0 mux")Reviewed-by Dragan Simic <[email protected]>Reviewed-by Chen-Yu Tsai <[email protected]>Signed-off-by Vasily Khoruzhick <[email protected]>--- include/dt-bindings/clock/sun50i-a64-ccu.h | 2 ++ 1 file changed, 2 insertions(+)include/dt-bindings/clock/sun50i-a64-ccu.h +0
-0
include/dt-bindings/clock/sun50i-a64-ccu.h line 49
Quoted 6 lines
include/dt-bindings/clock/sun50i-a64-ccu.h +2
-0@@ -44,7 +44,9 @@#define _DT_BINDINGS_CLK_SUN50I_A64_H_#define CLK_PLL_VIDEO0 7 +#define CLK_PLL_VIDEO0_2X 8#define CLK_PLL_PERIPH0 11 +#define CLK_PLL_MIPI 17
You can't really split code movement into two patches.
With this patch applied the clk driver will fail to build because the macros are now redefined in both header files.
Barring recombining the patches, please add a patch before this adding #ifndef's around the two macros that are moved.
ChenYu
Quoted 5 lines
include/dt-bindings/clock/sun50i-a64-ccu.h +0
-1#define CLK_CPUX 21#define CLK_BUS_MIPI_DSI 28 --2.47.1
Re: [PATCH v2 1/4] dt-bindings: clock: sunxi: Export PLL_VIDEO_2X and PLL_MIPI
Quoted 29 lines · Chen-Yu Tsai
Quoted 19 lines · Vasily Khoruzhick
Export
PLL_VIDEO_2XandPLL_MIPI, these will be used to explicitly select TCON0 clock parent in dtsFixes ca1170b69968 ("clk: sunxi-ng: a64: force select PLL_MIPI in TCON0 mux")Reviewed-by Dragan Simic <[email protected]>Reviewed-by Chen-Yu Tsai <[email protected]>Signed-off-by Vasily Khoruzhick <[email protected]>--- include/dt-bindings/clock/sun50i-a64-ccu.h | 2 ++ 1 file changed, 2 insertions(+)include/dt-bindings/clock/sun50i-a64-ccu.h +0
-0include/dt-bindings/clock/sun50i-a64-ccu.h line 49
Quoted 6 lines
include/dt-bindings/clock/sun50i-a64-ccu.h +2
-0@@ -44,7 +44,9 @@#define _DT_BINDINGS_CLK_SUN50I_A64_H_#define CLK_PLL_VIDEO0 7 +#define CLK_PLL_VIDEO0_2X 8#define CLK_PLL_PERIPH0 11 +#define CLK_PLL_MIPI 17You can't really split code movement into two patches.
Quoted 2 lines
With this patch applied the clk driver will fail to build because the macros are now redefined in both header files.
Are you sure? The values seem the same to me... I don't see how this could fail.
Quoted 4 lines
Barring recombining the patches, please add a patch before this adding #ifndef's around the two macros that are moved.
No, not necessary, just churn,
Best regards,
Krzysztof
Re: [PATCH v2 1/4] dt-bindings: clock: sunxi: Export PLL_VIDEO_2X and PLL_MIPI
Quoted 30 lines · On Sat, 4 Jan 2025 11:33:23 +0100 Krzysztof Kozlowski <[email protected]> wrote:
Quoted 29 lines · Chen-Yu Tsai
Quoted 19 lines · Vasily Khoruzhick
Export
PLL_VIDEO_2XandPLL_MIPI, these will be used to explicitly select TCON0 clock parent in dtsFixes ca1170b69968 ("clk: sunxi-ng: a64: force select PLL_MIPI in TCON0 mux")Reviewed-by Dragan Simic <[email protected]>Reviewed-by Chen-Yu Tsai <[email protected]>Signed-off-by Vasily Khoruzhick <[email protected]>--- include/dt-bindings/clock/sun50i-a64-ccu.h | 2 ++ 1 file changed, 2 insertions(+)include/dt-bindings/clock/sun50i-a64-ccu.h +0
-0include/dt-bindings/clock/sun50i-a64-ccu.h line 49
Quoted 6 lines
include/dt-bindings/clock/sun50i-a64-ccu.h +2
-0@@ -44,7 +44,9 @@#define _DT_BINDINGS_CLK_SUN50I_A64_H_#define CLK_PLL_VIDEO0 7 +#define CLK_PLL_VIDEO0_2X 8#define CLK_PLL_PERIPH0 11 +#define CLK_PLL_MIPI 17You can't really split code movement into two patches.
Quoted 5 lines
Quoted 2 lines
With this patch applied the clk driver will fail to build because the macros are now redefined in both header files.
Are you sure? The values seem the same to me... I don't see how this could fail.
Yes, IIRC the C standard allows repeated definitions with the same value. And I definitely tested this before (and hence recommended this approach to Vasily) and it compiled without any warnings here.
Cheers,
Andre
Quoted 12 lines
Quoted 5 lines
Barring recombining the patches, please add a patch before this adding #ifndef's around the two macros that are moved.
No, not necessary, just churn,
Best regards,
Krzysztof
Re: [PATCH v2 1/4] dt-bindings: clock: sunxi: Export PLL_VIDEO_2X and PLL_MIPI
Quoted 37 lines · Andre Przywara
Quoted 33 lines · On Sat, 4 Jan 2025 11:33:23 +0100 Krzysztof Kozlowski <[email protected]> wrote:
Quoted 31 lines · Chen-Yu Tsai
Quoted 19 lines · Vasily Khoruzhick
Export
PLL_VIDEO_2XandPLL_MIPI, these will be used to explicitly select TCON0 clock parent in dtsFixes ca1170b69968 ("clk: sunxi-ng: a64: force select PLL_MIPI in TCON0 mux")Reviewed-by Dragan Simic <[email protected]>Reviewed-by Chen-Yu Tsai <[email protected]>Signed-off-by Vasily Khoruzhick <[email protected]>--- include/dt-bindings/clock/sun50i-a64-ccu.h | 2 ++ 1 file changed, 2 insertions(+)include/dt-bindings/clock/sun50i-a64-ccu.h +0
-0include/dt-bindings/clock/sun50i-a64-ccu.h line 49
Quoted 6 lines
include/dt-bindings/clock/sun50i-a64-ccu.h +2
-0@@ -44,7 +44,9 @@#define _DT_BINDINGS_CLK_SUN50I_A64_H_#define CLK_PLL_VIDEO0 7 +#define CLK_PLL_VIDEO0_2X 8#define CLK_PLL_PERIPH0 11 +#define CLK_PLL_MIPI 17You can't really split code movement into two patches.
With this patch applied the clk driver will fail to build because the macros are now redefined in both header files.
Quoted 6 lines
Quoted 2 lines
Are you sure? The values seem the same to me... I don't see how this could fail.
Yes, IIRC the C standard allows repeated definitions with the same value. And I definitely tested this before (and hence recommended this approach to Vasily) and it compiled without any warnings here.
Hmm. Didn't know that. Good to know, and I just tried it on my end.
Thanks
ChenYu
Quoted 16 lines
Cheers,
AndreQuoted 12 lines
Quoted 5 lines
Barring recombining the patches, please add a patch before this adding #ifndef's around the two macros that are moved.
No, not necessary, just churn,
Best regards,
Krzysztof
Re: [PATCH v2 1/4] dt-bindings: clock: sunxi: Export PLL_VIDEO_2X and PLL_MIPI
Quoted 5 lines · Chen-Yu Tsai
Quoted 3 lines
Yes, IIRC the C standard allows repeated definitions with the same value. And I definitely tested this before (and hence recommended this approach to Vasily) and it compiled without any warnings here.
Hmm. Didn't know that. Good to know, and I just tried it on my end.
Yeah, I don't like it either. It's an artefact of pretending that the device tree directory(ies) is a separate tree.
Quoted 2 lines
Thanks
ChenYu
Re: [PATCH v2 1/4] dt-bindings: clock: sunxi: Export PLL_VIDEO_2X and PLL_MIPI
In reply to Andre PrzywaraHello all,
Quoted 34 lines · Andre Przywara
Quoted 33 lines · On Sat, 4 Jan 2025 11:33:23 +0100 Krzysztof Kozlowski <[email protected]> wrote:
Quoted 31 lines · Chen-Yu Tsai
Quoted 19 lines · Vasily Khoruzhick
Export
PLL_VIDEO_2XandPLL_MIPI, these will be used to explicitly select TCON0 clock parent in dtsFixes ca1170b69968 ("clk: sunxi-ng: a64: force select PLL_MIPI in TCON0 mux")Reviewed-by Dragan Simic <[email protected]>Reviewed-by Chen-Yu Tsai <[email protected]>Signed-off-by Vasily Khoruzhick <[email protected]>--- include/dt-bindings/clock/sun50i-a64-ccu.h | 2 ++ 1 file changed, 2 insertions(+)include/dt-bindings/clock/sun50i-a64-ccu.h +0
-0include/dt-bindings/clock/sun50i-a64-ccu.h line 49
Quoted 6 lines
include/dt-bindings/clock/sun50i-a64-ccu.h +2
-0@@ -44,7 +44,9 @@#define _DT_BINDINGS_CLK_SUN50I_A64_H_#define CLK_PLL_VIDEO0 7 +#define CLK_PLL_VIDEO0_2X 8#define CLK_PLL_PERIPH0 11 +#define CLK_PLL_MIPI 17You can't really split code movement into two patches.
With this patch applied the clk driver will fail to build because the macros are now redefined in both header files.
Quoted 6 lines
Quoted 2 lines
Are you sure? The values seem the same to me... I don't see how this could fail.
Yes, IIRC the C standard allows repeated definitions with the same value. And I definitely tested this before (and hence recommended this approach to Vasily) and it compiled without any warnings here.
FWIW, I also tested that approach when it was recommended, to make sure that the C compiler(s) are fine with that. And it worked. :)
Quoted 4 lines
Quoted 4 lines
Quoted 2 lines
Barring recombining the patches, please add a patch before this adding #ifndef's around the two macros that are moved.
No, not necessary, just churn,
PATCH v2 2/4 clk: sunxi-ng: a64: drop redundant CLK_PLL_VIDEO0_2X and CLK_PLL_MIPI
In reply to Vasily KhoruzhickDrop redundant CLK_PLL_VIDEO0_2X and CLK_PLL.MIPI. These are now defined in dt-bindings/clock/sun50i-a64-ccu.h
--- drivers/clk/sunxi-ng/ccu-sun50i-a64.h | 2 -- 1 file changed, 2 deletions(-)
drivers/clk/sunxi-ng/ccu-sun50i-a64.h +0 -2
@@ -21,7 +21,6 @@/* PLL_VIDEO0 exported for HDMI PHY */ -#define CLK_PLL_VIDEO0_2X 8#define CLK_PLL_VE 9#define CLK_PLL_DDR0 10
@@ -32,7 +31,6 @@#define CLK_PLL_PERIPH1_2X 14#define CLK_PLL_VIDEO1 15#define CLK_PLL_GPU 16 -#define CLK_PLL_MIPI 17#define CLK_PLL_HSIC 18#define CLK_PLL_DE 19#define CLK_PLL_DDR1 20
Signature · 1 line
2.47.1
PATCH v2 3/4 arm64: dts: allwinner: a64: explicitly assign clock parent for TCON0
In reply to Vasily KhoruzhickTCON0 seems to need a different clock parent depending on output type. For RGB it has to be PLL-VIDEO0-2X, while for DSI it has to be PLL-MIPI, so select it explicitly.
Video output doesn't work if incorrect clock is assigned.
On my Pinebook I manually configured PLL-VIDEO0-2X and PLL-MIPI to the same rate, and while video output works fine with PLL-VIDEO0-2X, it doesn't work at all (as in no picture) with PLL-MIPI.
--- arch/arm64/boot/dts/allwinner/sun50i-a64-pinebook.dts | 2 ++ arch/arm64/boot/dts/allwinner/sun50i-a64-teres-i.dts | 2 ++ arch/arm64/boot/dts/allwinner/sun50i-a64.dtsi | 2 ++ 3 files changed, 6 insertions(+)
arch/arm64/boot/dts/allwinner/sun50i-a64-pinebook.dts +2 -0
@@ -390,6 +390,8 @@ &sound { &tcon0 { pinctrl-names = "default"; pinctrl-0 = <&lcd_rgb666_pins>; + assigned-clocks = <&ccu CLK_TCON0>; + assigned-clock-parents = <&ccu CLK_PLL_VIDEO0_2X>; status = "okay"; };
arch/arm64/boot/dts/allwinner/sun50i-a64-teres-i.dts +2 -0
@@ -369,6 +369,8 @@ &sound { &tcon0 { pinctrl-names = "default"; pinctrl-0 = <&lcd_rgb666_pins>; + assigned-clocks = <&ccu CLK_TCON0>; + assigned-clock-parents = <&ccu CLK_PLL_VIDEO0_2X>; status = "okay"; };
arch/arm64/boot/dts/allwinner/sun50i-a64.dtsi +2 -0
@@ -445,6 +445,8 @@ tcon0: lcd-controller@1c0c000 { clock-names = "ahb", "tcon-ch0"; clock-output-names = "tcon-data-clock"; #clock-cells = <0>; + assigned-clocks = <&ccu CLK_TCON0>; + assigned-clock-parents = <&ccu CLK_PLL_MIPI>; resets = <&ccu RST_BUS_TCON0>, <&ccu RST_BUS_LVDS>; reset-names = "lcd", "lvds";
Signature · 1 line
2.47.1
PATCH v2 4/4 clk: sunxi-ng: a64: stop force-selecting PLL-MIPI as TCON0 parent
In reply to Vasily KhoruzhickStop force-selecting PLL-MIPI as TCON0 parent, since it breaks video output on Pinebook that uses RGB to eDP bridge.
Partially revert commit ca1170b69968 ("clk: sunxi-ng: a64: force select PLL_MIPI in TCON0 mux"), while still leaving CLK_SET_RATE_NO_REPARENT flag set, since we do not want the clock to be reparented.
The issue is that apparently different TCON0 outputs require a different clock, or the mux might be selecting the output type.
I did an experiment: I manually configured PLL_MIPI and PLL_VIDEO0_2X to the same clock rate and flipped the switch with devmem. Experiment clearly showed that whenever PLL_MIPI is selected as TCON0 clock parent, the video output stops working.
Therefore, TCON0 clock parent corresponding to the output type must be assigned in the device tree.
--- drivers/clk/sunxi-ng/ccu-sun50i-a64.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-)
drivers/clk/sunxi-ng/ccu-sun50i-a64.c +4 -9
@@ -535,11 +535,11 @@ static SUNXI_CCU_M_WITH_MUX_GATE(de_clk, "de", de_parents, CLK_SET_RATE_PARENT);/* -* DSI output seems to work only when PLL_MIPI selected. Set it and prevent -* the mux from reparenting. +* Experiments showed that RGB output requires pll-video0-2x, while DSI +* requires pll-mipi. It will not work with incorrect clock, the screen will +* be blank. +* sun50i-a64.dtsi assigns pll-mipi as TCON0 parent by default */ -#define SUN50I_A64_TCON0_CLK_REG 0x118 -static const char *const tcon0_parents[] = {"pll-mipi" ,"pll-video0-2x" };static const u8 tcon0_table[] = {0 ,2 , }; static SUNXI_CCU_MUX_TABLE_WITH_GATE_CLOSEST(tcon0_clk, "tcon0", tcon0_parents,
@@ -959,11 +959,6 @@ static int sun50i_a64_ccu_probe(struct platform_device *pdev)writel (0x515 , reg +SUN50I_A64_PLL_MIPI_REG ); -/* Set PLL MIPI as parent for TCON0 */ - val =readl (reg +SUN50I_A64_TCON0_CLK_REG ); - val &= ~GENMASK (26 ,24 ); -writel (val | (0 <<24 ), reg +SUN50I_A64_TCON0_CLK_REG ); - ret =devm_sunxi_ccu_probe (&pdev->dev, reg, &sun50i_a64_ccu_desc);if (ret)return ret;
Signature · 1 line
2.47.1
Chen-Yu Tsai
AppliedQuoted 10 lines · Vasily Khoruzhick
Since commit
ca1170b69968("clk: sunxi-ng: a64: force selectPLL_MIPIin TCON0 mux"), TCON0 clock parent is always set toPLL_MIPI, but unfortunately it breaks video output on Pinebook.I did an experiment: I manually configured
PLL_MIPIandPLL_VIDEO0_2Xto the same clock rate and flipped the switch with devmem. Experiment clearly showed that wheneverPLL_MIPIis selected as TCON0 clock parent, the video output stops working.[...]
Applied to sunxi/for-next in sunxi/linux.git, thanks!
[1/4] dt-bindings: clock: sunxi: Export PLL_VIDEO_2X and PLL_MIPI
https://git.kernel.org/sunxi/linux/c/9897831de614 [2/4] clk: sunxi-ng: a64: drop redundant CLK_PLL_VIDEO0_2X and CLK_PLL_MIPI https://git.kernel.org/sunxi/linux/c/0f368cb7ef10 [3/4] arm64: dts: allwinner: a64: explicitly assign clock parent for TCON0 https://git.kernel.org/sunxi/linux/c/8715c91a8365 [4/4] clk: sunxi-ng: a64: stop force-selecting PLL-MIPI as TCON0 parent https://git.kernel.org/sunxi/linux/c/383ca7bee8a9
Best regards,
Signature · 1 line
Chen-Yu Tsai <[email protected]>