Devicetree
 help / color / mirror / Atom feed
From: "Jens Emil Schulz Østergaard" <jensemil.schulzostergaard@microchip.com>
To: "Lee Jones" <lee@kernel.org>,
	"Jens Emil Schulz Østergaard"
	<jensemil.schulzostergaard@microchip.com>
Cc: Colin Foster <colin.foster@in-advantage.com>,
	<UNGLinuxDriver@microchip.com>, Rob Herring <robh@kernel.org>,
	"Krzysztof Kozlowski" <krzk+dt@kernel.org>,
	Conor Dooley <conor+dt@kernel.org>,
	"Richard Cochran" <richardcochran@gmail.com>,
	<mfd@lists.linux.dev>, <linux-kernel@vger.kernel.org>,
	<netdev@vger.kernel.org>, <devicetree@vger.kernel.org>
Subject: Re: [PATCH 3/4] mfd: ocelot: Add support for the LAN9645x switch family
Date: Thu, 3 Dec 2026 11:47:07 +0100	[thread overview]
Message-ID: <DNB1DFQSQS54.1RP7Q0NT4TAGI@microchip.com> (raw)
In-Reply-To: <20261202132826.GB43081@kernel.org>

On Wed Dec 2, 2026 at 2:28 PM CET, Lee Jones wrote:

[...]

>> +static const struct mfd_cell lan9645x_devs[] = {
>> +	{
>> +		.name = "lan9645x-pinctrl",
>> +		.of_compatible = "microchip,lan96455f-pinctrl",
>> +		.num_resources = ARRAY_SIZE(lan9645x_pinctrl_resources),
>> +		.resources = lan9645x_pinctrl_resources,
>> +	}, {
>> +		.name = "lan9645x-miim0",
>> +		.of_compatible = "microchip,lan966x-miim",
>> +		.of_reg = LAN9645X_MIIM0_RES_START,
>> +		.use_of_reg = true,
>> +		.num_resources = ARRAY_SIZE(lan9645x_miim0_resources),
>> +		.resources = lan9645x_miim0_resources,
>> +	}, {
>> +		.name = "lan9645x-miim1",
>> +		.of_compatible = "microchip,lan966x-miim",
>> +		.of_reg = LAN9645X_MIIM1_RES_START,
>> +		.use_of_reg = true,
>> +		.num_resources = ARRAY_SIZE(lan9645x_miim1_resources),
>> +		.resources = lan9645x_miim1_resources,
>> +	}, {
>> +		.name = "lan9645x-switch",
>> +		.of_compatible = "microchip,lan96455s-switch",
>> +		.num_resources = ARRAY_SIZE(lan9645x_switch_resources),
>> +		.resources = lan9645x_switch_resources,
>> +	},
>> +};
>
> MFD_CELL_*

Will do.

[...]

>> +struct ocelot_regmap_access {
>> +	const char *name;
>> +	const struct regmap_access_table *rd_table;
>> +	const struct regmap_access_table *wr_table;
>> +};
>> +
>> +static const struct ocelot_regmap_access lan9645x_regmap_access[] = {
>> +	{
>> +		.name = "gcb",
>> +		.rd_table = &lan9645x_gcb_rd_table,
>> +		.wr_table = &lan9645x_gcb_wr_table,
>> +	}, {
>> +		.name = "chip_top",
>> +		.rd_table = &lan9645x_chip_top_table,
>> +		.wr_table = &lan9645x_chip_top_table,
>> +	},
>> +};
>> +
>>  struct ocelot_cells {
>>  	const struct mfd_cell *cells;
>>  	unsigned int num_cells;
>> +	const struct ocelot_regmap_access *access;
>
> I'm more than a little perturbed by all of these ocelot structs of
> structs, etc.  Surely there's a better way to represent than this?
>
> What about instead of indexing into an array of 'struct ocelot_cells'
> wrapper structs and string-matching resource names against a separate
> 'struct ocelot_regmap_access' array, we can select the 'mfd_cell' array
> directly with a switch() on an integer provided via .data in
> ocelot_core_init().

Agreed. With the changes to patch 1 the cells are selected with a
switch() on the chip passed through .data, and struct ocelot_cells is
gone. This patch only adds the LAN9645x case.

>
> However, the bigger issue: why is the MFD core driver creating 27
> device-specific regmaps (and encoding child-specific register access
> restriction tables like 'FEAT_DISABLE' and 'CUPHY_LED_CFG') on behalf of
> its children in the first place?  In MFD, resources that are not shared
> between multiple children should be initialised by the child drivers
> that actually use them.

The access tables were only there to keep the switch driver away from
the registers of the other children. v2 drops them together with
struct ocelot_regmap_access, and the switch driver only accesses the
registers it uses.

The LAN9645x children follow the pattern established for the VSC7512.
The child drivers were written for memory mapped targets, with register
offsets relative to the target. The child drivers cannot create a regmap
on the SPI bus themselves, so the core creates one regmap per resource.

mdio-mscc-miim, pinctrl-ocelot and pinctrl-microchip-sgpio get theirs
with ocelot_regmap_from_resource(), which takes the resource of the
child by index and returns the regmap the parent created for it. The
LAN9645x support reuses mdio-mscc-miim and pinctrl-ocelot. The LAN9645x
switch driver gets its regmaps from the parent by name, same as felix does
for the VSC7512 switch.

[...]


  reply	other threads:[~2026-12-03 10:47 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-23 13:25 [PATCH 0/4] mfd: ocelot: Support the LAN9645x switch family Jens Emil Schulz Østergaard
2026-11-23 13:25 ` [PATCH 1/4] mfd: ocelot: Select the chip through match data Jens Emil Schulz Østergaard
2026-12-02 12:34   ` Lee Jones
2026-12-03 10:33     ` Jens Emil Schulz Østergaard
2026-11-23 13:25 ` [PATCH 2/4] dt-bindings: mfd: Add the Microchip LAN9645x switch family Jens Emil Schulz Østergaard
2026-11-23 13:25 ` [PATCH 3/4] mfd: ocelot: Add support for the " Jens Emil Schulz Østergaard
2026-12-02 13:28   ` Lee Jones
2026-12-03 10:47     ` Jens Emil Schulz Østergaard [this message]
2026-11-23 13:25 ` [PATCH 4/4] mfd: ocelot: Read LAN9645x registers in a single SPI transfer Jens Emil Schulz Østergaard
2026-12-02 13:35   ` Lee Jones
2026-12-03 10:54     ` Jens Emil Schulz Østergaard

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=DNB1DFQSQS54.1RP7Q0NT4TAGI@microchip.com \
    --to=jensemil.schulzostergaard@microchip.com \
    --cc=UNGLinuxDriver@microchip.com \
    --cc=colin.foster@in-advantage.com \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=krzk+dt@kernel.org \
    --cc=lee@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mfd@lists.linux.dev \
    --cc=netdev@vger.kernel.org \
    --cc=richardcochran@gmail.com \
    --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