[PATCH v2 3/3] arm64: dts: sun50i-h6: Add support for RTC and fix the clock tree

56 views
Skip to first unread message

meg...@megous.com

unread,
Aug 20, 2019, 11:19:39 AM8/20/19
to Alessandro Zummo, Alexandre Belloni, Rob Herring, Mark Rutland, Maxime Ripard, Chen-Yu Tsai, Ondrej Jirman, linu...@vger.kernel.org, devic...@vger.kernel.org, linux-ar...@lists.infradead.org, linux-...@vger.kernel.org, linux...@googlegroups.com
From: Ondrej Jirman <meg...@megous.com>

This patch adds RTC node and fixes the clock properties and nodes
to reflect the real clock tree.

The device nodes for the internal oscillator and osc32k are removed,
as these clocks are now provided by the RTC device. Clock references
are fixed accordingly, too.

Signed-off-by: Ondrej Jirman <meg...@megous.com>
---
arch/arm64/boot/dts/allwinner/sun50i-h6.dtsi | 30 +++++++++++---------
1 file changed, 16 insertions(+), 14 deletions(-)

diff --git a/arch/arm64/boot/dts/allwinner/sun50i-h6.dtsi b/arch/arm64/boot/dts/allwinner/sun50i-h6.dtsi
index 67b732e34091..67f920e0fc33 100644
--- a/arch/arm64/boot/dts/allwinner/sun50i-h6.dtsi
+++ b/arch/arm64/boot/dts/allwinner/sun50i-h6.dtsi
@@ -56,14 +56,6 @@
status = "disabled";
};

- iosc: internal-osc-clk {
- #clock-cells = <0>;
- compatible = "fixed-clock";
- clock-frequency = <16000000>;
- clock-accuracy = <300000000>;
- clock-output-names = "iosc";
- };
-
osc24M: osc24M_clk {
#clock-cells = <0>;
compatible = "fixed-clock";
@@ -71,11 +63,11 @@
clock-output-names = "osc24M";
};

