summaryrefslogtreecommitdiff
path: root/payloads/libpayload
diff options
context:
space:
mode:
authorDaisuke Nojiri <dnojiri@chromium.org>2015-02-18 16:41:26 -0800
committerPatrick Georgi <pgeorgi@google.com>2015-04-21 08:29:10 +0200
commit7ab46f8085146db57699001462da871f2e4d9965 (patch)
tree8c56bc6cc1554d311357c919bacf3b20060f1e2a /payloads/libpayload
parentb048432578871abe69c7eb54404089c42f35c2f6 (diff)
libpayload: add timer driver for cygnus
BUG=chrome-os-partner:36011 BRANCH=broadcom-firmware TEST=measured 10 seconds in depthcharge: Starting depthcharge on purin... dpch: time 10 9 8 7 6 5 4 3 2 1 0 Change-Id: I0bcb01c255b19518bb8440111ac81f056c07ed69 Signed-off-by: Patrick Georgi <pgeorgi@chromium.org> Original-Commit-Id: f5993bd400dd5d38e62d07bc8ce3513175e0d518 Original-Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> Original-Reviewed-on: https://chrome-internal-review.googlesource.com/200569 Original-Reviewed-by: Julius Werner <jwerner@chromium.org> Original-Commit-Queue: Daisuke Nojiri <dnojiri@google.com> Original-Tested-by: Daisuke Nojiri <dnojiri@google.com> Original-Change-Id: Id83aae29cec6320d897e0b231d023a9ee885903e Original-Reviewed-on: https://chromium-review.googlesource.com/256415 Reviewed-on: http://review.coreboot.org/9850 Tested-by: build bot (Jenkins) Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
Diffstat (limited to 'payloads/libpayload')
-rw-r--r--payloads/libpayload/Config.in5
-rw-r--r--payloads/libpayload/drivers/timer/cygnus.c31
2 files changed, 34 insertions, 2 deletions
diff --git a/payloads/libpayload/Config.in b/payloads/libpayload/Config.in
index 455d058dcc..40c57dcb06 100644
--- a/payloads/libpayload/Config.in
+++ b/payloads/libpayload/Config.in
@@ -442,6 +442,11 @@ config IPQ806X_TIMER_REG
help
Address of the register to read a free running timer value.
+config IPROC_PERIPH_GLB_TIM_REG_BASE
+ hex "Cygnus timer base address"
+ depends on TIMER_CYGNUS
+ default 0x19020200
+
config USB
bool "USB Support"
default n
diff --git a/payloads/libpayload/drivers/timer/cygnus.c b/payloads/libpayload/drivers/timer/cygnus.c
index 16035496b9..e627d3e532 100644
--- a/payloads/libpayload/drivers/timer/cygnus.c
+++ b/payloads/libpayload/drivers/timer/cygnus.c
@@ -18,12 +18,39 @@
*/
#include <libpayload.h>
+struct cygnus_timer {
+ u32 gtim_glob_low;
+ u32 gtim_glob_hi;
+ u32 gtim_glob_ctrl;
+};
+
+static struct cygnus_timer * const timer_ptr =
+ (void *)CONFIG_LP_IPROC_PERIPH_GLB_TIM_REG_BASE;
+
uint64_t timer_hz(void)
{
- return 0;
+ /*
+ * this is set up by coreboot as follows:
+ *
+ * PERIPH_CLOCK /
+ * (((TIMER_GLB_TIM_CTRL_PRESC & TIMER_GLB_TIM_CTRL_PRESC_MASK)>>8) + 1)
+ *
+ * where PERIPH_CLOCK is typically 500000000.
+ */
+ return 500000000;
}
uint64_t timer_raw_value(void)
{
- return 0;
+ uint64_t cur_tick;
+ uint32_t count_h;
+ uint32_t count_l;
+
+ do {
+ count_h = readl(&timer_ptr->gtim_glob_hi);
+ count_l = readl(&timer_ptr->gtim_glob_low);
+ cur_tick = readl(&timer_ptr->gtim_glob_hi);
+ } while (cur_tick != count_h);
+
+ return (cur_tick << 32) + count_l;
}