linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] arm64: dts: allwinner: h6: tanix-tx6: Use internal oscillator
@ 2020-01-13 18:07 Jernej Skrabec
  2020-01-16  8:06 ` Maxime Ripard
  0 siblings, 1 reply; 4+ messages in thread
From: Jernej Skrabec @ 2020-01-13 18:07 UTC (permalink / raw)
  To: mripard, wens, robh+dt, mark.rutland
  Cc: linux-arm-kernel, devicetree, linux-kernel, linux-sunxi

Tanix TX6 doesn't have external 32 kHz oscillator, so switch RTC clock
to internal one.

Signed-off-by: Jernej Skrabec <jernej.skrabec@siol.net>
---

While this patch gives one possible solution, I mainly want to start
discussion why Allwinner SoC dtsi reference external 32 kHz crystal
although some boards don't have it. My proposal would be to make clock
property optional, based on the fact if external crystal is present or
not. However, I'm not sure if that is possible at this point or not.
Driver also considers missing clock property as deprecated (old DT) [1],
so this might complicate things even further.

What do you think?

Best regards,
Jernej

[1] https://elixir.bootlin.com/linux/latest/source/drivers/rtc/rtc-sun6i.c#L263

 arch/arm64/boot/dts/allwinner/sun50i-h6-tanix-tx6.dts | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/arch/arm64/boot/dts/allwinner/sun50i-h6-tanix-tx6.dts b/arch/arm64/boot/dts/allwinner/sun50i-h6-tanix-tx6.dts
index 83e6cb0e59ce..af3aebda47bb 100644
--- a/arch/arm64/boot/dts/allwinner/sun50i-h6-tanix-tx6.dts
+++ b/arch/arm64/boot/dts/allwinner/sun50i-h6-tanix-tx6.dts
@@ -91,6 +91,12 @@ &r_ir {
 	status = "okay";
 };
 
+/* This board doesn't have external 32 kHz crystal. */
+&rtc {
+	assigned-clocks = <&rtc 0>;
+	assigned-clock-parents = <&rtc 2>;
+};
+
 &uart0 {
 	pinctrl-names = "default";
 	pinctrl-0 = <&uart0_ph_pins>;
-- 
2.24.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] arm64: dts: allwinner: h6: tanix-tx6: Use internal oscillator
  2020-01-13 18:07 [PATCH] arm64: dts: allwinner: h6: tanix-tx6: Use internal oscillator Jernej Skrabec
@ 2020-01-16  8:06 ` Maxime Ripard
  2020-01-16 16:47   ` Jernej Škrabec
  0 siblings, 1 reply; 4+ messages in thread
From: Maxime Ripard @ 2020-01-16  8:06 UTC (permalink / raw)
  To: Jernej Skrabec
  Cc: wens, robh+dt, mark.rutland, linux-arm-kernel, devicetree,
	linux-kernel, linux-sunxi

[-- Attachment #1: Type: text/plain, Size: 1920 bytes --]

Hi Jernej,

On Mon, Jan 13, 2020 at 07:07:20PM +0100, Jernej Skrabec wrote:
> Tanix TX6 doesn't have external 32 kHz oscillator, so switch RTC clock
> to internal one.
>
> Signed-off-by: Jernej Skrabec <jernej.skrabec@siol.net>
> ---
>
> While this patch gives one possible solution, I mainly want to start
> discussion why Allwinner SoC dtsi reference external 32 kHz crystal
> although some boards don't have it. My proposal would be to make clock
> property optional, based on the fact if external crystal is present or
> not. However, I'm not sure if that is possible at this point or not.

It's probably a bit of a dumb question but.. are you sure the crystal
is missing?

The H6 datasheet mentions that the 32kHz crystal needs to be there,
and it's part of the power sequence, so I'd expect all boards to have
it.

> Driver also considers missing clock property as deprecated (old DT) [1],
> so this might complicate things even further.
>
> What do you think?

I'm pretty sure (but that would need to be checked) that we never got
a node without the clocks property on the H6. If that's the case, then
we can add a check on the compatible.

> Best regards,
> Jernej
>
> [1] https://elixir.bootlin.com/linux/latest/source/drivers/rtc/rtc-sun6i.c#L263
>
>  arch/arm64/boot/dts/allwinner/sun50i-h6-tanix-tx6.dts | 6 ++++++
>  1 file changed, 6 insertions(+)
>
> diff --git a/arch/arm64/boot/dts/allwinner/sun50i-h6-tanix-tx6.dts b/arch/arm64/boot/dts/allwinner/sun50i-h6-tanix-tx6.dts
> index 83e6cb0e59ce..af3aebda47bb 100644
> --- a/arch/arm64/boot/dts/allwinner/sun50i-h6-tanix-tx6.dts
> +++ b/arch/arm64/boot/dts/allwinner/sun50i-h6-tanix-tx6.dts
> @@ -91,6 +91,12 @@ &r_ir {
>  	status = "okay";
>  };
>
> +/* This board doesn't have external 32 kHz crystal. */
> +&rtc {
> +	assigned-clocks = <&rtc 0>;
> +	assigned-clock-parents = <&rtc 2>;
> +};
> +

This should be dealt with in the driver however.

Maxime

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] arm64: dts: allwinner: h6: tanix-tx6: Use internal oscillator
  2020-01-16  8:06 ` Maxime Ripard
