From: Vladimir Oltean <vladimir.oltean@nxp.com>
To: Colin Foster <colin.foster@in-advantage.com>
Cc: Andy Shevchenko <andy.shevchenko@gmail.com>,
"devicetree@vger.kernel.org" <devicetree@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"netdev@vger.kernel.org" <netdev@vger.kernel.org>,
"linux-arm-kernel@lists.infradead.org"
<linux-arm-kernel@lists.infradead.org>,
"linux-gpio@vger.kernel.org" <linux-gpio@vger.kernel.org>,
Lee Jones <lee.jones@linaro.org>,
Rob Herring <robh+dt@kernel.org>,
Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>,
Andrew Lunn <andrew@lunn.ch>,
Heiner Kallweit <hkallweit1@gmail.com>,
Russell King <linux@armlinux.org.uk>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Lars Povlsen <lars.povlsen@microchip.com>,
Steen Hegelund <Steen.Hegelund@microchip.com>,
"UNGLinuxDriver@microchip.com" <UNGLinuxDriver@microchip.com>,
Linus Walleij <linus.walleij@linaro.org>,
Wolfram Sang <wsa@kernel.org>,
Terry Bowman <terry.bowman@amd.com>,
Alexandre Belloni <alexandre.belloni@bootlin.com>,
Arnd Bergmann <arnd@kernel.org>
Subject: Re: [PATCH v11 net-next 1/9] mfd: ocelot: add helper to get regmap from a resource
Date: Sat, 2 Jul 2022 12:42:06 +0000 [thread overview]
Message-ID: <20220702124205.53fqq65b24im2ilv@skbuf> (raw)
In-Reply-To: <20220701171831.GA3327062@euler>
On Fri, Jul 01, 2022 at 10:18:31AM -0700, Colin Foster wrote:
> While I have your ear: do I need to check for dev->parent == NULL before
> calling dev_get_regmap? I see find_dr will call
> (dev->parent)->devres_head... but specifically "does every device have a
> valid parent?"
While the technical answer is "no", the practical answer is "pretty much".
Platform devices sit at least on the "platform" bus created in drivers/base/platform.c,
and they are reparented to the "platform_bus" struct device named "platform"
within platform_device_add(), if they don't have a parent.
Additionally, for MMIO-controlled platform devices in Ocelot, these have
as parent a platform device probed by the drivers/bus/simple-pm-bus.c
driver on the "ahb@70000000" simple-bus OF node. That simple-bus
platform device has as parent the "platform_bus" device mentioned above.
So it's a pretty long way to the top in the device hierarchy, I wouldn't
concern myself too much with checking for NULL, unless you intend to
call dev_get_regmap() on a parent's parent's parent, or things like that.
> > > }
> > >
> > > So now there's no need for #if (CONFIG_MFD_OCELOT) - it can just remain
> > > an inline helper function. And so long as ocelot_core_init does this:
> > >
> > > static void ocelot_core_try_add_regmap(struct device *dev,
> > > const struct resource *res)
> > > {
> > > if (!dev_get_regmap(dev, res->name)) {
> > > ocelot_spi_init_regmap(dev, res);
> > > }
> > > }
> > >
> > > static void ocelot_core_try_add_regmaps(struct device *dev,
> > > const struct mfd_cell *cell)
> > > {
> > > int i;
> > >
> > > for (i = 0; i < cell->num_resources; i++) {
> > > ocelot_core_try_add_regmap(dev, &cell->resources[i]);
> > > }
> > > }
> > >
> > > int ocelot_core_init(struct device *dev)
> > > {
> > > int i, ndevs;
> > >
> > > ndevs = ARRAY_SIZE(vsc7512_devs);
> > >
> > > for (i = 0; i < ndevs; i++)
> > > ocelot_core_try_add_regmaps(dev, &vsc7512_devs[i]);
> >
> > Dumb question, why just "try"?
>
> Because of this conditional:
> > > if (!dev_get_regmap(dev, res->name)) {
> Don't add it if it is already there.
Hmm. So that's because you add regmaps iterating by the resource table
of each device. What if you keep a single resource table for regmap
creation purposes, and the device resource tables as separate?
> This might get interesting... The soc uses the HSIO regmap by way of
> syscon. Among other things, drivers/phy/mscc/phy-ocelot-serdes.c. If
> dev->parent has all the regmaps, what role does syscon play?
>
> But that's a problem for another day...
Interesting question. I think part of the reason why syscon exists is to
not have OF nodes with overlapping address regions. In that sense, its
need does not go away here - I expect the layout of OF nodes beneath the
ocelot SPI device to be the same as their AHB variants. But in terms of
driver implementation, I don't know. Even if the OF nodes for your MFD
functions will contain all the regs that their AHB variants do, I'd
personally still be inclined to also hardcode those as resources in the
ocelot mfd parent driver and use those - case in which the OF regs will
more or less exist just as a formality. Maybe because the HSIO syscon is
already compatible with "simple-mfd", devices beneath it should just
probe. I haven't studied how syscon_node_to_regmap() behaves when the
syscon itself is probed as a MFD function. If that "just works", then
the phy-ocelot-serdes.c driver might not need to be modified.
next prev parent reply other threads:[~2022-07-02 12:42 UTC|newest]
Thread overview: 41+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-28 8:17 [PATCH v11 net-next 0/9] add support for VSC7512 control over SPI Colin Foster
2022-06-28 8:17 ` [PATCH v11 net-next 1/9] mfd: ocelot: add helper to get regmap from a resource Colin Foster
2022-06-28 12:50 ` Andy Shevchenko
2022-06-28 15:33 ` Vladimir Oltean
2022-06-28 16:08 ` Vladimir Oltean
2022-06-28 17:25 ` Colin Foster
2022-06-28 18:47 ` Vladimir Oltean
2022-06-28 18:56 ` Vladimir Oltean
2022-06-28 19:04 ` Andy Shevchenko
2022-06-28 19:56 ` Colin Foster
2022-06-29 17:53 ` Vladimir Oltean
2022-06-29 20:39 ` Colin Foster
2022-06-29 23:08 ` Vladimir Oltean
2022-06-29 23:54 ` Colin Foster
2022-06-30 7:54 ` Lee Jones
2022-06-30 13:11 ` Vladimir Oltean
2022-06-30 20:09 ` Colin Foster
2022-07-01 16:21 ` Vladimir Oltean
2022-07-01 17:18 ` Colin Foster
2022-07-02 12:42 ` Vladimir Oltean [this message]
2022-07-02 16:17 ` Colin Foster
2022-06-28 8:17 ` [PATCH v11 net-next 2/9] net: mdio: mscc-miim: add ability to be used in a non-mmio configuration Colin Foster
2022-06-28 16:26 ` Vladimir Oltean
2022-06-28 18:31 ` Colin Foster
2022-06-28 8:17 ` [PATCH v11 net-next 3/9] pinctrl: ocelot: allow pinctrl-ocelot to be loaded as a module Colin Foster
2022-06-28 12:53 ` Andy Shevchenko
2022-06-28 18:25 ` Colin Foster
2022-06-28 19:00 ` Andy Shevchenko
2022-06-30 11:56 ` Linus Walleij
2022-06-28 8:17 ` [PATCH v11 net-next 4/9] pinctrl: ocelot: add ability to be used in a non-mmio configuration Colin Foster
2022-06-28 8:17 ` [PATCH v11 net-next 5/9] pinctrl: microchip-sgpio: allow sgpio driver to be used as a module Colin Foster
2022-06-28 12:55 ` Andy Shevchenko
2022-06-28 8:17 ` [PATCH v11 net-next 6/9] pinctrl: microchip-sgpio: add ability to be used in a non-mmio configuration Colin Foster
2022-06-28 8:17 ` [PATCH v11 net-next 7/9] resource: add define macro for register address resources Colin Foster
2022-06-28 8:17 ` [PATCH v11 net-next 8/9] dt-bindings: mfd: ocelot: add bindings for VSC7512 Colin Foster
2022-06-28 13:15 ` Rob Herring
2022-06-28 18:19 ` Colin Foster
2022-06-30 13:17 ` Vladimir Oltean
2022-06-28 8:17 ` [PATCH v11 net-next 9/9] mfd: ocelot: add support for the vsc7512 chip via spi Colin Foster
2022-06-28 20:07 ` Randy Dunlap
2022-06-28 20:24 ` Colin Foster
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=20220702124205.53fqq65b24im2ilv@skbuf \
--to=vladimir.oltean@nxp.com \
--cc=Steen.Hegelund@microchip.com \
--cc=UNGLinuxDriver@microchip.com \
--cc=alexandre.belloni@bootlin.com \
--cc=andrew@lunn.ch \
--cc=andy.shevchenko@gmail.com \
--cc=arnd@kernel.org \
--cc=colin.foster@in-advantage.com \
--cc=davem@davemloft.net \
--cc=devicetree@vger.kernel.org \
--cc=edumazet@google.com \
--cc=hkallweit1@gmail.com \
--cc=krzysztof.kozlowski+dt@linaro.org \
--cc=kuba@kernel.org \
--cc=lars.povlsen@microchip.com \
--cc=lee.jones@linaro.org \
--cc=linus.walleij@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=robh+dt@kernel.org \
--cc=terry.bowman@amd.com \
--cc=wsa@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 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).