summaryrefslogtreecommitdiff
path: root/zephyr
diff options
context:
space:
mode:
authorYuval Peress <peress@chromium.org>2021-04-15 10:55:25 -0600
committerCommit Bot <commit-bot@chromium.org>2021-04-16 22:32:27 +0000
commita2b75b36ebfeaf5f344e03e1c0ee0b77c11e82de (patch)
treefaa28631546a204f7f718b63173c36046830b269 /zephyr
parent7ffc631e080dde6741580ecf217e9565ad791a71 (diff)
downloadchrome-ec-a2b75b36ebfeaf5f344e03e1c0ee0b77c11e82de.tar.gz
driver: bmi: fix use of I2C_PORT_ACCEL
The BMI driver is currently using I2C_PORT_ACCEL incorrectly as a CONFIG_ value. Update the use cases to a new config option that selects between SPI and I2C communication specifically for the chip. To avoid a lot of device.h changes, the value of the config value is automatically inferred if not explicitly set. BRANCH=none BUG=b:185392974, b:146065507 TEST=zmake testall TEST=make buildall Signed-off-by: Yuval Peress <peress@chromium.org> Change-Id: I6196cc595dc61877ab2b8ed5416bebee51276927 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2829010 Commit-Queue: Keith Short <keithshort@chromium.org> Reviewed-by: Keith Short <keithshort@chromium.org>
Diffstat (limited to 'zephyr')
-rw-r--r--zephyr/CMakeLists.txt5
-rw-r--r--zephyr/Kconfig.accelgyro_bmi33
-rw-r--r--zephyr/Kconfig.sensor_devices9
-rw-r--r--zephyr/projects/volteer/volteer/prj.conf1
-rw-r--r--zephyr/shim/include/config_chip.h10
5 files changed, 56 insertions, 2 deletions
diff --git a/zephyr/CMakeLists.txt b/zephyr/CMakeLists.txt
index ce47548d3b..883031ef7e 100644
--- a/zephyr/CMakeLists.txt
+++ b/zephyr/CMakeLists.txt
@@ -201,10 +201,11 @@ zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC "${PLATFORM_EC}/common/base32.c"
zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_ACCEL_BMA255
"${PLATFORM_EC}/driver/accel_bma2x2.c"
"${PLATFORM_EC}/common/math_util.c")
-zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_ACCELGYRO_BMI260
+zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_ACCELGYRO_BMI
"${PLATFORM_EC}/driver/accelgyro_bmi_common.c"
- "${PLATFORM_EC}/driver/accelgyro_bmi260.c"
"${PLATFORM_EC}/common/math_util.c")
+zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_ACCELGYRO_BMI260
+ "${PLATFORM_EC}/driver/accelgyro_bmi260.c")
zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_ACCELGYRO_ICM
"${PLATFORM_EC}/driver/accelgyro_icm_common.c")
zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_ACCELGYRO_ICM426XX
diff --git a/zephyr/Kconfig.accelgyro_bmi b/zephyr/Kconfig.accelgyro_bmi
new file mode 100644
index 0000000000..bb8239f6d8
--- /dev/null
+++ b/zephyr/Kconfig.accelgyro_bmi
@@ -0,0 +1,33 @@
+# 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.
+
+
+if PLATFORM_EC_ACCELGYRO_BMI
+menu "BMI Sensor Common"
+
+choice PLATFORM_EC_ACCELGYRO_BMI_COMM
+ prompt "Accelgyro BMI's communication mode"
+ help
+ When using the BMI drivers, there's the option to communicate with the
+ chip via several methods. This choice helps improve code size by only
+ compiling the needed communication channels.
+
+config PLATFORM_EC_ACCELGYRO_BMI_COMM_SPI
+ bool "Use SPI communication"
+ help
+ The BMI chip is using SPI communication. This config value is used to
+ save on code size as only the SPI communication code will be included
+ for the BMI chip.
+
+config PLATFORM_EC_ACCELGYRO_BMI_COMM_I2C
+ bool "Use I2C communication"
+ help
+ The BMI chip is using I2C communication. This config value is used to
+ save on code size as only the I2C communication code will be included
+ for the BMI chip.
+
+endchoice
+
+endmenu # BMI Sensor
+endif # PLATFORM_EC_ACCELGYRO_BMI \ No newline at end of file
diff --git a/zephyr/Kconfig.sensor_devices b/zephyr/Kconfig.sensor_devices
index a62a43d6c2..3cfa41220d 100644
--- a/zephyr/Kconfig.sensor_devices
+++ b/zephyr/Kconfig.sensor_devices
@@ -4,6 +4,13 @@
menu "Sensor Devices"
+config PLATFORM_EC_ACCELGYRO_BMI
+ bool "Config used to include common accelgyro BMI features"
+ help
+ Do not set this directly in a .conf file. This value should be set
+ using an `select` statement in other BMI family of drivers such as
+ BMI260.
+
config PLATFORM_EC_ACCELGYRO_ICM
bool "Config used to include common accelgyro ICM features"
help
@@ -21,6 +28,7 @@ config PLATFORM_EC_ACCEL_BMA255
config PLATFORM_EC_ACCELGYRO_BMI260
bool "BMI260 Accelgyrometer Driver"
+ select PLATFORM_EC_ACCELGYRO_BMI
help
The driver supports Bosch's BMI260 which is an IMU consisting of
a 16-bit tri-axial gyroscope and a 16-bit tri-axial accelerometer.
@@ -38,6 +46,7 @@ config PLATFORM_EC_ACCELGYRO_ICM426XX
The driver supports ICM425XX which provides both accelerometer and
gyroscope readings.
+rsource "Kconfig.accelgyro_bmi"
rsource "Kconfig.accelgyro_icm"
endmenu # Sensor devices
diff --git a/zephyr/projects/volteer/volteer/prj.conf b/zephyr/projects/volteer/volteer/prj.conf
index 32a2ac8118..ed3255049d 100644
--- a/zephyr/projects/volteer/volteer/prj.conf
+++ b/zephyr/projects/volteer/volteer/prj.conf
@@ -86,6 +86,7 @@ CONFIG_PLATFORM_EC_TABLET_MODE=y
# Sensor Drivers
CONFIG_PLATFORM_EC_ACCEL_BMA255=y
CONFIG_PLATFORM_EC_ACCELGYRO_BMI260=y
+CONFIG_PLATFORM_EC_ACCELGYRO_BMI_COMM_I2C=y
CONFIG_PLATFORM_EC_ALS_TCS3400=y
# Temperature sensors
diff --git a/zephyr/shim/include/config_chip.h b/zephyr/shim/include/config_chip.h
index 923937688b..e0ca82c1c9 100644
--- a/zephyr/shim/include/config_chip.h
+++ b/zephyr/shim/include/config_chip.h
@@ -1447,4 +1447,14 @@
#define CONFIG_ACCELGYRO_ICM_COMM_I2C
#endif
+#undef CONFIG_ACCELGYRO_BMI_COMM_SPI
+#ifdef CONFIG_PLATFORM_EC_ACCELGYRO_BMI_COMM_SPI
+#define CONFIG_ACCELGYRO_BMI_COMM_SPI
+#endif
+
+#undef CONFIG_ACCELGYRO_BMI_COMM_I2C
+#ifdef CONFIG_PLATFORM_EC_ACCELGYRO_BMI_COMM_I2C
+#define CONFIG_ACCELGYRO_BMI_COMM_I2C
+#endif
+
#endif /* __CROS_EC_CONFIG_CHIP_H */