summaryrefslogtreecommitdiff
path: root/zephyr/program
diff options
context:
space:
mode:
Diffstat (limited to 'zephyr/program')
-rw-r--r--zephyr/program/corsola/include/variant_db_detection.h15
-rw-r--r--zephyr/program/corsola/npcx_adc.dtsi1
-rw-r--r--zephyr/program/corsola/src/npcx_usbc.c10
-rw-r--r--zephyr/program/corsola/src/usb_pd_policy.c13
-rw-r--r--zephyr/program/corsola/src/usbc.c6
-rw-r--r--zephyr/program/corsola/starmie/CMakeLists.txt5
-rw-r--r--zephyr/program/corsola/starmie/project.conf4
-rw-r--r--zephyr/program/corsola/starmie/project.overlay56
-rw-r--r--zephyr/program/corsola/starmie/src/base_detect.c151
-rw-r--r--zephyr/program/corsola/starmie/src/ppc.c8
-rw-r--r--zephyr/program/corsola/voltorb/project.conf1
-rw-r--r--zephyr/program/nissa/CMakeLists.txt1
-rw-r--r--zephyr/program/nissa/craask/src/led.c2
-rw-r--r--zephyr/program/nissa/joxer/cbi.dtsi21
-rw-r--r--zephyr/program/nissa/joxer/motionsense.dtsi6
-rw-r--r--zephyr/program/nissa/joxer/src/form_factor.c39
-rw-r--r--zephyr/program/nissa/uldren/motionsense.dtsi8
-rw-r--r--zephyr/program/nissa/yavilla/gpio.dtsi18
-rw-r--r--zephyr/program/nissa/yavilla/motionsense.dtsi148
-rw-r--r--zephyr/program/nissa/yavilla/overlay.dtsi34
-rw-r--r--zephyr/program/nissa/yavilla/project.conf16
-rw-r--r--zephyr/program/nissa/yavilla/project.overlay1
-rw-r--r--zephyr/program/nissa/yavilla/src/board.c36
-rw-r--r--zephyr/program/skyrim/winterhold/project.conf1
24 files changed, 549 insertions, 52 deletions
diff --git a/zephyr/program/corsola/include/variant_db_detection.h b/zephyr/program/corsola/include/variant_db_detection.h
index e98ba3067d..fb468126ef 100644
--- a/zephyr/program/corsola/include/variant_db_detection.h
+++ b/zephyr/program/corsola/include/variant_db_detection.h
@@ -8,27 +8,32 @@
#ifndef __CROS_EC_CORSOLA_DB_DETECTION_H
#define __CROS_EC_CORSOLA_DB_DETECTION_H
+#include <stdint.h>
+
enum corsola_db_type {
CORSOLA_DB_UNINIT = -1,
+ /* CORSOLA_DB_NO_DETECTION means there is no detection involved in. */
+ CORSOLA_DB_NO_DETECTION,
+ /* CORSOLA_DB_NONE means there is no DB in the design. */
CORSOLA_DB_NONE,
CORSOLA_DB_TYPEC,
CORSOLA_DB_HDMI,
CORSOLA_DB_COUNT,
};
-#ifdef CONFIG_VARIANT_CORSOLA_DB_DETECTION
/*
* Get the connected daughterboard type.
*
* @return The daughterboard type.
*/
+#ifdef CONFIG_VARIANT_CORSOLA_DB_DETECTION
enum corsola_db_type corsola_get_db_type(void);
-#else
+#elif !defined(CONFIG_TEST)
inline enum corsola_db_type corsola_get_db_type(void)
{
- return CORSOLA_DB_NONE;
-};
-#endif /* CONFIG_VARIANT_CORSOLA_DB_DETECTION */
+ return CORSOLA_DB_NO_DETECTION;
+}
+#endif
/* return the adjusted port count for board overridden usbc/charger functions.
*/
diff --git a/zephyr/program/corsola/npcx_adc.dtsi b/zephyr/program/corsola/npcx_adc.dtsi
index 7b69abe48a..cd6a9c1bef 100644
--- a/zephyr/program/corsola/npcx_adc.dtsi
+++ b/zephyr/program/corsola/npcx_adc.dtsi
@@ -7,6 +7,7 @@
* Kingler and Steelix use the same dts, take care of this when modify it.
*/
+
/ {
named-adc-channels {
compatible = "named-adc-channels";
diff --git a/zephyr/program/corsola/src/npcx_usbc.c b/zephyr/program/corsola/src/npcx_usbc.c
index 2e1d8d11c5..8e9cd09e55 100644
--- a/zephyr/program/corsola/src/npcx_usbc.c
+++ b/zephyr/program/corsola/src/npcx_usbc.c
@@ -179,9 +179,13 @@ int board_vbus_source_enabled(int port)
#if CONFIG_USB_PD_PORT_MAX_COUNT > 1
__override int board_rt1718s_set_snk_enable(int port, int enable)
{
- if (port == USBC_PORT_C1) {
- rt1718s_gpio_set_level(port, GPIO_EN_USB_C1_SINK, enable);
- }
+ rt1718s_gpio_set_level(port, GPIO_EN_USB_C1_SINK, enable);
+
+ return EC_SUCCESS;
+}
+__override int board_rt1718s_set_src_enable(int port, int enable)
+{
+ rt1718s_gpio_set_level(port, GPIO_EN_USB_C1_SOURCE, enable);
return EC_SUCCESS;
}
diff --git a/zephyr/program/corsola/src/usb_pd_policy.c b/zephyr/program/corsola/src/usb_pd_policy.c
index 30ded99aba..4b7e46cb74 100644
--- a/zephyr/program/corsola/src/usb_pd_policy.c
+++ b/zephyr/program/corsola/src/usb_pd_policy.c
@@ -229,12 +229,6 @@ void pd_power_supply_reset(int port)
prev_en = ppc_is_sourcing_vbus(port);
-#if defined(CONFIG_USB_PD_TCPM_RT1718S) && CONFIG_USB_PD_PORT_MAX_COUNT > 1
- if (port == USBC_PORT_C1) {
- rt1718s_gpio_set_level(port, GPIO_EN_USB_C1_SOURCE, 0);
- }
-#endif
-
/* Disable VBUS. */
ppc_vbus_source_enable(port, 0);
@@ -254,13 +248,6 @@ int pd_set_power_supply_ready(int port)
pd_set_vbus_discharge(port, 0);
-#if defined(CONFIG_USB_PD_TCPM_RT1718S) && CONFIG_USB_PD_PORT_MAX_COUNT > 1
- /* Provide Vbus. */
- if (port == USBC_PORT_C1) {
- rt1718s_gpio_set_level(port, GPIO_EN_USB_C1_SOURCE, 1);
- }
-#endif
-
RETURN_ERROR(ppc_vbus_source_enable(port, 1));
/* Notify host of power info change. */
diff --git a/zephyr/program/corsola/src/usbc.c b/zephyr/program/corsola/src/usbc.c
index 71c02ff54f..871c84a2e4 100644
--- a/zephyr/program/corsola/src/usbc.c
+++ b/zephyr/program/corsola/src/usbc.c
@@ -45,7 +45,7 @@ DECLARE_HOOK(HOOK_INIT, baseboard_init, HOOK_PRIO_PRE_DEFAULT);
__override uint8_t board_get_usb_pd_port_count(void)
{
- /* This function returns the PORT_COUNT+1 when HDMI db is connected.
+ /* This function returns the PORT_COUNT when HDMI db is connected.
* This is a trick to ensure the usb_mux_set being set properley.
* HDMI display functions using the USB virtual mux to * communicate
* with the DP bridge.
@@ -56,6 +56,8 @@ __override uint8_t board_get_usb_pd_port_count(void)
} else {
return CONFIG_USB_PD_PORT_MAX_COUNT - 1;
}
+ } else if (corsola_get_db_type() == CORSOLA_DB_NONE) {
+ return CONFIG_USB_PD_PORT_MAX_COUNT - 1;
}
return CONFIG_USB_PD_PORT_MAX_COUNT;
@@ -65,7 +67,7 @@ uint8_t board_get_adjusted_usb_pd_port_count(void)
{
const enum corsola_db_type db = corsola_get_db_type();
- if (db == CORSOLA_DB_TYPEC || db == CORSOLA_DB_NONE) {
+ if (db == CORSOLA_DB_TYPEC || db == CORSOLA_DB_NO_DETECTION) {
return CONFIG_USB_PD_PORT_MAX_COUNT;
} else {
return CONFIG_USB_PD_PORT_MAX_COUNT - 1;
diff --git a/zephyr/program/corsola/starmie/CMakeLists.txt b/zephyr/program/corsola/starmie/CMakeLists.txt
index f401c5dd43..dd669ab82c 100644
--- a/zephyr/program/corsola/starmie/CMakeLists.txt
+++ b/zephyr/program/corsola/starmie/CMakeLists.txt
@@ -9,4 +9,7 @@ zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_I2C "../src/ite_i2c.c")
zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_USBC
"../src/ite_usb_pd_policy.c" "../src/ite_usbc.c")
-zephyr_library_sources("src/ppc.c") \ No newline at end of file
+zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_DETACHABLE_BASE
+ "src/base_detect.c")
+
+zephyr_library_sources("src/ppc.c")
diff --git a/zephyr/program/corsola/starmie/project.conf b/zephyr/program/corsola/starmie/project.conf
index 70bd94520f..72d18b8e9f 100644
--- a/zephyr/program/corsola/starmie/project.conf
+++ b/zephyr/program/corsola/starmie/project.conf
@@ -40,3 +40,7 @@ CONFIG_PLATFORM_EC_BODY_DETECTION=y
CONFIG_PLATFORM_EC_BODY_DETECTION_ALWAYS_ENABLE_IN_S0=y
CONFIG_PLATFORM_EC_GESTURE_DETECTION=y
CONFIG_PLATFORM_EC_GESTURE_HOST_DETECTION=y
+
+# Detachable
+CONFIG_PLATFORM_EC_DETACHABLE_BASE=y
+CONFIG_PLATFORM_EC_BASE_ATTACHED_SWITCH=y
diff --git a/zephyr/program/corsola/starmie/project.overlay b/zephyr/program/corsola/starmie/project.overlay
index 2358026e2d..de79d92cdb 100644
--- a/zephyr/program/corsola/starmie/project.overlay
+++ b/zephyr/program/corsola/starmie/project.overlay
@@ -43,6 +43,11 @@
handler = "power_signal_interrupt";
};
+ pogo_prsnt_int: pogo-prsnt-int {
+ irq-pin = <&pogo_prsnt_int_l>;
+ flags = <GPIO_INT_EDGE_BOTH>;
+ handler = "base_detect_interrupt";
+ };
/delete-node/ lid_imu;
};
@@ -71,8 +76,8 @@
};
// POGO_PRSNT_INT_L GPI5
- pogo_prsnt_int_l: pogo_prsnt_int_l{
- gpios = <&gpioi 5 GPIO_INPUT_PULL_DOWN>;
+ pogo_prsnt_int_l: pogo_prsnt_int_l {
+ gpios = <&gpioi 5 (GPIO_INPUT | GPIO_ACTIVE_LOW)>;
};
pg_pp4200_s5_od: pg-pp4200-s5-od {
@@ -131,8 +136,8 @@
motionsense-rotation-ref {
compatible = "cros-ec,motionsense-rotation-ref";
lid_rot_ref_bmi: lid-rotation-ref-bmi {
- mat33 = <1 0 0
- 0 1 0
+ mat33 = <(-1) 0 0
+ 0 (-1) 0
0 0 1>;
};
};
@@ -217,6 +222,39 @@
power-gpio-pin = <&pmic_ec_resetb>;
};
};
+
+ named-adc-channels {
+ adc_temp_sensor_1: adc-temp-sensor-1 {
+ enum-name = "ADC_TEMP_SENSOR_1";
+ io-channels = <&adc0 6>;
+ };
+ adc_temp_sensor_2: adc-temp-sensor-2 {
+ enum-name = "ADC_TEMP_SENSOR_2";
+ io-channels = <&adc0 7>;
+ };
+ };
+
+ temp_sensor_1_thermistor: sensor-1-thermistor {
+ compatible = "cros-ec,temp-sensor-thermistor";
+ thermistor = <&thermistor_1V8_100K_100K_4250B>;
+ adc = <&adc_temp_sensor_1>;
+ };
+
+ temp_sensor_2_thermistor: sensor-2-thermistor {
+ compatible = "cros-ec,temp-sensor-thermistor";
+ thermistor = <&thermistor_1V8_100K_100K_4250B>;
+ adc = <&adc_temp_sensor_2>;
+ };
+
+ named-temp-sensors {
+ compatible = "cros-ec,temp-sensors";
+ temp_sensor_1 {
+ sensor = <&temp_sensor_1_thermistor>;
+ };
+ temp_sensor_2 {
+ sensor = <&temp_sensor_2_thermistor>;
+ };
+ };
};
&i2c0{
@@ -231,3 +269,13 @@
reg = <0x10>;
};
};
+
+&adc0{
+ status = "okay";
+ pinctrl-0 = <&adc0_ch6_gpi6_default>;
+ pinctrl-names = "default";
+};
+
+&thermistor_1V8_100K_100K_4250B{
+ status = "okay";
+};
diff --git a/zephyr/program/corsola/starmie/src/base_detect.c b/zephyr/program/corsola/starmie/src/base_detect.c
new file mode 100644
index 0000000000..144b26e3be
--- /dev/null
+++ b/zephyr/program/corsola/starmie/src/base_detect.c
@@ -0,0 +1,151 @@
+/* Copyright 2023 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "ap_power/ap_power.h"
+#include "base_state.h"
+#include "chipset.h"
+#include "console.h"
+#include "gpio/gpio_int.h"
+#include "hooks.h"
+#include "host_command.h"
+#include "tablet_mode.h"
+
+#include <zephyr/drivers/gpio.h>
+#include <zephyr/kernel.h>
+
+#define CPRINTS(format, args...) cprints(CC_SYSTEM, format, ##args)
+#define CPRINTF(format, args...) cprintf(CC_SYSTEM, format, ##args)
+
+/* Base detection debouncing */
+#define BASE_DETECT_EN_DEBOUNCE_US (350 * MSEC)
+#define BASE_DETECT_DIS_DEBOUNCE_US (20 * MSEC)
+
+K_MUTEX_DEFINE(modify_base_detection_mutex);
+static bool detect_base_enabled;
+
+static void base_detect_deferred(void);
+DECLARE_DEFERRED(base_detect_deferred);
+
+enum base_status {
+ BASE_UNKNOWN = 0,
+ BASE_DISCONNECTED = 1,
+ BASE_CONNECTED = 2,
+};
+
+static enum base_status current_base_status;
+
+static void base_update(enum base_status specified_status)
+{
+ int connected = (specified_status != BASE_CONNECTED) ? false : true;
+
+ if (current_base_status == specified_status)
+ return;
+
+ current_base_status = specified_status;
+
+ base_set_state(connected);
+ tablet_set_mode(!connected, TABLET_TRIGGER_BASE);
+ gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(en_pp3300_base_x), connected);
+}
+
+void base_detect_interrupt(enum gpio_signal signal)
+{
+ gpio_disable_dt_interrupt(GPIO_INT_FROM_NODELABEL(pogo_prsnt_int));
+ hook_call_deferred(&base_detect_deferred_data,
+ (current_base_status == BASE_CONNECTED) ?
+ BASE_DETECT_DIS_DEBOUNCE_US :
+ BASE_DETECT_EN_DEBOUNCE_US);
+}
+
+static inline void detect_and_update_base_status(void)
+{
+ if (gpio_pin_get_dt(GPIO_DT_FROM_NODELABEL(pogo_prsnt_int_l))) {
+ base_update(BASE_CONNECTED);
+ } else {
+ base_update(BASE_DISCONNECTED);
+ }
+}
+
+static void base_detect_deferred(void)
+{
+ k_mutex_lock(&modify_base_detection_mutex, K_FOREVER);
+ /*
+ * If a disable base detection is issued after an ISR, and is before
+ * executing the deferred hook, then we need to check whether the
+ * detection is enabled. If disabled, there is no need to re-enable the
+ * interrupt.
+ */
+ if (detect_base_enabled) {
+ detect_and_update_base_status();
+ gpio_enable_dt_interrupt(
+ GPIO_INT_FROM_NODELABEL(pogo_prsnt_int));
+ }
+ k_mutex_unlock(&modify_base_detection_mutex);
+}
+
+static void base_detect_enable(bool enable)
+{
+ detect_base_enabled = enable;
+ if (enable) {
+ gpio_enable_dt_interrupt(
+ GPIO_INT_FROM_NODELABEL(pogo_prsnt_int));
+ detect_and_update_base_status();
+ } else {
+ gpio_disable_dt_interrupt(
+ GPIO_INT_FROM_NODELABEL(pogo_prsnt_int));
+ base_update(BASE_UNKNOWN);
+ }
+}
+
+static void base_startup_hook(struct ap_power_ev_callback *cb,
+ struct ap_power_ev_data data)
+{
+ switch (data.event) {
+ case AP_POWER_STARTUP:
+ base_detect_enable(true);
+ break;
+ case AP_POWER_SHUTDOWN:
+ base_detect_enable(false);
+ break;
+ default:
+ return;
+ }
+}
+
+static int base_init(void)
+{
+ static struct ap_power_ev_callback cb;
+
+ detect_base_enabled = false;
+ ap_power_ev_init_callback(&cb, base_startup_hook,
+ AP_POWER_STARTUP | AP_POWER_SHUTDOWN);
+ ap_power_ev_add_callback(&cb);
+
+ if (!chipset_in_state(CHIPSET_STATE_ANY_OFF)) {
+ base_detect_enable(true);
+ }
+
+ return 0;
+}
+SYS_INIT(base_init, APPLICATION, 1);
+
+void base_force_state(enum ec_set_base_state_cmd state)
+{
+ k_mutex_lock(&modify_base_detection_mutex, K_FOREVER);
+ switch (state) {
+ case EC_SET_BASE_STATE_ATTACH:
+ base_detect_enable(false);
+ base_update(BASE_CONNECTED);
+ break;
+ case EC_SET_BASE_STATE_DETACH:
+ base_detect_enable(false);
+ base_update(BASE_DISCONNECTED);
+ break;
+ case EC_SET_BASE_STATE_RESET:
+ base_detect_enable(true);
+ break;
+ }
+ k_mutex_unlock(&modify_base_detection_mutex);
+}
diff --git a/zephyr/program/corsola/starmie/src/ppc.c b/zephyr/program/corsola/starmie/src/ppc.c
index 8c1dc2fe7f..505da06473 100644
--- a/zephyr/program/corsola/starmie/src/ppc.c
+++ b/zephyr/program/corsola/starmie/src/ppc.c
@@ -27,3 +27,11 @@ void ppc_interrupt(enum gpio_signal signal)
ppc_chips[0].drv->interrupt(0);
}
}
+
+static int set_rt1739(void)
+{
+ rt1739_init(0);
+ return 0;
+}
+
+SYS_INIT(set_rt1739, POST_KERNEL, 61);
diff --git a/zephyr/program/corsola/voltorb/project.conf b/zephyr/program/corsola/voltorb/project.conf
index d2693d0de8..19348b04cd 100644
--- a/zephyr/program/corsola/voltorb/project.conf
+++ b/zephyr/program/corsola/voltorb/project.conf
@@ -42,6 +42,7 @@ CONFIG_PLATFORM_EC_EXTPOWER_DEBOUNCE_MS=800
# Battery config
CONFIG_PLATFORM_EC_BATT_FULL_CHIPSET_OFF_INPUT_LIMIT_MV=15000
CONFIG_PLATFORM_EC_SMART_BATTERY_OPTIONAL_MFG_FUNC=y
+CONFIG_PLATFORM_EC_BATTERY_STBL_STAT=y
# Remove debug options and features for FW QUAL
CONFIG_PLATFORM_EC_SYSTEM_UNLOCKED=n
diff --git a/zephyr/program/nissa/CMakeLists.txt b/zephyr/program/nissa/CMakeLists.txt
index cd45f00a3a..88e2d1c8a4 100644
--- a/zephyr/program/nissa/CMakeLists.txt
+++ b/zephyr/program/nissa/CMakeLists.txt
@@ -71,6 +71,7 @@ if(DEFINED CONFIG_BOARD_JOXER)
zephyr_library_sources(
"joxer/src/led.c"
"joxer/src/keyboard.c"
+ "joxer/src/form_factor.c"
)
zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_USBC "joxer/src/usbc.c")
zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_CHARGER "joxer/src/charger.c")
diff --git a/zephyr/program/nissa/craask/src/led.c b/zephyr/program/nissa/craask/src/led.c
index 0af0202cf4..b3aefa3ab2 100644
--- a/zephyr/program/nissa/craask/src/led.c
+++ b/zephyr/program/nissa/craask/src/led.c
@@ -22,7 +22,7 @@ __override struct led_descriptor
LED_INDEFINITE } },
[STATE_DISCHARGE_S0] = { { EC_LED_COLOR_BLUE,
LED_INDEFINITE } },
- [STATE_DISCHARGE_S0_BAT_LOW] = { { EC_LED_COLOR_AMBER,
+ [STATE_DISCHARGE_S0_BAT_LOW] = { { EC_LED_COLOR_BLUE,
LED_INDEFINITE } },
[STATE_DISCHARGE_S3] = { { EC_LED_COLOR_AMBER,
1 * LED_ONE_SEC },
diff --git a/zephyr/program/nissa/joxer/cbi.dtsi b/zephyr/program/nissa/joxer/cbi.dtsi
index afbd125b32..71424ed681 100644
--- a/zephyr/program/nissa/joxer/cbi.dtsi
+++ b/zephyr/program/nissa/joxer/cbi.dtsi
@@ -28,5 +28,26 @@
value = <1>;
};
};
+
+ /*
+ * FW_CONFIG field to describe lid accelerometer orientation.
+ */
+ lid-inversion {
+ enum-name = "FW_LID_INVERSION";
+ start = <5>;
+ size = <1>;
+
+ default {
+ compatible = "cros-ec,cbi-fw-config-value";
+ enum-name = "SENSOR_DEFAULT";
+ value = <0>;
+ default;
+ };
+ inverted {
+ compatible = "cros-ec,cbi-fw-config-value";
+ enum-name = "SENSOR_INVERTED";
+ value = <1>;
+ };
+ };
};
};
diff --git a/zephyr/program/nissa/joxer/motionsense.dtsi b/zephyr/program/nissa/joxer/motionsense.dtsi
index e9c46a849a..fbac470660 100644
--- a/zephyr/program/nissa/joxer/motionsense.dtsi
+++ b/zephyr/program/nissa/joxer/motionsense.dtsi
@@ -40,6 +40,12 @@
0 0 (-1)>;
};
+ lid_rot_inverted: lid-rotation-inverted {
+ mat33 = <0 1 0
+ (-1) 0 0
+ 0 0 1>;
+ };
+
base_rot_ref: base-rotation-ref {
mat33 = <1 0 0
0 1 0
diff --git a/zephyr/program/nissa/joxer/src/form_factor.c b/zephyr/program/nissa/joxer/src/form_factor.c
new file mode 100644
index 0000000000..1087d7ddca
--- /dev/null
+++ b/zephyr/program/nissa/joxer/src/form_factor.c
@@ -0,0 +1,39 @@
+/* Copyright 2023 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "accelgyro.h"
+#include "cros_cbi.h"
+#include "hooks.h"
+#include "motionsense_sensors.h"
+
+#include <zephyr/devicetree.h>
+#include <zephyr/logging/log.h>
+
+LOG_MODULE_DECLARE(nissa, CONFIG_NISSA_LOG_LEVEL);
+
+#define ALT_MAT SENSOR_ROT_STD_REF_NAME(DT_NODELABEL(lid_rot_inverted))
+#define LID_ACCEL SENSOR_ID(DT_NODELABEL(lid_accel))
+
+static void form_factor_init(void)
+{
+ int ret;
+ uint32_t val;
+ /*
+ * If the firmware config indicates
+ * an inverted 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 == SENSOR_INVERTED) {
+ LOG_INF("Switching to inverted lid");
+ motion_sensors[LID_ACCEL].rot_standard_ref = &ALT_MAT;
+ }
+}
+DECLARE_HOOK(HOOK_INIT, form_factor_init, HOOK_PRIO_POST_I2C);
diff --git a/zephyr/program/nissa/uldren/motionsense.dtsi b/zephyr/program/nissa/uldren/motionsense.dtsi
index 70b381b843..baaec61e5e 100644
--- a/zephyr/program/nissa/uldren/motionsense.dtsi
+++ b/zephyr/program/nissa/uldren/motionsense.dtsi
@@ -35,14 +35,14 @@
motionsense-rotation-ref {
compatible = "cros-ec,motionsense-rotation-ref";
lid_rot_ref: lid-rotation-ref {
- mat33 = <0 (-1) 0
+ mat33 = <0 1 0
(-1) 0 0
- 0 0 (-1)>;
+ 0 0 1>;
};
base_rot_ref: base-rotation-ref {
- mat33 = <0 1 0
- (-1) 0 0
+ mat33 = <1 0 0
+ 0 1 0
0 0 1>;
};
};
diff --git a/zephyr/program/nissa/yavilla/gpio.dtsi b/zephyr/program/nissa/yavilla/gpio.dtsi
index a18e674b11..8c76048f25 100644
--- a/zephyr/program/nissa/yavilla/gpio.dtsi
+++ b/zephyr/program/nissa/yavilla/gpio.dtsi
@@ -34,6 +34,9 @@
named-gpios {
compatible = "named-gpios";
+ gpio_acc_int_l: acc_int_l {
+ gpios = <&gpioc 0 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>;
+ };
gpio_all_sys_pwrgd: all_sys_pwrgd {
gpios = <&gpiob 7 GPIO_INPUT>;
};
@@ -134,6 +137,9 @@
gpios = <&gpioe 2 GPIO_INPUT_PULL_UP>;
enum-name = "GPIO_POWER_BUTTON_L";
};
+ gpio_imu_int_l: imu_int_l {
+ gpios = <&gpioj 0 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>;
+ };
gpio_imvp91_vrrdy_od: imvp91_vrrdy_od {
gpios = <&gpioj 4 GPIO_INPUT>;
no-auto-init;
@@ -178,6 +184,10 @@
gpios = <&gpiod 1 GPIO_ODR_HIGH>;
no-auto-init;
};
+ gpio_tablet_mode_l: tablet_mode_l {
+ gpios = <&gpioa 7 GPIO_INPUT>;
+ enum-name = "GPIO_TABLET_MODE_L";
+ };
gpio_usb_a0_ilimit_sdp: usb_a0_ilimit_sdp {
gpios = <&gpiol 5 GPIO_OUTPUT>;
enum-name = "GPIO_USB1_ILIM_SEL";
@@ -216,6 +226,14 @@
gpios = <&gpioksol 2 GPIO_OUTPUT_HIGH>;
enum-name = "GPIO_KBD_KSO2";
};
+ gpio_voldn_btn_odl: voldn_btn_odl {
+ gpios = <&gpioi 6 GPIO_INPUT_PULL_UP>;
+ enum-name = "GPIO_VOLUME_DOWN_L";
+ };
+ gpio_volup_btn_odl: volup_btn_odl {
+ gpios = <&gpioi 7 GPIO_INPUT_PULL_UP>;
+ enum-name = "GPIO_VOLUME_UP_L";
+ };
};
named-i2c-ports {
diff --git a/zephyr/program/nissa/yavilla/motionsense.dtsi b/zephyr/program/nissa/yavilla/motionsense.dtsi
new file mode 100644
index 0000000000..df84c36471
--- /dev/null
+++ b/zephyr/program/nissa/yavilla/motionsense.dtsi
@@ -0,0 +1,148 @@
+/* Copyright 2023 The ChromiumOS Authors
+ * 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 {
+ /*
+ * Interrupt bindings for sensor devices.
+ */
+ bmi3xx-int = &base_accel;
+ bma4xx-int = &lid_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 {
+ };
+
+ base_mutex: base-mutex {
+ };
+ };
+
+ /* Rotation matrix used by drivers. */
+ motionsense-rotation-ref {
+ compatible = "cros-ec,motionsense-rotation-ref";
+ lid_rot_ref: lid-rotation-ref {
+ mat33 = <1 0 0
+ 0 (-1) 0
+ 0 0 (-1)>;
+ };
+
+ base_rot_ref: base-rotation-ref {
+ mat33 = <0 1 0
+ 1 0 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 {
+ bmi323_data: bmi323-drv-data {
+ compatible = "cros-ec,drvdata-bmi3xx";
+ status = "okay";
+ };
+
+ bma422_data: bma4xx-drv-data {
+ compatible = "cros-ec,drvdata-bma4xx";
+ status = "okay";
+ };
+ };
+
+ /*
+ * List of motion sensors that creates motion_sensors array.
+ * The nodelabel "lid_accel" and "base_accel" are used to indicate
+ * motion sensor IDs for lid angle calculation.
+ * TODO(b/238139272): The first entries of the array must be
+ * accelerometers,then gyroscope. Fix this dependency in the DTS
+ * processing which makes the devicetree entries independent.
+ */
+ motionsense-sensor {
+ lid_accel: lid-accel {
+ compatible = "cros-ec,bma4xx";
+ status = "okay";
+
+ active-mask = "SENSOR_ACTIVE_S0_S3";
+ location = "MOTIONSENSE_LOC_LID";
+ mutex = <&lid_mutex>;
+ port = <&i2c_ec_i2c_sensor>;
+ rot-standard-ref = <&lid_rot_ref>;
+ default-range = <2>;
+ drv-data = <&bma422_data>;
+ i2c-spi-addr-flags = "BMA4_I2C_ADDR_PRIMARY";
+ configs {
+ compatible =
+ "cros-ec,motionsense-sensor-config";
+ ec-s0 {
+ odr = <(10000 | ROUND_UP_FLAG)>;
+ };
+ ec-s3 {
+ odr = <(10000 | ROUND_UP_FLAG)>;
+ };
+ };
+ };
+
+ base_accel: base-accel {
+ compatible = "cros-ec,bmi3xx-accel";
+ status = "okay";
+
+ active-mask = "SENSOR_ACTIVE_S0_S3";
+ location = "MOTIONSENSE_LOC_BASE";
+ mutex = <&base_mutex>;
+ port = <&i2c_ec_i2c_sensor>;
+ rot-standard-ref = <&base_rot_ref>;
+ drv-data = <&bmi323_data>;
+ configs {
+ compatible =
+ "cros-ec,motionsense-sensor-config";
+ ec-s0 {
+ odr = <(10000 | ROUND_UP_FLAG)>;
+ };
+ ec-s3 {
+ odr = <(10000 | ROUND_UP_FLAG)>;
+ };
+ };
+ };
+
+ base_gyro: base-gyro {
+ compatible = "cros-ec,bmi3xx-gyro";
+ status = "okay";
+
+ active-mask = "SENSOR_ACTIVE_S0_S3";
+ location = "MOTIONSENSE_LOC_BASE";
+ mutex = <&base_mutex>;
+ port = <&i2c_ec_i2c_sensor>;
+ rot-standard-ref = <&base_rot_ref>;
+ drv-data = <&bmi323_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_imu &int_acc>;
+ };
+};
diff --git a/zephyr/program/nissa/yavilla/overlay.dtsi b/zephyr/program/nissa/yavilla/overlay.dtsi
index b60ad2f476..c75ae9dd79 100644
--- a/zephyr/program/nissa/yavilla/overlay.dtsi
+++ b/zephyr/program/nissa/yavilla/overlay.dtsi
@@ -49,6 +49,16 @@
flags = <GPIO_INT_EDGE_BOTH>;
handler = "power_button_interrupt";
};
+ int_vol_down: vol_down {
+ irq-pin = <&gpio_voldn_btn_odl>;
+ flags = <GPIO_INT_EDGE_BOTH>;
+ handler = "button_interrupt";
+ };
+ int_vol_up: vol_up {
+ irq-pin = <&gpio_volup_btn_odl>;
+ flags = <GPIO_INT_EDGE_BOTH>;
+ handler = "button_interrupt";
+ };
int_wp_l: wp_l {
irq-pin = <&gpio_ec_wp_odl>;
flags = <GPIO_INT_EDGE_BOTH>;
@@ -59,6 +69,21 @@
flags = <GPIO_INT_EDGE_BOTH>;
handler = "lid_interrupt";
};
+ int_tablet_mode: tablet_mode {
+ irq-pin = <&gpio_tablet_mode_l>;
+ flags = <GPIO_INT_EDGE_BOTH>;
+ handler = "gmr_tablet_switch_isr";
+ };
+ int_acc: lid_imu {
+ irq-pin = <&gpio_acc_int_l>;
+ flags = <GPIO_INT_EDGE_FALLING>;
+ handler = "bma4xx_interrupt";
+ };
+ int_imu: ec_imu {
+ irq-pin = <&gpio_imu_int_l>;
+ flags = <GPIO_INT_EDGE_FALLING>;
+ handler = "bmi3xx_interrupt";
+ };
int_usb_c0: usb_c0 {
irq-pin = <&gpio_usb_c0_int_odl>;
flags = <GPIO_INT_EDGE_FALLING>;
@@ -73,14 +98,9 @@
unused-pins {
compatible = "unused-gpios";
- unused-gpios = <&gpioa 7 0>,
- <&gpioc 0 0>,
- <&gpioc 6 0>,
+ unused-gpios = <&gpioc 6 0>,
<&gpiod 7 0>,
<&gpioh 2 0>,
- <&gpioi 6 0>,
- <&gpioi 7 0>,
- <&gpioj 0 0>,
<&gpioj 3 0>,
<&gpiok 7 GPIO_OUTPUT>;
};
@@ -292,7 +312,7 @@
&i2c2 {
label = "I2C_SENSOR";
- clock-frequency = <I2C_BITRATE_FAST>;
+ clock-frequency = <I2C_BITRATE_STANDARD>;
pinctrl-0 = <&i2c2_clk_gpf6_default
&i2c2_data_gpf7_default>;
pinctrl-names = "default";
diff --git a/zephyr/program/nissa/yavilla/project.conf b/zephyr/program/nissa/yavilla/project.conf
index 30818c4419..8011391adf 100644
--- a/zephyr/program/nissa/yavilla/project.conf
+++ b/zephyr/program/nissa/yavilla/project.conf
@@ -8,17 +8,11 @@ CONFIG_BOARD_YAVILLA=y
CONFIG_PLATFORM_EC_KEYBOARD_PWRBTN_ASSERTS_KSI3=y
CONFIG_PLATFORM_EC_KEYBOARD_REFRESH_ROW3=y
-# Sensors: disabled; yavilla is clamshell-only
-CONFIG_PLATFORM_EC_LID_ANGLE=n
-CONFIG_PLATFORM_EC_LID_ANGLE_UPDATE=n
-CONFIG_PLATFORM_EC_CONSOLE_CMD_ACCELS=n
-CONFIG_PLATFORM_EC_CONSOLE_CMD_ACCEL_INFO=n
-CONFIG_PLATFORM_EC_ACCEL_FIFO=n
-CONFIG_PLATFORM_EC_SENSOR_TIGHT_TIMESTAMPS=n
-CONFIG_PLATFORM_EC_GMR_TABLET_MODE=n
-CONFIG_PLATFORM_EC_TABLET_MODE=n
-CONFIG_PLATFORM_EC_TABLET_MODE_SWITCH=n
-CONFIG_PLATFORM_EC_VOLUME_BUTTONS=n
+# Sensors
+CONFIG_PLATFORM_EC_ACCELGYRO_BMI_COMM_I2C=y
+CONFIG_PLATFORM_EC_ACCELGYRO_BMI3XX=y
+CONFIG_PLATFORM_EC_ACCEL_BMA4XX=y
+CONFIG_PLATFORM_EC_DYNAMIC_MOTION_SENSOR_COUNT=y
CONFIG_PLATFORM_EC_MAX_SENSOR_FREQ_MILLIHZ=100000
# Keyboard
diff --git a/zephyr/program/nissa/yavilla/project.overlay b/zephyr/program/nissa/yavilla/project.overlay
index 97f431022c..40bbaec4bb 100644
--- a/zephyr/program/nissa/yavilla/project.overlay
+++ b/zephyr/program/nissa/yavilla/project.overlay
@@ -9,5 +9,6 @@
#include "fan.dtsi"
#include "gpio.dtsi"
#include "keyboard.dtsi"
+#include "motionsense.dtsi"
#include "overlay.dtsi"
#include "power_signals.dtsi"
diff --git a/zephyr/program/nissa/yavilla/src/board.c b/zephyr/program/nissa/yavilla/src/board.c
index f89b92ebd8..feee5fa91f 100644
--- a/zephyr/program/nissa/yavilla/src/board.c
+++ b/zephyr/program/nissa/yavilla/src/board.c
@@ -3,14 +3,19 @@
* found in the LICENSE file.
*/
/* yavilla hardware configuration */
+#include "cros_cbi.h"
#include "gpio/gpio_int.h"
#include "hooks.h"
+#include "motion_sense.h"
+#include "tablet_mode.h"
#include "task.h"
+#include <zephyr/devicetree.h>
#include <zephyr/drivers/gpio.h>
#include <zephyr/drivers/pinctrl.h>
#include <zephyr/init.h>
#include <zephyr/kernel.h>
+#include <zephyr/logging/log.h>
#include <zephyr/sys/printk.h>
LOG_MODULE_DECLARE(nissa, CONFIG_NISSA_LOG_LEVEL);
__override uint8_t board_get_usb_pd_port_count(void)
@@ -22,10 +27,39 @@ __override uint8_t board_get_usb_pd_port_count(void)
*/
static void board_init(void)
{
+ int ret;
+ uint32_t val;
+
+ /*
+ * Retrieve the tablet config.
+ */
+ ret = cros_cbi_get_fw_config(FW_TABLET, &val);
+ if (ret != 0) {
+ LOG_ERR("Error retrieving CBI FW_CONFIG field %d", FW_TABLET);
+ return;
+ }
+
/*
* Enable USB-C interrupts.
*/
gpio_enable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_usb_c0));
gpio_enable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_usb_c1));
+
+ /*
+ * Disable tablet related interrupts for tablet absent DUT.
+ */
+ if (val == FW_TABLET_ABSENT) {
+ motion_sensor_count = 0;
+ gmr_tablet_switch_disable();
+ gpio_disable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_imu));
+ /* Base accel is not stuffed, don't allow line to float */
+ gpio_pin_configure_dt(GPIO_DT_FROM_NODELABEL(gpio_imu_int_l),
+ GPIO_INPUT | GPIO_PULL_DOWN);
+ /* Lid accel is not stuffed, don't allow line to float */
+ gpio_pin_configure_dt(GPIO_DT_FROM_NODELABEL(gpio_acc_int_l),
+ GPIO_INPUT | GPIO_PULL_DOWN);
+ LOG_INF("Clameshell: Disable motion sensors and gmr sensor!");
+ } else
+ LOG_INF("Convertible!!!");
}
-DECLARE_HOOK(HOOK_INIT, board_init, HOOK_PRIO_DEFAULT);
+DECLARE_HOOK(HOOK_INIT, board_init, HOOK_PRIO_POST_I2C);
diff --git a/zephyr/program/skyrim/winterhold/project.conf b/zephyr/program/skyrim/winterhold/project.conf
index 3521417c68..ef336a4667 100644
--- a/zephyr/program/skyrim/winterhold/project.conf
+++ b/zephyr/program/skyrim/winterhold/project.conf
@@ -16,6 +16,7 @@ CONFIG_PLATFORM_EC_CHARGER_RUNTIME_CONFIG=y
CONFIG_PLATFORM_EC_CHARGER_ISL9238C=y
CONFIG_PLATFORM_EC_ISL9238C_ENABLE_BUCK_MODE=y
CONFIG_PLATFORM_EC_CHARGER_PROFILE_OVERRIDE=y
+CONFIG_PLATFORM_EC_CHARGER_MAINTAIN_VBAT=y
# Forward Buck Phase Comparator bit<15:13> to 100=-2mV
CONFIG_PLATFORM_EC_ISL9238C_BUCK_PHASE_VOLTAGE=6