[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <8a97a7d7be1b94fb4a92c486c458530792d0107a.camel@t-online.de>
Date: Thu, 26 Sep 2024 19:53:45 +0200
From: Alois Fertl <A.Fertl@...nline.de>
To: Andre Przywara <andre.przywara@....com>
Cc: a.zummo@...ertech.it, alexandre.belloni@...tlin.com, wens@...e.org,
jernej.skrabec@...il.com, samuel@...lland.org, linux-rtc@...r.kernel.org,
linux-sunxi@...ts.linux.dev, linux-kernel@...r.kernel.org
Subject: Re: [PATCH v4 1/1] drivers/rtc: rtc-sun6i: AutoCal Internal OSC
On Thu, 2024-05-30 at 18:10 +0100, Andre Przywara wrote:
> On Wed, 22 May 2024 20:28:26 +0200
> Alois Fertl <a.fertl@...nline.de> wrote:
>
> > I have a M98-8K PLUS Magcubic TV-Box based on the Allwinner H618
> > SOC.
> > On board is a Sp6330 wifi/bt module that requires a 32kHz clock to
> > operate correctly. Without this change the clock from the SOC is
> > ~29kHz and BT module does not start up. The patch enables the
> > Internal
> > OSC Clock Auto Calibration of the H616/H618 which than provides the
> > necessary 32kHz and the BT module initializes successfully.
> > Add a flag and set it for H6.
> > Also the code is developed on the H618 board it only modifies the
> > H6 as
> > there is no support for H616/H618 in the current code.
>
> I am a bit confused: so this patch doesn't fix your problem then,
> because
> the code you touch is not used on the H616/H618?
> Actually I would have expected your patch to only change
> drivers/clk/sunxi-ng/ccu-sun6i-rtc.c, since that's the only RTC clock
> driver relevant for the H616.
Thanks for your comment ans sorry for my late reaction.
I was using a community maintained version of drivers/rtc/rtc-sun6i.c
which adds support for the H616 into this file. The proposed change is
than common for H6 AND H616 based on the introduced flag has_auto_cal.
It does fix my problem.
The patch however is based on mainline and therefor does not have the
H616 extension.
>
> > Signed-off-by: Alois Fertl <a.fertl@...nline.de>
> > ---
> >
> > v1->v2
> > - add flag and activate for H6 AND H616
> >
> > v2->v3
> > - correct findings from review
> >
> > v3->v4
> > - adjust to mainline tree
> >
> > I have also tried to test this using the new driver in sunxi-ng
> > manually injecting the reverted patch
> > https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=60d9f050da63b
>
> So this was done on a H6 device? Because out of the box rtc-sun6i.c
> is
> used on the H6 only, and ccu-sun6i-rtc.c is only used on the H616.
>
> Maybe I am missing something here ...
Please see above.
>
> > The code in drivers/clk/sunxi-ng/ccu-sun6i-rtc.c is being called
> > and it
> > initializes the relevant registers to the same values as the old
> > driver,
> > but the change ends up with a system that often hangs during
> > booting and
> > only ocasionally reaches the login state (one out of 10).
> > The main difference I see adhoc is that the old drivers init is
> > done
> > using CLK_OF_DECLARE_DRIVER so initialization is done very early.
> > The new driver does the initialisation via probe which is quite
> > some
> > time later.
> > Can't tell if this is the cause for the problems.
>
> That sounds odd, can you post your changes somewhere?
>
Just recently I was able to get the code in drivers/clk/sunxi-ng/ccu-
sun6i-rtc.c working for my H618 box. It requires a change in just this
ccu-sun6i-rtc.c file. Unfortunatly it is based on try and error picking
and I don't understand why it is required.
The change is that the name "osc32k-out" is now equal tho the string
used in drivers/rtc/rtc-sun6i.c.
--- a/drivers/clk/sunxi-ng/ccu-sun6i-rtc.c
+++ b/drivers/clk/sunxi-ng/ccu-sun6i-rtc.c
@@ -202,7 +202,7 @@ static const struct clk_hw *osc32k_parents[] = {
};
static struct clk_init_data osc32k_init_data = {
- .name = "osc32k",
+ .name = "osc32k-out",
.ops = &ccu_mux_ops,
.parent_hws = osc32k_parents,
.num_parents = ARRAY_SIZE(osc32k_parents), /* updated during
probe */
@@ -271,13 +271,13 @@ static struct ccu_mux osc32k_fanout_clk = {
};
May be someone has a clue on this?
> Generally, without a proper problem and without further testing, I
> would
> not like to touch the H6 RTC code needlessly.
> For the H616 we have a concrete problem at hand, that justifies a
> change,
> also it's the proper driver for new devices, so that's where the
> change
> should happen.
So the PATCH requested here looses importance because for the H6 it
would improve RTC only in the rare case where there is no external 32k
oscillator or when the external oscillator fails.
Probably not worth the effort.
Regards,
Alois
>
> Cheers,
> Andre
>
> >
> > ---
> > drivers/rtc/rtc-sun6i.c | 16 +++++++++++++++-
> > 1 file changed, 15 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/rtc/rtc-sun6i.c b/drivers/rtc/rtc-sun6i.c
> > index 8e0c66906..57aa52d3b 100644
> > --- a/drivers/rtc/rtc-sun6i.c
> > +++ b/drivers/rtc/rtc-sun6i.c
> > @@ -42,6 +42,11 @@
> >
> > #define SUN6I_LOSC_CLK_PRESCAL 0x0008
> >
> > +#define SUN6I_LOSC_CLK_AUTO_CAL 0x000c
> > +#define SUN6I_LOSC_CLK_AUTO_CAL_16MS BIT(2)
> > +#define SUN6I_LOSC_CLK_AUTO_CAL_ENABLE BIT(1)
> > +#define SUN6I_LOSC_CLK_AUTO_CAL_SEL_CAL BIT(0)
> > +
> > /* RTC */
> > #define SUN6I_RTC_YMD 0x0010
> > #define SUN6I_RTC_HMS 0x0014
> > @@ -126,7 +131,6 @@
> > * registers (R40, H6)
> > * - SYS power domain controls (R40)
> > * - DCXO controls (H6)
> > - * - RC oscillator calibration (H6)
> > *
> > * These functions are not covered by this driver.
> > */
> > @@ -137,6 +141,7 @@ struct sun6i_rtc_clk_data {
> > unsigned int has_out_clk : 1;
> > unsigned int has_losc_en : 1;
> > unsigned int has_auto_swt : 1;
> > + unsigned int has_auto_cal : 1;
> > };
> >
> > #define RTC_LINEAR_DAY BIT(0)
> > @@ -267,6 +272,14 @@ static void __init sun6i_rtc_clk_init(struct
> > device_node *node,
> > }
> > writel(reg, rtc->base + SUN6I_LOSC_CTRL);
> >
> > + if (rtc->data->has_auto_cal) {
> > + /* Enable internal OSC clock auto calibration */
> > + reg = SUN6I_LOSC_CLK_AUTO_CAL_16MS |
> > + SUN6I_LOSC_CLK_AUTO_CAL_ENABLE |
> > + SUN6I_LOSC_CLK_AUTO_CAL_SEL_CAL;
> > + writel(reg, rtc->base + SUN6I_LOSC_CLK_AUTO_CAL);
> > + }
> > +
> > /* Yes, I know, this is ugly. */
> > sun6i_rtc = rtc;
> >
> > @@ -374,6 +387,7 @@ static const struct sun6i_rtc_clk_data
> > sun50i_h6_rtc_data = {
> > .has_out_clk = 1,
> > .has_losc_en = 1,
> > .has_auto_swt = 1,
> > + .has_auto_cal = 1,
> > };
> >
> > static void __init sun50i_h6_rtc_clk_init(struct device_node
> > *node)
>
Powered by blists - more mailing lists