summaryrefslogtreecommitdiff
path: root/zephyr/shim/src/hwtimer.c
diff options
context:
space:
mode:
authorJack Rosenthal <jrosenth@chromium.org>2020-09-23 08:43:26 -0600
committerCommit Bot <commit-bot@chromium.org>2020-10-01 19:14:48 +0000
commit480a1dc59a883251019262147a8c306e98599436 (patch)
treeb3ace437b75856c62c3b31ea06fcb972ef9de475 /zephyr/shim/src/hwtimer.c
parent326864e0a15bcd0de5890579f10c14fda888022a (diff)
downloadchrome-ec-480a1dc59a883251019262147a8c306e98599436.tar.gz
zephyr: shim in the timer module
This enables building timer.c in the Zephyr shim. In addition, we provide definitions for the symbols __hw_clock_source_read64 and __hw_clock_event_get defined for Zephyr to provide times to the CrOS EC. The event timer does not make sense for Zephyr code, but we need it defined to prevent link errors (timerinfo uses it). Perhaps the solution to this is to add a new config option (e.g., CONFIG_EVENT_TIMER) which can be used to selectively enable/disable the event timer in the CrOS EC. But punting this work for now and just adding a fake definition. BUG=b:167590251 BRANCH=none TEST=compile for posix-ec, run gettime and timerinfo commands Signed-off-by: Jack Rosenthal <jrosenth@chromium.org> Change-Id: I58990a6295625f9c34ec080360470431b46155bd Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2427100 Reviewed-by: Jett Rink <jettrink@chromium.org>
Diffstat (limited to 'zephyr/shim/src/hwtimer.c')
-rw-r--r--zephyr/shim/src/hwtimer.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/zephyr/shim/src/hwtimer.c b/zephyr/shim/src/hwtimer.c
new file mode 100644
index 0000000000..85c72c5c59
--- /dev/null
+++ b/zephyr/shim/src/hwtimer.c
@@ -0,0 +1,29 @@
+/* Copyright 2020 The Chromium OS Authors. All rights reserved.
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include <kernel.h>
+#include <stdint.h>
+#include <zephyr.h>
+
+#include "hwtimer.h"
+
+uint64_t __hw_clock_source_read64(void)
+{
+ return k_ticks_to_us_floor64(k_uptime_ticks());
+}
+
+uint32_t __hw_clock_event_get(void)
+{
+ /*
+ * CrOS EC event deadlines don't quite make sense in Zephyr
+ * terms. Evaluate what to do about this later...
+ */
+ return 0;
+}
+
+void udelay(unsigned us)
+{
+ k_busy_wait(us);
+}