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 1/4] mfd: ocelot: Select the chip through match data
Date: Thu, 3 Dec 2026 11:33:26 +0100	[thread overview]
Message-ID: <DNB12YEJ8J0F.Z66NFYUHGS5O@microchip.com> (raw)
In-Reply-To: <179568560270.32537.14032655101111129070@kernel.org>

On Wed Dec 2, 2026 at 1:34 PM CET, Lee Jones wrote:
> On Mon, 23 Nov 2026, Jens Emil Schulz Østergaard wrote:
>
>> The SPI interface bootstrap, the chip reset and the child devices are
>> hardcoded for the VSC7512. Describe the serial interface configuration
>> target, its registers, the IF_CFGSTAT readback check and the padding
>> byte calculation in SPI match data, and select the soft reset register
>> and the child devices in the core by the chip it names. This prepares
>> for adding the LAN9645x switch family.
>
> I support the idea, just not the implementation.

Thanks for the review.

[...]

>> +struct ocelot_cells {
>> +	const struct mfd_cell *cells;
>> +	unsigned int num_cells;
>> +};
>> +
>> +static const struct ocelot_cells ocelot_cells[] = {
>> +	[OCELOT_CHIP_VSC7512] = {
>> +		.cells = vsc7512_devs,
>> +		.num_cells = ARRAY_SIZE(vsc7512_devs),
>> +	},
>> +};
>
> Please select the 'mfd_cell' array and its size using a switch() statement on
> 'ddata->chip' inside ocelot_core_init() rather than introducing a wrapper struct
> and an array of arrays.
>
> Also, we already have helpers for you in:
>
>   include/linux/mfd/core.h

Will do. In v2 ocelot_core_init() selects the cells with a switch() on
ddata->chip, and the soft reset register is selected the same way
instead of through the ocelot_soft_rst[] table. A separate patch before
this one will convert the existing VSC7512 cells to MFD_CELL_OF() and
MFD_CELL_OF_REG().

[...]

>> +	for (i = 0; i < c->num_cells; i++)
>
> for (int i = 0; ...

Will do.

[...]

>
>> -static int ocelot_spi_initialize(struct device *dev)
>> +struct ocelot_spi_data {
>
> May I suggest that we ditch this pdata strategy and assign these based
> off of an integer that you pass through .data?

Yes, in the next version the OF and SPI match tables will only carry the enum
ocelot_chip value, and the probe sets the chip specific values in a
switch() on it.

>
>> +	enum ocelot_chip chip;
>> +	const struct resource *cpuorg_res;
>> +	unsigned int if_ctrl;
>> +	unsigned int if_cfgstat;
>> +	u32 if_cfgstat_si;
>> +	const struct resource *gcb_res;
>> +	int (*padding_bytes)(u32 max_speed_hz);
>
> Function pointers at driver-level give me the ick.
>
> Again, if there is no other way to do this other than in a function, you
> can call it from within the correct case of the switch() suggested
> above.  This way you can keep all of the chip specific logic together in
> a coherent space.

Understood, the padding calculation will be called from the case of
the chip in that switch().

  reply	other threads:[~2026-12-03 10:33 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 [this message]
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
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=DNB12YEJ8J0F.Z66NFYUHGS5O@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