From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=68.232.153.233 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796294831; b=s+qMvHWkfLz49x3Hoc2iK3il7Dh900sgnwHXFZwGAXwewlEJM0uBgVWthwkvQLhFuafY ahquKi6+vV+XZwTD+YgmjQNklzs+O4lGNAFoV2wzPZtQPVsHwfMnABGxggLyyKvfOZ4h8 P14GASzGBbCrsA73ptuSKpD6SjtEwacg1iw2tdRJctga9WsJeTrMgarosB1Ye7whnWB8q I46ouvJW8Uhz4FW13n004O8aexDIm5gOuJmg7suy07Bp7Q8/8kixD7RAlQZODuqQqxq7a Bn7h836jWfBES5XuUicURilwapsWdnhCoBku2Zbi+WEgO7OPAvfh8Gv5zvdAwcZHajw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796294831; h=DMARC-Filter:DKIM-Signature:X-CSE-ConnectionGUID:X-CSE-MsgGUID: X-IronPort-AV:X-Amp-Result:Received:Received:Received:MIME-Version: Content-Transfer-Encoding:Content-Type:Date:Message-ID:Subject:CC: From:To:X-Mailer:References:In-Reply-To; bh=+nqqu8B3pixAB03kb75aCudayfl3akSdiz9sc5gBGuw=; b=Hy480t+FAAhGk216Z+qLB3IffIemXgAT+Hl1TCHx0B2R0YPv8fiajgLGyIAh0+qk50Cf laBtx3HKDWjiMazS3nw73ZYluS4r7K3APkxm+dX/rIXZns/K0qpj9AOwZ/JB33Dl/njek An74Qf8FrWHDI4/KhNsCr6aSqWM8MniowAiW/aSiCBNomp1114W2dZhiP87iIudf381ok HwRV+Yi9xVzmK7jxfNwenGTIoIn6PpLvyRJfTIOd0SwUH7+Ra3WVQqQ8BDC/1jOlR9zYJ hFuXetjnBrDruD8asVFCAxtRVeUJcFl2aL7D0Y1snYCwGtKzpYQEttx0nnbYToMIBAw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=microchip.com; spf=pass smtp.mailfrom=microchip.com; dkim=pass header.d=microchip.com header.i=@microchip.com header.a=rsa-sha256 header.s=mchp header.b=yyfTM0TU; arc=none smtp.remote-ip=68.232.153.233 Received: from esa.microchip.iphmx.com (esa.microchip.iphmx.com [68.232.153.233]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 11836606A322; Thu, 3 Dec 2026 10:47:10 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 11836606A322 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=microchip.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=microchip.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=microchip.com header.i=@microchip.com header.a=rsa-sha256 header.s=mchp header.b=yyfTM0TU DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1796294830; x=1827830830; h=mime-version:content-transfer-encoding:date:message-id: subject:cc:from:to:references:in-reply-to; bh=XIlBOaZCe+W5w0pFfAmCAPYz7lcyuYK5PiuNVH0I/XU=; b=yyfTM0TUjlpfby+dhvZSNyF5nzRINx27SHoqSR0bab6D7NDGQbyv3OeX 0fQ3ZaAh4U6ndlYujfy4CPV1/zb0RvZRsTjyB2eiVLBNAsva9mvrJ5Zok 37a+/ebLvyi/H+ZfIeZjKaE+PcNgPh8EZqdpNFy/CB1px+j1NpvprSb7Q 21zFW4V3mwvcwP75f/UYEXf82cgbTBmdrp7IS5usDkkAafA9b8W1AcBgG CFyp3+k6jWOF5J5ySB/0ic8CuBkHjHCys3Vrlt0CdEU+h42q2SzxkT9EC VKrv/v2Xn+3A2QLFwm3I6/E7PAv5gbpoEiG/gAyS5mauLCGz2J+i6B4Xv Q==; X-CSE-ConnectionGUID: 7n9TEpZZQ5S0gr0JYP/m5Q== X-CSE-MsgGUID: THL3bBNmSSqVi8uzt98giQ== X-IronPort-AV: E=Sophos;i="6.27,248,1787036400"; d="scan'208";a="78293472" X-Amp-Result: SKIPPED(no attachment in message) Received: from unknown (HELO email.microchip.com) ([170.129.1.10]) by esa1.microchip.iphmx.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 03 Dec 2026 03:47:10 -0700 Received: from chn-vm-ex04.mchp-main.com (10.10.85.152) by chn-vm-ex02.mchp-main.com (10.10.85.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.58; Thu, 3 Dec 2026 03:47:09 -0700 Received: from localhost (10.10.85.11) by chn-vm-ex04.mchp-main.com (10.10.85.152) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.58 via Frontend Transport; Thu, 3 Dec 2026 03:47:09 -0700 X-Mailing-List: devicetree@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="UTF-8" Date: Thu, 3 Dec 2026 11:47:07 +0100 Message-ID: Subject: Re: [PATCH 3/4] mfd: ocelot: Add support for the LAN9645x switch family CC: Colin Foster , , Rob Herring , "Krzysztof Kozlowski" , Conor Dooley , "Richard Cochran" , , , , From: =?utf-8?q?Jens_Emil_Schulz_=C3=98stergaard?= To: Lee Jones , =?utf-8?q?Jens_Emil_Schulz_=C3=98stergaard?= X-Mailer: aerc 0.21.0 References: <20261123-mfd-ocelot-add-lan9645x-support-v1-0-567d811fe1de@microchip.com> <20261123-mfd-ocelot-add-lan9645x-support-v1-3-567d811fe1de@microchip.com> <20261202132826.GB43081@kernel.org> 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[] =3D { >> + { >> + .name =3D "lan9645x-pinctrl", >> + .of_compatible =3D "microchip,lan96455f-pinctrl", >> + .num_resources =3D ARRAY_SIZE(lan9645x_pinctrl_resources), >> + .resources =3D lan9645x_pinctrl_resources, >> + }, { >> + .name =3D "lan9645x-miim0", >> + .of_compatible =3D "microchip,lan966x-miim", >> + .of_reg =3D LAN9645X_MIIM0_RES_START, >> + .use_of_reg =3D true, >> + .num_resources =3D ARRAY_SIZE(lan9645x_miim0_resources), >> + .resources =3D lan9645x_miim0_resources, >> + }, { >> + .name =3D "lan9645x-miim1", >> + .of_compatible =3D "microchip,lan966x-miim", >> + .of_reg =3D LAN9645X_MIIM1_RES_START, >> + .use_of_reg =3D true, >> + .num_resources =3D ARRAY_SIZE(lan9645x_miim1_resources), >> + .resources =3D lan9645x_miim1_resources, >> + }, { >> + .name =3D "lan9645x-switch", >> + .of_compatible =3D "microchip,lan96455s-switch", >> + .num_resources =3D ARRAY_SIZE(lan9645x_switch_resources), >> + .resources =3D 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[] =3D { >> + { >> + .name =3D "gcb", >> + .rd_table =3D &lan9645x_gcb_rd_table, >> + .wr_table =3D &lan9645x_gcb_wr_table, >> + }, { >> + .name =3D "chip_top", >> + .rd_table =3D &lan9645x_chip_top_table, >> + .wr_table =3D &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. [...]