summaryrefslogtreecommitdiff
path: root/zephyr/shim/src/motionsense_driver/bmi260-drvinfo.inc
diff options
context:
space:
mode:
authorHyungwoo Yang <hyungwoo.yang@intel.corp-partner.google.com>2021-03-19 23:37:43 -0700
committerCommit Bot <commit-bot@chromium.org>2021-03-24 02:10:53 +0000
commita0e46cd164efca0f48ecff3d1d2ffe10309e3fd4 (patch)
tree57dd6c2651c674ee563173635cb4aaeb5f8d9cc2 /zephyr/shim/src/motionsense_driver/bmi260-drvinfo.inc
parentd4ebcc156bc62d9b883882ddd7b3ad629b926803 (diff)
downloadchrome-ec-a0e46cd164efca0f48ecff3d1d2ffe10309e3fd4.tar.gz
zephyr: DT: support BMI260
This change is to support BMI260 via DT. The change includes, using DT, - creating BMI260 driver specific data - creating motion sensor entry for BMI260 - creating the BMI260 irq event to motion sense task 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: Id5c64df4d2f14a50709ac15855567a67671b8515 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2778821 Reviewed-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'zephyr/shim/src/motionsense_driver/bmi260-drvinfo.inc')
-rw-r--r--zephyr/shim/src/motionsense_driver/bmi260-drvinfo.inc57
1 files changed, 57 insertions, 0 deletions
diff --git a/zephyr/shim/src/motionsense_driver/bmi260-drvinfo.inc b/zephyr/shim/src/motionsense_driver/bmi260-drvinfo.inc
new file mode 100644
index 0000000000..2457fca31a
--- /dev/null
+++ b/zephyr/shim/src/motionsense_driver/bmi260-drvinfo.inc
@@ -0,0 +1,57 @@
+/* Copyright 2021 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 "driver/accelgyro_bmi_common_public.h"
+#include "driver/accelgyro_bmi260_public.h"
+
+/*
+ * CREATE_SENSOR_DATA which is defined in motionsense_sensros.c is
+ * the helper to create sensor driver specific data.
+ *
+ * CREATE_SENSOR_DATA gets two arguments. One is the compatible
+ * property value specified in device tree and the other one is the macro
+ * that actually creates sensor driver specific data. The macro gets
+ * node id and the name to be used for the sensor driver data.
+ */
+
+/*
+ * Create driver data. It can be shared among the entries in
+ * motion_sensors array which are using the same bmi260 driver.
+ */
+#define CREATE_SENSOR_DATA_BMI260(id, drvdata_name) \
+ static struct bmi_drv_data_t drvdata_name;
+
+/*
+ * Create driver data for each BMI260 drvinfo instance in device tree.
+ * (compatible = "cros-ec,drvdata-bmi260")
+ */
+CREATE_SENSOR_DATA(cros_ec_drvdata_bmi260, CREATE_SENSOR_DATA_BMI260)
+/*
+ * CREATE_MOTION_SENSOR which is defined in motionsense_sensros.c is
+ * the macro to create an entry in motion_sensors array.
+ * The macro gets value of compatible property of
+ * the sensor in device tree and sensor specific values like chip ID,
+ * type of sensor, name of driver, default min/max frequency.
+ * Then using the values, it creates the corresponding motion_sense_t entry
+ * in motion_sensors array.
+ */
+
+/*
+ * Here, we call CREATE_MOTION_SENSOR to create a motion_sensor_t entry
+ * for each BMI260_accel instance(compatible = "cros-ec,bmi260-accel")
+ * in device tree.
+ */
+CREATE_MOTION_SENSOR(cros_ec_bmi260_accel, MOTIONSENSE_CHIP_BMI260, \
+ MOTIONSENSE_TYPE_ACCEL, bmi260_drv, \
+ BMI_ACCEL_MIN_FREQ, BMI_ACCEL_MAX_FREQ)
+
+/*
+ * Here, we call CREATE_MOTION_SENSOR to create a motion_sensor_t entry
+ * for each BMI260_gyro instance (compatible = "cros-ec,bmi260-gyro")
+ * in device tree.
+ */
+CREATE_MOTION_SENSOR(cros_ec_bmi260_gyro, MOTIONSENSE_CHIP_BMI260, \
+ MOTIONSENSE_TYPE_GYRO, bmi260_drv, \
+ BMI_GYRO_MIN_FREQ, BMI_GYRO_MAX_FREQ)