summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShou-Chieh Hsu <shouchieh@google.com>2023-01-31 16:48:25 +0800
committerShou-Chieh Hsu <shouchieh@chromium.org>2023-01-31 08:59:49 +0000
commitdce247e97903a2464ff8884106bffa43587c1dcb (patch)
treee20629e33a27c322b1c569a4f929cb240eab3d1b
parent2962a79f0aac5845ca29a04cfe90f9728d0a91e9 (diff)
parent9011f4f3f23078f6099e170c1661b12218d778b0 (diff)
downloadchrome-ec-dce247e97903a2464ff8884106bffa43587c1dcb.tar.gz
Merge remote-tracking branch cros/main into firmware-nissa-15217.B-main
Generated by: util/update_release_branch.py -r --zephyr --board nissa firmware- nissa-15217.B-main Relevant changes: git log --oneline 2962a79f0a..9011f4f3f2 -- zephyr/program/nissa util/getversion.sh af02307a26 xivu: modify form_factor motionsene function 0f7b43a563 pujjo: Increase OCP level margin to prevent OCP 221c98d97c craask: Config to reduce flash size BRANCH=None BUG=b:265752765 b:263996465 b:266867807 TEST=`make -j buildall` Force-Relevant-Builds: all Cq-Depend: chromium:4207308 Change-Id: Ia93d05dd17ed0d94820c222ce5b30ef60877b866 Signed-off-by: Shou-Chieh Hsu <shouchieh@google.com>
-rw-r--r--baseboard/asurada/hibernate.c7
-rw-r--r--board/casta/battery.c2
-rw-r--r--board/mushu/board.h7
-rw-r--r--board/nami/board.h7
-rw-r--r--board/nautilus/battery.c2
-rw-r--r--board/omnigul/battery.c54
-rw-r--r--board/omnigul/board.h2
-rw-r--r--common/usbc/usb_pe_drp_sm.c2
-rw-r--r--common/usbc/usb_tc_drp_acc_trysrc_sm.c2
-rw-r--r--docs/pupr.md19
-rw-r--r--docs/sitemap.md1
-rw-r--r--driver/charger/isl923x.c4
-rw-r--r--driver/charger/isl923x.h4
-rw-r--r--driver/tcpm/raa489000.h5
-rw-r--r--driver/temp_sensor/f75303.c60
-rw-r--r--driver/temp_sensor/f75303.h45
-rw-r--r--include/config.h3
-rw-r--r--include/ec_commands.h6
-rw-r--r--include/ioexpander.h10
-rw-r--r--navbar.md2
-rwxr-xr-xutil/check_zephyr_project_config.py8
-rwxr-xr-xutil/check_zephyr_project_config_unittest.py6
-rw-r--r--util/config_allowed.txt1
-rw-r--r--zephyr/CMakeLists.txt2
-rw-r--r--zephyr/Kconfig12
-rw-r--r--zephyr/Kconfig.charger7
-rw-r--r--zephyr/Kconfig.tcpm14
-rw-r--r--zephyr/Kconfig.temperature8
-rw-r--r--zephyr/app/ec/ec_app_main.c18
-rw-r--r--zephyr/boards/arm/stm32g4/Kconfig.board10
-rw-r--r--zephyr/boards/arm/stm32g4/Kconfig.defconfig6
-rw-r--r--zephyr/boards/arm/stm32g4/stm32g473.dts18
-rw-r--r--zephyr/boards/arm/stm32g4/stm32g473_defconfig32
-rw-r--r--zephyr/dts/bindings/temp/cros-ec,temp-sensor-f75303.yaml10
-rw-r--r--zephyr/emul/emul_bb_retimer.c2
-rw-r--r--zephyr/emul/emul_bma255.c2
-rw-r--r--zephyr/emul/emul_bmi.c2
-rw-r--r--zephyr/emul/emul_isl923x.c2
-rw-r--r--zephyr/emul/emul_lis2dw12.c3
-rw-r--r--zephyr/emul/emul_ln9310.c2
-rw-r--r--zephyr/emul/emul_pct2075.c2
-rw-r--r--zephyr/emul/emul_pi3usb9201.c3
-rw-r--r--zephyr/emul/emul_rt9490.c2
-rw-r--r--zephyr/emul/emul_smart_battery.c2
-rw-r--r--zephyr/emul/emul_sn5s330.c2
-rw-r--r--zephyr/emul/emul_syv682x.c2
-rw-r--r--zephyr/emul/emul_tcs3400.c2
-rw-r--r--zephyr/emul/emul_tusb1064.c2
-rw-r--r--zephyr/emul/i2c_mock.c2
-rw-r--r--zephyr/emul/tcpc/emul_anx7447.c2
-rw-r--r--zephyr/emul/tcpc/emul_ps8xxx.c2
-rw-r--r--zephyr/emul/tcpc/emul_tcpci_generic.c2
-rw-r--r--zephyr/include/emul/tcpc/emul_tcpci.h6
-rw-r--r--zephyr/program/nissa/craask/project.conf4
-rw-r--r--zephyr/program/nissa/pujjo/project.conf3
-rw-r--r--zephyr/program/nissa/xivu/src/form_factor.c47
-rw-r--r--zephyr/program/rex/rex/project.conf3
-rw-r--r--zephyr/program/skyrim/markarth/project.overlay27
-rw-r--r--zephyr/program/skyrim/program.conf4
-rw-r--r--zephyr/program/skyrim/src/stt.c11
-rw-r--r--zephyr/program/skyrim/winterhold/project.conf3
-rw-r--r--zephyr/program/skyrim/winterhold/project.overlay10
-rw-r--r--zephyr/program/skyrim/winterhold/src/thermal.c101
-rw-r--r--zephyr/shim/include/config_chip.h11
-rw-r--r--zephyr/shim/include/temp_sensor/temp_sensor.h18
-rw-r--r--zephyr/shim/src/temp_sensors.c40
-rw-r--r--zephyr/test/drivers/i2c_controller/src/basic_i2c_device_emul.c2
-rw-r--r--zephyr/test/skyrim/CMakeLists.txt15
-rw-r--r--zephyr/test/skyrim/Kconfig64
-rw-r--r--zephyr/test/skyrim/boards/native_posix.overlay33
-rw-r--r--zephyr/test/skyrim/prj.conf13
-rw-r--r--zephyr/test/skyrim/src/baseboard/common.c7
-rw-r--r--zephyr/test/skyrim/src/baseboard/usb_pd_policy.c263
-rw-r--r--zephyr/test/skyrim/src/crystaldrift/common.c7
-rw-r--r--zephyr/test/skyrim/src/frostflow/common.c7
-rw-r--r--zephyr/test/skyrim/src/markarth/common.c7
-rw-r--r--zephyr/test/skyrim/src/skyrim/common.c7
-rw-r--r--zephyr/test/skyrim/src/winterhold/common.c7
-rw-r--r--zephyr/test/skyrim/testcase.yaml47
79 files changed, 1101 insertions, 100 deletions
diff --git a/baseboard/asurada/hibernate.c b/baseboard/asurada/hibernate.c
index 60b191d3e6..21c2de41e3 100644
--- a/baseboard/asurada/hibernate.c
+++ b/baseboard/asurada/hibernate.c
@@ -28,10 +28,13 @@ __override void board_hibernate_late(void)
return;
}
- isl9238c_hibernate(CHARGER_SOLO);
-
gpio_set_level(GPIO_EN_SLP_Z, 1);
/* should not reach here */
__builtin_unreachable();
}
+
+void board_hibernate(void)
+{
+ isl9238c_hibernate(CHARGER_SOLO);
+}
diff --git a/board/casta/battery.c b/board/casta/battery.c
index efee023d6a..81e2d98e40 100644
--- a/board/casta/battery.c
+++ b/board/casta/battery.c
@@ -54,7 +54,7 @@ const struct board_batt_params board_battery_info[] = {
}
},
.batt_info = {
- .voltage_max = 8650,
+ .voltage_max = 8600,
.voltage_normal = 7700, /* mV */
.voltage_min = 6000, /* mV */
.precharge_current = 200, /* mA */
diff --git a/board/mushu/board.h b/board/mushu/board.h
index 02443bbfa3..f8ae0deb4d 100644
--- a/board/mushu/board.h
+++ b/board/mushu/board.h
@@ -198,6 +198,13 @@ enum temp_sensor_id {
TEMP_SENSOR_COUNT
};
+enum f75303_index {
+ F75303_IDX_LOCAL = 0,
+ F75303_IDX_REMOTE1,
+ F75303_IDX_REMOTE2,
+ F75303_IDX_COUNT,
+};
+
/* List of possible batteries */
enum battery_type {
BATTERY_POWER_TECH,
diff --git a/board/nami/board.h b/board/nami/board.h
index 652db4826d..2a1ce91d3c 100644
--- a/board/nami/board.h
+++ b/board/nami/board.h
@@ -223,6 +223,13 @@ enum temp_sensor_id {
TEMP_SENSOR_COUNT,
};
+enum f75303_index {
+ F75303_IDX_LOCAL = 0,
+ F75303_IDX_REMOTE1,
+ F75303_IDX_REMOTE2,
+ F75303_IDX_COUNT,
+};
+
/*
* Motion sensors:
* When reading through IO memory is set up for sensors (LPC is used),
diff --git a/board/nautilus/battery.c b/board/nautilus/battery.c
index dd9b72e222..c36d48a69a 100644
--- a/board/nautilus/battery.c
+++ b/board/nautilus/battery.c
@@ -32,7 +32,7 @@ static enum battery_present batt_pres_prev = BP_NOT_SURE;
#define CHARGING_CURRENT_MA_SAFE 1500
static const struct battery_info info = {
- .voltage_max = 8700,
+ .voltage_max = 8600,
.voltage_normal = 7700,
.voltage_min = 6000,
/* Pre-charge values. */
diff --git a/board/omnigul/battery.c b/board/omnigul/battery.c
index 5d2eff0722..39087f72a3 100644
--- a/board/omnigul/battery.c
+++ b/board/omnigul/battery.c
@@ -33,70 +33,72 @@
* address, mask, and disconnect value need to be provided.
*/
const struct board_batt_params board_battery_info[] = {
- /* POW-TECH GQA05 Battery Information */
- [BATTERY_POWER_TECH] = {
- /* BQ40Z50 Fuel Gauge */
+ /* LGC AP19B8M Battery Information */
+ /*
+ * Battery info provided by ODM on b/263691095, comment #2
+ */
+ [BATTERY_AP19B8M] = {
.fuel_gauge = {
- .manuf_name = "POW-TECH",
- .device_name = "BATGQA05L22",
+ .manuf_name = "LGC KT0030G024",
+ .device_name = "AP19B8M",
.ship_mode = {
.reg_addr = 0x00,
.reg_data = { 0x0010, 0x0010 },
},
.fet = {
- .mfgacc_support = 1,
- .reg_addr = 0x00,
- .reg_mask = 0x2000, /* XDSG */
- .disconnect_val = 0x2000,
+ .reg_addr = 0x43,
+ .reg_mask = 0x0003, /* D-FET C-FET */
+ .disconnect_val = 0x0000,
}
},
.batt_info = {
- .voltage_max = TARGET_WITH_MARGIN(13050, 5),
- .voltage_normal = 11400, /* mV */
+ .voltage_max = 13350,
+ .voltage_normal = 11610, /* mV */
.voltage_min = 9000, /* mV */
- .precharge_current = 280, /* mA */
+ .precharge_current = 256, /* mA */
.start_charging_min_c = 0,
- .start_charging_max_c = 45,
+ .start_charging_max_c = 50,
.charging_min_c = 0,
- .charging_max_c = 45,
- .discharging_min_c = -10,
- .discharging_max_c = 60,
+ .charging_max_c = 60,
+ .discharging_min_c = -20,
+ .discharging_max_c = 75,
},
},
- /* LGC L17L3PB0 Battery Information */
+ /* COSMX AP20CBL Battery Information */
/*
- * Battery info provided by ODM on b/143477210, comment #11
+ * Battery info provided by ODM on b/263691095, comment #2
*/
- [BATTERY_LGC011] = {
+ [BATTERY_AP20CBL] = {
.fuel_gauge = {
- .manuf_name = "LGC",
+ .manuf_name = "COSMX KT0030B004",
.ship_mode = {
.reg_addr = 0x00,
.reg_data = { 0x0010, 0x0010 },
},
.fet = {
+ .mfgacc_support = 1,
.reg_addr = 0x0,
- .reg_mask = 0x6000,
- .disconnect_val = 0x6000,
+ .reg_mask = 0x0006, /* D-FET C-FET */
+ .disconnect_val = 0x0000,
}
},
.batt_info = {
- .voltage_max = TARGET_WITH_MARGIN(13200, 5),
+ .voltage_max = 13200,
.voltage_normal = 11550, /* mV */
.voltage_min = 9000, /* mV */
.precharge_current = 256, /* mA */
.start_charging_min_c = 0,
- .start_charging_max_c = 45,
+ .start_charging_max_c = 50,
.charging_min_c = 0,
.charging_max_c = 60,
- .discharging_min_c = 0,
+ .discharging_min_c = -20,
.discharging_max_c = 75,
},
},
};
BUILD_ASSERT(ARRAY_SIZE(board_battery_info) == BATTERY_TYPE_COUNT);
-const enum battery_type DEFAULT_BATTERY_TYPE = BATTERY_POWER_TECH;
+const enum battery_type DEFAULT_BATTERY_TYPE = BATTERY_AP19B8M;
enum battery_present battery_hw_present(void)
{
diff --git a/board/omnigul/board.h b/board/omnigul/board.h
index f637b0c6fa..2f260f88f8 100644
--- a/board/omnigul/board.h
+++ b/board/omnigul/board.h
@@ -245,7 +245,7 @@ enum sensor_id {
enum ioex_port { IOEX_C0_NCT38XX = 0, IOEX_C2_NCT38XX, IOEX_PORT_COUNT };
-enum battery_type { BATTERY_POWER_TECH, BATTERY_LGC011, BATTERY_TYPE_COUNT };
+enum battery_type { BATTERY_AP19B8M, BATTERY_AP20CBL, BATTERY_TYPE_COUNT };
enum pwm_channel {
PWM_CH_LED2 = 0, /* PWM0 (white charger) */
diff --git a/common/usbc/usb_pe_drp_sm.c b/common/usbc/usb_pe_drp_sm.c
index 0aff4feaaf..4e06a35ddf 100644
--- a/common/usbc/usb_pe_drp_sm.c
+++ b/common/usbc/usb_pe_drp_sm.c
@@ -1787,7 +1787,7 @@ static void print_current_state(const int port)
CPRINTS_L1("C%d: %s%s", port,
pe_state_names[get_state_pe(port)], mode);
else
- CPRINTS("C%d: pe-st%d", port, get_state_pe(port));
+ CPRINTS_L1("C%d: pe-st%d", port, get_state_pe(port));
}
static void send_source_cap(int port)
diff --git a/common/usbc/usb_tc_drp_acc_trysrc_sm.c b/common/usbc/usb_tc_drp_acc_trysrc_sm.c
index c2394f8aa1..962b65154a 100644
--- a/common/usbc/usb_tc_drp_acc_trysrc_sm.c
+++ b/common/usbc/usb_tc_drp_acc_trysrc_sm.c
@@ -1729,7 +1729,7 @@ static void print_current_state(const int port)
if (IS_ENABLED(USB_PD_DEBUG_LABELS))
CPRINTS_L1("C%d: %s", port, tc_state_names[get_state_tc(port)]);
else
- CPRINTS("C%d: tc-st%d", port, get_state_tc(port));
+ CPRINTS_L1("C%d: tc-st%d", port, get_state_tc(port));
}
static void handle_device_access(int port)
diff --git a/docs/pupr.md b/docs/pupr.md
new file mode 100644
index 0000000000..bb7d110bae
--- /dev/null
+++ b/docs/pupr.md
@@ -0,0 +1,19 @@
+# Parallel Uprevs for platform/ec
+
+## Overview
+
+Since the platform/ec repo doesn't use the normal ebuild based CQ some of the
+ebuild files don't use the normal automatic uprev. Instead the go/pupr tool
+creates new CLs to uprev the chromeos-base/ec-utils and send them through the
+slow CQ running all the ebuilds that depend on it.
+
+## Reviewer responsibilities
+
+For the most part you can ignore these CLs. You don't need to add CR+2 nor CQ+2.
+However if you see that the CL has failed the CQ several times, you should
+check and see if there is a real bug that is preventing the CL from submitting.
+
+## Failure implications
+
+If the CL fails to merge, then the ectool binary will not be built with the
+latest code.
diff --git a/docs/sitemap.md b/docs/sitemap.md
index 0bdc3ede12..1d9b2b3cb4 100644
--- a/docs/sitemap.md
+++ b/docs/sitemap.md
@@ -77,6 +77,7 @@
* [Code Reviews](./code_reviews.md)
* [IDE Support](./ide-support.md)
* [Building with Goma (Googlers only)](./goma.md)
+* [Parallel Uprevs for ebuilds](./pupr.md)
[1]:https://chromium.googlesource.com/chromiumos/platform/ec/+/cr50_stab/docs/case_closed_debugging.md
[2]:https://chromium.googlesource.com/chromiumos/platform/ec/+/cr50_stab/docs/case_closed_debugging_cr50.md
diff --git a/driver/charger/isl923x.c b/driver/charger/isl923x.c
index e2838810f1..24e9e488a5 100644
--- a/driver/charger/isl923x.c
+++ b/driver/charger/isl923x.c
@@ -711,6 +711,10 @@ static void isl923x_init(int chgnum)
goto init_fail;
reg |= ISL923X_C0_ENABLE_BUCK;
+ /* Adjusts phase comparator threshold offset */
+ reg &= ~ISL923X_C0_BUCK_PHASE_MASK;
+ reg |= CONFIG_ISL9238C_BUCK_PHASE_VOLTAGE
+ << ISL923X_C0_BUCK_PHASE_SHIFT;
if (raw_write16(chgnum, ISL923X_REG_CONTROL0, reg))
goto init_fail;
diff --git a/driver/charger/isl923x.h b/driver/charger/isl923x.h
index cec8f43fd3..251d62dc99 100644
--- a/driver/charger/isl923x.h
+++ b/driver/charger/isl923x.h
@@ -107,6 +107,10 @@
#define ISL923X_C0_DCHOT_3A (3 << 3)
#define ISL923X_C0_DCHOT_MASK (3 << 3)
+/* Control0: adjusts phase comparator threshold offset for forward buck */
+#define ISL923X_C0_BUCK_PHASE_MASK GENMASK(15, 13)
+#define ISL923X_C0_BUCK_PHASE_SHIFT 13
+
/* Control0: BGATE force on */
#define RAA489000_C0_BGATE_FORCE_ON BIT(10)
#define RAA489000_C0_EN_CHG_PUMPS_TO_100PCT BIT(6)
diff --git a/driver/tcpm/raa489000.h b/driver/tcpm/raa489000.h
index 41a37f94e7..b0bb202f98 100644
--- a/driver/tcpm/raa489000.h
+++ b/driver/tcpm/raa489000.h
@@ -39,7 +39,12 @@
/* VBUS_OCP_UV_THRESHOLD */
/* Detect voltage level of overcurrent protection during Sourcing VBUS */
+#ifdef CONFIG_PLATFORM_EC_RAA489000_OCP_UV_THRESHOLD_MV
+#define RAA489000_OCP_THRESHOLD_VALUE \
+ (CONFIG_PLATFORM_EC_RAA489000_OCP_UV_THRESHOLD_MV / 25)
+#else
#define RAA489000_OCP_THRESHOLD_VALUE 0x00BE /* 4.75V */
+#endif
/* TYPEC_SETTING1 - only older silicon */
/* Enables for reverse current protection */
diff --git a/driver/temp_sensor/f75303.c b/driver/temp_sensor/f75303.c
index d83f7bc4a6..dbeaf4470c 100644
--- a/driver/temp_sensor/f75303.c
+++ b/driver/temp_sensor/f75303.c
@@ -10,10 +10,19 @@
#include "f75303.h"
#include "hooks.h"
#include "i2c.h"
+#include "math_util.h"
#include "util.h"
+#ifdef CONFIG_ZEPHYR
+#include "temp_sensor/temp_sensor.h"
+#endif
+
+#define F75303_RESOLUTION 11
+#define F75303_SHIFT1 (16 - F75303_RESOLUTION)
+#define F75303_SHIFT2 (F75303_RESOLUTION - 8)
+
static int temps[F75303_IDX_COUNT];
-static int8_t fake_temp[F75303_IDX_COUNT] = { -1, -1, -1 };
+static int8_t fake_temp[F75303_IDX_COUNT];
/**
* Read 8 bits register from temp sensor.
@@ -50,6 +59,34 @@ int f75303_get_val(int idx, int *temp)
return EC_SUCCESS;
}
+static inline int f75303_reg_to_mk(int16_t reg)
+{
+ int temp_mc;
+
+ temp_mc = (((reg >> F75303_SHIFT1) * 1000) >> F75303_SHIFT2);
+
+ return MILLI_CELSIUS_TO_MILLI_KELVIN(temp_mc);
+}
+
+int f75303_get_val_k(int idx, int *temp_k_ptr)
+{
+ if (idx >= F75303_IDX_COUNT)
+ return EC_ERROR_INVAL;
+
+ *temp_k_ptr = MILLI_KELVIN_TO_KELVIN(temps[idx]);
+ return EC_SUCCESS;
+}
+
+int f75303_get_val_mk(int idx, int *temp_mk_ptr)
+{
+ if (idx >= F75303_IDX_COUNT)
+ return EC_ERROR_INVAL;
+
+ *temp_mk_ptr = temps[idx];
+ return EC_SUCCESS;
+}
+
+#ifndef CONFIG_ZEPHYR
static void f75303_sensor_poll(void)
{
get_temp(F75303_TEMP_LOCAL, &temps[F75303_IDX_LOCAL]);
@@ -57,6 +94,18 @@ static void f75303_sensor_poll(void)
get_temp(F75303_TEMP_REMOTE2, &temps[F75303_IDX_REMOTE2]);
}
DECLARE_HOOK(HOOK_SECOND, f75303_sensor_poll, HOOK_PRIO_TEMP_SENSOR);
+#else
+void f75303_update_temperature(int idx)
+{
+ int temp_reg = 0;
+
+ if (idx >= F75303_IDX_COUNT)
+ return;
+
+ if (get_temp(idx, &temp_reg) == EC_SUCCESS)
+ temps[idx] = f75303_reg_to_mk(temp_reg);
+}
+#endif /* CONFIG_ZEPHYR */
static int f75303_set_fake_temp(int argc, const char **argv)
{
@@ -89,3 +138,12 @@ static int f75303_set_fake_temp(int argc, const char **argv)
}
DECLARE_CONSOLE_COMMAND(f75303, f75303_set_fake_temp, "<index> <value>|off",
"Set fake temperature of sensor f75303.");
+
+static void f75303_init(void)
+{
+ int index;
+
+ for (index = 0; index < F75303_IDX_COUNT; index++)
+ fake_temp[index] = -1;
+}
+DECLARE_HOOK(HOOK_INIT, f75303_init, HOOK_PRIO_TEMP_SENSOR);
diff --git a/driver/temp_sensor/f75303.h b/driver/temp_sensor/f75303.h
index f8c85231da..4632978145 100644
--- a/driver/temp_sensor/f75303.h
+++ b/driver/temp_sensor/f75303.h
@@ -14,13 +14,20 @@
#define F75303_I2C_ADDR_FLAGS 0x4C
#endif
-enum f75303_index {
- F75303_IDX_LOCAL = 0,
- F75303_IDX_REMOTE1,
- F75303_IDX_REMOTE2,
- F75303_IDX_COUNT,
+/*
+ * I2C port and address information for all the board F75303 sensors should be
+ * defined in an array of the following structures, with an enum f75303_sensor
+ * indexing the array. The enum f75303_sensor shall end with a F75303_IDX_COUNT
+ * defining the maximum number of sensors for the board.
+ */
+
+struct f75303_sensor_t {
+ int i2c_port;
+ int i2c_addr_flags;
};
+extern const struct f75303_sensor_t f75303_sensors[];
+
/* F75303 register */
#define F75303_TEMP_LOCAL 0x00
#define F75303_TEMP_REMOTE1 0x01
@@ -37,4 +44,32 @@ enum f75303_index {
*/
int f75303_get_val(int idx, int *temp);
+/**
+ * Get the last polled value of a sensor.
+ *
+ * @param idx Index to read, from board's enum f75303_sensor
+ * definition
+ *
+ * @param temp_k_ptr Destination for temperature in K.
+ *
+ * @return EC_SUCCESS if successful, non-zero if error.
+ */
+int f75303_get_val_k(int idx, int *temp_k_ptr);
+
+/**
+ * Get the last polled value of a sensor.
+ *
+ * @param idx Index to read, from board's enum f75303_sensor
+ * definition
+ *
+ * @param temp_mk_ptr Destination for temperature in mK.
+ *
+ * @return EC_SUCCESS if successful, non-zero if error.
+ */
+int f75303_get_val_mk(int idx, int *temp_mk_ptr);
+
+#ifdef CONFIG_ZEPHYR
+void f75303_update_temperature(int idx);
+#endif /* CONFIG_ZEPHYR */
+
#endif /* __CROS_EC_F75303_H */
diff --git a/include/config.h b/include/config.h
index a448cf0147..e563fad17c 100644
--- a/include/config.h
+++ b/include/config.h
@@ -3505,6 +3505,9 @@
*/
#undef CONFIG_ISL9238C_ENABLE_BUCK_MODE
+/* ISL9238C adjusts phase comparator threshold offset */
+#define CONFIG_ISL9238C_BUCK_PHASE_VOLTAGE 0
+
/* Support MKBP event */
#undef CONFIG_MKBP_EVENT
diff --git a/include/ec_commands.h b/include/ec_commands.h
index 1a059ce1a2..2b5900b0dd 100644
--- a/include/ec_commands.h
+++ b/include/ec_commands.h
@@ -248,7 +248,11 @@ extern "C" {
#define EC_FAN_SPEED_ENTRIES 4 /* Number of fans at EC_MEMMAP_FAN */
#define EC_FAN_SPEED_NOT_PRESENT 0xffff /* Entry not present */
-#define EC_FAN_SPEED_STALLED 0xfffe /* Fan stalled */
+
+/* Report 0 for fan stalled so userspace applications can take
+ * an appropriate action based on this value to control the fan.
+ */
+#define EC_FAN_SPEED_STALLED 0x0 /* Fan stalled */
/* Battery bit flags at EC_MEMMAP_BATT_FLAG. */
#define EC_BATT_FLAG_AC_PRESENT 0x01
diff --git a/include/ioexpander.h b/include/ioexpander.h
index 9aff67dfaf..5717b10743 100644
--- a/include/ioexpander.h
+++ b/include/ioexpander.h
@@ -92,26 +92,26 @@ extern struct ioexpander_config_t ioex_config[];
#define ioex_disable_interrupt gpio_disable_interrupt
#ifdef CONFIG_GPIO_GET_EXTENDED
-inline int ioex_get_flags(enum gpio_signal signal, int *flags)
+static inline int ioex_get_flags(enum gpio_signal signal, int *flags)
{
*flags = gpio_get_flags(signal);
return EC_SUCCESS;
}
#endif
-inline int ioex_set_flags(enum gpio_signal signal, int flags)
+static inline int ioex_set_flags(enum gpio_signal signal, int flags)
{
gpio_set_flags(signal, flags);
return EC_SUCCESS;
}
-inline int ioex_get_level(enum gpio_signal signal, int *val)
+static inline int ioex_get_level(enum gpio_signal signal, int *val)
{
*val = gpio_get_level(signal);
return EC_SUCCESS;
}
-inline int ioex_set_level(enum gpio_signal signal, int val)
+static inline int ioex_set_level(enum gpio_signal signal, int val)
{
gpio_set_level(signal, val);
return EC_SUCCESS;
@@ -119,7 +119,7 @@ inline int ioex_set_level(enum gpio_signal signal, int val)
int ioex_init(int ioex);
-inline const char *ioex_get_name(enum ioex_signal signal)
+static inline const char *ioex_get_name(enum ioex_signal signal)
{
return gpio_get_name(signal);
}
diff --git a/navbar.md b/navbar.md
index 3799ca3620..f4809aa3be 100644
--- a/navbar.md
+++ b/navbar.md
@@ -1,6 +1,6 @@
# CrOS EC (Embedded Controller)
-[logo]: https://chromium-review.googlesource.com/plugins/chromium-style/static/web/chromium_logo.png
+[logo]: https://chromium-review.googlesource.com/static/chromium_logo.png
[home]: /README.md
* [Home][home]
diff --git a/util/check_zephyr_project_config.py b/util/check_zephyr_project_config.py
index 6a48e348fd..a49e9855b9 100755
--- a/util/check_zephyr_project_config.py
+++ b/util/check_zephyr_project_config.py
@@ -23,6 +23,12 @@ else:
EC_BASE.resolve().parent.parent / "third_party" / "zephyr" / "main"
)
+if not os.path.exists(ZEPHYR_BASE):
+ raise Exception(
+ f"ZEPHYR_BASE path does not exist!\nZEPHYR_BASE={ZEPHYR_BASE}"
+ )
+
+
site.addsitedir(ZEPHYR_BASE / "scripts")
site.addsitedir(ZEPHYR_BASE / "scripts" / "kconfig")
# pylint:disable=import-error,wrong-import-position
@@ -96,7 +102,7 @@ class KconfigCheck:
"""
with tempfile.TemporaryDirectory() as temp_dir:
modules = zephyr_module.parse_modules(
- ZEPHYR_BASE, extra_modules=[EC_BASE]
+ ZEPHYR_BASE, modules=[EC_BASE]
)
kconfig = ""
diff --git a/util/check_zephyr_project_config_unittest.py b/util/check_zephyr_project_config_unittest.py
index 0229085725..ad28d8e128 100755
--- a/util/check_zephyr_project_config_unittest.py
+++ b/util/check_zephyr_project_config_unittest.py
@@ -52,7 +52,7 @@ class TestKconfigCheck(unittest.TestCase):
parse_modules_mock.assert_called_once_with(
check_zephyr_project_config.ZEPHYR_BASE,
- extra_modules=[check_zephyr_project_config.EC_BASE],
+ modules=[check_zephyr_project_config.EC_BASE],
)
process_kconfig_mock.assert_called_once_with("project", "meta")
kconfig_mock.assert_called_once_with(
@@ -83,9 +83,7 @@ class TestKconfigCheck(unittest.TestCase):
kconfig_mock.assert_called_once_with(kconfig_path)
self.assertEqual(process_kconfig_mock.call_count, 0)
- parse_modules_mock.assert_called_once_with(
- mock.ANY, extra_modules=mock.ANY
- )
+ parse_modules_mock.assert_called_once_with(mock.ANY, modules=mock.ANY)
@mock.patch("pathlib.Path.is_file")
@mock.patch("check_zephyr_project_config.KconfigCheck._init_kconfig")
diff --git a/util/config_allowed.txt b/util/config_allowed.txt
index 160e208c21..3c792ae0fb 100644
--- a/util/config_allowed.txt
+++ b/util/config_allowed.txt
@@ -842,7 +842,6 @@ CONFIG_TEMP_SENSOR_ADT7481
CONFIG_TEMP_SENSOR_AMD_R19ME4070
CONFIG_TEMP_SENSOR_BD99992GW
CONFIG_TEMP_SENSOR_EC_ADC
-CONFIG_TEMP_SENSOR_F75303
CONFIG_TEMP_SENSOR_G753
CONFIG_TEMP_SENSOR_G781
CONFIG_TEMP_SENSOR_G782
diff --git a/zephyr/CMakeLists.txt b/zephyr/CMakeLists.txt
index 25ce9f0f27..5fd91e2335 100644
--- a/zephyr/CMakeLists.txt
+++ b/zephyr/CMakeLists.txt
@@ -393,6 +393,8 @@ zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_TEMP_SENSOR_SB_TSI
"${PLATFORM_EC}/driver/temp_sensor/sb_tsi.c")
zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_TEMP_SENSOR_TMP112
"${PLATFORM_EC}/driver/temp_sensor/tmp112.c")
+zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_TEMP_SENSOR_F75303
+ "${PLATFORM_EC}/driver/temp_sensor/f75303.c")
zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_THROTTLE_AP
"${PLATFORM_EC}/common/throttle_ap.c")
zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_TIMER
diff --git a/zephyr/Kconfig b/zephyr/Kconfig
index 597e6ee250..38e2efe751 100644
--- a/zephyr/Kconfig
+++ b/zephyr/Kconfig
@@ -137,6 +137,18 @@ config PLATFORM_EC_BOARD_RESET_AFTER_POWER_ON
the EC starts up, performs some amount of processing and then gets a
reset that it is not expecting.
+config PLATFORM_EC_BOOT_NO_SLEEP
+ bool "Disable deep sleep after boot"
+ default y if !ZTEST
+ help
+ Disable deep sleep for PLATFORM_EC_BOOT_NO_SLEEP_MS after boot.
+
+config PLATFORM_EC_BOOT_NO_SLEEP_MS
+ int "No deep sleep after boot duration"
+ default 15000
+ help
+ Duration for PLATFORM_EC_BOOT_NO_SLEEP in ms.
+
config PLATFORM_EC_WAIT_RESET_CYCLES_PER_ITERATION
int "CPU execution cycle per iteration for waiting the H1 reset"
default 4
diff --git a/zephyr/Kconfig.charger b/zephyr/Kconfig.charger
index 30a2426870..131f40e4d3 100644
--- a/zephyr/Kconfig.charger
+++ b/zephyr/Kconfig.charger
@@ -786,6 +786,13 @@ config PLATFORM_EC_ISL9238C_ENABLE_BUCK_MODE
Enable Force Buck mode for ISL9238C.
If the Force Buck mode is enabled, the Buck-Boost window narrows.
+config PLATFORM_EC_ISL9238C_BUCK_PHASE_VOLTAGE
+ int "Value of phase comparator threshold offset"
+ default 0
+ help
+ Adjusts the phase comparator threshold offset for forward buck
+ and buck-boost.
+
config PLATFORM_EC_AC_PROCHOT_CURRENT_MA
int "Value of the prochot threshold current in mA"
default 3328
diff --git a/zephyr/Kconfig.tcpm b/zephyr/Kconfig.tcpm
index d2783e9f0a..6651336954 100644
--- a/zephyr/Kconfig.tcpm
+++ b/zephyr/Kconfig.tcpm
@@ -236,6 +236,20 @@ config PLATFORM_EC_USB_PD_TCPM_RAA489000
Build drivers for the RAA489000, a combined battery charger and USB-C
TCPCI.
+if PLATFORM_EC_USB_PD_TCPM_RAA489000
+
+config PLATFORM_EC_RAA489000_OCP_UV_THRESHOLD_MV
+ int "Undervoltage threshold while sourcing VBUS (mV)"
+ default 4750
+ help
+ Sets the RAA489000 undervoltage theshold when sourcing VBUS, in mV.
+
+ If VBUS drops below this level while sourcing, the chip disables sourcing
+ under the assumption that too much current was being drawn. Rated accuracy
+ of this measurement is 5%, with 25 mV resolution.
+
+endif
+
config PLATFORM_EC_USB_PD_TCPM_RT1715
bool "Richtek RT1715 Type-C Port Controller"
help
diff --git a/zephyr/Kconfig.temperature b/zephyr/Kconfig.temperature
index b1f6e63c96..bd977b2832 100644
--- a/zephyr/Kconfig.temperature
+++ b/zephyr/Kconfig.temperature
@@ -66,6 +66,14 @@ config PLATFORM_EC_TEMP_SENSOR_TMP112
Enables support for the CrosEC TMP112 driver, an i2c peripheral
temperature sensor from TI.
+config PLATFORM_EC_TEMP_SENSOR_F75303
+ bool "F75303 support"
+ default y
+ depends on DT_HAS_CROS_EC_TEMP_SENSOR_F75303_ENABLED
+ help
+ Enables support for the CrosEC F75303 driver, an i2c peripheral
+ temperature sensor from TI.
+
endif # PLATFORM_EC_TEMP_SENSOR
diff --git a/zephyr/app/ec/ec_app_main.c b/zephyr/app/ec/ec_app_main.c
index 961e4f5ce2..160156f7bb 100644
--- a/zephyr/app/ec/ec_app_main.c
+++ b/zephyr/app/ec/ec_app_main.c
@@ -18,9 +18,16 @@
#include "zephyr_espi_shim.h"
#include <zephyr/kernel.h>
+#include <zephyr/pm/policy.h>
#include <zephyr/shell/shell_uart.h>
#include <zephyr/sys/printk.h>
+static struct k_timer timer;
+static void console_allow_sleep(struct k_timer *timer)
+{
+ pm_policy_state_lock_put(PM_STATE_SUSPEND_TO_IDLE, PM_ALL_SUBSTATES);
+}
+
/* For testing purposes this is not named main. See main_shim.c for the real
* main() function.
*/
@@ -42,6 +49,17 @@ void ec_app_main(void)
watchdog_init();
}
+ if (IS_ENABLED(CONFIG_PLATFORM_EC_BOOT_NO_SLEEP)) {
+ k_timeout_t duration =
+ K_MSEC(CONFIG_PLATFORM_EC_BOOT_NO_SLEEP_MS);
+
+ k_timer_init(&timer, console_allow_sleep, NULL);
+ k_timer_start(&timer, duration, K_NO_WAIT);
+
+ pm_policy_state_lock_get(PM_STATE_SUSPEND_TO_IDLE,
+ PM_ALL_SUBSTATES);
+ }
+
/*
* Keyboard scan init/Button init can set recovery events to
* indicate to host entry into recovery mode. Before this is
diff --git a/zephyr/boards/arm/stm32g4/Kconfig.board b/zephyr/boards/arm/stm32g4/Kconfig.board
new file mode 100644
index 0000000000..115115b5fc
--- /dev/null
+++ b/zephyr/boards/arm/stm32g4/Kconfig.board
@@ -0,0 +1,10 @@
+# Copyright 2023 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.
+
+config BOARD_STM32G4_G473
+ bool "STM32G473"
+ depends on SOC_STM32G473XX
+ # Enables support for the STM32 HAL drivers
+ select HAS_STM32CUBE
+ select USE_STM32_HAL_CORTEX
diff --git a/zephyr/boards/arm/stm32g4/Kconfig.defconfig b/zephyr/boards/arm/stm32g4/Kconfig.defconfig
new file mode 100644
index 0000000000..f22cbf7879
--- /dev/null
+++ b/zephyr/boards/arm/stm32g4/Kconfig.defconfig
@@ -0,0 +1,6 @@
+# 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.
+
+config BOARD
+ default "stm32g473" if BOARD_STM32G4_G473
diff --git a/zephyr/boards/arm/stm32g4/stm32g473.dts b/zephyr/boards/arm/stm32g4/stm32g473.dts
new file mode 100644
index 0000000000..0c8c63f936
--- /dev/null
+++ b/zephyr/boards/arm/stm32g4/stm32g473.dts
@@ -0,0 +1,18 @@
+/* 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.
+ */
+
+/dts-v1/;
+
+#include <st/g4/stm32g473Xc.dtsi>
+#include <st/g4/stm32g473m(b-c-e)tx-pinctrl.dtsi>
+
+/ {
+ model = "STMicroelectronics STM32G473";
+ compatible = "st,stm32g473";
+
+ chosen {
+ zephyr,sram = &sram0;
+ };
+};
diff --git a/zephyr/boards/arm/stm32g4/stm32g473_defconfig b/zephyr/boards/arm/stm32g4/stm32g473_defconfig
new file mode 100644
index 0000000000..5df31bb6f0
--- /dev/null
+++ b/zephyr/boards/arm/stm32g4/stm32g473_defconfig
@@ -0,0 +1,32 @@
+# 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.
+
+
+# SOC Config
+CONFIG_ARM_MPU=y
+CONFIG_SOC_SERIES_STM32G4X=y
+CONFIG_SOC_STM32G473XX=y
+
+# Pinctrl Driver
+CONFIG_PINCTRL=y
+
+# GPIO Controller
+CONFIG_GPIO=y
+
+# Enable sys_reboot
+CONFIG_REBOOT=y
+
+# Clock configuration
+CONFIG_CLOCK_CONTROL=y
+
+# Watchdog configuration
+CONFIG_WATCHDOG=y
+
+# Enable HW Stack protection
+CONFIG_HW_STACK_PROTECTION=y
+
+# USB configuration
+CONFIG_USB_DEVICE_MANUFACTURER="Google Inc."
+CONFIG_USB_DEVICE_VID=0x18d1
+
diff --git a/zephyr/dts/bindings/temp/cros-ec,temp-sensor-f75303.yaml b/zephyr/dts/bindings/temp/cros-ec,temp-sensor-f75303.yaml
new file mode 100644
index 0000000000..3ef0bca2ac
--- /dev/null
+++ b/zephyr/dts/bindings/temp/cros-ec,temp-sensor-f75303.yaml
@@ -0,0 +1,10 @@
+# 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.
+
+description: >
+ Properties for a F75303 I2C temperature sensor
+
+compatible: "cros-ec,temp-sensor-f75303"
+
+include: i2c-device.yaml
diff --git a/zephyr/emul/emul_bb_retimer.c b/zephyr/emul/emul_bb_retimer.c
index 8028c53c0f..10f0fa591d 100644
--- a/zephyr/emul/emul_bb_retimer.c
+++ b/zephyr/emul/emul_bb_retimer.c
@@ -328,7 +328,7 @@ static int bb_emul_init(const struct emul *emul, const struct device *parent)
.addr = DT_INST_REG_ADDR(n), \
}; \
EMUL_DT_INST_DEFINE(n, bb_emul_init, &bb_emul_data_##n, \
- &bb_emul_cfg_##n, &i2c_common_emul_api)
+ &bb_emul_cfg_##n, &i2c_common_emul_api, NULL)
DT_INST_FOREACH_STATUS_OKAY(BB_RETIMER_EMUL)
diff --git a/zephyr/emul/emul_bma255.c b/zephyr/emul/emul_bma255.c
index 2afe1f722e..cd85c74872 100644
--- a/zephyr/emul/emul_bma255.c
+++ b/zephyr/emul/emul_bma255.c
@@ -1005,7 +1005,7 @@ static int bma_emul_init(const struct emul *emul, const struct device *parent)
.addr = DT_INST_REG_ADDR(n), \
}; \
EMUL_DT_INST_DEFINE(n, bma_emul_init, &bma_emul_data_##n, \
- &bma_emul_cfg_##n, &i2c_common_emul_api)
+ &bma_emul_cfg_##n, &i2c_common_emul_api, NULL)
DT_INST_FOREACH_STATUS_OKAY(BMA255_EMUL)
diff --git a/zephyr/emul/emul_bmi.c b/zephyr/emul/emul_bmi.c
index d0f5691402..f80c8202b1 100644
--- a/zephyr/emul/emul_bmi.c
+++ b/zephyr/emul/emul_bmi.c
@@ -1105,7 +1105,7 @@ static int bmi_emul_init(const struct emul *emul, const struct device *parent)
.addr = DT_INST_REG_ADDR(n), \
}; \
EMUL_DT_INST_DEFINE(n, bmi_emul_init, &bmi_emul_data_##n, \
- &bmi_emul_cfg_##n, &i2c_common_emul_api)
+ &bmi_emul_cfg_##n, &i2c_common_emul_api, NULL)
DT_INST_FOREACH_STATUS_OKAY(BMI_EMUL)
diff --git a/zephyr/emul/emul_isl923x.c b/zephyr/emul/emul_isl923x.c
index d46f1131d4..42401b94f9 100644
--- a/zephyr/emul/emul_isl923x.c
+++ b/zephyr/emul/emul_isl923x.c
@@ -435,7 +435,7 @@ static int emul_isl923x_init(const struct emul *emul,
}, \
}; \
EMUL_DT_INST_DEFINE(n, emul_isl923x_init, &isl923x_emul_data_##n, \
- &isl923x_emul_cfg_##n, &i2c_common_emul_api)
+ &isl923x_emul_cfg_##n, &i2c_common_emul_api, NULL)
DT_INST_FOREACH_STATUS_OKAY(INIT_ISL923X)
diff --git a/zephyr/emul/emul_lis2dw12.c b/zephyr/emul/emul_lis2dw12.c
index 547e74912c..cd04cd27b5 100644
--- a/zephyr/emul/emul_lis2dw12.c
+++ b/zephyr/emul/emul_lis2dw12.c
@@ -293,7 +293,8 @@ void lis2dw12_emul_clear_accel_reading(const struct emul *emul)
}, \
}; \
EMUL_DT_INST_DEFINE(n, emul_lis2dw12_init, &lis2dw12_emul_data_##n, \
- &lis2dw12_emul_cfg_##n, &i2c_common_emul_api)
+ &lis2dw12_emul_cfg_##n, &i2c_common_emul_api, \
+ NULL)
DT_INST_FOREACH_STATUS_OKAY(INIT_LIS2DW12)
DT_INST_FOREACH_STATUS_OKAY(EMUL_STUB_DEVICE);
diff --git a/zephyr/emul/emul_ln9310.c b/zephyr/emul/emul_ln9310.c
index 9d6a0197a0..21cfa74a27 100644
--- a/zephyr/emul/emul_ln9310.c
+++ b/zephyr/emul/emul_ln9310.c
@@ -505,7 +505,7 @@ static int emul_ln9310_init(const struct emul *emul,
.addr = DT_INST_REG_ADDR(n), \
}; \
EMUL_DT_INST_DEFINE(n, emul_ln9310_init, &ln9310_emul_data_##n, \
- &ln9310_emul_cfg_##n, &i2c_common_emul_api)
+ &ln9310_emul_cfg_##n, &i2c_common_emul_api, NULL)
DT_INST_FOREACH_STATUS_OKAY(INIT_LN9310)
DT_INST_FOREACH_STATUS_OKAY(EMUL_STUB_DEVICE);
diff --git a/zephyr/emul/emul_pct2075.c b/zephyr/emul/emul_pct2075.c
index cfd172b6dc..3388db4ad4 100644
--- a/zephyr/emul/emul_pct2075.c
+++ b/zephyr/emul/emul_pct2075.c
@@ -100,7 +100,7 @@ static int pct2075_emul_init(const struct emul *emul,
}, \
}; \
EMUL_DT_INST_DEFINE(n, pct2075_emul_init, &pct2075_data_##n, \
- &common_cfg_##n, &i2c_common_emul_api)
+ &common_cfg_##n, &i2c_common_emul_api, NULL)
DT_INST_FOREACH_STATUS_OKAY(INIT_PCT2075_EMUL)
diff --git a/zephyr/emul/emul_pi3usb9201.c b/zephyr/emul/emul_pi3usb9201.c
index a722fc3039..ca3818a812 100644
--- a/zephyr/emul/emul_pi3usb9201.c
+++ b/zephyr/emul/emul_pi3usb9201.c
@@ -174,7 +174,8 @@ static int pi3usb9201_emul_init(const struct emul *emul,
}; \
EMUL_DT_INST_DEFINE(n, pi3usb9201_emul_init, \
&pi3usb9201_emul_data_##n, \
- &pi3usb9201_emul_cfg_##n, &pi3usb9201_emul_api)
+ &pi3usb9201_emul_cfg_##n, &pi3usb9201_emul_api, \
+ NULL)
DT_INST_FOREACH_STATUS_OKAY(PI3USB9201_EMUL)
diff --git a/zephyr/emul/emul_rt9490.c b/zephyr/emul/emul_rt9490.c
index 1775bc9235..290ae6c4da 100644
--- a/zephyr/emul/emul_rt9490.c
+++ b/zephyr/emul/emul_rt9490.c
@@ -115,7 +115,7 @@ static int rt9490_emul_init(const struct emul *emul,
.common = { .cfg = &common_cfg_##n } \
}; \
EMUL_DT_INST_DEFINE(n, rt9490_emul_init, &rt9490_data_##n, \
- &common_cfg_##n, &i2c_common_emul_api)
+ &common_cfg_##n, &i2c_common_emul_api, NULL)
DT_INST_FOREACH_STATUS_OKAY(INIT_RT9490_EMUL)
diff --git a/zephyr/emul/emul_smart_battery.c b/zephyr/emul/emul_smart_battery.c
index acada754d7..a935a71921 100644
--- a/zephyr/emul/emul_smart_battery.c
+++ b/zephyr/emul/emul_smart_battery.c
@@ -885,7 +885,7 @@ DT_INST_FOREACH_STATUS_OKAY(SMART_BATTERY_VALIDATE_STRING_PROPS_SIZE)
.addr = DT_INST_REG_ADDR(n), \
}; \
EMUL_DT_INST_DEFINE(n, sbat_emul_init, &sbat_emul_data_##n, \
- &sbat_emul_cfg_##n, &i2c_common_emul_api)
+ &sbat_emul_cfg_##n, &i2c_common_emul_api, NULL)
DT_INST_FOREACH_STATUS_OKAY(SMART_BATTERY_EMUL)
diff --git a/zephyr/emul/emul_sn5s330.c b/zephyr/emul/emul_sn5s330.c
index 96342abf70..36f21775c5 100644
--- a/zephyr/emul/emul_sn5s330.c
+++ b/zephyr/emul/emul_sn5s330.c
@@ -348,7 +348,7 @@ static int emul_sn5s330_init(const struct emul *emul,
}, \
}; \
EMUL_DT_INST_DEFINE(n, emul_sn5s330_init, &sn5s330_emul_data_##n, \
- &sn5s330_emul_cfg_##n, &i2c_common_emul_api)
+ &sn5s330_emul_cfg_##n, &i2c_common_emul_api, NULL)
DT_INST_FOREACH_STATUS_OKAY(INIT_SN5S330)
DT_INST_FOREACH_STATUS_OKAY(EMUL_STUB_DEVICE);
diff --git a/zephyr/emul/emul_syv682x.c b/zephyr/emul/emul_syv682x.c
index 68c1a84e15..712dca2276 100644
--- a/zephyr/emul/emul_syv682x.c
+++ b/zephyr/emul/emul_syv682x.c
@@ -270,7 +270,7 @@ static int syv682x_emul_init(const struct emul *emul,
}, \
}; \
EMUL_DT_INST_DEFINE(n, syv682x_emul_init, &syv682x_emul_data_##n, \
- &syv682x_emul_cfg_##n, &i2c_common_emul_api)
+ &syv682x_emul_cfg_##n, &i2c_common_emul_api, NULL)
DT_INST_FOREACH_STATUS_OKAY(SYV682X_EMUL)
diff --git a/zephyr/emul/emul_tcs3400.c b/zephyr/emul/emul_tcs3400.c
index 0266fe2998..fe64acf791 100644
--- a/zephyr/emul/emul_tcs3400.c
+++ b/zephyr/emul/emul_tcs3400.c
@@ -616,7 +616,7 @@ static int tcs_emul_init(const struct emul *emul, const struct device *parent)
.addr = DT_INST_REG_ADDR(n), \
}; \
EMUL_DT_INST_DEFINE(n, tcs_emul_init, &tcs_emul_data_##n, \
- &tcs_emul_cfg_##n, &i2c_common_emul_api)
+ &tcs_emul_cfg_##n, &i2c_common_emul_api, NULL)
DT_INST_FOREACH_STATUS_OKAY(TCS3400_EMUL)
diff --git a/zephyr/emul/emul_tusb1064.c b/zephyr/emul/emul_tusb1064.c
index 866493bc32..292fd8f4c6 100644
--- a/zephyr/emul/emul_tusb1064.c
+++ b/zephyr/emul/emul_tusb1064.c
@@ -101,7 +101,7 @@ static int tusb1064_emul_init(const struct emul *emul,
.common = { .cfg = &common_cfg_##n } \
}; \
EMUL_DT_INST_DEFINE(n, tusb1064_emul_init, &tusb1064_data_##n, \
- &common_cfg_##n, &i2c_common_emul_api)
+ &common_cfg_##n, &i2c_common_emul_api, NULL)
DT_INST_FOREACH_STATUS_OKAY(INIT_TUSB1064_EMUL)
diff --git a/zephyr/emul/i2c_mock.c b/zephyr/emul/i2c_mock.c
index c906e76c13..cb5d7fc729 100644
--- a/zephyr/emul/i2c_mock.c
+++ b/zephyr/emul/i2c_mock.c
@@ -63,7 +63,7 @@ static int i2c_mock_init(const struct emul *emul, const struct device *parent)
}; \
static struct i2c_common_emul_data i2c_mock_data_##n; \
EMUL_DT_INST_DEFINE(n, i2c_mock_init, &i2c_mock_data_##n, \
- &i2c_mock_cfg_##n, &i2c_common_emul_api)
+ &i2c_mock_cfg_##n, &i2c_common_emul_api, NULL)
DT_INST_FOREACH_STATUS_OKAY(INIT_I2C_MOCK)
diff --git a/zephyr/emul/tcpc/emul_anx7447.c b/zephyr/emul/tcpc/emul_anx7447.c
index fb15e2eb4e..26d172f90f 100644
--- a/zephyr/emul/tcpc/emul_anx7447.c
+++ b/zephyr/emul/tcpc/emul_anx7447.c
@@ -146,7 +146,7 @@ struct i2c_emul_api i2c_anx7447_emul_api = {
#define ANX7447_EMUL(n) \
TCPCI_EMUL_DEFINE(n, anx7447_emul_init, NULL, NULL, \
- &i2c_anx7447_emul_api)
+ &i2c_anx7447_emul_api, NULL)
DT_INST_FOREACH_STATUS_OKAY(ANX7447_EMUL)
diff --git a/zephyr/emul/tcpc/emul_ps8xxx.c b/zephyr/emul/tcpc/emul_ps8xxx.c
index d0be005144..fc94b4f9d6 100644
--- a/zephyr/emul/tcpc/emul_ps8xxx.c
+++ b/zephyr/emul/tcpc/emul_ps8xxx.c
@@ -676,7 +676,7 @@ static int ps8xxx_emul_init(const struct emul *emul,
}, \
}; \
TCPCI_EMUL_DEFINE(n, ps8xxx_emul_init, &ps8xxx_emul_cfg_##n, \
- &ps8xxx_emul_data_##n, &i2c_ps8xxx_emul_api)
+ &ps8xxx_emul_data_##n, &i2c_ps8xxx_emul_api, NULL)
DT_INST_FOREACH_STATUS_OKAY(PS8XXX_EMUL)
diff --git a/zephyr/emul/tcpc/emul_tcpci_generic.c b/zephyr/emul/tcpc/emul_tcpci_generic.c
index 01fae7c978..3b6695f953 100644
--- a/zephyr/emul/tcpc/emul_tcpci_generic.c
+++ b/zephyr/emul/tcpc/emul_tcpci_generic.c
@@ -153,7 +153,7 @@ struct i2c_emul_api i2c_tcpci_generic_emul_api = {
#define TCPCI_GENERIC_EMUL(n) \
TCPCI_EMUL_DEFINE(n, tcpci_generic_emul_init, NULL, NULL, \
- &i2c_tcpci_generic_emul_api)
+ &i2c_tcpci_generic_emul_api, NULL)
DT_INST_FOREACH_STATUS_OKAY(TCPCI_GENERIC_EMUL)
diff --git a/zephyr/include/emul/tcpc/emul_tcpci.h b/zephyr/include/emul/tcpc/emul_tcpci.h
index 8badf7dbc4..5a7777d6ad 100644
--- a/zephyr/include/emul/tcpc/emul_tcpci.h
+++ b/zephyr/include/emul/tcpc/emul_tcpci.h
@@ -95,7 +95,8 @@ struct tcpc_emul_data {
const struct i2c_common_emul_cfg i2c_cfg;
};
-#define TCPCI_EMUL_DEFINE(n, init, cfg_ptr, chip_data_ptr, bus_api) \
+#define TCPCI_EMUL_DEFINE(n, init, cfg_ptr, chip_data_ptr, bus_api, \
+ backend_api) \
static uint8_t tcpci_emul_tx_buf_##n[128]; \
static struct tcpci_emul_msg tcpci_emul_tx_msg_##n = { \
.buf = tcpci_emul_tx_buf_##n, \
@@ -123,7 +124,8 @@ struct tcpc_emul_data {
.addr = DT_INST_REG_ADDR(n), \
}, \
}; \
- EMUL_DT_INST_DEFINE(n, init, &tcpc_emul_data_##n, cfg_ptr, bus_api)
+ EMUL_DT_INST_DEFINE(n, init, &tcpc_emul_data_##n, cfg_ptr, bus_api, \
+ backend_api)
/** Response from TCPCI specific device operations */
enum tcpci_emul_ops_resp {
diff --git a/zephyr/program/nissa/craask/project.conf b/zephyr/program/nissa/craask/project.conf
index fd66e4f7c5..f530f0f54e 100644
--- a/zephyr/program/nissa/craask/project.conf
+++ b/zephyr/program/nissa/craask/project.conf
@@ -14,6 +14,10 @@ CONFIG_PLATFORM_EC_DYNAMIC_MOTION_SENSOR_COUNT=y
CONFIG_PLATFORM_EC_BUTTONS_RUNTIME_CONFIG=y
+# Flash space saving
+# Turning off extended console help saves ~3500 bytes
+CONFIG_SHELL_HELP=n
+
# Keyboard
CONFIG_PLATFORM_EC_KEYBOARD_KEYPAD=y
CONFIG_PLATFORM_EC_KEYBOARD_FACTORY_TEST=y
diff --git a/zephyr/program/nissa/pujjo/project.conf b/zephyr/program/nissa/pujjo/project.conf
index da8ac6b6df..7bc035a7cd 100644
--- a/zephyr/program/nissa/pujjo/project.conf
+++ b/zephyr/program/nissa/pujjo/project.conf
@@ -35,3 +35,6 @@ CONFIG_PLATFORM_EC_USB_PORT_POWER_SMART=y
CONFIG_PLATFORM_EC_USB_PORT_POWER_SMART_CDP_SDP_ONLY=y
CONFIG_PLATFORM_EC_USB_PORT_POWER_SMART_DEFAULT_CDP=y
CONFIG_PLATFORM_EC_USB_PORT_POWER_SMART_INVERTED=y
+
+#OCP
+CONFIG_PLATFORM_EC_RAA489000_OCP_UV_THRESHOLD_MV=4000 \ No newline at end of file
diff --git a/zephyr/program/nissa/xivu/src/form_factor.c b/zephyr/program/nissa/xivu/src/form_factor.c
index 51632c2f6b..bfb3eee466 100644
--- a/zephyr/program/nissa/xivu/src/form_factor.c
+++ b/zephyr/program/nissa/xivu/src/form_factor.c
@@ -22,22 +22,34 @@
LOG_MODULE_DECLARE(nissa, CONFIG_NISSA_LOG_LEVEL);
-static bool use_alt_sensor;
-static bool use_alt_lid_accel;
+enum motionsense_type {
+ motion_none = 0,
+ motion_bmi323,
+ motion_lsm6dso,
+};
+
+enum lid_accel_type {
+ lid_none = 0,
+ lid_bma422,
+ lid_lis2dw12,
+};
+
+static int use_sensor = motion_bmi323;
+static int use_lid_accel = lid_bma422;
void motion_interrupt(enum gpio_signal signal)
{
- if (use_alt_sensor)
+ if (use_sensor == motion_bmi323)
bmi3xx_interrupt(signal);
- else
+ else if (use_sensor == motion_lsm6dso)
lsm6dso_interrupt(signal);
}
void lid_accel_interrupt(enum gpio_signal signal)
{
- if (use_alt_lid_accel)
+ if (use_lid_accel == lid_bma422)
bma4xx_interrupt(signal);
- else
+ else if (use_lid_accel == lid_lis2dw12)
lis2dw12_interrupt(signal);
}
@@ -45,33 +57,42 @@ static void form_factor_init(void)
{
if (cros_cbi_ssfc_check_match(
CBI_SSFC_VALUE_ID(DT_NODELABEL(base_sensor_bmi323)))) {
- use_alt_sensor = true;
+ use_sensor = motion_bmi323;
MOTIONSENSE_ENABLE_ALTERNATE(alt_base_accel);
MOTIONSENSE_ENABLE_ALTERNATE(alt_base_gyro);
ccprints("BASE ACCEL IS BMI323");
} else if (cros_cbi_ssfc_check_match(CBI_SSFC_VALUE_ID(
DT_NODELABEL(base_sensor_lsm6dso)))) {
- use_alt_sensor = false;
+ use_sensor = motion_lsm6dso;
ccprints("BASE ACCEL IS LSM6DSO");
} else {
- use_alt_sensor = false;
+ use_sensor = motion_none;
ccprints("no motionsense");
}
if (cros_cbi_ssfc_check_match(
CBI_SSFC_VALUE_ID(DT_NODELABEL(lid_sensor_bma422)))) {
- use_alt_lid_accel = true;
+ use_lid_accel = lid_bma422;
MOTIONSENSE_ENABLE_ALTERNATE(alt_lid_accel);
ccprints("LID SENSOR IS BMA422");
} else if (cros_cbi_ssfc_check_match(CBI_SSFC_VALUE_ID(
DT_NODELABEL(lid_sensor_lis2dw12)))) {
- use_alt_lid_accel = false;
+ use_lid_accel = lid_lis2dw12;
ccprints("LID SENSOR IS LIS2DW12");
} else {
- use_alt_lid_accel = false;
+ use_lid_accel = lid_none;
ccprints("no lid sensor");
}
- motion_sensors_check_ssfc();
+ if (use_sensor && use_lid_accel) {
+ motion_sensors_check_ssfc();
+ } else {
+ 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);
+ ccprints("Clamshell: disable motionsense function.");
+ }
}
DECLARE_HOOK(HOOK_INIT, form_factor_init, HOOK_PRIO_POST_I2C);
diff --git a/zephyr/program/rex/rex/project.conf b/zephyr/program/rex/rex/project.conf
index 9d812d8e04..d81aa30d5e 100644
--- a/zephyr/program/rex/rex/project.conf
+++ b/zephyr/program/rex/rex/project.conf
@@ -4,3 +4,6 @@
# Rex-NPCX9 reference-board-specific Kconfig settings.
CONFIG_BOARD_REX=y
+
+# Ensure recovery key combination (esc+refresh+power) is reliable: b/260555509
+CONFIG_PLATFORM_EC_KEYBOARD_PWRBTN_ASSERTS_KSI2=y
diff --git a/zephyr/program/skyrim/markarth/project.overlay b/zephyr/program/skyrim/markarth/project.overlay
index d59c9712df..4f4ce9fd7a 100644
--- a/zephyr/program/skyrim/markarth/project.overlay
+++ b/zephyr/program/skyrim/markarth/project.overlay
@@ -49,7 +49,7 @@
named-temp-sensors {
compatible = "cros-ec,temp-sensors";
- soc-pct2075 {
+ soc-f75303 {
temp_host_high = <100>;
temp_host_halt = <105>;
temp_host_release_high = <80>;
@@ -57,11 +57,11 @@
temp_fan_off = <35>;
temp_fan_max = <70>;
power-good-pin = <&gpio_pg_pwr_s5>;
- sensor = <&soc_pct2075>;
+ sensor = <&soc_f75303>;
};
- amb-pct2075 {
+ amb-f75303 {
power-good-pin = <&gpio_pg_pwr_s5>;
- sensor = <&amb_pct2075>;
+ sensor = <&amb_f75303>;
};
};
@@ -184,3 +184,22 @@
&usbc_port1 {
/delete-property/ bc12;
};
+
+&i2c6_1 {
+ /delete-node/ soc-pct2075@48;
+ /delete-node/ amb-pct2075@4f;
+ soc_f75303: soc-f75303@48 {
+ compatible = "cros-ec,temp-sensor-f75303";
+ reg = <0x48>;
+ };
+
+ amb_f75303: amb-f75303@4f {
+ compatible = "cros-ec,temp-sensor-f75303";
+ reg = <0x4f>;
+ };
+};
+
+&i2c_sensor {
+ /delete-node/ enum-names;
+ enum-names = "I2C_PORT_THERMAL";
+}; \ No newline at end of file
diff --git a/zephyr/program/skyrim/program.conf b/zephyr/program/skyrim/program.conf
index 69642809c7..255169bede 100644
--- a/zephyr/program/skyrim/program.conf
+++ b/zephyr/program/skyrim/program.conf
@@ -8,7 +8,6 @@ CONFIG_SHIMMED_TASKS=y
CONFIG_ESPI=y
# Shell features
-CONFIG_SHELL_HELP=y
CONFIG_SHELL_HISTORY=y
CONFIG_SHELL_TAB=y
CONFIG_SHELL_TAB_AUTOCOMPLETION=y
@@ -130,6 +129,7 @@ CONFIG_FLASH_PAGE_LAYOUT=n # 1876 bytes
CONFIG_FLASH_SHELL=n # 1852 bytes
CONFIG_PLATFORM_EC_CONSOLE_CMD_ACCEL_INFO=n # 656 bytes
CONFIG_PLATFORM_EC_CONSOLE_CMD_MEM=n # 896 bytes
-# CONFIG_PLATFORM_EC_CONSOLE_CMD_TCPC_DUMP=n # 1180 bytes
+CONFIG_PLATFORM_EC_CONSOLE_CMD_TCPC_DUMP=n # 1180 bytes
CONFIG_PLATFORM_EC_CONSOLE_CMD_USB_PD_CABLE=n # 1104 bytes
+CONFIG_SHELL_HELP=n # 3432 bytes
CONFIG_THREAD_MONITOR=n # 1548 bytes
diff --git a/zephyr/program/skyrim/src/stt.c b/zephyr/program/skyrim/src/stt.c
index 40743fbc68..e6a87c8d9f 100644
--- a/zephyr/program/skyrim/src/stt.c
+++ b/zephyr/program/skyrim/src/stt.c
@@ -6,6 +6,7 @@
/* Support code for STT temperature reporting */
#include "chipset.h"
+#include "driver/temp_sensor/f75303.h"
#include "temp_sensor/pct2075.h"
#include "temp_sensor/temp_sensor.h"
@@ -14,8 +15,13 @@ int board_get_soc_temp_mk(int *temp_mk)
if (chipset_in_state(CHIPSET_STATE_HARD_OFF))
return EC_ERROR_NOT_POWERED;
+#ifdef CONFIG_TEMP_SENSOR_PCT2075
return pct2075_get_val_mk(PCT2075_SENSOR_ID(DT_NODELABEL(soc_pct2075)),
temp_mk);
+#else
+ return f75303_get_val_mk(F75303_SENSOR_ID(DT_NODELABEL(soc_f75303)),
+ temp_mk);
+#endif
}
int board_get_ambient_temp_mk(int *temp_mk)
@@ -23,6 +29,11 @@ int board_get_ambient_temp_mk(int *temp_mk)
if (chipset_in_state(CHIPSET_STATE_HARD_OFF))
return EC_ERROR_NOT_POWERED;
+#ifdef CONFIG_TEMP_SENSOR_PCT2075
return pct2075_get_val_mk(PCT2075_SENSOR_ID(DT_NODELABEL(amb_pct2075)),
temp_mk);
+#else
+ return f75303_get_val_mk(F75303_SENSOR_ID(DT_NODELABEL(amb_f75303)),
+ temp_mk);
+#endif
}
diff --git a/zephyr/program/skyrim/winterhold/project.conf b/zephyr/program/skyrim/winterhold/project.conf
index c962d95abe..9938196f0c 100644
--- a/zephyr/program/skyrim/winterhold/project.conf
+++ b/zephyr/program/skyrim/winterhold/project.conf
@@ -21,6 +21,9 @@ CONFIG_PLATFORM_EC_CHARGER_ISL9238C=y
CONFIG_PLATFORM_EC_ISL9238C_ENABLE_BUCK_MODE=y
CONFIG_PLATFORM_EC_CHARGER_PROFILE_OVERRIDE=y
+# Forward Buck Phase Comparator bit<15:13> to 100=-4mV
+CONFIG_PLATFORM_EC_ISL9238C_BUCK_PHASE_VOLTAGE=4
+
# Get the vbus voltage from TCPC
CONFIG_PLATFORM_EC_USB_PD_VBUS_MEASURE_CHARGER=n
CONFIG_PLATFORM_EC_USB_PD_VBUS_MEASURE_TCPC=y
diff --git a/zephyr/program/skyrim/winterhold/project.overlay b/zephyr/program/skyrim/winterhold/project.overlay
index 07958c4660..fbbc1f2b88 100644
--- a/zephyr/program/skyrim/winterhold/project.overlay
+++ b/zephyr/program/skyrim/winterhold/project.overlay
@@ -58,8 +58,8 @@
temp_host_halt = <110>;
temp_host_release_high = <95>;
temp_host_release_halt = <100>;
- temp_fan_off = <42>;
- temp_fan_max = <70>;
+ temp_fan_off = <55>;
+ temp_fan_max = <75>;
power-good-pin = <&gpio_pg_pwr_s5>;
sensor = <&soc_pct2075>;
};
@@ -190,7 +190,7 @@
&fan0 {
pwms = <&pwm0 0 PWM_KHZ(2) PWM_POLARITY_NORMAL>;
rpm_min = <2100>;
- rpm_start = <2600>;
+ rpm_start = <2800>;
rpm_max = <4800>;
};
@@ -213,8 +213,8 @@
/delete-property/ temp_host_high;
/delete-property/ temp_host_halt;
/delete-property/ temp_host_release_high;
- temp_fan_off = <54>;
- temp_fan_max = <67>;
+ temp_fan_off = <62>;
+ temp_fan_max = <72>;
};
/* handler overrides */
diff --git a/zephyr/program/skyrim/winterhold/src/thermal.c b/zephyr/program/skyrim/winterhold/src/thermal.c
index dcc0562fff..e2c5e13298 100644
--- a/zephyr/program/skyrim/winterhold/src/thermal.c
+++ b/zephyr/program/skyrim/winterhold/src/thermal.c
@@ -13,7 +13,11 @@
#define CPRINTS(format, args...) cprints(CC_THERMAL, format, ##args)
#define CPRINTF(format, args...) cprintf(CC_THERMAL, format, ##args)
+/*AMB sensor for thermal tabel control*/
#define TEMP_AMB TEMP_SENSOR_ID(DT_NODELABEL(temp_sensor_amb))
+/*SOC and CPU sensor for fan tabel control*/
+#define TEMP_SOC TEMP_SENSOR_ID(DT_NODELABEL(temp_sensor_soc))
+#define TEMP_CPU TEMP_SENSOR_ID(DT_NODELABEL(temp_sensor_cpu))
/*
* TODO(b/202062363): Remove when clang is fixed.
@@ -59,12 +63,12 @@ __maybe_unused static const struct ec_thermal_config thermal_desktop_lid_close =
#define THERMAL_LAPTOP \
{ \
.temp_host = { \
- [EC_TEMP_THRESH_WARN] = C_TO_K(44), \
+ [EC_TEMP_THRESH_WARN] = C_TO_K(42), \
[EC_TEMP_THRESH_HIGH] = C_TO_K(105), \
[EC_TEMP_THRESH_HALT] = C_TO_K(110), \
}, \
.temp_host_release = { \
- [EC_TEMP_THRESH_WARN] = C_TO_K(40), \
+ [EC_TEMP_THRESH_WARN] = C_TO_K(38), \
[EC_TEMP_THRESH_HIGH] = C_TO_K(95), \
[EC_TEMP_THRESH_HALT] = C_TO_K(100), \
}, \
@@ -72,6 +76,93 @@ __maybe_unused static const struct ec_thermal_config thermal_desktop_lid_close =
__maybe_unused static const struct ec_thermal_config thermal_laptop =
THERMAL_LAPTOP;
+/*
+ * TODO(b/202062363): Remove when clang is fixed.
+ */
+#define FAN_SOC_DESKTOP_LID_OPEN \
+ { \
+ .temp_host = { \
+ [EC_TEMP_THRESH_HIGH] = C_TO_K(105), \
+ [EC_TEMP_THRESH_HALT] = C_TO_K(110), \
+ }, \
+ .temp_host_release = { \
+ [EC_TEMP_THRESH_HIGH] = C_TO_K(95), \
+ [EC_TEMP_THRESH_HALT] = C_TO_K(100), \
+ }, \
+ .temp_fan_off = C_TO_K(55), \
+ .temp_fan_max = C_TO_K(75), \
+ }
+__maybe_unused static const struct ec_thermal_config fan_soc_desktop_lid_open =
+ FAN_SOC_DESKTOP_LID_OPEN;
+
+/*
+ * TODO(b/202062363): Remove when clang is fixed.
+ */
+#define FAN_SOC_DESKTOP_LID_CLOSE \
+ { \
+ .temp_host = { \
+ [EC_TEMP_THRESH_HIGH] = C_TO_K(105), \
+ [EC_TEMP_THRESH_HALT] = C_TO_K(110), \
+ }, \
+ .temp_host_release = { \
+ [EC_TEMP_THRESH_HIGH] = C_TO_K(95), \
+ [EC_TEMP_THRESH_HALT] = C_TO_K(100), \
+ }, \
+ .temp_fan_off = C_TO_K(55), \
+ .temp_fan_max = C_TO_K(75), \
+ }
+__maybe_unused static const struct ec_thermal_config fan_soc_desktop_lid_close =
+ FAN_SOC_DESKTOP_LID_CLOSE;
+
+/*
+ * TODO(b/202062363): Remove when clang is fixed.
+ */
+#define FAN_SOC_LAPTOP \
+ { \
+ .temp_host = { \
+ [EC_TEMP_THRESH_HIGH] = C_TO_K(105), \
+ [EC_TEMP_THRESH_HALT] = C_TO_K(110), \
+ }, \
+ .temp_host_release = { \
+ [EC_TEMP_THRESH_HIGH] = C_TO_K(95), \
+ [EC_TEMP_THRESH_HALT] = C_TO_K(100), \
+ }, \
+ .temp_fan_off = C_TO_K(51), \
+ .temp_fan_max = C_TO_K(71), \
+ }
+__maybe_unused static const struct ec_thermal_config fan_soc_laptop =
+ FAN_SOC_LAPTOP;
+
+/*
+ * TODO(b/202062363): Remove when clang is fixed.
+ */
+#define FAN_CPU_DESKTOP_LID_OPEN \
+ { \
+ .temp_fan_off = C_TO_K(62), .temp_fan_max = C_TO_K(72), \
+ }
+__maybe_unused static const struct ec_thermal_config fan_cpu_desktop_lid_open =
+ FAN_CPU_DESKTOP_LID_OPEN;
+
+/*
+ * TODO(b/202062363): Remove when clang is fixed.
+ */
+#define FAN_CPU_DESKTOP_LID_CLOSE \
+ { \
+ .temp_fan_off = C_TO_K(62), .temp_fan_max = C_TO_K(72), \
+ }
+__maybe_unused static const struct ec_thermal_config fan_cpu_desktop_lid_close =
+ FAN_CPU_DESKTOP_LID_CLOSE;
+
+/*
+ * TODO(b/202062363): Remove when clang is fixed.
+ */
+#define FAN_CPU_LAPTOP \
+ { \
+ .temp_fan_off = C_TO_K(58), .temp_fan_max = C_TO_K(68), \
+ }
+__maybe_unused static const struct ec_thermal_config fan_cpu_laptop =
+ FAN_CPU_LAPTOP;
+
static int last_amb_temp = -1;
/* Switch thermal table when mode change */
@@ -82,13 +173,19 @@ static void thermal_table_switch(void)
if (body_state == BODY_DETECTION_OFF_BODY) {
if (lid_is_open()) {
thermal_params[TEMP_AMB] = thermal_desktop_lid_open;
+ thermal_params[TEMP_SOC] = fan_soc_desktop_lid_open;
+ thermal_params[TEMP_CPU] = fan_cpu_desktop_lid_open;
CPRINTS("Thermal: Desktop lid open mode");
} else {
thermal_params[TEMP_AMB] = thermal_desktop_lid_close;
+ thermal_params[TEMP_SOC] = fan_soc_desktop_lid_close;
+ thermal_params[TEMP_CPU] = fan_cpu_desktop_lid_close;
CPRINTS("Thermal: Desktop lid close mode");
}
} else {
thermal_params[TEMP_AMB] = thermal_laptop;
+ thermal_params[TEMP_SOC] = fan_soc_laptop;
+ thermal_params[TEMP_CPU] = fan_cpu_laptop;
CPRINTS("Thermal: Laptop mode");
}
}
diff --git a/zephyr/shim/include/config_chip.h b/zephyr/shim/include/config_chip.h
index ee79496035..7ecb3b0f13 100644
--- a/zephyr/shim/include/config_chip.h
+++ b/zephyr/shim/include/config_chip.h
@@ -367,6 +367,12 @@
#define CONFIG_ISL9238C_ENABLE_BUCK_MODE
#endif
+#undef CONFIG_ISL9238C_BUCK_PHASE_VOLTAGE
+#ifdef CONFIG_PLATFORM_EC_ISL9238C_BUCK_PHASE_VOLTAGE
+#define CONFIG_ISL9238C_BUCK_PHASE_VOLTAGE \
+ CONFIG_PLATFORM_EC_ISL9238C_BUCK_PHASE_VOLTAGE
+#endif
+
#undef CONFIG_AC_PROCHOT_CURRENT_MA
#ifdef CONFIG_PLATFORM_EC_AC_PROCHOT_CURRENT_MA
#define CONFIG_AC_PROCHOT_CURRENT_MA CONFIG_PLATFORM_EC_AC_PROCHOT_CURRENT_MA
@@ -672,6 +678,11 @@ extern char mock_jump_data[CONFIG_PLATFORM_EC_PRESERVED_END_OF_RAM_SIZE];
#define CONFIG_TEMP_SENSOR_TMP112
#endif
+#undef CONFIG_TEMP_SENSOR_F75303
+#ifdef CONFIG_PLATFORM_EC_TEMP_SENSOR_F75303
+#define CONFIG_TEMP_SENSOR_F75303
+#endif
+
#undef CONFIG_FANS
#ifdef CONFIG_PLATFORM_EC_NUM_FANS
#define CONFIG_FANS CONFIG_PLATFORM_EC_NUM_FANS
diff --git a/zephyr/shim/include/temp_sensor/temp_sensor.h b/zephyr/shim/include/temp_sensor/temp_sensor.h
index 5e4cca3063..5ff7662d62 100644
--- a/zephyr/shim/include/temp_sensor/temp_sensor.h
+++ b/zephyr/shim/include/temp_sensor/temp_sensor.h
@@ -15,6 +15,7 @@
#define PCT2075_COMPAT nxp_pct2075
#define TMP112_COMPAT cros_ec_temp_sensor_tmp112
+#define F75303_COMPAT cros_ec_temp_sensor_f75303
#define SB_TSI_COMPAT amd_sb_tsi
#define THERMISTOR_COMPAT cros_ec_temp_sensor_thermistor
#define TEMP_SENSORS_COMPAT cros_ec_temp_sensors
@@ -27,6 +28,7 @@
#define FOREACH_TEMP_SENSOR(fn) \
DT_FOREACH_STATUS_OKAY(PCT2075_COMPAT, fn) \
DT_FOREACH_STATUS_OKAY(TMP112_COMPAT, fn) \
+ DT_FOREACH_STATUS_OKAY(F75303_COMPAT, fn) \
DT_FOREACH_STATUS_OKAY_VARGS(RT9490_CHG_COMPAT, TEMP_RT9490_FN, fn) \
DT_FOREACH_STATUS_OKAY(SB_TSI_COMPAT, fn) \
DT_FOREACH_STATUS_OKAY(THERMISTOR_COMPAT, fn)
@@ -141,6 +143,22 @@ enum tmp112_sensor {
#undef TMP112_SENSOR_ID_WITH_COMMA
+/* F75303 access array */
+/*
+ * Get the F75303 sensor ID from a hardware device node.
+ *
+ * @param node_id: node id of a hardware F75303 sensor node
+ */
+#define F75303_SENSOR_ID(node_id) DT_CAT(F75303_, node_id)
+#define F75303_SENSOR_ID_WITH_COMMA(node_id) F75303_SENSOR_ID(node_id),
+
+enum f75303_sensor {
+ DT_FOREACH_STATUS_OKAY(F75303_COMPAT, F75303_SENSOR_ID_WITH_COMMA)
+ F75303_IDX_COUNT,
+};
+
+#undef F75303_SENSOR_ID_WITH_COMMA
+
struct zephyr_temp_sensor {
/* Read sensor value in K into temp_ptr; return non-zero if error. */
int (*read)(const struct temp_sensor_t *sensor, int *temp_ptr);
diff --git a/zephyr/shim/src/temp_sensors.c b/zephyr/shim/src/temp_sensors.c
index ae3a367252..439ea917f9 100644
--- a/zephyr/shim/src/temp_sensors.c
+++ b/zephyr/shim/src/temp_sensors.c
@@ -6,6 +6,7 @@
#include "adc.h"
#include "charger/chg_rt9490.h"
#include "driver/charger/rt9490.h"
+#include "driver/temp_sensor/f75303.h"
#include "hooks.h"
#include "temp_sensor.h"
#include "temp_sensor/pct2075.h"
@@ -198,6 +199,42 @@ const struct tmp112_sensor_t tmp112_sensors[TMP112_COUNT] = {
DT_FOREACH_STATUS_OKAY(TMP112_COMPAT, DEFINE_TMP112_DATA)
};
+#if DT_HAS_COMPAT_STATUS_OKAY(F75303_COMPAT)
+/* The function maybe unused because a temperature sensor can be added to dts
+ * without a reference in the cros_ec_temp_sensors node.
+ */
+__maybe_unused static int f75303_get_temp(const struct temp_sensor_t *sensor,
+ int *temp_ptr)
+{
+ return f75303_get_val_k(sensor->idx, temp_ptr);
+}
+#endif /* f75303_COMPAT */
+
+#define DEFINE_F75303_DATA(node_id) \
+ [F75303_SENSOR_ID(node_id)] = { \
+ .i2c_port = I2C_PORT_BY_DEV(node_id), \
+ .i2c_addr_flags = DT_REG_ADDR(node_id), \
+ },
+
+#define GET_ZEPHYR_TEMP_SENSOR_F75303(named_id) \
+ (&(const struct zephyr_temp_sensor){ \
+ .read = &f75303_get_temp, \
+ .thermistor = NULL, \
+ .update_temperature = f75303_update_temperature, \
+ FILL_POWER_GOOD(named_id) })
+
+#define TEMP_F75303(named_id, sensor_id) \
+ [TEMP_SENSOR_ID(named_id)] = { \
+ .name = DT_NODE_FULL_NAME(sensor_id), \
+ .idx = F75303_SENSOR_ID(sensor_id), \
+ .type = TEMP_SENSOR_TYPE_BOARD, \
+ .zephyr_info = GET_ZEPHYR_TEMP_SENSOR_F75303(named_id), \
+ }
+
+const struct f75303_sensor_t f75303_sensors[F75303_IDX_COUNT] = {
+ DT_FOREACH_STATUS_OKAY(F75303_COMPAT, DEFINE_F75303_DATA)
+};
+
/* There can be only one thermistor on RT9490 with current driver */
#define ADD_ONE(node_id) 1 +
#if DT_FOREACH_STATUS_OKAY_VARGS(RT9490_CHG_COMPAT, TEMP_RT9490_FN, \
@@ -235,7 +272,8 @@ const struct tmp112_sensor_t tmp112_sensors[TMP112_COUNT] = {
CHECK_COMPAT(PCT2075_COMPAT, named_id, sensor_id, TEMP_PCT2075) \
CHECK_COMPAT(SB_TSI_COMPAT, named_id, sensor_id, TEMP_SB_TSI) \
CHECK_COMPAT(TMP112_COMPAT, named_id, sensor_id, TEMP_TMP112) \
- CHECK_COMPAT(RT9490_CHG_COMPAT, named_id, sensor_id, TEMP_RT9490)
+ CHECK_COMPAT(RT9490_CHG_COMPAT, named_id, sensor_id, TEMP_RT9490) \
+ CHECK_COMPAT(F75303_COMPAT, named_id, sensor_id, TEMP_F75303)
#define TEMP_SENSOR_ENTRY(named_id) \
TEMP_SENSOR_FIND(named_id, DT_PHANDLE(named_id, sensor))
diff --git a/zephyr/test/drivers/i2c_controller/src/basic_i2c_device_emul.c b/zephyr/test/drivers/i2c_controller/src/basic_i2c_device_emul.c
index 8d00d5d3ba..926fa6152f 100644
--- a/zephyr/test/drivers/i2c_controller/src/basic_i2c_device_emul.c
+++ b/zephyr/test/drivers/i2c_controller/src/basic_i2c_device_emul.c
@@ -105,7 +105,7 @@ static int basic_i2c_device_init(const struct emul *emul,
}; \
EMUL_DT_INST_DEFINE(n, basic_i2c_device_init, \
&basic_i2c_device_data_##n, &common_cfg_##n, \
- &i2c_common_emul_api)
+ &i2c_common_emul_api, NULL)
DT_INST_FOREACH_STATUS_OKAY(INIT_BASIC_I2C_DEVICE_EMUL);
diff --git a/zephyr/test/skyrim/CMakeLists.txt b/zephyr/test/skyrim/CMakeLists.txt
new file mode 100644
index 0000000000..8fbcc78432
--- /dev/null
+++ b/zephyr/test/skyrim/CMakeLists.txt
@@ -0,0 +1,15 @@
+# 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.
+
+cmake_minimum_required(VERSION 3.13.1)
+find_package(Zephyr REQUIRED HINTS "${ZEPHYR_BASE}")
+project(skyrim)
+
+zephyr_include_directories("${PLATFORM_EC_PROGRAM_DIR}/skyrim/include")
+
+add_subdirectory(${PLATFORM_EC}/zephyr/test/test_utils test_utils)
+
+target_sources(app PRIVATE src/${CONFIG_TEST_BOARD_NAME}/common.c)
+
+target_sources_ifdef(CONFIG_TEST_BOARD_USB_PD_POLICY app PRIVATE src/baseboard/usb_pd_policy.c ${PLATFORM_EC_PROGRAM_DIR}/skyrim/src/usb_pd_policy.c) \ No newline at end of file
diff --git a/zephyr/test/skyrim/Kconfig b/zephyr/test/skyrim/Kconfig
new file mode 100644
index 0000000000..41685834be
--- /dev/null
+++ b/zephyr/test/skyrim/Kconfig
@@ -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.
+
+choice TEST_BOARD_VARIANT
+ prompt "Select board variant for tests"
+ help
+ Board variant to use for tests
+
+ config TEST_BOARD_BASEBOARD
+ bool "Enable baseboard-specific tests"
+ help
+ Enable baseboard tests.
+
+ config TEST_BOARD_CRYSTALDRIFT
+ bool "Enable crystaldrift-specific tests"
+ help
+ Enable tests for crystaldrift variant.
+
+ config TEST_BOARD_FROSTFLOW
+ bool "Enable frostflow-specific tests"
+ help
+ Enable tests for frostflow variant.
+
+ config TEST_BOARD_MARKARTH
+ bool "Enable markarth-specific tests"
+ help
+ Enable tests for markarth variant.
+
+ config TEST_BOARD_SKYRIM
+ bool "Enable skyrim-specific tests"
+ help
+ Enable tests for skyrim variant.
+
+ config TEST_BOARD_WINTERHOLD
+ bool "Enable winterhold-specific tests"
+ help
+ Enable tests for winterhold variant.
+
+endchoice # TEST_BOARD_VARIANT
+
+config TEST_BOARD_NAME
+ string "Board name"
+ default "baseboard" if TEST_BOARD_BASEBOARD
+ default "crystaldrift" if TEST_BOARD_CRYSTALDRIFT
+ default "frostflow" if TEST_BOARD_FROSTFLOW
+ default "markarth" if TEST_BOARD_MARKARTH
+ default "skyrim" if TEST_BOARD_SKYRIM
+ default "winterhold" if TEST_BOARD_WINTERHOLD
+
+config TEST_BOARD_USB_PD_POLICY
+ bool "Enable USB PD policy specific tests"
+ select TEST_ENABLE_USB_PD_HOST_CMD
+ default n
+
+config TEST_ENABLE_USB_PD_HOST_CMD
+ bool "Fake config to enable this feature"
+ default n
+
+config USB_PD_DISCHARGE
+ bool "Fake config to enable this feature"
+ default n
+
+source "Kconfig.zephyr"
diff --git a/zephyr/test/skyrim/boards/native_posix.overlay b/zephyr/test/skyrim/boards/native_posix.overlay
new file mode 100644
index 0000000000..7328610584
--- /dev/null
+++ b/zephyr/test/skyrim/boards/native_posix.overlay
@@ -0,0 +1,33 @@
+/* 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 <board-overlays/native_posix.dts>
+#include <dt-bindings/gpio_defines.h>
+
+/ {
+ /* GPIOs shared by all boards */
+ named-gpios {
+ compatible = "named-gpios";
+
+ gpio_pg_pwr_s5: pg_pwr_s5 {
+ gpios = <&gpio0 0 GPIO_INPUT>;
+ enum-name = "GPIO_S5_PGOOD";
+ };
+
+ gpio_usb_c0_tcpc_fastsw_ctl_en: usb_c0_tcpc_fastsw_ctl_en {
+ gpios = <&gpio0 1 GPIO_OUTPUT_LOW>;
+ enum-name = "IOEX_USB_C0_TCPC_FASTSW_CTL_EN";
+ };
+
+ gpio_usb_c1_tcpc_fastsw_ctl_en: usb_c1_tcpc_fastsw_ctl_en {
+ gpios = <&gpio0 2 GPIO_OUTPUT_LOW>;
+ enum-name = "IOEX_USB_C1_TCPC_FASTSW_CTL_EN";
+ };
+ };
+};
+
+&gpio0 {
+ ngpios = <23>;
+}; \ No newline at end of file
diff --git a/zephyr/test/skyrim/prj.conf b/zephyr/test/skyrim/prj.conf
new file mode 100644
index 0000000000..77f7eab5a2
--- /dev/null
+++ b/zephyr/test/skyrim/prj.conf
@@ -0,0 +1,13 @@
+# 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.
+
+CONFIG_ZTEST=y
+CONFIG_ZTEST_ASSERT_VERBOSE=1
+CONFIG_ZTEST_NEW_API=y
+CONFIG_ASSERT=y
+
+CONFIG_CROS_EC=y
+CONFIG_PLATFORM_EC=y
+CONFIG_EMUL=y
+CONFIG_GPIO=y
diff --git a/zephyr/test/skyrim/src/baseboard/common.c b/zephyr/test/skyrim/src/baseboard/common.c
new file mode 100644
index 0000000000..841b7db140
--- /dev/null
+++ b/zephyr/test/skyrim/src/baseboard/common.c
@@ -0,0 +1,7 @@
+/* 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 <zephyr/ztest.h>
+
+ZTEST_SUITE(common, NULL, NULL, NULL, NULL, NULL);
diff --git a/zephyr/test/skyrim/src/baseboard/usb_pd_policy.c b/zephyr/test/skyrim/src/baseboard/usb_pd_policy.c
new file mode 100644
index 0000000000..1a8e5e8805
--- /dev/null
+++ b/zephyr/test/skyrim/src/baseboard/usb_pd_policy.c
@@ -0,0 +1,263 @@
+/* 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 <zephyr/drivers/gpio.h>
+#include <zephyr/drivers/gpio/gpio_emul.h>
+#include <zephyr/fff.h>
+#include <zephyr/ztest.h>
+
+#include <gpio.h>
+#include <ioexpander.h>
+#include <usb_pd.h>
+
+FAKE_VALUE_FUNC(int, ppc_vbus_source_enable, int, int);
+FAKE_VOID_FUNC(pd_set_vbus_discharge, int, int);
+FAKE_VOID_FUNC(pd_send_host_event, int);
+FAKE_VALUE_FUNC(bool, tcpm_get_src_ctrl, int);
+FAKE_VALUE_FUNC(int, ppc_vbus_sink_enable, int, int);
+
+int board_is_sourcing_vbus(int port);
+
+ZTEST(usb_pd_policy, pd_check_vconn_swap)
+{
+ const struct gpio_dt_spec *gpio =
+ GPIO_DT_FROM_NODELABEL(gpio_pg_pwr_s5);
+
+ /*
+ * The value of pd_check_vconn_swap should follow gpio_pg_pwr_s5
+ * for all ports.
+ */
+ zassert_ok(gpio_emul_input_set(gpio->port, gpio->pin, true));
+ zassert_true(pd_check_vconn_swap(0));
+ zassert_true(pd_check_vconn_swap(1));
+
+ zassert_ok(gpio_emul_input_set(gpio->port, gpio->pin, false));
+ zassert_false(pd_check_vconn_swap(0));
+ zassert_false(pd_check_vconn_swap(1));
+}
+
+ZTEST(usb_pd_policy, pd_power_supply_reset_c0_success)
+{
+ ppc_vbus_source_enable_fake.return_val = EC_SUCCESS;
+ ppc_vbus_sink_enable_fake.return_val = EC_SUCCESS;
+
+ pd_power_supply_reset(0);
+
+ zassert_equal(ppc_vbus_source_enable_fake.call_count, 1);
+ /* port */
+ zassert_equal(ppc_vbus_source_enable_fake.arg0_val, 0);
+ /* enable */
+ zassert_equal(ppc_vbus_source_enable_fake.arg1_val, 0);
+
+ if (IS_ENABLED(CONFIG_USB_PD_DISCHARGE)) {
+ zassert_equal(pd_set_vbus_discharge_fake.call_count, 1);
+ /* port */
+ zassert_equal(pd_set_vbus_discharge_fake.arg0_val, 0);
+ /* enable */
+ zassert_equal(pd_set_vbus_discharge_fake.arg1_val, 1);
+ }
+
+ zassert_equal(pd_send_host_event_fake.call_count, 1);
+}
+
+ZTEST(usb_pd_policy, pd_power_supply_reset_c1_success)
+{
+ ppc_vbus_source_enable_fake.return_val = EC_SUCCESS;
+ ppc_vbus_sink_enable_fake.return_val = EC_SUCCESS;
+
+ pd_power_supply_reset(1);
+
+ zassert_equal(ppc_vbus_source_enable_fake.call_count, 1);
+ /* port */
+ zassert_equal(ppc_vbus_source_enable_fake.arg0_val, 1);
+ /* enable */
+ zassert_equal(ppc_vbus_source_enable_fake.arg1_val, 0);
+
+ if (IS_ENABLED(CONFIG_USB_PD_DISCHARGE)) {
+ zassert_equal(pd_set_vbus_discharge_fake.call_count, 1);
+ /* port */
+ zassert_equal(pd_set_vbus_discharge_fake.arg0_val, 1);
+ /* enable */
+ zassert_equal(pd_set_vbus_discharge_fake.arg1_val, 1);
+ }
+
+ zassert_equal(pd_send_host_event_fake.call_count, 1);
+}
+
+ZTEST(usb_pd_policy, pd_set_power_supply_ready_c0_success)
+{
+ ppc_vbus_source_enable_fake.return_val = EC_SUCCESS;
+ ppc_vbus_sink_enable_fake.return_val = EC_SUCCESS;
+
+ zassert_equal(pd_set_power_supply_ready(0), EC_SUCCESS);
+
+ zassert_equal(ppc_vbus_sink_enable_fake.call_count, 1);
+ /* port */
+ zassert_equal(ppc_vbus_sink_enable_fake.arg0_val, 0);
+ /* enable */
+ zassert_equal(ppc_vbus_sink_enable_fake.arg1_val, 0);
+
+ if (IS_ENABLED(CONFIG_USB_PD_DISCHARGE)) {
+ zassert_equal(pd_set_vbus_discharge_fake.call_count, 1);
+ /* port */
+ zassert_equal(pd_set_vbus_discharge_fake.arg0_val, 0);
+ /* enable */
+ zassert_equal(pd_set_vbus_discharge_fake.arg1_val, 0);
+ }
+
+ zassert_equal(ppc_vbus_source_enable_fake.call_count, 1);
+ /* port */
+ zassert_equal(ppc_vbus_source_enable_fake.arg0_val, 0);
+ /* enable */
+ zassert_equal(ppc_vbus_source_enable_fake.arg1_val, 1);
+
+ zassert_equal(pd_send_host_event_fake.call_count, 1);
+}
+
+ZTEST(usb_pd_policy, pd_set_power_supply_ready_c1_success)
+{
+ ppc_vbus_source_enable_fake.return_val = EC_SUCCESS;
+ ppc_vbus_sink_enable_fake.return_val = EC_SUCCESS;
+
+ zassert_equal(pd_set_power_supply_ready(1), EC_SUCCESS);
+
+ zassert_equal(ppc_vbus_sink_enable_fake.call_count, 1);
+ /* port */
+ zassert_equal(ppc_vbus_sink_enable_fake.arg0_val, 1);
+ /* enable */
+ zassert_equal(ppc_vbus_sink_enable_fake.arg1_val, 0);
+
+ if (IS_ENABLED(CONFIG_USB_PD_DISCHARGE)) {
+ zassert_equal(pd_set_vbus_discharge_fake.call_count, 1);
+ /* port */
+ zassert_equal(pd_set_vbus_discharge_fake.arg0_val, 1);
+ /* enable */
+ zassert_equal(pd_set_vbus_discharge_fake.arg1_val, 0);
+ }
+
+ zassert_equal(ppc_vbus_source_enable_fake.call_count, 1);
+ /* port */
+ zassert_equal(ppc_vbus_source_enable_fake.arg0_val, 1);
+ /* enable */
+ zassert_equal(ppc_vbus_source_enable_fake.arg1_val, 1);
+
+ zassert_equal(pd_send_host_event_fake.call_count, 1);
+}
+
+ZTEST(usb_pd_policy, pd_set_power_supply_ready_c0_failure)
+{
+ /* Test with ppc_vbus_sink_enable_fake failing. */
+ ppc_vbus_sink_enable_fake.return_val = EC_ERROR_INVAL;
+ zassert_not_equal(pd_set_power_supply_ready(0), EC_SUCCESS);
+ zassert_equal(ppc_vbus_sink_enable_fake.call_count, 1);
+ /* port */
+ zassert_equal(ppc_vbus_sink_enable_fake.arg0_val, 0);
+ /* enable */
+ zassert_equal(ppc_vbus_sink_enable_fake.arg1_val, 0);
+
+ /* Test with ppc_vbus_source_enable failing. */
+ ppc_vbus_sink_enable_fake.return_val = EC_SUCCESS;
+ ppc_vbus_source_enable_fake.return_val = EC_ERROR_INVAL;
+ zassert_not_equal(pd_set_power_supply_ready(0), EC_SUCCESS);
+ zassert_equal(ppc_vbus_source_enable_fake.call_count, 1);
+ /* port */
+ zassert_equal(ppc_vbus_source_enable_fake.arg0_val, 0);
+ /* enable */
+ zassert_equal(ppc_vbus_source_enable_fake.arg1_val, 1);
+
+ zassert_equal(pd_send_host_event_fake.call_count, 0);
+}
+
+ZTEST(usb_pd_policy, pd_set_power_supply_ready_c1_failure)
+{
+ /* Test with ppc_vbus_sink_enable_fake failing. */
+ ppc_vbus_sink_enable_fake.return_val = EC_ERROR_INVAL;
+ zassert_not_equal(pd_set_power_supply_ready(1), EC_SUCCESS);
+ zassert_equal(ppc_vbus_sink_enable_fake.call_count, 1);
+ /* port */
+ zassert_equal(ppc_vbus_sink_enable_fake.arg0_val, 1);
+ /* enable */
+ zassert_equal(ppc_vbus_sink_enable_fake.arg1_val, 0);
+
+ /* Test with ppc_vbus_source_enable failing. */
+ ppc_vbus_sink_enable_fake.return_val = EC_SUCCESS;
+ ppc_vbus_source_enable_fake.return_val = EC_ERROR_INVAL;
+ zassert_not_equal(pd_set_power_supply_ready(1), EC_SUCCESS);
+ zassert_equal(ppc_vbus_source_enable_fake.call_count, 1);
+ /* port */
+ zassert_equal(ppc_vbus_source_enable_fake.arg0_val, 1);
+ /* enable */
+ zassert_equal(ppc_vbus_source_enable_fake.arg1_val, 1);
+
+ zassert_equal(pd_send_host_event_fake.call_count, 0);
+}
+
+ZTEST(usb_pd_policy, board_pd_set_frs_enable)
+{
+ const struct gpio_dt_spec *c0 =
+ GPIO_DT_FROM_NODELABEL(gpio_usb_c0_tcpc_fastsw_ctl_en);
+ const struct gpio_dt_spec *c1 =
+ GPIO_DT_FROM_NODELABEL(gpio_usb_c1_tcpc_fastsw_ctl_en);
+
+ /* Enables to each port should just change the corresponding GPIO. */
+ zassert_equal(board_pd_set_frs_enable(0, true), EC_SUCCESS);
+ zassert_equal(gpio_emul_output_get(c0->port, c0->pin), 1);
+
+ zassert_equal(board_pd_set_frs_enable(0, false), EC_SUCCESS);
+ zassert_equal(gpio_emul_output_get(c0->port, c0->pin), 0);
+
+ zassert_equal(board_pd_set_frs_enable(1, true), EC_SUCCESS);
+ zassert_equal(gpio_emul_output_get(c1->port, c1->pin), 1);
+
+ zassert_equal(board_pd_set_frs_enable(1, false), EC_SUCCESS);
+ zassert_equal(gpio_emul_output_get(c1->port, c1->pin), 0);
+}
+
+ZTEST(usb_pd_policy, board_is_sourcing_vbus_c0_true)
+{
+ tcpm_get_src_ctrl_fake.return_val = true;
+ zassert_true(board_is_sourcing_vbus(0));
+ zassert_equal(tcpm_get_src_ctrl_fake.call_count, 1);
+ /* port */
+ zassert_equal(tcpm_get_src_ctrl_fake.arg0_val, 0);
+}
+
+ZTEST(usb_pd_policy, board_is_sourcing_vbus_c0_false)
+{
+ tcpm_get_src_ctrl_fake.return_val = false;
+ zassert_false(board_is_sourcing_vbus(0));
+ zassert_equal(tcpm_get_src_ctrl_fake.call_count, 1);
+ /* port */
+ zassert_equal(tcpm_get_src_ctrl_fake.arg0_val, 0);
+}
+
+ZTEST(usb_pd_policy, board_is_sourcing_vbus_c1_true)
+{
+ tcpm_get_src_ctrl_fake.return_val = true;
+ zassert_true(board_is_sourcing_vbus(1));
+ zassert_equal(tcpm_get_src_ctrl_fake.call_count, 1);
+ /* port */
+ zassert_equal(tcpm_get_src_ctrl_fake.arg0_val, 1);
+}
+
+ZTEST(usb_pd_policy, board_is_sourcing_vbus_c1_false)
+{
+ tcpm_get_src_ctrl_fake.return_val = false;
+ zassert_false(board_is_sourcing_vbus(1));
+ zassert_equal(tcpm_get_src_ctrl_fake.call_count, 1);
+ /* port */
+ zassert_equal(tcpm_get_src_ctrl_fake.arg0_val, 1);
+}
+
+static void usb_pd_policy_before(void *fixture)
+{
+ ARG_UNUSED(fixture);
+ RESET_FAKE(ppc_vbus_source_enable);
+ RESET_FAKE(pd_set_vbus_discharge);
+ RESET_FAKE(pd_send_host_event);
+ RESET_FAKE(tcpm_get_src_ctrl);
+ RESET_FAKE(ppc_vbus_sink_enable);
+}
+
+ZTEST_SUITE(usb_pd_policy, NULL, NULL, usb_pd_policy_before, NULL, NULL);
diff --git a/zephyr/test/skyrim/src/crystaldrift/common.c b/zephyr/test/skyrim/src/crystaldrift/common.c
new file mode 100644
index 0000000000..841b7db140
--- /dev/null
+++ b/zephyr/test/skyrim/src/crystaldrift/common.c
@@ -0,0 +1,7 @@
+/* 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 <zephyr/ztest.h>
+
+ZTEST_SUITE(common, NULL, NULL, NULL, NULL, NULL);
diff --git a/zephyr/test/skyrim/src/frostflow/common.c b/zephyr/test/skyrim/src/frostflow/common.c
new file mode 100644
index 0000000000..841b7db140
--- /dev/null
+++ b/zephyr/test/skyrim/src/frostflow/common.c
@@ -0,0 +1,7 @@
+/* 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 <zephyr/ztest.h>
+
+ZTEST_SUITE(common, NULL, NULL, NULL, NULL, NULL);
diff --git a/zephyr/test/skyrim/src/markarth/common.c b/zephyr/test/skyrim/src/markarth/common.c
new file mode 100644
index 0000000000..841b7db140
--- /dev/null
+++ b/zephyr/test/skyrim/src/markarth/common.c
@@ -0,0 +1,7 @@
+/* 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 <zephyr/ztest.h>
+
+ZTEST_SUITE(common, NULL, NULL, NULL, NULL, NULL);
diff --git a/zephyr/test/skyrim/src/skyrim/common.c b/zephyr/test/skyrim/src/skyrim/common.c
new file mode 100644
index 0000000000..841b7db140
--- /dev/null
+++ b/zephyr/test/skyrim/src/skyrim/common.c
@@ -0,0 +1,7 @@
+/* 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 <zephyr/ztest.h>
+
+ZTEST_SUITE(common, NULL, NULL, NULL, NULL, NULL);
diff --git a/zephyr/test/skyrim/src/winterhold/common.c b/zephyr/test/skyrim/src/winterhold/common.c
new file mode 100644
index 0000000000..841b7db140
--- /dev/null
+++ b/zephyr/test/skyrim/src/winterhold/common.c
@@ -0,0 +1,7 @@
+/* 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 <zephyr/ztest.h>
+
+ZTEST_SUITE(common, NULL, NULL, NULL, NULL, NULL);
diff --git a/zephyr/test/skyrim/testcase.yaml b/zephyr/test/skyrim/testcase.yaml
new file mode 100644
index 0000000000..29d22a2fcd
--- /dev/null
+++ b/zephyr/test/skyrim/testcase.yaml
@@ -0,0 +1,47 @@
+# 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.
+
+common:
+ platform_allow: native_posix
+tests:
+ # Baseboard tests
+ skyrim.baseboard:
+ extra_configs:
+ - CONFIG_TEST_BOARD_BASEBOARD=y
+
+ skyrim.baseboard.usb_pd_policy:
+ extra_configs:
+ - CONFIG_TEST_BOARD_BASEBOARD=y
+ - CONFIG_TEST_BOARD_USB_PD_POLICY=y
+
+ skyrim.baseboard.usb_pd_policy.discharge:
+ extra_configs:
+ - CONFIG_TEST_BOARD_BASEBOARD=y
+ - CONFIG_TEST_BOARD_USB_PD_POLICY=y
+ - CONFIG_USB_PD_DISCHARGE=y
+
+ # Crystaldrift tests
+ skyrim.crystaldrift:
+ extra_configs:
+ - CONFIG_TEST_BOARD_CRYSTALDRIFT=y
+
+ # Frostflow tests
+ skyrim.frostflow:
+ extra_configs:
+ - CONFIG_TEST_BOARD_FROSTFLOW=y
+
+ # Markarth tests
+ skyrim.markarth:
+ extra_configs:
+ - CONFIG_TEST_BOARD_MARKARTH=y
+
+ # Skyrim tests
+ skyrim.skyrim:
+ extra_configs:
+ - CONFIG_TEST_BOARD_SKYRIM=y
+
+ # Winterhold tests
+ skyrim.winterhold:
+ extra_configs:
+ - CONFIG_TEST_BOARD_WINTERHOLD=y