[coreboot-gerrit] New patch to review for coreboot: dd4b61e exynos: convert to stopwatch API

Patrick Georgi (pgeorgi@google.com) gerrit at coreboot.org
Fri Mar 20 16:13:47 CET 2015


Patrick Georgi (pgeorgi at google.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/8825

-gerrit

commit dd4b61ec790ae07b7e057887a2c19ae99aed1dd3
Author: Aaron Durbin <adurbin at chromium.org>
Date:   Wed Sep 24 10:27:29 2014 -0500

    exynos: convert to stopwatch API
    
    Instead of open coding monotonic timer usage,
    use the stopwatch API.
    
    BUG=None
    BRANCH=None
    TEST=None
    
    Change-Id: I1c541c1c9f3fde0dec9163ad6cc94322538ac7f7
    Signed-off-by: Patrick Georgi <pgeorgi at chromium.org>
    Original-Commit-Id: 46ede0897687da6bcf730a8904f25e5a4485d6cd
    Original-Change-Id: Ia63a05850a1b6afdc42c2422332f77af516d27e3
    Original-Signed-off-by: Aaron Durbin <adurbin at chromium.org>
    Original-Reviewed-on: https://chromium-review.googlesource.com/219716
    Original-Reviewed-by: Julius Werner <jwerner at chromium.org>
    Original-Reviewed-by: David Hendricks <dhendrix at chromium.org>
    Original-Reviewed-by: Furquan Shaikh <furquan at chromium.org>
---
 src/soc/samsung/exynos5250/clock.c  | 13 ++++++-------
 src/soc/samsung/exynos5250/dp-reg.c | 18 ++++++------------
 src/soc/samsung/exynos5250/fb.c     | 20 +++++++-------------
 src/soc/samsung/exynos5420/clock.c  |  9 +++------
 src/soc/samsung/exynos5420/i2c.c    |  9 +++------
 5 files changed, 25 insertions(+), 44 deletions(-)

diff --git a/src/soc/samsung/exynos5250/clock.c b/src/soc/samsung/exynos5250/clock.c
index a00af02..246b9dc 100644
--- a/src/soc/samsung/exynos5250/clock.c
+++ b/src/soc/samsung/exynos5250/clock.c
@@ -597,7 +597,7 @@ int clock_epll_set_rate(unsigned long rate)
 	unsigned int epll_con, epll_con_k;
 	unsigned int i;
 	unsigned int lockcnt;
-	struct mono_time current, end;
+	struct stopwatch sw;
 
 	epll_con = readl(&exynos_clock->epll_con0);
 	epll_con &= ~((EPLL_CON0_LOCK_DET_EN_MASK <<
@@ -631,17 +631,16 @@ int clock_epll_set_rate(unsigned long rate)
 	writel(epll_con, &exynos_clock->epll_con0);
 	writel(epll_con_k, &exynos_clock->epll_con1);
 
-	timer_monotonic_get(&current);
-	end = current;
-	mono_time_add_msecs(&end, TIMEOUT_EPLL_LOCK);
+	stopwatch_init_msecs_expire(&sw, TIMEOUT_EPLL_LOCK);
 
 	while (!(readl(&exynos_clock->epll_con0) &
 			(0x1 << EXYNOS5_EPLLCON0_LOCKED_SHIFT))) {
-		if (mono_time_after(&current, &end)) {
-			printk(BIOS_DEBUG, "%s: Timeout waiting for EPLL lock\n", __func__);
+		if (stopwatch_expired(&sw)) {
+			printk(BIOS_DEBUG,
+				"%s: Timeout waiting for EPLL lock\n",
+				__func__);
 			return -1;
 		}
-		timer_monotonic_get(&current);
 	}
 
 	return 0;
diff --git a/src/soc/samsung/exynos5250/dp-reg.c b/src/soc/samsung/exynos5250/dp-reg.c
index 1cc7088..018633e 100644
--- a/src/soc/samsung/exynos5250/dp-reg.c
+++ b/src/soc/samsung/exynos5250/dp-reg.c
@@ -120,7 +120,7 @@ unsigned int s5p_dp_get_pll_lock_status(struct s5p_dp_device *dp)
 int s5p_dp_init_analog_func(struct s5p_dp_device *dp)
 {
 	u32 reg;
-	struct mono_time current, end;
+	struct stopwatch sw;
 	struct exynos5_dp *base = dp->base;
 
 	writel(0x00, &base->dp_phy_pd);
@@ -135,17 +135,14 @@ int s5p_dp_init_analog_func(struct s5p_dp_device *dp)
 
 		clrbits_le32(&base->dp_pll_ctl, DP_PLL_PD);
 
-		timer_monotonic_get(&current);
-		end = current;
-		mono_time_add_msecs(&end, PLL_LOCK_TIMEOUT);
+		stopwatch_init_msecs_expire(&sw, PLL_LOCK_TIMEOUT);
 
 		while (s5p_dp_get_pll_lock_status(dp) == PLL_UNLOCKED) {
-			if (mono_time_after(&current, &end)) {
+			if (stopwatch_expired(&sw)) {
 				printk(BIOS_ERR, "%s: PLL is not locked\n",
 						__func__);
 				return -1;
 			}
-			timer_monotonic_get(&current);
 		}
 	}
 
@@ -435,13 +432,11 @@ void s5p_dp_enable_video_master(struct s5p_dp_device *dp)
 int s5p_dp_is_video_stream_on(struct s5p_dp_device *dp)
 {
 	u32 reg, i = 0;
-	struct mono_time current, end;
+	struct stopwatch sw;
 	struct exynos5_dp *base = dp->base;
 
 	/* Wait for 4 VSYNC_DET interrupts */
-	timer_monotonic_get(&current);
-	end = current;
-	mono_time_add_msecs(&end, STREAM_ON_TIMEOUT);
+	stopwatch_init_msecs_expire(&sw, STREAM_ON_TIMEOUT);
 
 	do {
 		reg = readl(&base->common_int_sta_1);
@@ -451,8 +446,7 @@ int s5p_dp_is_video_stream_on(struct s5p_dp_device *dp)
 		}
 		if (i == 4)
 			break;
-		timer_monotonic_get(&current);
-	} while (mono_time_before(&current, &end));
+	} while (!stopwatch_expired(&sw));
 
 	if (i != 4) {
 		printk(BIOS_DEBUG, "s5p_dp_is_video_stream_on timeout\n");
diff --git a/src/soc/samsung/exynos5250/fb.c b/src/soc/samsung/exynos5250/fb.c
index e0355fc..48295a5 100644
--- a/src/soc/samsung/exynos5250/fb.c
+++ b/src/soc/samsung/exynos5250/fb.c
@@ -181,7 +181,7 @@ static int s5p_dp_config_video(struct s5p_dp_device *dp,
 {
 	int timeout = 0;
 	struct exynos5_dp *base = dp->base;
-	struct mono_time start, current, end;
+	struct stopwatch sw;
 	s5p_dp_config_video_slave_mode(dp, video_info);
 
 	s5p_dp_set_video_color_format(dp, video_info->color_depth,
@@ -194,20 +194,17 @@ static int s5p_dp_config_video(struct s5p_dp_device *dp,
 		return -ERR_PLL_NOT_UNLOCKED;
 	}
 
-	timer_monotonic_get(&start);
-	end = current = start;
-	mono_time_add_usecs(&end, STREAM_ON_TIMEOUT * USECS_PER_MSEC);
+	stopwatch_init_msecs_expire(&sw, STREAM_ON_TIMEOUT);
 	do {
 		if (s5p_dp_is_slave_video_stream_clock_on(dp) == 0) {
 			timeout++;
 			break;
 		}
-		timer_monotonic_get(&current);
-	} while (mono_time_before(&current, &end));
+	} while (!stopwatch_expired(&sw));
 
 	if (!timeout) {
 		printk(BIOS_ERR, "Video Clock Not ok after %ldus.\n",
-				mono_time_diff_microseconds(&start, &end));
+				stopwatch_duration_usecs(&sw));
 		return -ERR_VIDEO_CLOCK_BAD;
 	}
 
@@ -402,23 +399,20 @@ static int s5p_dp_hw_link_training(struct s5p_dp_device *dp,
 	int pll_is_locked = 0;
 	u32 data;
 	int lane;
-	struct mono_time current, end;
+	struct stopwatch sw;
 	struct exynos5_dp *base = dp->base;
 
 	/* Stop Video */
 	clrbits_le32(&base->video_ctl_1, VIDEO_EN);
 
-	timer_monotonic_get(&current);
-	end = current;
-	mono_time_add_msecs(&end, PLL_LOCK_TIMEOUT);
+	stopwatch_init_msecs_expire(&sw, PLL_LOCK_TIMEOUT);
 
 	while ((pll_is_locked = s5p_dp_get_pll_lock_status(dp)) == PLL_UNLOCKED) {
-		if (mono_time_after(&current, &end)) {
+		if (stopwatch_expired(&sw)) {
 			/* Ignore this error, and try to continue */
 			printk(BIOS_ERR, "PLL is not locked yet.\n");
 			break;
 		}
-		timer_monotonic_get(&current);
 	}
 	printk(BIOS_SPEW, "PLL is %slocked\n",
 			pll_is_locked == PLL_LOCKED ? "": "not ");
diff --git a/src/soc/samsung/exynos5420/clock.c b/src/soc/samsung/exynos5420/clock.c
index 5cf3583..91e61cb 100644
--- a/src/soc/samsung/exynos5420/clock.c
+++ b/src/soc/samsung/exynos5420/clock.c
@@ -561,7 +561,7 @@ int clock_epll_set_rate(unsigned long rate)
 	unsigned int epll_con, epll_con_k;
 	unsigned int i;
 	unsigned int lockcnt;
-	struct mono_time current, end;
+	struct stopwatch sw;
 
 	epll_con = readl(&exynos_clock->epll_con0);
 	epll_con &= ~((EPLL_CON0_LOCK_DET_EN_MASK <<
@@ -595,17 +595,14 @@ int clock_epll_set_rate(unsigned long rate)
 	writel(epll_con, &exynos_clock->epll_con0);
 	writel(epll_con_k, &exynos_clock->epll_con1);
 
-	timer_monotonic_get(&current);
-	end = current;
-	mono_time_add_msecs(&end, TIMEOUT_EPLL_LOCK);
+	stopwatch_init_msecs_expire(&sw, TIMEOUT_EPLL_LOCK);
 
 	while (!(readl(&exynos_clock->epll_con0) &
 			(0x1 << EXYNOS5_EPLLCON0_LOCKED_SHIFT))) {
-		if (mono_time_after(&current, &end)) {
+		if (stopwatch_expired(&sw)) {
 			printk(BIOS_DEBUG, "%s: Timeout waiting for EPLL lock\n", __func__);
 			return -1;
 		}
-		timer_monotonic_get(&current);
 	}
 
 	return 0;
diff --git a/src/soc/samsung/exynos5420/i2c.c b/src/soc/samsung/exynos5420/i2c.c
index 49875d7..8c6c361 100644
--- a/src/soc/samsung/exynos5420/i2c.c
+++ b/src/soc/samsung/exynos5420/i2c.c
@@ -415,16 +415,13 @@ static int hsi2c_check_transfer(struct hsi2c_regs *regs)
  */
 static int hsi2c_wait_for_transfer(struct hsi2c_regs *i2c)
 {
-	struct mono_time current, end;
+	struct stopwatch sw;
 
-	timer_monotonic_get(&current);
-	end = current;
-	mono_time_add_usecs(&end, Hsi2cTimeout * 1000);
-	while (mono_time_before(&current, &end)) {
+	stopwatch_init_msecs_expire(&sw, Hsi2cTimeout);
+	while (!stopwatch_expired(&sw)) {
 		int ret = hsi2c_check_transfer(i2c);
 		if (ret)
 			return ret;
-		timer_monotonic_get(&current);
 	}
 	return 0;
 }



More information about the coreboot-gerrit mailing list