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=1796294009; b=5ICzh/1zqnsA3VVKEDYP56tu4ZH225cJGxwVT/Ui1ipcM9YrOA5LGdX/66Y91HPvE5dY rCF/xyArS2kbTFUpbwu+X+i8OYnZtrzQ+MELlYyGEtHhtqmhOkcXTr0ZLrhBtb3vjqV6O hGVmefB4KAKfXsm1YDySWZN85qPzDsNWfVcsJVtO5OVvL8GdecF8r716GnFXXSA87mCdj HsAKTxFIf2HEbowOALu2BqYQ814WxZjd+wsrXdVZx3SunH/d5M6eabDcJU6KP4DIfDtiC 46wWh1aot8rrBYhuJssMqtFkamh2Y/aLndqgpf4dj1oXsYGTEC0wK2ygohmX72QbwUQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796294009; 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:From:To: Subject:CC:X-Mailer:References:In-Reply-To; bh=kB2syiKhC9bjaU5mqvqd0vum2QBL7/A7IKRA6YwHpsk=; b=jZLwRaknjVSZ2R7O/iHmIpQ5cA60lVmK8ugAWxDijgAapwtlOnK8s/Zo2SIq8SuExr/u HlD8ZBcudnrCqrVkh4iAaB39HpKcVdst2iyZfPKMD0Nsr/A0FbpS8qVr9GNGzW9LrqhDU M45TN4XhUYwg4xu+ZVf7HKouKto7/gVR/SY53VKk4Ao66Mm58/uGZr+D2KqWB4ZlRHn5c NGk7AylO7nEP024KI7pNgyP0OKSMMrT7zv6MDy4xa5L8aPvDnGoU96D7VYAg2WvVbmxNA JhY3i1FcCiBMPVg8uio1lofkUvBxd8U1EpqjR+ysnHlO2gC6fbkRZuqApcd/eEswkqQ== 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=rlJR7016; 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 5FAF5606A322; Thu, 3 Dec 2026 10:33:29 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 5FAF5606A322 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, unprotected) header.d=microchip.com header.i=@microchip.com header.a=rsa-sha256 header.s=mchp header.b=rlJR7016 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1796294009; x=1827830009; h=mime-version:content-transfer-encoding:date:message-id: from:to:subject:cc:references:in-reply-to; bh=IInby7D8VMWvWoBEaoFfCZ0bSrXFDTkNf3KQQYF1ZyM=; b=rlJR7016ce14VQOSX2PJ/Kg35pstPP5EXUlAt/sezNvn77CqfKX3P/8+ 62RlNHcMz/7VSX35RXIYGc46DDU5Rt3Oqgpdn53HvdHMppF6sb64oHWVl lqy/uPDJEC8/vt571CEWEobMXQeQGn/W2WFihEuJMtV2qTMOPYM3hfxuI u6TsHJCDgZXptVttrAQWGeMsGsHV3leFZoWcDG83APDeT9IrNIXdTyZBe RmfChatoJUYUhwYQy3RIfQ8v9KP0rID9cz4s3Bt4qE0+YssrPcpS3pXye mzI33QQTjgCAhp47fuQXSLHkIJLfaKZisf/i2VLuzXvfB2rhYYSsU+zrS A==; X-CSE-ConnectionGUID: dxWyttWfR9uyrPFkS0KKJQ== X-CSE-MsgGUID: yOV6ahdQRSWPTdF94v/C0Q== X-IronPort-AV: E=Sophos;i="6.27,248,1787036400"; d="scan'208";a="78292954" 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-AES256-GCM-SHA384; 03 Dec 2026 03:33:28 -0700 Received: from chn-vm-ex04.mchp-main.com (10.10.87.151) by chn-vm-ex1.mchp-main.com (10.10.87.30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.2.2562.57; Thu, 3 Dec 2026 03:33:28 -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:33:27 -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:33:26 +0100 Message-ID: From: =?utf-8?q?Jens_Emil_Schulz_=C3=98stergaard?= To: Lee Jones , =?utf-8?q?Jens_Emil_Schulz_=C3=98stergaard?= Subject: Re: [PATCH 1/4] mfd: ocelot: Select the chip through match data CC: Colin Foster , , Rob Herring , "Krzysztof Kozlowski" , Conor Dooley , "Richard Cochran" , , , , 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-1-567d811fe1de@microchip.com> <179568560270.32537.14032655101111129070@kernel.org> 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 =C3=98stergaard 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[] =3D { >> + [OCELOT_CHIP_VSC7512] =3D { >> + .cells =3D vsc7512_devs, >> + .num_cells =3D ARRAY_SIZE(vsc7512_devs), >> + }, >> +}; > > Please select the 'mfd_cell' array and its size using a switch() statemen= t 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 =3D 0; i < c->num_cells; i++) > > for (int i =3D 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 en= um 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().