@ 2020-01-16 16:47   ` Jernej Škrabec
  2020-01-17 18:39     ` Maxime Ripard
  0 siblings, 1 reply; 4+ messages in thread
From: Jernej Škrabec @ 2020-01-16 16:47 UTC (permalink / raw)
  To: Maxime Ripard
  Cc: wens, robh+dt, mark.rutland, linux-arm-kernel, devicetree,
	linux-kernel, linux-sunxi

Hi!

Dne četrtek, 16. januar 2020 ob 09:06:52 CET je Maxime Ripard napisal(a):
> Hi Jernej,
> 
> On Mon, Jan 13, 2020 at 07:07:20PM +0100, Jernej Skrabec wrote:
> > Tanix TX6 doesn't have external 32 kHz oscillator, so switch RTC clock
> > to internal one.
> > 
> > Signed-off-by: Jernej Skrabec <jernej.skrabec@siol.net>
> > ---
> > 
> > While this patch gives one possible solution, I mainly want to start
> > discussion why Allwinner SoC dtsi reference external 32 kHz crystal
> > although some boards don't have it. My proposal would be to make clock
> > property optional, based on the fact if external crystal is present or
> > not. However, I'm not sure if that is possible at this point or not.
> 
> It's probably a bit of a dumb question but.. are you sure the crystal
> is missing?

Although I don't have schematic, I'm pretty sure. Without this patch or one at 
[1], RTC gives a lot of errors in dmesg. I think that unpopulated XC2 pads 
near SoC (see [2]) are probably reserved for crystal.

With patch in [1], which enables automatic switching in case of error, I saw 
that on this box RTC always switched to internal RC.

> 
> The H6 datasheet mentions that the 32kHz crystal needs to be there,
> and it's part of the power sequence, so I'd expect all boards to have
> it.

Can you be more specific where it is stated that crystal is mandatory? 

Note that schematic of some boards, like OrangePi PC2 (H5) or OrangePi Zero 
(H3) don't even have 32K crystal in them.

> 
> > Driver also considers missing clock property as deprecated (old DT) [1],
> > so this might complicate things even further.
> > 
> > What do you think?
> 
> I'm pretty sure (but that would need to be checked) that we never got
> a node without the clocks property on the H6. If that's the case, then
> we can add a check on the compatible.

Yes, that would be nice solution. I can work something out if you agree that 
this is the way.

> 
> > Best regards,
> > Jernej
> > 
> > [1]
> > https://elixir.bootlin.com/linux/latest/source/drivers/rtc/rtc-sun6i.c#L2
> > 63> 
> >  arch/arm64/boot/dts/allwinner/sun50i-h6-tanix-tx6.dts | 6 ++++++
> >  1 file changed, 6 insertions(+)
> > 
> > diff --git a/arch/arm64/boot/dts/allwinner/sun50i-h6-tanix-tx6.dts
> > b/arch/arm64/boot/dts/allwinner/sun50i-h6-tanix-tx6.dts index
> > 83e6cb0e59ce..af3aebda47bb 100644
> > --- a/arch/arm64/boot/dts/allwinner/sun50i-h6-tanix-tx6.dts
> > +++ b/arch/arm64/boot/dts/allwinner/sun50i-h6-tanix-tx6.dts
> > @@ -91,6 +91,12 @@ &r_ir {
> > 
> >  	status = "okay";
> >  
> >  };
> > 
> > +/* This board doesn't have external 32 kHz crystal. */
> > +&rtc {
> > +	assigned-clocks = <&rtc 0>;
> > +	assigned-clock-parents = <&rtc 2>;
> > +};
> > +
> 
> This should be dealt with in the driver however.