- osc32k: osc32k_clk {
+ ext_osc32k: ext_osc32k_clk {
#clock-cells = <0>;
compatible = "fixed-clock";
clock-frequency = <32768>;
- clock-output-names = "osc32k";
+ clock-output-names = "ext_osc32k";
};

psci {
@@ -197,7 +189,7 @@
ccu: clock@3001000 {
compatible = "allwinner,sun50i-h6-ccu";
reg = <0x03001000 0x1000>;
- clocks = <&osc24M>, <&osc32k>, <&iosc>;
+ clocks = <&osc24M>, <&rtc 0>, <&rtc 2>;
clock-names = "hosc", "losc", "iosc";
#clock-cells = <1>;
#reset-cells = <1>;
@@ -236,7 +228,7 @@
<GIC_SPI 53 IRQ_TYPE_LEVEL_HIGH>,
<GIC_SPI 54 IRQ_TYPE_LEVEL_HIGH>,
<GIC_SPI 59 IRQ_TYPE_LEVEL_HIGH>;
- clocks = <&ccu CLK_APB1>, <&osc24M>, <&osc32k>;
+ clocks = <&ccu CLK_APB1>, <&osc24M>, <&rtc 0>;
clock-names = "apb", "hosc", "losc";
gpio-controller;
#gpio-cells = <3>;
@@ -710,10 +702,20 @@
};
};

+ rtc: rtc@7000000 {
+ compatible = "allwinner,sun50i-h6-rtc";
+ reg = <0x07000000 0x400>;
+ interrupts = <GIC_SPI 101 IRQ_TYPE_LEVEL_HIGH>,
+ <GIC_SPI 102 IRQ_TYPE_LEVEL_HIGH>;
+ clock-output-names = "osc32k", "osc32k-out", "iosc";
+ clocks = <&ext_osc32k>;
+ #clock-cells = <1>;
+ };
+
r_ccu: clock@7010000 {
compatible = "allwinner,sun50i-h6-r-ccu";
reg = <0x07010000 0x400>;
- clocks = <&osc24M>, <&osc32k>, <&iosc>,
+ clocks = <&osc24M>, <&rtc 0>, <&rtc 2>,
<&ccu CLK_PLL_PERIPH0>;
clock-names = "hosc", "losc", "iosc", "pll-periph";
#clock-cells = <1>;
@@ -741,7 +743,7 @@
reg = <0x07022000 0x400>;
interrupts = <GIC_SPI 105 IRQ_TYPE_LEVEL_HIGH>,
<GIC_SPI 111 IRQ_TYPE_LEVEL_HIGH>;
- clocks = <&r_ccu CLK_R_APB1>, <&osc24M>, <&osc32k>;
+ clocks = <&r_ccu CLK_R_APB1>, <&osc24M>, <&rtc 0>;
clock-names = "apb", "hosc", "losc";
gpio-controller;
#gpio-cells = <3>;
--
2.22.1

meg...@megous.com

unread,
Aug 20, 2019, 11:19:39 AM8/20/19
to Alessandro Zummo, Alexandre Belloni, Rob Herring, Mark Rutland, Maxime Ripard, Chen-Yu Tsai, Ondrej Jirman, linu...@vger.kernel.org, devic...@vger.kernel.org, linux-ar...@lists.infradead.org, linux-...@vger.kernel.org, linux...@googlegroups.com
From: Ondrej Jirman <meg...@megous.com>

I went through the datasheets for H6 and H5, and compared the differences.
RTCs are largely similar, but not entirely compatible. Incompatibilities
are in details not yet implemented by the rtc driver though.

I also corrected the clock tree in H6 DTSI.

This patchset is necessary for implementing the WiFi/Bluetooth support
on boards using H6 SoC.

There was some discussion previously of describing HOSC, DCXO and XO
oscillators and clocks as part of RTC in DT, but I decided against it
because it's not necessary, becuse information that would be provided
as a part of DT can already be determined at runtime from RTC registers,
so this woudn't add any value and would only introduce complications
to the driver. See: https://patchwork.kernel.org/cover/10898083/

Please take a look.


Thank you and regards,
Ondrej Jirman


Changes in v2:
- bindings converted to yaml
- added reviewed by tags

Ondrej Jirman (3):
dt-bindings: Add compatible for H6 RTC
rtc: sun6i: Add support for H6 RTC
arm64: dts: sun50i-h6: Add support for RTC and fix the clock tree

.../bindings/rtc/allwinner,sun6i-a31-rtc.yaml | 13 ++++++
arch/arm64/boot/dts/allwinner/sun50i-h6.dtsi | 30 +++++++-------
drivers/rtc/rtc-sun6i.c | 40 ++++++++++++++++++-
3 files changed, 67 insertions(+), 16 deletions(-)

--
2.22.1

Maxime Ripard

unread,
Aug 23, 2019, 4:19:23 AM8/23/19
to meg...@megous.com, Alessandro Zummo, Alexandre Belloni, Rob Herring, Mark Rutland, Chen-Yu Tsai, linu...@vger.kernel.org, devic...@vger.kernel.org, linux-ar...@lists.infradead.org, linux-...@vger.kernel.org, linux...@googlegroups.com
On Tue, Aug 20, 2019 at 05:19:34PM +0200, meg...@megous.com wrote:
> From: Ondrej Jirman <meg...@megous.com>
>
> This patch adds RTC node and fixes the clock properties and nodes
> to reflect the real clock tree.
>
> The device nodes for the internal oscillator and osc32k are removed,
> as these clocks are now provided by the RTC device. Clock references
> are fixed accordingly, too.
>
> Signed-off-by: Ondrej Jirman <meg...@megous.com>

The prefix should be "arm64: dts: allwinner: h6:"

I've fixed it up and applied it.

Maxime

--
Maxime Ripard, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
signature.asc

Jernej Škrabec

unread,
Aug 24, 2019, 4:04:30 AM8/24/19
to linux...@googlegroups.com, meg...@megous.com, Alessandro Zummo, Alexandre Belloni, Rob Herring, Mark Rutland, Maxime Ripard, Chen-Yu Tsai, linu...@vger.kernel.org, devic...@vger.kernel.org, linux-ar...@lists.infradead.org, linux-...@vger.kernel.org
Hi!

Dne torek, 20. avgust 2019 ob 17:19:31 CEST je meg...@megous.com napisal(a):
> From: Ondrej Jirman <meg...@megous.com>
>
> I went through the datasheets for H6 and H5, and compared the differences.
> RTCs are largely similar, but not entirely compatible. Incompatibilities
> are in details not yet implemented by the rtc driver though.
>
> I also corrected the clock tree in H6 DTSI.
>
> This patchset is necessary for implementing the WiFi/Bluetooth support
> on boards using H6 SoC.
>
> There was some discussion previously of describing HOSC, DCXO and XO
> oscillators and clocks as part of RTC in DT, but I decided against it
> because it's not necessary, becuse information that would be provided
> as a part of DT can already be determined at runtime from RTC registers,
> so this woudn't add any value and would only introduce complications
> to the driver. See: https://patchwork.kernel.org/cover/10898083/
>
> Please take a look.
>
>
> Thank you and regards,
> Ondrej Jirman

Sorry for a bit late test, but with your patches on Tanix TX6 box I get this
in dmesg:

[ 17.431742] sun6i-rtc 7000000.rtc: Failed to set rtc time.
[ 20.439742] sun6i-rtc 7000000.rtc: rtc is still busy.
[ 21.435744] sun6i-rtc 7000000.rtc: rtc is still busy.
[ 24.055741] sun6i-rtc 7000000.rtc: rtc is still busy.
[ 24.439752] sun6i-rtc 7000000.rtc: rtc is still busy.

Last line is repeated non-stop.

Any idea what could be wrong?

Best regards,
Jernej



Jernej Škrabec

unread,
Aug 24, 2019, 4:06:19 AM8/24/19
to linux...@googlegroups.com, meg...@megous.com, Alessandro Zummo, Alexandre Belloni, Rob Herring, Mark Rutland, Maxime Ripard, Chen-Yu Tsai, linu...@vger.kernel.org, devic...@vger.kernel.org, linux-ar...@lists.infradead.org, linux-...@vger.kernel.org
Dne sobota, 24. avgust 2019 ob 10:04:24 CEST je Jernej Škrabec napisal(a):
Additional info - this is on kernel 5.2.6 with your patches applied.

Best regards,
Jernej




Ondřej Jirman

unread,
Aug 24, 2019, 8:56:15 AM8/24/19
to Jernej Škrabec, linux...@googlegroups.com, Alessandro Zummo, Alexandre Belloni, devic...@vger.kernel.org, Maxime Ripard, linux-...@vger.kernel.org, Chen-Yu Tsai, Rob Herring, Mark Rutland, linux-ar...@lists.infradead.org, linu...@vger.kernel.org
Hi,
Do you have schematics, or a FEX file for the board or any other info on how the
RTC is set up on that board?

Can you dump the RTC register range?

regards,
o.

> Best regards,
> Jernej
>
>
>
>
>
> _______________________________________________
> linux-arm-kernel mailing list
> linux-ar...@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

Jernej Škrabec

unread,
Aug 24, 2019, 8:58:23 AM8/24/19
to linux...@googlegroups.com, meg...@megous.com, Alessandro Zummo, Alexandre Belloni, devic...@vger.kernel.org, Maxime Ripard, linux-...@vger.kernel.org, Chen-Yu Tsai, Rob Herring, Mark Rutland, linux-ar...@lists.infradead.org, linu...@vger.kernel.org
Dne sobota, 24. avgust 2019 ob 14:56:12 CEST je Ondřej Jirman napisal(a):
I have only Android DT, but as I already said in latest reply to patch 2,
changing switch bypass to bit 14 instead of 15 solved all issues.

Best regards,
Jernej
Reply all
Reply to author
Forward
0 new messages