summaryrefslogtreecommitdiff
path: root/zephyr
diff options
context:
space:
mode:
Diffstat (limited to 'zephyr')
-rw-r--r--zephyr/projects/nissa/craask/cbi.dts27
-rw-r--r--zephyr/projects/nissa/craask/src/form_factor.c21
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)));