summaryrefslogtreecommitdiff
path: root/zephyr/shim/include/motionsense_sensors_defs.h
diff options
context:
space:
mode:
authorAseda Aboagye <aaboagye@google.com>2022-01-10 17:26:56 -0600
committerAseda Aboagye <aaboagye@google.com>2022-01-10 17:26:56 -0600
commitdc11829e169a9c425860ec5cca949ef80df9e0b7 (patch)
tree0517b0831c6e52b347926a1b727741df380e908c /zephyr/shim/include/motionsense_sensors_defs.h
parentc5bd23a4b204565dab616f7fa4ee8a0b7b433d4c (diff)
parentb44d10f8f79cadb259cc7ab79714a0919fc0c4c8 (diff)
downloadchrome-ec-dc11829e169a9c425860ec5cca949ef80df9e0b7.tar.gz
Merge remote-tracking branch cros/main into firmware-keeby-14119.B-mainfirmware-keeby-14119.B-main
Relevant changes: git log --oneline c5bd23a4b..b44d10f8f -- baseboard/dedede board/cappy2 board/corori board/driblee board/gooey board/haboki board/lalala board/waddledoo2 common/charge_state_v2.c common/mkbp_* common/ocpc.c common/usbc/usb_tc_drp_acc_trysrc_sm.c common/usbc/usb_sm.c common/usbc/*_pd_* common/usbc/dp_alt_mode.c common/usbc/usb_prl_sm.c common/usbc/usb_pe_drp_sm.c common/usb_charger.c common/usb_common.c common/usbc_ocp.c driver/charger/sm5803.* driver/charger/isl923x.* driver/tcpm/raa489000.* driver/tcpm/it83* include/power/icelake.h include/intel_x86.h power/icelake.c power/intel_x86.c util/getversion.sh 42d03a001 config: change temp_sensor_power from config to gpio e296efb28 usb_common: Fix CONFIG_USB_PD_DISCHARGE_TCPC typo c346481f4 atomic: cast to unsigned when shifting 9b972a0f2 driver/tcpm/it83xx, it8xxx2: ITE inactive port return from HOOK a499d8fd4 driver/tcpm/it83xx, it8xxx2: set sleep mask for mixed TCPC case ed62e2583 TCPMv2: don't set the sleep mask for TCPC embedded in EC c962696e8 motion_sensor: Remove |int_signal| field 86b216794 ocpc: modify pre-charge target condition 6f8336eb4 dedede: Set MKBP event wake mask to 0 02d034df0 dedede: add stylus fw_config 4f7cd7509 atomic: use atomic_t where it is possible e3ffa0519 mkbp: change the type fifo_entries to atomic_t bb4c47af0 usb: use atomic_t where possible c6e513ee2 power/icelake: Add SLP_S5 as a watched power signal d89e49b20 power: Introduce S4 as a real power state ba8a3c9c0 chgstv2: Use chipset_in_state instead of naming states 23a975d12 i2c: Use declared initializers for i2c_ports: boards a-l 35865dbec TCPMv2: Guard DATA_RESET using CONFIG_USB_PD_DATA_RESET_MSG d4d8243ed i2c: Use declared initializers for i2c_ports: baseboards eba8d0305 RAA489000: Fixed RAA489000 max charging current e78b83e0f TCPMv2: Delay Data Reset until mode entry request 6230e60fc TCPMv2: Support Data Reset as DFP, initiator 412246836 intel_x86: Apply chipset resume init and suspend complete hooks f2809b72c config: rename CONFIG_HOSTCMD_ESPI to CONFIG_HOST_INTERFACE_ESPI BRANCH=None BUG=b:202796060 b:207805856 b:167983049 b:208318528 b:181983966 BUG=b:207328258 b:195416058 b:205285137 b:199919093 b:207055975 BUG=b:129159505 b:204947672 b:141363146 b:207082842 b:205675485 TEST=`make -j buildall` Signed-off-by: Aseda Aboagye <aaboagye@google.com> Change-Id: I980351977e11088a130e478df0701be4715f049b
Diffstat (limited to 'zephyr/shim/include/motionsense_sensors_defs.h')
-rw-r--r--zephyr/shim/include/motionsense_sensors_defs.h103
1 files changed, 103 insertions, 0 deletions
diff --git a/zephyr/shim/include/motionsense_sensors_defs.h b/zephyr/shim/include/motionsense_sensors_defs.h
new file mode 100644
index 0000000000..ec2180566e
--- /dev/null
+++ b/zephyr/shim/include/motionsense_sensors_defs.h
@@ -0,0 +1,103 @@
+/* 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.
+ */
+
+#ifndef __CROS_EC_MOTIONSENSE_SENSORS_DEFS_H
+#define __CROS_EC_MOTIONSENSE_SENSORS_DEFS_H
+
+#include <devicetree.h>
+
+#define SENSOR_NODE DT_PATH(motionsense_sensor)
+#define SENSOR_INFO_NODE DT_PATH(motionsense_sensor_info)
+#define SENSOR_ALT_NODE DT_PATH(motionsense_sensor_alt)
+
+#define SENSOR_ID(id) DT_CAT(SENSOR_, id)
+
+/* Define the SENSOR_ID if:
+ * DT_NODE_HAS_STATUS(id, okay) && !DT_NODE_HAS_PROP(id, alternate_for)
+ */
+#define SENSOR_ID_WITH_COMMA(id) \
+ IF_ENABLED(DT_NODE_HAS_STATUS(id, okay), \
+ (COND_CODE_0(DT_NODE_HAS_PROP(id, alternate_for), \
+ (SENSOR_ID(id), ), ())))
+
+enum sensor_id {
+#if DT_NODE_EXISTS(SENSOR_NODE)
+ DT_FOREACH_CHILD(SENSOR_NODE, SENSOR_ID_WITH_COMMA)
+#endif
+ SENSOR_COUNT,
+};
+
+#undef SENSOR_ID_WITH_COMMA
+/* Define the SENSOR_ID if:
+ * DT_NODE_HAS_STATUS(id, okay) && DT_NODE_HAS_PROP(id, alternate_for)
+ */
+#define SENSOR_ID_WITH_COMMA(id) \
+ IF_ENABLED(DT_NODE_HAS_STATUS(id, okay), \
+ (COND_CODE_1(DT_NODE_HAS_PROP(id, alternate_for), \
+ (SENSOR_ID(id), ), ())))
+enum sensor_alt_id {
+#if DT_NODE_EXISTS(SENSOR_ALT_NODE)
+ DT_FOREACH_CHILD(SENSOR_ALT_NODE, SENSOR_ID_WITH_COMMA)
+#endif
+ SENSOR_ALT_COUNT,
+};
+
+/*
+ * Find the accelerometers for lid angle calculation.
+ *
+ * The angle calculation requires two accelerometers. One is on the lid
+ * and the other one is on the base. So we need to specify which sensor is
+ * on the lid and which one is on the base. We use two labels "lid_accel"
+ * and "base_accel".
+ *
+ * base_accel - label for the accelerometer sensor on the base.
+ * lid_accel - label for the accelerometer sensor on the lid.
+ *
+ * e.g) below shows BMA255 is the accelerometer on the lid and bmi260 is
+ * the accelerometer on the base.
+ *
+ * motionsense-sensor {
+ * lid_accel: lid-accel {
+ * compatible = "cros-ec,bma255";
+ * status = "okay";
+ * :
+ * :
+ * };
+ *
+ * base_accel: base-accel {
+ * compatible = "cros-ec,bmi260";
+ * status = "okay";
+ * :
+ * :
+ * };
+ * };
+ */
+#ifdef CONFIG_LID_ANGLE
+#define CONFIG_LID_ANGLE_SENSOR_LID SENSOR_ID(DT_NODELABEL(lid_accel))
+#define CONFIG_LID_ANGLE_SENSOR_BASE SENSOR_ID(DT_NODELABEL(base_accel))
+#endif
+
+/*
+ * Get the sensors running in force mode from DT and create a bit mask for it.
+ *
+ * e.g) lid accel and als_clear are in accel_force_mode. The macro below finds
+ * the corresponding bit for each sensor in bit mask and set it.
+ * motionsense-sensor-info {
+ * compatible = "cros-ec,motionsense-sensor-info";
+ *
+ * // list of sensors in force mode
+ * accel-force-mode-sensors = <&lid_accel &als_clear>;
+ * };
+ */
+#if DT_NODE_HAS_PROP(SENSOR_INFO_NODE, accel_force_mode_sensors)
+#define SENSOR_IN_FORCE_MODE(i, id) \
+ | BIT(SENSOR_ID(DT_PHANDLE_BY_IDX(id, accel_force_mode_sensors, i)))
+#define CONFIG_ACCEL_FORCE_MODE_MASK \
+ (0 UTIL_LISTIFY(DT_PROP_LEN(SENSOR_INFO_NODE, \
+ accel_force_mode_sensors), SENSOR_IN_FORCE_MODE, \
+ SENSOR_INFO_NODE))
+#endif
+
+#endif /* __CROS_EC_MOTIONSENSE_SENSORS_DEFS_H */