summaryrefslogtreecommitdiff
path: root/common/motion_sense.c
diff options
context:
space:
mode:
authorHyungwoo Yang <hyungwoo.yang@intel.corp-partner.google.com>2021-01-19 21:18:36 -0800
committerCommit Bot <commit-bot@chromium.org>2021-01-22 21:43:16 +0000
commit90995b4a525442b448384e8c5e6d77f541283c4d (patch)
tree9e68cdf860d4080a258115edc447c9e488b3688c /common/motion_sense.c
parent90dea61948cfcb668f6d893a7d8f6aef419ef942 (diff)
downloadchrome-ec-90995b4a525442b448384e8c5e6d77f541283c4d.tar.gz
zephyr: add motion sense support
Add support for motion sense in zephyr. This change adds basic functions for motion sense task to do meaningful work. sensor_map.h included by board.h will be used to get board specific sensor configuration. BUG=b:173507858 BRANCH=none TEST=make buildall -j8 build volteer on zephyr Signed-off-by: Hyungwoo Yang <hyungwoo.yang@intel.corp-partner.google.com> Change-Id: I906316d2e97428cf46b9a15071666c8e3b039b18 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2638909 Reviewed-by: Jack Rosenthal <jrosenth@chromium.org> Commit-Queue: Jack Rosenthal <jrosenth@chromium.org> Tested-by: Jack Rosenthal <jrosenth@chromium.org>
Diffstat (limited to 'common/motion_sense.c')
-rw-r--r--common/motion_sense.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/common/motion_sense.c b/common/motion_sense.c
index 7a306bfb4a..9564012abe 100644
--- a/common/motion_sense.c
+++ b/common/motion_sense.c
@@ -53,7 +53,7 @@ STATIC_IF(CONFIG_CMD_ACCEL_INFO) int accel_disp;
*/
#define MOTION_SENSOR_INT_ADJUSTMENT_US 10
-struct mutex g_sensor_mutex;
+mutex_t g_sensor_mutex;
/*
* Current power level (S0, S3, S5, ...)
@@ -78,6 +78,18 @@ static uint32_t odr_event_required;
/* Whether or not the FIFO interrupt should be enabled (set from the AP). */
__maybe_unused static int fifo_int_enabled;
+#ifdef CONFIG_ZEPHYR
+static int init_sensor_mutex(const struct device *dev)
+{
+ ARG_UNUSED(dev);
+
+ k_mutex_init(&g_sensor_mutex);
+
+ return 0;
+}
+SYS_INIT(init_sensor_mutex, POST_KERNEL, 50);
+#endif /* CONFIG_ZEPHYR */
+
static inline int motion_sensor_in_forced_mode(
const struct motion_sensor_t *sensor)
{