[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <YmhmXl5IWHmKzAyG@robh.at.kernel.org>
Date: Tue, 26 Apr 2022 16:38:38 -0500
From: Rob Herring <robh@...nel.org>
To: Arnd Bergmann <arnd@...db.de>
Cc: Linus Walleij <linus.walleij@...aro.org>,
"Hawkins, Nick" <nick.hawkins@....com>,
"Verdun, Jean-Marie" <verdun@....com>,
Joel Stanley <joel@....id.au>,
OpenBMC Maillist <openbmc@...ts.ozlabs.org>,
Daniel Lezcano <daniel.lezcano@...aro.org>,
Thomas Gleixner <tglx@...utronix.de>,
Linux Kernel Mailing List <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH v5 04/11] clocksource/drivers: Add HPE GXP timer
On Tue, Apr 26, 2022 at 08:00:20AM +0200, Arnd Bergmann wrote:
> On Mon, Apr 25, 2022 at 10:38 PM Linus Walleij <linus.walleij@...aro.org> wrote:
> > On Fri, Apr 22, 2022 at 3:16 PM Arnd Bergmann <arnd@...db.de> wrote:
> > > On Thu, Apr 21, 2022 at 9:21 PM <nick.hawkins@....com> wrote:
> > >
> > > > +
> > > > +static struct platform_device gxp_watchdog_device = {
> > > > + .name = "gxp-wdt",
> > > > + .id = -1,
> > > > +};
> > > > +/*
> > > > + * This probe gets called after the timer is already up and running. This will create
> > > > + * the watchdog device as a child since the registers are shared.
> > > > + */
> > > > +
> > > > +static int gxp_timer_probe(struct platform_device *pdev)
> > > > +{
> > > > + struct device *dev = &pdev->dev;
> > > > +
> > > > + /* Pass the base address (counter) as platform data and nothing else */
> > > > + gxp_watchdog_device.dev.platform_data = local_gxp_timer->counter;
> > > > + gxp_watchdog_device.dev.parent = dev;
> > > > + return platform_device_register(&gxp_watchdog_device);
> > > > +}
> > >
> > > I don't understand what this is about: the device should be created from
> > > DT, not defined statically in the code. There are multiple ways of creating
> > > a platform_device from a DT node, or you can allocate one here, but static
> > > definitions are generally a mistake.
> > >
> > > I see that you copied this from the ixp4xx driver, so I think we should fix this
> > > there as well.
> >
> > The ixp4xx driver looks like that because the register range used for
> > the timer and the watchdog is combined, i.e. it is a single IP block:
> >
> > timer@...05000 {
> > compatible = "intel,ixp4xx-timer";
> > reg = <0xc8005000 0x100>;
> > interrupts = <5 IRQ_TYPE_LEVEL_HIGH>;
> > };
> >
> > Device tree probing does not allow two devices to probe from the same
> > DT node, so this was solved by letting the (less important) watchdog
> > be spawn as a platform device from the timer.
> >
> > I don't know if double-probing for the same register range can be fixed,
> > but I was assuming that the one-compatible-to-one-driver assumption
> > was pretty hard-coded into the abstractions. Maybe it isn't?
>
> Having a child device is fine, my objection was about the way
> the device is created from a 'static platform_device ...' definition
> rather than having the device structure allocated at probe time.
>
> > Another way is of course to introduce an MFD. That becomes
> > problematic in another way: MFD abstractions are supposed to
> > be inbetween the resource and the devices it spawns, and with
> > timers/clocksources this creates a horrible special-casing since the
> > MFD bus (the parent may be providing e.g. an MMIO regmap)
> > then need to be early-populated and searched by the timer core
> > from TIMER_OF_DECLARE() early in boot.
> >
> > So this solution was the lesser evil that I could think about.
>
> There are multiple ways of doing this that we already discussed
> in the thread. The easiest is probably to have a child node without
> custom registers in the DT and then use the DT helpers to
> populate the linux devices with the correct data.
I think that's what the wdt binding is doing, but I don't like that.
Maybe it's not a child node, I can't tell.
Bindings should not be decided on the *current* driver split on one
particular OS. This looks like 1 block, so 1 node. If that doesn't work
well or easy for Linux, then we should fix Linux.
Rob
Powered by blists - more mailing lists