From patchwork Thu Oct 13 09:13:08 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 13005777 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 E4D72C433FE for ; Thu, 13 Oct 2022 09:14:31 +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=FTnAhJfcyjCzml8UHfPT+LPwRNXIPMGW35+KmyaXgNs=; b=FGr4RRFGGeztbb /g9qys3lXSmt98/IBZ7R8DGGc2V5VULOsWiZ2DwpyU66601tpLZIUV0KfQEYHeyZRKOrDDXMGKvno hIVQHpkOV+XOqyvqUK8XQSEDgkN2RJRAU05veyGOcQFjaDgbdyBxQrQ0bixMtIvZqNbOhnZtF0Hhm +8uwX2+pIsJqZwQ2ptz2n8JyYDy2yBmlshwEja54UwFQ/2qOzw/1kkr08dIo50hB1utZ4C3Z0kCFc alwDE70+guEsWBGLRopuAq8YQD0OuZZ7y8qnDVVlny2+UUxqksgBGWCqj0lT4PiLlWdhYbQJsS9NK dF82/WAY260ZTZud+hyw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oiuHP-00BETG-4A; Thu, 13 Oct 2022 09:13:27 +0000 Received: from out1-smtp.messagingengine.com ([66.111.4.25]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oiuHC-00BEOU-V8; Thu, 13 Oct 2022 09:13:16 +0000 Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.nyi.internal (Postfix) with ESMTP id 480685C00D5; Thu, 13 Oct 2022 05:13:14 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute3.internal (MEProxy); Thu, 13 Oct 2022 05:13:14 -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=1665652394; x= 1665738794; bh=bShaN/7NERGul8hcL4IyWVx5LIqH+sRwvrBsPYVMzg8=; b=E AiosCw/vKKYwxEjD5hfuO1Hg5/6A1SmEpDMxSHTiKxgcFrJJu+4GZzRGDtJBMQ1K OY9N6D414TUzQ/FLW/Nc3OjmqmdY7ezuTlSE9X4WclH4grJxR6DfzcE0fUVSYMq1 EPY5OHkAYL6NqOA6q0rdhtkV8gqBQpUCfHX9Dn25gM1qDoPXdSdBQtcdvbwFYAwf s1Nxu6PWscII1xtCQirriwo/XPqg3Yg+afBYqXi/FK4pp+zKIUv9XteBZHn0a3AI jGw+VQUJnMxQUUOwWCcHc5YvewsUI97STuNfVrJo55amFfWBTplhkRRV5Qv3YKwT dR98nPINGTQHb3ttl6how== 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=1665652394; x= 1665738794; bh=bShaN/7NERGul8hcL4IyWVx5LIqH+sRwvrBsPYVMzg8=; b=j YMV69Ay0N0U2JJzwInr3WafU2oixNPkiJdfF2YPp/XY5XO3CMMrFWH0Ocp5mLFka yxAkg03BnqsamL2DEIOhoq7QC4X/lJJndfSO4+sDqkMPZbOz2qvwIx39Vl75FGHh /bTcfXlgLgqTmQMaCbquTojPOOlnH983tz3wZCnjCBHgsx6ZSdq3yS9ncN0wizw/ KnP+hqT9AzpNcw8UgcW2FzXu+IwKEDmNRSgRK9nwLw7FJN/aCjeu//yMGPGaJAq5 tHP3XJX5jO5sLY1pkyB5ndEQUiKOxKg7ffKflBA+sYidLcY/bwZxxS2ZBTGn/UI/ bZkYEmlvWEho9DSGisJkQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedrfeektddgudegucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephfffufggtgfgkfhfjgfvvefosehtkeertdertdejnecuhfhrohhmpeforgig ihhmvgcutfhiphgrrhguuceomhgrgihimhgvsegtvghrnhhordhtvggthheqnecuggftrf grthhtvghrnhepudduudfhveejteefgedvffdvvedvjedugedukeejhedtlefhffevtefh jeeltdevnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomh epmhgrgihimhgvsegtvghrnhhordhtvggthh X-ME-Proxy: Feedback-ID: i8771445c:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 13 Oct 2022 05:13:13 -0400 (EDT) From: Maxime Ripard Date: Thu, 13 Oct 2022 11:13:08 +0200 Subject: [PATCH v3 1/7] firmware: raspberrypi: Introduce rpi_firmware_find_node() MIME-Version: 1.0 Message-Id: <20220815-rpi-fix-4k-60-v3-1-fc56729d11fe@cerno.tech> References: <20220815-rpi-fix-4k-60-v3-0-fc56729d11fe@cerno.tech> In-Reply-To: <20220815-rpi-fix-4k-60-v3-0-fc56729d11fe@cerno.tech> To: Florian Fainelli , Michael Turquette , Emma Anholt , Stephen Boyd , Ray Jui , Scott Branden , Broadcom internal kernel review list , Daniel Vetter , David Airlie , Maxime Ripard Cc: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Maxime Ripard , Stefan Wahren , linux-clk@vger.kernel.org, linux-rpi-kernel@lists.infradead.org, Dom Cobley , dri-devel@lists.freedesktop.org X-Mailer: b4 0.11.0-dev-7da52 X-Developer-Signature: v=1; a=openpgp-sha256; l=2223; i=maxime@cerno.tech; h=from:subject:message-id; bh=vWcb/Ejr0pN1Zc4Oe8EeogxMKfphDG9wQuTjtg3Mq60=; b=owGbwMvMwCX2+D1vfrpE4FHG02pJDMnu15ak3nFobW54oXNCbZfu6iq9loUWm5a33orgzM6MvRpc PzGko5SFQYyLQVZMkSVG2HxJ3KlZrzvZ+ObBzGFlAhnCwMUpABN5cpDhr+y95YVh1vNUBB7H84l7+8 pyZX0+u21iWPevGJZT/EqGKgx/OFrTv35m8Um/ctvqzp8T19L/9cQkXDx7bMeUJ11OognreAE= 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-20221013_021315_088963_30A5F0E5 X-CRM114-Status: UNSURE ( 9.77 ) 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 --- drivers/firmware/raspberrypi.c | 7 +++++++ include/soc/bcm2835/raspberrypi-firmware.h | 7 +++++++ 2 files changed, 14 insertions(+) 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 Thu Oct 13 09:13:09 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 13005778 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 6BB60C433FE for ; Thu, 13 Oct 2022 09:14:49 +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=BClelvjjz5+02qCyAFSQFw7qZNzA9ox8HMhgShF3an8=; b=nqVvQskR9oDm49 MhhCmawa8XtkHBTKfPzXBpKXr5WALyghk0SF7NJ9zgga0G2/ldHyJCFbgGUma1sQoDQ+ps0yu4Ycm 12H8t0Wfr4pd3PfxBLTmQBBbNN8AdJAGq30oag76WKFLJH+ScF3ivkoR7Rg31Qcl5xcyueRoqdLqf 15OPKxDgGJbjQgwIarg0t/3pqhJLZ2WD7fQ6yHUHFNDjliC9hPajX4ElJwvU6irIkAVMbWLnuIZ0J C4nFIDxOHX4JLAr0xGK/uZcMMuAI+1ujVeAHMgdtllA7B04mnb6zbpUECpfW0XDJw7UqOZ4IFxZVg 1AVlQyaxOk9o3wzUci1Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oiuHZ-00BEW8-4i; Thu, 13 Oct 2022 09:13:37 +0000 Received: from out1-smtp.messagingengine.com ([66.111.4.25]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oiuHE-00BEP0-Mz; Thu, 13 Oct 2022 09:13:18 +0000 Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.nyi.internal (Postfix) with ESMTP id 1BE895C010E; Thu, 13 Oct 2022 05:13:16 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute5.internal (MEProxy); Thu, 13 Oct 2022 05:13:16 -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=1665652396; x= 1665738796; bh=ML+ODx52p7Zj2uoXLzDPtbac1cZv+/aiKbj3DuchnPg=; b=Z ztm9CmuT4VAB2juZKzyeSFGG0KmTGkeilo+yzIa/RX04+1ExkNDcceHwrUeyNLXu SdWtvJX7aLLK4UNNx9F1G1LRM1KqzEoyiKH0HGR5qk0G0xshUja5+6xSiTXF6mBV lHsd8qw3DBLDUHzeEskY8WtuKRubrlj/6gE2LkMYA7scjNcYENBupDXJUdJ9mJJu KO82lWdbMAEJKqWwPFlM1Hozom5N7yEdriGlK8Ug0dlMfNU+4NhY5Sw8xyouK9Lm 7xhCZTV7s2t4x/bc6HRs4+sFdBqx0pFaFyz8VCX7b6bPeHYNK87e1h3WXfeU7EC6 sk1FiWS1xVUP3t+yaUp7Q== 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=1665652396; x= 1665738796; bh=ML+ODx52p7Zj2uoXLzDPtbac1cZv+/aiKbj3DuchnPg=; b=n HtSHUb+wyBBcF54w7Q/rgZo9noa80Q6Wy3vhZzQMn5q9KrDzuYiSV4U/VYPAB7gd 7FpGt0Iu6v9Txu8wQ7PUs2uNOJ9duxR4vyYDYsNgDaaJtNLP7t5DDWF1ZYik5ju6 37K8qzUCY20Rnxk14/wKdeh7mGiwGadenzCG2Ny7Ji1lpyK90nu6JWPvTGAGCiGt yo64YhTK2FszaEQmfsS8HaU2qJrFtOAiUL2MRBncL21iVriQ1SdpBeW7K1AIm4hi 1JAZZfRb53t43Z4u3yuAXighP8b1FYUyyQzgzbmJaftCOtMf1BpmEMki8yI3/k+r S3xvxUqOSf76qlNfp2IYQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedrfeektddgudegucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephfffufggtgfgkfhfjgfvvefosehtkeertdertdejnecuhfhrohhmpeforgig ihhmvgcutfhiphgrrhguuceomhgrgihimhgvsegtvghrnhhordhtvggthheqnecuggftrf grthhtvghrnhepudduudfhveejteefgedvffdvvedvjedugedukeejhedtlefhffevtefh jeeltdevnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomh epmhgrgihimhgvsegtvghrnhhordhtvggthh X-ME-Proxy: Feedback-ID: i8771445c:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 13 Oct 2022 05:13:15 -0400 (EDT) From: Maxime Ripard Date: Thu, 13 Oct 2022 11:13:09 +0200 Subject: [PATCH v3 2/7] firmware: raspberrypi: Move the clock IDs to the firmware header MIME-Version: 1.0 Message-Id: <20220815-rpi-fix-4k-60-v3-2-fc56729d11fe@cerno.tech> References: <20220815-rpi-fix-4k-60-v3-0-fc56729d11fe@cerno.tech> In-Reply-To: <20220815-rpi-fix-4k-60-v3-0-fc56729d11fe@cerno.tech> To: Florian Fainelli , Michael Turquette , Emma Anholt , Stephen Boyd , Ray Jui , Scott Branden , Broadcom internal kernel review list , Daniel Vetter , David Airlie , Maxime Ripard Cc: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Maxime Ripard , Stefan Wahren , linux-clk@vger.kernel.org, linux-rpi-kernel@lists.infradead.org, Dom Cobley , dri-devel@lists.freedesktop.org X-Mailer: b4 0.11.0-dev-7da52 X-Developer-Signature: v=1; a=openpgp-sha256; l=2282; i=maxime@cerno.tech; h=from:subject:message-id; bh=O/C1GjD9JjcVdok+PjgiTRoaq2K0l0WecgWMoNXNBjc=; b=owGbwMvMwCX2+D1vfrpE4FHG02pJDMnu15b0K5av2VF75NSt4gqL5EWt6vqMOaZyr9vz33GyT5uZ et6zo5SFQYyLQVZMkSVG2HxJ3KlZrzvZ+ObBzGFlAhnCwMUpABPhYmJkOC+wr4r35bX1EyYeelvuFv DyUGPewwUFHOI36zNnfb3Xe5+R4Y1a/5b89Y5n9/w8uts69sa/cotjuYu1rgiuP9lyuenwYj4A 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-20221013_021316_849883_211B070E X-CRM114-Status: UNSURE ( 7.92 ) 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 Acked-by: Stephen Boyd Reviewed-by: Florian Fainelli --- drivers/clk/bcm/clk-raspberrypi.c | 18 ------------------ include/soc/bcm2835/raspberrypi-firmware.h | 18 ++++++++++++++++++ 2 files changed, 18 insertions(+), 18 deletions(-) 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 Thu Oct 13 09:13:10 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 13005779 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 9B3BCC4332F for ; Thu, 13 Oct 2022 09:14:49 +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=N5/fuaN8Yd30hXRymnWFebGUI+C/RnE04dELlVqaLJ0=; b=b1fBvW2PHBOjs4 6qrcnLQ6yQYtWxapyaZalhUEdAKljBRmuZxtK2MPBpwboioPbHhC0CrBUGC167ycpVS/vZJhu5QG5 Gt4u1Nfomi8AXJi+CQIsRvDw+Zj4XcR0+KUhz+H3PMHNuE1geX9FARLCP2rAUGm2C2opkOoN3T3PX APDLSSLt0fIwaQiZJlFc3U+3BbgNqipFMCFro3Ft37/mTLdatN8iAK1mnL3MmUhYqrzOiYoiM/huh e/qhOH6gJdO0LRcvmmaY88RMXlC34UyGZzdZd7WUr+3uq3Cc5QjwfRKsJlwYlXDxGSnasy36gmHwu iei6X3jZWsEZFiI50vPA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oiuHi-00BEYt-4s; Thu, 13 Oct 2022 09:13:46 +0000 Received: from out1-smtp.messagingengine.com ([66.111.4.25]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oiuHG-00BEPT-DG; Thu, 13 Oct 2022 09:13:19 +0000 Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id C860C5C00D5; Thu, 13 Oct 2022 05:13:17 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute2.internal (MEProxy); Thu, 13 Oct 2022 05:13:17 -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=1665652397; x= 1665738797; bh=NbLfsfDu1Gtr2c9qmTrYb//pcpOFa59Pn2YWUwdR2PQ=; b=v btCpBwB/dRvHJNh0uI58CDkNB68elf0mXaDTcTgRndoUTf0zCIQeMDtwFrxM8um+ XwJWnEdsiC5nq5CzPoHkfY6TVE8y1h0mPbCrY7V+JuH9vFurD0A2K4nzhVt0+vhX waJUsEwzIlRyZVFXyDSTAIcy/3ONewTOagiq8L5ynmvLk3mrTZwlM/eMs7Ah1zSn DJxT7L0b2znlVIRcOmwkOHcmIhwKgWOWo3OZgSL61Q4qMb2qdKmLb8IAE3axLnR6 Q73dP2H2CZsXliafRb+KFYNDx6NQhifboMeKC6Ium3JJ6hltyb8kOIb5wdkSO7KQ imrfWCd8dfcMwFEuvFhSg== 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=1665652397; x= 1665738797; bh=NbLfsfDu1Gtr2c9qmTrYb//pcpOFa59Pn2YWUwdR2PQ=; b=T PWfBqKrIsFE6oum+0YE5rNlNG508+cLK1ooGcDBMdHx7E5NZZmRoYErukFlsi4QP 3xgi1gKoZJR0hcplg0V7HkFSwer8XCiQuMVZjvRw1r5sd3cLExrbQgYoZ9K37y4+ leWarvxWLgtofU0W0xmwzH04Oz+XzjsVgjrASb1R10pVCMwUtsDCoh7IzjYfKpoP H+tBLQjw91xozW5dm01eheXGZtvzVdMORMByvGGi75gECCdgwL2WcNFGPAwXv7pF 1Tqa0ZXQLRqotmapTogf0Xosi7AA8qjAZkvdrTJTOQ+oLoWcu08IuvcQDFsNBEex 4jhJ+o9VfPdbUbG5cjyeA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedrfeektddgudegucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephfffufggtgfgkfhfjgfvvefosehtkeertdertdejnecuhfhrohhmpeforgig ihhmvgcutfhiphgrrhguuceomhgrgihimhgvsegtvghrnhhordhtvggthheqnecuggftrf grthhtvghrnhepudduudfhveejteefgedvffdvvedvjedugedukeejhedtlefhffevtefh jeeltdevnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomh epmhgrgihimhgvsegtvghrnhhordhtvggthh X-ME-Proxy: Feedback-ID: i8771445c:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 13 Oct 2022 05:13:17 -0400 (EDT) From: Maxime Ripard Date: Thu, 13 Oct 2022 11:13:10 +0200 Subject: [PATCH v3 3/7] firmware: raspberrypi: Provide a helper to query a clock max rate MIME-Version: 1.0 Message-Id: <20220815-rpi-fix-4k-60-v3-3-fc56729d11fe@cerno.tech> References: <20220815-rpi-fix-4k-60-v3-0-fc56729d11fe@cerno.tech> In-Reply-To: <20220815-rpi-fix-4k-60-v3-0-fc56729d11fe@cerno.tech> To: Florian Fainelli , Michael Turquette , Emma Anholt , Stephen Boyd , Ray Jui , Scott Branden , Broadcom internal kernel review list , Daniel Vetter , David Airlie , Maxime Ripard Cc: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Maxime Ripard , Stefan Wahren , linux-clk@vger.kernel.org, linux-rpi-kernel@lists.infradead.org, Dom Cobley , dri-devel@lists.freedesktop.org X-Mailer: b4 0.11.0-dev-7da52 X-Developer-Signature: v=1; a=openpgp-sha256; l=3367; i=maxime@cerno.tech; h=from:subject:message-id; bh=RlOL1ZTsE2adkZajmlAYwbEWoCI8gC05XMJ1fjN2UAo=; b=owGbwMvMwCX2+D1vfrpE4FHG02pJDMnu15ZMmB1f+OGOaJ3DD/NDG62OXJho9PnTrrmnjBaasMqU TIxY3FHKwiDGxSArpsgSI2y+JO7UrNedbHzzYOawMoEMYeDiFICJ6D1lZFi6+Gf0ygvPX4Wtlln+eY Lnx/9bRT19U4piEqt+qqocfsnPyNDg1Ovz5+aUr6K1EVMSn5ezSLVI+Bvv+bH/tlxyVIeSNycA 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-20221013_021318_542953_845D8EA8 X-CRM114-Status: GOOD ( 13.45 ) 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. Acked-by: Stephen Boyd Signed-off-by: Maxime Ripard Reviewed-by: Florian Fainelli --- drivers/firmware/raspberrypi.c | 20 ++++++++++++++++++++ include/soc/bcm2835/raspberrypi-firmware.h | 26 ++++++++++++++++++++++++++ 2 files changed, 46 insertions(+) diff --git a/drivers/firmware/raspberrypi.c b/drivers/firmware/raspberrypi.c index b916e1e171f8..1353ec2f9b53 100644 --- a/drivers/firmware/raspberrypi.c +++ b/drivers/firmware/raspberrypi.c @@ -228,6 +228,26 @@ 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) + /* + * If our firmware doesn't support that operation, or fails, we + * assume the maximum clock rate is absolute maximum we can + * store over our type. + */ + return UINT_MAX; + + 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 Thu Oct 13 09:13:11 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 13005780 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 087D9C433FE for ; Thu, 13 Oct 2022 09:15:02 +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=uHhvkBSgna6uQxirSta2Bjk3pj/5zA1v88vWi0y/57Y=; b=pCKVM0Q6s8Pqpm qXrHLcn2z8y/GqAkAp4LrM6UmZytkobF783ITLNLrfrH4pSkaGuUSulXpKMeJn2aFzFFW7V8GVObt 0Z+84/hpT5b+W0w6qbpSsNIOAR9JXJT714v1YC1BDFi2yrcBBoRut0zeoRN5QCZU+q/lVnMxxofiz xDbIrRY0zEh+XZmbjrFHuDgsS35FOycctw+QgmWNWhCRX2PiVH6W/MQStbH+HkHw6IHC3CNGjIzeU y3BtlQViEsFYLdelpQWu3gtCLn6Ng2OpYnDfKLXRINLw03y2xdRvK31tf/cqMM0eAgEUCZTycZ1gO T4UieRVqndjPAuj5rVJQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oiuHu-00BEfD-Ee; Thu, 13 Oct 2022 09:13:58 +0000 Received: from out1-smtp.messagingengine.com ([66.111.4.25]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oiuHI-00BEPu-3b; Thu, 13 Oct 2022 09:13:21 +0000 Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.nyi.internal (Postfix) with ESMTP id 7F4375C00EE; Thu, 13 Oct 2022 05:13:19 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute5.internal (MEProxy); Thu, 13 Oct 2022 05:13:19 -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=1665652399; x= 1665738799; bh=ZQjFpYF4e0Dy/cWO7rqPvZZq5y+2aveHJD01sKou3PU=; b=y cebru2AvS8YSPHdZivIu35r08q7j5b0spf7C2/oPrjCXnSPNwTe32zs7h8+CSW4N uC4pNldahFzjVWhzMkVvIOg0Zt9rxNMREr3pTZXS6o0X0IoCEOXhOdBQkY4MaVIv nERnRt16WNUhv2+k84DHjxJis9PTxACkchZfTD/ohIFT7uyY6JbR8GDMGA0ctluM jT7O5Jocer5xv1LHdk3qYvTt/KfkjjveiMgl7qAmqiCOkLjQHmHGLjJhL5nDzxwt 97a2SOoAArQplSz8sfdbmaQg7M8TpLZ58tXwCiqbOoZ/akdfwP4MXvOVHTiUiVbg xQ/LaeQKz4R0DcoWcEfHw== 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=1665652399; x= 1665738799; bh=ZQjFpYF4e0Dy/cWO7rqPvZZq5y+2aveHJD01sKou3PU=; b=e CFacKkbVJPckcAjNKWtetOmybTV+4rF97s1DA2qsNrPa4KK3Be7hFQf/qrWjgMoU 04VvoqoBG9hhUgCYjUvPqQj64YHWqfvHR+oUrZrWYRiij0OiEDp8UN58et6muUeu HZ0daqS/a2AFa6CqeLyxl2pr/zqBUt6zX5HV0lEZCOumoKIVVeVqh4kw90qOHF/k yjqUGyrYGsjGY1SJUKqPpXCbLdM5+ejBsYcCmtOvewyxp8FUgEyMBQ2Rt7m70MAt 0JKHp/3SPeByD3bOOB5WQvISdAX+AtcEP0UIeSfmE2kTls3nO94GUQKuh4G5/mIj 4y/1YwwCIc7SN6lO96Pmg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedrfeektddgudegucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephfffufggtgfgkfhfjgfvvefosehtkeertdertdejnecuhfhrohhmpeforgig ihhmvgcutfhiphgrrhguuceomhgrgihimhgvsegtvghrnhhordhtvggthheqnecuggftrf grthhtvghrnhepudduudfhveejteefgedvffdvvedvjedugedukeejhedtlefhffevtefh jeeltdevnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomh epmhgrgihimhgvsegtvghrnhhordhtvggthh X-ME-Proxy: Feedback-ID: i8771445c:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 13 Oct 2022 05:13:18 -0400 (EDT) From: Maxime Ripard Date: Thu, 13 Oct 2022 11:13:11 +0200 Subject: [PATCH v3 4/7] drm/vc4: hdmi: Fix hdmi_enable_4kp60 detection MIME-Version: 1.0 Message-Id: <20220815-rpi-fix-4k-60-v3-4-fc56729d11fe@cerno.tech> References: <20220815-rpi-fix-4k-60-v3-0-fc56729d11fe@cerno.tech> In-Reply-To: <20220815-rpi-fix-4k-60-v3-0-fc56729d11fe@cerno.tech> To: Florian Fainelli , Michael Turquette , Emma Anholt , Stephen Boyd , Ray Jui , Scott Branden , Broadcom internal kernel review list , Daniel Vetter , David Airlie , Maxime Ripard Cc: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Maxime Ripard , Stefan Wahren , linux-clk@vger.kernel.org, linux-rpi-kernel@lists.infradead.org, Dom Cobley , dri-devel@lists.freedesktop.org X-Mailer: b4 0.11.0-dev-7da52 X-Developer-Signature: v=1; a=openpgp-sha256; l=1913; i=maxime@cerno.tech; h=from:subject:message-id; bh=f1lo6Ai83eEY39RwlVf8bpafgmNreYn4rcZrYcxd9Lc=; b=owGbwMvMwCX2+D1vfrpE4FHG02pJDMnu15bYFYvKHn33JrTu102PFdfPm1y58np6WuKsB8lfp5Zs k59q1VHKwiDGxSArpsgSI2y+JO7UrNedbHzzYOawMoEMYeDiFICJmN5kZDg/c66DyqWv93i2ljpEBJ koGRybdOf53ffGiqeOaiwpzvjN8N+7rrvyffARowALc0e3+4uiJwpMuHpuKk+sGueEQBedCWwA 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-20221013_021320_271739_5257DE3E X-CRM114-Status: GOOD ( 13.82 ) 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 --- drivers/gpu/drm/vc4/vc4_hdmi.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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 Thu Oct 13 09:13:12 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 13005781 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 9B48AC433FE for ; Thu, 13 Oct 2022 09:15:23 +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=FaXL4n7vJUlxJUpVpLy4RoJ1EP1wTDxWdY5Hj4wwJng=; b=poYG0L6UOMTXTE kOUPBo7crEzfz0GiWEnua7oCc0mdIxKhr3tzS5QrHrhHJvEmkJrOwMsPrKcdm2u535QuVDAuE7zXB yb3M7WtUDTEav/SGA2tHQ/TVVJlwgf3r6t6LCz395pS7IO0Nnfb4iQ4QkRe/ykuXqyGWhhfkMiC9t 0s+FfESZ2hy3s2RlYjAdNiewXNA/unUbXAglLtDlPMDgGFNNj7n6A6WXqNLVAp5gL091YKXqUbws7 AZSoxL9WbSXrAC0T2DAkORLxUK3bPpRbKbP8vo9dUDE/wNZu71DNuZG+POZBjd6YAISriRWaGSovr K6Avy92y4bJOdYxP9Ehw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oiuI8-00BEm6-Rj; Thu, 13 Oct 2022 09:14:13 +0000 Received: from out1-smtp.messagingengine.com ([66.111.4.25]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oiuHJ-00BEQq-PO; Thu, 13 Oct 2022 09:13:23 +0000 Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id 2D7785C009B; Thu, 13 Oct 2022 05:13:21 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute1.internal (MEProxy); Thu, 13 Oct 2022 05:13:21 -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=1665652401; x= 1665738801; bh=2JSMy2S6xUR+ZHeYAulhRYzlIjCrNr0csZYZefwkoR8=; b=O MUGa4dzGhLRMSNRLmAR0jDbypSzSMfqPEkSlpzyQ7CvJzYrwKdIC8Ryxcycy3PF3 wUim0iW4UTjpigXSdNUcw3ewWQy8caPLTQAchTpzIVNyzERTcI6Dg8XxcStowR1A 9+BPYTYguYMRJFx5wYBlRUuHWpLxNtS+f5YafuVDZngM/riqOvfJMIeszogaevgW T193oukcZnoN/IT1SZq3BnPnJtLpUXXPJyLVBEjjOJScL6Ujg+4kAeDbdOfGmUqe FzixXTkug5jgaJtQv5LNob2vh/ZC1vGJWrrZW2VG4Lhd8CLPIyZuMeqNS6ZKGojR 7b0iHFiLVGUSDeRXrUPhg== 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=1665652401; x= 1665738801; bh=2JSMy2S6xUR+ZHeYAulhRYzlIjCrNr0csZYZefwkoR8=; b=A dXu5h0MxThMcz8HuEYg1nSc1QHA/BHjNBsINpe+hhmO7D/N/znd1j/OOGyLz07C4 5PkULwbRBL0xp2HlrbzavzcOqEbbJh2IAobzAzQgXEA8xZ1QYdSeplkwa8/XOSrZ nC0OeNSEaUwfI2Fnr9wz+UASE6TTTyPH/t3Pk4pCfr6BTWJFPhvc3s1yC1k0ZSr1 N8YeKL+9B5uW1AlqxRg83bpcS6cwoE8PyK68VIJMw/WVJor9UOLe3m6qY3CeLCS8 skYk/hRzaXvDAc3w0Sykrf+U4bRPDtGgJxwxBUd1QNMpOSNo7dDm3nEpNmfPmqiP IjC9qb5yfolJn5UTDLs7A== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedrfeektddgudegucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephfffufggtgfgkfhfjgfvvefosehtkeertdertdejnecuhfhrohhmpeforgig ihhmvgcutfhiphgrrhguuceomhgrgihimhgvsegtvghrnhhordhtvggthheqnecuggftrf grthhtvghrnhepudduudfhveejteefgedvffdvvedvjedugedukeejhedtlefhffevtefh jeeltdevnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomh epmhgrgihimhgvsegtvghrnhhordhtvggthh X-ME-Proxy: Feedback-ID: i8771445c:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 13 Oct 2022 05:13:20 -0400 (EDT) From: Maxime Ripard Date: Thu, 13 Oct 2022 11:13:12 +0200 Subject: [PATCH v3 5/7] drm/vc4: hdmi: Rework hdmi_enable_4kp60 detection code MIME-Version: 1.0 Message-Id: <20220815-rpi-fix-4k-60-v3-5-fc56729d11fe@cerno.tech> References: <20220815-rpi-fix-4k-60-v3-0-fc56729d11fe@cerno.tech> In-Reply-To: <20220815-rpi-fix-4k-60-v3-0-fc56729d11fe@cerno.tech> To: Florian Fainelli , Michael Turquette , Emma Anholt , Stephen Boyd , Ray Jui , Scott Branden , Broadcom internal kernel review list , Daniel Vetter , David Airlie , Maxime Ripard Cc: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Maxime Ripard , Stefan Wahren , linux-clk@vger.kernel.org, linux-rpi-kernel@lists.infradead.org, Dom Cobley , dri-devel@lists.freedesktop.org X-Mailer: b4 0.11.0-dev-7da52 X-Developer-Signature: v=1; a=openpgp-sha256; l=5858; i=maxime@cerno.tech; h=from:subject:message-id; bh=DuTFZxWsGq/sZk7xQ05Ey8kf6JSb104QwOLdz5GnoB8=; b=owGbwMvMwCX2+D1vfrpE4FHG02pJDMnu15aoiD6OXct+bWenhoulu8480+NeE24WfLC/JKArKyW4 UuNiRykLgxgXg6yYIkuMsPmSuFOzXney8c2DmcPKBDKEgYtTACaiO5eR4U64+YQ7Xc0BTsnfG5Kdwt Ozteu3dOYvn8Rd6bt62jk2BkaG56W1T5Ic44Vddz4zWqf+yOL/mWsPgpv7bzLY7brjwRPHDQA= 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-20221013_021321_945912_43E904AC X-CRM114-Status: GOOD ( 21.08 ) 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 --- drivers/gpu/drm/vc4/vc4_drv.h | 10 ++++++++++ drivers/gpu/drm/vc4/vc4_hdmi.c | 15 ++++----------- drivers/gpu/drm/vc4/vc4_hdmi.h | 8 -------- drivers/gpu/drm/vc4/vc4_hvs.c | 23 +++++++++++++++++++++++ 4 files changed, 37 insertions(+), 19 deletions(-) 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 Thu Oct 13 09:13:13 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 13005782 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 04EBDC433FE for ; Thu, 13 Oct 2022 09:15:50 +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=6BasDcPA1VlPiPsvadtTV3R3h76aEMuZI5v848adkTQ=; b=iwR9OFd9QxDB5S Ylu6mHUQI97xcTQHLp+Qs0/lgkCweKwD73dC9aVmM2PwPvC/iPfpwKyLfXvY9DqRhMNBmEKM8qBWY TdPCFyRz3bWNJHHACcTIE8AfMb9IUy14ijOGobX+hq+frkM0EuTvYNwVQLwFI+nyEW7Pls4NCim2c V1ifEtfBzeEuHR06pZA/O3IAH61oPKSgcedJ5JgkuEnG/nK/Ef4Q+KuGODu26O9xLqqVCmw4VHIcs dnwJBVsLaltGA24VmQL0EoDiIg2tjfT4UGTTfRyztlKFIW7GKBVObhEZnR8jDRDS0JVZYd38fLy3k lh1EeNKd/Z4i3/vSRzKA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oiuIU-00BEvZ-Bl; Thu, 13 Oct 2022 09:14:34 +0000 Received: from out1-smtp.messagingengine.com ([66.111.4.25]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oiuHL-00BERS-HO; Thu, 13 Oct 2022 09:13:25 +0000 Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.nyi.internal (Postfix) with ESMTP id DE78B5C0162; Thu, 13 Oct 2022 05:13:22 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute3.internal (MEProxy); Thu, 13 Oct 2022 05:13:22 -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=1665652402; x= 1665738802; bh=qmzT73Nu8Eo80tOnAkFbYbAqOXBysXSE5lE905g1TjE=; b=d l3+WEg5YQS895fzP8Iv6T22TGg5de4JRmgwkSHgT7i8T688LZn8IkrjHppYsoP8k AvHpHaXwiviVbWxbKthEKPGfUq7fXfNRSv3P2gyxCP0VeRkC7019rv2SCCLhSOIB HyTNvS3V5bWCVpF6PenHg8ZIvrUoJLTqVvLpCKLElkqDR9Lxtc+oe2JpKNPA+oIe eJXWF+Gyq/Q5jF7bJ02a7aevmbB8UEkKyv7fs5wtfuL8TqUEZFSMUyY3XBJpRXg7 kgkSdVdkHCnyYiuTvH30EfveL/INnexP3VFugT2uqolu/snmRKNgcpTEvbVykqOM Iq+VB5mPTjULSzsYrQMhQ== 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=1665652402; x= 1665738802; bh=qmzT73Nu8Eo80tOnAkFbYbAqOXBysXSE5lE905g1TjE=; b=A nQIVh1bP0qcIsXkAlIvQ1h2kQA4MYkCxHMQzomBmSaq+X17CxBXpaOZBdiTB5Fg3 oRYOe4bvHU4EYG9en5v9+mEbq3rLldPkJ6E8RUKG+boHTlKPuDXKCEbO4mxqbuto Q1HlBQD6gOOCJlZBJCTin8nYKk/gEET0v0ub9k8MBiMTYjIGoEbg41w3HdwSjIu4 834no9bp4dZwTPzVOLsdbd7D4wlDtcyA3V/krL1bVUvpLxyQH+RnQBPWYWq2Ofwv HzJp4//sAPxXNANwxjJsxRb7QoteIT8EgutlxrDMeSveKejNAOMc5pIRhVo5skWd KEHFMSjxsJlLKBFRqHupQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedrfeektddgudegucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephfffufggtgfgkfhfjgfvvefosehtkeertdertdejnecuhfhrohhmpeforgig ihhmvgcutfhiphgrrhguuceomhgrgihimhgvsegtvghrnhhordhtvggthheqnecuggftrf grthhtvghrnhepudduudfhveejteefgedvffdvvedvjedugedukeejhedtlefhffevtefh jeeltdevnecuvehluhhsthgvrhfuihiivgepudenucfrrghrrghmpehmrghilhhfrhhomh epmhgrgihimhgvsegtvghrnhhordhtvggthh X-ME-Proxy: Feedback-ID: i8771445c:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 13 Oct 2022 05:13:22 -0400 (EDT) From: Maxime Ripard Date: Thu, 13 Oct 2022 11:13:13 +0200 Subject: [PATCH v3 6/7] drm/vc4: hdmi: Add more checks for 4k resolutions MIME-Version: 1.0 Message-Id: <20220815-rpi-fix-4k-60-v3-6-fc56729d11fe@cerno.tech> References: <20220815-rpi-fix-4k-60-v3-0-fc56729d11fe@cerno.tech> In-Reply-To: <20220815-rpi-fix-4k-60-v3-0-fc56729d11fe@cerno.tech> To: Florian Fainelli , Michael Turquette , Emma Anholt , Stephen Boyd , Ray Jui , Scott Branden , Broadcom internal kernel review list , Daniel Vetter , David Airlie , Maxime Ripard Cc: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Maxime Ripard , Stefan Wahren , linux-clk@vger.kernel.org, linux-rpi-kernel@lists.infradead.org, Dom Cobley , dri-devel@lists.freedesktop.org X-Mailer: b4 0.11.0-dev-7da52 X-Developer-Signature: v=1; a=openpgp-sha256; l=3452; i=maxime@cerno.tech; h=from:subject:message-id; bh=oHROItAGNywnvJYBrN7pZtlhRHDQIJa7w2WOAz0D1No=; b=owGbwMvMwCX2+D1vfrpE4FHG02pJDMnu15b47m09yaP5K5Pvd6jdX/9WDWE1a8vTz+ZrydYvtHKR 1vzTUcrCIMbFICumyBIjbL4k7tSs151sfPNg5rAygQxh4OIUgIkkTGD4Zxxv+20F63LB8/+z+vbPmd Znq9ZUNN9CJvwYXyabcIY6EyPDqQsxJwUXNNhcs1CY7m0jFjy1QuK/jL9upbKxSFKU8F1GAA== 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-20221013_021323_766525_76979D44 X-CRM114-Status: GOOD ( 14.90 ) 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 --- drivers/gpu/drm/vc4/vc4_drv.h | 6 ++++++ drivers/gpu/drm/vc4/vc4_hdmi.c | 11 +++++++++-- drivers/gpu/drm/vc4/vc4_hvs.c | 3 +++ 3 files changed, 18 insertions(+), 2 deletions(-) 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 Thu Oct 13 09:13:14 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 13005783 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 72475C433FE for ; Thu, 13 Oct 2022 09:16:02 +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=6r/0o+/ZypDs1hk8dnGh38NzdYjg1hP1fnlnYccBZTw=; b=JndolRSYIa93NX 1KwoQgaUu3sucsrWmdFR05NfUeNOStfrArX6RB8YOmRKZTnYcDFzZoWKRQBSnOYICEfC6mCB+TkLF IdWU7pvnhVc82/HZCU1DlS3LjbVDWcAwk969dQz7eVoXbOu3exTTEPlEdzrPq1CyJb9wv5cUyxR+z 9mimUJnztseTbThAMFwtgC7mvq73BoiHFGnkTHGCTpgzDUdfBW6k6797IryZtdVpt6w7h+ZNHVWkw XZqodC+5UBxZBYED5QyBV6k8zE+rKtvNRm3ki7mGCVmHfk6tx4uj5LRZXbp65EWvyfkReCqUkuvPg UIT/bZqCyKZY6dNts8vA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oiuIp-00BF4Q-2Z; Thu, 13 Oct 2022 09:14:55 +0000 Received: from out1-smtp.messagingengine.com ([66.111.4.25]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oiuHN-00BES6-7U; Thu, 13 Oct 2022 09:13:26 +0000 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id 9AB5E5C0088; Thu, 13 Oct 2022 05:13:24 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute4.internal (MEProxy); Thu, 13 Oct 2022 05:13:24 -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=1665652404; x= 1665738804; bh=VNQ+rzhIH5hRx9r2piVwTWvHL+idSBOUdFscI6rLzxE=; b=J CA5Tta1qADmnwMO1RYaiaSS2ehgaXa7BsEORpl1pfzmZJLTokz8L92qW+AeWqt5E HY7IzdfYmVnoSDrr8smGWFOHJMcUtm7QRVdCEyDmR96IS/kuVy5fWGNISI3bCnQA Um2obI0kd/rJEzYDxVgPnvBokcbRCVXW3FFq8Xlu6ILAoj5fl9aexyTCUn9R2+v7 sncBr1xe+L5Zor1QFn4ixeWTnPPcKSVkkZKKfrK0TLsw+UaqbeooVuv8Rp7G9R8u vtOsbf3l8eAJC7E1KCaPelWisDRzUk+7ZlHw+DIGyBFf1PjfASsbsSDrzeAsHayT l6djrAxq0vo2r3gf/mKyQ== 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=1665652404; x= 1665738804; bh=VNQ+rzhIH5hRx9r2piVwTWvHL+idSBOUdFscI6rLzxE=; b=i WWqbhiB0MM6zxO5lHeriMLEd4LsvsxL0XAAhd1eKb1wJ4ia+tFEdMTceGn5G532V +kFhXvlyzgIQFMoHkWArUSHw6mZRFTHUJ8ZLxBPQEb5QHOxJOt5k9X5o7QN8b7Vj egVmLwu4k57qQOEOPF3vzCuecTALE8IgWvdW75lwMRP2DhffnXLD4OiCngIHn6Me BfWoKKc4Wqsp2PlIQVGOF8KIxxJs/tmV7/+J56Y5oh269ALQSONwEvo9qqAMkHS2 YNujalNYD6cPIjbeFPOvsVuTaGq2y9baNyJfNnCT2e57nRw4YveFnkc3wWAhg3DJ 0WFjNdV/qXndfolhb3ZnQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedrfeektddgudegucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephfffufggtgfgkfhfjgfvvefosehtkeertdertdejnecuhfhrohhmpeforgig ihhmvgcutfhiphgrrhguuceomhgrgihimhgvsegtvghrnhhordhtvggthheqnecuggftrf grthhtvghrnhepudduudfhveejteefgedvffdvvedvjedugedukeejhedtlefhffevtefh jeeltdevnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomh epmhgrgihimhgvsegtvghrnhhordhtvggthh X-ME-Proxy: Feedback-ID: i8771445c:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 13 Oct 2022 05:13:24 -0400 (EDT) From: Maxime Ripard Date: Thu, 13 Oct 2022 11:13:14 +0200 Subject: [PATCH v3 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-v3-7-fc56729d11fe@cerno.tech> References: <20220815-rpi-fix-4k-60-v3-0-fc56729d11fe@cerno.tech> In-Reply-To: <20220815-rpi-fix-4k-60-v3-0-fc56729d11fe@cerno.tech> To: Florian Fainelli , Michael Turquette , Emma Anholt , Stephen Boyd , Ray Jui , Scott Branden , Broadcom internal kernel review list , Daniel Vetter , David Airlie , Maxime Ripard Cc: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Maxime Ripard , Stefan Wahren , linux-clk@vger.kernel.org, linux-rpi-kernel@lists.infradead.org, Dom Cobley , dri-devel@lists.freedesktop.org X-Mailer: b4 0.11.0-dev-7da52 X-Developer-Signature: v=1; a=openpgp-sha256; l=1996; i=maxime@cerno.tech; h=from:subject:message-id; bh=ld8ipA25nQnVtvJwO2QQQ+Hw9FjcRy6PgrDDJON91qg=; b=owGbwMvMwCX2+D1vfrpE4FHG02pJDMnu15awBd7JOJN9WGGF/I1fsz+veZC6vuVV87XUim39X5P+ FUws6ihlYRDjYpAVU2SJETZfEndq1utONr55MHNYmUCGMHBxCsBEbPgZ/if9c0o5cjY0bNOJWbaHGK 9unPOG7f3CKt/EQ4G/lF3M7woyMjy/He4seO3P07o7nRvy/9bNEWrpPrv292Gro99U7ziWPWcEAA== 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-20221013_021325_365029_5AE8AD29 X-CRM114-Status: GOOD ( 10.95 ) 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 --- drivers/gpu/drm/vc4/vc4_kms.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) 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));