Sure, it is something to start discussion, I don't like tackling clocks in DT 
either.

Best regards,
Jernej

[1] https://github.com/LibreELEC/LibreELEC.tv/blob/master/projects/Allwinner/
devices/H6/patches/linux/15-RTC-workaround.patch
[2] http://linux-sunxi.org/images/2/2e/Tanix_tx6_pcb_top.png





^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] arm64: dts: allwinner: h6: tanix-tx6: Use internal oscillator
  2020-01-16 16:47   ` Jernej Škrabec
@ 2020-01-17 18:39     ` Maxime Ripard
  0 siblings, 0 replies; 4+ messages in thread
From: Maxime Ripard @ 2020-01-17 18:39 UTC (permalink / raw)
  To: Jernej Škrabec
  Cc: wens, robh+dt, mark.rutland, linux-arm-kernel, devicetree,
	linux-kernel, linux-sunxi

[-- Attachment #1: Type: text/plain, Size: 3003 bytes --]

Hi,

On Thu, Jan 16, 2020 at 05:47:12PM +0100, Jernej Škrabec wrote:
> Dne četrtek, 16. januar 2020 ob 09:06:52 CET je Maxime Ripard napisal(a):
> > Hi Jernej,
> >
> > On Mon, Jan 13, 2020 at 07:07:20PM +0100, Jernej Skrabec wrote:
> > > Tanix TX6 doesn't have external 32 kHz oscillator, so switch RTC clock
> > > to internal one.
> > >
> > > Signed-off-by: Jernej Skrabec <jernej.skrabec@siol.net>
> > > ---
> > >
> > > While this patch gives one possible solution, I mainly want to start
> > > discussion why Allwinner SoC dtsi reference external 32 kHz crystal
> > > although some boards don't have it. My proposal would be to make clock
> > > property optional, based on the fact if external crystal is present or
> > > not. However, I'm not sure if that is possible at this point or not.
> >
> > It's probably a bit of a dumb question but.. are you sure the crystal
> > is missing?
>
> Although I don't have schematic, I'm pretty sure. Without this patch or one at
> [1], RTC gives a lot of errors in dmesg. I think that unpopulated XC2 pads
> near SoC (see [2]) are probably reserved for crystal.
>
> With patch in [1], which enables automatic switching in case of error, I saw
> that on this box RTC always switched to internal RC.
>
> >
> > The H6 datasheet mentions that the 32kHz crystal needs to be there,
> > and it's part of the power sequence, so I'd expect all boards to have
> > it.
>
> Can you be more specific where it is stated that crystal is mandatory?

I was mostly referring to the power sequence mentionned in the H6
Datasheet (not the user manual, the smaller one).

https://linux-sunxi.org/images/5/5c/Allwinner_H6_V200_Datasheet_V1.1.pdf

Page 74

> Note that schematic of some boards, like OrangePi PC2 (H5) or OrangePi Zero
> (H3) don't even have 32K crystal in them.

And we can't use the compatible for these..

> >
> > > Driver also considers missing clock property as deprecated (old DT) [1],
> > > so this might complicate things even further.
> > >
> > > What do you think?
> >
> > I'm pretty sure (but that would need to be checked) that we never got
> > a node without the clocks property on the H6. If that's the case, then
> > we can add a check on the compatible.
>
> Yes, that would be nice solution. I can work something out if you agree that
> this is the way.

So if we want to have something that works for the H3 too, then I
guess we need to revert the patch that switches the 32kHz clock source
to the external one all the time, and do it only if we have a clock
provided.

If we don't, we would run from the internal oscillator (which would
work for both the H3 and H6 boards you have I guess?) and if we do we
will still use the better, more accurate, clock.

That would change a bit the behaviour of the old DTs again and revert
to the old behaviour we had, but we didn't hear anything the first
time we did, so I wouldn't be overly concerned.

Does that make sense?
Maxime

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-01-17 18:39 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-13 18:07 [PATCH] arm64: dts: allwinner: h6: tanix-tx6: Use internal oscillator Jernej Skrabec
2020-01-16  8:06 ` Maxime Ripard
2020-01-16 16:47   ` Jernej Škrabec
2020-01-17 18:39     ` Maxime Ripard

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).