aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLucas Stach <l.stach@pengutronix.de>2017-04-11 09:54:50 -0400
committerLucas Stach <l.stach@pengutronix.de>2017-05-05 11:14:51 -0400
commitd79fd1ccf2cd76adba2121a62bae996bc4beccfe (patch)
tree68b2662b7e7d5e451746585877c162f4f3c10e97
parent7cef6004ecf8ca9aef383318515e759338475a46 (diff)
drm/etnaviv: implement cooling support for new GPU cores
GPU cores with the DYNAMIC_FREQUENCY_SCALING feature bit set expect the platform to provide the clock scaling and ignore any requests to use the internal FSCALE divider. Writes to this register still work, but don't have any effect on the GPU clock frequency. Save the initial core and shader clock frequency and ask the platform to provide a slower clock when cooling is requested. Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
-rw-r--r--drivers/gpu/drm/etnaviv/etnaviv_gpu.c20
-rw-r--r--drivers/gpu/drm/etnaviv/etnaviv_gpu.h2
2 files changed, 16 insertions, 6 deletions
diff --git a/drivers/gpu/drm/etnaviv/etnaviv_gpu.c b/drivers/gpu/drm/etnaviv/etnaviv_gpu.c
index d4c7b443a757..ada45fdd0eae 100644
--- a/drivers/gpu/drm/etnaviv/etnaviv_gpu.c
+++ b/drivers/gpu/drm/etnaviv/etnaviv_gpu.c
@@ -412,13 +412,19 @@ static void etnaviv_gpu_load_clock(struct etnaviv_gpu *gpu, u32 clock)
412 412
413static void etnaviv_gpu_update_clock(struct etnaviv_gpu *gpu) 413static void etnaviv_gpu_update_clock(struct etnaviv_gpu *gpu)
414{ 414{
415 unsigned int fscale = 1 << (6 - gpu->freq_scale); 415 if (gpu->identity.minor_features2 &
416 u32 clock; 416 chipMinorFeatures2_DYNAMIC_FREQUENCY_SCALING) {
417 417 clk_set_rate(gpu->clk_core,
418 clock = VIVS_HI_CLOCK_CONTROL_DISABLE_DEBUG_REGISTERS | 418 gpu->base_rate_core >> gpu->freq_scale);
419 VIVS_HI_CLOCK_CONTROL_FSCALE_VAL(fscale); 419 clk_set_rate(gpu->clk_shader,
420 gpu->base_rate_shader >> gpu->freq_scale);
421 } else {
422 unsigned int fscale = 1 << (6 - gpu->freq_scale);
423 u32 clock = VIVS_HI_CLOCK_CONTROL_DISABLE_DEBUG_REGISTERS |
424 VIVS_HI_CLOCK_CONTROL_FSCALE_VAL(fscale);
420 425
421 etnaviv_gpu_load_clock(gpu, clock); 426 etnaviv_gpu_load_clock(gpu, clock);
427 }
422} 428}
423 429
424static int etnaviv_hw_reset(struct etnaviv_gpu *gpu) 430static int etnaviv_hw_reset(struct etnaviv_gpu *gpu)
@@ -1742,11 +1748,13 @@ static int etnaviv_gpu_platform_probe(struct platform_device *pdev)
1742 DBG("clk_core: %p", gpu->clk_core); 1748 DBG("clk_core: %p", gpu->clk_core);
1743 if (IS_ERR(gpu->clk_core)) 1749 if (IS_ERR(gpu->clk_core))
1744 gpu->clk_core = NULL; 1750 gpu->clk_core = NULL;
1751 gpu->base_rate_core = clk_get_rate(gpu->clk_core);
1745 1752
1746 gpu->clk_shader = devm_clk_get(&pdev->dev, "shader"); 1753 gpu->clk_shader = devm_clk_get(&pdev->dev, "shader");
1747 DBG("clk_shader: %p", gpu->clk_shader); 1754 DBG("clk_shader: %p", gpu->clk_shader);
1748 if (IS_ERR(gpu->clk_shader)) 1755 if (IS_ERR(gpu->clk_shader))
1749 gpu->clk_shader = NULL; 1756 gpu->clk_shader = NULL;
1757 gpu->base_rate_shader = clk_get_rate(gpu->clk_shader);
1750 1758
1751 /* TODO: figure out max mapped size */ 1759 /* TODO: figure out max mapped size */
1752 dev_set_drvdata(dev, gpu); 1760 dev_set_drvdata(dev, gpu);
diff --git a/drivers/gpu/drm/etnaviv/etnaviv_gpu.h b/drivers/gpu/drm/etnaviv/etnaviv_gpu.h
index 9227a9740447..689cb8f3680c 100644
--- a/drivers/gpu/drm/etnaviv/etnaviv_gpu.h
+++ b/drivers/gpu/drm/etnaviv/etnaviv_gpu.h
@@ -152,6 +152,8 @@ struct etnaviv_gpu {
152 u32 hangcheck_dma_addr; 152 u32 hangcheck_dma_addr;
153 struct work_struct recover_work; 153 struct work_struct recover_work;
154 unsigned int freq_scale; 154 unsigned int freq_scale;
155 unsigned long base_rate_core;
156 unsigned long base_rate_shader;
155}; 157};
156 158
157static inline void gpu_write(struct etnaviv_gpu *gpu, u32 reg, u32 data) 159static inline void gpu_write(struct etnaviv_gpu *gpu, u32 reg, u32 data)