From patchwork Thu Oct 27 12:52:41 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 13022053 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 51A89FA3740 for ; Thu, 27 Oct 2022 12:54:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References:Message-Id :MIME-Version:Subject:Date:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=uAarku5z1jZabFz/c2AtdOq64Sc9TDD5e8YaUMkY/cI=; b=tHRRiRpiaEJsMU OpHxdhzweF+n20hgQVuRJbKhDIp8wU1hoyZrB3INRi/5UkXfsIcof7Fwmuo8BEZTmXyw9Cyylvcj4 TqolWUti6oGrAfSCZbMCTfOzl4Wjo8ZOXpr7dtdamoHDomdBSOMOSOxsaNUl51owRG8jXiDtx+RBb GvKMCt54N6XLQ/9ptxqXcPH5PIqGbx2JylG8MbLuu4U1fW36OWsQrm8NDMsphbFUpDDp9QrPl8BVj FO2p5reclIjTmc0w3fleyFzPXQed1c/l+jMN3gsByZMjDO2Bg3FshVF7s9qE2q3E62j/DgPJvbF87 ZVHjPTG8fRhA+GRrG3Tw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oo2Nw-00DFCy-V9; Thu, 27 Oct 2022 12:53:25 +0000 Received: from wout5-smtp.messagingengine.com ([64.147.123.21]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oo2NT-00DEyn-OC; Thu, 27 Oct 2022 12:52:58 +0000 Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailout.west.internal (Postfix) with ESMTP id 681583200392; Thu, 27 Oct 2022 08:52:52 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute2.internal (MEProxy); Thu, 27 Oct 2022 08:52:53 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cerno.tech; h=cc :cc:content-transfer-encoding:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to; s=fm3; t=1666875172; x= 1666961572; bh=XLoY6/AIOx7GxUWpn4fPxhdJ84XuveOm5Oti9fOQbTQ=; b=E VZCWoS/+J3cfUe2Xm6fHOyr287iVnqPZre+poXfmhzNiGyJ8xRcPp22h5Q2gar6t cF1wmzuEZ+mlm0uRXEIZKyUFe01ZAQ7djyJDa2FYBxYR88jZ/0XlMOcpQfnhgqC2 8vB4UoMH1dUrmAMfYSK1nkMDgBwQ90YbHyHVbxZR4/0Ysm6km5tThv5jpVyvjJXm sGQmRqDBETBZPYBzcjDviKzjFdaVy9GsQ9EzPXdzu1wgNlTXZjyu7GzGbKNKa+/m Mgbg1XzbpiObOmANUdIou8WwxACVMMp7UcHHChd5KMYBOif/lrLcCYWVIvSMwyOr oWlTiUOnCoS6HwbcnG9wg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t=1666875172; x= 1666961572; bh=XLoY6/AIOx7GxUWpn4fPxhdJ84XuveOm5Oti9fOQbTQ=; b=o O/y49EJLy6ZGLFozmlVtAfw4WHfY4oTcPmFHth64OSmzZQU2PaxmUPaKbmiynFZB wzdW79MY9wy+Fy7Jsbj+wnK+8sDGoYBkhxLYLAeOE2FJrjhOzpW3fUkh71SstX3a KtSYF9MDzcspiJYmABHwJAmm0SIms5ZVH+JCyd/MuT0B7OA51A9sUek3u6mFn+Dq m54y0WECTA53D9jpHYEdGAHpte5ODVcZt7oHvLWt+5JYB9FWpN69IIpI6tGj5eqs H4srqg+JNr8tWqpENlScwqaDtLosUCAi1wWUFndpSviKi6fCy72LKJRp+6AbocTY hTg72XbYTTGCHSnwB6swg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvgedrtdeggdehhecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefhfffugggtgffkfhgjvfevofesthekredtredtjeenucfhrhhomhepofgrgihi mhgvucftihhprghrugcuoehmrgigihhmvgestggvrhhnohdrthgvtghhqeenucggtffrrg htthgvrhhnpeduudduhfevjeetfeegvdffvdevvdejudegudekjeehtdelhfffveethfej ledtveenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpe hmrgigihhmvgestggvrhhnohdrthgvtghh X-ME-Proxy: Feedback-ID: i8771445c:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 27 Oct 2022 08:52:50 -0400 (EDT) From: Maxime Ripard Date: Thu, 27 Oct 2022 14:52:41 +0200 Subject: [PATCH v5 1/7] firmware: raspberrypi: Introduce rpi_firmware_find_node() MIME-Version: 1.0 Message-Id: <20220815-rpi-fix-4k-60-v5-1-fe9e7ac8b111@cerno.tech> References: <20220815-rpi-fix-4k-60-v5-0-fe9e7ac8b111@cerno.tech> In-Reply-To: <20220815-rpi-fix-4k-60-v5-0-fe9e7ac8b111@cerno.tech> To: Stephen Boyd , Florian Fainelli , Maxime Ripard , Scott Branden , Broadcom internal kernel review list , Michael Turquette , Daniel Vetter , Emma Anholt , David Airlie , Ray Jui Cc: linux-rpi-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Dave Stevenson , Maxime Ripard , dri-devel@lists.freedesktop.org, Dom Cobley , linux-arm-kernel@lists.infradead.org, linux-clk@vger.kernel.org, Stefan Wahren X-Mailer: b4 0.11.0-dev-99e3a X-Developer-Signature: v=1; a=openpgp-sha256; l=2850; i=maxime@cerno.tech; h=from:subject:message-id; bh=2vslMbMdS0Ot1OIkS9uhKRt2nTBeQBge9lhrJ7SVTlc=; b=owGbwMvMwCX2+D1vfrpE4FHG02pJDMlR9TIvmwS4C1wOrvz6q3bPFeUlbBful/o1nN3aHxX736ec LUygo5SFQYyLQVZMkSVG2HxJ3KlZrzvZ+ObBzGFlAhnCwMUpABO5bs3wzyZZpczq5rv/ezP5vmtWfJ zez/V/1xr5fWl/Flacu7f4+2JGhvcTV61PdYlsuqqVK/FS/mgOe9pFvdXB4mvkWZxtpx1N4wMA X-Developer-Key: i=maxime@cerno.tech; a=openpgp; fpr=BE5675C37E818C8B5764241C254BCFC56BF6CE8D X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221027_055255_876301_F5753BC2 X-CRM114-Status: GOOD ( 12.76 ) 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 A significant number of RaspberryPi drivers using the firmware don't have a phandle to it, so end up scanning the device tree to find a node with the firmware compatible. That code is duplicated everywhere, so let's introduce a helper instead. Acked-by: Florian Fainelli Signed-off-by: Maxime Ripard --- drivers/firmware/raspberrypi.c | 18 ++++++++++++------ include/soc/bcm2835/raspberrypi-firmware.h | 7 +++++++ 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/drivers/firmware/raspberrypi.c b/drivers/firmware/raspberrypi.c index 4b8978b254f9..932a8bef22fb 100644 --- a/drivers/firmware/raspberrypi.c +++ b/drivers/firmware/raspberrypi.c @@ -311,6 +311,18 @@ static int rpi_firmware_remove(struct platform_device *pdev) return 0; } +static const struct of_device_id rpi_firmware_of_match[] = { + { .compatible = "raspberrypi,bcm2835-firmware", }, + {}, +}; +MODULE_DEVICE_TABLE(of, rpi_firmware_of_match); + +struct device_node *rpi_firmware_find_node(void) +{ + return of_find_matching_node(NULL, rpi_firmware_of_match); +} +EXPORT_SYMBOL_GPL(rpi_firmware_find_node); + /** * rpi_firmware_get - Get pointer to rpi_firmware structure. * @firmware_node: Pointer to the firmware Device Tree node. @@ -366,12 +378,6 @@ struct rpi_firmware *devm_rpi_firmware_get(struct device *dev, } EXPORT_SYMBOL_GPL(devm_rpi_firmware_get); -static const struct of_device_id rpi_firmware_of_match[] = { - { .compatible = "raspberrypi,bcm2835-firmware", }, - {}, -}; -MODULE_DEVICE_TABLE(of, rpi_firmware_of_match); - static struct platform_driver rpi_firmware_driver = { .driver = { .name = "raspberrypi-firmware", diff --git a/include/soc/bcm2835/raspberrypi-firmware.h b/include/soc/bcm2835/raspberrypi-firmware.h index 811ea668c4a1..63426082bcb9 100644 --- a/include/soc/bcm2835/raspberrypi-firmware.h +++ b/include/soc/bcm2835/raspberrypi-firmware.h @@ -142,6 +142,7 @@ int rpi_firmware_property(struct rpi_firmware *fw, int rpi_firmware_property_list(struct rpi_firmware *fw, void *data, size_t tag_size); void rpi_firmware_put(struct rpi_firmware *fw); +struct device_node *rpi_firmware_find_node(void); struct rpi_firmware *rpi_firmware_get(struct device_node *firmware_node); struct rpi_firmware *devm_rpi_firmware_get(struct device *dev, struct device_node *firmware_node); @@ -159,6 +160,12 @@ static inline int rpi_firmware_property_list(struct rpi_firmware *fw, } static inline void rpi_firmware_put(struct rpi_firmware *fw) { } + +static inline struct device_node *rpi_firmware_find_node(void) +{ + return NULL; +} + static inline struct rpi_firmware *rpi_firmware_get(struct device_node *firmware_node) { return NULL;