From: "Arnd Bergmann" <arnd@arndb.de>
To: "James Hilliard" <james.hilliard1@gmail.com>,
"Andrew Lunn" <andrew@lunn.ch>
Cc: "Lee Jones" <lee@kernel.org>, "Rob Herring" <robh@kernel.org>,
"Krzysztof Kozlowski" <krzk+dt@kernel.org>,
"Conor Dooley" <conor+dt@kernel.org>,
mfd@lists.linux.dev, devicetree@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v6 2/3] mfd: syscon: Add managed registration for external regmaps
Date: Tue, 11 Aug 2026 13:03:00 +0200 [thread overview]
Message-ID: <7bfb45da-8b67-4fda-844c-e2608c36d539@app.fastmail.com> (raw)
In-Reply-To: <CADvTj4qUEA-ccFj0cSQgHb8+0jB4m6tcpsZZwveZhC_RE8w9vA@mail.gmail.com>
On Tue, Aug 11, 2026, at 11:17, James Hilliard wrote:
> On Tue, Aug 11, 2026 at 2:47 AM Arnd Bergmann <arnd@arndb.de> wrote:
>> I don't think this is the right way to do it. As far as I can tell,
>> the device you have here is a generic mfd that uses a regmap, which
>> is not the same thing we usually call a syscon.
>>
>> The of_syscon_register_regmap() code path was added specifically
>> for chips that have a traditional syscon but depending on the
>> firmware may have to access this by some other means. This is
>> already stretching the definition of syscon. I don't think we
>> should take this further and allow normal device drivers like
>> yours to register through the syscon framework.
>
> This was suggested to me by Andrew:
> https://lore.kernel.org/all/c78c2c35-52e7-4393-9714-06039d8a3f28@lunn.ch/
Maybe Andrew can clarify, but his reply can also be interpreted
as saying that you should copy syscon_regmap_lookup_by_phandle()
into your own driver, rather than changing the actual
syscon code.
One problem I see with your current approach is that the lifetime of
the regmap is not the lifetime of the user by the framework.
Unloading the mfd driver while the phy driver is in use will
destroy the regmap. This is a direct result of syscon being
a very special case that must work during early boot instead
of being a general-purpose abstraction for managing regmaps.
>> Since you already have a top-level mfd device here, just use
>> that to pass the regmap to the child devices like we do for
>> other mfd drivers. You can e.g. do this when populating the child
>> devices through platform_data, or get the pointer from the
>> parent drvdata.
>
> The EPHY is not an MFD-created platform child. Phylib enumerates it as a
> struct phy_device on the SoC MDIO bus, so its device parent is the
> struct mii_bus rather than the AC200 I2C device. It therefore cannot
> directly obtain the AC200 regmap through parent drvdata or MFD child
> platform data.
I see, so the fundamental problem here is that you have a single
device that is connected to two buses and both the OF devicetree
and the Linux driver model are rather bad at handling this.
I would probably do this in one of two ways:
a) have a driver module that registers both a phy driver and
a platform_driver and figures out the interaction between
them internally.
b) have the MFD driver export a private interface that lets
the phy_driver interact with the i2c registers and
make sure the i2c_driver sets suppress_bind_attrs=true
to prevent it from being unbound while the phy_driver
is loaded. The symbol dependency itself is enough to
prevent the mfd driver from being unloaded here.
In either case, you still have the choice between a proper
abstraction that can deal with multiple instances of the
ac200 device, or slightly cheaty but common assumption that
only one of them can ever be present.
Arnd
next prev parent reply other threads:[~2026-08-11 11:03 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-11 8:27 [PATCH v6 0/3] mfd: add X-Powers AC200 support James Hilliard
2026-08-11 8:27 ` [PATCH v6 1/3] dt-bindings: mfd: x-powers: Add AC200 James Hilliard
2026-08-11 8:27 ` [PATCH v6 2/3] mfd: syscon: Add managed registration for external regmaps James Hilliard
2026-08-11 8:46 ` Arnd Bergmann
2026-08-11 9:17 ` James Hilliard
2026-08-11 11:03 ` Arnd Bergmann [this message]
2026-08-11 8:27 ` [PATCH v6 3/3] mfd: ac200: Add X-Powers AC200 support James Hilliard
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=7bfb45da-8b67-4fda-844c-e2608c36d539@app.fastmail.com \
--to=arnd@arndb.de \
--cc=andrew@lunn.ch \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=james.hilliard1@gmail.com \
--cc=krzk+dt@kernel.org \
--cc=lee@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mfd@lists.linux.dev \
--cc=robh@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