summaryrefslogtreecommitdiff
path: root/zephyr
diff options
context:
space:
mode:
authorPeter Marheine <pmarheine@chromium.org>2022-02-07 12:50:00 +1100
committerCommit Bot <commit-bot@chromium.org>2022-02-09 02:41:46 +0000
commit6e61b75cb85f9a811d8077467b4abf3423b5fa5e (patch)
tree5d01ce05fd01ebb8fa0fd419ece6dec1bea6ee85 /zephyr
parent8c2cd9431493072052b23bc9b465744db2e8854f (diff)
downloadchrome-ec-6e61b75cb85f9a811d8077467b4abf3423b5fa5e.tar.gz
zephyr: add shim support for BMA4xx accelerometer
A kconfig option for this driver already existed, but device tree bindings didn't exist and the driver wouldn't actually be built. BUG=none TEST=driver builds and runs when enabled on nereid BRANCH=none Change-Id: Ia147f582c0782db16a94bf5580c06cd0c2e2cd82 Signed-off-by: Peter Marheine <pmarheine@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3442901 Reviewed-by: Andrew McRae <amcrae@google.com> Reviewed-by: Jack Rosenthal <jrosenth@chromium.org>
Diffstat (limited to 'zephyr')
-rw-r--r--zephyr/CMakeLists.txt2
-rw-r--r--zephyr/dts/bindings/motionsense/driver/cros-ec,bma4xx.yaml19
-rw-r--r--zephyr/dts/bindings/motionsense/drvdata/cros-ec,drvdata-bma4xx.yaml18
-rw-r--r--zephyr/shim/src/motionsense_driver/bma4xx-drvinfo.inc44
-rw-r--r--zephyr/shim/src/motionsense_driver/sensor_drv_list.inc3
5 files changed, 86 insertions, 0 deletions
diff --git a/zephyr/CMakeLists.txt b/zephyr/CMakeLists.txt
index 992e6d4790..3873e44566 100644
--- a/zephyr/CMakeLists.txt
+++ b/zephyr/CMakeLists.txt
@@ -128,6 +128,8 @@ zephyr_library_sources_ifdef(CONFIG_HAS_TASK_POWERBTN
"${PLATFORM_EC}/common/power_button_x86.c")
zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_ACCEL_BMA255
"${PLATFORM_EC}/driver/accel_bma2x2.c")
+zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_ACCEL_BMA4XX
+ "${PLATFORM_EC}/driver/accel_bma4xx.c")
zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_ACCEL_KX022
"${PLATFORM_EC}/driver/accel_kionix.c")
zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_ACCEL_LIS2DW12
diff --git a/zephyr/dts/bindings/motionsense/driver/cros-ec,bma4xx.yaml b/zephyr/dts/bindings/motionsense/driver/cros-ec,bma4xx.yaml
new file mode 100644
index 0000000000..6c912c96d4
--- /dev/null
+++ b/zephyr/dts/bindings/motionsense/driver/cros-ec,bma4xx.yaml
@@ -0,0 +1,19 @@
+# Copyright 2022 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 BMA4xx
+
+compatible: "cros-ec,bma4xx"
+
+# 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 peripheral logic GPIO
+ enum:
+ - "BMA4_I2C_ADDR_PRIMARY"
+ - "BMA4_I2C_ADDR_SECONDARY"
+ default: "BMA4_I2C_ADDR_PRIMARY"
diff --git a/zephyr/dts/bindings/motionsense/drvdata/cros-ec,drvdata-bma4xx.yaml b/zephyr/dts/bindings/motionsense/drvdata/cros-ec,drvdata-bma4xx.yaml
new file mode 100644
index 0000000000..2f00d771b3
--- /dev/null
+++ b/zephyr/dts/bindings/motionsense/drvdata/cros-ec,drvdata-bma4xx.yaml
@@ -0,0 +1,18 @@
+# Copyright 2022 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: BMA4XX driver data node
+
+compatible: "cros-ec,drvdata-bma4xx"
+
+include: drvdata-base.yaml
+
+#
+# examples:
+#
+# bma4xx_data: bma4xx-drv-data {
+# compatible = "cros-ec,drvdata-bma4xx";
+# status = "okay";
+# };
+#
diff --git a/zephyr/shim/src/motionsense_driver/bma4xx-drvinfo.inc b/zephyr/shim/src/motionsense_driver/bma4xx-drvinfo.inc
new file mode 100644
index 0000000000..2d40c55de7
--- /dev/null
+++ b/zephyr/shim/src/motionsense_driver/bma4xx-drvinfo.inc
@@ -0,0 +1,44 @@
+/* Copyright 2022 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/accel_bma4xx.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 BMA4xx drvinfo instance in device tree.
+ * (compatible = "cros-ec,drvdata-bma4xx")
+ */
+/* Declare BMA4xx driver data */
+#define CREATE_SENSOR_DATA_BMA4XX(id, drvdata_name) \
+ static struct accelgyro_saved_data_t drvdata_name;
+
+CREATE_SENSOR_DATA(cros_ec_drvdata_bma4xx, CREATE_SENSOR_DATA_BMA4XX)
+
+/*
+ * 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 BMA4XX
+ * instance(compatible = "cros-ec,bma4xx") in device tree.
+ */
+CREATE_MOTION_SENSOR(cros_ec_bma4xx, MOTIONSENSE_CHIP_BMA422, \
+ MOTIONSENSE_TYPE_ACCEL, bma4_accel_drv, \
+ BMA4_ACCEL_MIN_FREQ, BMA4_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 dc2690662a..2b70a6ec16 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_BMA4XX
+#include "bma4xx-drvinfo.inc"
+#endif
#ifdef CONFIG_PLATFORM_EC_ACCEL_KX022
#include "kx022-drvinfo.inc"
#endif