From patchwork Tue Sep 20 12:50:20 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 12982100 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 41857C54EE9 for ; Tue, 20 Sep 2022 12:56:33 +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=SVVybx1Ttl5AreH6QiMJVczWlytTi+QVhxjIHl9M/14=; b=NC6ioMwma277SF 5zOplfQx/2tCqHMQUVdmz9d8adFNDW4QDSeb79MxZar7Zv0T35BoIrpncd3jlKZdDDqB8szz8XMpo gjYrPC6cKeeHqG6VZPQUc2Zs+MfVuSkthfedK1xfmUn/Sdu6Oj6Ey0SVHArtYS9e228LeJmS1cpvc v184QJPupwnsiOTGqbFIkUrJcgvtfDXpiADdax5yyUOYNI+pivIrggm7mr4iZhYgjvBn1HEn4Sgck 9w53Z86r+8Tip+V+0U0IQwAgn2KdHK7qOQW0l5HotBtEM3xRnBnzcmvOTueFct2KgKvIVTQMhKZgD fCjCQUZZM3bfE2NpM40A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oacmX-003rAy-NS; Tue, 20 Sep 2022 12:55:22 +0000 Received: from wout4-smtp.messagingengine.com ([64.147.123.20]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oackk-003q20-7G; Tue, 20 Sep 2022 12:53:33 +0000 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.west.internal (Postfix) with ESMTP id 42659320096D; Tue, 20 Sep 2022 08:53:28 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute4.internal (MEProxy); Tue, 20 Sep 2022 08:53:29 -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=fm2; t=1663678407; x= 1663764807; bh=bznVlAm7CcwW9vUQI8XUe6+ILjJSwqZMClSNEtYWnA0=; b=A sKMnczh+2BDL5xM7Pns5gd6SDZYEktsEDc/vVkS4rEjfxNoDnlh54KLAqZoj+RUC 5e0LP628Bcs6VyT54Kry52Ve8eIA3Bf4KE4PrsrnDHBzWm3cnORgNIVHr2bT2PO6 4EmG4R3iqwawCgeyJOyYhJuz1B3r0Y3eOfwJHBkuO73t+Ja7KYJD7TNJzwOYpLVS xpmIGyixS3vjMzevFdRQWST1uci5Ct/exPmw6MgHQK/qLXa/YYqdCYK3Q7iiAN3a fqgfB8YqkFh4yJmzHL6SFjPnvwIUgpiOsU4owhRrqbjsYrU9xs28w6D6KWBGyodd po53ovDXB6sJmwrMg0qqw== 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=fm2; t=1663678407; x= 1663764807; bh=bznVlAm7CcwW9vUQI8XUe6+ILjJSwqZMClSNEtYWnA0=; b=X sOjUiFRSJbBFqt7qfe9eyPPr/XCQIHIOAKYEMuQi2fdOPzzz8aafL6iJ0csi85EU NeLlCVajKAFgCsKioZt19cgvn+0i3SmuUkPYJUaUxYhFJ4oXUFshnUO4he09djAJ 85q8mM3oEjJo/hbTlsMNmRELyVHCtzPpKT56yahoJ+h3w63DyldkbVTaRSX1RMhE T+sTCJ56+uJAMhlC0+5s5/6qLDEzXdiJDCYqblMhK9wFIQqaOv1t4XpVWt9odgOS ZZi1IGFxKvk6loq0bXG1CUb21QyPxgW2BwWrNG1GNQpUYMLtntgD6ptlBnI1rO1e /ZqoJIR+oVd1B3RSRmXuA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedrfedvledgheekucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephfffufggtgfgkfhfjgfvvefosehtkeertdertdejnecuhfhrohhmpeforgig ihhmvgcutfhiphgrrhguuceomhgrgihimhgvsegtvghrnhhordhtvggthheqnecuggftrf grthhtvghrnhepudduudfhveejteefgedvffdvvedvjedugedukeejhedtlefhffevtefh jeeltdevnecuvehluhhsthgvrhfuihiivgepvdenucfrrghrrghmpehmrghilhhfrhhomh epmhgrgihimhgvsegtvghrnhhordhtvggthh X-ME-Proxy: Feedback-ID: i8771445c:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 20 Sep 2022 08:53:27 -0400 (EDT) From: Maxime Ripard Date: Tue, 20 Sep 2022 14:50:20 +0200 Subject: [PATCH v2 1/7] firmware: raspberrypi: Introduce rpi_firmware_find_node() MIME-Version: 1.0 Message-Id: <20220815-rpi-fix-4k-60-v2-1-983276b83f62@cerno.tech> References: <20220815-rpi-fix-4k-60-v2-0-983276b83f62@cerno.tech> In-Reply-To: <20220815-rpi-fix-4k-60-v2-0-983276b83f62@cerno.tech> To: Daniel Vetter , Florian Fainelli , David Airlie , Broadcom internal kernel review list , Michael Turquette , Scott Branden , Stephen Boyd , Emma Anholt , Ray Jui , Maxime Ripard Cc: linux-rpi-kernel@lists.infradead.org, linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org, Dom Cobley , dri-devel@lists.freedesktop.org, Maxime Ripard , linux-arm-kernel@lists.infradead.org X-Mailer: b4 0.10.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2058; i=maxime@cerno.tech; h=from:subject:message-id; bh=sPYmav9OfSnKW2AKxDc1YspDgs/8ZuYriYV4H73zKeE=; b=owGbwMvMwCX2+D1vfrpE4FHG02pJDMma2/nUStbW2dvqKh7+InZYRUJb3HGb4tu1zj1sN6e/jttj aZreUcrCIMbFICumyBIjbL4k7tSs151sfPNg5rAygQxh4OIUgIlk3mBkmFAcxfuX74pIYrZNyaWkn4 VhvfInT0/x0D20Zu6Zm/MFBBj+B+7pM/pjtPlmbfz90J/bzUrmn15gNf+5XLnHlzutVVuYWAE= 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-20220920_055331_007453_779BB1FC X-CRM114-Status: UNSURE ( 9.36 ) X-CRM114-Notice: Please train this message. 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. Signed-off-by: Maxime Ripard diff --git a/drivers/firmware/raspberrypi.c b/drivers/firmware/raspberrypi.c index 4b8978b254f9..b916e1e171f8 100644 --- a/drivers/firmware/raspberrypi.c +++ b/drivers/firmware/raspberrypi.c @@ -311,6 +311,13 @@ static int rpi_firmware_remove(struct platform_device *pdev) return 0; } +static const struct of_device_id 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. 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; From patchwork Tue Sep 20 12:50:21 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 12982094 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 614E4C6FA8B for ; Tue, 20 Sep 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=E9xkUpyUmg/QwI7y1Z9DJzbGHRFLArDvK4sPfU8EZSU=; b=XiS25k5wUVnLlP MnEP011GPUz2nBfbm9jCDnAI883pNydSoM9P2Nv9rfTkgwt99afVgf07VL+ql8CHuxqoQNlVOgAP7 JZvTBJgSZzP8nOZ0itTQcGfJ2IbRD8ftNHhgu9jzFfhWhtfACW35fgecze+Ef5pcZpKaq8GcHxFLi iQ4mP0uzc4ZUXw+jVtXoeLgsllz4DEsbzxgjQIKxUNTBT1ULoq8Qxb9CcJbQNmPZ2cvX2icS3UoPi FvpmZjH2J99OLvogsrggp2OWpvIZHdNug1u9P8lvOSkH+GAcmL2l5CbboSvhV9aioq4c9h0yNDFdH cwQ1sGg0Iwzih9LFSN5w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oackM-003psU-EA; Tue, 20 Sep 2022 12:53:06 +0000 Received: from wout4-smtp.messagingengine.com ([64.147.123.20]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oackJ-003ppm-J6; Tue, 20 Sep 2022 12:53:05 +0000 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.west.internal (Postfix) with ESMTP id 7B83A320094D; Tue, 20 Sep 2022 08:52:59 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute4.internal (MEProxy); Tue, 20 Sep 2022 08:53:01 -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=fm2; t=1663678379; x= 1663764779; bh=vbFyspAQsg3yNRKNMEYHBJbMt9LJYRJ5b26Dvh979Qk=; b=v sK/UngwTugPfIsTCCqWL0HVQiUHWOhNnKrheAMPeBbIzKFSh/qJuDg2zNEFA8dJ1 VBvd5kc6GPonPe5b8LqjLEUDl+o8vw33JBQZ+h6bS303QJ644l2WDqNeNzSbptzU L2m+sva5YL3/Ovh4G+D0cMkUk4dERjViK1u6B2L420cE1YWyZr1Ct4fHaCwVG30D 9+Uavi40C7ob1t38jkcKK9hyrig30SmS/5fdu0CkEA9/M6yCQi4GocsVqBMr2hCG fCKEcJuVgkPcqxITMAA7d3JDkEWv1/1U7ki8uQxegCDFYCm1ap3jbO9kxIUMHZIF qceiq0ARxytRc6Z2lfULg== 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=fm2; t=1663678379; x= 1663764779; bh=vbFyspAQsg3yNRKNMEYHBJbMt9LJYRJ5b26Dvh979Qk=; b=S RepxWrcdnlKEvbeAOl3WQNvcm4uGmLtIotrMC3KIkGCM+TwK1WbDbhv/19bk04NM pmXfap/EfbnRlSKJ1d4u+LrANWJ1I9KAFdotFv7d3G0WksKoQKzJ0U7DPIei6nLz zjeX8uRvMseJCd0mnfL3yuPvGzx2KdRUlANmYZPSvaZGXh4kwO06HaObS6ZRfRgA k2us+gfY5iRF4axdQ+sEy4m9oWQK+XnnSDHoz3bLAYOcd3en8jRN/+F9A48MWoXI Q3JUSORlVw4MZv/KBVLfI8cojJVx+d76+CmWPq/m/tH18lnf2VRayrLdRgWkVO3n v5IRBvsud+f5XvwDDdbWg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedrfedvledgheekucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephfffufggtgfgkfhfjgfvvefosehtkeertdertdejnecuhfhrohhmpeforgig ihhmvgcutfhiphgrrhguuceomhgrgihimhgvsegtvghrnhhordhtvggthheqnecuggftrf grthhtvghrnhepudduudfhveejteefgedvffdvvedvjedugedukeejhedtlefhffevtefh jeeltdevnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomh epmhgrgihimhgvsegtvghrnhhordhtvggthh X-ME-Proxy: Feedback-ID: i8771445c:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 20 Sep 2022 08:52:58 -0400 (EDT) From: Maxime Ripard Date: Tue, 20 Sep 2022 14:50:21 +0200 Subject: [PATCH v2 2/7] firmware: raspberrypi: Move the clock IDs to the firmware header MIME-Version: 1.0 Message-Id: <20220815-rpi-fix-4k-60-v2-2-983276b83f62@cerno.tech> References: <20220815-rpi-fix-4k-60-v2-0-983276b83f62@cerno.tech> In-Reply-To: <20220815-rpi-fix-4k-60-v2-0-983276b83f62@cerno.tech> To: Daniel Vetter , Florian Fainelli , David Airlie , Broadcom internal kernel review list , Michael Turquette , Scott Branden , Stephen Boyd , Emma Anholt , Ray Jui , Maxime Ripard Cc: linux-rpi-kernel@lists.infradead.org, linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org, Dom Cobley , dri-devel@lists.freedesktop.org, Maxime Ripard , linux-arm-kernel@lists.infradead.org X-Mailer: b4 0.10.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2076; i=maxime@cerno.tech; h=from:subject:message-id; bh=TrD+SFGf4YZRmdJ85X/XZBFv+MxAtrE6oLVm8pSPxrw=; b=owGbwMvMwCX2+D1vfrpE4FHG02pJDMma2/leWNqdblzx/Y+AwZ8j3HPZbF4dVSmZGliQHbXNb1LG mvNbO0pZGMS4GGTFFFlihM2XxJ2a9bqTjW8ezBxWJpAhDFycAjARtk2MDPP/1rtrfb6j+k36uGize3 Nk8e/Vtg/rfr2RWO55RuBP3xNGhlPLtO40VXrUJSzWeWgwS7AyteNG6gPzrVVTa9euCf2Qww4A 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-20220920_055303_815469_472CE594 X-CRM114-Status: UNSURE ( 7.11 ) X-CRM114-Notice: Please train this message. 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 We'll need the clock IDs in more drivers than just the clock driver from now on, so let's move them in the firmware header. Signed-off-by: Maxime Ripard diff --git a/drivers/clk/bcm/clk-raspberrypi.c b/drivers/clk/bcm/clk-raspberrypi.c index 876b37b8683c..1f5e6a1554e6 100644 --- a/drivers/clk/bcm/clk-raspberrypi.c +++ b/drivers/clk/bcm/clk-raspberrypi.c @@ -18,24 +18,6 @@ #include -enum rpi_firmware_clk_id { - RPI_FIRMWARE_EMMC_CLK_ID = 1, - RPI_FIRMWARE_UART_CLK_ID, - RPI_FIRMWARE_ARM_CLK_ID, - RPI_FIRMWARE_CORE_CLK_ID, - RPI_FIRMWARE_V3D_CLK_ID, - RPI_FIRMWARE_H264_CLK_ID, - RPI_FIRMWARE_ISP_CLK_ID, - RPI_FIRMWARE_SDRAM_CLK_ID, - RPI_FIRMWARE_PIXEL_CLK_ID, - RPI_FIRMWARE_PWM_CLK_ID, - RPI_FIRMWARE_HEVC_CLK_ID, - RPI_FIRMWARE_EMMC2_CLK_ID, - RPI_FIRMWARE_M2MC_CLK_ID, - RPI_FIRMWARE_PIXEL_BVB_CLK_ID, - RPI_FIRMWARE_NUM_CLK_ID, -}; - static char *rpi_firmware_clk_names[] = { [RPI_FIRMWARE_EMMC_CLK_ID] = "emmc", [RPI_FIRMWARE_UART_CLK_ID] = "uart", diff --git a/include/soc/bcm2835/raspberrypi-firmware.h b/include/soc/bcm2835/raspberrypi-firmware.h index 63426082bcb9..74c7bcc1ac2a 100644 --- a/include/soc/bcm2835/raspberrypi-firmware.h +++ b/include/soc/bcm2835/raspberrypi-firmware.h @@ -136,6 +136,24 @@ enum rpi_firmware_property_tag { RPI_FIRMWARE_GET_DMA_CHANNELS = 0x00060001, }; +enum rpi_firmware_clk_id { + RPI_FIRMWARE_EMMC_CLK_ID = 1, + RPI_FIRMWARE_UART_CLK_ID, + RPI_FIRMWARE_ARM_CLK_ID, + RPI_FIRMWARE_CORE_CLK_ID, + RPI_FIRMWARE_V3D_CLK_ID, + RPI_FIRMWARE_H264_CLK_ID, + RPI_FIRMWARE_ISP_CLK_ID, + RPI_FIRMWARE_SDRAM_CLK_ID, + RPI_FIRMWARE_PIXEL_CLK_ID, + RPI_FIRMWARE_PWM_CLK_ID, + RPI_FIRMWARE_HEVC_CLK_ID, + RPI_FIRMWARE_EMMC2_CLK_ID, + RPI_FIRMWARE_M2MC_CLK_ID, + RPI_FIRMWARE_PIXEL_BVB_CLK_ID, + RPI_FIRMWARE_NUM_CLK_ID, +}; + #if IS_ENABLED(CONFIG_RASPBERRYPI_FIRMWARE) int rpi_firmware_property(struct rpi_firmware *fw, u32 tag, void *data, size_t len); From patchwork Tue Sep 20 12:50:22 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 12982096 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 BFDB3ECAAD8 for ; Tue, 20 Sep 2022 12:54:43 +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=W4ws0wM/CaTbM1A+z/VUE4khoDBvC+AUUpA/IumtjF8=; b=CortVgaQ01bdWM fGZID+2O2V0pebgxSO7QGCP6fZs2jI/amN51xU6erKITWST57d1/2EEXvuW2AAH7Oi7uEKzLTk5lq ScZ6HF5y4pv6rejcr0moJgMzG7AkaCtKxrg45Uqfl/WfEUcrcVT6NBoPGz8CMRHcJwvBWzP4xHFtQ bwNnk5b5a4f7RxY/nwkce97zOfjoXNwesmlc+g1Wnuh/cxg88dvvyCbNI1KRsBDebtDjPhcqBvYxf YFBSAThvxtGtTjRrep7L9okmAeqQfBQwUglVq82TRFzjbcg7rXeOA7VaGUo9Yr2a9yiC8qk7gNqRs 8uBkwShCUpiMeLD72c8Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oackv-003qB9-IN; Tue, 20 Sep 2022 12:53:42 +0000 Received: from wout4-smtp.messagingengine.com ([64.147.123.20]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oackM-003psg-Dx; Tue, 20 Sep 2022 12:53:07 +0000 Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailout.west.internal (Postfix) with ESMTP id 734EA3200A22; Tue, 20 Sep 2022 08:53:04 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute2.internal (MEProxy); Tue, 20 Sep 2022 08:53:05 -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=fm2; t=1663678383; x= 1663764783; bh=Oiy8kIrWntAe9Yt5cwgH+aW2cgmJxqz4HocKaGGRcNk=; b=E tkMWkXgpBxKlSbUPsQdMtUQkgHXbrfmVUzOzgUsXr3G/U3+V+fqnIh/aplPBbnDS VLcF10RAHeEpSUqSNvGc49/Nr1rjIf2GVdweXmr8DeRmUQj+TQQ1b4vf/tFwyUUT 6If//qhRUHQqhUMhgUWkpbbSI35uEbB136zoeF7u8VYThjhyX+iLYLgJW2YLpbkh Y10DRcXEPf+FPg9uH6VUvubWCcuaGt8GlRLyaVC8sF4SXSPOS603vT4ik/XIrQww LOcwHlDsWAXnd504rQxNJhePvi/QRTvA2jXhST8Rap9xOAbWiwawuLJT4sWUI340 KfUFdnENO84RyfVwxlrrg== 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=fm2; t=1663678383; x= 1663764783; bh=Oiy8kIrWntAe9Yt5cwgH+aW2cgmJxqz4HocKaGGRcNk=; b=o kuWE/2f+d5a8axPLZGdphHCAsCZAibP0zhA604Ws1qeI0zobNK2SHDfhgEqn88t1 oNLHU11GnGCl31eZHH1Awnm2CVMx1T6mzkX9Va6hNvmWgWGxCjszRXpeDVR8RnYf cAq+AwSZJO295NyZz5OiFUAxg5J/XV6EWBR1YpWQ6OFmH6DmFytyiTvJn3EMHYKu pLqdxZ+Eafzocs6FYe3PO9310ifSZL9tZ6C6BktjO87uzxrzZ7TuIrzPdiN9DLoW +d/CWwc0NhBrxtFv3I+IXunCdmQcQptvr8lGpG3fHr0Luohr1gEGQth4eoglR+zH e1lvAJxTJUGL+npPIqeLg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedrfedvledgheekucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephfffufggtgfgkfhfjgfvvefosehtkeertdertdejnecuhfhrohhmpeforgig ihhmvgcutfhiphgrrhguuceomhgrgihimhgvsegtvghrnhhordhtvggthheqnecuggftrf grthhtvghrnhepudduudfhveejteefgedvffdvvedvjedugedukeejhedtlefhffevtefh jeeltdevnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomh epmhgrgihimhgvsegtvghrnhhordhtvggthh X-ME-Proxy: Feedback-ID: i8771445c:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 20 Sep 2022 08:53:02 -0400 (EDT) From: Maxime Ripard Date: Tue, 20 Sep 2022 14:50:22 +0200 Subject: [PATCH v2 3/7] firmware: raspberrypi: Provide a helper to query a clock max rate MIME-Version: 1.0 Message-Id: <20220815-rpi-fix-4k-60-v2-3-983276b83f62@cerno.tech> References: <20220815-rpi-fix-4k-60-v2-0-983276b83f62@cerno.tech> In-Reply-To: <20220815-rpi-fix-4k-60-v2-0-983276b83f62@cerno.tech> To: Daniel Vetter , Florian Fainelli , David Airlie , Broadcom internal kernel review list , Michael Turquette , Scott Branden , Stephen Boyd , Emma Anholt , Ray Jui , Maxime Ripard Cc: linux-rpi-kernel@lists.infradead.org, linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org, Dom Cobley , dri-devel@lists.freedesktop.org, Maxime Ripard , linux-arm-kernel@lists.infradead.org X-Mailer: b4 0.10.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2942; i=maxime@cerno.tech; h=from:subject:message-id; bh=JMjc9vTvD3H2O1YtnTvuBs8PHnlojILED71Z9PcUCZo=; b=owGbwMvMwCX2+D1vfrpE4FHG02pJDMma2/ncKlKnsvlVbvHoLpr69asJ88cXN/68mjtF7o39cre1 s8z+dJSyMIhxMciKKbLECJsviTs163UnG988mDmsTCBDGLg4BWAil4MYGTZXnd5UHKNXUhTSuGGO+Q R/t84VDr+ik/VsD9W0yXsWtTAy9CTdmbzNV6I8Kvh2pvrljQ1B/451nfkdtfhZQvepSQ0fmAE= 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-20220920_055306_563656_63716FA0 X-CRM114-Status: GOOD ( 12.29 ) 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 The firmware allows to query for its clocks the operating range of a given clock. We'll need this for some drivers (KMS, in particular) to infer the state of some configuration options, so let's create a function to do so. Signed-off-by: Maxime Ripard Acked-by: Stephen Boyd diff --git a/drivers/firmware/raspberrypi.c b/drivers/firmware/raspberrypi.c index b916e1e171f8..c4b9ea70f5a7 100644 --- a/drivers/firmware/raspberrypi.c +++ b/drivers/firmware/raspberrypi.c @@ -228,6 +228,21 @@ static void rpi_register_clk_driver(struct device *dev) -1, NULL, 0); } +unsigned int rpi_firmware_clk_get_max_rate(struct rpi_firmware *fw, unsigned int id) +{ + struct rpi_firmware_clk_rate_request msg = + RPI_FIRMWARE_CLK_RATE_REQUEST(id); + int ret; + + ret = rpi_firmware_property(fw, RPI_FIRMWARE_GET_MAX_CLOCK_RATE, + &msg, sizeof(msg)); + if (ret) + return 0; + + return le32_to_cpu(msg.rate); +} +EXPORT_SYMBOL_GPL(rpi_firmware_clk_get_max_rate); + static void rpi_firmware_delete(struct kref *kref) { struct rpi_firmware *fw = container_of(kref, struct rpi_firmware, diff --git a/include/soc/bcm2835/raspberrypi-firmware.h b/include/soc/bcm2835/raspberrypi-firmware.h index 74c7bcc1ac2a..10248c370229 100644 --- a/include/soc/bcm2835/raspberrypi-firmware.h +++ b/include/soc/bcm2835/raspberrypi-firmware.h @@ -154,12 +154,32 @@ enum rpi_firmware_clk_id { RPI_FIRMWARE_NUM_CLK_ID, }; +/** + * struct rpi_firmware_clk_rate_request - Firmware Request for a rate + * @id: ID of the clock being queried + * @rate: Rate in Hertz. Set by the firmware. + * + * Used by @RPI_FIRMWARE_GET_CLOCK_RATE, @RPI_FIRMWARE_GET_CLOCK_MEASURED, + * @RPI_FIRMWARE_GET_MAX_CLOCK_RATE and @RPI_FIRMWARE_GET_MIN_CLOCK_RATE. + */ +struct rpi_firmware_clk_rate_request { + __le32 id; + __le32 rate; +} __packed; + +#define RPI_FIRMWARE_CLK_RATE_REQUEST(_id) \ + { \ + .id = _id, \ + } + #if IS_ENABLED(CONFIG_RASPBERRYPI_FIRMWARE) int rpi_firmware_property(struct rpi_firmware *fw, u32 tag, void *data, size_t len); int rpi_firmware_property_list(struct rpi_firmware *fw, void *data, size_t tag_size); void rpi_firmware_put(struct rpi_firmware *fw); +unsigned int rpi_firmware_clk_get_max_rate(struct rpi_firmware *fw, + unsigned int id); 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, @@ -179,6 +199,12 @@ static inline int rpi_firmware_property_list(struct rpi_firmware *fw, static inline void rpi_firmware_put(struct rpi_firmware *fw) { } +static inline unsigned int rpi_firmware_clk_get_max_rate(struct rpi_firmware *fw, + unsigned int id) +{ + return UINT_MAX; +} + static inline struct device_node *rpi_firmware_find_node(void) { return NULL; From patchwork Tue Sep 20 12:50:23 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 12982097 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 3B67EECAAD8 for ; Tue, 20 Sep 2022 12:55:16 +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=MoLir3vRpPkmOzYhLOV9ubqXGc4gcJ+nepAP378662w=; b=XczK3EjyPOxFfj YooSv7iRqAMTFCj2T6VsC8RvYywwAOnUWdGLyB04aeV6Tbz6ghsSzq4m1w9j4X3MSib/I1weaWksH F+BfS+yoWwYp26Juaunc5s3hVRfRgsdW22S6qcowjqRPrYOvJaiRR72ElPLAmV6XPWqBpMq9977pp QjVmbUEG1DImn6p5OI1vUi8snK1qyON79csji+yenVGeM+J5AUBqi4Xd+CprUhVmr16YiQv/5iXvx Aknq37bAkzZNtKDpUjj65vimO53SqxHLAZjS5Sj1WdGcQvtbB8DspD3oWmqpksoBxeOt3gy9F27sl DSdXPpUh3ebh9cuASy2w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oaclQ-003qSr-43; Tue, 20 Sep 2022 12:54:12 +0000 Received: from wout4-smtp.messagingengine.com ([64.147.123.20]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oackR-003pun-Pi; Tue, 20 Sep 2022 12:53:13 +0000 Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.west.internal (Postfix) with ESMTP id 7921F3200A0C; Tue, 20 Sep 2022 08:53:09 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute3.internal (MEProxy); Tue, 20 Sep 2022 08:53:11 -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=fm2; t=1663678388; x= 1663764788; bh=5Cc2S/zQVAffcAyuSwlU7SwrejWyJZT6LOsl2nIBccg=; b=x HZjhJACzsIjchHSoEGtKM6fih5rcS5UMLXhA0VKE31Y68n0cAsamtdckte7qOnyY n/yWS/roxQ1yulD10fHE+wECaFgWi3y0UsLQamEPeALq5ei1ror/+Qq/iYhdkiA9 dAh87iCaQbIIQRi+CuiyvUMUMDDBrnqLDC981nprQiNIJj36PmFUM1sbGNI2MKu3 yNehaS0UVwWXlgfC5qVQcpickyt9DNcVrILZdl8gw4wLCEM0tycUVjFsSa6tfRH+ MLJN8QVXViLvwtoODebxg/j0oFzpFqjPX9a8224hbSfKtqaGa/Q/ZGtyqcKjIiMc mdew2Y8O8fogRr0hisW6g== 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=fm2; t=1663678388; x= 1663764788; bh=5Cc2S/zQVAffcAyuSwlU7SwrejWyJZT6LOsl2nIBccg=; b=S lqnTfqSEvCr0p5IJGeT/GzosqpnyB5qoI/2iILg8r/9mvaqvs8I3+b6q648d6bjr EmnOj9jSXHRgH4V4Dv+bmw/N1LhdTC26ljJJNJZwTGI7QjqAgF11TUXJHN9s6J4q BpjFa44qlvMoWQ9QBRgpqJE2XoR5QsGrb65rk3N7KnnPNvdr8MA56XR9NqSprBA3 EsG7YmM5C0qSg4T9F74JqaXIyWxHoSj6CWvarcriqaGs33YLZC3vCmHYgyVQbPqT djSmdSU7/nTX2HjopwV1sVRxrHnkRqty32ykzvtZFZn4VV+gJXsm9rsAhLlTiMP4 rimChMMpqKgQZ+Yt2PPTQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedrfedvledgheekucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephfffufggtgfgkfhfjgfvvefosehtkeertdertdejnecuhfhrohhmpeforgig ihhmvgcutfhiphgrrhguuceomhgrgihimhgvsegtvghrnhhordhtvggthheqnecuggftrf grthhtvghrnhepudduudfhveejteefgedvffdvvedvjedugedukeejhedtlefhffevtefh jeeltdevnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomh epmhgrgihimhgvsegtvghrnhhordhtvggthh X-ME-Proxy: Feedback-ID: i8771445c:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 20 Sep 2022 08:53:08 -0400 (EDT) From: Maxime Ripard Date: Tue, 20 Sep 2022 14:50:23 +0200 Subject: [PATCH v2 4/7] drm/vc4: hdmi: Fix hdmi_enable_4kp60 detection MIME-Version: 1.0 Message-Id: <20220815-rpi-fix-4k-60-v2-4-983276b83f62@cerno.tech> References: <20220815-rpi-fix-4k-60-v2-0-983276b83f62@cerno.tech> In-Reply-To: <20220815-rpi-fix-4k-60-v2-0-983276b83f62@cerno.tech> To: Daniel Vetter , Florian Fainelli , David Airlie , Broadcom internal kernel review list , Michael Turquette , Scott Branden , Stephen Boyd , Emma Anholt , Ray Jui , Maxime Ripard Cc: linux-rpi-kernel@lists.infradead.org, linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org, Dom Cobley , dri-devel@lists.freedesktop.org, Maxime Ripard , linux-arm-kernel@lists.infradead.org X-Mailer: b4 0.10.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1808; i=maxime@cerno.tech; h=from:subject:message-id; bh=XWjpwgSgO/e0xPKi2xqW6eLYT6GXogPpdSxziMgFD2I=; b=owGbwMvMwCX2+D1vfrpE4FHG02pJDMma2/mquKa7py22cvVg/X7IJKx/58+QJZqBVl735mTIz2LK aJfpKGVhEONikBVTZIkRNl8Sd2rW6042vnkwc1iZQIYwcHEKwEQ+uDEybBB4kDk3l9POjIuv7YFBxU nvDl2P2XJMr7pfvvtwm7ffgeGf3utpwvJyBrNvfnN4/2m37gvZG1Nu6RYXv36x4bgKc+VzRgA= 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-20220920_055311_889553_EC8FFF65 X-CRM114-Status: GOOD ( 11.92 ) 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 In order to support higher HDMI frequencies, users have to set the hdmi_enable_4kp60 parameter in their config.txt file. We were detecting this so far by calling clk_round_rate() on the core clock with the frequency we're supposed to run at when one of those modes is enabled. Whether or not the parameter was enabled could then be inferred by the returned rate since the maximum clock rate reported by the firmware was one of the side effect of setting that parameter. However, the recent clock rework we did changed what clk_round_rate() was returning to always return the minimum allowed, and thus this test wasn't reliable anymore. Let's use the new clk_get_max_rate() function to reliably determine the maximum rate allowed on that clock and fix the 4k@60Hz output. Fixes: e9d6cea2af1c ("clk: bcm: rpi: Run some clocks at the minimum rate allowed") Signed-off-by: Maxime Ripard diff --git a/drivers/gpu/drm/vc4/vc4_hdmi.c b/drivers/gpu/drm/vc4/vc4_hdmi.c index 1e5f68704d7d..3b75ac6fa0db 100644 --- a/drivers/gpu/drm/vc4/vc4_hdmi.c +++ b/drivers/gpu/drm/vc4/vc4_hdmi.c @@ -46,6 +46,7 @@ #include #include #include +#include #include #include #include @@ -2966,7 +2967,7 @@ static int vc4_hdmi_bind(struct device *dev, struct device *master, void *data) if (variant->max_pixel_clock == 600000000) { struct vc4_dev *vc4 = to_vc4_dev(drm); - long max_rate = clk_round_rate(vc4->hvs->core_clk, 550000000); + unsigned long max_rate = rpi_firmware_clk_get_max_rate(vc4->hvs->core_clk); if (max_rate < 550000000) vc4_hdmi->disable_4kp60 = true; From patchwork Tue Sep 20 12:50:24 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 12982098 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 73155C54EE9 for ; Tue, 20 Sep 2022 12:55:43 +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=QTj/mMbtScbpZEVxpztfO0p1BOK7drIoFfMimSlu2PY=; b=PzN7QGoJhvUbXZ QCQHeNcRbtPoqiCcQSNYpem+jW2tTe7wtTXAYLDjJVQWw/wkMR+Ol6FsNeNaUnw6xgF4oidwtMJr0 U1IrmuixSQMccUqvsTmNAk6PNlVG7xFzpJGIAhvEg17ETZGkELGzpbuO39zxgre5uWQBfhHzrIo5i Cs57CA6+Ueit5pculq/xsyVHlpSDHZ9ixYRTkrWfLQtIrxPC1tIvfG9SPC0FRtVoZvIPJUn3RdxP/ zq5ALOGsW+L98jWg4Q/Nm0ATO2xIP31XXDJdND5e1oFTZN0MxuHmSXhhC/bLWWyE1cNqKHnekWMBd iCESnAw3zNOBfgMR545g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oacls-003qlO-Bi; Tue, 20 Sep 2022 12:54:40 +0000 Received: from wout4-smtp.messagingengine.com ([64.147.123.20]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oackW-003pwm-8R; Tue, 20 Sep 2022 12:53:18 +0000 Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailout.west.internal (Postfix) with ESMTP id 4AA7B320094D; Tue, 20 Sep 2022 08:53:14 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute2.internal (MEProxy); Tue, 20 Sep 2022 08:53:15 -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=fm2; t=1663678393; x= 1663764793; bh=FuNSdoSlxTBK1onGoyUka3ZW50au1ZMFxxRRFbg42qE=; b=V t+e5CzSaC6zZ8BeJzKIZ3dfPZUvGPbIOZOjR0i+ggsyTOErklUM9pCI+LpwEkXZL 6Mvv6EhMdiek1cQpxTr5J0f1EeXfX+7hhVVclBo57YOKx8JuCoDeiKSCV9kBRsKk lNhqtn374QMHpUbcH7L5YlxO9YC6XABizZbCGPb/ra4m/ZjVW/GOL5EEBUmYnx1Y U3jHTX3FqZLl1pE/UTvY4GJg88wWiKMk+JJwuo6KrvvBYRT7mMfn/I9MIkHX3vmG 4RS3Xlle+u4Q5zou/Zw3F4Ohsf5AX5NrOGbrfTGSWnKYZefWcF3f1BSVx/E86gjv F1juZV6XiUkJfficbDL4w== 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=fm2; t=1663678393; x= 1663764793; bh=FuNSdoSlxTBK1onGoyUka3ZW50au1ZMFxxRRFbg42qE=; b=P l8/4htyvHyGRTl2Mzaar01EeYU4HU8PC3+uEkCRhfTm7DuBmtB76vkZK/XP/GuvN ZTR3DVYpsP6/VTILpOMkhSibr/V2D4y0jko26aPx3rnBUb3Cce5600JS2hEEkT7a IWajCwec8jyoKG4ZJSz/ChoX4fnMBB3Vxva3fPtHCyMp3PYnKM+phMIblWeMtiqt /LkuEJ/R33F5/pxBcFKUvhAkw7737RWH5cxKfcQvp4920EKctkVaEKDnqr+7HTlG CI5lyRLGu1BMoRFHDvxAcfPl0qsidTog2VeRgYoyilrRmaEftVz6h4yLz+v2N1Td 2tXOWvWh9UAI59lz4TWFg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedrfedvledgheekucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephfffufggtgfgkfhfjgfvvefosehtkeertdertdejnecuhfhrohhmpeforgig ihhmvgcutfhiphgrrhguuceomhgrgihimhgvsegtvghrnhhordhtvggthheqnecuggftrf grthhtvghrnhepudduudfhveejteefgedvffdvvedvjedugedukeejhedtlefhffevtefh jeeltdevnecuvehluhhsthgvrhfuihiivgepudenucfrrghrrghmpehmrghilhhfrhhomh epmhgrgihimhgvsegtvghrnhhordhtvggthh X-ME-Proxy: Feedback-ID: i8771445c:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 20 Sep 2022 08:53:13 -0400 (EDT) From: Maxime Ripard Date: Tue, 20 Sep 2022 14:50:24 +0200 Subject: [PATCH v2 5/7] drm/vc4: hdmi: Rework hdmi_enable_4kp60 detection code MIME-Version: 1.0 Message-Id: <20220815-rpi-fix-4k-60-v2-5-983276b83f62@cerno.tech> References: <20220815-rpi-fix-4k-60-v2-0-983276b83f62@cerno.tech> In-Reply-To: <20220815-rpi-fix-4k-60-v2-0-983276b83f62@cerno.tech> To: Daniel Vetter , Florian Fainelli , David Airlie , Broadcom internal kernel review list , Michael Turquette , Scott Branden , Stephen Boyd , Emma Anholt , Ray Jui , Maxime Ripard Cc: linux-rpi-kernel@lists.infradead.org, linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org, Dom Cobley , dri-devel@lists.freedesktop.org, Maxime Ripard , linux-arm-kernel@lists.infradead.org X-Mailer: b4 0.10.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=5578; i=maxime@cerno.tech; h=from:subject:message-id; bh=Ny/0l26k7lXuGdwY73KyuiuZ8LMTiHztBaP+/V6QoQw=; b=owGbwMvMwCX2+D1vfrpE4FHG02pJDMma2/k4b+/oYDzQP/1vV7JBfZds13FBNqX7bBZ3QyR6OJd8 mXS6o5SFQYyLQVZMkSVG2HxJ3KlZrzvZ+ObBzGFlAhnCwMUpABOR+MTw3/Pu+SlRXG0XTwf9f7MkZK P19u0/Ov/p/fA5fGVjaIF8dxvD/6CQIA/3ttgWLpED2wr78zwWP96xPLrJSOH+5KmaEm4H2AA= 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-20220920_055316_362667_42511191 X-CRM114-Status: GOOD ( 19.86 ) 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 In order to support higher HDMI frequencies, users have to set the hdmi_enable_4kp60 parameter in their config.txt file. This will have the side-effect of raising the maximum of the core clock, tied to the HVS, and managed by the HVS driver. However, we are querying this in the HDMI driver by poking into the HVS structure to get our struct clk handle. Let's make this part of the HVS bind implementation to have all the core clock related setup in the same place. Signed-off-by: Maxime Ripard diff --git a/drivers/gpu/drm/vc4/vc4_drv.h b/drivers/gpu/drm/vc4/vc4_drv.h index 1beb96b77b8c..09cdbdb7fff0 100644 --- a/drivers/gpu/drm/vc4/vc4_drv.h +++ b/drivers/gpu/drm/vc4/vc4_drv.h @@ -328,6 +328,8 @@ struct vc4_hvs { struct clk *core_clk; + unsigned long max_core_rate; + /* Memory manager for CRTCs to allocate space in the display * list. Units are dwords. */ @@ -339,6 +341,14 @@ struct vc4_hvs { struct drm_mm_node mitchell_netravali_filter; struct debugfs_regset32 regset; + + /* + * Even if HDMI0 on the RPi4 can output modes requiring a pixel + * rate higher than 297MHz, it needs some adjustments in the + * config.txt file to be able to do so and thus won't always be + * available. + */ + bool vc5_hdmi_enable_scrambling; }; struct vc4_plane { diff --git a/drivers/gpu/drm/vc4/vc4_hdmi.c b/drivers/gpu/drm/vc4/vc4_hdmi.c index 3b75ac6fa0db..f367f93ca832 100644 --- a/drivers/gpu/drm/vc4/vc4_hdmi.c +++ b/drivers/gpu/drm/vc4/vc4_hdmi.c @@ -46,7 +46,6 @@ #include #include #include -#include #include #include #include @@ -277,6 +276,7 @@ static void vc4_hdmi_connector_destroy(struct drm_connector *connector) static int vc4_hdmi_connector_get_modes(struct drm_connector *connector) { struct vc4_hdmi *vc4_hdmi = connector_to_vc4_hdmi(connector); + struct vc4_dev *vc4 = to_vc4_dev(connector->dev); int ret = 0; struct edid *edid; @@ -293,7 +293,7 @@ static int vc4_hdmi_connector_get_modes(struct drm_connector *connector) ret = drm_add_edid_modes(connector, edid); kfree(edid); - if (vc4_hdmi->disable_4kp60) { + if (!vc4->hvs->vc5_hdmi_enable_scrambling) { struct drm_device *drm = connector->dev; struct drm_display_mode *mode; @@ -1480,11 +1480,12 @@ vc4_hdmi_encoder_clock_valid(const struct vc4_hdmi *vc4_hdmi, { const struct drm_connector *connector = &vc4_hdmi->connector; const struct drm_display_info *info = &connector->display_info; + struct vc4_dev *vc4 = to_vc4_dev(connector->dev); if (clock > vc4_hdmi->variant->max_pixel_clock) return MODE_CLOCK_HIGH; - if (vc4_hdmi->disable_4kp60 && clock > HDMI_14_MAX_TMDS_CLK) + if (!vc4->hvs->vc5_hdmi_enable_scrambling && clock > HDMI_14_MAX_TMDS_CLK) return MODE_CLOCK_HIGH; if (info->max_tmds_clock && clock > (info->max_tmds_clock * 1000)) @@ -2965,14 +2966,6 @@ static int vc4_hdmi_bind(struct device *dev, struct device *master, void *data) vc4_hdmi->disable_wifi_frequencies = of_property_read_bool(dev->of_node, "wifi-2.4ghz-coexistence"); - if (variant->max_pixel_clock == 600000000) { - struct vc4_dev *vc4 = to_vc4_dev(drm); - unsigned long max_rate = rpi_firmware_clk_get_max_rate(vc4->hvs->core_clk); - - if (max_rate < 550000000) - vc4_hdmi->disable_4kp60 = true; - } - pm_runtime_enable(dev); /* diff --git a/drivers/gpu/drm/vc4/vc4_hdmi.h b/drivers/gpu/drm/vc4/vc4_hdmi.h index c3ed2b07df23..7506943050cf 100644 --- a/drivers/gpu/drm/vc4/vc4_hdmi.h +++ b/drivers/gpu/drm/vc4/vc4_hdmi.h @@ -155,14 +155,6 @@ struct vc4_hdmi { */ bool disable_wifi_frequencies; - /* - * Even if HDMI0 on the RPi4 can output modes requiring a pixel - * rate higher than 297MHz, it needs some adjustments in the - * config.txt file to be able to do so and thus won't always be - * available. - */ - bool disable_4kp60; - struct cec_adapter *cec_adap; struct cec_msg cec_rx_msg; bool cec_tx_ok; diff --git a/drivers/gpu/drm/vc4/vc4_hvs.c b/drivers/gpu/drm/vc4/vc4_hvs.c index fbaa741dda5f..e28a13a75ec2 100644 --- a/drivers/gpu/drm/vc4/vc4_hvs.c +++ b/drivers/gpu/drm/vc4/vc4_hvs.c @@ -27,6 +27,8 @@ #include #include +#include + #include "vc4_drv.h" #include "vc4_regs.h" @@ -671,12 +673,33 @@ static int vc4_hvs_bind(struct device *dev, struct device *master, void *data) hvs->regset.nregs = ARRAY_SIZE(hvs_regs); if (vc4->is_vc5) { + struct rpi_firmware *firmware; + struct device_node *node; + unsigned long max_rate; + + node = rpi_firmware_find_node(); + if (!node) + return -EINVAL; + + firmware = rpi_firmware_get(node); + of_node_put(node); + if (!firmware) + return -EPROBE_DEFER; + hvs->core_clk = devm_clk_get(&pdev->dev, NULL); if (IS_ERR(hvs->core_clk)) { dev_err(&pdev->dev, "Couldn't get core clock\n"); return PTR_ERR(hvs->core_clk); } + max_rate = rpi_firmware_clk_get_max_rate(firmware, + RPI_FIRMWARE_CORE_CLK_ID); + rpi_firmware_put(firmware); + if (max_rate >= 550000000) + hvs->vc5_hdmi_enable_scrambling = true; + + hvs->max_core_rate = max_rate; + ret = clk_prepare_enable(hvs->core_clk); if (ret) { dev_err(&pdev->dev, "Couldn't enable the core clock\n"); From patchwork Tue Sep 20 12:50:25 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 12982099 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 DA98FC54EE9 for ; Tue, 20 Sep 2022 12:56:22 +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=6utflRfSMUFt9H7/yX0Qu2kO+jdrFD4yoIZEb28wx2I=; b=FMpz/azRCWq2Fb 2ZITX9B8ScQB6sFiMUkECU2a0uI1Te6IE01sj9Jz1Jtp3NhMIfZPZaRQBy8yX5cJi8OpTgPFruvdj K//jeRwRKucJlfOTkghgLMOFZmN9wyS5hlzO2eKu/Bm34gEyxf+efXA4n/2i3BHL03hYmOWO5AoIE m+uUVyAtm9CVdQj6G0jqLXu09/fljDS/QJjcHZePAh4IAChrECKsXIM7NITfmcVDNWkDPjdYSWlwd Npj4I+C7H71KyNoH7hkNMaMBuuE1U/pWnv4e4xnghtn7ai4vE2Q6mWXKQ/9KXxEFbTO2Xvi7+9ouo EViVj9tZK7ArQ7QQhCoA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oacmE-003qyl-Tc; Tue, 20 Sep 2022 12:55:03 +0000 Received: from wout4-smtp.messagingengine.com ([64.147.123.20]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oacka-003pzW-UQ; Tue, 20 Sep 2022 12:53:22 +0000 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.west.internal (Postfix) with ESMTP id DDD3E3200985; Tue, 20 Sep 2022 08:53:18 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute4.internal (MEProxy); Tue, 20 Sep 2022 08:53:20 -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=fm2; t=1663678398; x= 1663764798; bh=QPg9G5ivjHJPpfwME/clZpzxlHbJakfKiCz4R1/XPHk=; b=R KWZUVjw71KTr3vm/kU+oGkWy8tOP0PJ/bpCrzMxdoM1iyo1e2qBSSgIRnASiEJd1 HajNVq0ZWTTYDHNTNnDx7warrKYcm7rqlYhSm5oz8au4SFyFdeqyrWwjtpK306vZ Pzfp5SeSIlA20y8IZUK3U8+h1fEzvGrzeVZs6wAiqmGbAnNCHooAgzMaFqybu+K3 hiQvmc2KoAt1f8/qjcE/adtDDQJNh+OjG4Na5wV5rKNWGYRGCnJNsZ4Ch2T1MMod zFIUmoueSlrgO6Tbv3ujR/XJ47zO/utd7RvYadVDJ/fqwbA5X76LgN9viNz7rMPY ED2BqqOG2BTnS3vcP7/lw== 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=fm2; t=1663678398; x= 1663764798; bh=QPg9G5ivjHJPpfwME/clZpzxlHbJakfKiCz4R1/XPHk=; b=C gNIQPjKD08AzbBKJYXT5WkdFqHhwwl1rSzerY8yH7LV7IJk92uLiUvA6CnsuRJFb qczbRZ5vW4i35XDkG83q+mwHDm3s6SebO5W9LyDWwpNJUfqDSopWgdoldsGRaLLX rSzpw+imrWP3OYoVr2sMqs8iXuifNniv6E7TUn8FSKKkASFuKNO/cafORIkUeuN4 RM/f2qwF0NXkp6PAVGLcqHEoowPk7NgRS6wCz1feRq/dVuwkbuZZMjB9CoTcCO32 tQcM/kMJGlLI+vWtnVqN4cZ+Vm9EDlny0p9ZXpPqoMEBYW6oHCZN9uGidbNxRY3/ pA58PHGhpGfqIOL/UolUg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedrfedvledgheekucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephfffufggtgfgkfhfjgfvvefosehtkeertdertdejnecuhfhrohhmpeforgig ihhmvgcutfhiphgrrhguuceomhgrgihimhgvsegtvghrnhhordhtvggthheqnecuggftrf grthhtvghrnhepudduudfhveejteefgedvffdvvedvjedugedukeejhedtlefhffevtefh jeeltdevnecuvehluhhsthgvrhfuihiivgepudenucfrrghrrghmpehmrghilhhfrhhomh epmhgrgihimhgvsegtvghrnhhordhtvggthh X-ME-Proxy: Feedback-ID: i8771445c:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 20 Sep 2022 08:53:17 -0400 (EDT) From: Maxime Ripard Date: Tue, 20 Sep 2022 14:50:25 +0200 Subject: [PATCH v2 6/7] drm/vc4: hdmi: Add more checks for 4k resolutions MIME-Version: 1.0 Message-Id: <20220815-rpi-fix-4k-60-v2-6-983276b83f62@cerno.tech> References: <20220815-rpi-fix-4k-60-v2-0-983276b83f62@cerno.tech> In-Reply-To: <20220815-rpi-fix-4k-60-v2-0-983276b83f62@cerno.tech> To: Daniel Vetter , Florian Fainelli , David Airlie , Broadcom internal kernel review list , Michael Turquette , Scott Branden , Stephen Boyd , Emma Anholt , Ray Jui , Maxime Ripard Cc: linux-rpi-kernel@lists.infradead.org, linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org, Dom Cobley , dri-devel@lists.freedesktop.org, Maxime Ripard , linux-arm-kernel@lists.infradead.org X-Mailer: b4 0.10.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=3248; i=maxime@cerno.tech; h=from:subject:message-id; bh=og7yp0bHrituGtq5GFguKmTt56yND9plFAQ/PXTZ8pI=; b=owGbwMvMwCX2+D1vfrpE4FHG02pJDMma2/l8pXYkrZoZX72wKq8tOFXqlJRr1aY3bFe8rig9cTvf sjSuo5SFQYyLQVZMkSVG2HxJ3KlZrzvZ+ObBzGFlAhnCwMUpABPZxsHwV1L5mrwSe7KdtYvOTbmjZ5 wvFGfWf9F/F7YsTpWz67Y2B8M/HedYodsbpxl4pP5+M+GATr0Qm+g66QOqhXO0XLX9Glu4AA== 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-20220920_055321_071303_06D5219C X-CRM114-Status: GOOD ( 12.74 ) 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 From: Dom Cobley At least the 4096x2160@60Hz mode requires some overclocking that isn't available by default, even if hdmi_enable_4kp60 is enabled. Let's add some logic to detect whether we can satisfy the core clock requirements for that mode, and prevent it from being used otherwise. Signed-off-by: Dom Cobley Signed-off-by: Maxime Ripard diff --git a/drivers/gpu/drm/vc4/vc4_drv.h b/drivers/gpu/drm/vc4/vc4_drv.h index 09cdbdb7fff0..094ebe8567e2 100644 --- a/drivers/gpu/drm/vc4/vc4_drv.h +++ b/drivers/gpu/drm/vc4/vc4_drv.h @@ -349,6 +349,12 @@ struct vc4_hvs { * available. */ bool vc5_hdmi_enable_scrambling; + + /* + * 4096x2160@60 requires a core overclock to work, so register + * whether that is sufficient. + */ + bool vc5_hdmi_enable_4096by2160; }; struct vc4_plane { diff --git a/drivers/gpu/drm/vc4/vc4_hdmi.c b/drivers/gpu/drm/vc4/vc4_hdmi.c index f367f93ca832..cf1fee6c29f3 100644 --- a/drivers/gpu/drm/vc4/vc4_hdmi.c +++ b/drivers/gpu/drm/vc4/vc4_hdmi.c @@ -1476,6 +1476,7 @@ vc4_hdmi_sink_supports_format_bpc(const struct vc4_hdmi *vc4_hdmi, static enum drm_mode_status vc4_hdmi_encoder_clock_valid(const struct vc4_hdmi *vc4_hdmi, + const struct drm_display_mode *mode, unsigned long long clock) { const struct drm_connector *connector = &vc4_hdmi->connector; @@ -1488,6 +1489,12 @@ vc4_hdmi_encoder_clock_valid(const struct vc4_hdmi *vc4_hdmi, if (!vc4->hvs->vc5_hdmi_enable_scrambling && clock > HDMI_14_MAX_TMDS_CLK) return MODE_CLOCK_HIGH; + /* 4096x2160@60 is not reliable without overclocking core */ + if (!vc4->hvs->vc5_hdmi_enable_4096by2160 && + mode->hdisplay > 3840 && mode->vdisplay >= 2160 && + drm_mode_vrefresh(mode) >= 50) + return MODE_CLOCK_HIGH; + if (info->max_tmds_clock && clock > (info->max_tmds_clock * 1000)) return MODE_CLOCK_HIGH; @@ -1522,7 +1529,7 @@ vc4_hdmi_encoder_compute_clock(const struct vc4_hdmi *vc4_hdmi, unsigned long long clock; clock = vc4_hdmi_encoder_compute_mode_clock(mode, bpc, fmt); - if (vc4_hdmi_encoder_clock_valid(vc4_hdmi, clock) != MODE_OK) + if (vc4_hdmi_encoder_clock_valid(vc4_hdmi, mode, clock) != MODE_OK) return -EINVAL; vc4_state->tmds_char_rate = clock; @@ -1685,7 +1692,7 @@ vc4_hdmi_encoder_mode_valid(struct drm_encoder *encoder, (mode->hsync_end % 2) || (mode->htotal % 2))) return MODE_H_ILLEGAL; - return vc4_hdmi_encoder_clock_valid(vc4_hdmi, mode->clock * 1000); + return vc4_hdmi_encoder_clock_valid(vc4_hdmi, mode, mode->clock * 1000); } static const struct drm_encoder_helper_funcs vc4_hdmi_encoder_helper_funcs = { diff --git a/drivers/gpu/drm/vc4/vc4_hvs.c b/drivers/gpu/drm/vc4/vc4_hvs.c index e28a13a75ec2..32f5ab937ace 100644 --- a/drivers/gpu/drm/vc4/vc4_hvs.c +++ b/drivers/gpu/drm/vc4/vc4_hvs.c @@ -698,6 +698,9 @@ static int vc4_hvs_bind(struct device *dev, struct device *master, void *data) if (max_rate >= 550000000) hvs->vc5_hdmi_enable_scrambling = true; + if (max_rate >= 600000000) + hvs->vc5_hdmi_enable_4096by2160 = true; + hvs->max_core_rate = max_rate; ret = clk_prepare_enable(hvs->core_clk); From patchwork Tue Sep 20 12:50:26 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 12982129 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 4F2D0C6FA8B for ; Tue, 20 Sep 2022 12:57:38 +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=jpTZktcS1MddYs2uCW6HVJlTk/B36AdNXiM0NFJP3QQ=; b=plCKMfA3Oj/JHY juPYtxuIqjsx7fV1zVqrauCzCUWh7MX6CHXMPiqCLqc6P13n9scx8F4u6jUDmNqeRf4WVoY/OZr+Y U2Kve64LWvgv6AcL8zoOq6nLiaqFpHsoFBJj8HxlXwV0XKW0Y2/58YvTFXfadLD8kb7JqZjYOjPjA aNBoiXr3J1z/3Gby79QqCwFEquTRSLGP2ppL0J8ZIC1yWnZ1fmYtXY3Horf7e0XYgVZFbKR7zFnKO uAGgTro6BghYt2tvzAIFIZ5yNHwsPx/f7fh8/NIXnIEe9l6GwG0F4fOW1V61dP0hzqJq4pISDz+Xv ubA7Wf8WomiAOgLhXvQw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oacnJ-003rcS-F9; Tue, 20 Sep 2022 12:56:10 +0000 Received: from wout4-smtp.messagingengine.com ([64.147.123.20]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oackf-003q1x-MW; Tue, 20 Sep 2022 12:53:33 +0000 Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.west.internal (Postfix) with ESMTP id A97683200A0C; Tue, 20 Sep 2022 08:53:23 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute5.internal (MEProxy); Tue, 20 Sep 2022 08:53:25 -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=fm2; t=1663678403; x= 1663764803; bh=wGqLmKp8PyrCWTiski6RZ9ILduluZPIkJhco5wIZcAs=; b=X nMjZ841XeoCfJsO/Ga2e8KRZBI9BfRkLJYsauzFgSdp86HD6ti5ybHpc7KeY/Ojt N/ohr9g/wb23hgFp5YSLM3qb7DXKFw/FSpV0a0KcrvD9fwy52qNOR6eJOWEL5nE/ A7zfy7IFSNG1lV0wrDq9LZ7rPp9RGZA7jXz+AV15xH9ziV0cFSYov1rtmQzFQBnZ bpP70LxE2TvxKDuMwU4XHGX1j6yhlPBo4bXSlSvcPWbBGD4AQ0IRJycODtZEhpYo W213L5bJiFsAnH9Hu3Q4JssBd94duaBtqTP329H6JrXKsltb8ac2/Ei4UY7NYqrU mVDGNspd5SjHw6L4TqGIw== 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=fm2; t=1663678403; x= 1663764803; bh=wGqLmKp8PyrCWTiski6RZ9ILduluZPIkJhco5wIZcAs=; b=z ZmbmMhjJYLtD89tLN/IOlairvEfjMDcnCv7RC1Ti+TyNE0Fr+FHuw61hwSjule6T 9af7wc0hugoYAQ52Ix8RgcndEx7AnCWDI5MoeuxiMzbMf1ni5sRwyPgiDm4mv6wY ZX3/FlFmdwU1xZczRL/ny6zl89F6L84hsCshhLK+w9mNuVoWluM1eDeJjkEBiBlh UD3f1WksZ7MO3kocXgoMISeHHQfFbx1yyX4pXtIRcv3xFthw6ClRfE63+dKIxvAF mRt01imSnzKnpVGIOko9bEBNd4F5OUXxjsY8tSY7HgeRoPvjJthJPabUxoM3olCt ZVAjcRZiygJp6micv5zjg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedrfedvledgheekucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephfffufggtgfgkfhfjgfvvefosehtkeertdertdejnecuhfhrohhmpeforgig ihhmvgcutfhiphgrrhguuceomhgrgihimhgvsegtvghrnhhordhtvggthheqnecuggftrf grthhtvghrnhepudduudfhveejteefgedvffdvvedvjedugedukeejhedtlefhffevtefh jeeltdevnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomh epmhgrgihimhgvsegtvghrnhhordhtvggthh X-ME-Proxy: Feedback-ID: i8771445c:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 20 Sep 2022 08:53:22 -0400 (EDT) From: Maxime Ripard Date: Tue, 20 Sep 2022 14:50:26 +0200 Subject: [PATCH v2 7/7] drm/vc4: Make sure we don't end up with a core clock too high MIME-Version: 1.0 Message-Id: <20220815-rpi-fix-4k-60-v2-7-983276b83f62@cerno.tech> References: <20220815-rpi-fix-4k-60-v2-0-983276b83f62@cerno.tech> In-Reply-To: <20220815-rpi-fix-4k-60-v2-0-983276b83f62@cerno.tech> To: Daniel Vetter , Florian Fainelli , David Airlie , Broadcom internal kernel review list , Michael Turquette , Scott Branden , Stephen Boyd , Emma Anholt , Ray Jui , Maxime Ripard Cc: linux-rpi-kernel@lists.infradead.org, linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org, Dom Cobley , dri-devel@lists.freedesktop.org, Maxime Ripard , linux-arm-kernel@lists.infradead.org X-Mailer: b4 0.10.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1880; i=maxime@cerno.tech; h=from:subject:message-id; bh=ktzm8C9IydCiRKTg61h6xCxAgPQPdqFOXPfUpNJEefY=; b=owGbwMvMwCX2+D1vfrpE4FHG02pJDMma2/k8XyfPEslInSfzsn/HPx+nqS2317rKzlr3d71VxsJ1 alsSOkpZGMS4GGTFFFlihM2XxJ2a9bqTjW8ezBxWJpAhDFycAjARRXtGho+R+a/8XG75hTAc2KY1cc lS5+J/B2c1lsxO2DRTTD+zMJ2RYbaBgdC0J/duRwdkR1ekn715qXWC06blFn/rKw+Waf6sYwEA 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-20220920_055331_013653_E589EF82 X-CRM114-Status: UNSURE ( 9.15 ) X-CRM114-Notice: Please train this message. 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 Following the clock rate range improvements to the clock framework, trying to set a disjoint range on a clock will now result in an error. Thus, we can't set a minimum rate higher than the maximum reported by the firmware, or clk_set_min_rate() will fail. Thus we need to clamp the rate we are about to ask for to the maximum rate possible on that clock. Signed-off-by: Maxime Ripard diff --git a/drivers/gpu/drm/vc4/vc4_kms.c b/drivers/gpu/drm/vc4/vc4_kms.c index b45dcdfd7306..d241620fd5a7 100644 --- a/drivers/gpu/drm/vc4/vc4_kms.c +++ b/drivers/gpu/drm/vc4/vc4_kms.c @@ -397,8 +397,8 @@ static void vc4_atomic_commit_tail(struct drm_atomic_state *state) if (vc4->is_vc5) { unsigned long state_rate = max(old_hvs_state->core_clock_rate, new_hvs_state->core_clock_rate); - unsigned long core_rate = max_t(unsigned long, - 500000000, state_rate); + unsigned long core_rate = clamp_t(unsigned long, state_rate, + 500000000, hvs->max_core_rate); drm_dbg(dev, "Raising the core clock at %lu Hz\n", core_rate); @@ -432,14 +432,17 @@ static void vc4_atomic_commit_tail(struct drm_atomic_state *state) drm_atomic_helper_cleanup_planes(dev, state); if (vc4->is_vc5) { - drm_dbg(dev, "Running the core clock at %lu Hz\n", - new_hvs_state->core_clock_rate); + unsigned long core_rate = min_t(unsigned long, + hvs->max_core_rate, + new_hvs_state->core_clock_rate); + + drm_dbg(dev, "Running the core clock at %lu Hz\n", core_rate); /* * Request a clock rate based on the current HVS * requirements. */ - WARN_ON(clk_set_min_rate(hvs->core_clk, new_hvs_state->core_clock_rate)); + WARN_ON(clk_set_min_rate(hvs->core_clk, core_rate)); drm_dbg(dev, "Core clock actual rate: %lu Hz\n", clk_get_rate(hvs->core_clk));