From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id A7E84CD5BB1 for ; Thu, 21 May 2026 13:24:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:In-Reply-To: Content-Transfer-Encoding:Content-Type:MIME-Version:References:Message-ID: Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=6mNExNFm3zMGc4yL+55czjAtplM3YZBBXYf2rNEsSlU=; b=FYEQFib0S6aRffTtf62WU2i0Lh qpj2SFpRvnKqgRKawOq4tMEEEph8ILqoUfQHpQ+RXgp+/I0aw/U+7M/RV1owsyd/v3BwVaWUm/4Jj xwcMWwHGCIUwSUD325xMYbSYHdIBySF3Jgw1xLNs4GsytCV8ZPEqwue9MEFYJXMOYoIm3rEoCXotD SZ85gGg3O/7/d6NaYHbrWc+uNTulPp6SRlauF/SkODINmcsovcnhS1f++ZyxHLffGgbYRl7VXt0yr BSDpvkDB9pFhbBr27wN41H2kjF8yc4HKPq7s5Dzg6T7SBxAZfRP6sT1BVIyX70JFLEnJvDGU/N/E3 lI4xpfKw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.99.1 #2 (Red Hat Linux)) id 1wQ3O3-00000007rZC-2ASC; Thu, 21 May 2026 13:24:31 +0000 Received: from tor.source.kernel.org ([2600:3c04:e001:324:0:1991:8:25]) by bombadil.infradead.org with esmtps (Exim 4.99.1 #2 (Red Hat Linux)) id 1wQ3O2-00000007rZ2-01K6 for linux-arm-kernel@lists.infradead.org; Thu, 21 May 2026 13:24:30 +0000 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by tor.source.kernel.org (Postfix) with ESMTP id 75BA2601F3; Thu, 21 May 2026 13:24:29 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4B6601F000E9; Thu, 21 May 2026 13:24:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1779369869; bh=6mNExNFm3zMGc4yL+55czjAtplM3YZBBXYf2rNEsSlU=; h=Date:From:To:Cc:Subject:References:In-Reply-To; b=Wt1gJ/L/Ii/r0CNslJdXGcSk0iV5uUteyjluNNTVkUvbTYhiFQOBa179autMJ8DaT rhzwTncC/HoMx0iAasauSJOP9VxM0xMFY60XaWN2zyPst0/EDXFWXKotcSNWHuYpcb QQf4S9NwA6iVFXQ9CbX6XWtv8c4P5f54HMPPog2c7nRKFMrJZAoV4KW9yMU0cxUzNc VFECRBDC8SqMVQNN3dAgzZKW/5g7qqMvIiAtglPUkhFgPYL+IHBkqU+G4k/dlKbDr/ zg/KERKK9/CJYJj6OpqQKaafJbdGt1CFwqYEpEqBW2+lVyI0Isvl/bafhSjLi6ZtGT i7QNGdNVDJaTw== Date: Thu, 21 May 2026 14:24:19 +0100 From: Lee Jones To: Bartosz Golaszewski Cc: Shivendra Pratap , Sebastian Reichel , Mark Rutland , Lorenzo Pieralisi , "Rafael J. Wysocki" , Daniel Lezcano , Christian Loehle , Ulf Hansson , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Bjorn Andersson , Konrad Dybcio , Arnd Bergmann , Souvik Chakravarty , Andy Yan , Matthias Brugger , John Stultz , Moritz Fischer , Sudeep Holla , linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org, Florian Fainelli , Krzysztof Kozlowski , Dmitry Baryshkov , Mukesh Ojha , Andre Draszik , Greg Kroah-Hartman , Kathiravan Thirumoorthy , Srinivas Kandagatla , Bartosz Golaszewski Subject: Re: [PATCH v22 08/13] mfd: core: Add firmware-node support to MFD cells Message-ID: <20260521132419.GA3591266@google.com> References: <20260514-arm-psci-system_reset2-vendor-reboots-v22-0-28a5bde07483@oss.qualcomm.com> <20260514-arm-psci-system_reset2-vendor-reboots-v22-8-28a5bde07483@oss.qualcomm.com> <20260521112638.GD2921053@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Thu, 21 May 2026, Bartosz Golaszewski wrote: > On Thu, May 21, 2026 at 1:26 PM Lee Jones wrote: > > > > On Thu, 14 May 2026, Shivendra Pratap wrote: > > > > > MFD core has no way to register a child device using an explicit firmware > > > node. This prevents drivers from registering child nodes when those nodes > > > do not define a compatible string. One such example is the PSCI > > > "reboot-mode" node, which omits a compatible string as it describes > > > boot-states provided by the underlying firmware. > > > > > > Extend struct mfd_cell with a callback that allows drivers to provide an > > > explicit firmware node. The node is added to the MFD child device during > > > registration when none is assigned by device tree, ACPI, or software > > > matching. > > > > > > Suggested-by: Bartosz Golaszewski > > > Signed-off-by: Shivendra Pratap > > > --- > > > drivers/mfd/mfd-core.c | 30 ++++++++++++++++++++++++++++++ > > > include/linux/mfd/core.h | 14 ++++++++++++++ > > > 2 files changed, 44 insertions(+) > > > > > > diff --git a/drivers/mfd/mfd-core.c b/drivers/mfd/mfd-core.c > > > index 7aa32b90cf1eb7fa0a05bf3dc506e60a262c9850..cc2a2a924d6d3044e29a9f864b536ee325ed797b 100644 > > > --- a/drivers/mfd/mfd-core.c > > > +++ b/drivers/mfd/mfd-core.c > > > @@ -10,6 +10,7 @@ > > > #include > > > #include > > > #include > > > +#include > > > #include > > > #include > > > #include > > > @@ -148,6 +149,11 @@ static int mfd_match_of_node_to_dev(struct platform_device *pdev, > > > return 0; > > > } > > > > > > +static void mfd_child_fwnode_put(void *data) > > > +{ > > > + fwnode_handle_put(data); > > > +} > > > + > > > static int mfd_add_device(struct device *parent, int id, > > > const struct mfd_cell *cell, > > > struct resource *mem_base, > > > @@ -156,6 +162,7 @@ static int mfd_add_device(struct device *parent, int id, > > > struct resource *res; > > > struct platform_device *pdev; > > > struct mfd_of_node_entry *of_entry, *tmp; > > > + struct fwnode_handle *fwnode; > > > bool disabled = false; > > > int ret = -ENOMEM; > > > int platform_id; > > > @@ -224,6 +231,29 @@ static int mfd_add_device(struct device *parent, int id, > > > > > > mfd_acpi_add_device(cell, pdev); > > > > > > + if (!pdev->dev.fwnode && cell->get_child_fwnode) { > > > + fwnode = cell->get_child_fwnode(parent); > > > + if (fwnode) { > > > + device_set_node(&pdev->dev, fwnode); > > > + > > > + /* > > > + * platform_device_release() drops only of_node refs. > > > + * Track non-OF fwnodes explicitly so they are put on > > > + * all teardown paths. > > > + */ > > > + if (!to_of_node(fwnode)) { > > > + ret = devm_add_action(&pdev->dev, > > > + mfd_child_fwnode_put, > > > + fwnode); > > > + if (ret) { > > > + device_set_node(&pdev->dev, NULL); > > > + fwnode_handle_put(fwnode); > > > + goto fail_of_entry; > > > + } > > > + } > > > + } > > > + } > > > > mfd_add_device() is getting very busy now with support for all of these > > different registration APIs. Suggest that we start breaking them out. > > > > > + > > > if (cell->pdata_size) { > > > ret = platform_device_add_data(pdev, > > > cell->platform_data, cell->pdata_size); > > > diff --git a/include/linux/mfd/core.h b/include/linux/mfd/core.h > > > index faeea7abd688f223fb0b31cde0a9b69dfe2a61ff..abfc26c057d6ee46947ba2b6f2e99f420e74b127 100644 > > > --- a/include/linux/mfd/core.h > > > +++ b/include/linux/mfd/core.h > > > @@ -50,6 +50,7 @@ > > > #define MFD_DEP_LEVEL_HIGH 1 > > > > > > struct irq_domain; > > > +struct fwnode_handle; > > > struct software_node; > > > > > > /* Matches ACPI PNP id, either _HID or _CID, or ACPI _ADR */ > > > @@ -80,6 +81,19 @@ struct mfd_cell { > > > > > > /* Software node for the device. */ > > > const struct software_node *swnode; > > > + /* > > > + * Callback to return an explicit firmware node. > > > + * @parent: MFD parent device passed to mfd_add_devices(). > > > + * > > > + * Called only if OF/ACPI matching did not assign a fwnode. > > > + * Ownership of the returned reference is transferred to MFD core. > > > + * > > > + * Return a referenced fwnode or NULL if none is available. > > > + * > > > + * mfd_cell must be zero-initialized or get_child_fwnode must be NULL > > > + * when unused. > > > + */ > > > + struct fwnode_handle *(*get_child_fwnode)(struct device *parent); > > > > I'm very much against pointers to functions if they can be avoided. Why > > does fwnode need this and none of the other APIs do? > > > > I suggested it because of its flexibility. The alternative I had in > mind is something like a new field in mfd_cell: > > const char *cell_node_name; > > Which - if set - would tell MFD to look up an fwnode that's a child of > the parent device's node by name - as it may not have a compatible. Remind me why the chlid device can't look-up its own fwnode? -- Lee Jones