From: "Jernej Škrabec" <jernej.skrabec-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
To: linux-sunxi-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org,
megous-5qf/QAjKc83QT0dZR+AlfA@public.gmane.org
Cc: Mark Rutland <mark.rutland-5wv7dgnIgG8@public.gmane.org>,
Alessandro Zummo
<a.zummo-BfzFCNDTiLLj+vYz1yj4TQ@public.gmane.org>,
Alexandre Belloni
<alexandre.belloni-LDxbnhwyfcJBDgjK7y7TUQ@public.gmane.org>,
devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
Maxime Ripard
<maxime.ripard-LDxbnhwyfcJBDgjK7y7TUQ@public.gmane.org>,
linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
Chen-Yu Tsai <wens-jdAy2FN1RRM@public.gmane.org>,
Rob Herring <robh+dt-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>,
linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org,
linux-rtc-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: Re: [PATCH v2 2/3] rtc: sun6i: Add support for H6 RTC
Date: Sat, 24 Aug 2019 23:36:26 +0200 [thread overview]
Message-ID: <7913281.jYEbquIlsS@jernej-laptop> (raw)
In-Reply-To: <20190824212746.a5pyilkrrvysjjbd-9v8tmBix7cb9zxVx7UNMDg@public.gmane.org>
Dne sobota, 24. avgust 2019 ob 23:27:46 CEST je Ondřej Jirman napisal(a):
> Hello Jernej,
>
> On Sat, Aug 24, 2019 at 11:09:49PM +0200, Jernej Škrabec wrote:
> > > Visually?
> > >
> > > That would explain why it doesn't work for you. The mainline RTC driver
> > > disables auto-switch feature, and if your board doesn't have a crystal
> > > for
> > > LOSC, RTC will not generate a clock for the RTC.
> > >
> > > H6's dtsi describes by default a situatiuon with external 32k crystal
> > > oscillator. See ext_osc32k node. That's incorrect for your board if it
> > > doesn't have the crystal. You need to fix this in the DTS for your board
> > > instead of patching the driver.
> >
> > I see that reparenting is supported, but I'm not sure how to fix that in
> > DT. Any suggestion?
>
> You may try removing the clocks property from rtc node.
I don't think this would work:
https://elixir.bootlin.com/linux/latest/source/drivers/rtc/rtc-sun6i.c#L246
>
> > > The driver has parent clock selection logic in case the LOSC crystal is
> > > not
> > > used.
> > >
> > > Your patch enables automatic detection of LOSC failure and RTC changes
> > > clock to LOSC automatically, despite what's described in the DTS. That
> > > may fix the issue, but is not the correct solution.
> > >
> > > Registers on my board look like this (external 32k osc is used) for
> > > reference:
> > >
> > > LOSC_CTRL_REG[7000000]: 8011
> > >
> > > KEY_FIELD ??? (0)
> > > LOSC_AUTO_SWT_BYPASS EN (1)
> > > LOSC_AUTO_SWT_EN DIS (0)
> > > EXT_LOSC_EN EN (1)
> > > EXT_LOSC_GSM LOW (0)
> > > BATTERY_DIR DISCHARGE (0)
> > > LOSC_SRC_SEL EXT32k (1)
> > >
> > > LOSC_AUTO_SWT_STA_REG[7000004]: 1
> > >
> > > EXT_LOSC_STA OK (0)
> > > LOSC_AUTO_SWT_PEND NOEFF (0)
> > > LOSC_SRC_SEL_STA EXT32K (1)
> >
> > In my case LOSC_CTRL_REG has value 0x4010 and LOSC_AUTO_SWT_STA_REG
> > has value 0x4, so there is issue with external crystal (it's missing) and
> > RTC switched to internal one.
> >
> > BTW, what's wrong with automatic switching? Why is it disabled?
>
> It always was disabled on mainline (bit 14 was set to 0 even before my
> patch). H6 just probably has another extra undocummented bit, that's needed
> to disables it properly.
>
> You probably don't want a glitch to switch your RTC from high-precision
> clock to a low precision one possibly without any indication in the
> userspace or a kernel log.
>
> Regardless of all this, DTS needs to have a correct description of the HW,
> which means if RTC module is not connected to the 32.757kHz crystal/clock,
> clocks property should be empty.
If we are talking about correct HW description, then clock property should
actually have possibility that two clocks are defined - one for internal RC
(always present) and one external crystal (optional). In such case I could
really just omit external clock and be done with it. But I'm not sure if such
solution is acceptable at this point.
Best regards,
Jernej
>
> regards,
> o.
>
> > Best regards,
> > Jernej
> >
> > > regards,
> > >
> > > o.
> > >
> > > > > The real issue probably is that the mainline driver is missing this:
> > > > >
> > > > > https://megous.com/git/linux/tree/drivers/rtc/rtc-sunxi.c?h=h6-4.9-b
> > > > > sp#n
> > > > > 650
> > > >
> > > > Not sure what you mean by that. ext vs. int source selection?
> > > >
> > > >
> > > >
> > > > Best regards,
> > > > Jernej
> > > >
> > > > > regards,
> > > > >
> > > > > o.
--
You received this message because you are subscribed to the Google Groups "linux-sunxi" group.
To unsubscribe from this group and stop receiving emails from it, send an email to linux-sunxi+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To view this discussion on the web, visit https://groups.google.com/d/msgid/linux-sunxi/7913281.jYEbquIlsS%40jernej-laptop.
next prev parent reply other threads:[~2019-08-24 21:36 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-08-20 15:19 [PATCH v2 0/3] Add basic support for RTC on Allwinner H6 SoC megous-5qf/QAjKc83QT0dZR+AlfA
[not found] ` <20190820151934.3860-1-megous-5qf/QAjKc83QT0dZR+AlfA@public.gmane.org>
2019-08-20 15:19 ` [PATCH v2 1/3] dt-bindings: Add compatible for H6 RTC megous-5qf/QAjKc83QT0dZR+AlfA
[not found] ` <20190820151934.3860-2-megous-5qf/QAjKc83QT0dZR+AlfA@public.gmane.org>
2019-08-22 21:15 ` Alexandre Belloni
2019-08-20 15:19 ` [PATCH v2 2/3] rtc: sun6i: Add support " megous-5qf/QAjKc83QT0dZR+AlfA
2019-08-22 21:16 ` Alexandre Belloni
[not found] ` <20190820151934.3860-3-megous-5qf/QAjKc83QT0dZR+AlfA@public.gmane.org>
2019-08-24 12:32 ` Jernej Škrabec
2019-08-24 12:46 ` Ondřej Jirman
[not found] ` <20190824124654.nqtlkam2gsaqsj77-9v8tmBix7cb9zxVx7UNMDg@public.gmane.org>
2019-08-24 12:51 ` Jernej Škrabec
2019-08-24 13:05 ` Ondřej Jirman
[not found] ` <20190824130544.kxypq3siv7kffidp-9v8tmBix7cb9zxVx7UNMDg@public.gmane.org>
2019-08-24 13:16 ` Jernej Škrabec
2019-08-24 13:30 ` Ondřej Jirman
[not found] ` <20190824133057.rhpj3xuzr3vymdiy-9v8tmBix7cb9zxVx7UNMDg@public.gmane.org>
2019-08-24 21:09 ` Jernej Škrabec
2019-08-24 21:27 ` Ondřej Jirman
[not found] ` <20190824212746.a5pyilkrrvysjjbd-9v8tmBix7cb9zxVx7UNMDg@public.gmane.org>
2019-08-24 21:36 ` Jernej Škrabec [this message]
2019-08-24 22:16 ` [linux-sunxi] " Ondřej Jirman
2019-08-20 15:19 ` [PATCH v2 3/3] arm64: dts: sun50i-h6: Add support for RTC and fix the clock tree megous-5qf/QAjKc83QT0dZR+AlfA
[not found] ` <20190820151934.3860-4-megous-5qf/QAjKc83QT0dZR+AlfA@public.gmane.org>
2019-08-23 8:19 ` Maxime Ripard
2019-08-24 8:04 ` [PATCH v2 0/3] Add basic support for RTC on Allwinner H6 SoC Jernej Škrabec
2019-08-24 8:06 ` Jernej Škrabec
2019-08-24 12:56 ` Ondřej Jirman
[not found] ` <20190824125612.zq5qsay2wv62wykt-9v8tmBix7cb9zxVx7UNMDg@public.gmane.org>
2019-08-24 12:58 ` Jernej Škrabec
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=7913281.jYEbquIlsS@jernej-laptop \
--to=jernej.skrabec-re5jqeeqqe8avxtiumwx3w@public.gmane.org \
--cc=a.zummo-BfzFCNDTiLLj+vYz1yj4TQ@public.gmane.org \
--cc=alexandre.belloni-LDxbnhwyfcJBDgjK7y7TUQ@public.gmane.org \
--cc=devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org \
--cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-rtc-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-sunxi-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org \
--cc=mark.rutland-5wv7dgnIgG8@public.gmane.org \
--cc=maxime.ripard-LDxbnhwyfcJBDgjK7y7TUQ@public.gmane.org \
--cc=megous-5qf/QAjKc83QT0dZR+AlfA@public.gmane.org \
--cc=robh+dt-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
--cc=wens-jdAy2FN1RRM@public.gmane.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox