summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAbe Levkoy <alevkoy@chromium.org>2021-01-26 09:39:13 -0700
committerAbe Levkoy <alevkoy@chromium.org>2021-01-26 16:45:57 +0000
commit5cd37974006fe1e69fefbfbd169a17c9bb498d8a (patch)
tree8af7967ba45e5cb92c9e61d1b2a9537e0e249fb4
parent6bf5cfa646533f89674164a3dd1edb34589f089d (diff)
parent1fff129e5ddfe20c2c1513835e06c4e4d8f57608 (diff)
downloadchrome-ec-5cd37974006fe1e69fefbfbd169a17c9bb498d8a.tar.gz
Merge remote-tracking branch 'cros/main' into firmware-volteer-13672.B-main
Sync with main. Includes the following changes: 1fff129e5 (m/master, cros/main) zmake: remove prefer-zephyr-sdk from project config 7d2680152 zephyr: kohaku/volteer: unset prefer-zephyr-sdk e40faf973 zephyr: Use Chrome EC's libgcc implementation over the compiler's 774e4bfab drawcia: Set gyroscope translation matrix 6bd8ba080 voema: Initialize the vivaldi keyboard. 0ba6f7f8c zork: add support SSFC e10667e30 voxel: Enable CONFIG_KEYBOARD_VIVALDI 061ca8397 Metaknight: Fix wrong words 09926c20b woomax: Modify strength value of PS8818 for USB-C0 signal quality 6bf5cfa64 usb_mux: Send missed disconnect mode in S3/S0ix 3f64cdcb6 usb_mux: Use atomic operations for updating the flag 67bf75c9b tcpmv2: Re-discover cable if the port parter is PD 2.0 bde820f24 tcpmv2: ensure the USB mux state is only changed in the PD task 7a09b754e docs: add porting considerations for Ztest e8faab25e dedede: Add MKBP_EVENT to baseboard affbf150d usb_mux: Send missed disconnect mode in S3/S0ix 7ebc7659f usb_mux: Use atomic operations for updating the flag 5305a5d61 zephyr: volteer: move CONFIG_SHIMMED_TASKS 8aefdfec0 guybrush: Configure keyboard 10a919e01 ctn730: Print payload and handle download mode b1d414b77 pchg: Initialize pchg chips on startup 3c5f55ace zephyr: provide a header for cpu.h e9eefa1d9 tcpmv2: Re-discover cable if the port parter is PD 2.0 bfc29b475 zephyr: test: update unit tests for zmake 0f7a6d893 zephyr: test: provide Kconfig defaults for tests c109df3a4 Trogdor: Don't make pressing a key a wake source if no keyboard fbca51787 pd: fix superspeed mux steering on UFP c6baaa7c8 guybrush: implement usb_pd_policy stubs d289734a5 TBT: Correct pdcable command 24c5daa48 tcpmv2: ensure the USB mux state is only changed in the PD task eb3d6b6b4 guybrush: Enable BOARD_RESET_AFTER_POWER_ON d032dc3c0 octopus: set CONFIG_BC12_MAX14637_DELAY_FROM_OFF_TO_ON_MS to 100ms 8b5963199 max14637: Switch should not be kept open when PD adapter is disconnected 7ac3b8771 Metaknight: Add temp sensor to read temperature 6fdd5a2eb elemi: Change thermal and fan configuration BUG=none TEST=make buildall BRANCH=firmware-volteer-13672.B-main Change-Id: I9bf1672754ba15e339ee88286e42e52402bc366d
-rw-r--r--baseboard/dedede/baseboard.h4
-rw-r--r--baseboard/guybrush/base_ec.tasklist2
-rw-r--r--baseboard/guybrush/baseboard.c49
-rw-r--r--baseboard/guybrush/baseboard.h32
-rw-r--r--baseboard/guybrush/usb_pd_policy.c46
-rw-r--r--baseboard/octopus/baseboard.h2
-rw-r--r--baseboard/trogdor/baseboard.h6
-rw-r--r--baseboard/zork/build.mk1
-rw-r--r--baseboard/zork/cbi_ssfc.c31
-rw-r--r--baseboard/zork/cbi_ssfc.h40
-rw-r--r--board/drawcia/board.c2
-rw-r--r--board/drawcia/board.h3
-rw-r--r--board/elemi/board.c57
-rw-r--r--board/madoo/board.h3
-rw-r--r--board/magolor/board.h3
-rw-r--r--board/metaknight/battery.c2
-rw-r--r--board/metaknight/board.c17
-rw-r--r--board/metaknight/board.h17
-rw-r--r--board/metaknight/gpio.inc2
-rw-r--r--board/sasuke/board.h3
-rw-r--r--board/voema/board.c23
-rw-r--r--board/voema/board.h2
-rw-r--r--board/voxel/board.c43
-rw-r--r--board/voxel/board.h6
-rw-r--r--board/waddledoo/board.h3
-rw-r--r--board/woomax/board.c4
-rw-r--r--common/mock/usb_tc_sm_mock.c5
-rw-r--r--common/peripheral_charger.c85
-rw-r--r--common/usb_common.c3
-rw-r--r--common/usb_pd_console_cmd.c2
-rw-r--r--docs/ztest.md29
-rw-r--r--driver/bc12/max14637.c1
-rw-r--r--driver/nfc/ctn730.c17
-rw-r--r--test/usb_typec_drp_acc_trysrc.c6
-rw-r--r--zephyr/Kconfig3
-rw-r--r--zephyr/app/ec/Kconfig13
-rw-r--r--zephyr/cmake/toolchain/coreboot-sdk/target.cmake8
-rw-r--r--zephyr/projects/kohaku/zmake.yaml18
-rw-r--r--zephyr/projects/volteer/boards/arm/volteer/volteer_defconfig2
-rw-r--r--zephyr/projects/volteer/prj.conf1
-rw-r--r--zephyr/projects/volteer/zmake.yaml18
-rw-r--r--zephyr/shim/include/cpu.h14
-rw-r--r--zephyr/shim/src/CMakeLists.txt2
-rw-r--r--zephyr/shim/src/libgcc_arm.S11
-rw-r--r--zephyr/test/accel_cal/prj.conf16
-rw-r--r--zephyr/test/base32/CMakeLists.txt20
-rw-r--r--zephyr/test/base32/prj.conf2
-rw-r--r--zephyr/test/crc/CMakeLists.txt9
-rw-r--r--zephyr/test/crc/prj.conf2
-rw-r--r--zephyr/test/hooks/CMakeLists.txt20
-rw-r--r--zephyr/test/hooks/prj.conf3
-rw-r--r--zephyr/test/i2c/CMakeLists.txt30
-rw-r--r--zephyr/test/i2c/prj.conf4
-rw-r--r--zephyr/test/i2c/src/main.c3
-rw-r--r--zephyr/test/i2c_dts/CMakeLists.txt2
-rw-r--r--zephyr/test/system/CMakeLists.txt2
-rw-r--r--zephyr/test/system/prj.conf18
-rw-r--r--zephyr/test/tasks/CMakeLists.txt24
-rw-r--r--zephyr/test/tasks/prj.conf3
-rw-r--r--zephyr/zmake/zmake/project.py7
-rw-r--r--zephyr/zmake/zmake/zmake.py15
61 files changed, 544 insertions, 277 deletions
diff --git a/baseboard/dedede/baseboard.h b/baseboard/dedede/baseboard.h
index 96cedeee2a..fe7fee1c08 100644
--- a/baseboard/dedede/baseboard.h
+++ b/baseboard/dedede/baseboard.h
@@ -146,6 +146,10 @@
/* LED */
#define CONFIG_LED_COMMON
+/* Sensors */
+#define CONFIG_MKBP_EVENT
+#define CONFIG_MKBP_USE_GPIO_AND_HOST_EVENT
+
/* SoC */
#define CONFIG_BOARD_HAS_RTC_RESET
#define CONFIG_CHIPSET_JASPERLAKE
diff --git a/baseboard/guybrush/base_ec.tasklist b/baseboard/guybrush/base_ec.tasklist
index cb567355ef..434d4d54ed 100644
--- a/baseboard/guybrush/base_ec.tasklist
+++ b/baseboard/guybrush/base_ec.tasklist
@@ -14,8 +14,10 @@
TASK_ALWAYS(USB_CHG_P1, usb_charger_task, 1, TASK_STACK_SIZE) \
TASK_ALWAYS(CHARGER, charger_task, NULL, VENTI_TASK_STACK_SIZE) \
TASK_NOTEST(CHIPSET, chipset_task, NULL, VENTI_TASK_STACK_SIZE) \
+ TASK_NOTEST(KEYPROTO, keyboard_protocol_task, NULL, TASK_STACK_SIZE) \
TASK_ALWAYS(HOSTCMD, host_command_task, NULL, LARGER_TASK_STACK_SIZE) \
TASK_ALWAYS(POWERBTN, power_button_task, NULL, VENTI_TASK_STACK_SIZE) \
+ TASK_NOTEST(KEYSCAN, keyboard_scan_task, NULL, LARGER_TASK_STACK_SIZE) \
TASK_ALWAYS(CONSOLE, console_task, NULL, VENTI_TASK_STACK_SIZE) \
TASK_ALWAYS(PD_C0, pd_task, NULL, VENTI_TASK_STACK_SIZE) \
TASK_ALWAYS(PD_C1, pd_task, NULL, VENTI_TASK_STACK_SIZE) \
diff --git a/baseboard/guybrush/baseboard.c b/baseboard/guybrush/baseboard.c
index b166167761..be4eebe144 100644
--- a/baseboard/guybrush/baseboard.c
+++ b/baseboard/guybrush/baseboard.c
@@ -8,12 +8,14 @@
#include "adc.h"
#include "adc_chip.h"
#include "battery_fuel_gauge.h"
-#include "chipset.h"
#include "charge_manager.h"
#include "charge_ramp.h"
#include "charge_state.h"
#include "charge_state_v2.h"
#include "charger.h"
+#include "chip/npcx/ps2_chip.h"
+#include "chip/npcx/pwm_chip.h"
+#include "chipset.h"
#include "driver/ppc/aoz1380.h"
#include "driver/ppc/nx20p348x.h"
#include "driver/tcpm/nct38xx.h"
@@ -23,9 +25,11 @@
#include "i2c.h"
#include "ioexpander.h"
#include "isl9241.h"
+#include "keyboard_scan.h"
#include "nct38xx.h"
#include "pi3usb9201.h"
#include "power.h"
+#include "pwm.h"
#include "temp_sensor.h"
#include "thermal.h"
#include "thermistor.h"
@@ -403,6 +407,49 @@ struct ioexpander_config_t ioex_config[] = {
BUILD_ASSERT(ARRAY_SIZE(ioex_config) == USBC_PORT_COUNT);
BUILD_ASSERT(CONFIG_IO_EXPANDER_PORT_COUNT == USBC_PORT_COUNT);
+/* Keyboard scan setting */
+struct keyboard_scan_config keyscan_config = {
+ /*
+ * F3 key scan cycle completed but scan input is not
+ * charging to logic high when EC start scan next
+ * column for "T" key, so we set .output_settle_us
+ * to 80us
+ */
+ .output_settle_us = 80,
+ .debounce_down_us = 6 * MSEC,
+ .debounce_up_us = 30 * MSEC,
+ .scan_period_us = 1500,
+ .min_post_scan_delay_us = 1000,
+ .poll_timeout_us = SECOND,
+ .actual_key_mask = {
+ 0x3c, 0xff, 0xff, 0xff, 0xff, 0xf5, 0xff,
+ 0xa4, 0xff, 0xfe, 0x55, 0xfa, 0xca /* full set */
+ },
+};
+
+const struct pwm_t pwm_channels[] = {
+ [PWM_CH_FAN] = {
+ .channel = 0,
+ .flags = PWM_CONFIG_OPEN_DRAIN,
+ .freq = 25000,
+ },
+ [PWM_CH_KBLIGHT] = {
+ .channel = 1,
+ .flags = PWM_CONFIG_DSLEEP,
+ .freq = 100,
+ },
+ [PWM_CH_LED_CHRG] = {
+ .channel = 2,
+ .flags = PWM_CONFIG_DSLEEP,
+ .freq = 100,
+ },
+ [PWM_CH_LED_FULL] = {
+ .channel = 3,
+ .flags = PWM_CONFIG_DSLEEP,
+ .freq = 100,
+ },
+};
+BUILD_ASSERT(ARRAY_SIZE(pwm_channels) == PWM_CH_COUNT);
int board_set_active_charge_port(int port)
{
diff --git a/baseboard/guybrush/baseboard.h b/baseboard/guybrush/baseboard.h
index 5fc1c28eca..adbf1d1228 100644
--- a/baseboard/guybrush/baseboard.h
+++ b/baseboard/guybrush/baseboard.h
@@ -44,6 +44,13 @@
#define GPIO_PCH_SYS_PWROK GPIO_EC_SOC_PWR_GOOD
#define GPIO_SYS_RESET_L GPIO_EC_SYS_RST_L
#define GPIO_EN_PWR_A GPIO_EN_PWR_Z1
+/*
+ * On power-on, H1 releases the EC from reset but then quickly asserts and
+ * releases the reset a second time. This means the EC sees 2 resets:
+ * (1) power-on reset, (2) reset-pin reset. This config will
+ * allow the second reset to be treated as a power-on.
+ */
+#define CONFIG_BOARD_RESET_AFTER_POWER_ON
/* Thermal Config */
#define CONFIG_ADC
@@ -59,13 +66,23 @@
#define GPIO_WP_L GPIO_EC_WP_L
/* Host communication */
+#define CONFIG_HOSTCMD_ESPI
+#define CONFIG_MKBP_EVENT
+#define CONFIG_MKBP_USE_GPIO_AND_HOST_EVENT
+#define GPIO_EC_INT_L GPIO_EC_SOC_INT_L
/* Chipset config */
#define CONFIG_CHIPSET_STONEY
#define CONFIG_CHIPSET_CAN_THROTTLE
#define CONFIG_CHIPSET_RESET_HOOK
-/* Common Keyboard Defines */
+/* Keyboard Config */
+#define CONFIG_KEYBOARD_BACKLIGHT
+#define CONFIG_KEYBOARD_BOARD_CONFIG
+#define CONFIG_KEYBOARD_COL2_INVERTED
+#define CONFIG_KEYBOARD_PROTOCOL_8042
+#define CONFIG_KEYBOARD_VIVALDI
+#define GPIO_KBD_KSO2 GPIO_EC_KSO_02_INV
/* Sensors */
#define CONFIG_TABLET_MODE
@@ -209,6 +226,10 @@
/* Fan features */
+/* LED Config */
+#define CONFIG_PWM
+#define CONFIG_PWM_KBLIGHT
+
#ifndef __ASSEMBLER__
#include "gpio_signal.h"
@@ -264,6 +285,15 @@ enum battery_type {
BATTERY_TYPE_COUNT,
};
+/* PWM Channels */
+enum pwm_channel {
+ PWM_CH_FAN = 0,
+ PWM_CH_KBLIGHT,
+ PWM_CH_LED_CHRG,
+ PWM_CH_LED_FULL,
+ PWM_CH_COUNT
+};
+
/* Common definition for the USB PD interrupt handlers. */
void tcpc_alert_event(enum gpio_signal signal);
void bc12_interrupt(enum gpio_signal signal);
diff --git a/baseboard/guybrush/usb_pd_policy.c b/baseboard/guybrush/usb_pd_policy.c
index 213a457593..ac92a6e0ad 100644
--- a/baseboard/guybrush/usb_pd_policy.c
+++ b/baseboard/guybrush/usb_pd_policy.c
@@ -20,19 +20,55 @@
int pd_check_vconn_swap(int port)
{
- /* TODO */
- return 0;
+ /*
+ * Do not allow vconn swap 5V rail is off
+ * S5_PGOOD depends on PG_PP5000_S5 being asserted,
+ * so GPIO_S5_PGOOD is a reasonable proxy for PP5000_S5
+ */
+ return gpio_get_level(GPIO_S5_PGOOD);
}
void pd_power_supply_reset(int port)
{
- /* TODO */
+ /*
+ * Don't need to shutoff VBus if we are not sourcing it
+ * TODO: Ensure Vbus sourcing is being disabled appropriately to
+ * avoid invalid TC states
+ */
+ if (ppc_is_sourcing_vbus(port)) {
+ /* Disable VBUS. */
+ ppc_vbus_source_enable(port, 0);
+
+ /* Enable discharge if we were previously sourcing 5V */
+ if (IS_ENABLED(CONFIG_USB_PD_DISCHARGE))
+ pd_set_vbus_discharge(port, 1);
+ }
+
+ /* Notify host of power info change. */
+ pd_send_host_event(PD_EVENT_POWER_CHANGE);
}
int pd_set_power_supply_ready(int port)
{
- /* TODO */
- return 0;
+ int rv;
+
+ /* Disable charging. */
+ rv = ppc_vbus_sink_enable(port, 0);
+ if (rv)
+ return rv;
+
+ if (IS_ENABLED(CONFIG_USB_PD_DISCHARGE))
+ pd_set_vbus_discharge(port, 0);
+
+ /* Provide Vbus. */
+ rv = ppc_vbus_source_enable(port, 1);
+ if (rv)
+ return rv;
+
+ /* Notify host of power info change. */
+ pd_send_host_event(PD_EVENT_POWER_CHANGE);
+
+ return EC_SUCCESS;
}
int board_vbus_source_enabled(int port)
diff --git a/baseboard/octopus/baseboard.h b/baseboard/octopus/baseboard.h
index 44868cc475..c342e48687 100644
--- a/baseboard/octopus/baseboard.h
+++ b/baseboard/octopus/baseboard.h
@@ -216,6 +216,8 @@
#define CONFIG_USB_PD_TCPM_MUX
#define CONFIG_USB_PD_TCPM_TCPCI
#define CONFIG_BC12_DETECT_MAX14637
+#undef CONFIG_BC12_MAX14637_DELAY_FROM_OFF_TO_ON_MS
+#define CONFIG_BC12_MAX14637_DELAY_FROM_OFF_TO_ON_MS 100
#define CONFIG_HOSTCMD_PD_CONTROL
#define CONFIG_CMD_PPC_DUMP
diff --git a/baseboard/trogdor/baseboard.h b/baseboard/trogdor/baseboard.h
index ec459287f1..a785671e8b 100644
--- a/baseboard/trogdor/baseboard.h
+++ b/baseboard/trogdor/baseboard.h
@@ -203,10 +203,16 @@
EC_HOST_EVENT_MASK(EC_HOST_EVENT_MODE_CHANGE))
/* And the MKBP events */
+#ifdef HAS_TASK_KEYSCAN
#define CONFIG_MKBP_EVENT_WAKEUP_MASK \
(BIT(EC_MKBP_EVENT_KEY_MATRIX) | \
BIT(EC_MKBP_EVENT_HOST_EVENT) | \
BIT(EC_MKBP_EVENT_SENSOR_FIFO))
+#else
+#define CONFIG_MKBP_EVENT_WAKEUP_MASK \
+ (BIT(EC_MKBP_EVENT_HOST_EVENT) | \
+ BIT(EC_MKBP_EVENT_SENSOR_FIFO))
+#endif
#ifndef __ASSEMBLER__
diff --git a/baseboard/zork/build.mk b/baseboard/zork/build.mk
index 740252ac9a..e79d60cc91 100644
--- a/baseboard/zork/build.mk
+++ b/baseboard/zork/build.mk
@@ -8,6 +8,7 @@
baseboard-y=baseboard.o
baseboard-y+=cbi_ec_fw_config.o
+baseboard-y+=cbi_ssfc.o
baseboard-$(CONFIG_USB_POWER_DELIVERY)+=usb_pd_policy.o
baseboard-$(VARIANT_ZORK_TREMBYLE)+=variant_trembyle.o
baseboard-$(VARIANT_ZORK_DALBOZ)+=variant_dalboz.o
diff --git a/baseboard/zork/cbi_ssfc.c b/baseboard/zork/cbi_ssfc.c
new file mode 100644
index 0000000000..cf1001e5c2
--- /dev/null
+++ b/baseboard/zork/cbi_ssfc.c
@@ -0,0 +1,31 @@
+/* Copyright 2021 The Chromium OS Authors. All rights reserved.
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "cbi_ssfc.h"
+#include "common.h"
+#include "console.h"
+#include "cros_board_info.h"
+#include "hooks.h"
+
+#define CPRINTS(format, args...) cprints(CC_SYSTEM, format, ##args)
+
+/* Cache SSFC on init since we don't expect it to change in runtime */
+static union zork_cbi_ssfc cached_ssfc;
+BUILD_ASSERT(sizeof(cached_ssfc) == sizeof(uint32_t));
+
+static void cbi_ssfc_init(void)
+{
+ if (cbi_get_ssfc(&cached_ssfc.raw_value) != EC_SUCCESS)
+ /* Default to 0 when CBI isn't populated */
+ cached_ssfc.raw_value = 0;
+
+ CPRINTS("Read CBI SSFC : 0x%04X", cached_ssfc.raw_value);
+}
+DECLARE_HOOK(HOOK_INIT, cbi_ssfc_init, HOOK_PRIO_FIRST);
+
+enum ec_ssfc_base_gyro_sensor get_cbi_ssfc_base_sensor(void)
+{
+ return cached_ssfc.base_sensor;
+}
diff --git a/baseboard/zork/cbi_ssfc.h b/baseboard/zork/cbi_ssfc.h
new file mode 100644
index 0000000000..de073847e7
--- /dev/null
+++ b/baseboard/zork/cbi_ssfc.h
@@ -0,0 +1,40 @@
+/* Copyright 2021 The Chromium OS Authors. All rights reserved.
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#ifndef _ZORK_CBI_SSFC__H_
+#define _ZORK_CBI_SSFC__H_
+
+#include "stdint.h"
+
+/****************************************************************************
+ * Zork CBI Second Source Factory Cache
+ */
+
+/*
+ * Base Sensor (Bits 0-2)
+ */
+enum ec_ssfc_base_gyro_sensor {
+ SSFC_BASE_GYRO_NONE = 0,
+ SSFC_BASE_GYRO_BMI160 = 1,
+ SSFC_BASE_GYRO_LSM6DSM = 2,
+ SSFC_BASE_GYRO_ICM426XX = 3,
+};
+
+union zork_cbi_ssfc {
+ struct {
+ enum ec_ssfc_base_gyro_sensor base_sensor : 3;
+ uint32_t reserved : 29;
+ };
+ uint32_t raw_value;
+};
+
+/**
+ * Get the Base sensor type from SSFC_CONFIG.
+ *
+ * @return the Base sensor board type.
+ */
+enum ec_ssfc_base_gyro_sensor get_cbi_ssfc_base_sensor(void);
+
+#endif /* _ZORK_CBI_SSFC__H_ */
diff --git a/board/drawcia/board.c b/board/drawcia/board.c
index 6728eb1183..f160335e53 100644
--- a/board/drawcia/board.c
+++ b/board/drawcia/board.c
@@ -346,7 +346,7 @@ struct motion_sensor_t motion_sensors[] = {
.port = I2C_PORT_SENSOR,
.i2c_spi_addr_flags = LSM6DSM_ADDR0_FLAGS,
.default_range = 1000 | ROUND_UP_FLAG, /* dps */
- .rot_standard_ref = NULL,
+ .rot_standard_ref = &base_standard_ref,
.min_frequency = LSM6DSM_ODR_MIN_VAL,
.max_frequency = LSM6DSM_ODR_MAX_VAL,
},
diff --git a/board/drawcia/board.h b/board/drawcia/board.h
index 0808a21315..0479234318 100644
--- a/board/drawcia/board.h
+++ b/board/drawcia/board.h
@@ -40,6 +40,9 @@
/* Sensors without hardware FIFO are in forced mode */
#define CONFIG_ACCEL_FORCE_MODE_MASK BIT(LID_ACCEL)
+#define CONFIG_CMD_ACCELS
+#define CONFIG_CMD_ACCEL_INFO
+
#define CONFIG_ACCEL_INTERRUPTS
/* Enable sensor fifo, must also define the _SIZE and _THRES */
#define CONFIG_ACCEL_FIFO
diff --git a/board/elemi/board.c b/board/elemi/board.c
index b8971f8aa8..e8983019d6 100644
--- a/board/elemi/board.c
+++ b/board/elemi/board.c
@@ -77,17 +77,10 @@ const struct fan_conf fan_conf_0 = {
.enable_gpio = GPIO_EN_PP5000_FAN,
};
-/*
- * Fan specs from datasheet:
- * Max speed 5900 rpm (+/- 7%), minimum duty cycle 30%.
- * Minimum speed not specified by RPM. Set minimum RPM to max speed (with
- * margin) x 30%.
- * 5900 x 1.07 x 0.30 = 1894, round up to 1900
- */
const struct fan_rpm fan_rpm_0 = {
- .rpm_min = 1900,
- .rpm_start = 1900,
- .rpm_max = 5900,
+ .rpm_min = 2500,
+ .rpm_start = 2500,
+ .rpm_max = 6500,
};
const struct fan_t fans[FAN_CH_COUNT] = {
@@ -107,43 +100,43 @@ const struct fan_t fans[FAN_CH_COUNT] = {
*/
const static struct ec_thermal_config thermal_cpu = {
.temp_host = {
- [EC_TEMP_THRESH_HIGH] = C_TO_K(70),
- [EC_TEMP_THRESH_HALT] = C_TO_K(80),
+ [EC_TEMP_THRESH_HIGH] = C_TO_K(68),
+ [EC_TEMP_THRESH_HALT] = C_TO_K(70),
},
.temp_host_release = {
- [EC_TEMP_THRESH_HIGH] = C_TO_K(65),
+ [EC_TEMP_THRESH_HIGH] = C_TO_K(58),
},
- .temp_fan_off = C_TO_K(35),
- .temp_fan_max = C_TO_K(50),
+ .temp_fan_off = C_TO_K(40),
+ .temp_fan_max = C_TO_K(60),
};
-/*
- * Inductor limits - used for both charger and PP3300 regulator
- *
- * Need to use the lower of the charger IC, PP3300 regulator, and the inductors
- *
- * Charger max recommended temperature 100C, max absolute temperature 125C
- * PP3300 regulator: operating range -40 C to 145 C
- *
- * Inductors: limit of 125c
- * PCB: limit is 80c
- */
-const static struct ec_thermal_config thermal_inductor = {
+const static struct ec_thermal_config thermal_charger = {
.temp_host = {
- [EC_TEMP_THRESH_HIGH] = C_TO_K(75),
+ [EC_TEMP_THRESH_HIGH] = C_TO_K(78),
[EC_TEMP_THRESH_HALT] = C_TO_K(80),
},
.temp_host_release = {
- [EC_TEMP_THRESH_HIGH] = C_TO_K(65),
+ [EC_TEMP_THRESH_HIGH] = C_TO_K(68),
},
.temp_fan_off = C_TO_K(40),
- .temp_fan_max = C_TO_K(55),
+ .temp_fan_max = C_TO_K(70),
};
+const static struct ec_thermal_config thermal_regulator = {
+ .temp_host = {
+ [EC_TEMP_THRESH_HIGH] = C_TO_K(68),
+ [EC_TEMP_THRESH_HALT] = C_TO_K(70),
+ },
+ .temp_host_release = {
+ [EC_TEMP_THRESH_HIGH] = C_TO_K(58),
+ },
+ .temp_fan_off = C_TO_K(40),
+ .temp_fan_max = C_TO_K(55),
+};
struct ec_thermal_config thermal_params[] = {
- [TEMP_SENSOR_1_CHARGER] = thermal_inductor,
- [TEMP_SENSOR_2_PP3300_REGULATOR] = thermal_inductor,
+ [TEMP_SENSOR_1_CHARGER] = thermal_charger,
+ [TEMP_SENSOR_2_PP3300_REGULATOR] = thermal_regulator,
[TEMP_SENSOR_3_DDR_SOC] = thermal_cpu,
[TEMP_SENSOR_4_FAN] = thermal_cpu,
};
diff --git a/board/madoo/board.h b/board/madoo/board.h
index 020793f830..f18d2a0cfe 100644
--- a/board/madoo/board.h
+++ b/board/madoo/board.h
@@ -103,9 +103,6 @@
#define CONFIG_ACCEL_LSM6DSM_INT_EVENT \
TASK_EVENT_MOTION_SENSOR_INTERRUPT(BASE_ACCEL)
-#define CONFIG_MKBP_EVENT
-#define CONFIG_MKBP_USE_GPIO
-
#define CONFIG_BATTERY_DEVICE_CHEMISTRY "LION"
#define CONFIG_BATTERY_FUEL_GAUGE
diff --git a/board/magolor/board.h b/board/magolor/board.h
index cab934da2b..648d431be5 100644
--- a/board/magolor/board.h
+++ b/board/magolor/board.h
@@ -145,9 +145,6 @@
#define CONFIG_TABLET_MODE_SWITCH
#define CONFIG_GMR_TABLET_MODE
-#define CONFIG_MKBP_EVENT
-#define CONFIG_MKBP_USE_GPIO
-
/* Volume Button feature */
#define CONFIG_ADC_BUTTONS
#define CONFIG_VOLUME_BUTTONS
diff --git a/board/metaknight/battery.c b/board/metaknight/battery.c
index 9edc99b811..943771ffa4 100644
--- a/board/metaknight/battery.c
+++ b/board/metaknight/battery.c
@@ -10,7 +10,7 @@
#include "common.h"
/*
- * Battery info for all waddledoo battery types. Note that the fields
+ * Battery info for all metaknight battery types. Note that the fields
* start_charging_min/max and charging_min/max are not used for the charger.
* The effective temperature limits are given by discharging_min/max_c.
*
diff --git a/board/metaknight/board.c b/board/metaknight/board.c
index c93ebc52ad..9b852a6ec2 100644
--- a/board/metaknight/board.c
+++ b/board/metaknight/board.c
@@ -3,7 +3,7 @@
* found in the LICENSE file.
*/
-/* Waddledoo board-specific configuration */
+/* metaknight board-specific configuration */
#include "adc_chip.h"
#include "button.h"
@@ -19,6 +19,8 @@
#include "driver/accel_kionix.h"
#include "driver/accelgyro_bmi_common.h"
#include "driver/accelgyro_lsm6dsm.h"
+#include "driver/temp_sensor/thermistor.h"
+#include "temp_sensor.h"
#include "driver/bc12/pi3usb9201.h"
#include "driver/charger/isl923x.h"
#include "driver/retimer/nb7v904m.h"
@@ -207,6 +209,19 @@ const struct adc_t adc_channels[] = {
};
BUILD_ASSERT(ARRAY_SIZE(adc_channels) == ADC_CH_COUNT);
+/* Thermistors */
+const struct temp_sensor_t temp_sensors[] = {
+ [TEMP_SENSOR_1] = {.name = "Memory",
+ .type = TEMP_SENSOR_TYPE_BOARD,
+ .read = get_temp_3v3_51k1_47k_4050b,
+ .idx = ADC_TEMP_SENSOR_1},
+ [TEMP_SENSOR_2] = {.name = "Ambient",
+ .type = TEMP_SENSOR_TYPE_BOARD,
+ .read = get_temp_3v3_51k1_47k_4050b,
+ .idx = ADC_TEMP_SENSOR_2},
+};
+BUILD_ASSERT(ARRAY_SIZE(temp_sensors) == TEMP_SENSOR_COUNT);
+
/* Enable HDMI any time the SoC is on */
static void hdmi_enable(void)
{
diff --git a/board/metaknight/board.h b/board/metaknight/board.h
index ad37dc6604..1f7fcdaa98 100644
--- a/board/metaknight/board.h
+++ b/board/metaknight/board.h
@@ -3,7 +3,7 @@
* found in the LICENSE file.
*/
-/* Waddledoo board configuration */
+/* metaknight board configuration */
#ifndef __CROS_EC_BOARD_H
#define __CROS_EC_BOARD_H
@@ -44,6 +44,12 @@
#define CONFIG_PWM
#define NPCX7_PWM1_SEL 1 /* GPIO C2 is used as PWM1. */
+/* Temp sensor */
+#define CONFIG_TEMP_SENSOR
+#define CONFIG_THERMISTOR_NCP15WB
+#define CONFIG_STEINHART_HART_3V3_51K1_47K_4050B
+#define CONFIG_TEMP_SENSOR_POWER_GPIO GPIO_EN_PP3300_A
+
/* USB */
#define CONFIG_BC12_DETECT_PI3USB9201
#define CONFIG_USBC_RETIMER_NB7V904M
@@ -123,9 +129,6 @@
#define CONFIG_TABLET_MODE_SWITCH
#define CONFIG_GMR_TABLET_MODE
-#define CONFIG_MKBP_EVENT
-#define CONFIG_MKBP_USE_GPIO
-
/* Volume Button feature */
#define CONFIG_ADC_BUTTONS
#define CONFIG_VOLUME_BUTTONS
@@ -163,6 +166,12 @@ enum adc_channel {
ADC_CH_COUNT
};
+enum temp_sensor_id {
+ TEMP_SENSOR_1,
+ TEMP_SENSOR_2,
+ TEMP_SENSOR_COUNT
+};
+
enum sensor_id {
LID_ACCEL,
BASE_ACCEL,
diff --git a/board/metaknight/gpio.inc b/board/metaknight/gpio.inc
index f0179018c3..8b8f84048d 100644
--- a/board/metaknight/gpio.inc
+++ b/board/metaknight/gpio.inc
@@ -99,7 +99,7 @@ GPIO(EN_USB_A0_VBUS, PIN(4, 1), GPIO_OUT_LOW) /* Enable A1 5V Charging */
GPIO(EN_USB_A1_VBUS, PIN(F, 2), GPIO_OUT_LOW) /* Enable A1 5V Charging */
/*
- * Waddledoo doesn't have these physical pins coming to the EC but uses other
+ * metaknight doesn't have these physical pins coming to the EC but uses other
* logic.
*/
UNIMPLEMENTED(AC_PRESENT)
diff --git a/board/sasuke/board.h b/board/sasuke/board.h
index b2a79a499c..54fc3292b0 100644
--- a/board/sasuke/board.h
+++ b/board/sasuke/board.h
@@ -122,9 +122,6 @@
#define GPIO_EC_I2C_SUB_USB_C1_SCL GPIO_EC_I2C_SUB_C1_SCL_HDMI_EN_ODL
#define GPIO_EC_I2C_SUB_USB_C1_SDA GPIO_EC_I2C_SUB_C1_SDA_HDMI_HPD_ODL
-#define CONFIG_MKBP_EVENT
-#define CONFIG_MKBP_USE_GPIO
-
#define CONFIG_MATH_UTIL
#ifndef __ASSEMBLER__
diff --git a/board/voema/board.c b/board/voema/board.c
index 898732838d..f6dff264f6 100644
--- a/board/voema/board.c
+++ b/board/voema/board.c
@@ -60,6 +60,29 @@ struct keyboard_scan_config keyscan_config = {
},
};
+static const struct ec_response_keybd_config voema_kb = {
+ .num_top_row_keys = 10,
+ .action_keys = {
+ TK_BACK, /* T1 */
+ TK_REFRESH, /* T2 */
+ TK_FULLSCREEN, /* T3 */
+ TK_OVERVIEW, /* T4 */
+ TK_SNAPSHOT, /* T5 */
+ TK_BRIGHTNESS_DOWN, /* T6 */
+ TK_BRIGHTNESS_UP, /* T7 */
+ TK_VOL_MUTE, /* T8 */
+ TK_VOL_DOWN, /* T9 */
+ TK_VOL_UP, /* T10 */
+ },
+ .capabilities = KEYBD_CAP_SCRNLOCK_KEY,
+};
+
+__override const struct ec_response_keybd_config
+*board_vivaldi_keybd_config(void)
+{
+ return &voema_kb;
+}
+
/******************************************************************************/
/*
* FW_CONFIG defaults for Volteer if the CBI data is not initialized.
diff --git a/board/voema/board.h b/board/voema/board.h
index 2f08c2dde1..10728d8383 100644
--- a/board/voema/board.h
+++ b/board/voema/board.h
@@ -28,6 +28,8 @@
#define CONFIG_LED_ONOFF_STATES
/* Keyboard features */
+#define CONFIG_KEYBOARD_VIVALDI
+#define CONFIG_KEYBOARD_REFRESH_ROW3
/* Sensors */
/* BMA253 accelerometer in base */
diff --git a/board/voxel/board.c b/board/voxel/board.c
index da0a5dbb40..bba00ead94 100644
--- a/board/voxel/board.c
+++ b/board/voxel/board.c
@@ -47,6 +47,49 @@
#define CPRINTS(format, args...) cprints(CC_CHIPSET, format, ## args)
+static const struct ec_response_keybd_config zbu_new_kb = {
+ .num_top_row_keys = 10,
+ .action_keys = {
+ TK_BACK,
+ TK_REFRESH,
+ TK_FULLSCREEN,
+ TK_OVERVIEW,
+ TK_SNAPSHOT,
+ TK_BRIGHTNESS_DOWN,
+ TK_BRIGHTNESS_UP,
+ TK_VOL_MUTE,
+ TK_VOL_DOWN,
+ TK_VOL_UP,
+ },
+ .capabilities = KEYBD_CAP_SCRNLOCK_KEY,
+};
+
+static const struct ec_response_keybd_config zbu_old_kb = {
+ .num_top_row_keys = 10,
+ .action_keys = {
+ TK_BACK, /* T1 */
+ TK_FORWARD, /* T2 */
+ TK_REFRESH, /* T3 */
+ TK_FULLSCREEN, /* T4 */
+ TK_OVERVIEW, /* T5 */
+ TK_BRIGHTNESS_DOWN, /* T6 */
+ TK_BRIGHTNESS_UP, /* T7 */
+ TK_VOL_MUTE, /* T8 */
+ TK_VOL_DOWN, /* T9 */
+ TK_VOL_UP, /* T10 */
+ },
+ .capabilities = KEYBD_CAP_SCRNLOCK_KEY,
+};
+
+__override
+const struct ec_response_keybd_config *board_vivaldi_keybd_config(void)
+{
+ if (get_board_id() > 2)
+ return &zbu_new_kb;
+ else
+ return &zbu_old_kb;
+}
+
/* Keyboard scan setting */
struct keyboard_scan_config keyscan_config = {
/* Increase from 50 us, because KSO_02 passes through the H1. */
diff --git a/board/voxel/board.h b/board/voxel/board.h
index 6478644b18..6628be18b5 100644
--- a/board/voxel/board.h
+++ b/board/voxel/board.h
@@ -45,12 +45,6 @@
#define CONFIG_LED_ONOFF_STATES
/* Keyboard features */
-/*
- * Disable VOL up/down when tablet mode.
- * TODO(b/170966461): Re-enable Vivaldi keyboard once
- * 8042 and MKBP drivers can coexist.
- */
-#undef CONFIG_KEYBOARD_VIVALDI
/* Sensors */
/* BMI160 Base accel/gyro */
diff --git a/board/waddledoo/board.h b/board/waddledoo/board.h
index c286507638..d2c013dffd 100644
--- a/board/waddledoo/board.h
+++ b/board/waddledoo/board.h
@@ -139,9 +139,6 @@
#define CONFIG_TABLET_MODE_SWITCH
#define CONFIG_GMR_TABLET_MODE
-#define CONFIG_MKBP_EVENT
-#define CONFIG_MKBP_USE_GPIO
-
#ifndef __ASSEMBLER__
#include "gpio_signal.h"
diff --git a/board/woomax/board.c b/board/woomax/board.c
index eeae681ae7..aac0fea651 100644
--- a/board/woomax/board.c
+++ b/board/woomax/board.c
@@ -276,7 +276,7 @@ static int woomax_ps8818_mux_set(const struct usb_mux *me,
PS8818_REG_PAGE1,
PS8818_REG1_APTX1EQ_10G_LEVEL,
PS8818_EQ_LEVEL_UP_MASK,
- PS8818_EQ_LEVEL_UP_19DB);
+ PS8818_EQ_LEVEL_UP_18DB);
if (rv)
return rv;
@@ -284,7 +284,7 @@ static int woomax_ps8818_mux_set(const struct usb_mux *me,
PS8818_REG_PAGE1,
PS8818_REG1_APTX2EQ_10G_LEVEL,
PS8818_EQ_LEVEL_UP_MASK,
- PS8818_EQ_LEVEL_UP_19DB);
+ PS8818_EQ_LEVEL_UP_18DB);
if (rv)
return rv;
diff --git a/common/mock/usb_tc_sm_mock.c b/common/mock/usb_tc_sm_mock.c
index cb866a9268..6923e97f9d 100644
--- a/common/mock/usb_tc_sm_mock.c
+++ b/common/mock/usb_tc_sm_mock.c
@@ -172,6 +172,11 @@ bool pd_get_partner_dual_role_power(int port)
return true;
}
+bool pd_capable(int port)
+{
+ return true;
+}
+
void pd_set_suspend(int port, int suspend)
{
}
diff --git a/common/peripheral_charger.c b/common/peripheral_charger.c
index 8e714e99c9..e907257452 100644
--- a/common/peripheral_charger.c
+++ b/common/peripheral_charger.c
@@ -4,6 +4,7 @@
*/
#include "atomic.h"
+#include "chipset.h"
#include "common.h"
#include "device_event.h"
#include "hooks.h"
@@ -69,20 +70,29 @@ static const char *_text_event(enum pchg_event event)
return event_names[event];
}
+static enum pchg_state pchg_initialize(struct pchg *ctx, enum pchg_state state)
+{
+ int rv = ctx->cfg->drv->init(ctx);
+
+ if (rv == EC_SUCCESS) {
+ pchg_queue_event(ctx, PCHG_EVENT_ENABLE);
+ state = PCHG_STATE_INITIALIZED;
+ } else if (rv == EC_SUCCESS_IN_PROGRESS) {
+ state = PCHG_STATE_RESET;
+ } else {
+ CPRINTS("ERR: Failed to initialize");
+ }
+
+ return state;
+}
+
static enum pchg_state pchg_state_reset(struct pchg *ctx)
{
enum pchg_state state = PCHG_STATE_RESET;
- int rv;
switch (ctx->event) {
case PCHG_EVENT_INITIALIZE:
- rv = ctx->cfg->drv->init(ctx);
- if (rv == EC_SUCCESS) {
- pchg_queue_event(ctx, PCHG_EVENT_ENABLE);
- state = PCHG_STATE_INITIALIZED;
- } else if (rv != EC_SUCCESS_IN_PROGRESS) {
- CPRINTS("ERR: Failed to initialize");
- }
+ state = pchg_initialize(ctx, state);
break;
case PCHG_EVENT_INITIALIZED:
pchg_queue_event(ctx, PCHG_EVENT_ENABLE);
@@ -108,6 +118,9 @@ static enum pchg_state pchg_state_initialized(struct pchg *ctx)
return state;
switch (ctx->event) {
+ case PCHG_EVENT_INITIALIZE:
+ state = pchg_initialize(ctx, state);
+ break;
case PCHG_EVENT_ENABLE:
rv = ctx->cfg->drv->enable(ctx, true);
if (rv == EC_SUCCESS)
@@ -131,6 +144,9 @@ static enum pchg_state pchg_state_enabled(struct pchg *ctx)
int rv;
switch (ctx->event) {
+ case PCHG_EVENT_INITIALIZE:
+ state = pchg_initialize(ctx, state);
+ break;
case PCHG_EVENT_DISABLE:
ctx->error |= PCHG_ERROR_HOST;
rv = ctx->cfg->drv->enable(ctx, false);
@@ -161,6 +177,9 @@ static enum pchg_state pchg_state_detected(struct pchg *ctx)
int rv;
switch (ctx->event) {
+ case PCHG_EVENT_INITIALIZE:
+ state = pchg_initialize(ctx, state);
+ break;
case PCHG_EVENT_DISABLE:
ctx->error |= PCHG_ERROR_HOST;
rv = ctx->cfg->drv->enable(ctx, false);
@@ -194,6 +213,9 @@ static enum pchg_state pchg_state_charging(struct pchg *ctx)
int rv;
switch (ctx->event) {
+ case PCHG_EVENT_INITIALIZE:
+ state = pchg_initialize(ctx, state);
+ break;
case PCHG_EVENT_DISABLE:
ctx->error |= PCHG_ERROR_HOST;
rv = ctx->cfg->drv->enable(ctx, false);
@@ -277,7 +299,6 @@ static int pchg_run(struct pchg *ctx)
CPRINTS("->%s", _text_state(ctx->state));
ctx->event = PCHG_EVENT_NONE;
- CPRINTS("Done");
return 1;
}
@@ -297,23 +318,56 @@ void pchg_irq(enum gpio_signal signal)
}
}
-void pchg_task(void *u)
+static void pchg_startup(void)
{
struct pchg *ctx;
int p;
- int rv;
- /* TODO: i2c is wedged for a while after reset. investigate. */
- msleep(500);
+ CPRINTS("%s", __func__);
for (p = 0; p < pchg_count; p++) {
ctx = &pchgs[p];
- ctx->state = PCHG_STATE_RESET;
- queue_init(&ctx->events);
pchg_queue_event(ctx, PCHG_EVENT_INITIALIZE);
gpio_enable_interrupt(ctx->cfg->irq_pin);
}
+ task_wake(TASK_ID_PCHG);
+}
+DECLARE_HOOK(HOOK_CHIPSET_STARTUP, pchg_startup, HOOK_PRIO_DEFAULT);
+
+static void pchg_shutdown(void)
+{
+ struct pchg *ctx;
+ int p;
+
+ CPRINTS("%s", __func__);
+
+ for (p = 0; p < pchg_count; p++) {
+ ctx = &pchgs[0];
+ gpio_disable_interrupt(ctx->cfg->irq_pin);
+ mutex_lock(&ctx->mtx);
+ queue_init(&ctx->events);
+ mutex_unlock(&ctx->mtx);
+ }
+}
+DECLARE_HOOK(HOOK_CHIPSET_SHUTDOWN, pchg_shutdown, HOOK_PRIO_DEFAULT);
+
+void pchg_task(void *u)
+{
+ struct pchg *ctx;
+ int p;
+ int rv;
+
+ /*
+ * Without delay, after servo flash, ctn730 in RW always fails to write
+ * ENABLE_CMD (b:176824601).
+ */
+ msleep(50);
+
+ /* In case we arrive here after power-on (for late sysjump) */
+ if (chipset_in_state(CHIPSET_STATE_ON))
+ pchg_startup();
+
while (true) {
/* Process pending events for all ports. */
rv = 0;
@@ -390,7 +444,6 @@ static int cc_pchg(int argc, char **argv)
}
if (!strcasecmp(argv[2], "init")) {
- ctx->state = PCHG_STATE_RESET;
pchg_queue_event(ctx, PCHG_EVENT_INITIALIZE);
} else if (!strcasecmp(argv[2], "enable")) {
pchg_queue_event(ctx, PCHG_EVENT_ENABLE);
diff --git a/common/usb_common.c b/common/usb_common.c
index 37cd0886bd..81e9d2f24f 100644
--- a/common/usb_common.c
+++ b/common/usb_common.c
@@ -430,11 +430,12 @@ mux_state_t get_mux_mode_to_set(int port)
return USB_PD_MUX_NONE;
/*
- * If the power role is sink and the partner device is not capable
+ * If the power role is sink and the PD partner device is not capable
* of USB communication then disconnect.
*/
if (IS_ENABLED(CONFIG_USB_PD_DUAL_ROLE) &&
pd_get_power_role(port) == PD_ROLE_SINK &&
+ pd_capable(port) &&
!pd_get_partner_usb_comm_capable(port))
return USB_PD_MUX_NONE;
diff --git a/common/usb_pd_console_cmd.c b/common/usb_pd_console_cmd.c
index c1b263907a..1448424213 100644
--- a/common/usb_pd_console_cmd.c
+++ b/common/usb_pd_console_cmd.c
@@ -133,7 +133,7 @@ static int command_cable(int argc, char **argv)
}
ccprintf("%s\n", cable_type[ptype]);
- cable_rev = pd_get_vdo_ver(port, TCPC_TX_SOP_PRIME);
+ cable_rev = pd_get_rev(port, TCPC_TX_SOP_PRIME);
disc = pd_get_am_discovery(port, TCPC_TX_SOP_PRIME);
cable_mode_resp.raw_value =
pd_get_tbt_mode_vdo(port, TCPC_TX_SOP_PRIME);
diff --git a/docs/ztest.md b/docs/ztest.md
index 9c020c5d58..1dd4c91a0c 100644
--- a/docs/ztest.md
+++ b/docs/ztest.md
@@ -12,6 +12,35 @@ For examples of porting an EC unit test to the Ztest API, see:
* [base32](https://crrev.com/c/2492527) and [improvements](https://crrev.com/c/2634401)
* [accel_cal](https://crrev.com/c/2645198)
+## Porting Considerations
+
+Not every EC unit test can be ported to Ztest. This section describes cases
+that are not supported and cases where caveats apply.
+
+### EC Mocks Are Not Supported
+
+If a test has a `$TEST.mocklist` file associated with the unit test, it is
+using the EC mocking framework, which is unsupported in the Ztest framework.
+Ztest has its own mocking framework which the EC does not support.
+
+### Multiple Task Caveats
+
+The EC unit test framework starts a single task to call `run_test`, and this
+task will then call the functions for the various test cases. Some unit tests
+have multiple threads of execution, which is enabled by a `$TEST.tasklist`
+file associated with the unit test. The test runner task has a task ID of
+`TASK_ID_TEST_RUNNER`, which can be used as an argument to any of the task
+functions. See for example the [`charge_ramp` unit test](https://chromium.googlesource.com/chromiumos/platform/ec/+/refs/heads/master/test/charge_ramp.c#81)
+and the [`host_command` unit test](https://chromium.googlesource.com/chromiumos/platform/ec/+/refs/heads/master/test/host_command.c#32)
+
+When a unit test is ported to Ztest, `test_main` doesn't have a thread ID, so
+`TASK_ID_TEST_RUNNER` is undefined. `charge_ramp` and `host_command` cannot
+be ported at this time. `test_main` also cannot call any of the task functions
+that must be called from a task, such as `task_wake`; these functions can pend
+the calling task, but since `test_main` doesn't have a thread ID, the pend
+will fail. See the [`mutex` unit test](https://chromium.googlesource.com/chromiumos/platform/ec/+/refs/heads/master/test/mutex.c#116)
+for an example.
+
## Determine source files being tested
Determine which C files the unit test requires by finding the test in
diff --git a/driver/bc12/max14637.c b/driver/bc12/max14637.c
index de0971132d..a2bbfd4fb7 100644
--- a/driver/bc12/max14637.c
+++ b/driver/bc12/max14637.c
@@ -144,6 +144,7 @@ static void detect_or_power_down_ic(const int port)
} else {
/* Let charge manager know there's no more charge available. */
charge_manager_update_charge(CHARGE_SUPPLIER_OTHER, port, NULL);
+ bc12_detect(port);
#if defined(CONFIG_POWER_PP5000_CONTROL) && defined(HAS_TASK_CHIPSET)
/* Issue a request to turn off the rail. */
power_5v_enable(task_get_current(), 0);
diff --git a/driver/nfc/ctn730.c b/driver/nfc/ctn730.c
index 1d60fb3f2e..5528b8c5ec 100644
--- a/driver/nfc/ctn730.c
+++ b/driver/nfc/ctn730.c
@@ -5,6 +5,7 @@
#include "common.h"
#include "console.h"
+#include "gpio.h"
#include "i2c.h"
#include "peripheral_charger.h"
#include "timer.h"
@@ -15,6 +16,9 @@
* Configuration
*/
+/* Print additional data */
+#define CTN730_DEBUG
+
/*
* When ctn730 is asleep, I2C is ignored but can wake it up. I2C will be resent
* after this delay.
@@ -220,10 +224,9 @@ static int _i2c_read(int i2c_port, uint8_t *in, int in_len)
static void _print_header(const struct ctn730_msg *msg)
{
- CPRINTS("%s_%s LEN=%d",
+ CPRINTS("%s_%s",
_text_instruction(msg->instruction),
- _text_message_type(msg->message_type),
- msg->length);
+ _text_message_type(msg->message_type));
}
static int _send_command(struct pchg *ctx, const struct ctn730_msg *cmd)
@@ -307,6 +310,9 @@ static int _process_payload_response(struct pchg *ctx, struct ctn730_msg *res)
if (rv)
return rv;
+ if (IS_ENABLED(CTN730_DEBUG))
+ CPRINTS("Payload: %ph", HEX_BUF(buf, len));
+
switch (res->instruction) {
case WLC_HOST_CTRL_RESET:
if (len != WLC_HOST_CTRL_RESET_RSP_SIZE
@@ -350,10 +356,15 @@ static int _process_payload_event(struct pchg *ctx, struct ctn730_msg *res)
if (rv)
return rv;
+ if (IS_ENABLED(CTN730_DEBUG))
+ CPRINTS("Payload: %ph", HEX_BUF(buf, len));
+
switch (res->instruction) {
case WLC_HOST_CTRL_RESET:
if (buf[0] == WLC_HOST_CTRL_RESET_EVT_NORMAL_MODE)
ctx->event = PCHG_EVENT_INITIALIZED;
+ else if (buf[0] == WLC_HOST_CTRL_RESET_EVT_DOWNLOAD_MODE)
+ ctx->event = PCHG_EVENT_NONE;
else
return EC_ERROR_INVAL;
break;
diff --git a/test/usb_typec_drp_acc_trysrc.c b/test/usb_typec_drp_acc_trysrc.c
index f33c7079cf..3d329606ba 100644
--- a/test/usb_typec_drp_acc_trysrc.c
+++ b/test/usb_typec_drp_acc_trysrc.c
@@ -87,6 +87,12 @@ __maybe_unused static int test_mux_con_dis_as_snk(void)
mock_tcpc.should_print_call = false;
mock_usb_mux.num_set_calls = 0;
+ /*
+ * we expect a PD-capable partner to be able to check below
+ * whether it is data capable.
+ */
+ tc_pd_connection(0, 1);
+
/* Update CC lines send state machine event to process */
mock_tcpc.cc1 = TYPEC_CC_VOLT_RP_3_0;
mock_tcpc.cc2 = TYPEC_CC_VOLT_OPEN;
diff --git a/zephyr/Kconfig b/zephyr/Kconfig
index a1d2d142e5..55f3b74c12 100644
--- a/zephyr/Kconfig
+++ b/zephyr/Kconfig
@@ -208,6 +208,7 @@ endif # PLATFORM_EC_FLASH
menuconfig PLATFORM_EC_KEYBOARD
bool "Keyboard support"
select HAS_TASK_KEYSCAN
+ default n if ARCH_POSIX
default y
help
Enable compilation of support for scanning a keyboard and providing
@@ -275,6 +276,7 @@ config PLATFORM_EC_HOOKS
config PLATFORM_EC_I2C
bool "I2C shim"
+ default n if ARCH_POSIX
default y
help
Enable compilation of the EC i2c module. Once enabled, it will be
@@ -285,6 +287,7 @@ config PLATFORM_EC_I2C
menuconfig PLATFORM_EC_HOSTCMD
bool "Host commands"
+ default n if ARCH_POSIX
default y if AP
select HAS_TASK_HOSTCMD
help
diff --git a/zephyr/app/ec/Kconfig b/zephyr/app/ec/Kconfig
index 22519a20fa..44f8690f64 100644
--- a/zephyr/app/ec/Kconfig
+++ b/zephyr/app/ec/Kconfig
@@ -42,51 +42,64 @@ config CROS_EC_ACTIVE_COPY
When the active copy name is output to a console, this
string will be displayed.
+# When building for the host, we still need values for the various memory
+# sizes, though they aren't actually used, so just set some reasonable-looking
+# values and then ignore them.
config CROS_EC_RAM_SIZE
hex "The total available RAM size."
+ default 0x0000f800 if ARCH_POSIX
help
This value describes the total available RAM size for the chip.
config CROS_EC_DATA_RAM_SIZE
hex "The total available RAM size for data."
+ default 0x00010000 if ARCH_POSIX
help
This value describes the total available RAM size for data on the chip.
config CROS_EC_RAM_BASE
hex "Base address of RAM for the chip."
+ default 0x200c0000 if ARCH_POSIX
help
Base address of RAM for the chip.
config CROS_EC_PROGRAM_MEMORY_BASE
hex "The base address of the program memory region."
+ default 0x10090000 if ARCH_POSIX
help
This will be used (among other things) to calculate the current PC's
offset within the program memory.
config CROS_EC_RO_MEM_OFF
hex "The RO region's offset."
+ default 0x0 if ARCH_POSIX
help
This will be used to determine if the current PC is in the RO section.
config CROS_EC_RO_SIZE
hex "The size of the RO region."
+ default 0xb000 if ARCH_POSIX
help
This will be used (along with SYSTEM_RO_MEM_OFF) to determine if the
current PC is in the RO section.
config CROS_EC_RW_MEM_OFF
hex "The RW region's offset."
+ default 0xb000 if ARCH_POSIX
help
This will be used to determine if the current PC is in the RW section.
config CROS_EC_RW_SIZE
hex "The size of the RW region."
+ default 0x75000 if ARCH_POSIX
help
This will be used (along with SYSTEM_RW_MEM_OFF) to determine if the
current PC is in the RW section.
+# By default, a unit test doesn't need shimmed tasks.
config SHIMMED_TASKS
bool "Add support for shimming in platform/ec tasks as Zephyr threads"
+ default n if ARCH_POSIX
help
When this option is enabled, a shimmed_tasks.h header with the
CROS_EC_TASK_LIST defined needs to be included for the project to
diff --git a/zephyr/cmake/toolchain/coreboot-sdk/target.cmake b/zephyr/cmake/toolchain/coreboot-sdk/target.cmake
index cf3a6ec736..5f3d86459b 100644
--- a/zephyr/cmake/toolchain/coreboot-sdk/target.cmake
+++ b/zephyr/cmake/toolchain/coreboot-sdk/target.cmake
@@ -29,3 +29,11 @@ set(CMAKE_OBJCOPY "${CROSS_COMPILE}objcopy")
set(CMAKE_OBJDUMP "${CROSS_COMPILE}objdump")
set(CMAKE_RANLIB "${CROSS_COMPILE}ranlib")
set(CMAKE_READELF "${CROSS_COMPILE}readelf")
+
+# On ARM, we don't use libgcc: It's built against a fixed target (e.g.
+# used instruction set, ABI, ISA extensions) and doesn't adapt when
+# compiler flags change any of these assumptions. Use our own mini-libgcc
+# instead.
+if("${ARCH}" STREQUAL "arm")
+ set(no_libgcc True)
+endif()
diff --git a/zephyr/projects/kohaku/zmake.yaml b/zephyr/projects/kohaku/zmake.yaml
index 95831a19f7..7477961500 100644
--- a/zephyr/projects/kohaku/zmake.yaml
+++ b/zephyr/projects/kohaku/zmake.yaml
@@ -5,6 +5,7 @@
board: kohaku
supported-zephyr-versions:
- v2.4
+toolchain: coreboot-sdk
# Note: below output type is not correct, but good enough for
# developing right now. We need to run ecst to pack the RO/RW binary
@@ -14,20 +15,3 @@ supported-zephyr-versions:
# build-singleimage/zephyr/zephyr_kohaku.bin instead until Zmake
# grows a configuration option to handle ecst.
output-type: raw
-
-# Note: coreboot-sdk toolchain will build, but may have runtime
-# issues. This is set to "coreboot-sdk" so the automated CQ builder
-# can use it for build tests.
-#
-# For compiling for a real device, you need to use the Zephyr SDK
-# toolchain, which is not available in the chroot (and thus, to the CQ
-# builder). Please follow
-# https://docs.zephyrproject.org/latest/getting_started/installation_linux.html
-# for instructions on installing the SDK.
-#
-# If you are building outside of the chroot on a gLinux machine, the
-# arm-none-eabi-gcc toolchain seems to work fine. If you prefer this
-# toolchain, you can pass --toolchain=arm-none-eabi to zmake
-# configure, and that will work as well.
-toolchain: coreboot-sdk
-prefer-zephyr-sdk: true
diff --git a/zephyr/projects/volteer/boards/arm/volteer/volteer_defconfig b/zephyr/projects/volteer/boards/arm/volteer/volteer_defconfig
index 84df5902a6..7670ba7228 100644
--- a/zephyr/projects/volteer/boards/arm/volteer/volteer_defconfig
+++ b/zephyr/projects/volteer/boards/arm/volteer/volteer_defconfig
@@ -52,5 +52,3 @@ CONFIG_CROS_EC_RW_MEM_OFF=0x40000
# (CONFIG_CROS_EC_FLASH_SIZE - CONFIG_CROS_EC_RW_MEM_OFF -
# CONFIG_CROS_EC_RO_MEM_OFF)
CONFIG_CROS_EC_RW_SIZE=0x40000
-
-CONFIG_SHIMMED_TASKS=y
diff --git a/zephyr/projects/volteer/prj.conf b/zephyr/projects/volteer/prj.conf
index aeb44f5b64..1d7d885c82 100644
--- a/zephyr/projects/volteer/prj.conf
+++ b/zephyr/projects/volteer/prj.conf
@@ -13,6 +13,7 @@ CONFIG_ESPI=y
CONFIG_PLATFORM_EC_ESPI_VW_SLP_S4=y
CONFIG_PLATFORM_EC=y
+CONFIG_SHIMMED_TASKS=y
CONFIG_I2C=y
CONFIG_PLATFORM_EC_EXTPOWER_GPIO=y
CONFIG_PLATFORM_EC_KEYBOARD=y
diff --git a/zephyr/projects/volteer/zmake.yaml b/zephyr/projects/volteer/zmake.yaml
index b1251c2d08..914f8660e0 100644
--- a/zephyr/projects/volteer/zmake.yaml
+++ b/zephyr/projects/volteer/zmake.yaml
@@ -5,6 +5,7 @@
board: volteer
supported-zephyr-versions:
- v2.4
+toolchain: coreboot-sdk
# Note: below output type is not correct, but good enough for
# developing right now. We need to run ecst to pack the RO/RW binary
@@ -14,20 +15,3 @@ supported-zephyr-versions:
# build-singleimage/zephyr/zephyr_volteer.bin instead until Zmake
# grows a configuration option to handle ecst.
output-type: raw
-
-# Note: coreboot-sdk toolchain will build, but may have runtime
-# issues. This is set to "coreboot-sdk" so the automated CQ builder
-# can use it for build tests.
-#
-# For compiling for a real device, you need to use the Zephyr SDK
-# toolchain, which is not available in the chroot (and thus, to the CQ
-# builder). Please follow
-# https://docs.zephyrproject.org/latest/getting_started/installation_linux.html
-# for instructions on installing the SDK.
-#
-# If you are building outside of the chroot on a gLinux machine, the
-# arm-none-eabi-gcc toolchain seems to work fine. If you prefer this
-# toolchain, you can pass --toolchain=arm-none-eabi to zmake
-# configure, and that will work as well.
-toolchain: coreboot-sdk
-prefer-zephyr-sdk: true
diff --git a/zephyr/shim/include/cpu.h b/zephyr/shim/include/cpu.h
new file mode 100644
index 0000000000..617f644fa9
--- /dev/null
+++ b/zephyr/shim/include/cpu.h
@@ -0,0 +1,14 @@
+/* Copyright 2021 The Chromium OS Authors. All rights reserved.
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#ifndef __CROS_EC_CPU_H
+#define __CROS_EC_CPU_H
+
+/* Do nothing for Zephyr */
+static inline void cpu_init(void)
+{
+}
+
+#endif /* __CROS_EC_CPU_H */
diff --git a/zephyr/shim/src/CMakeLists.txt b/zephyr/shim/src/CMakeLists.txt
index e5101e8dbd..be283829cc 100644
--- a/zephyr/shim/src/CMakeLists.txt
+++ b/zephyr/shim/src/CMakeLists.txt
@@ -7,6 +7,8 @@ zephyr_sources(gpio.c)
zephyr_sources(util.c)
zephyr_sources(crc.c)
+zephyr_sources_ifdef(no_libgcc libgcc_${ARCH}.S)
+
zephyr_sources_ifdef(CONFIG_PLATFORM_EC_ESPI espi.c)
zephyr_sources_ifdef(CONFIG_PLATFORM_EC_FLASH flash.c)
zephyr_sources_ifdef(CONFIG_PLATFORM_EC_HOOKS hooks.c)
diff --git a/zephyr/shim/src/libgcc_arm.S b/zephyr/shim/src/libgcc_arm.S
new file mode 100644
index 0000000000..ffdbefc675
--- /dev/null
+++ b/zephyr/shim/src/libgcc_arm.S
@@ -0,0 +1,11 @@
+/* Copyright 2021 The Chromium OS Authors. All rights reserved.
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "../../third_party/libaeabi-cortexm0/core/cortex-m/ldivmod.S"
+#include "../../third_party/libaeabi-cortexm0/core/cortex-m/uldivmod.S"
+
+exception_panic:
+ mov r0, #3 @ K_ERR_KERNEL_OOPS
+ b z_fatal_error
diff --git a/zephyr/test/accel_cal/prj.conf b/zephyr/test/accel_cal/prj.conf
index 648eb63dd7..5efe3ec6b7 100644
--- a/zephyr/test/accel_cal/prj.conf
+++ b/zephyr/test/accel_cal/prj.conf
@@ -4,21 +4,5 @@
CONFIG_ZTEST=y
CONFIG_HAS_TEST_TASKS=y
-CONFIG_POLL=y
-
CONFIG_PLATFORM_EC=y
-CONFIG_PLATFORM_EC_I2C=n
-CONFIG_PLATFORM_EC_KEYBOARD=n
-CONFIG_PLATFORM_EC_HOSTCMD=n
-CONFIG_PLATFORM_EC_TIMER=n
-
CONFIG_CROS_EC=y
-# Define necessary program memory locations. These are meaning less though
-CONFIG_CROS_EC_PROGRAM_MEMORY_BASE=0x10090000
-CONFIG_CROS_EC_RAM_BASE=0x200c0000
-CONFIG_CROS_EC_DATA_RAM_SIZE=0x00010000
-CONFIG_CROS_EC_RAM_SIZE=0x0000f800
-CONFIG_CROS_EC_RO_MEM_OFF=0x0
-CONFIG_CROS_EC_RO_SIZE=0xb000
-CONFIG_CROS_EC_RW_MEM_OFF=0xb000
-CONFIG_CROS_EC_RW_SIZE=0x75000
diff --git a/zephyr/test/base32/CMakeLists.txt b/zephyr/test/base32/CMakeLists.txt
index 6ae6f232a9..674ad0d244 100644
--- a/zephyr/test/base32/CMakeLists.txt
+++ b/zephyr/test/base32/CMakeLists.txt
@@ -1,23 +1,9 @@
-# SPDX-License-Identifier: Apache-2.0
+# Copyright 2021 The Chromium OS Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
cmake_minimum_required(VERSION 3.13.1)
-set(BOARD native_posix)
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
project(base32)
-# Need to ensure that we are including only zephyr definitions in include files
-# We cannot set these via kconfig, since this unit test does not bring in the
-# zephyr-chrome repository
-zephyr_compile_definitions("CONFIG_ZEPHYR")
-
-# We need to include the EC include directory and this local test directory
-# for the task defines
-zephyr_include_directories(
- "${PLATFORM_EC}/zephyr/shim/include"
- "${PLATFORM_EC}/fuzz"
- "${PLATFORM_EC}/test"
- "${PLATFORM_EC}/include")
-
-# Include test file, test under test and console dependency
target_sources(app PRIVATE "${PLATFORM_EC}/test/base32.c")
-target_sources(app PRIVATE "${PLATFORM_EC}/common/base32.c")
diff --git a/zephyr/test/base32/prj.conf b/zephyr/test/base32/prj.conf
index 3940ec99eb..ec8c5035f5 100644
--- a/zephyr/test/base32/prj.conf
+++ b/zephyr/test/base32/prj.conf
@@ -3,3 +3,5 @@
# found in the LICENSE file.
CONFIG_ZTEST=y
+CONFIG_PLATFORM_EC=y
+CONFIG_CROS_EC=y
diff --git a/zephyr/test/crc/CMakeLists.txt b/zephyr/test/crc/CMakeLists.txt
index 8c1a38b56a..0b46729578 100644
--- a/zephyr/test/crc/CMakeLists.txt
+++ b/zephyr/test/crc/CMakeLists.txt
@@ -1,17 +1,10 @@
# Copyright 2020 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.
-# SPDX-License-Identifier: Apache-2.0
cmake_minimum_required(VERSION 3.13.1)
-set(BOARD native_posix)
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
-project(tasks)
-
-# We need to include the EC include directory and this local test directory
-# for the task defines
-zephyr_include_directories("${PLATFORM_EC}/include")
+project(crc)
# Include the test source and the file under test
target_sources(app PRIVATE main.c)
-target_sources(app PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/../../shim/src/crc.c")
diff --git a/zephyr/test/crc/prj.conf b/zephyr/test/crc/prj.conf
index 3940ec99eb..ec8c5035f5 100644
--- a/zephyr/test/crc/prj.conf
+++ b/zephyr/test/crc/prj.conf
@@ -3,3 +3,5 @@
# found in the LICENSE file.
CONFIG_ZTEST=y
+CONFIG_PLATFORM_EC=y
+CONFIG_CROS_EC=y
diff --git a/zephyr/test/hooks/CMakeLists.txt b/zephyr/test/hooks/CMakeLists.txt
index 2236963762..81ff57d69d 100644
--- a/zephyr/test/hooks/CMakeLists.txt
+++ b/zephyr/test/hooks/CMakeLists.txt
@@ -3,27 +3,7 @@
# found in the LICENSE file.
cmake_minimum_required(VERSION 3.13.1)
-set(BOARD native_posix)
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
project(hooks)
-# Need to ensure that we are including only zephyr definitions in include files
-# We cannot set these via kconfig, since this unit test does not bring in the
-# zephyr-chrome repository
-zephyr_compile_definitions("CONFIG_ZEPHYR")
-zephyr_compile_definitions("CONFIG_PLATFORM_EC_HOOKS")
-
-# We need to include the EC include directory and this local test directory
-# for the task defines
-zephyr_include_directories(
- "${PLATFORM_EC}/zephyr/shim/include"
- "${PLATFORM_EC}/fuzz"
- "${PLATFORM_EC}/test"
- "${PLATFORM_EC}/include")
-
-# Include test file, test under test and console dependency
target_sources(app PRIVATE hooks.c)
-target_sources(app PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/../../../common/printf.c")
-target_sources(app PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/../../shim/src/hooks.c")
-target_sources(app PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/../../shim/src/console.c")
-target_sources(app PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/../../shim/src/util.c")
diff --git a/zephyr/test/hooks/prj.conf b/zephyr/test/hooks/prj.conf
index 3940ec99eb..c0c02e22ca 100644
--- a/zephyr/test/hooks/prj.conf
+++ b/zephyr/test/hooks/prj.conf
@@ -3,3 +3,6 @@
# found in the LICENSE file.
CONFIG_ZTEST=y
+CONFIG_PLATFORM_EC=y
+CONFIG_PLATFORM_EC_HOOKS=y
+CONFIG_CROS_EC=y
diff --git a/zephyr/test/i2c/CMakeLists.txt b/zephyr/test/i2c/CMakeLists.txt
index 4edbfb9006..214177013f 100644
--- a/zephyr/test/i2c/CMakeLists.txt
+++ b/zephyr/test/i2c/CMakeLists.txt
@@ -1,29 +1,9 @@
-# SPDX-License-Identifier: Apache-2.0
+# Copyright 2020 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.
cmake_minimum_required(VERSION 3.13.1)
-set(BOARD native_posix)
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
-project(base32)
+project(i2c)
-# Need to ensure that we are including only zephyr definitions in include files
-# We cannot set these via kconfig, since this unit test does not bring in the
-# zephyr-chrome repository
-zephyr_compile_definitions("CONFIG_ZEPHYR")
-zephyr_compile_definitions("CONFIG_PLATFORM_EC_I2C")
-
-# We need to include the EC include directory and this local test directory
-# for the task defines
-zephyr_include_directories(
- "${PLATFORM_EC}/zephyr/shim/include"
- "${PLATFORM_EC}/fuzz"
- "${PLATFORM_EC}/test"
- "${PLATFORM_EC}/include")
-
-# Include test file, test under test and console dependency
-target_sources(app PRIVATE
- src/main.c
- "${PLATFORM_EC}/zephyr/shim/src/console.c"
- "${PLATFORM_EC}/zephyr/shim/src/i2c.c"
- "${PLATFORM_EC}/zephyr/shim/src/util.c"
- "${PLATFORM_EC}/common/i2c_controller.c"
- "${PLATFORM_EC}/common/printf.c")
+target_sources(app PRIVATE src/main.c)
diff --git a/zephyr/test/i2c/prj.conf b/zephyr/test/i2c/prj.conf
index bbf4d93e8e..8023c0492b 100644
--- a/zephyr/test/i2c/prj.conf
+++ b/zephyr/test/i2c/prj.conf
@@ -13,6 +13,10 @@ CONFIG_EMUL_BMI160=y
CONFIG_SENSOR=y
CONFIG_BMI160_TRIGGER_NONE=y
+CONFIG_PLATFORM_EC=y
+CONFIG_PLATFORM_EC_I2C=y
+CONFIG_CROS_EC=y
+
# TODO(b/173711210) figure out why SPI is required here when we're not using it.
CONFIG_SPI=y
CONFIG_SPI_EMUL=y
diff --git a/zephyr/test/i2c/src/main.c b/zephyr/test/i2c/src/main.c
index 6a6afe19fe..064ce78816 100644
--- a/zephyr/test/i2c/src/main.c
+++ b/zephyr/test/i2c/src/main.c
@@ -10,9 +10,6 @@
#include "i2c/i2c.h"
/* Unused: required for shimming i2c. */
-uint32_t sleep_mask;
-
-/* Unused: required for shimming i2c. */
void watchdog_reload(void)
{
}
diff --git a/zephyr/test/i2c_dts/CMakeLists.txt b/zephyr/test/i2c_dts/CMakeLists.txt
index 1537267349..eea2834af1 100644
--- a/zephyr/test/i2c_dts/CMakeLists.txt
+++ b/zephyr/test/i2c_dts/CMakeLists.txt
@@ -3,8 +3,6 @@
# found in the LICENSE file.
cmake_minimum_required(VERSION 3.13.1)
-set(BOARD native_posix)
-
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
project(i2c_test)
diff --git a/zephyr/test/system/CMakeLists.txt b/zephyr/test/system/CMakeLists.txt
index dda6be4a4b..2afa9d6301 100644
--- a/zephyr/test/system/CMakeLists.txt
+++ b/zephyr/test/system/CMakeLists.txt
@@ -3,8 +3,6 @@
# found in the LICENSE file.
cmake_minimum_required(VERSION 3.13.1)
-
-set(BOARD native_posix)
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
project(system_test)
diff --git a/zephyr/test/system/prj.conf b/zephyr/test/system/prj.conf
index bcaca677c5..03357fa10f 100644
--- a/zephyr/test/system/prj.conf
+++ b/zephyr/test/system/prj.conf
@@ -1,22 +1,4 @@
CONFIG_ZTEST=y
CONFIG_PLATFORM_EC=y
-CONFIG_PLATFORM_EC_I2C=n
CONFIG_CROS_EC=y
CONFIG_LOG=y
-
-# Disable all other shimmed code.
-CONFIG_SHIMMED_TASKS=n
-CONFIG_PLATFORM_EC_I2C=n
-CONFIG_PLATFORM_EC_KEYBOARD=n
-CONFIG_PLATFORM_EC_HOSTCMD=n
-CONFIG_PLATFORM_EC_TIMER=n
-
-CONFIG_CROS_EC_PROGRAM_MEMORY_BASE=0x10090000
-CONFIG_CROS_EC_RAM_BASE=0x200c0000
-CONFIG_CROS_EC_DATA_RAM_SIZE=0x00010000
-CONFIG_CROS_EC_RAM_SIZE=0x0000f800
-
-CONFIG_CROS_EC_RO_MEM_OFF=0x0
-CONFIG_CROS_EC_RO_SIZE=0xb000
-CONFIG_CROS_EC_RW_MEM_OFF=0xb000
-CONFIG_CROS_EC_RW_SIZE=0x75000
diff --git a/zephyr/test/tasks/CMakeLists.txt b/zephyr/test/tasks/CMakeLists.txt
index 174d3b6428..f5ea76e67e 100644
--- a/zephyr/test/tasks/CMakeLists.txt
+++ b/zephyr/test/tasks/CMakeLists.txt
@@ -1,28 +1,14 @@
# Copyright 2020 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.
-# SPDX-License-Identifier: Apache-2.0
cmake_minimum_required(VERSION 3.13.1)
-set(BOARD native_posix)
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
project(tasks)
-# Need to ensure that we are including only zephyr definitions in include files
-# We cannot set these via kconfig, since this unit test does not bring in the
-# zephyr-chrome repository
-zephyr_compile_definitions("CONFIG_ZEPHYR")
-zephyr_compile_definitions("CONFIG_SHIMMED_TASKS")
+# Include the local test directory for shimmed_test_tasks.h
+zephyr_include_directories("${CMAKE_CURRENT_SOURCE_DIR}")
-# We need to include the EC include directory and this local test directory
-# for the task defines
-zephyr_include_directories(
- "${CMAKE_CURRENT_SOURCE_DIR}"
- "${PLATFORM_EC}/zephyr/shim/include"
- "${PLATFORM_EC}/fuzz"
- "${PLATFORM_EC}/test"
- "${PLATFORM_EC}/include")
-
-# Include the test source and the file under test
-target_sources(app PRIVATE main.c)
-target_sources(app PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/../../shim/src/tasks.c")
+target_sources(app PRIVATE
+ main.c
+ "${CMAKE_CURRENT_SOURCE_DIR}/../../shim/src/tasks.c") \ No newline at end of file
diff --git a/zephyr/test/tasks/prj.conf b/zephyr/test/tasks/prj.conf
index d2cdafda60..77e8ab9b0c 100644
--- a/zephyr/test/tasks/prj.conf
+++ b/zephyr/test/tasks/prj.conf
@@ -4,4 +4,5 @@
CONFIG_ZTEST=y
CONFIG_HAS_TEST_TASKS=y
-CONFIG_POLL=y
+CONFIG_PLATFORM_EC=y
+CONFIG_CROS_EC=y
diff --git a/zephyr/zmake/zmake/project.py b/zephyr/zmake/zmake/project.py
index 7bb68a7018..db8e5a2e17 100644
--- a/zephyr/zmake/zmake/project.py
+++ b/zephyr/zmake/zmake/project.py
@@ -38,9 +38,6 @@ class ProjectConfig:
'toolchain': {
'type': 'string',
},
- 'prefer-zephyr-sdk': {
- 'type': 'boolean',
- },
'is-test': {
'type': 'boolean',
},
@@ -70,10 +67,6 @@ class ProjectConfig:
return self.config_dict['toolchain']
@property
- def zephyr_sdk_is_preferred(self):
- return self.config_dict.get('prefer-zephyr-sdk', False)
-
- @property
def is_test(self):
return self.config_dict.get('is-test', False)
diff --git a/zephyr/zmake/zmake/zmake.py b/zephyr/zmake/zmake/zmake.py
index 5a2e0d0105..2a9587ffe5 100644
--- a/zephyr/zmake/zmake/zmake.py
+++ b/zephyr/zmake/zmake/zmake.py
@@ -94,21 +94,6 @@ class Zmake:
if not toolchain:
toolchain = project.config.toolchain
- if project.config.zephyr_sdk_is_preferred:
- try:
- toolchains.find_zephyr_sdk()
- except OSError:
- self.logger.warning(
- 'Unable to find the Zephyr SDK, which is the preferred '
- 'toolchain for this project (however, unavailable in '
- 'the chroot by default). Using %r instead, which '
- 'will probably compile but may not actually work at '
- 'all. See go/zephyr-care for more info.', toolchain)
- else:
- self.logger.info(
- 'Zephyr SDK is available. Using it instead of %r.',
- toolchain)
- toolchain = 'zephyr'
toolchain_config = toolchains.get_toolchain(toolchain, module_paths)
if not build_dir.exists():