From: Parthiban Nallathambi <parthiban@linumiz.com>
To: Frank Binns <frank.binns@imgtec.com>,
Matt Coster <matt.coster@imgtec.com>,
David Airlie <airlied@gmail.com>,
Simona Vetter <simona@ffwll.ch>,
Maarten Lankhorst <maarten.lankhorst@linux.intel.com>,
Maxime Ripard <mripard@kernel.org>,
Thomas Zimmermann <tzimmermann@suse.de>,
Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>,
Philipp Zabel <p.zabel@pengutronix.de>
Cc: dri-devel@lists.freedesktop.org, devicetree@vger.kernel.org,
linux-kernel@vger.kernel.org,
Parthiban Nallathambi <parthiban@linumiz.com>
Subject: [PATCH 2/2] drm/imagination: add reset control support
Date: Mon, 25 Nov 2024 22:07:04 +0530 [thread overview]
Message-ID: <20241125-pvr-reset-v1-2-b437b8052948@linumiz.com> (raw)
In-Reply-To: <20241125-pvr-reset-v1-0-b437b8052948@linumiz.com>
On some platforms like Allwinner A133 with GE8300 includes
reset control from reset control unit. Add reset control
optionally from the devicetree.
Signed-off-by: Parthiban Nallathambi <parthiban@linumiz.com>
---
drivers/gpu/drm/imagination/pvr_device.h | 8 ++++++++
drivers/gpu/drm/imagination/pvr_drv.c | 5 +++++
drivers/gpu/drm/imagination/pvr_power.c | 16 +++++++++++++++-
3 files changed, 28 insertions(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/imagination/pvr_device.h b/drivers/gpu/drm/imagination/pvr_device.h
index 6d0dfacb677b..21ec7dd64415 100644
--- a/drivers/gpu/drm/imagination/pvr_device.h
+++ b/drivers/gpu/drm/imagination/pvr_device.h
@@ -23,6 +23,7 @@
#include <linux/kernel.h>
#include <linux/math.h>
#include <linux/mutex.h>
+#include <linux/reset.h>
#include <linux/spinlock_types.h>
#include <linux/timer.h>
#include <linux/types.h>
@@ -131,6 +132,13 @@ struct pvr_device {
*/
struct clk *mem_clk;
+ /**
+ * @reset: Optional reset control
+ *
+ * This may be used on some platforms to reset the GPU module/IP.
+ */
+ struct reset_control *reset;
+
/** @irq: IRQ number. */
int irq;
diff --git a/drivers/gpu/drm/imagination/pvr_drv.c b/drivers/gpu/drm/imagination/pvr_drv.c
index fb17196e05f4..d9b918410ea9 100644
--- a/drivers/gpu/drm/imagination/pvr_drv.c
+++ b/drivers/gpu/drm/imagination/pvr_drv.c
@@ -36,6 +36,7 @@
#include <linux/of_platform.h>
#include <linux/platform_device.h>
#include <linux/pm_runtime.h>
+#include <linux/reset.h>
#include <linux/xarray.h>
/**
@@ -1427,6 +1428,10 @@ pvr_probe(struct platform_device *plat_dev)
pm_runtime_use_autosuspend(&plat_dev->dev);
pvr_watchdog_init(pvr_dev);
+ pvr_dev->reset = devm_reset_control_get_optional_exclusive(&plat_dev->dev, "ahb");
+ if (PTR_ERR(pvr_dev->reset) == -EPROBE_DEFER)
+ return PTR_ERR(pvr_dev->reset);
+
err = pvr_device_init(pvr_dev);
if (err)
goto err_watchdog_fini;
diff --git a/drivers/gpu/drm/imagination/pvr_power.c b/drivers/gpu/drm/imagination/pvr_power.c
index ba7816fd28ec..a24ed85f36c7 100644
--- a/drivers/gpu/drm/imagination/pvr_power.c
+++ b/drivers/gpu/drm/imagination/pvr_power.c
@@ -15,6 +15,7 @@
#include <linux/mutex.h>
#include <linux/platform_device.h>
#include <linux/pm_runtime.h>
+#include <linux/reset.h>
#include <linux/timer.h>
#include <linux/types.h>
#include <linux/workqueue.h>
@@ -252,6 +253,9 @@ pvr_power_device_suspend(struct device *dev)
clk_disable_unprepare(pvr_dev->sys_clk);
clk_disable_unprepare(pvr_dev->core_clk);
+ if (!IS_ERR(pvr_dev->reset))
+ reset_control_assert(pvr_dev->reset);
+
err_drm_dev_exit:
drm_dev_exit(idx);
@@ -270,9 +274,15 @@ pvr_power_device_resume(struct device *dev)
if (!drm_dev_enter(drm_dev, &idx))
return -EIO;
+ if (!IS_ERR(pvr_dev->reset)) {
+ err = reset_control_reset(pvr_dev->reset);
+ if (err)
+ goto err_drm_dev_exit;
+ }
+
err = clk_prepare_enable(pvr_dev->core_clk);
if (err)
- goto err_drm_dev_exit;
+ goto err_reset_exit;
err = clk_prepare_enable(pvr_dev->sys_clk);
if (err)
@@ -301,6 +311,10 @@ pvr_power_device_resume(struct device *dev)
err_core_clk_disable:
clk_disable_unprepare(pvr_dev->core_clk);
+err_reset_exit:
+ if (!IS_ERR(pvr_dev->reset))
+ reset_control_assert(pvr_dev->reset);
+
err_drm_dev_exit:
drm_dev_exit(idx);
--
2.39.2
next prev parent reply other threads:[~2024-11-25 16:37 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-25 16:37 [PATCH 0/2] drm/imagination: add reset handling Parthiban Nallathambi
2024-11-25 16:37 ` [PATCH 1/2] dt-bindings: gpu: add reset control property Parthiban Nallathambi
2024-11-25 18:07 ` Conor Dooley
2024-11-26 3:46 ` Parthiban
2024-11-26 9:32 ` Krzysztof Kozlowski
2024-11-26 9:42 ` Parthiban
2024-11-26 9:32 ` Krzysztof Kozlowski
2024-11-25 16:37 ` Parthiban Nallathambi [this message]
2024-11-26 9:29 ` [PATCH 2/2] drm/imagination: add reset control support Philipp Zabel
2024-11-26 9:48 ` Parthiban
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20241125-pvr-reset-v1-2-b437b8052948@linumiz.com \
--to=parthiban@linumiz.com \
--cc=airlied@gmail.com \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=frank.binns@imgtec.com \
--cc=krzk+dt@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=maarten.lankhorst@linux.intel.com \
--cc=matt.coster@imgtec.com \
--cc=mripard@kernel.org \
--cc=p.zabel@pengutronix.de \
--cc=robh@kernel.org \
--cc=simona@ffwll.ch \
--cc=tzimmermann@suse.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox