summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYuval Peress <peress@chromium.org>2021-04-21 23:24:17 -0600
committerCommit Bot <commit-bot@chromium.org>2021-04-23 17:32:01 +0000
commit91fae3e36038080aa004507c08e43f4c12281169 (patch)
treeaa0349578d3ffa1e7679df088cf005b0560f9338
parent03e78d7583ebdfe0f9d53f70a256d0fb23807696 (diff)
downloadchrome-ec-91fae3e36038080aa004507c08e43f4c12281169.tar.gz
zephyr: drivers: add bindings for KX022
Add the bindings files for the kx022 and generic kionix driver data. Also, add the .inc files needed to create an instance of the sensor and data structures. BRANCH=none BUG=b:185966444 TEST=zmake testall Signed-off-by: Yuval Peress <peress@chromium.org> Change-Id: Id72690763b27888848645ee38a747a4e49fa0d42 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2845558 Reviewed-by: Keith Short <keithshort@chromium.org> Reviewed-by: Jack Rosenthal <jrosenth@chromium.org> Commit-Queue: Keith Short <keithshort@chromium.org> Commit-Queue: Jack Rosenthal <jrosenth@chromium.org>
-rw-r--r--zephyr/dts/bindings/motionsense/driver/cros-ec,kx022.yaml21
-rw-r--r--zephyr/dts/bindings/motionsense/drvdata/cros-ec,drvdata-kionix.yaml18
-rw-r--r--zephyr/shim/src/motionsense_driver/kx022-drvinfo.inc44
-rw-r--r--zephyr/shim/src/motionsense_driver/sensor_drv_list.inc3
4 files changed, 86 insertions, 0 deletions
diff --git a/zephyr/dts/bindings/motionsense/driver/cros-ec,kx022.yaml b/zephyr/dts/bindings/motionsense/driver/cros-ec,kx022.yaml
new file mode 100644
index 0000000000..b90d824575
--- /dev/null
+++ b/zephyr/dts/bindings/motionsense/driver/cros-ec,kx022.yaml
@@ -0,0 +1,21 @@
+# 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.
+
+description: motionsense sensor node for KX022
+
+compatible: "cros-ec,kx022"
+
+# every motionsense sensor node should include motionsense-sensor-base.yaml
+include: motionsense-sensor-base.yaml
+
+properties:
+ i2c-spi-addr-flags:
+ type: string
+ description: i2c address or SPI slave logic GPIO
+ enum:
+ - "KX022_ADDR0_FLAGS"
+ - "KX022_ADDR1_FLAGS"
+ default: "KX022_ADDR0_FLAGS"
+ default-range:
+ default: 2
diff --git a/zephyr/dts/bindings/motionsense/drvdata/cros-ec,drvdata-kionix.yaml b/zephyr/dts/bindings/motionsense/drvdata/cros-ec,drvdata-kionix.yaml
new file mode 100644
index 0000000000..3151412b79
--- /dev/null
+++ b/zephyr/dts/bindings/motionsense/drvdata/cros-ec,drvdata-kionix.yaml
@@ -0,0 +1,18 @@
+# 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.
+
+description: Kionix driver data node
+
+compatible: "cros-ec,drvdata-kionix"
+
+include: drvdata-base.yaml
+
+#
+# examples:
+#
+# kx022_data: kx022-drv-data {
+# compatible = "cros-ec,drvdata-kionix";
+# status = "okay";
+# };
+#
diff --git a/zephyr/shim/src/motionsense_driver/kx022-drvinfo.inc b/zephyr/shim/src/motionsense_driver/kx022-drvinfo.inc
new file mode 100644
index 0000000000..93e471b859
--- /dev/null
+++ b/zephyr/shim/src/motionsense_driver/kx022-drvinfo.inc
@@ -0,0 +1,44 @@
+/* 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 "accel_kx022.h"
+
+/*
+ * CREATE_SENSOR_DATA which is defined in motionsense_sensors.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 for each Kionix drvinfo instance in device tree.
+ * (compatible = "cros-ec,drvdata-kionix")
+ */
+/* Declare Kionix driver data */
+#define CREATE_SENSOR_DATA_KIONIX(id, drvdata_name) \
+ static struct kionix_accel_data drvdata_name;
+
+CREATE_SENSOR_DATA(cros_ec_drvdata_kionix, CREATE_SENSOR_DATA_KIONIX)
+
+/*
+ * CREATE_MOTION_SENSOR which is defined in motionsense_sensors.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.
+ */
+
+/*
+ * Create a motion_sensor_t entry for each KX022
+ * instance(compatible = "cros-ec,kx022") in device tree.
+ */
+CREATE_MOTION_SENSOR(cros_ec_kx022, MOTIONSENSE_CHIP_KX022, \
+ MOTIONSENSE_TYPE_ACCEL, kionix_accel_drv, \
+ KX022_ACCEL_MIN_FREQ, KX022_ACCEL_MAX_FREQ)
diff --git a/zephyr/shim/src/motionsense_driver/sensor_drv_list.inc b/zephyr/shim/src/motionsense_driver/sensor_drv_list.inc
index 67fb660dbe..b9b3a189ad 100644
--- a/zephyr/shim/src/motionsense_driver/sensor_drv_list.inc
+++ b/zephyr/shim/src/motionsense_driver/sensor_drv_list.inc
@@ -22,6 +22,9 @@
#ifdef CONFIG_PLATFORM_EC_ACCEL_BMA255
#include "bma255-drvinfo.inc"
#endif
+#ifdef CONFIG_PLATFORM_EC_ACCEL_KX022
+#include "kx022-drvinfo.inc"
+#endif
#ifdef CONFIG_PLATFORM_EC_ACCELGYRO_BMI160
#include "bmi160-drvinfo.inc"
#endif