From: Yoshinori Sato <ysato@users.sourceforge.jp>
To: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: linux-sh@vger.kernel.org, glaubitz@physik.fu-berlin.de
Subject: Re: [RFC PATCH v3 22/35] drivers/clocksource/sh_tmu: Add support CLOCKSOURCE.
Date: Mon, 23 Oct 2023 20:40:04 +0900 [thread overview]
Message-ID: <87wmvd7ejv.wl-ysato@users.sourceforge.jp> (raw)
In-Reply-To: <CAMuHMdU66TvS7D=tuQUMazO85V9wh+uMf_t086VKBB+C8wvYQg@mail.gmail.com>
On Thu, 19 Oct 2023 01:04:57 +0900,
Geert Uytterhoeven wrote:
>
> Hi Sato-san,
>
> Thanks for your patch!
>
> On Sat, Oct 14, 2023 at 4:54 PM Yoshinori Sato
> <ysato@users.sourceforge.jp> wrote:
> > Enables registration as a Clocksource in the case of OF.
>
> I think this is not a good description.
> What this patch does, is to add support for early registration using
> TIMER_OF_DECLARE(), so the timer can be used as a clocksource
> on SoCs that do not have any other suitable timer.
>
> Then I wondered: do you need this? On R-Mobile A1, the TMU is also
> used as a clocksource, how come it works there?
> The trick is to set preset_lpj based on the CPU core clock frequency.
>
> I see your v2 actually added that, but you dropped the code in v3.
> https://lore.kernel.org/linux-sh/236185b4a47f303332aafeacadd9c9652e650062.1694596125.git.ysato@users.sourceforge.jp
> Nevertheless, it doesn't work anymore, as you also removed the
> clock-frequency property from cpu@0 in DT...
> Adding that makes it work without this TMU patch.
Currently sh initializes the timer with a parameter called "earlytimer",
but this does not seem to work correctly with CONFIG_OF.
It will be initialized later when of_platform_depopulate is called,
so it can be started, but I think this is incorrect initialization
of the timer.
I think it's better to follow the OF procedure rather than the old
SH-specific framework.
> > Signed-off-by: Yoshinori Sato <ysato@users.sourceforge.jp>
>
> > --- a/drivers/clocksource/sh_tmu.c
> > +++ b/drivers/clocksource/sh_tmu.c
>
> > @@ -403,7 +411,8 @@ static void sh_tmu_clock_event_resume(struct clock_event_device *ced)
> > }
> >
> > static void sh_tmu_register_clockevent(struct sh_tmu_channel *ch,
> > - const char *name)
> > + const char *name,
> > + struct device_node *np)
>
> "np" is unused in this function, hence this change is unneeded.
>
> > {
> > struct clock_event_device *ced = &ch->ced;
> > int ret;
>
> > static int sh_tmu_register(struct sh_tmu_channel *ch, const char *name,
> > + struct device_node *np,
>
> This change is unneeded...
>
> > bool clockevent, bool clocksource)
> > {
> > if (clockevent) {
> > ch->tmu->has_clockevent = true;
> > - sh_tmu_register_clockevent(ch, name);
> > + sh_tmu_register_clockevent(ch, name, np);
>
> ... as sh_tmu_register_clockevent() doesn't use "np".
>
> > } else if (clocksource) {
> > ch->tmu->has_clocksource = true;
> > sh_tmu_register_clocksource(ch, name);
>
> > @@ -465,53 +477,59 @@ static int sh_tmu_channel_setup(struct sh_tmu_channel *ch, unsigned int index,
> > else
> > ch->base = tmu->mapbase + 8 + ch->index * 12;
> >
> > - ch->irq = platform_get_irq(tmu->pdev, index);
> > + if (tmu->pdev)
> > + ch->irq = platform_get_irq(tmu->pdev, index);
> > + else
> > + ch->irq = of_irq_get(np, index);
>
> You can use of_irq_get() uncondtionally.
>
> > if (ch->irq < 0)
> > return ch->irq;
> >
> > ch->cs_enabled = false;
> > ch->enable_count = 0;
> >
> > - return sh_tmu_register(ch, dev_name(&tmu->pdev->dev),
> > + return sh_tmu_register(ch, tmu->name, np,
>
> No need to pass np.
>
> > clockevent, clocksource);
> > }
> >
> > -static int sh_tmu_map_memory(struct sh_tmu_device *tmu)
> > +static int sh_tmu_map_memory(struct sh_tmu_device *tmu, struct device_node *np)
> > {
> > struct resource *res;
> >
> > - res = platform_get_resource(tmu->pdev, IORESOURCE_MEM, 0);
> > - if (!res) {
> > - dev_err(&tmu->pdev->dev, "failed to get I/O memory\n");
> > - return -ENXIO;
> > - }
> > + if (tmu->pdev) {
> > + res = platform_get_resource(tmu->pdev, IORESOURCE_MEM, 0);
> > + if (!res) {
> > + pr_err("sh_tmu failed to get I/O memory\n");
> > + return -ENXIO;
> > + }
> > +
> > + tmu->mapbase = ioremap(res->start, resource_size(res));
> > + } else
> > + tmu->mapbase = of_iomap(np, 0);
>
> You can use of_iomap() unconditionally.
>
> >
> > - tmu->mapbase = ioremap(res->start, resource_size(res));
> > if (tmu->mapbase == NULL)
> > return -ENXIO;
> >
> > return 0;
> > }
> >
> > -static int sh_tmu_parse_dt(struct sh_tmu_device *tmu)
> > +static int sh_tmu_parse_dt(struct sh_tmu_device *tmu, struct device_node *np)
> > {
> > - struct device_node *np = tmu->pdev->dev.of_node;
> > -
> > tmu->model = SH_TMU;
> > tmu->num_channels = 3;
> >
> > of_property_read_u32(np, "#renesas,channels", &tmu->num_channels);
> >
> > if (tmu->num_channels != 2 && tmu->num_channels != 3) {
> > - dev_err(&tmu->pdev->dev, "invalid number of channels %u\n",
> > - tmu->num_channels);
> > + pr_err("%s: invalid number of channels %u\n",
> > + tmu->name, tmu->num_channels);
> > return -EINVAL;
> > }
> >
> > return 0;
> > }
> >
> > -static int sh_tmu_setup(struct sh_tmu_device *tmu, struct platform_device *pdev)
> > +static int sh_tmu_setup(struct sh_tmu_device *tmu,
> > + struct platform_device *pdev, struct device_node *np)
> > {
> > unsigned int i;
> > int ret;
>
> > @@ -531,14 +554,17 @@ static int sh_tmu_setup(struct sh_tmu_device *tmu, struct platform_device *pdev)
> > tmu->model = id->driver_data;
> > tmu->num_channels = hweight8(cfg->channels_mask);
> > } else {
> > - dev_err(&tmu->pdev->dev, "missing platform data\n");
> > + pr_err("%s missing platform data\n", tmu->name);
> > return -ENXIO;
> > }
> >
> > /* Get hold of clock. */
> > - tmu->clk = clk_get(&tmu->pdev->dev, "fck");
> > + if (pdev)
> > + tmu->clk = clk_get(&tmu->pdev->dev, "fck");
> > + else
> > + tmu->clk = of_clk_get(np, 0);
>
> You can use of_clk_get() unconditionally.
>
> > if (IS_ERR(tmu->clk)) {
> > - dev_err(&tmu->pdev->dev, "cannot get clock\n");
> > + pr_err("%s: cannot get clock\n", tmu->name);
> > return PTR_ERR(tmu->clk);
> > }
> >
>
> 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
--
Yosinori Sato
next prev parent reply other threads:[~2023-10-23 11:40 UTC|newest]
Thread overview: 91+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-14 14:53 [RFC PATCH v3 00/35] Device Tree support for SH7751 based board Yoshinori Sato
2023-10-14 14:53 ` [RFC PATCH v3 01/35] arch/sh/boot/compressed/head_32.S: passing FDT address to initialize function Yoshinori Sato
2023-10-14 17:11 ` Sergei Shtylyov
2023-10-14 14:53 ` [RFC PATCH v3 02/35] arch/sh/boards/Kconfig: unified OF supported targets Yoshinori Sato
2023-10-14 14:53 ` [RFC PATCH v3 03/35] arch/sh: Disable SH specific modules in OF enabled Yoshinori Sato
2023-10-19 2:12 ` kernel test robot
2023-10-14 14:53 ` [RFC PATCH v3 04/35] include/linux/sh_intc.h: Add stub function "intc_finalize" Yoshinori Sato
2023-10-14 14:53 ` [RFC PATCH v3 05/35] arch/sh/kernel/setup.c: Update DT support Yoshinori Sato
2023-10-19 10:01 ` Geert Uytterhoeven
2023-10-14 14:53 ` [RFC PATCH v3 06/35] arch/sh/boards/of-generic.c: some cleanup Yoshinori Sato
2023-10-18 18:37 ` Geert Uytterhoeven
2023-10-26 3:40 ` Yoshinori Sato
2023-10-26 7:20 ` Geert Uytterhoeven
2023-10-14 14:53 ` [RFC PATCH v3 07/35] arch/sh/kernel/time.c: support COMMON_CLK Yoshinori Sato
2023-10-14 14:53 ` [RFC PATCH v3 08/35] arch/sh/include/asm: Disable SH specific PCI define in OF enabled Yoshinori Sato
2023-10-14 14:53 ` [RFC PATCH v3 09/35] drivers/pci/controller: SH7751 PCI Host bridge driver Yoshinori Sato
2023-10-16 17:27 ` Bjorn Helgaas
2023-10-16 19:52 ` Bjorn Helgaas
2023-10-14 14:53 ` [RFC PATCH v3 10/35] Documentation/devicetree/bindings/pci: renesas,pci-sh7751.yaml new file Yoshinori Sato
2023-10-16 5:28 ` Krzysztof Kozlowski
2023-10-16 11:55 ` Krzysztof Kozlowski
2023-10-14 14:53 ` [RFC PATCH v3 11/35] include/dt-bindings/clock/sh7750.h: cpg-sh7750 binding header Yoshinori Sato
2023-10-18 13:49 ` Geert Uytterhoeven
2023-10-14 14:53 ` [RFC PATCH v3 12/35] drivers/clk/renesas: clk-sh7750.c SH7750/7751 CPG driver Yoshinori Sato
2023-10-18 13:02 ` Geert Uytterhoeven
2023-10-19 7:18 ` Geert Uytterhoeven
2023-10-14 14:53 ` [RFC PATCH v3 13/35] Documentation/devicetree/bindings/clock: Add renesas,sh7750-cpg binding document Yoshinori Sato
2023-10-18 13:41 ` Geert Uytterhoeven
2023-10-14 14:53 ` [RFC PATCH v3 14/35] drivers/irqchip: Add SH7751 Internal INTC drivers Yoshinori Sato
2023-10-17 9:27 ` Geert Uytterhoeven
2023-10-18 8:02 ` Thomas Gleixner
2023-10-18 8:18 ` Geert Uytterhoeven
2023-10-14 14:53 ` [RFC PATCH v3 15/35] Documentation/devicetree/bindings/interrupt-controller: Add renesas,sh7751-intc.yaml Yoshinori Sato
2023-10-19 11:29 ` Geert Uytterhoeven
2023-10-19 11:38 ` Geert Uytterhoeven
2023-10-14 14:53 ` [RFC PATCH v3 16/35] drivers/irqchip: SH7751 IRL external encoder with enable gate Yoshinori Sato
2023-10-16 18:46 ` Thomas Gleixner
2023-10-16 18:50 ` John Paul Adrian Glaubitz
2023-10-16 21:55 ` Thomas Gleixner
2023-10-17 16:33 ` Thomas Gleixner
2023-10-14 14:53 ` [RFC PATCH v3 17/35] Documentation/devicetree/bindings/interrupt-controller: Add renesas,sh7751-irl-ext.yaml Yoshinori Sato
2023-10-14 14:53 ` [RFC PATCH v3 18/35] drivers/tty/serial: sh-sci.c fix SH4 OF support Yoshinori Sato
2023-10-18 8:23 ` Geert Uytterhoeven
2023-10-14 14:53 ` [RFC PATCH v3 19/35] Documentation/devicetree/bindings/serial: renesas,scif.yaml Add SH Yoshinori Sato
2023-10-18 14:04 ` Geert Uytterhoeven
2023-10-14 14:53 ` [RFC PATCH v3 20/35] drivers/mfd: sm501 add some properties Yoshinori Sato
2023-10-18 14:53 ` kernel test robot
2023-10-18 18:14 ` kernel test robot
2023-10-19 11:55 ` Lee Jones
2023-10-14 14:53 ` [RFC PATCH v3 21/35] devicetree/binding/display/sm501fb.txt: sm501fb add properies Yoshinori Sato
2023-10-14 14:53 ` [RFC PATCH v3 22/35] drivers/clocksource/sh_tmu: Add support CLOCKSOURCE Yoshinori Sato
2023-10-18 16:04 ` Geert Uytterhoeven
2023-10-23 11:40 ` Yoshinori Sato [this message]
2023-10-14 14:53 ` [RFC PATCH v3 23/35] Documentation/devicetree/bindings/timer: renesas,tmu.yaml add SH Yoshinori Sato
2023-10-18 19:40 ` Geert Uytterhoeven
2023-10-14 14:53 ` [RFC PATCH v3 24/35] include/dt-binding/interrupt-controller/sh_intc.h: renesas,sh7751-intc.h helper Yoshinori Sato
2023-10-18 13:39 ` Geert Uytterhoeven
2023-10-18 14:03 ` Krzysztof Kozlowski
2023-10-14 14:54 ` [RFC PATCH v3 25/35] Documentation/devicetree/bindings/sh/cpus.yaml: Add SH CPU Yoshinori Sato
2023-10-18 14:27 ` Geert Uytterhoeven
2023-10-25 11:14 ` Yoshinori Sato
2023-10-25 11:33 ` D. Jeff Dionne
2023-10-25 12:04 ` Geert Uytterhoeven
2023-10-25 12:10 ` D. Jeff Dionne
2023-10-25 12:17 ` Geert Uytterhoeven
2023-10-25 12:34 ` D. Jeff Dionne
2023-10-25 12:07 ` Yoshinori Sato
2023-10-25 12:01 ` Geert Uytterhoeven
2023-10-14 14:54 ` [RFC PATCH v3 26/35] arch/sh/boot/dts: SH7751R SoC Internal peripheral definition dtsi Yoshinori Sato
2023-10-19 12:18 ` Geert Uytterhoeven
2023-10-14 14:54 ` [RFC PATCH v3 27/35] Documentation/devicetree/bindings: vendor-prefix add IO DATA DEVICE Inc Yoshinori Sato
2023-10-18 18:43 ` Geert Uytterhoeven
2023-10-14 14:54 ` [RFC PATCH v3 28/35] Documentation/devicetree/bindings/ata: ata-generic.yaml add usl-5p and rts7751r2d Yoshinori Sato
2023-10-15 22:25 ` Damien Le Moal
2023-10-14 14:54 ` [RFC PATCH v3 29/35] Documentation/devicetree/bindings/soc/renesas/sh.yaml: Add SH7751 based target Yoshinori Sato
2023-10-18 18:48 ` Geert Uytterhoeven
2023-10-18 18:49 ` Geert Uytterhoeven
2023-10-18 19:44 ` Geert Uytterhoeven
2023-10-25 11:58 ` Yoshinori Sato
2023-10-25 12:05 ` Yoshinori Sato
2023-10-14 14:54 ` [RFC PATCH v3 30/35] arch/sh/boot/dts: RTS7751R2D Plus DeviceTree Yoshinori Sato
2023-10-19 12:13 ` Geert Uytterhoeven
2023-10-14 14:54 ` [RFC PATCH v3 31/35] arch/sh/boot/dts: LANDISK DeviceTree Yoshinori Sato
2023-10-19 12:14 ` Geert Uytterhoeven
2023-10-14 14:54 ` [RFC PATCH v3 32/35] arch/sh/boot/dts: USL-5P DeviceTree Yoshinori Sato
2023-10-14 14:54 ` [RFC PATCH v3 33/35] arch/sh: Add dtbs target support Yoshinori Sato
2023-10-19 11:54 ` Geert Uytterhoeven
2023-10-14 14:54 ` [RFC PATCH v3 34/35] arch/sh: RTS7751R2D Plus OF defconfig Yoshinori Sato
2023-10-14 14:54 ` [RFC PATCH v3 35/35] arch/sh/configs: LANDISK " Yoshinori Sato
2023-11-07 10:23 ` [RFC PATCH v3 00/35] Device Tree support for SH7751 based board John Paul Adrian Glaubitz
2023-11-08 7:57 ` Yoshinori Sato
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=87wmvd7ejv.wl-ysato@users.sourceforge.jp \
--to=ysato@users.sourceforge.jp \
--cc=geert@linux-m68k.org \
--cc=glaubitz@physik.fu-berlin.de \
--cc=linux-sh@vger.kernel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.