[coreboot-gerrit] Patch set updated for coreboot: 381e3d2 exynos5/5250: Update timer call sites to use monotonic timer API

David Hendricks (dhendrix@chromium.org) gerrit at coreboot.org
Fri May 3 22:28:13 CEST 2013


David Hendricks (dhendrix at chromium.org) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/3176

-gerrit

commit 381e3d24c2ac388f28e76603a74edf48937e5146
Author: David Hendricks <dhendrix at chromium.org>
Date:   Thu May 2 14:23:51 2013 -0700

    exynos5/5250: Update timer call sites to use monotonic timer API
    
    This goes thru various call sites where we used timer_us() and updates
    them to use the new monotonic timer API.
    
    udelay() changed substantially and now gracefully handles wraparound.
    
    Change-Id: Ie2cc86a4125cf0de12837fd7d337a11aed25715c
    Signed-off-by: David Hendricks <dhendrix at chromium.org>
---
 src/cpu/samsung/exynos5-common/exynos-fb.c | 17 +++++++++--------
 src/cpu/samsung/exynos5-common/timer.c     | 23 +++++++++++++----------
 src/cpu/samsung/exynos5250/Makefile.inc    |  3 +++
 3 files changed, 25 insertions(+), 18 deletions(-)

diff --git a/src/cpu/samsung/exynos5-common/exynos-fb.c b/src/cpu/samsung/exynos5-common/exynos-fb.c
index 00ff19e..b2e926f 100644
--- a/src/cpu/samsung/exynos5-common/exynos-fb.c
+++ b/src/cpu/samsung/exynos5-common/exynos-fb.c
@@ -27,7 +27,7 @@
 #include <arch/io.h>
 #include <stdlib.h>
 #include <string.h>
-#include <time.h>
+#include <timer.h>
 #include <console/console.h>
 #include <cpu/samsung/exynos5250/cpu.h>
 #include <cpu/samsung/exynos5250/power.h>
@@ -212,9 +212,8 @@ static int s5p_dp_config_video(struct s5p_dp_device *dp,
 			       struct video_info *video_info)
 {
 	int timeout = 0;
-	u32 start, end;
 	struct exynos5_dp *base = dp->base;
-
+	struct mono_time start, current, end;
 	s5p_dp_config_video_slave_mode(dp, video_info);
 
 	s5p_dp_set_video_color_format(dp, video_info->color_depth,
@@ -227,18 +226,20 @@ static int s5p_dp_config_video(struct s5p_dp_device *dp,
 		return -ERR_PLL_NOT_UNLOCKED;
 	}
 
-	start = timer_us();
-	end = start + STREAM_ON_TIMEOUT*1000;
+	timer_monotonic_get(&start);
+	end = current = start;
+	mono_time_add_usecs(&end, STREAM_ON_TIMEOUT * USECS_PER_MSEC);
 	do {
 		if (s5p_dp_is_slave_video_stream_clock_on(dp) == 0) {
 			timeout++;
 			break;
 		}
-	} while (timer_us() < end);
+		timer_monotonic_get(&current);
+	} while (mono_time_before(&current, &end));
 
 	if (!timeout) {
-		printk(BIOS_ERR, "Video Clock Not ok after %uus.\n",
-							timer_us() - start);
+		printk(BIOS_ERR, "Video Clock Not ok after %ldus.\n",
+				mono_time_diff_microseconds(&start, &end));
 		return -ERR_VIDEO_CLOCK_BAD;
 	}
 
diff --git a/src/cpu/samsung/exynos5-common/timer.c b/src/cpu/samsung/exynos5-common/timer.c
index ca15501..b1ddd1a 100644
--- a/src/cpu/samsung/exynos5-common/timer.c
+++ b/src/cpu/samsung/exynos5-common/timer.c
@@ -25,7 +25,7 @@
 
 #include <common.h>
 #include <arch/io.h>
-#include <time.h>
+#include <timer.h>
 #include <console/console.h>
 #include <cpu/samsung/exynos5-common/pwm.h>
 #include <cpu/samsung/exynos5-common/clk.h>
@@ -121,16 +121,19 @@ unsigned long timer_get_us(void)
 /* delay x useconds */
 void udelay(unsigned long usec)
 {
-	unsigned long start;
+	struct mono_time current, end;
 
-	start = timer_us();
-	if ((start + usec) < start){
-		printk(BIOS_EMERG, "udelay: %08lx is impossibly large\n",
-			usec);
-		usec = 1000000;
-	}
-	while ((timer_us() - start) < usec)
-		;
+	timer_monotonic_get(&current);
+	end = current;
+	mono_time_add_usecs(&end, usec);
+
+	if (mono_time_cmp(&current, &end) == 1)
+		printk(BIOS_WARNING, "udelay(%lu) will wraparound\n", usec);
+	while (mono_time_cmp(&current, &end) == 1)
+		timer_monotonic_get(&current);
+
+	while (mono_time_cmp(&current, &end) == -1)
+		timer_monotonic_get(&current);
 }
 
 /*
diff --git a/src/cpu/samsung/exynos5250/Makefile.inc b/src/cpu/samsung/exynos5250/Makefile.inc
index 403c198..2cd3428 100644
--- a/src/cpu/samsung/exynos5250/Makefile.inc
+++ b/src/cpu/samsung/exynos5250/Makefile.inc
@@ -7,6 +7,7 @@ bootblock-y += pinmux.c mct.c power.c
 # Clock is required for UART
 bootblock-$(CONFIG_EARLY_CONSOLE) += clock_init.c
 bootblock-$(CONFIG_EARLY_CONSOLE) += clock.c
+bootblock-$(CONFIG_EARLY_CONSOLE) += monotonic_timer.c
 bootblock-$(CONFIG_EARLY_CONSOLE) += soc.c
 bootblock-$(CONFIG_EARLY_CONSOLE) += uart.c
 
@@ -17,6 +18,7 @@ romstage-y += dmc_common.c
 romstage-y += dmc_init_ddr3.c
 romstage-y += power.c
 romstage-y += mct.c
+romstage-y += monotonic_timer.c
 romstage-$(CONFIG_EARLY_CONSOLE) += soc.c
 romstage-$(CONFIG_EARLY_CONSOLE) += uart.c
 
@@ -30,6 +32,7 @@ ramstage-$(CONFIG_CONSOLE_SERIAL_UART) += uart.c
 ramstage-y += cpu.c
 ramstage-y += exynos5250-tmu.c
 ramstage-y += mct.c
+ramstage-y += monotonic_timer.c
 
 #ramstage-$(CONFIG_SATA_AHCI) += sata.c
 



More information about the coreboot-gerrit mailing list