[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <737b2631320dad9dea71eb786a521d7a1d2100c5.camel@pengutronix.de>
Date: Thu, 05 Dec 2024 17:57:54 +0100
From: Philipp Zabel <p.zabel@...gutronix.de>
To: LECOINTRE Philippe <philippe.lecointre@...lesgroup.com>, Lucas Stach
<l.stach@...gutronix.de>, Russell King <linux+etnaviv@...linux.org.uk>,
Christian Gmeiner <christian.gmeiner@...il.com>
Cc: David Airlie <airlied@...il.com>, Simona Vetter <simona@...ll.ch>,
"etnaviv@...ts.freedesktop.org" <etnaviv@...ts.freedesktop.org>,
"dri-devel@...ts.freedesktop.org" <dri-devel@...ts.freedesktop.org>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>, LENAIN Simon
<simon.lenain@...lesgroup.com>, BARBEAU Etienne
<etienne.barbeau@...lesgroup.com>, LEJEUNE Sebastien
<sebastien.lejeune@...lesgroup.com>
Subject: Re: [PATCH v2] drm/etnaviv: add optional reset support
On Fr, 2024-11-08 at 14:00 +0000, LECOINTRE Philippe wrote:
> 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: Philippe Lecointre <philippe.lecointre@...lesgroup.com>
> Reviewed-by: Simon Lenain <simon.lenain@...lesgroup.com>
> ---
> v2:
> - Add missing include of irq.h
> ---
> drivers/gpu/drm/etnaviv/etnaviv_gpu.c | 30 +++++++++++++++++++++++++++
> drivers/gpu/drm/etnaviv/etnaviv_gpu.h | 2 ++
> 2 files changed, 32 insertions(+)
>
> diff --git a/drivers/gpu/drm/etnaviv/etnaviv_gpu.c b/drivers/gpu/drm/etnaviv/etnaviv_gpu.c
> index 7c7f97793ddd..3e0c5dd9f74b 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>
> @@ -8,11 +9,13 @@
> #include <linux/delay.h>
> #include <linux/dma-fence.h>
> #include <linux/dma-mapping.h>
> +#include <linux/irq.h>
> #include <linux/mod_devicetable.h>
> #include <linux/module.h>
> #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 +1632,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 +1662,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 +1897,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 +1907,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);
Please use devm_reset_control_get_optional_exclusive() directly.
regards
Philipp
Powered by blists - more mailing lists