diff options
author | Robert Zieba <robertzieba@google.com> | 2022-03-09 13:10:22 -0700 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2022-03-17 01:31:36 +0000 |
commit | 0e73ccb23eb5d8b2c4999f0cb294b90be0785e70 (patch) | |
tree | 3c8d82c0d95ab837798f4275cc6b72393721e27a | |
parent | 83dc64e5ef30dd3b573e53dec92c6b36b6ad6884 (diff) | |
download | chrome-ec-0e73ccb23eb5d8b2c4999f0cb294b90be0785e70.tar.gz |
Zephyr: enable motion sensors for guybrush and skyrim
This commits adds the motionsense device tree and config changes
required to enable motion sensors for guybrush and skyrim.
BUG=b:214619940
TEST=Used `ectool motionsense` and `accelread` to validate sensor readings
under zephyr
BRANCH=none
Signed-off-by: Robert Zieba <robertzieba@google.com>
Change-Id: I3ef8e14eadcb07c97c616f938c78a8e1254444bc
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3517676
Reviewed-by: Diana Z <dzigterman@chromium.org>
-rw-r--r-- | zephyr/dts/bindings/motionsense/driver/cros-ec,bmi3xx-accel.yaml | 2 | ||||
-rw-r--r-- | zephyr/projects/skyrim/BUILD.py | 1 | ||||
-rw-r--r-- | zephyr/projects/skyrim/guybrush.dts | 18 | ||||
-rw-r--r-- | zephyr/projects/skyrim/interrupts.dts | 5 | ||||
-rw-r--r-- | zephyr/projects/skyrim/motionsense.dts | 144 | ||||
-rw-r--r-- | zephyr/projects/skyrim/prj.conf | 14 | ||||
-rw-r--r-- | zephyr/projects/skyrim/prj_guybrush.conf | 2 | ||||
-rw-r--r-- | zephyr/projects/skyrim/skyrim.dts | 18 |
8 files changed, 200 insertions, 4 deletions
diff --git a/zephyr/dts/bindings/motionsense/driver/cros-ec,bmi3xx-accel.yaml b/zephyr/dts/bindings/motionsense/driver/cros-ec,bmi3xx-accel.yaml index 713dcc0698..24d28645ee 100644 --- a/zephyr/dts/bindings/motionsense/driver/cros-ec,bmi3xx-accel.yaml +++ b/zephyr/dts/bindings/motionsense/driver/cros-ec,bmi3xx-accel.yaml @@ -2,7 +2,7 @@ # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. -description: motion sense sensor node for BMI260 accel +description: motion sense sensor node for BMI3XX accel compatible: "cros-ec,bmi3xx-accel" diff --git a/zephyr/projects/skyrim/BUILD.py b/zephyr/projects/skyrim/BUILD.py index fded4164f0..21b4caded7 100644 --- a/zephyr/projects/skyrim/BUILD.py +++ b/zephyr/projects/skyrim/BUILD.py @@ -16,6 +16,7 @@ def register_variant(project_name): here / "i2c.dts", here / "interrupts.dts", here / "keyboard.dts", + here / "motionsense.dts", here / "pwm.dts", here / "usbc.dts", # Project-specific DTS customizations. diff --git a/zephyr/projects/skyrim/guybrush.dts b/zephyr/projects/skyrim/guybrush.dts index d3e1d95832..4d633c33a9 100644 --- a/zephyr/projects/skyrim/guybrush.dts +++ b/zephyr/projects/skyrim/guybrush.dts @@ -89,7 +89,7 @@ ec_pwm7 { gpios = <&gpio6 0 GPIO_INPUT_PULL_UP>; }; - 6axis_int_l { + gpio_accel_gyro_int_l: accel_gyro_int_l { gpios = <&gpioa 0 GPIO_INPUT_PULL_UP>; }; }; @@ -175,4 +175,20 @@ handler = "baseboard_en_pwr_pcore_s0"; }; }; + + /* Rotation matrices for motion sensors. */ + motionsense-rotation-ref { + compatible = "cros-ec,motionsense-rotation-ref"; + lid_rot_ref: lid-rotation-ref { + mat33 = <0 (-1) 0 + (-1) 0 0 + 0 0 (-1)>; + }; + + base_rot_ref: base-rotation-ref { + mat33 = <(-1) 0 0 + 0 1 0 + 0 0 (-1)>; + }; + }; }; diff --git a/zephyr/projects/skyrim/interrupts.dts b/zephyr/projects/skyrim/interrupts.dts index 656fd78da1..66df9efadb 100644 --- a/zephyr/projects/skyrim/interrupts.dts +++ b/zephyr/projects/skyrim/interrupts.dts @@ -87,5 +87,10 @@ flags = <GPIO_INT_EDGE_FALLING>; handler = "bc12_interrupt"; }; + int_accel_gyro: accel_gyro { + irq-pin = <&gpio_accel_gyro_int_l>; + flags = <GPIO_INT_EDGE_FALLING>; + handler = "bmi3xx_interrupt"; + }; }; }; diff --git a/zephyr/projects/skyrim/motionsense.dts b/zephyr/projects/skyrim/motionsense.dts new file mode 100644 index 0000000000..642a1cddf8 --- /dev/null +++ b/zephyr/projects/skyrim/motionsense.dts @@ -0,0 +1,144 @@ +/* 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 <dt-bindings/motionsense/utils.h> + + +/ { + aliases { + /* + * motion sense's <>_INT_EVENT is handled + * by alias. Using the alias, each driver creates + * its own <>_INT_EVENT. + */ + bmi3xx-int = &base_accel; + }; + + /* + * Declare mutexes used by sensor drivers. + * A mutex node is used to create an instance of mutex_t. + * A mutex node is referenced by a sensor node if the + * corresponding sensor driver needs to use the + * instance of the mutex. + */ + motionsense-mutex { + compatible = "cros-ec,motionsense-mutex"; + lid_mutex: lid-mutex { + label = "LID_MUTEX"; + }; + + mutex_bmi3xx: bmi3xx-mutex { + label = "BMI3XX_MUTEX"; + }; + }; + + /* + * Driver specific data. A driver-specific data can be shared with + * different motion sensors while they are using the same driver. + * + * If a node's compatible starts with "cros-ec,accelgyro-", it is for + * a common structure defined in accelgyro.h. + * e.g) compatible = "cros-ec,accelgyro-als-drv-data" is for + * "struct als_drv_data_t" in accelgyro.h + */ + motionsense-sensor-data { + bma4xx_data: bma4xx-drv-data { + compatible = "cros-ec,drvdata-bma4xx"; + status = "okay"; + }; + + bmi3xx_data: bmi3xx-drv-data { + compatible = "cros-ec,drvdata-bmi3xx"; + status = "okay"; + }; + }; + + /* + * List of motion sensors that creates motion_sensors array. + * The label "lid_accel" and "base_accel" are used to indicate + * motion sensor IDs for lid angle calculation. + */ + motionsense-sensor { + lid_accel: lid-accel { + compatible = "cros-ec,bma4xx"; + status = "okay"; + + label = "Lid Accel"; + active-mask = "SENSOR_ACTIVE_S0_S3"; + location = "MOTIONSENSE_LOC_LID"; + mutex = <&lid_mutex>; + port = <&i2c_sensor>; + drv-data = <&bma4xx_data>; + rot-standard-ref = <&lid_rot_ref>; + default-range = <2>; + configs { + compatible = + "cros-ec,motionsense-sensor-config"; + ec-s0 { + label = "SENSOR_CONFIG_EC_S0"; + odr = <(12500 | ROUND_UP_FLAG)>; + ec-rate = <100>; + }; + ec-s3 { + label = "SENSOR_CONFIG_EC_S3"; + odr = <(12500 | ROUND_UP_FLAG)>; + }; + }; + }; + + base_accel: base-accel { + compatible = "cros-ec,bmi3xx-accel"; + status = "okay"; + + label = "Base Accel"; + active-mask = "SENSOR_ACTIVE_S0_S3"; + location = "MOTIONSENSE_LOC_BASE"; + mutex = <&mutex_bmi3xx>; + port = <&i2c_sensor>; + rot-standard-ref = <&base_rot_ref>; + drv-data = <&bmi3xx_data>; + + configs { + compatible = + "cros-ec,motionsense-sensor-config"; + ec-s0 { + label = "SENSOR_CONFIG_EC_S0"; + odr = <(12500 | ROUND_UP_FLAG)>; + ec-rate = <100>; + }; + ec-s3 { + label = "SENSOR_CONFIG_EC_S3"; + odr = <(12500 | ROUND_UP_FLAG)>; + }; + }; + }; + + base-gyro { + compatible = "cros-ec,bmi3xx-gyro"; + status = "okay"; + + label = "Base Gyro"; + active-mask = "SENSOR_ACTIVE_S0_S3"; + location = "MOTIONSENSE_LOC_BASE"; + mutex = <&mutex_bmi3xx>; + port = <&i2c_sensor>; + rot-standard-ref = <&base_rot_ref>; + drv-data = <&bmi3xx_data>; + }; + }; + + motionsense-sensor-info { + compatible = "cros-ec,motionsense-sensor-info"; + + /* + * list of GPIO interrupts that have to + * be enabled at initial stage + */ + sensor-irqs = <&int_accel_gyro>; + + /* list of sensors in force mode */ + accel-force-mode-sensors = <&lid_accel>; + }; +}; diff --git a/zephyr/projects/skyrim/prj.conf b/zephyr/projects/skyrim/prj.conf index b5d1a14075..1bc9cb8345 100644 --- a/zephyr/projects/skyrim/prj.conf +++ b/zephyr/projects/skyrim/prj.conf @@ -132,5 +132,19 @@ CONFIG_PLATFORM_EC_IOEX=y CONFIG_PLATFORM_EC_BOARD_RESET_AFTER_POWER_ON=y CONFIG_PLATFORM_EC_HIBERNATE_PSL=y +# Motion sense +CONFIG_PLATFORM_EC_MOTIONSENSE=y +CONFIG_PLATFORM_EC_ACCEL_FIFO=y +CONFIG_PLATFORM_EC_ACCEL_INTERRUPTS=y +CONFIG_PLATFORM_EC_CONSOLE_CMD_ACCELS=y +CONFIG_PLATFORM_EC_CONSOLE_CMD_ACCEL_INFO=y +CONFIG_PLATFORM_EC_LID_ANGLE=y +CONFIG_PLATFORM_EC_LID_ANGLE_UPDATE=y +CONFIG_PLATFORM_EC_SENSOR_TIGHT_TIMESTAMPS=y + +CONFIG_PLATFORM_EC_ACCEL_BMA4XX=y +CONFIG_PLATFORM_EC_ACCELGYRO_BMI3XX=y +CONFIG_PLATFORM_EC_ACCELGYRO_BMI_COMM_I2C=y + # Misc. CONFIG_PLATFORM_EC_I2C_DEBUG=y diff --git a/zephyr/projects/skyrim/prj_guybrush.conf b/zephyr/projects/skyrim/prj_guybrush.conf index f1ef2ae811..0ca57174a4 100644 --- a/zephyr/projects/skyrim/prj_guybrush.conf +++ b/zephyr/projects/skyrim/prj_guybrush.conf @@ -6,4 +6,4 @@ CONFIG_BOARD_GUYBRUSH=y # Only Guybrush has TMP112 -CONFIG_PLATFORM_EC_TEMP_SENSOR_TMP112=y +CONFIG_PLATFORM_EC_TEMP_SENSOR_TMP112=y
\ No newline at end of file diff --git a/zephyr/projects/skyrim/skyrim.dts b/zephyr/projects/skyrim/skyrim.dts index 7f20c5e266..88661a9fb2 100644 --- a/zephyr/projects/skyrim/skyrim.dts +++ b/zephyr/projects/skyrim/skyrim.dts @@ -84,7 +84,7 @@ ec_espi_rst_l { gpios = <&gpio5 4 GPIO_PULL_DOWN>; }; - 6axis_int_l { + gpio_accel_gyro_int_l: accel_gyro_int_l { gpios = <&gpioa 0 GPIO_INPUT>; }; }; @@ -180,4 +180,20 @@ }; }; }; + + /* Rotation matrices for motion sensors. */ + motionsense-rotation-ref { + compatible = "cros-ec,motionsense-rotation-ref"; + lid_rot_ref: lid-rotation-ref { + mat33 = <0 (-1) 0 + 1 0 0 + 0 0 1>; + }; + + base_rot_ref: base-rotation-ref { + mat33 = <0 1 0 + (-1) 0 0 + 0 0 1>; + }; + }; }; |