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 92150CD4F5E for ; Thu, 21 May 2026 11:27:55 +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-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=UZOTOngkbfj30aKE5h0OheISuX6tazoHMxsmKuVcuU8=; b=Yy9QGV31EHAVWz9+yNIdcaYVj4 UVO6NULiISo3jqYSFJb6MFYiAV48zcwsio46j1BJ9L0Vi2Z/01T6eosGGWU+G9rQfYKjMzCmoAI9W wp0r8egpanhqmKjBP2LzdMsGp0deL1RDoB27T4Z/DzLUMTNSXsSvizCjXei5MFRocDgH5zRJemZJs 46oddAqxMiURRvywGZnZTjLE3HKoqP6QjRaFuONSMBuKW9H8OheILDgeQEntxNnCvUS5MLpqwxQLZ bBl6LAk1RUgMxY9nXQFBdiw7ljVipPfcZ13vmVBrT1j82DWqA7KIoGbcV1V1apkg5j/tVtrOpFkVg TOGQ1vsw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.99.1 #2 (Red Hat Linux)) id 1wQ1YA-00000007bHx-3YIA; Thu, 21 May 2026 11:26:50 +0000 Received: from sea.source.kernel.org ([172.234.252.31]) by bombadil.infradead.org with esmtps (Exim 4.99.1 #2 (Red Hat Linux)) id 1wQ1Y8-00000007bGg-3dic for linux-arm-kernel@lists.infradead.org; Thu, 21 May 2026 11:26:50 +0000 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by sea.source.kernel.org (Postfix) with ESMTP id 2457F42A52; Thu, 21 May 2026 11:26:48 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 207021F000E9; Thu, 21 May 2026 11:26:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1779362808; bh=UZOTOngkbfj30aKE5h0OheISuX6tazoHMxsmKuVcuU8=; h=Date:From:To:Cc:Subject:References:In-Reply-To; b=YknBrn9kiMeaSTRI5stxMpPOhLCuv//1zvSkCq9TrxnhvQVUZi90Ibx6SNCLL2+c9 1f9NhY9sd9GPPpZl+xrHLLtgsR0jHAQrg2aAIdocwHaUOOJnoZS1Oq1XQ3Aome8SpV nB8o+D12abKjKOLGHshtpVVCPx/trcADPRHMA/dbbxJcR5NQ2dp7TjQse3XlQlk82h pPLFc954YP2q/udXd94u/7aALaBOfqHoXXVA67i7koQng6GhIR8dEKsHehwnAELkLl ikQcgsaQmJxnSiolThEawMr79VBhwBN4ckowU42WuBQznI+D203WXd2Zb2TtdTaXd/ Uv+MRCmq+cMHA== Date: Thu, 21 May 2026 12:26:38 +0100 From: Lee Jones To: Shivendra Pratap Cc: 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 , Bartosz Golaszewski , 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: <20260521112638.GD2921053@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> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20260514-arm-psci-system_reset2-vendor-reboots-v22-8-28a5bde07483@oss.qualcomm.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.9.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20260521_042649_057169_284F7D98 X-CRM114-Status: GOOD ( 30.58 ) 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, 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? > /* > * Device Tree compatible string > > -- > 2.34.1 > -- Lee Jones