aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJordan Crouse <jcrouse@codeaurora.org>2017-07-27 12:42:31 -0400
committerRob Clark <robdclark@gmail.com>2017-08-01 19:10:28 -0400
commit6e749e5971fc7c7a33d7a673fbe4944604b397cf (patch)
tree2ebaaa6998acb42ef22814bf5eec1936ca14e67a
parent3394f5618dfe8e686a2429aad75edf7ff6540911 (diff)
drm/msm: Allow hardware clock gating to be toggled
There are some use cases wherein we need to turn off hardware clock gating before reading certain registers. Modify the A5XX HWCG function to allow user to enable or disable clock gating at will. Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> Signed-off-by: Rob Clark <robdclark@gmail.com>
-rw-r--r--drivers/gpu/drm/msm/adreno/a5xx_gpu.c42
-rw-r--r--drivers/gpu/drm/msm/adreno/a5xx_gpu.h1
2 files changed, 10 insertions, 33 deletions
diff --git a/drivers/gpu/drm/msm/adreno/a5xx_gpu.c b/drivers/gpu/drm/msm/adreno/a5xx_gpu.c
index 1f60a9a885b4..c1f8c20414f1 100644
--- a/drivers/gpu/drm/msm/adreno/a5xx_gpu.c
+++ b/drivers/gpu/drm/msm/adreno/a5xx_gpu.c
@@ -117,12 +117,10 @@ static void a5xx_submit(struct msm_gpu *gpu, struct msm_gem_submit *submit,
117 gpu->funcs->flush(gpu); 117 gpu->funcs->flush(gpu);
118} 118}
119 119
120struct a5xx_hwcg { 120static const struct {
121 u32 offset; 121 u32 offset;
122 u32 value; 122 u32 value;
123}; 123} a5xx_hwcg[] = {
124
125static const struct a5xx_hwcg a530_hwcg[] = {
126 {REG_A5XX_RBBM_CLOCK_CNTL_SP0, 0x02222222}, 124 {REG_A5XX_RBBM_CLOCK_CNTL_SP0, 0x02222222},
127 {REG_A5XX_RBBM_CLOCK_CNTL_SP1, 0x02222222}, 125 {REG_A5XX_RBBM_CLOCK_CNTL_SP1, 0x02222222},
128 {REG_A5XX_RBBM_CLOCK_CNTL_SP2, 0x02222222}, 126 {REG_A5XX_RBBM_CLOCK_CNTL_SP2, 0x02222222},
@@ -217,38 +215,16 @@ static const struct a5xx_hwcg a530_hwcg[] = {
217 {REG_A5XX_RBBM_CLOCK_DELAY_VFD, 0x00002222} 215 {REG_A5XX_RBBM_CLOCK_DELAY_VFD, 0x00002222}
218}; 216};
219 217
220static const struct { 218void a5xx_set_hwcg(struct msm_gpu *gpu, bool state)
221 int (*test)(struct adreno_gpu *gpu);
222 const struct a5xx_hwcg *regs;
223 unsigned int count;
224} a5xx_hwcg_regs[] = {
225 { adreno_is_a530, a530_hwcg, ARRAY_SIZE(a530_hwcg), },
226};
227
228static void _a5xx_enable_hwcg(struct msm_gpu *gpu,
229 const struct a5xx_hwcg *regs, unsigned int count)
230{ 219{
231 unsigned int i; 220 unsigned int i;
232 221
233 for (i = 0; i < count; i++) 222 for (i = 0; i < ARRAY_SIZE(a5xx_hwcg); i++)
234 gpu_write(gpu, regs[i].offset, regs[i].value); 223 gpu_write(gpu, a5xx_hwcg[i].offset,
235 224 state ? a5xx_hwcg[i].value : 0);
236 gpu_write(gpu, REG_A5XX_RBBM_CLOCK_CNTL, 0xAAA8AA00);
237 gpu_write(gpu, REG_A5XX_RBBM_ISDB_CNT, 0x182);
238}
239 225
240static void a5xx_enable_hwcg(struct msm_gpu *gpu) 226 gpu_write(gpu, REG_A5XX_RBBM_CLOCK_CNTL, state ? 0xAAA8AA00 : 0);
241{ 227 gpu_write(gpu, REG_A5XX_RBBM_ISDB_CNT, state ? 0x182 : 0x180);
242 struct adreno_gpu *adreno_gpu = to_adreno_gpu(gpu);
243 unsigned int i;
244
245 for (i = 0; i < ARRAY_SIZE(a5xx_hwcg_regs); i++) {
246 if (a5xx_hwcg_regs[i].test(adreno_gpu)) {
247 _a5xx_enable_hwcg(gpu, a5xx_hwcg_regs[i].regs,
248 a5xx_hwcg_regs[i].count);
249 return;
250 }
251 }
252} 228}
253 229
254static int a5xx_me_init(struct msm_gpu *gpu) 230static int a5xx_me_init(struct msm_gpu *gpu)
@@ -545,7 +521,7 @@ static int a5xx_hw_init(struct msm_gpu *gpu)
545 gpu_write(gpu, REG_A5XX_RBBM_AHB_CNTL1, 0xA6FFFFFF); 521 gpu_write(gpu, REG_A5XX_RBBM_AHB_CNTL1, 0xA6FFFFFF);
546 522
547 /* Enable HWCG */ 523 /* Enable HWCG */
548 a5xx_enable_hwcg(gpu); 524 a5xx_set_hwcg(gpu, true);
549 525
550 gpu_write(gpu, REG_A5XX_RBBM_AHB_CNTL2, 0x0000003F); 526 gpu_write(gpu, REG_A5XX_RBBM_AHB_CNTL2, 0x0000003F);
551 527
diff --git a/drivers/gpu/drm/msm/adreno/a5xx_gpu.h b/drivers/gpu/drm/msm/adreno/a5xx_gpu.h
index 6638bc85645d..d24796f3a706 100644
--- a/drivers/gpu/drm/msm/adreno/a5xx_gpu.h
+++ b/drivers/gpu/drm/msm/adreno/a5xx_gpu.h
@@ -59,5 +59,6 @@ static inline int spin_usecs(struct msm_gpu *gpu, uint32_t usecs,
59} 59}
60 60
61bool a5xx_idle(struct msm_gpu *gpu); 61bool a5xx_idle(struct msm_gpu *gpu);
62void a5xx_set_hwcg(struct msm_gpu *gpu, bool state);
62 63
63#endif /* __A5XX_GPU_H__ */ 64#endif /* __A5XX_GPU_H__ */