summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/battery.h7
-rw-r--r--include/charge_state.h232
-rw-r--r--include/charge_state_v1.h69
-rw-r--r--include/charge_state_v2.h228
-rw-r--r--include/charger.h13
-rw-r--r--include/charger_base.h64
-rw-r--r--include/charger_profile_override.h2
-rw-r--r--include/config.h32
-rw-r--r--include/hooks.h2
-rw-r--r--include/keyboard_8042.h25
-rw-r--r--include/power.h11
-rw-r--r--include/system_safe_mode.h7
-rw-r--r--include/usb_pd.h6
13 files changed, 363 insertions, 335 deletions
diff --git a/include/battery.h b/include/battery.h
index 0daa6205a7..23d9352643 100644
--- a/include/battery.h
+++ b/include/battery.h
@@ -25,13 +25,6 @@
/* Stop charge when charging and battery level >= this percentage */
#define BATTERY_LEVEL_FULL 100
-/* Tell host we're charged when battery level >= this percentage */
-#ifdef CONFIG_BATTERY_LEVEL_NEAR_FULL
-#define BATTERY_LEVEL_NEAR_FULL CONFIG_BATTERY_LEVEL_NEAR_FULL
-#else
-#define BATTERY_LEVEL_NEAR_FULL 97
-#endif
-
/*
* Send battery-low host event when discharging and battery level <= this level
*/
diff --git a/include/charge_state.h b/include/charge_state.h
index dcf3430954..34576dc333 100644
--- a/include/charge_state.h
+++ b/include/charge_state.h
@@ -5,7 +5,13 @@
#ifndef __CROS_EC_CHARGE_STATE_H
#define __CROS_EC_CHARGE_STATE_H
+#include "battery.h"
+#include "battery_smart.h"
+#include "charger.h"
+#include "chipset.h"
#include "common.h"
+#include "ec_ec_comm_client.h"
+#include "ocpc.h"
#include "stdbool.h"
#include "timer.h"
@@ -26,7 +32,7 @@
#endif
/* Power states */
-enum charge_state {
+enum led_pwr_state {
/* Meta-state; unchanged from previous time through task loop */
PWR_STATE_UNCHANGE = 0,
/* Initializing charge state machine at boot */
@@ -61,7 +67,7 @@ enum charge_state {
/* Battery is responsive */
#define CHARGE_FLAG_BATT_RESPONSIVE BIT(2)
-/* Debugging constants, in the same order as enum charge_state. This string
+/* Debugging constants, in the same order as enum pwr_state. This string
* table was moved here to sync with enum above.
*/
#define CHARGE_STATE_NAME_TABLE \
@@ -72,10 +78,50 @@ enum charge_state {
}
/* End of CHARGE_STATE_NAME_TABLE macro */
+/*
+ * The values exported by charge_get_state() and charge_get_flags() are used
+ * only to control the LEDs (with one not-quite-correct exception). For V2
+ * we use a different set of states internally.
+ */
+enum charge_state_v2 {
+ ST_IDLE = 0,
+ ST_DISCHARGE,
+ ST_CHARGE,
+ ST_PRECHARGE,
+
+ NUM_STATES_V2
+};
+
+struct charge_state_data {
+ timestamp_t ts;
+ int ac;
+ int batt_is_charging;
+ struct charger_params chg;
+ struct batt_params batt;
+ enum charge_state_v2 state;
+ int requested_voltage;
+ int requested_current;
+ int desired_input_current;
+#ifdef CONFIG_CHARGER_OTG
+ int output_current;
+#endif
+#ifdef CONFIG_EC_EC_COMM_BATTERY_CLIENT
+ int input_voltage;
+#endif
+#ifdef CONFIG_OCPC
+ struct ocpc_data ocpc;
+#endif
+};
+
+struct sustain_soc {
+ int8_t lower;
+ int8_t upper;
+};
+
/**
* Return current charge state.
*/
-enum charge_state charge_get_state(void);
+enum led_pwr_state led_pwr_get_state(void);
/**
* Return current charge v2 state.
@@ -191,7 +237,185 @@ int charge_get_battery_temp(int idx, int *temp_ptr);
*/
const struct batt_params *charger_current_battery_params(void);
+/**
+ * Set the output current limit and voltage. This is used to provide power from
+ * the charger chip ("OTG" mode).
+ *
+ * @param chgnum Charger index to act upon
+ * @param ma Maximum current to provide in mA (0 to disable output).
+ * @param mv Voltage in mV (ignored if ma == 0).
+ * @return EC_SUCCESS or error
+ */
+int charge_set_output_current_limit(int chgnum, int ma, int mv);
+
+/**
+ * Set the charge input current limit. This value is stored and sent every
+ * time AC is applied.
+ *
+ * The input current limit is automatically derated by
+ * CONFIG_CHARGER_INPUT_CURRENT_DERATE_PCT (if configured), and is clamped to
+ * no less than CONFIG_CHARGER_MIN_INPUT_CURRENT_LIMIT mA (if configured).
+ *
+ * @param ma New input current limit in mA
+ * @param mv Negotiated charge voltage in mV.
+ * @return EC_SUCCESS or error
+ */
+int charge_set_input_current_limit(int ma, int mv);
+
+/**
+ * Set the desired manual charge current when in idle mode.
+ *
+ * @param curr_ma: Charge current in mA.
+ */
+void chgstate_set_manual_current(int curr_ma);
+
+/**
+ * Set the desired manual charge voltage when in idle mode.
+ *
+ * @param volt_mv: Charge voltage in mV.
+ */
+void chgstate_set_manual_voltage(int volt_mv);
+
+/**
+ * Board-specific routine to indicate if the base is connected.
+ */
+int board_is_base_connected(void);
+
+/**
+ * Board-specific routine to enable power distribution between lid and base
+ * (current can flow both ways).
+ */
+void board_enable_base_power(int enable);
+
+/**
+ * Board-specific routine to reset the base (in case it is unresponsive, e.g.
+ * if we told it to hibernate).
+ */
+void board_base_reset(void);
+
+/**
+ * Callback with which boards determine action on critical low battery
+ *
+ * The default implementation is provided in charge_state_v2.c. Overwrite it
+ * to customize it.
+ *
+ * @param curr Pointer to struct charge_state_data
+ * @return Action to take.
+ */
+enum critical_shutdown
+board_critical_shutdown_check(struct charge_state_data *curr);
+
+/**
+ * Callback to set battery level for shutdown
+ *
+ * A board can implement this to customize shutdown battery level at runtime.
+ *
+ * @return battery level for shutdown
+ */
+uint8_t board_set_battery_level_shutdown(void);
+
+/**
+ * Return system PLT power and battery's desired power.
+ *
+ * @return desired power in mW
+ */
+int charge_get_plt_plus_bat_desired_mw(void);
+
+/**
+ * Get the stable battery charging current. The current will be
+ * CHARGE_CURRENT_UNINITIALIZED if not yet stable.
+ *
+ * @return stable battery charging current in mA
+ */
+int charge_get_stable_current(void);
+
+/**
+ * Select which charger IC will actually be performing the charger switching.
+ *
+ * @param idx The index into the chg_chips table.
+ */
+void charge_set_active_chg_chip(int idx);
+
+/**
+ * Retrieve which charger IC is the active charger IC performing the charger
+ * switching.
+ */
+int charge_get_active_chg_chip(void);
+
+/**
+ * Set the stable current.
+ *
+ * @param ma: battery charging current in mA
+ */
+void charge_set_stable_current(int ma);
+
+/**
+ * Reset stable current counter stable_ts. Calling this function would set
+ * stable_current to CHARGE_CURRENT_UNINITIALIZED.
+ */
+void charge_reset_stable_current(void);
+
+/**
+ * Reset stable current counter stable_ts. Calling this function would set
+ * stable_current to CHARGE_CURRENT_UNINITIALIZED.
+ *
+ * @param us: sample stable current until us later.
+ */
+void charge_reset_stable_current_us(uint64_t us);
+
+/**
+ * Check if the battery charging current is stable by examining the timestamp.
+ *
+ * @return true if stable timestamp expired, false otherwise.
+ */
+bool charge_is_current_stable(void);
+
+/**
+ * Reset the OCPC internal state data and set the target VSYS to the current
+ * battery voltage for the auxiliary chargers.
+ */
+void trigger_ocpc_reset(void);
+
+/* Track problems in communicating with the battery or charger */
+enum problem_type {
+ PR_STATIC_UPDATE,
+ PR_SET_VOLTAGE,
+ PR_SET_CURRENT,
+ PR_SET_MODE,
+ PR_SET_INPUT_CURR,
+ PR_POST_INIT,
+ PR_CHG_FLAGS,
+ PR_BATT_FLAGS,
+ PR_CUSTOM,
+ PR_CFG_SEC_CHG,
+
+ NUM_PROBLEM_TYPES
+};
+
+void charge_problem(enum problem_type p, int v);
+
+struct charge_state_data *charge_get_status(void);
+
+enum ec_charge_control_mode get_chg_ctrl_mode(void);
+
+__test_only void reset_prev_disp_charge(void);
+
+/**
+ * Whether or not the charging progress was shown. Note, calling this function
+ * will reset the value to false.
+ *
+ * @return Whether or not the charging progress was printed to the console
+ */
+__test_only bool charging_progress_displayed(void);
+
+/**
+ * Callback for boards to request charger to enable bypass mode on/off.
+ *
+ * @return True for requesting bypass on. False for requesting bypass off.
+ */
+int board_should_charger_bypass(void);
+
/* Config Charger */
-#include "charge_state_v2.h"
+#include "charge_state.h"
#endif /* __CROS_EC_CHARGE_STATE_H */
diff --git a/include/charge_state_v1.h b/include/charge_state_v1.h
deleted file mode 100644
index 302fc0acf8..0000000000
--- a/include/charge_state_v1.h
+++ /dev/null
@@ -1,69 +0,0 @@
-/* Copyright 2013 The ChromiumOS Authors
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include "battery.h"
-#include "timer.h"
-
-#ifndef __CROS_EC_CHARGE_STATE_V1_H
-#define __CROS_EC_CHARGE_STATE_V1_H
-
-/* Update period to prevent charger watchdog timeout */
-#define CHARGER_UPDATE_PERIOD (SECOND * 10)
-
-/* Power state error flags */
-#define F_CHARGER_INIT BIT(0) /* Charger initialization */
-#define F_CHARGER_VOLTAGE BIT(1) /* Charger maximum output voltage */
-#define F_CHARGER_CURRENT BIT(2) /* Charger maximum output current */
-#define F_BATTERY_VOLTAGE BIT(3) /* Battery voltage */
-#define F_BATTERY_MODE BIT(8) /* Battery mode */
-#define F_BATTERY_CAPACITY BIT(9) /* Battery capacity */
-#define F_BATTERY_STATE_OF_CHARGE BIT(10) /* State of charge, percentage */
-#define F_BATTERY_UNRESPONSIVE BIT(11) /* Battery not responding */
-#define F_BATTERY_NOT_CONNECTED BIT(12) /* Battery not connected */
-#define F_BATTERY_GET_PARAMS BIT(13) /* Any battery parameter bad */
-
-#define F_BATTERY_MASK \
- (F_BATTERY_VOLTAGE | F_BATTERY_MODE | F_BATTERY_CAPACITY | \
- F_BATTERY_STATE_OF_CHARGE | F_BATTERY_UNRESPONSIVE | \
- F_BATTERY_NOT_CONNECTED | F_BATTERY_GET_PARAMS)
-#define F_CHARGER_MASK (F_CHARGER_VOLTAGE | F_CHARGER_CURRENT | F_CHARGER_INIT)
-
-/* Power state data
- * Status collection of charging state machine.
- */
-struct charge_state_data {
- int ac;
- int charging_voltage;
- int charging_current;
- struct batt_params batt;
- enum charge_state state;
- uint32_t error;
- timestamp_t ts;
-};
-
-/* State context
- * The shared context for state handler. The context contains current and
- * previous state.
- */
-struct charge_state_context {
- struct charge_state_data curr;
- struct charge_state_data prev;
- timestamp_t charge_state_updated_time;
- uint32_t *memmap_batt_volt;
- uint32_t *memmap_batt_rate;
- uint32_t *memmap_batt_cap;
- uint8_t *memmap_batt_flags;
- /* Charger and battery pack info */
- const struct charger_info *charger;
- const struct battery_info *battery;
- /* Charging timestamps */
- timestamp_t charger_update_time;
- timestamp_t trickle_charging_time;
- timestamp_t voltage_debounce_time;
- timestamp_t shutdown_warning_time;
- int battery_responsive;
-};
-
-#endif /* __CROS_EC_CHARGE_STATE_V1_H */
diff --git a/include/charge_state_v2.h b/include/charge_state_v2.h
index 6d0b936f4a..72fd8a88ff 100644
--- a/include/charge_state_v2.h
+++ b/include/charge_state_v2.h
@@ -3,235 +3,7 @@
* found in the LICENSE file.
*/
-#include "battery.h"
-#include "battery_smart.h"
-#include "charger.h"
-#include "chipset.h"
-#include "ec_ec_comm_client.h"
-#include "ocpc.h"
-#include "timer.h"
-
-#include <stdbool.h>
-
#ifndef __CROS_EC_CHARGE_STATE_V2_H
#define __CROS_EC_CHARGE_STATE_V2_H
-/*
- * The values exported by charge_get_state() and charge_get_flags() are used
- * only to control the LEDs (with one not-quite-correct exception). For V2
- * we use a different set of states internally.
- */
-enum charge_state_v2 {
- ST_IDLE = 0,
- ST_DISCHARGE,
- ST_CHARGE,
- ST_PRECHARGE,
-
- NUM_STATES_V2
-};
-
-struct charge_state_data {
- timestamp_t ts;
- int ac;
- int batt_is_charging;
- struct charger_params chg;
- struct batt_params batt;
- enum charge_state_v2 state;
- int requested_voltage;
- int requested_current;
- int desired_input_current;
-#ifdef CONFIG_CHARGER_OTG
- int output_current;
-#endif
-#ifdef CONFIG_EC_EC_COMM_BATTERY_CLIENT
- int input_voltage;
-#endif
-#ifdef CONFIG_OCPC
- struct ocpc_data ocpc;
-#endif
-};
-
-struct sustain_soc {
- int8_t lower;
- int8_t upper;
-};
-
-/**
- * Set the output current limit and voltage. This is used to provide power from
- * the charger chip ("OTG" mode).
- *
- * @param chgnum Charger index to act upon
- * @param ma Maximum current to provide in mA (0 to disable output).
- * @param mv Voltage in mV (ignored if ma == 0).
- * @return EC_SUCCESS or error
- */
-int charge_set_output_current_limit(int chgnum, int ma, int mv);
-
-/**
- * Set the charge input current limit. This value is stored and sent every
- * time AC is applied.
- *
- * The input current limit is automatically derated by
- * CONFIG_CHARGER_INPUT_CURRENT_DERATE_PCT (if configured), and is clamped to
- * no less than CONFIG_CHARGER_MIN_INPUT_CURRENT_LIMIT mA (if configured).
- *
- * @param ma New input current limit in mA
- * @param mv Negotiated charge voltage in mV.
- * @return EC_SUCCESS or error
- */
-int charge_set_input_current_limit(int ma, int mv);
-
-/**
- * Set the desired manual charge current when in idle mode.
- *
- * @param curr_ma: Charge current in mA.
- */
-void chgstate_set_manual_current(int curr_ma);
-
-/**
- * Set the desired manual charge voltage when in idle mode.
- *
- * @param volt_mv: Charge voltage in mV.
- */
-void chgstate_set_manual_voltage(int volt_mv);
-
-/**
- * Board-specific routine to indicate if the base is connected.
- */
-int board_is_base_connected(void);
-
-/**
- * Board-specific routine to enable power distribution between lid and base
- * (current can flow both ways).
- */
-void board_enable_base_power(int enable);
-
-/**
- * Board-specific routine to reset the base (in case it is unresponsive, e.g.
- * if we told it to hibernate).
- */
-void board_base_reset(void);
-
-/**
- * Callback with which boards determine action on critical low battery
- *
- * The default implementation is provided in charge_state_v2.c. Overwrite it
- * to customize it.
- *
- * @param curr Pointer to struct charge_state_data
- * @return Action to take.
- */
-enum critical_shutdown
-board_critical_shutdown_check(struct charge_state_data *curr);
-
-/**
- * Callback to set battery level for shutdown
- *
- * A board can implement this to customize shutdown battery level at runtime.
- *
- * @return battery level for shutdown
- */
-uint8_t board_set_battery_level_shutdown(void);
-
-/**
- * Return system PLT power and battery's desired power.
- *
- * @return desired power in mW
- */
-int charge_get_plt_plus_bat_desired_mw(void);
-
-/**
- * Get the stable battery charging current. The current will be
- * CHARGE_CURRENT_UNINITIALIZED if not yet stable.
- *
- * @return stable battery charging current in mA
- */
-int charge_get_stable_current(void);
-
-/**
- * Select which charger IC will actually be performing the charger switching.
- *
- * @param idx The index into the chg_chips table.
- */
-void charge_set_active_chg_chip(int idx);
-
-/**
- * Retrieve which charger IC is the active charger IC performing the charger
- * switching.
- */
-int charge_get_active_chg_chip(void);
-
-/**
- * Set the stable current.
- *
- * @param ma: battery charging current in mA
- */
-void charge_set_stable_current(int ma);
-
-/**
- * Reset stable current counter stable_ts. Calling this function would set
- * stable_current to CHARGE_CURRENT_UNINITIALIZED.
- */
-void charge_reset_stable_current(void);
-
-/**
- * Reset stable current counter stable_ts. Calling this function would set
- * stable_current to CHARGE_CURRENT_UNINITIALIZED.
- *
- * @param us: sample stable current until us later.
- */
-void charge_reset_stable_current_us(uint64_t us);
-
-/**
- * Check if the battery charging current is stable by examining the timestamp.
- *
- * @return true if stable timestamp expired, false otherwise.
- */
-bool charge_is_current_stable(void);
-
-/**
- * Reset the OCPC internal state data and set the target VSYS to the current
- * battery voltage for the auxiliary chargers.
- */
-void trigger_ocpc_reset(void);
-
-/* Track problems in communicating with the battery or charger */
-enum problem_type {
- PR_STATIC_UPDATE,
- PR_SET_VOLTAGE,
- PR_SET_CURRENT,
- PR_SET_MODE,
- PR_SET_INPUT_CURR,
- PR_POST_INIT,
- PR_CHG_FLAGS,
- PR_BATT_FLAGS,
- PR_CUSTOM,
- PR_CFG_SEC_CHG,
-
- NUM_PROBLEM_TYPES
-};
-
-void charge_problem(enum problem_type p, int v);
-
-struct charge_state_data *charge_get_status(void);
-
-enum ec_charge_control_mode get_chg_ctrl_mode(void);
-
-__test_only void reset_prev_disp_charge(void);
-
-/**
- * Whether or not the charging progress was shown. Note, calling this function
- * will reset the value to false.
- *
- * @return Whether or not the charging progress was printed to the console
- */
-__test_only bool charging_progress_displayed(void);
-
-/**
- * Callback for boards to request charger to enable bypass mode on/off.
- *
- * @return True for requesting bypass on. False for requesting bypass off.
- */
-int board_should_charger_bypass(void);
-
#endif /* __CROS_EC_CHARGE_STATE_V2_H */
diff --git a/include/charger.h b/include/charger.h
index 468d267bb8..0f5a9b3e7c 100644
--- a/include/charger.h
+++ b/include/charger.h
@@ -435,4 +435,17 @@ void print_charger_prochot(int chgnum);
*/
int charger_get_min_bat_pct_for_power_on(void);
+/* Wake up the task when something important happens */
+void charge_wakeup(void);
+
+/*
+ * Ask the charger for some voltage and current. If either value is 0,
+ * charging is disabled; otherwise it's enabled. Negative values are ignored.
+ *
+ * @param use_curr Use values from requested voltage and current (otherwise use
+ * 0 for both)
+ * @param is_full Battery is full
+ */
+int charge_request(bool use_curr, bool is_full);
+
#endif /* __CROS_EC_CHARGER_H */
diff --git a/include/charger_base.h b/include/charger_base.h
new file mode 100644
index 0000000000..efe4a6885f
--- /dev/null
+++ b/include/charger_base.h
@@ -0,0 +1,64 @@
+/* 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.
+ */
+
+/* Charger functions related to a connected keyboard called a 'base' */
+
+#ifndef __CROS_EC_CHARGER_BASE_H
+#define __CROS_EC_CHARGER_BASE_H
+
+#include <stdbool.h>
+
+struct charge_state_data;
+
+/* allocate power between the base and the lid */
+void base_charge_allocate_input_current_limit(
+ const struct charge_state_data *curr, bool is_full, bool debugging);
+
+/*
+ * Check base external-power settings and react as needed
+ *
+ * @param ac Current ac value from struct charge_state_data
+ * @param prev_ac Previous value of ac
+ * Returns true if ac should be zeroed, false to leave it along
+ */
+bool base_check_extpower(int ac, int prev_ac);
+
+/* Update base battery information */
+void base_update_battery_info(void);
+
+#ifdef CONFIG_EC_EC_COMM_BATTERY_CLIENT
+/* Check if there is a base and it is connected */
+bool base_connected(void);
+
+#else
+static inline bool base_connected(void)
+{
+ return false;
+}
+#endif
+
+/* Set up the charger task for the base */
+void charger_base_setup(void);
+
+/* Check if charge_base has changed since last time */
+bool charger_base_charge_changed(void);
+
+/* Update prev_charge_base with charge_base */
+void charger_base_charge_update(void);
+
+/* Show the current charge level of the base on the console */
+void charger_base_show_charge(void);
+
+/* Check if the base charge is near full */
+bool charger_base_charge_near_full(void);
+
+/* Get the base input-voltage */
+int charger_base_get_input_voltage(const struct charge_state_data *curr);
+
+/* Set the input voltage for the base */
+void charger_base_set_input_voltage(struct charge_state_data *curr,
+ int input_voltage);
+
+#endif /* __CROS_EC_CHARGER_BASE_H */
diff --git a/include/charger_profile_override.h b/include/charger_profile_override.h
index 24606d3c3d..4648fb0ced 100644
--- a/include/charger_profile_override.h
+++ b/include/charger_profile_override.h
@@ -8,7 +8,7 @@
#ifndef __CROS_EC_CHARGER_PROFILE_OVERRIDE_H
#define __CROS_EC_CHARGER_PROFILE_OVERRIDE_H
-#include "charge_state_v2.h"
+#include "charge_state.h"
#define TEMPC_TENTHS_OF_DEG(c) ((c)*10)
diff --git a/include/config.h b/include/config.h
index 3279cbc821..a3a2edb1ed 100644
--- a/include/config.h
+++ b/include/config.h
@@ -631,12 +631,6 @@
#define CONFIG_BATTERY_LOW_VOLTAGE_TIMEOUT (30 * 60 * SECOND)
/*
- * Specify the battery percentage at which the host is told it is full.
- * If this value is not specified the default is 97% set in battery.h.
- */
-#undef CONFIG_BATTERY_LEVEL_NEAR_FULL
-
-/*
* Use memory mapped region to store battery information. It supports only
* single battery systems. V2 should be used unless there is a reason not to.
*/
@@ -1636,6 +1630,10 @@
#undef CONFIG_CMD_CHARGEN
#endif
#define CONFIG_CMD_CHARGER
+
+/* Extra debugging info for the charger */
+#define CONFIG_CHARGE_DEBUG
+
#undef CONFIG_CMD_CHARGER_ADC_AMON_BMON
#undef CONFIG_CMD_CHARGER_DUMP
#undef CONFIG_CMD_CHARGER_PROFILE_OVERRIDE
@@ -6308,6 +6306,7 @@
#define CONFIG_USBC_OCP
#endif
+#ifndef CONFIG_ZEPHYR
/*****************************************************************************/
/*
* Define CONFIG_USB_PD_VBUS_MEASURE_CHARGER if the charger on the board
@@ -6318,19 +6317,24 @@
defined(CONFIG_CHARGER_MT6370) || defined(CONFIG_CHARGER_BQ25710) || \
defined(CONFIG_CHARGER_BQ25720) || defined(CONFIG_CHARGER_ISL9241) || \
defined(CONFIG_CHARGER_RAA489110)
+#if !defined(CONFIG_USB_PD_VBUS_MEASURE_TCPC) && \
+ !defined(CONFIG_USB_PD_VBUS_MEASURE_ADC_EACH_PORT) && \
+ !defined(CONFIG_USB_PD_VBUS_MEASURE_BY_BOARD)
#define CONFIG_USB_PD_VBUS_MEASURE_CHARGER
+#endif /* VBUS_MEASURE options */
#ifdef CONFIG_USB_PD_VBUS_MEASURE_NOT_PRESENT
#error CONFIG_USB_PD_VBUS_MEASURE_NOT_PRESENT defined, but charger can measure
-#endif
-#endif
-
+#endif /* VBUS_NOT_PRESENT */
+#endif /* Charger chips */
+#endif /* CONFIG_ZEPHYR */
/*****************************************************************************/
/*
* Define CONFIG_USB_PD_VBUS_MEASURE_TCPC if the tcpc on the board supports
* VBUS measurement.
*/
-#if defined(CONFIG_USB_PD_TCPM_FUSB302)
+#if defined(CONFIG_USB_PD_TCPM_FUSB302) && \
+ !defined(CONFIG_USB_PD_VBUS_MEASURE_CHARGER)
#define CONFIG_USB_PD_VBUS_MEASURE_TCPC
#endif
@@ -6436,14 +6440,6 @@
/*****************************************************************************/
/*
- * Define CONFIG_LIBCRYPTOC if a board needs to read secret data from the
- * anti-rollback block.
- */
-#ifdef CONFIG_ROLLBACK_SECRET_SIZE
-#define CONFIG_LIBCRYPTOC
-#endif
-
-/*
* Handle task-dependent configs.
*
* This prevent sub-modules from being compiled when the task and parent module
diff --git a/include/hooks.h b/include/hooks.h
index a1bb97e55d..ea4eb0b480 100644
--- a/include/hooks.h
+++ b/include/hooks.h
@@ -222,7 +222,7 @@ enum hook_type {
HOOK_POWER_BUTTON_CHANGE,
/*
- * Battery state of charge changed
+ * Battery state-of-charge changed
*
* Hook routines are called from the charger task.
*/
diff --git a/include/keyboard_8042.h b/include/keyboard_8042.h
index bd56106f1d..fbc5bcf073 100644
--- a/include/keyboard_8042.h
+++ b/include/keyboard_8042.h
@@ -59,4 +59,29 @@ void send_aux_data_to_host_interrupt(uint8_t data);
*/
void send_aux_data_to_device(uint8_t data);
+#ifdef TEST_BUILD
+
+/**
+ * @brief Expose function for testing to set typematic scan code
+ *
+ * @param scan_code Pointer to byte array with scan code
+ * @param len Length of scan code in number of bytes
+ */
+void set_typematic_key(const uint8_t *scan_code, int32_t len);
+
+/**
+ * @brief Force-set the resend command buffer for testing.
+ *
+ * @param data Pointer to command to copy from
+ * @param length Number of bytes to copy (capped at MAX_SCAN_CODE_LEN)
+ */
+__test_only void test_keyboard_8042_set_resend_command(const uint8_t *data,
+ int length);
+
+/**
+ * @brief Reset typematic, RAM, and scancode set for testing purposes.
+ */
+__test_only void test_keyboard_8042_reset(void);
+#endif /* TEST_BUILD */
+
#endif /* __CROS_EC_KEYBOARD_8042_H */
diff --git a/include/power.h b/include/power.h
index 728903be01..de51b2cfce 100644
--- a/include/power.h
+++ b/include/power.h
@@ -218,6 +218,17 @@ static inline void power_signal_interrupt(enum gpio_signal signal)
#endif /* !CONFIG_AP_POWER_CONTROL */
/**
+ * Interrupt handler for pwrok signal. This interrupt handler should be used
+ * when there is a requirement to have minimum pass through delay between the
+ * pwrok coming to the EC and the pwrok that goes to the PCH for high->low
+ * transitions. Low->high transitions are still handled from within the chipset
+ * task power state machine.
+ *
+ * @param signal - The gpio signal that triggered the interrupt.
+ */
+void intel_x86_pwrok_signal_interrupt(enum gpio_signal signal);
+
+/**
* Interrupt handler for rsmrst signal GPIO. This interrupt handler should be
* used when there is a requirement to have minimum pass through delay between
* the rsmrst coming to the EC and the rsmrst that goes to the PCH for high->low
diff --git a/include/system_safe_mode.h b/include/system_safe_mode.h
index 6c8909bf43..766d0535af 100644
--- a/include/system_safe_mode.h
+++ b/include/system_safe_mode.h
@@ -47,13 +47,6 @@ int disable_non_safe_mode_critical_tasks(void);
int start_system_safe_mode(void);
/**
- * Schedules safe mode timeout.
- *
- * @return EC_SUCCESS or EC_xxx on error
- */
-int schedule_system_safe_mode_timeout(void);
-
-/**
* This handler is called when safe mode times out.
*/
void handle_system_safe_mode_timeout(void);
diff --git a/include/usb_pd.h b/include/usb_pd.h
index e85c5cc80a..b5981abc46 100644
--- a/include/usb_pd.h
+++ b/include/usb_pd.h
@@ -5,6 +5,12 @@
/* USB Power delivery module */
+/*
+ * TODO(b/272518464): Work around coreboot GCC preprocessor bug.
+ * #line marks the *next* line, so it is off by one.
+ */
+#line 13
+
#ifndef __CROS_EC_USB_PD_H
#define __CROS_EC_USB_PD_H