diff options
author | Sue Chen <sue.chen@quanta.corp-partner.google.com> | 2022-09-13 11:17:59 +0800 |
---|---|---|
committer | Chromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com> | 2022-09-14 09:17:42 +0000 |
commit | 6315e187bdb783569447799018b5cbcdd800e2fe (patch) | |
tree | 79ebe26d74974b1641150b0686462132d3bebe49 /zephyr | |
parent | 21ba201712719bf277e4f5a217aa182d2c472851 (diff) | |
download | chrome-ec-6315e187bdb783569447799018b5cbcdd800e2fe.tar.gz |
Craask: Fix lid rotation parameters for Craaskbowl
The placement of the LID sensor is spin 180' on xy plane for Craaskbowl.
Use fw_config bit8 to describe Lid sensor orientation:
0: original placement
1: rotate 180' on xy plane
BUG=none
BRANCH=none
TEST=table mode and rotation work fine on Craaskbowl
Signed-off-by: Sue Chen <sue.chen@quanta.corp-partner.google.com>
Change-Id: Ifa3d22ca2e1c90dfebb8ad8a7eca676b84c07191
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3891565
Code-Coverage: Andrew McRae <amcrae@google.com>
Reviewed-by: Andrew McRae <amcrae@google.com>
Diffstat (limited to 'zephyr')
-rw-r--r-- | zephyr/projects/nissa/craask/cbi.dts | 27 | ||||
-rw-r--r-- | zephyr/projects/nissa/craask/src/form_factor.c | 21 |
2 files changed, 48 insertions, 0 deletions
diff --git a/zephyr/projects/nissa/craask/cbi.dts b/zephyr/projects/nissa/craask/cbi.dts index de17bb1db9..7a827c192e 100644 --- a/zephyr/projects/nissa/craask/cbi.dts +++ b/zephyr/projects/nissa/craask/cbi.dts @@ -4,6 +4,33 @@ */ / { + /* Craask-specific fw_config fields. */ + nissa-fw-config { + /* + * FW_CONFIG field to describe Lid sensor orientation. + */ + lid-inversion { + enum-name = "FW_LID_INVERSION"; + start = <8>; + size = <1>; + + /* + * 0: regular placement of the lid sensor + * 1: rotate 180' of xy plane. + */ + regular { + compatible = "cros-ec,cbi-fw-config-value"; + enum-name = "FW_LID_REGULAR"; + value = <0>; + default; + }; + xy_rotate_180 { + compatible = "cros-ec,cbi-fw-config-value"; + enum-name = "FW_LID_XY_ROT_180"; + value = <1>; + }; + }; + }; /* Craask-specific ssfc fields. */ cbi-ssfc { compatible = "named-cbi-ssfc"; diff --git a/zephyr/projects/nissa/craask/src/form_factor.c b/zephyr/projects/nissa/craask/src/form_factor.c index 7c642119f1..ccf0e66a4f 100644 --- a/zephyr/projects/nissa/craask/src/form_factor.c +++ b/zephyr/projects/nissa/craask/src/form_factor.c @@ -22,9 +22,13 @@ LOG_MODULE_DECLARE(nissa, CONFIG_NISSA_LOG_LEVEL); * Mainboard orientation support. */ +#define LIS_ALT_MAT SENSOR_ROT_STD_REF_NAME(DT_NODELABEL(lid_rot_bma422)) +#define BMA_ALT_MAT SENSOR_ROT_STD_REF_NAME(DT_NODELABEL(lid_rot_ref)) #define ALT_MAT SENSOR_ROT_STD_REF_NAME(DT_NODELABEL(base_rot_ver1)) +#define LID_SENSOR SENSOR_ID(DT_NODELABEL(lid_accel)) #define BASE_SENSOR SENSOR_ID(DT_NODELABEL(base_accel)) #define BASE_GYRO SENSOR_ID(DT_NODELABEL(base_gyro)) +#define ALT_LID_S SENSOR_ID(DT_NODELABEL(alt_lid_accel)) static bool use_alt_sensor; @@ -51,6 +55,23 @@ static void form_factor_init(void) motion_sensors[BASE_GYRO].rot_standard_ref = &ALT_MAT; } + /* + * If the firmware config indicates + * an craaskbowl form factor, use the alternative + * rotation matrix. + */ + ret = cros_cbi_get_fw_config(FW_LID_INVERSION, &val); + if (ret != 0) { + LOG_ERR("Error retrieving CBI FW_CONFIG field %d", + FW_LID_INVERSION); + return; + } + if (val == FW_LID_XY_ROT_180) { + LOG_INF("Lid sensor placement rotate 180 on xy plane"); + motion_sensors[LID_SENSOR].rot_standard_ref = &LIS_ALT_MAT; + motion_sensors_alt[ALT_LID_S].rot_standard_ref = &BMA_ALT_MAT; + } + /* check which base sensor is used for motion_interrupt */ use_alt_sensor = cros_cbi_ssfc_check_match( CBI_SSFC_VALUE_ID(DT_NODELABEL(base_sensor_1))); |