From: LECOINTRE Philippe <philippe.lecointre@thalesgroup.com>
To: Lucas Stach <l.stach@pengutronix.de>,
Russell King <linux+etnaviv@armlinux.org.uk>,
Christian Gmeiner <christian.gmeiner@gmail.com>
Cc: David Airlie <airlied@gmail.com>, Simona Vetter <simona@ffwll.ch>,
"etnaviv@lists.freedesktop.org" <etnaviv@lists.freedesktop.org>,
"dri-devel@lists.freedesktop.org"
<dri-devel@lists.freedesktop.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
LENAIN Simon <simon.lenain@thalesgroup.com>,
BARBEAU Etienne <etienne.barbeau@thalesgroup.com>,
LEJEUNE Sebastien <sebastien.lejeune@thalesgroup.com>
Subject: [PATCH] drm/etnaviv: add optional reset support
Date: Tue, 5 Nov 2024 14:37:26 +0000 [thread overview]
Message-ID: <0825fa6ad3954cda970b42c25b45fb0d@thalesgroup.com> (raw)
Add optional reset support which is mentioned in vivante,gc.yaml to
allow the driver to work on SoCs whose reset signal is asserted by default
Avoid enabling the interrupt until everything is ready
Signed-off-by: LECOINTRE Philippe <philippe.lecointre@thalesgroup.com>
Reviewed-by: LENAIN Simon <simon.lenain@thalesgroup.com>
---
drivers/gpu/drm/etnaviv/etnaviv_gpu.c | 29 +++++++++++++++++++++++++++
drivers/gpu/drm/etnaviv/etnaviv_gpu.h | 2 ++
2 files changed, 31 insertions(+)
diff --git a/drivers/gpu/drm/etnaviv/etnaviv_gpu.c b/drivers/gpu/drm/etnaviv/etnaviv_gpu.c
index 7c7f97793ddd..f698fec50343 100644
--- a/drivers/gpu/drm/etnaviv/etnaviv_gpu.c
+++ b/drivers/gpu/drm/etnaviv/etnaviv_gpu.c
@@ -1,6 +1,7 @@
// SPDX-License-Identifier: GPL-2.0
/*
* Copyright (C) 2015-2018 Etnaviv Project
+ * Copyright (C) 2024 Thales
*/
#include <linux/clk.h>
@@ -13,6 +14,7 @@
#include <linux/platform_device.h>
#include <linux/pm_runtime.h>
#include <linux/regulator/consumer.h>
+#include <linux/reset.h>
#include <linux/thermal.h>
#include "etnaviv_cmdbuf.h"
@@ -1629,8 +1631,24 @@ static int etnaviv_gpu_clk_enable(struct etnaviv_gpu *gpu)
if (ret)
goto disable_clk_core;
+ /* 32 core clock cycles (slowest clock) required before deassertion. */
+ /* 1 microsecond might match all implementations */
+ usleep_range(1, 2);
+
+ ret = reset_control_deassert(gpu->rst);
+ if (ret)
+ goto disable_clk_shader;
+
+ /* 128 core clock cycles (slowest clock) required before any activity on AHB. */
+ /* 1 microsecond might match all implementations */
+ usleep_range(1, 2);
+
+ enable_irq(gpu->irq);
+
return 0;
+disable_clk_shader:
+ clk_disable_unprepare(gpu->clk_shader);
disable_clk_core:
clk_disable_unprepare(gpu->clk_core);
disable_clk_bus:
@@ -1643,6 +1661,8 @@ static int etnaviv_gpu_clk_enable(struct etnaviv_gpu *gpu)
static int etnaviv_gpu_clk_disable(struct etnaviv_gpu *gpu)
{
+ disable_irq(gpu->irq);
+ reset_control_assert(gpu->rst);
clk_disable_unprepare(gpu->clk_shader);
clk_disable_unprepare(gpu->clk_core);
clk_disable_unprepare(gpu->clk_bus);
@@ -1876,6 +1896,9 @@ static int etnaviv_gpu_platform_probe(struct platform_device *pdev)
if (gpu->irq < 0)
return gpu->irq;
+ /* Avoid enabling the interrupt until everything is ready */
+ irq_set_status_flags(gpu->irq, IRQ_NOAUTOEN);
+
err = devm_request_irq(&pdev->dev, gpu->irq, irq_handler, 0,
dev_name(gpu->dev), gpu);
if (err) {
@@ -1883,6 +1906,12 @@ static int etnaviv_gpu_platform_probe(struct platform_device *pdev)
return err;
}
+ /* Get Reset: */
+ gpu->rst = devm_reset_control_get_optional(&pdev->dev, NULL);
+ if (IS_ERR(gpu->rst))
+ return dev_err_probe(dev, PTR_ERR(gpu->rst),
+ "failed to get reset\n");
+
/* Get Clocks: */
gpu->clk_reg = devm_clk_get_optional(&pdev->dev, "reg");
DBG("clk_reg: %p", gpu->clk_reg);
diff --git a/drivers/gpu/drm/etnaviv/etnaviv_gpu.h b/drivers/gpu/drm/etnaviv/etnaviv_gpu.h
index 31322195b9e4..8c181191755e 100644
--- a/drivers/gpu/drm/etnaviv/etnaviv_gpu.h
+++ b/drivers/gpu/drm/etnaviv/etnaviv_gpu.h
@@ -1,6 +1,7 @@
/* SPDX-License-Identifier: GPL-2.0 */
/*
* Copyright (C) 2015-2018 Etnaviv Project
+ * Copyright (C) 2024 Thales
*/
#ifndef __ETNAVIV_GPU_H__
@@ -157,6 +158,7 @@ struct etnaviv_gpu {
struct clk *clk_reg;
struct clk *clk_core;
struct clk *clk_shader;
+ struct reset_control *rst;
unsigned int freq_scale;
unsigned int fe_waitcycles;
--
2.19.1
next reply other threads:[~2024-11-06 8:18 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-05 14:37 LECOINTRE Philippe [this message]
2024-11-05 23:04 ` [PATCH] drm/etnaviv: add optional reset support kernel test robot
2024-11-05 23:15 ` kernel test robot
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=0825fa6ad3954cda970b42c25b45fb0d@thalesgroup.com \
--to=philippe.lecointre@thalesgroup.com \
--cc=airlied@gmail.com \
--cc=christian.gmeiner@gmail.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=etienne.barbeau@thalesgroup.com \
--cc=etnaviv@lists.freedesktop.org \
--cc=l.stach@pengutronix.de \
--cc=linux+etnaviv@armlinux.org.uk \
--cc=linux-kernel@vger.kernel.org \
--cc=sebastien.lejeune@thalesgroup.com \
--cc=simon.lenain@thalesgroup.com \
--cc=simona@ffwll.ch \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.