summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSue Chen <sue.chen@quanta.corp-partner.google.com>2022-09-21 10:46:02 +0800
committerChromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com>2022-09-21 08:15:46 +0000
commite4deb595e1543a416a29de6eed10d0ba050d0d68 (patch)
tree59db701dab6230c69e7b06f993c32f03069549ed
parent3c6ef637c85bb70f668cc9aab8eaf19fbd2d4c2f (diff)
downloadchrome-ec-e4deb595e1543a416a29de6eed10d0ba050d0d68.tar.gz
Craask: Fw_config bit9 to describe clamshell/convertible
FW_CONFIG bit9 0: Convertible 1: Clamshell BUG=none BRANCH=none TEST=set fw_config bit9=1 can disable motion sense. Signed-off-by: Sue Chen <sue.chen@quanta.corp-partner.google.com> Change-Id: I9e29a901e3f5c647c561bada31b03f1f3f20332d Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3906511 Code-Coverage: Andrew McRae <amcrae@google.com> Reviewed-by: Andrew McRae <amcrae@google.com>
-rw-r--r--zephyr/projects/nissa/craask/cbi.dts22
-rw-r--r--zephyr/projects/nissa/craask/prj.conf1
-rw-r--r--zephyr/projects/nissa/craask/src/form_factor.c18
3 files changed, 41 insertions, 0 deletions
diff --git a/zephyr/projects/nissa/craask/cbi.dts b/zephyr/projects/nissa/craask/cbi.dts
index 7a827c192e..4c2e052f4d 100644
--- a/zephyr/projects/nissa/craask/cbi.dts
+++ b/zephyr/projects/nissa/craask/cbi.dts
@@ -30,6 +30,28 @@
value = <1>;
};
};
+ /*
+ * FW_CONFIG field to describe Clamshell/Convertible.
+ */
+ form_factor {
+ enum-name = "FORM_FACTOR";
+ start = <9>;
+ size = <1>;
+
+ /*
+ * 0: convertible, 1: clamshell
+ */
+ convertible {
+ compatible = "cros-ec,cbi-fw-config-value";
+ enum-name = "CONVERTIBLE";
+ value = <0>;
+ };
+ clamshell {
+ compatible = "cros-ec,cbi-fw-config-value";
+ enum-name = "CLAMSHELL";
+ value = <1>;
+ };
+ };
};
/* Craask-specific ssfc fields. */
cbi-ssfc {
diff --git a/zephyr/projects/nissa/craask/prj.conf b/zephyr/projects/nissa/craask/prj.conf
index bcf4cc836d..b7f31cee63 100644
--- a/zephyr/projects/nissa/craask/prj.conf
+++ b/zephyr/projects/nissa/craask/prj.conf
@@ -10,5 +10,6 @@ CONFIG_PLATFORM_EC_ACCELGYRO_LSM6DSO=y
CONFIG_PLATFORM_EC_ACCEL_BMA4XX=y
CONFIG_PLATFORM_EC_ACCELGYRO_BMI_COMM_I2C=y
CONFIG_PLATFORM_EC_ACCELGYRO_BMI3XX=y
+CONFIG_PLATFORM_EC_DYNAMIC_MOTION_SENSOR_COUNT=y
CONFIG_PLATFORM_EC_BUTTONS_RUNTIME_CONFIG=y
diff --git a/zephyr/projects/nissa/craask/src/form_factor.c b/zephyr/projects/nissa/craask/src/form_factor.c
index 1303711de3..59869eaa2f 100644
--- a/zephyr/projects/nissa/craask/src/form_factor.c
+++ b/zephyr/projects/nissa/craask/src/form_factor.c
@@ -12,8 +12,11 @@
#include "cros_cbi.h"
#include "driver/accelgyro_bmi323.h"
#include "driver/accelgyro_lsm6dso.h"
+#include "gpio/gpio_int.h"
#include "hooks.h"
#include "motionsense_sensors.h"
+#include "motion_sense.h"
+#include "tablet_mode.h"
#include "nissa_common.h"
@@ -99,5 +102,20 @@ static void form_factor_init(void)
CBI_SSFC_VALUE_ID(DT_NODELABEL(base_sensor_1)));
motion_sensors_check_ssfc();
+
+ /* Check if it's clamshell or convertible */
+ ret = cros_cbi_get_fw_config(FORM_FACTOR, &val);
+ if (ret != 0) {
+ LOG_ERR("Error retrieving CBI FW_CONFIG field %d", FORM_FACTOR);
+ return;
+ }
+ if (val == CLAMSHELL) {
+ LOG_INF("Clamshell: disable motionsense function.");
+ motion_sensor_count = 0;
+ gmr_tablet_switch_disable();
+ gpio_disable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_imu));
+ gpio_pin_configure_dt(GPIO_DT_FROM_NODELABEL(gpio_imu_int_l),
+ GPIO_DISCONNECTED);
+ }
}
DECLARE_HOOK(HOOK_INIT, form_factor_init, HOOK_PRIO_POST_I2C);