Skip to content

Commit 6bde14b

Browse files
PhilippeLecointrelynxeye-dev
authored andcommitted
drm/etnaviv: add optional reset support
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 Signed-off-by: Philippe Lecointre <[email protected]> Acked-by: Simon Lenain <[email protected]> Signed-off-by: Lucas Stach <[email protected]>
1 parent 6bef484 commit 6bde14b

File tree

2 files changed

+43
-0
lines changed

2 files changed

+43
-0
lines changed

drivers/gpu/drm/etnaviv/etnaviv_gpu.c

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include <linux/platform_device.h>
1414
#include <linux/pm_runtime.h>
1515
#include <linux/regulator/consumer.h>
16+
#include <linux/reset.h>
1617
#include <linux/thermal.h>
1718

1819
#include "etnaviv_cmdbuf.h"
@@ -172,6 +173,29 @@ int etnaviv_gpu_get_param(struct etnaviv_gpu *gpu, u32 param, u64 *value)
172173
return 0;
173174
}
174175

176+
static int etnaviv_gpu_reset_deassert(struct etnaviv_gpu *gpu)
177+
{
178+
int ret;
179+
180+
/*
181+
* 32 core clock cycles (slowest clock) required before deassertion
182+
* 1 microsecond might match all implementations without computation
183+
*/
184+
usleep_range(1, 2);
185+
186+
ret = reset_control_deassert(gpu->rst);
187+
if (ret)
188+
return ret;
189+
190+
/*
191+
* 128 core clock cycles (slowest clock) required before any activity on AHB
192+
* 1 microsecond might match all implementations without computation
193+
*/
194+
usleep_range(1, 2);
195+
196+
return 0;
197+
}
198+
175199
static inline bool etnaviv_is_model_rev(struct etnaviv_gpu *gpu, u32 model, u32 revision)
176200
{
177201
return gpu->identity.model == model &&
@@ -799,6 +823,12 @@ int etnaviv_gpu_init(struct etnaviv_gpu *gpu)
799823
goto pm_put;
800824
}
801825

826+
ret = etnaviv_gpu_reset_deassert(gpu);
827+
if (ret) {
828+
dev_err(gpu->dev, "GPU reset deassert failed\n");
829+
goto fail;
830+
}
831+
802832
etnaviv_hw_identify(gpu);
803833

804834
if (gpu->identity.model == 0) {
@@ -1860,6 +1890,17 @@ static int etnaviv_gpu_platform_probe(struct platform_device *pdev)
18601890
if (IS_ERR(gpu->mmio))
18611891
return PTR_ERR(gpu->mmio);
18621892

1893+
1894+
/* Get Reset: */
1895+
gpu->rst = devm_reset_control_get_optional_exclusive(&pdev->dev, NULL);
1896+
if (IS_ERR(gpu->rst))
1897+
return dev_err_probe(dev, PTR_ERR(gpu->rst),
1898+
"failed to get reset\n");
1899+
1900+
err = reset_control_assert(gpu->rst);
1901+
if (err)
1902+
return dev_err_probe(dev, err, "failed to assert reset\n");
1903+
18631904
/* Get Interrupt: */
18641905
gpu->irq = platform_get_irq(pdev, 0);
18651906
if (gpu->irq < 0)

drivers/gpu/drm/etnaviv/etnaviv_gpu.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ struct etnaviv_event {
9393
struct etnaviv_cmdbuf_suballoc;
9494
struct regulator;
9595
struct clk;
96+
struct reset_control;
9697

9798
#define ETNA_NR_EVENTS 30
9899

@@ -158,6 +159,7 @@ struct etnaviv_gpu {
158159
struct clk *clk_reg;
159160
struct clk *clk_core;
160161
struct clk *clk_shader;
162+
struct reset_control *rst;
161163

162164
unsigned int freq_scale;
163165
unsigned int fe_waitcycles;

0 commit comments

Comments
 (0)