diff mbox

[27/48] staging: etnaviv: provide a helper to load the GPU clock field

Message ID 1443182280-15868-28-git-send-email-l.stach@pengutronix.de (mailing list archive)
State New, archived
Headers show

Commit Message

Lucas Stach Sept. 25, 2015, 11:57 a.m. UTC
From: Russell King <rmk+kernel@arm.linux.org.uk>

The GPU requires a double-write to set the clock divisor.  Rather than
open-coding this knowledge in a couple of places, provide a helper to
do this instead.  This avoids spreading this knowledge around the
driver.

Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
---
 drivers/staging/etnaviv/etnaviv_gpu.c | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)
diff mbox

Patch

diff --git a/drivers/staging/etnaviv/etnaviv_gpu.c b/drivers/staging/etnaviv/etnaviv_gpu.c
index b12d46075732..d274fcf9f5b1 100644
--- a/drivers/staging/etnaviv/etnaviv_gpu.c
+++ b/drivers/staging/etnaviv/etnaviv_gpu.c
@@ -280,6 +280,13 @@  static void etnaviv_hw_identify(struct etnaviv_gpu *gpu)
 	etnaviv_hw_specs(gpu);
 }
 
+static void etnaviv_gpu_load_clock(struct etnaviv_gpu *gpu, u32 clock)
+{
+	gpu_write(gpu, VIVS_HI_CLOCK_CONTROL, clock |
+		  VIVS_HI_CLOCK_CONTROL_FSCALE_CMD_LOAD);
+	gpu_write(gpu, VIVS_HI_CLOCK_CONTROL, clock);
+}
+
 static int etnaviv_hw_reset(struct etnaviv_gpu *gpu)
 {
 	u32 control, idle;
@@ -301,9 +308,7 @@  static int etnaviv_hw_reset(struct etnaviv_gpu *gpu)
 			  VIVS_HI_CLOCK_CONTROL_FSCALE_VAL(0x40);
 
 		/* enable clock */
-		gpu_write(gpu, VIVS_HI_CLOCK_CONTROL, control |
-			  VIVS_HI_CLOCK_CONTROL_FSCALE_CMD_LOAD);
-		gpu_write(gpu, VIVS_HI_CLOCK_CONTROL, control);
+		etnaviv_gpu_load_clock(gpu, control);
 
 		/* Wait for stable clock.  Vivante's code waited for 1ms */
 		usleep_range(1000, 10000);
@@ -367,9 +372,7 @@  static int etnaviv_hw_reset(struct etnaviv_gpu *gpu)
 		  VIVS_HI_CLOCK_CONTROL_FSCALE_VAL(0x40);
 
 	/* enable clock */
-	gpu_write(gpu, VIVS_HI_CLOCK_CONTROL, control |
-		  VIVS_HI_CLOCK_CONTROL_FSCALE_CMD_LOAD);
-	gpu_write(gpu, VIVS_HI_CLOCK_CONTROL, control);
+	etnaviv_gpu_load_clock(gpu, control);
 
 	return 0;
 }