diff options
author | ben chen <ben.chen2@quanta.corp-partner.google.com> | 2022-03-22 15:15:49 +0800 |
---|---|---|
committer | Chromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com> | 2022-04-06 03:18:52 +0000 |
commit | f8bbc4c4e00dd9a61ed281c32c2681f712396632 (patch) | |
tree | fd5417c078d4cef807e1d63372725bcd1cc39a1b | |
parent | 5d05527d1c5f7beca755ffdde8a690512da79072 (diff) | |
download | chrome-ec-f8bbc4c4e00dd9a61ed281c32c2681f712396632.tar.gz |
villager: Add motion sensor config for kx022
Add kx022 lid accel sensor config.
BUG=b:224884903
BRANCH=main
TEST=Using ectool 'motionsense' verified lid angle now goes
from 0 to 360 and swtiches to tablet mode after crossing 200
threshold on re-work kx022 DUT
Change-Id: I1b93b114dd20707f27a0b0a7f71b0dbc4fa83e41
Signed-off-by: Ben Chen <ben.chen2@quanta.corp-partner.google.com>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3538158
Reviewed-by: Wai-Hong Tam <waihong@google.com>
-rw-r--r-- | zephyr/projects/herobrine/BUILD.py | 2 | ||||
-rw-r--r-- | zephyr/projects/herobrine/motionsense_villager.dts | 157 | ||||
-rw-r--r-- | zephyr/projects/herobrine/prj_villager.conf | 1 |
3 files changed, 159 insertions, 1 deletions
diff --git a/zephyr/projects/herobrine/BUILD.py b/zephyr/projects/herobrine/BUILD.py index 067e2c2a10..3f55eda0b2 100644 --- a/zephyr/projects/herobrine/BUILD.py +++ b/zephyr/projects/herobrine/BUILD.py @@ -58,7 +58,7 @@ register_variant( extra_dts_overlays=[ here / "battery_villager.dts", here / "gpio_villager.dts", - here / "motionsense.dts", + here / "motionsense_villager.dts", here / "switchcap.dts", here / "usbc_villager.dts", ], diff --git a/zephyr/projects/herobrine/motionsense_villager.dts b/zephyr/projects/herobrine/motionsense_villager.dts new file mode 100644 index 0000000000..92cc051a8e --- /dev/null +++ b/zephyr/projects/herobrine/motionsense_villager.dts @@ -0,0 +1,157 @@ +/* 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 <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. + */ + bmi260-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_bmi260: bmi260-mutex { + label = "BMI260_MUTEX"; + }; + }; + + /* Rotation matrix used by drivers. */ + 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)>; + }; + }; + + /* + * 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 { + kx022_data: kx022-drv-data { + compatible = "cros-ec,drvdata-kionix"; + status = "okay"; + }; + + bmi260_data: bmi260-drv-data { + compatible = "cros-ec,drvdata-bmi260"; + 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,kx022"; + status = "okay"; + + label = "Lid Accel"; + active-mask = "SENSOR_ACTIVE_S0_S3"; + location = "MOTIONSENSE_LOC_LID"; + mutex = <&lid_mutex>; + port = <&i2c_sensor>; + rot-standard-ref = <&lid_rot_ref>; + default-range = <2>; + drv-data = <&kx022_data>; + i2c-spi-addr-flags = "KX022_ADDR0_FLAGS"; + configs { + compatible = + "cros-ec,motionsense-sensor-config"; + ec-s0 { + label = "SENSOR_CONFIG_EC_S0"; + odr = <(10000 | ROUND_UP_FLAG)>; + }; + ec-s3 { + label = "SENSOR_CONFIG_EC_S3"; + odr = <(10000 | ROUND_UP_FLAG)>; + }; + }; + }; + + base_accel: base-accel { + compatible = "cros-ec,bmi260-accel"; + status = "okay"; + + label = "Base Accel"; + active-mask = "SENSOR_ACTIVE_S0_S3"; + location = "MOTIONSENSE_LOC_BASE"; + mutex = <&mutex_bmi260>; + port = <&i2c_sensor>; + rot-standard-ref = <&base_rot_ref>; + drv-data = <&bmi260_data>; + configs { + compatible = + "cros-ec,motionsense-sensor-config"; + ec-s0 { + label = "SENSOR_CONFIG_EC_S0"; + odr = <(10000 | ROUND_UP_FLAG)>; + }; + ec-s3 { + label = "SENSOR_CONFIG_EC_S3"; + odr = <(10000 | ROUND_UP_FLAG)>; + }; + }; + }; + + base-gyro { + compatible = "cros-ec,bmi260-gyro"; + status = "okay"; + + label = "Base Gyro"; + active-mask = "SENSOR_ACTIVE_S0_S3"; + location = "MOTIONSENSE_LOC_BASE"; + mutex = <&mutex_bmi260>; + port = <&i2c_sensor>; + rot-standard-ref = <&base_rot_ref>; + drv-data = <&bmi260_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/herobrine/prj_villager.conf b/zephyr/projects/herobrine/prj_villager.conf index fae79ac3b3..35fe2d2502 100644 --- a/zephyr/projects/herobrine/prj_villager.conf +++ b/zephyr/projects/herobrine/prj_villager.conf @@ -7,3 +7,4 @@ CONFIG_BOARD_VILLAGER=y # LED CONFIG_PLATFORM_EC_LED_COMMON=n +CONFIG_PLATFORM_EC_ACCEL_KX022=y |