linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Geert Uytterhoeven <geert@linux-m68k.org>
To: Biju Das <biju.das.jz@bp.renesas.com>,
	Daniel Lezcano <daniel.lezcano@linaro.org>
Cc: Maxime Coquelin <mcoquelin.stm32@gmail.com>,
	 Alexandre Torgue <alexandre.torgue@foss.st.com>,
	Philipp Zabel <p.zabel@pengutronix.de>,
	 Thomas Gleixner <tglx@linutronix.de>,
	Chris Brandt <Chris.Brandt@renesas.com>,
	 "linux-stm32@st-md-mailman.stormreply.com"
	<linux-stm32@st-md-mailman.stormreply.com>,
	 "linux-arm-kernel@lists.infradead.org"
	<linux-arm-kernel@lists.infradead.org>,
	 Chris Paterson <Chris.Paterson2@renesas.com>,
	Biju Das <biju.das@bp.renesas.com>,
	 Prabhakar Mahadev Lad <prabhakar.mahadev-lad.rj@bp.renesas.com>,
	 "linux-renesas-soc@vger.kernel.org"
	<linux-renesas-soc@vger.kernel.org>
Subject: Re: [PATCH v3 3/4] clocksource/drivers/renesas-ostm: Add RZ/G2L OSTM support
Date: Mon, 29 Nov 2021 11:15:59 +0100	[thread overview]
Message-ID: <CAMuHMdUE3A0WwhGYpVK52S0C5xMqccpvHp0hHdnqq3aawzb7DQ@mail.gmail.com> (raw)
In-Reply-To: <OS0PR01MB592240481D7503FFC505BD5E86669@OS0PR01MB5922.jpnprd01.prod.outlook.com>

Hi Biju, Daniel,

On Mon, Nov 29, 2021 at 11:06 AM Biju Das <biju.das.jz@bp.renesas.com> wrote:
> > Subject: Re: [PATCH v3 3/4] clocksource/drivers/renesas-ostm: Add RZ/G2L
> > OSTM support
> >
> > On 12/11/2021 19:44, Biju Das wrote:
> > > RZ/G2L SoC has Generic Timer Module(a.k.a OSTM) which needs to
> > > deassert the reset line before accessing any registers.
> > >
> > > This patch adds an entry point for RZ/G2L so that we can deassert the
> > > reset line in probe callback.
> >
> > What is the connection between adding the reset line control and the
> > platform driver at the end of the driver ?
>
> The original driver has no arm architecture timer, so it needs to be

s/driver/SoC used with this driver/

> called very early in the boot and using of calls for handling the clocks.

Hence must be handled by TIMER_OF_DECLARE().

> Where as RZ/G2L has arm architecture timer and it needs to release the module
> Reset before accessing any registers. So it has to be built in and it needs cpg driver
> which happens at later stage compared to the original case, for de-asserting the reset.
>
> Geert, please correct me if I am wrong.

The reset driver is not available yet at TIMER_OF_DECLARE() time,
so of_reset_control_get_optional_exclusive() returns -EPROBE_DEFER
on RZ/G2L.  Fortunately there is no need to have this timer available
early on RZ/G2L, as it uses the arm architecture timer as the main
clock source.  Still, to be available at all, the platform driver
is needed to support re-probing after the reset driver has become
available.


> > > Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
> > > Reviewed-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
> > > ---
> > > v2->v3:
> > >  * Added reset_control_put() on error path.
> > >  * enabled suppress_bind_attrs in ostm_device_driver structure
> > > v1->v2:
> > >  * Added reset handling inside ostm_init
> > >  * Used same compatible for builtin driver aswell
> > > ---
> > >  drivers/clocksource/renesas-ostm.c | 39
> > > +++++++++++++++++++++++++++++-
> > >  1 file changed, 38 insertions(+), 1 deletion(-)
> > >
> > > diff --git a/drivers/clocksource/renesas-ostm.c
> > > b/drivers/clocksource/renesas-ostm.c
> > > index 3d06ba66008c..21d1392637b8 100644
> > > --- a/drivers/clocksource/renesas-ostm.c
> > > +++ b/drivers/clocksource/renesas-ostm.c
> > > @@ -9,6 +9,8 @@
> > >  #include <linux/clk.h>
> > >  #include <linux/clockchips.h>
> > >  #include <linux/interrupt.h>
> > > +#include <linux/platform_device.h>
> > > +#include <linux/reset.h>
> > >  #include <linux/sched_clock.h>
> > >  #include <linux/slab.h>
> > >
> > > @@ -159,6 +161,7 @@ static int __init ostm_init_clkevt(struct timer_of
> > > *to)
> > >
> > >  static int __init ostm_init(struct device_node *np)  {
> > > +   struct reset_control *rstc;
> > >     struct timer_of *to;
> > >     int ret;
> > >
> > > @@ -166,6 +169,14 @@ static int __init ostm_init(struct device_node *np)
> > >     if (!to)
> > >             return -ENOMEM;
> > >
> > > +   rstc = of_reset_control_get_optional_exclusive(np, NULL);
> > > +   if (IS_ERR(rstc)) {
> > > +           ret = PTR_ERR(rstc);
> > > +           goto err_free;
> > > +   }
> > > +
> > > +   reset_control_deassert(rstc);
> > > +
> > >     to->flags = TIMER_OF_BASE | TIMER_OF_CLOCK;
> > >     if (system_clock) {
> > >             /*
> > > @@ -178,7 +189,7 @@ static int __init ostm_init(struct device_node
> > > *np)
> > >
> > >     ret = timer_of_init(np, to);
> > >     if (ret)
> > > -           goto err_free;
> > > +           goto err_reset;
> > >
> > >     /*
> > >      * First probed device will be used as system clocksource. Any @@
> > > -203,9 +214,35 @@ static int __init ostm_init(struct device_node *np)
> > >
> > >  err_cleanup:
> > >     timer_of_cleanup(to);
> > > +err_reset:
> > > +   reset_control_assert(rstc);
> > > +   reset_control_put(rstc);
> > >  err_free:
> > >     kfree(to);
> > >     return ret;
> > >  }
> > >
> > >  TIMER_OF_DECLARE(ostm, "renesas,ostm", ostm_init);
> > > +
> > > +#ifdef CONFIG_ARCH_R9A07G044
> > > +static int __init ostm_probe(struct platform_device *pdev) {
> > > +   struct device *dev = &pdev->dev;
> > > +
> > > +   return ostm_init(dev->of_node);
> > > +}
> > > +
> > > +static const struct of_device_id ostm_of_table[] = {
> > > +   { .compatible = "renesas,ostm", },
> > > +   { /* sentinel */ }
> > > +};
> > > +
> > > +static struct platform_driver ostm_device_driver = {
> > > +   .driver = {
> > > +           .name = "renesas_ostm",
> > > +           .of_match_table = of_match_ptr(ostm_of_table),
> > > +           .suppress_bind_attrs = true,
> > > +   },
> > > +};
> > > +builtin_platform_driver_probe(ostm_device_driver, ostm_probe); #endif

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  reply	other threads:[~2021-11-29 10:18 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-12 18:44 [PATCH v3 0/4] Add RZ/G2L OSTM support Biju Das
2021-11-12 18:44 ` [PATCH v3 2/4] dt-bindings: timer: renesas: ostm: Document Renesas RZ/G2L OSTM Biju Das
2021-11-29  0:06   ` Rob Herring
2021-11-12 18:44 ` [PATCH v3 3/4] clocksource/drivers/renesas-ostm: Add RZ/G2L OSTM support Biju Das
2021-11-18 10:44   ` Geert Uytterhoeven
2021-11-29  9:53   ` Daniel Lezcano
2021-11-29 10:05     ` Biju Das
2021-11-29 10:15       ` Geert Uytterhoeven [this message]
2021-12-07 13:32         ` Biju Das
2021-12-09 13:10           ` Daniel Lezcano

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=CAMuHMdUE3A0WwhGYpVK52S0C5xMqccpvHp0hHdnqq3aawzb7DQ@mail.gmail.com \
    --to=geert@linux-m68k.org \
    --cc=Chris.Brandt@renesas.com \
    --cc=Chris.Paterson2@renesas.com \
    --cc=alexandre.torgue@foss.st.com \
    --cc=biju.das.jz@bp.renesas.com \
    --cc=biju.das@bp.renesas.com \
    --cc=daniel.lezcano@linaro.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-renesas-soc@vger.kernel.org \
    --cc=linux-stm32@st-md-mailman.stormreply.com \
    --cc=mcoquelin.stm32@gmail.com \
    --cc=p.zabel@pengutronix.de \
    --cc=prabhakar.mahadev-lad.rj@bp.renesas.com \
    --cc=tglx@linutronix.de \
    /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;
as well as URLs for NNTP newsgroup(s).