Message ID | 20211110153142.3451-4-biju.das.jz@bp.renesas.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | Add RZ/G2L OSTM support | expand |
Hi Biju, On Wed, Nov 10, 2021 at 4:32 PM Biju Das <biju.das.jz@bp.renesas.com> 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. > > Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com> > Reviewed-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com> Thanks for your patch! > --- a/drivers/clocksource/renesas-ostm.c > +++ b/drivers/clocksource/renesas-ostm.c > @@ -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,33 @@ static int __init ostm_init(struct device_node *np) > > err_cleanup: > timer_of_cleanup(to); > +err_reset: > + reset_control_assert(rstc); Missing 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
Hi Biju, On Wed, Nov 10, 2021 at 4:32 PM Biju Das <biju.das.jz@bp.renesas.com> 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. > > Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com> > Reviewed-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com> FTR, no regressions detected when booting RSK+RZA1 and RZA2MEVB, which rely on the OSTM as system timer. 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
Hi Geert, Thanks for the feedback. > Subject: Re: [PATCH v2 3/3] clocksource/drivers/renesas-ostm: Add RZ/G2L > OSTM support > > Hi Biju, > > On Wed, Nov 10, 2021 at 4:32 PM Biju Das <biju.das.jz@bp.renesas.com> > 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. > > > > Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com> > > Reviewed-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com> > > Thanks for your patch! > > > --- a/drivers/clocksource/renesas-ostm.c > > +++ b/drivers/clocksource/renesas-ostm.c > > > @@ -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,33 @@ static int __init ostm_init(struct device_node > > *np) > > > > err_cleanup: > > timer_of_cleanup(to); > > +err_reset: > > + reset_control_assert(rstc); > > Missing reset_control_put(rstc). Oops. Missed it. Will fix it in next version Regards, Biju > > > 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
diff --git a/drivers/clocksource/renesas-ostm.c b/drivers/clocksource/renesas-ostm.c index 3d06ba66008c..3fe78bc4ad88 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,33 @@ static int __init ostm_init(struct device_node *np) err_cleanup: timer_of_cleanup(to); +err_reset: + reset_control_assert(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), + }, +}; +builtin_platform_driver_probe(ostm_device_driver, ostm_probe); +#endif