From patchwork Tue Jan 28 19:48:08 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Wilczynski X-Patchwork-Id: 13953113 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 95F6FC0218A for ; Tue, 28 Jan 2025 19:48:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:References:MIME-Version:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=LvvmfbeYdfSWl/AIDIJEaRgZo+BgJfM6dBrd5EjNCao=; b=dRxwNHRinesHDU VFWrVHE7cZCPl0By3sybpX7PR/0kpztmQJLCGQ7GfbvZ1e1/FrmAErxEskau5r3KQ69De1zwbqlGw Lw7/yubLPvrA7clarxpSfqCMeloN9LbwD6nvbUr2Sjb1as+mX75D0u2eZ2oiL0CrN/V8RYYvyWs8G p/kaXK0m11dVvs3rG13y8nYcqiZ8AB3jndimMVc28OwVkXWka4LnUtXQp5G8AZjgjXDUirVyb/2eJ JTtrtapJp9X6pOKwjL0nsSlp3BLSZybenl6FejWTNlwRK3PooG2RZc0fWUIE0ULwh4YO9dtTz6k+u QOfBcMWO1QfsDnyPXm5w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tcrZq-00000005jWu-0QEZ; Tue, 28 Jan 2025 19:48:50 +0000 Received: from mailout2.w1.samsung.com ([210.118.77.12]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tcrZh-00000005jNp-1st2 for linux-riscv@lists.infradead.org; Tue, 28 Jan 2025 19:48:44 +0000 Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20250128194840euoutp0212096fdd13acd04d74749720c3c698ec~e8wedtnUy2670226702euoutp02Y for ; Tue, 28 Jan 2025 19:48:40 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20250128194840euoutp0212096fdd13acd04d74749720c3c698ec~e8wedtnUy2670226702euoutp02Y DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1738093720; bh=ZYBRmW5t2GpCZtOdW6RPCwHBIk2zBYiTkDA13XDEtW4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VAmp3YGtt/afem4W6kd0GjProjMLNMmADbZE7lu1Zhf7gd/kT3Pzm1aZQiILNsAK/ N2ylkXQro3hHI//fBpXxw8hb/8nK4h2cFBnsCECFln6I8hRmbGvjEY8K2ZSWhEzD0R AzuecuN/yU+FQzyLpf7Ctzby8GCrZBLJRWy65OEA= Received: from eusmges1new.samsung.com (unknown [203.254.199.242]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20250128194838eucas1p2d1c38c43bb0dbc2368835a9b395f43c6~e8wdOwKIM2210922109eucas1p2-; Tue, 28 Jan 2025 19:48:38 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges1new.samsung.com (EUCPMTA) with SMTP id 1D.F8.20821.69439976; Tue, 28 Jan 2025 19:48:38 +0000 (GMT) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20250128194838eucas1p1829115b2b05d209a7c277eccf56e0b90~e8wcpMNv41988619886eucas1p10; Tue, 28 Jan 2025 19:48:38 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20250128194838eusmtrp2c4b9da3b48e09b6efa5f6cbe0f24fd16~e8wcoeocA3008430084eusmtrp2f; Tue, 28 Jan 2025 19:48:38 +0000 (GMT) X-AuditID: cbfec7f2-b11c470000005155-99-67993496f2fe Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id E7.BB.19654.69439976; Tue, 28 Jan 2025 19:48:38 +0000 (GMT) Received: from AMDC4942.home (unknown [106.210.136.40]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20250128194836eusmtip17d32b73588c20ebc10d406239e436948~e8wbTFR8q0756107561eusmtip1Q; Tue, 28 Jan 2025 19:48:36 +0000 (GMT) From: Michal Wilczynski To: mturquette@baylibre.com, sboyd@kernel.org, robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org, drew@pdp7.com, guoren@kernel.org, wefu@redhat.com, jassisinghbrar@gmail.com, paul.walmsley@sifive.com, palmer@dabbelt.com, aou@eecs.berkeley.edu, frank.binns@imgtec.com, matt.coster@imgtec.com, maarten.lankhorst@linux.intel.com, mripard@kernel.org, tzimmermann@suse.de, airlied@gmail.com, simona@ffwll.ch, ulf.hansson@linaro.org, jszhang@kernel.org, p.zabel@pengutronix.de, m.szyprowski@samsung.com Cc: linux-clk@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, dri-devel@lists.freedesktop.org, linux-pm@vger.kernel.org, Michal Wilczynski Subject: [PATCH v4 10/18] drm/imagination: Add reset controller support for GPU initialization Date: Tue, 28 Jan 2025 20:48:08 +0100 Message-Id: <20250128194816.2185326-11-m.wilczynski@samsung.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250128194816.2185326-1-m.wilczynski@samsung.com> M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Mqq1KL8+KLSnNTiQ4ym QHdPZJYSTc4HJri8knhDMwNTQxMzSwNTSzNjJXFetivn04QE0hNLUrNTUwtSi2D6mDg4pRqY TJ89u37EOOz+19abq5sEMgU+aysc1u1L4e7/uzVceHX377V1UXOdhcq/vOPv9w5KV35nFtMT e3xNT2pZT9bbPPnMVsO425mFzyxTuviZTD/kf8y7xDfH/6KGYL7r35u+p0oeZj7N2vOizrvf wcreieP1u8MuQbkv5JmuPOXKad5Z9FPYe8431pApaawv1RYu+G/n/i6IdWNig2Wj1o8wmSvm U/s1hC/Xsv3z+GYWpL6z4/bDzKKLsVVbWjy+xURFhn1/tHyhU/r/9LSTR3/teFwmuFu3IFo+ Kc+1XOhyImNYUH/1lCk3Ds4U5AwwvV0475fbmUzpDXvyDxyuXH565e3Die5rUp8wGzJ4rldi Kc5INNRiLipOBABUgEkKuAMAAA== X-CMS-MailID: 20250128194838eucas1p1829115b2b05d209a7c277eccf56e0b90 X-Msg-Generator: CA X-RootMTR: 20250128194838eucas1p1829115b2b05d209a7c277eccf56e0b90 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20250128194838eucas1p1829115b2b05d209a7c277eccf56e0b90 References: <20250128194816.2185326-1-m.wilczynski@samsung.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20250128_114841_767934_29E26953 X-CRM114-Status: GOOD ( 22.16 ) X-BeenThere: linux-riscv@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-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org Certain platforms, such as the T-Head TH1520 and Banana Pi BPI-F3, require a controlled GPU reset sequence during the power-up procedure to ensure proper initialization. Without this reset, the GPU may remain in an undefined state, potentially leading to stability or performance issues. This commit integrates a dedicated reset controller within the drm/imagination driver. By doing so, the driver can coordinate the necessary reset operations as part of the normal GPU bring-up process, improving reliability and ensuring that the hardware is ready for operation. Signed-off-by: Michal Wilczynski --- drivers/gpu/drm/imagination/pvr_device.c | 21 +++++++++++++++++++++ drivers/gpu/drm/imagination/pvr_device.h | 9 +++++++++ drivers/gpu/drm/imagination/pvr_power.c | 12 +++++++++++- 3 files changed, 41 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/imagination/pvr_device.c b/drivers/gpu/drm/imagination/pvr_device.c index 1704c0268589..ef73e95157ee 100644 --- a/drivers/gpu/drm/imagination/pvr_device.c +++ b/drivers/gpu/drm/imagination/pvr_device.c @@ -25,6 +25,7 @@ #include #include #include +#include #include #include #include @@ -120,6 +121,21 @@ static int pvr_device_clk_init(struct pvr_device *pvr_dev) return 0; } +static int pvr_device_reset_init(struct pvr_device *pvr_dev) +{ + struct drm_device *drm_dev = from_pvr_device(pvr_dev); + struct reset_control *reset; + + reset = devm_reset_control_get_optional_exclusive(drm_dev->dev, NULL); + if (IS_ERR(reset)) + return dev_err_probe(drm_dev->dev, PTR_ERR(reset), + "failed to get gpu reset line\n"); + + pvr_dev->reset = reset; + + return 0; +} + /** * pvr_device_process_active_queues() - Process all queue related events. * @pvr_dev: PowerVR device to check @@ -509,6 +525,11 @@ pvr_device_init(struct pvr_device *pvr_dev) if (err) return err; + /* Get the reset line for the GPU */ + err = pvr_device_reset_init(pvr_dev); + if (err) + return err; + /* Explicitly power the GPU so we can access control registers before the FW is booted. */ err = pm_runtime_resume_and_get(dev); if (err) diff --git a/drivers/gpu/drm/imagination/pvr_device.h b/drivers/gpu/drm/imagination/pvr_device.h index 6d0dfacb677b..f6576c08111c 100644 --- a/drivers/gpu/drm/imagination/pvr_device.h +++ b/drivers/gpu/drm/imagination/pvr_device.h @@ -131,6 +131,15 @@ struct pvr_device { */ struct clk *mem_clk; + /** + * @reset: Optional reset line. + * + * This may be used on some platforms to provide a reset line that needs to be de-asserted + * after power-up procedure. It would also need to be asserted after the power-down + * procedure. + */ + struct reset_control *reset; + /** @irq: IRQ number. */ int irq; diff --git a/drivers/gpu/drm/imagination/pvr_power.c b/drivers/gpu/drm/imagination/pvr_power.c index ba7816fd28ec..e39460d594bd 100644 --- a/drivers/gpu/drm/imagination/pvr_power.c +++ b/drivers/gpu/drm/imagination/pvr_power.c @@ -15,6 +15,7 @@ #include #include #include +#include #include #include #include @@ -252,6 +253,8 @@ pvr_power_device_suspend(struct device *dev) clk_disable_unprepare(pvr_dev->sys_clk); clk_disable_unprepare(pvr_dev->core_clk); + err = reset_control_assert(pvr_dev->reset); + err_drm_dev_exit: drm_dev_exit(idx); @@ -282,16 +285,23 @@ pvr_power_device_resume(struct device *dev) if (err) goto err_sys_clk_disable; + err = reset_control_deassert(pvr_dev->reset); + if (err) + goto err_mem_clk_disable; + if (pvr_dev->fw_dev.booted) { err = pvr_power_fw_enable(pvr_dev); if (err) - goto err_mem_clk_disable; + goto err_reset_assert; } drm_dev_exit(idx); return 0; +err_reset_assert: + reset_control_assert(pvr_dev->reset); + err_mem_clk_disable: clk_disable_unprepare(pvr_dev->mem_clk);