summaryrefslogtreecommitdiff
path: root/zephyr/shim/src
diff options
context:
space:
mode:
Diffstat (limited to 'zephyr/shim/src')
-rw-r--r--zephyr/shim/src/CMakeLists.txt14
-rw-r--r--zephyr/shim/src/adc.c5
-rw-r--r--zephyr/shim/src/battery.c6
-rw-r--r--zephyr/shim/src/bb_retimer_usb_mux.c13
-rw-r--r--zephyr/shim/src/bc12.c5
-rw-r--r--zephyr/shim/src/bc12_pi3usb9201.c10
-rw-r--r--zephyr/shim/src/bc12_rt9490.c7
-rw-r--r--zephyr/shim/src/cbi/CMakeLists.txt7
-rw-r--r--zephyr/shim/src/cbi/cbi_eeprom.c37
-rw-r--r--zephyr/shim/src/cbi/cros_cbi.c3
-rw-r--r--zephyr/shim/src/cbi/cros_cbi_fw_config.c16
-rw-r--r--zephyr/shim/src/cbi/cros_cbi_ssfc.c29
-rw-r--r--zephyr/shim/src/charger.c3
-rw-r--r--zephyr/shim/src/chipset_api.c3
-rw-r--r--zephyr/shim/src/chipset_state_check.h2
-rw-r--r--zephyr/shim/src/console.c31
-rw-r--r--zephyr/shim/src/console_buffer.c4
-rw-r--r--zephyr/shim/src/crc.c4
-rw-r--r--zephyr/shim/src/espi.c24
-rw-r--r--zephyr/shim/src/fan.c32
-rw-r--r--zephyr/shim/src/flash.c11
-rw-r--r--zephyr/shim/src/gpio.c40
-rw-r--r--zephyr/shim/src/gpio_id.c20
-rw-r--r--zephyr/shim/src/gpio_int.c12
-rw-r--r--zephyr/shim/src/hooks.c11
-rw-r--r--zephyr/shim/src/host_command.c4
-rw-r--r--zephyr/shim/src/hwtimer.c5
-rw-r--r--zephyr/shim/src/i2c.c11
-rw-r--r--zephyr/shim/src/ioex.c9
-rw-r--r--zephyr/shim/src/ioex_drv.c47
-rw-r--r--zephyr/shim/src/keyboard_raw.c17
-rw-r--r--zephyr/shim/src/keyscan.c12
-rw-r--r--zephyr/shim/src/led_driver/CMakeLists.txt4
-rw-r--r--zephyr/shim/src/led_driver/led.c20
-rw-r--r--zephyr/shim/src/led_driver/led.h10
-rw-r--r--zephyr/shim/src/led_driver/led_gpio.c19
-rw-r--r--zephyr/shim/src/led_driver/led_pwm.c22
-rw-r--r--zephyr/shim/src/log_backend_console_buffer.c8
-rw-r--r--zephyr/shim/src/motionsense_sensors.c7
-rw-r--r--zephyr/shim/src/panic.c8
-rw-r--r--zephyr/shim/src/power.c30
-rw-r--r--zephyr/shim/src/ppc.c7
-rw-r--r--zephyr/shim/src/pwm_hc.c12
-rw-r--r--zephyr/shim/src/pwm_led.c1
-rw-r--r--zephyr/shim/src/rtc.c6
-rw-r--r--zephyr/shim/src/switchcap_gpio.c31
-rw-r--r--zephyr/shim/src/switchcap_ln9310.c26
-rw-r--r--zephyr/shim/src/system.c13
-rw-r--r--zephyr/shim/src/tasks.c46
-rw-r--r--zephyr/shim/src/tcpc.c10
-rw-r--r--zephyr/shim/src/tcpc_nct38xx.c6
-rw-r--r--zephyr/shim/src/temp_sensors.c69
-rw-r--r--zephyr/shim/src/thermal.c2
-rw-r--r--zephyr/shim/src/usb_muxes.c11
-rw-r--r--zephyr/shim/src/usba.c5
-rw-r--r--zephyr/shim/src/watchdog.c10
-rw-r--r--zephyr/shim/src/ztest_system.c2
57 files changed, 387 insertions, 452 deletions
diff --git a/zephyr/shim/src/CMakeLists.txt b/zephyr/shim/src/CMakeLists.txt
index 543c2b2303..97968e8a52 100644
--- a/zephyr/shim/src/CMakeLists.txt
+++ b/zephyr/shim/src/CMakeLists.txt
@@ -5,7 +5,9 @@
zephyr_library_sources(console.c)
zephyr_library_sources(crc.c)
zephyr_library_sources(gpio.c)
+zephyr_library_sources(gpio_id.c)
zephyr_library_sources(gpio_int.c)
+zephyr_library_sources(power.c)
add_subdirectory("cbi")
add_subdirectory("led_driver")
@@ -29,8 +31,6 @@ zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_HOST_INTERFACE_ESPI
espi.c)
zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_FAN fan.c)
zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_FLASH_CROS flash.c)
-zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_GPIO_ID
- gpio_id.c)
zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_HOOKS hooks.c)
zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_HOSTCMD host_command.c)
zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_HOSTCMD_CONSOLE
@@ -42,22 +42,20 @@ if (NOT DEFINED CONFIG_PLATFORM_EC_KEYBOARD_DISCRETE)
zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_KEYBOARD
keyboard_raw.c)
endif()
-zephyr_library_sources_ifdef(CONFIG_CROS_EC_KEYSCAN keyscan.c)
+zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_KEYBOARD keyscan.c)
zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_LOG_BACKEND_CONSOLE_BUFFER
log_backend_console_buffer.c)
zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_MKBP_EVENT mkbp_event.c)
zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_MOTIONSENSE
motionsense_sensors.c)
zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_PANIC panic.c)
-zephyr_library_sources_ifdef(CONFIG_CROS_EC_POWER_SIGNAL_LIST
- power.c)
zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_PWM_HC pwm_hc.c)
zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_LED_PWM pwm_led.c)
zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_RTC rtc.c)
zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_SWITCHCAP_GPIO
- switchcap_gpio.c)
-zephyr_library_sources_ifdef(CONFIG_CROS_EC_SWITCHCAP_LN9310
- switchcap_ln9310.c)
+ switchcap_gpio.c)
+zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_SWITCHCAP_LN9310
+ switchcap_ln9310.c)
zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_TEMP_SENSOR temp_sensors.c
thermal.c)
zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_TIMER hwtimer.c)
diff --git a/zephyr/shim/src/adc.c b/zephyr/shim/src/adc.c
index b448823eee..9d5e64376c 100644
--- a/zephyr/shim/src/adc.c
+++ b/zephyr/shim/src/adc.c
@@ -3,12 +3,11 @@
* found in the LICENSE file.
*/
-#include "adc.h"
-#include "zephyr_adc.h"
-
#include <zephyr/devicetree/io-channels.h>
#include <zephyr/drivers/adc.h>
#include <zephyr/logging/log.h>
+#include "adc.h"
+#include "zephyr_adc.h"
LOG_MODULE_REGISTER(shim_adc, LOG_LEVEL_ERR);
diff --git a/zephyr/shim/src/battery.c b/zephyr/shim/src/battery.c
index 8485f1314e..98c0877770 100644
--- a/zephyr/shim/src/battery.c
+++ b/zephyr/shim/src/battery.c
@@ -3,10 +3,10 @@
* found in the LICENSE file.
*/
-#include "battery_fuel_gauge.h"
-
#include <zephyr/devicetree.h>
+#include "battery_fuel_gauge.h"
+
#define NODE_FUEL_GAUGE(node) \
{ \
.manuf_name = DT_PROP(node, manuf_name), \
@@ -17,7 +17,7 @@
.reg_data = DT_PROP(node, ship_mode_reg_data), \
}, \
.sleep_mode = { \
- .sleep_supported = DT_PROP_OR(node, sleep_mode_support, 0), \
+ .sleep_supported = DT_PROP_OR(node, sleep_mode_supported, 0), \
.reg_addr = DT_PROP_OR(node, sleep_mode_reg_addr, 0), \
.reg_data = DT_PROP_OR(node, sleep_mode_reg_data, 0), \
}, \
diff --git a/zephyr/shim/src/bb_retimer_usb_mux.c b/zephyr/shim/src/bb_retimer_usb_mux.c
index b0e3944528..c40068211e 100644
--- a/zephyr/shim/src/bb_retimer_usb_mux.c
+++ b/zephyr/shim/src/bb_retimer_usb_mux.c
@@ -1,13 +1,18 @@
-/* Copyright 2022 The ChromiumOS Authors
+/* Copyright 2022 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/devicetree.h>
+#include <zephyr/sys/util_macro.h>
#include "usb_mux.h"
#include "usbc/usb_muxes.h"
-#include <zephyr/devicetree.h>
-#include <zephyr/sys/util_macro.h>
+/**
+ * This prevents creating struct usb_mux bb_controls[] for platforms that didn't
+ * migrate USB mux configuration to DTS yet.
+ */
+#if DT_HAS_COMPAT_STATUS_OKAY(cros_ec_usb_mux_chain)
BB_RETIMER_CHECK_SAME_CONTROLS(BB_RETIMER_INSTANCES_LIST)
@@ -30,3 +35,5 @@ BB_RETIMER_CHECK_SAME_CONTROLS(BB_RETIMER_INSTANCES_LIST)
BB_CONTROLS_CONST struct bb_usb_control bb_controls[] = {
USB_MUX_BB_RETIMERS_CONTROLS_ARRAY
};
+
+#endif /* #if DT_HAS_COMPAT_STATUS_OKAY(cros_ec_usb_mux_chain) */
diff --git a/zephyr/shim/src/bc12.c b/zephyr/shim/src/bc12.c
index 12b45d2197..6542a166eb 100644
--- a/zephyr/shim/src/bc12.c
+++ b/zephyr/shim/src/bc12.c
@@ -3,15 +3,14 @@
* found in the LICENSE file.
*/
-#include "usb_charge.h"
+#include <zephyr/devicetree.h>
#include "usbc/bc12_pi3usb9201.h"
#include "usbc/bc12_rt1718s.h"
#include "usbc/bc12_rt1739.h"
#include "usbc/bc12_rt9490.h"
#include "usbc/tcpc_rt1718s.h"
#include "usbc/utils.h"
-
-#include <zephyr/devicetree.h>
+#include "usb_charge.h"
#if DT_HAS_COMPAT_STATUS_OKAY(RT1718S_BC12_COMPAT) || \
DT_HAS_COMPAT_STATUS_OKAY(RT1739_BC12_COMPAT) || \
diff --git a/zephyr/shim/src/bc12_pi3usb9201.c b/zephyr/shim/src/bc12_pi3usb9201.c
index d41fcc3212..25d1962ff2 100644
--- a/zephyr/shim/src/bc12_pi3usb9201.c
+++ b/zephyr/shim/src/bc12_pi3usb9201.c
@@ -5,16 +5,20 @@
#define DT_DRV_COMPAT pericom_pi3usb9201
+#include <zephyr/devicetree.h>
#include "bc12/pi3usb9201_public.h"
#include "gpio/gpio_int.h"
#include "hooks.h"
-#include "i2c/i2c.h"
#include "task.h"
#include "usb_charge.h"
#include "usb_pd.h"
#include "usbc/utils.h"
+#include "i2c/i2c.h"
-#include <zephyr/devicetree.h>
+#if DT_HAS_COMPAT_STATUS_OKAY(DT_DRV_COMPAT)
+
+BUILD_ASSERT(DT_NUM_INST_STATUS_OKAY(DT_DRV_COMPAT) > 0,
+ "No compatible BC1.2 instance found");
#define USBC_PORT_BC12(usbc_id, bc12_id) \
[USBC_PORT_NEW(usbc_id)] = { \
@@ -52,3 +56,5 @@ void usb1_evt(enum gpio_signal signal)
usb_charger_task_set_event(1, USB_CHG_EVENT_BC12);
}
#endif
+
+#endif /* DT_HAS_COMPAT_STATUS_OKAY(DT_DRV_COMPAT) */
diff --git a/zephyr/shim/src/bc12_rt9490.c b/zephyr/shim/src/bc12_rt9490.c
index a3c97e7faf..df10fb5570 100644
--- a/zephyr/shim/src/bc12_rt9490.c
+++ b/zephyr/shim/src/bc12_rt9490.c
@@ -3,14 +3,15 @@
* found in the LICENSE file.
*/
-#define DT_DRV_COMPAT richtek_rt9490
+#define DT_DRV_COMPAT richtek_rt9490_bc12
+#include <zephyr/devicetree.h>
#include "driver/charger/rt9490.h"
#include "gpio/gpio_int.h"
#include "hooks.h"
#include "usbc/utils.h"
-#include <zephyr/devicetree.h>
+#if DT_HAS_COMPAT_STATUS_OKAY(DT_DRV_COMPAT)
static void rt9490_bc12_enable_irqs(void)
{
@@ -41,3 +42,5 @@ void rt9490_bc12_dt_interrupt(enum gpio_signal signal)
break;
}
}
+
+#endif /* DT_HAS_COMPAT_STATUS_OKAY(DT_DRV_COMPAT) */
diff --git a/zephyr/shim/src/cbi/CMakeLists.txt b/zephyr/shim/src/cbi/CMakeLists.txt
index a5d3894ad0..4b14f0bb1d 100644
--- a/zephyr/shim/src/cbi/CMakeLists.txt
+++ b/zephyr/shim/src/cbi/CMakeLists.txt
@@ -1,6 +1,9 @@
# SPDX-License-Identifier: Apache-2.0
-zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_CBI cros_cbi.c
+zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_CBI_EEPROM cbi_eeprom.c
+ cros_cbi.c
+ cros_cbi_fw_config.c
+ cros_cbi_ssfc.c)
+zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_CBI_GPIO cros_cbi.c
cros_cbi_fw_config.c
cros_cbi_ssfc.c)
-zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_CBI_EEPROM cbi_eeprom.c)
diff --git a/zephyr/shim/src/cbi/cbi_eeprom.c b/zephyr/shim/src/cbi/cbi_eeprom.c
index 9cd0d0a955..aa6c4e0fa1 100644
--- a/zephyr/shim/src/cbi/cbi_eeprom.c
+++ b/zephyr/shim/src/cbi/cbi_eeprom.c
@@ -3,16 +3,15 @@
* found in the LICENSE file.
*/
-#include "console.h"
-#include "cros_board_info.h"
-#include "write_protect.h"
-
#include <zephyr/drivers/eeprom.h>
#include <zephyr/drivers/gpio.h>
-#define CBI_EEPROM_NODE DT_NODELABEL(cbi_eeprom)
+#include "console.h"
+#include "cros_board_info.h"
+#include "write_protect.h"
-BUILD_ASSERT(DT_NODE_EXISTS(CBI_EEPROM_NODE), "cbi_eeprom node not defined");
+#if DT_NODE_EXISTS(DT_NODELABEL(cbi_eeprom))
+#define CBI_EEPROM_DEV DEVICE_DT_GET(DT_NODELABEL(cbi_eeprom))
#ifdef CONFIG_PLATFORM_EC_EEPROM_CBI_WP
#if !DT_NODE_EXISTS(DT_ALIAS(gpio_cbi_wp))
@@ -26,39 +25,22 @@ void cbi_latch_eeprom_wp(void)
}
#endif /* CONFIG_PLATFORM_EC_EEPROM_CBI_WP */
-test_mockable_static int eeprom_load(uint8_t offset, uint8_t *data, int len)
+static int eeprom_load(uint8_t offset, uint8_t *data, int len)
{
- const struct device *dev;
-
- dev = DEVICE_DT_GET(CBI_EEPROM_NODE);
-
- if (!device_is_ready(dev)) {
- return -ENODEV;
- }
-
- return eeprom_read(dev, offset, data, len);
+ return eeprom_read(CBI_EEPROM_DEV, offset, data, len);
}
static int eeprom_is_write_protected(void)
{
- if (IS_ENABLED(CONFIG_PLATFORM_EC_BYPASS_CBI_EEPROM_WP_CHECK)) {
+ if (IS_ENABLED(CONFIG_PLATFORM_EC_BYPASS_CBI_EEPROM_WP_CHECK))
return 0;
- }
return write_protect_is_asserted();
}
static int eeprom_store(uint8_t *cbi)
{
- const struct device *dev;
-
- dev = DEVICE_DT_GET(CBI_EEPROM_NODE);
-
- if (!device_is_ready(dev)) {
- return -ENODEV;
- }
-
- return eeprom_write(dev, 0, cbi,
+ return eeprom_write(CBI_EEPROM_DEV, 0, cbi,
((struct cbi_header *)cbi)->total_size);
}
@@ -72,3 +54,4 @@ const struct cbi_storage_config_t cbi_config = {
.storage_type = CBI_STORAGE_TYPE_EEPROM,
.drv = &eeprom_drv,
};
+#endif
diff --git a/zephyr/shim/src/cbi/cros_cbi.c b/zephyr/shim/src/cbi/cros_cbi.c
index e6fa3e8cd1..5b90f9442d 100644
--- a/zephyr/shim/src/cbi/cros_cbi.c
+++ b/zephyr/shim/src/cbi/cros_cbi.c
@@ -3,8 +3,9 @@
* found in the LICENSE file.
*/
-#include "cros_board_info.h"
#include "cros_cbi.h"
+
+#include "cros_board_info.h"
#include "hooks.h"
static void cros_cbi_ec_init(void)
diff --git a/zephyr/shim/src/cbi/cros_cbi_fw_config.c b/zephyr/shim/src/cbi/cros_cbi_fw_config.c
index 8f6086eb58..6710a30726 100644
--- a/zephyr/shim/src/cbi/cros_cbi_fw_config.c
+++ b/zephyr/shim/src/cbi/cros_cbi_fw_config.c
@@ -3,11 +3,11 @@
* found in the LICENSE file.
*/
+#include <zephyr/logging/log.h>
+
#include "cros_board_info.h"
#include "cros_cbi.h"
-#include <zephyr/logging/log.h>
-
LOG_MODULE_REGISTER(cros_cbi_fw_config, LOG_LEVEL_ERR);
/*
@@ -47,13 +47,13 @@ LOG_MODULE_REGISTER(cros_cbi_fw_config, LOG_LEVEL_ERR);
#define FW_SHIFT_MASK(id) (FW_MASK(id) << FW_START(id))
/*
- * For a child "cros-ec,cbi-fw-config-value" node, retrieve the
+ * For a child "named-cbi-fw-config-value" node, retrieve the
* size of the parent field this value is associated with.
*/
#define FW_PARENT_SIZE(id) DT_PROP(DT_PARENT(id), size)
/*
- * For a child "cros-ec,cbi-fw-config-value" node, retrieve the
+ * For a child "named-cbi-fw-config-value" node, retrieve the
* start of the parent field this value is associated with.
*/
#define FW_PARENT_START(id) DT_PROP(DT_PARENT(id), start)
@@ -115,7 +115,7 @@ DT_FOREACH_STATUS_OKAY(CBI_FW_CONFIG_VALUE_COMPAT, FW_VALUE_BUILD_ASSERT)
/*
* Define bit fields based on the device tree entries. Example:
* cbi-fw-config {
- * compatible = "cros-ec,cbi-fw-config";
+ * compatible = "named-cbi-fw-config";
*
* fan {
* enum-name = "FW_CONFIG_FAN";
@@ -123,7 +123,7 @@ DT_FOREACH_STATUS_OKAY(CBI_FW_CONFIG_VALUE_COMPAT, FW_VALUE_BUILD_ASSERT)
* size = <1>;
* fan_present {
* enum-name = "FW_FAN_PRESENT"
- * compatible = "cros-ec,cbi-fw-config-value";
+ * compatible = "named-cbi-fw-config-value";
* value = <1>;
* };
* };
@@ -148,7 +148,7 @@ DT_FOREACH_STATUS_OKAY(CBI_FW_CONFIG_VALUE_COMPAT, FW_VALUE_BUILD_ASSERT)
break;
/*
- * Create a case for every child of this "cros-ec,cbi-fw-config" node.
+ * Create a case for every child of this "named-cbi-fw-config" node.
*/
#define FW_FIELD_NODES(inst, cached, value) \
DT_FOREACH_CHILD_STATUS_OKAY_VARGS(inst, FW_FIELD_CASE, cached, value)
@@ -177,7 +177,7 @@ static int cros_cbi_fw_config_get_field(uint32_t cached_fw_config,
{
switch (field_id) {
/*
- * Iterate through all the the "cros-ec,cbi-fw-config" nodes,
+ * Iterate through all the the "named-cbi-fw-config" nodes,
* and create cases for all of their child nodes.
*/
DT_FOREACH_STATUS_OKAY_VARGS(CBI_FW_CONFIG_COMPAT,
diff --git a/zephyr/shim/src/cbi/cros_cbi_ssfc.c b/zephyr/shim/src/cbi/cros_cbi_ssfc.c
index f20ca457f4..eb0f69b1cb 100644
--- a/zephyr/shim/src/cbi/cros_cbi_ssfc.c
+++ b/zephyr/shim/src/cbi/cros_cbi_ssfc.c
@@ -3,24 +3,25 @@
* found in the LICENSE file.
*/
+#include <zephyr/logging/log.h>
+
#include "cros_board_info.h"
#include "cros_cbi.h"
-#include <zephyr/logging/log.h>
-
LOG_MODULE_REGISTER(cros_cbi_ssfc, LOG_LEVEL_ERR);
-/* Actually, two "compatible" values are handle here - cros_ec_cbi_ssfc_value
- * and cros_ec_cbi_ssfc. cros_ec_cbi_ssfc_value nodes are grandchildren of the
- * cros_ec_cbi_ssfc node. cros_ec_cbi_ssfc_value is introduced to iterate over
- * grandchildren of the cros_ec_cbi_ssfc (macro DT_FOREACH_CHILD can not be
- * nested) and it can be pointed by a sensor dts to indicate alternative usage.
+/* Actually, two "compatible" values are handle here -
+ * named_cbi_ssfc_value and named_cbi_ssfc. named_cbi_ssfc_value nodes are
+ * grandchildren of the named_cbi_ssfc node. named_cbi_ssfc_value is introduced
+ * to iterate over grandchildren of the named_cbi_ssfc(macro
+ * DT_FOREACH_CHILD can not be nested) and it can be pointed by a sensor dts to
+ * indicate alternative usage.
*/
-#define DT_DRV_COMPAT cros_ec_cbi_ssfc_value
+#define DT_DRV_COMPAT named_cbi_ssfc_value
-BUILD_ASSERT(DT_NUM_INST_STATUS_OKAY(cros_ec_cbi_ssfc) < 2,
+BUILD_ASSERT(DT_NUM_INST_STATUS_OKAY(named_cbi_ssfc) < 2,
"More than 1 CBI SSFS node");
-#define CBI_SSFC_NODE DT_INST(0, cros_ec_cbi_ssfc)
+#define CBI_SSFC_NODE DT_INST(0, named_cbi_ssfc)
#define CBI_SSFC_INIT_DEFAULT_ID(id, ssfc) \
do { \
@@ -72,13 +73,13 @@ BUILD_ASSERT(CBI_SSFC_FIELDS_SIZE <= 32, "CBI SSFS is bigger than 32 bits");
/*
* Define union bit fields based on the device tree entries. Example:
* cbi-ssfc {
- * compatible = "cros-ec,cbi-ssfc";
+ * compatible = "named-cbi-ssfc";
*
* base_sensor {
* enum-name = "BASE_SENSOR";
* size = <3>;
* bmi160 {
- * compatible = "cros-ec,cbi-ssfc-value";
+ * compatible = "named-cbi-ssfc-value";
* status = "okay";
* value = <1>;
* };
@@ -87,7 +88,7 @@ BUILD_ASSERT(CBI_SSFC_FIELDS_SIZE <= 32, "CBI SSFS is bigger than 32 bits");
* enum-name = "LID_SENSOR";
* size = <3>;
* bma255 {
- * compatible = "cros-ec,cbi-ssfc-value";
+ * compatible = "named-cbi-ssfc-value";
* status = "okay";
* value = <1>;
* };
@@ -96,7 +97,7 @@ BUILD_ASSERT(CBI_SSFC_FIELDS_SIZE <= 32, "CBI SSFS is bigger than 32 bits");
* enum-name = "LIGHTBAR";
* size = <2>;
* 10_led {
- * compatible = "cros-ec,cbi-ssfc-value";
+ * compatible = "named-cbi-ssfc-value";
* status = "okay";
* value = <1>;
* };
diff --git a/zephyr/shim/src/charger.c b/zephyr/shim/src/charger.c
index 9d6021ad7d..35ede5a8f7 100644
--- a/zephyr/shim/src/charger.c
+++ b/zephyr/shim/src/charger.c
@@ -4,6 +4,7 @@
*/
#include "charger.h"
+#include <zephyr/devicetree.h>
#include "charger/chg_bq25710.h"
#include "charger/chg_isl923x.h"
#include "charger/chg_isl9241.h"
@@ -11,8 +12,6 @@
#include "charger/chg_sm5803.h"
#include "usbc/utils.h"
-#include <zephyr/devicetree.h>
-
#define CHG_CHIP_ENTRY(usbc_id, chg_id, config_fn) \
[USBC_PORT_NEW(usbc_id)] = config_fn(chg_id)
diff --git a/zephyr/shim/src/chipset_api.c b/zephyr/shim/src/chipset_api.c
index 925d13f6e1..6c48719a7f 100644
--- a/zephyr/shim/src/chipset_api.c
+++ b/zephyr/shim/src/chipset_api.c
@@ -5,9 +5,10 @@
/* Chipset interface APIs */
+#include "common.h"
+
#include "ap_power/ap_power_interface.h"
#include "chipset_state_check.h"
-#include "common.h"
int chipset_in_state(int state_mask)
{
diff --git a/zephyr/shim/src/chipset_state_check.h b/zephyr/shim/src/chipset_state_check.h
index c33a3f9553..2d10b2ce4a 100644
--- a/zephyr/shim/src/chipset_state_check.h
+++ b/zephyr/shim/src/chipset_state_check.h
@@ -6,8 +6,8 @@
#ifndef __CHIPSET_STATE_CHECK_H__
#define __CHIPSET_STATE_CHECK_H__
-#include "ap_power/ap_power_interface.h"
#include "chipset.h"
+#include "ap_power/ap_power_interface.h"
BUILD_ASSERT((int)AP_POWER_STATE_HARD_OFF == (int)CHIPSET_STATE_HARD_OFF);
BUILD_ASSERT((int)AP_POWER_STATE_SOFT_OFF == (int)CHIPSET_STATE_SOFT_OFF);
diff --git a/zephyr/shim/src/console.c b/zephyr/shim/src/console.c
index fa6dc5a613..4ac8e249cb 100644
--- a/zephyr/shim/src/console.c
+++ b/zephyr/shim/src/console.c
@@ -3,6 +3,20 @@
* found in the LICENSE file.
*/
+#include <zephyr/device.h>
+#include <zephyr/drivers/uart.h>
+#include <zephyr/shell/shell.h>
+#ifdef CONFIG_SHELL_BACKEND_DUMMY /* nocheck */
+#include <zephyr/shell/shell_dummy.h> /* nocheck */
+#endif
+#include <zephyr/shell/shell_uart.h>
+#include <stdbool.h>
+#include <string.h>
+#include <zephyr/sys/printk.h>
+#include <zephyr/sys/ring_buffer.h>
+#include <zephyr/kernel.h>
+#include <zephyr/logging/log.h>
+
/*
* TODO(b/238433667): Include EC printf functions
* (crec_vsnprintf/crec_snprintf) until we switch to the standard
@@ -16,21 +30,6 @@
#include "usb_console.h"
#include "zephyr_console_shim.h"
-#include <stdbool.h>
-#include <string.h>
-
-#include <zephyr/device.h>
-#include <zephyr/drivers/uart.h>
-#include <zephyr/kernel.h>
-#include <zephyr/logging/log.h>
-#include <zephyr/shell/shell.h>
-#ifdef CONFIG_SHELL_BACKEND_DUMMY /* nocheck */
-#include <zephyr/shell/shell_dummy.h> /* nocheck */
-#endif
-#include <zephyr/shell/shell_uart.h>
-#include <zephyr/sys/printk.h>
-#include <zephyr/sys/ring_buffer.h>
-
#if !defined(CONFIG_SHELL_BACKEND_SERIAL) && \
!defined(CONFIG_SHELL_BACKEND_DUMMY) /* nocheck */
#error Must select either CONFIG_SHELL_BACKEND_SERIAL or \
@@ -322,7 +321,7 @@ void uart_write_char(char c)
{
uart_poll_out(uart_shell_dev, c);
- if (IS_ENABLED(CONFIG_PLATFORM_EC_HOSTCMD_CONSOLE) && !k_is_in_isr())
+ if (IS_ENABLED(CONFIG_PLATFORM_EC_HOSTCMD_CONSOLE))
console_buf_notify_chars(&c, 1);
}
diff --git a/zephyr/shim/src/console_buffer.c b/zephyr/shim/src/console_buffer.c
index f5e80b2d20..dad0031267 100644
--- a/zephyr/shim/src/console_buffer.c
+++ b/zephyr/shim/src/console_buffer.c
@@ -3,12 +3,12 @@
* found in the LICENSE file.
*/
+#include <zephyr/kernel.h>
+
#include "common.h"
#include "console.h"
#include "ec_commands.h"
-#include <zephyr/kernel.h>
-
static char console_buf[CONFIG_PLATFORM_EC_HOSTCMD_CONSOLE_BUF_SIZE];
static uint32_t previous_snapshot_idx;
static uint32_t current_snapshot_idx;
diff --git a/zephyr/shim/src/crc.c b/zephyr/shim/src/crc.c
index 1e98c1cf3f..f8ce335029 100644
--- a/zephyr/shim/src/crc.c
+++ b/zephyr/shim/src/crc.c
@@ -3,10 +3,10 @@
* found in the LICENSE file.
*/
-#include "crc8.h"
-
#include <zephyr/sys/crc.h>
+#include "crc8.h"
+
/* Polynomial representation for x^8 + x^2 + x + 1 is 0x07 */
#define SMBUS_POLYNOMIAL 0x07
diff --git a/zephyr/shim/src/espi.c b/zephyr/shim/src/espi.c
index 9cc5de8f0b..6a8e18e262 100644
--- a/zephyr/shim/src/espi.c
+++ b/zephyr/shim/src/espi.c
@@ -3,6 +3,17 @@
* found in the LICENSE file.
*/
+#include <atomic.h>
+#include <zephyr/device.h>
+#include <zephyr/drivers/espi.h>
+#include <zephyr/drivers/gpio.h>
+#include <zephyr/logging/log.h>
+#include <zephyr/kernel.h>
+#include <stdint.h>
+
+#include <ap_power/ap_power.h>
+#include <ap_power/ap_power_events.h>
+#include <ap_power/ap_power_espi.h>
#include "acpi.h"
#include "chipset.h"
#include "common.h"
@@ -17,19 +28,6 @@
#include "timer.h"
#include "zephyr_espi_shim.h"
-#include <stdint.h>
-
-#include <zephyr/device.h>
-#include <zephyr/drivers/espi.h>
-#include <zephyr/drivers/gpio.h>
-#include <zephyr/kernel.h>
-#include <zephyr/logging/log.h>
-
-#include <ap_power/ap_power.h>
-#include <ap_power/ap_power_espi.h>
-#include <ap_power/ap_power_events.h>
-#include <atomic.h>
-
#define VWIRE_PULSE_TRIGGER_TIME \
CONFIG_PLATFORM_EC_HOST_INTERFACE_ESPI_DEFAULT_VW_WIDTH_US
diff --git a/zephyr/shim/src/fan.c b/zephyr/shim/src/fan.c
index 9978e6f4ca..c7074b0c4d 100644
--- a/zephyr/shim/src/fan.c
+++ b/zephyr/shim/src/fan.c
@@ -5,6 +5,12 @@
#define DT_DRV_COMPAT cros_ec_fans
+#include <zephyr/drivers/gpio.h>
+#include <zephyr/drivers/pwm.h>
+#include <zephyr/drivers/sensor.h>
+#include <zephyr/logging/log.h>
+#include <zephyr/sys/util_macro.h>
+
#include "fan.h"
#include "gpio_signal.h"
#include "hooks.h"
@@ -12,12 +18,6 @@
#include "system.h"
#include "util.h"
-#include <zephyr/drivers/gpio.h>
-#include <zephyr/drivers/pwm.h>
-#include <zephyr/drivers/sensor.h>
-#include <zephyr/logging/log.h>
-#include <zephyr/sys/util_macro.h>
-
LOG_MODULE_REGISTER(fan_shim, LOG_LEVEL_ERR);
BUILD_ASSERT(DT_NUM_INST_STATUS_OKAY(DT_DRV_COMPAT) == 1,
@@ -43,7 +43,6 @@ BUILD_ASSERT(DT_NUM_INST_STATUS_OKAY(DT_DRV_COMPAT) == 1,
.rpm_min = DT_PROP(node_id, rpm_min), \
.rpm_start = DT_PROP(node_id, rpm_start), \
.rpm_max = DT_PROP(node_id, rpm_max), \
- .rpm_deviation = DT_PROP(node_id, rpm_deviation), \
};
#define FAN_INST(node_id) \
@@ -62,6 +61,14 @@ DT_INST_FOREACH_CHILD(0, FAN_CONFIGS)
const struct fan_t fans[FAN_CH_COUNT] = { DT_INST_FOREACH_CHILD(0, FAN_INST) };
+/* Rpm deviation (Unit:percent) */
+#ifndef RPM_DEVIATION
+#define RPM_DEVIATION 7
+#endif
+
+/* Margin of target rpm */
+#define RPM_MARGIN(rpm_target) (((rpm_target)*RPM_DEVIATION) / 100)
+
/* Fan mode */
enum fan_mode {
/* FAN rpm mode */
@@ -125,9 +132,9 @@ static void fan_pwm_update(int ch)
LOG_DBG("FAN PWM %s set percent (%d), pulse %d", pwm_dev->name,
data->pwm_percent, pulse_ns);
- ret = pwm_set_pulse_dt(&cfg->pwm, pulse_ns);
+ ret = pwm_set_dt(&cfg->pwm, cfg->pwm.period, pulse_ns);
if (ret) {
- LOG_ERR("pwm_set_pulse_dt failed %s (%d)", pwm_dev->name, ret);
+ LOG_ERR("pwm_set() failed %s (%d)", pwm_dev->name, ret);
}
}
@@ -219,10 +226,9 @@ enum fan_status fan_smart_control(int ch)
int duty, rpm_diff;
int rpm_actual = data->rpm_actual;
int rpm_target = data->rpm_target;
- int deviation = fans[ch].rpm->rpm_deviation;
/* wait rpm is stable */
- if (ABS(rpm_actual - data->rpm_pre) > (rpm_target * deviation / 100)) {
+ if (ABS(rpm_actual - data->rpm_pre) > RPM_MARGIN(rpm_actual)) {
data->rpm_pre = rpm_actual;
return FAN_STATUS_CHANGING;
}
@@ -237,7 +243,7 @@ enum fan_status fan_smart_control(int ch)
return FAN_STATUS_STOPPED;
}
- if (rpm_diff > (rpm_target * deviation / 100)) {
+ if (rpm_diff > RPM_MARGIN(rpm_target)) {
/* Increase PWM duty */
if (duty == 100) {
return FAN_STATUS_FRUSTRATED;
@@ -245,7 +251,7 @@ enum fan_status fan_smart_control(int ch)
fan_adjust_duty(ch, rpm_diff, duty);
return FAN_STATUS_CHANGING;
- } else if (rpm_diff < -(rpm_target * deviation / 100)) {
+ } else if (rpm_diff < -RPM_MARGIN(rpm_target)) {
/* Decrease PWM duty */
if (duty == 1 && rpm_target != 0) {
return FAN_STATUS_FRUSTRATED;
diff --git a/zephyr/shim/src/flash.c b/zephyr/shim/src/flash.c
index 5b7079e450..8aa7deecf5 100644
--- a/zephyr/shim/src/flash.c
+++ b/zephyr/shim/src/flash.c
@@ -3,18 +3,17 @@
* found in the LICENSE file.
*/
+#include <flash.h>
+#include <zephyr/kernel.h>
+#include <zephyr/logging/log.h>
+#include <zephyr/drivers/flash.h>
+
#include "console.h"
#include "drivers/cros_flash.h"
#include "registers.h"
#include "task.h"
#include "util.h"
-#include <zephyr/drivers/flash.h>
-#include <zephyr/kernel.h>
-#include <zephyr/logging/log.h>
-
-#include <flash.h>
-
LOG_MODULE_REGISTER(shim_flash, LOG_LEVEL_ERR);
#if !DT_HAS_CHOSEN(cros_ec_flash_controller)
diff --git a/zephyr/shim/src/gpio.c b/zephyr/shim/src/gpio.c
index a629c77a11..528569980d 100644
--- a/zephyr/shim/src/gpio.c
+++ b/zephyr/shim/src/gpio.c
@@ -3,19 +3,19 @@
* found in the LICENSE file.
*/
+#include <zephyr/device.h>
+#include <zephyr/init.h>
+#include <zephyr/kernel.h>
+#include <zephyr/logging/log.h>
+
#ifdef __REQUIRE_ZEPHYR_GPIOS__
#undef __REQUIRE_ZEPHYR_GPIOS__
#endif
-#include "cros_version.h"
#include "gpio.h"
#include "gpio/gpio.h"
#include "ioexpander.h"
#include "system.h"
-
-#include <zephyr/device.h>
-#include <zephyr/init.h>
-#include <zephyr/kernel.h>
-#include <zephyr/logging/log.h>
+#include "cros_version.h"
LOG_MODULE_REGISTER(gpio_shim, LOG_LEVEL_ERR);
@@ -166,11 +166,6 @@ int gpio_or_ioex_get_level(int signal, int *value)
return EC_SUCCESS;
}
-/* Don't define any 1.8V bit if not supported. */
-#ifndef GPIO_VOLTAGE_1P8
-#define GPIO_VOLTAGE_1P8 0
-#endif
-
/* GPIO flags which are the same in Zephyr and this codebase */
#define GPIO_CONVERSION_SAME_BITS \
(GPIO_OPEN_DRAIN | GPIO_PULL_UP | GPIO_PULL_DOWN | GPIO_VOLTAGE_1P8 | \
@@ -255,10 +250,7 @@ const struct gpio_dt_spec *gpio_get_dt_spec(enum gpio_signal signal)
return &configs[signal].spec;
}
-/* Allow access to this function in tests so we can run it multiple times
- * without having to create a new binary for each run.
- */
-test_export_static int init_gpios(const struct device *unused)
+static int init_gpios(const struct device *unused)
{
gpio_flags_t flags;
bool is_sys_jumped = system_jumped_to_this_image();
@@ -325,10 +317,9 @@ void gpio_reset(enum gpio_signal signal)
void gpio_reset_port(const struct device *port)
{
for (size_t i = 0; i < ARRAY_SIZE(configs); ++i) {
- if (port == configs[i].spec.port) {
+ if (port == configs[i].spec.port)
gpio_pin_configure_dt(&configs[i].spec,
configs[i].init_flags);
- }
}
}
@@ -343,17 +334,12 @@ void gpio_set_flags(enum gpio_signal signal, int flags)
void gpio_set_flags_by_mask(uint32_t port, uint32_t mask, uint32_t flags)
{
- const gpio_flags_t zephyr_flags = convert_to_zephyr_flags(flags);
+ int pin;
- /* Using __builtin_ctz here will guarantee that this loop is as
- * performant as the underlying architecture allows it to be.
- */
- while (mask != 0) {
- int pin = __builtin_ctz(mask);
-
- gpio_configure_port_pin(port, pin, zephyr_flags);
- mask &= ~BIT(pin);
- }
+ for (pin = 0; pin < 8; pin++)
+ if (mask & BIT(pin))
+ gpio_configure_port_pin(port, pin,
+ convert_to_zephyr_flags(flags));
}
int signal_is_gpio(int signal)
diff --git a/zephyr/shim/src/gpio_id.c b/zephyr/shim/src/gpio_id.c
index e157e2d487..b994154cd1 100644
--- a/zephyr/shim/src/gpio_id.c
+++ b/zephyr/shim/src/gpio_id.c
@@ -3,14 +3,16 @@
* found in the LICENSE file.
*/
+#include <zephyr/devicetree.h>
+
#ifdef __REQUIRE_ZEPHYR_GPIOS__
#undef __REQUIRE_ZEPHYR_GPIOS__
#endif
-
#include "gpio.h"
#include "util.h"
-#include <zephyr/devicetree.h>
+#define IS_BOARD_COMPATIBLE DT_NODE_HAS_COMPAT(DT_PATH(board), cros_ec_gpio_id)
+#define IS_SKU_COMPATIBLE DT_NODE_HAS_COMPAT(DT_PATH(sku), cros_ec_gpio_id)
#define CONVERT_NUMERAL_SYSTEM_EVAL(system, bits, nbits) \
system##_from_bits(bits, nbits)
@@ -21,15 +23,14 @@
#define READ_PIN_FROM_PHANDLE(node_id, prop, idx) \
gpio_get_ternary(GPIO_SIGNAL(DT_PHANDLE_BY_IDX(node_id, prop, idx))),
-#define SKU_GPIO_ID_NODE DT_NODELABEL(gpio_id_sku)
-#if DT_NODE_HAS_STATUS(SKU_GPIO_ID_NODE, okay)
+#if DT_NODE_EXISTS(DT_PATH(sku)) && IS_SKU_COMPATIBLE
__override uint32_t board_get_sku_id(void)
{
static uint32_t sku_id = (uint32_t)-1;
if (sku_id == (uint32_t)-1) {
- int bits[] = { DT_FOREACH_PROP_ELEM(SKU_GPIO_ID_NODE, bits,
+ int bits[] = { DT_FOREACH_PROP_ELEM(DT_PATH(sku), bits,
READ_PIN_FROM_PHANDLE) };
if (sizeof(bits) == 0)
@@ -45,15 +46,14 @@ __override uint32_t board_get_sku_id(void)
#endif
-#define BOARD_GPIO_ID_NODE DT_NODELABEL(gpio_id_board)
-#if DT_NODE_HAS_STATUS(SKU_GPIO_ID_NODE, okay)
+#if DT_NODE_EXISTS(DT_PATH(board)) && IS_BOARD_COMPATIBLE
__override int board_get_version(void)
{
static int board_version = -1;
if (board_version == -1) {
- int bits[] = { DT_FOREACH_PROP_ELEM(BOARD_GPIO_ID_NODE, bits,
+ int bits[] = { DT_FOREACH_PROP_ELEM(DT_PATH(board), bits,
READ_PIN_FROM_PHANDLE) };
if (sizeof(bits) == 0)
@@ -68,7 +68,3 @@ __override int board_get_version(void)
}
#endif
-
-BUILD_ASSERT(DT_NODE_HAS_STATUS(SKU_GPIO_ID_NODE, okay) ||
- DT_NODE_HAS_STATUS(BOARD_GPIO_ID_NODE, okay),
- "neither sku or board id nodelabels found");
diff --git a/zephyr/shim/src/gpio_int.c b/zephyr/shim/src/gpio_int.c
index 761e7e7b3c..8406f3abe8 100644
--- a/zephyr/shim/src/gpio_int.c
+++ b/zephyr/shim/src/gpio_int.c
@@ -3,18 +3,18 @@
* found in the LICENSE file.
*/
+#include <zephyr/device.h>
+#include <zephyr/init.h>
+#include <zephyr/kernel.h>
+#include <zephyr/logging/log.h>
+
#ifdef __REQUIRE_ZEPHYR_GPIOS__
#undef __REQUIRE_ZEPHYR_GPIOS__
#endif
-#include "cros_version.h"
#include "gpio.h"
#include "gpio/gpio.h"
#include "gpio/gpio_int.h"
-
-#include <zephyr/device.h>
-#include <zephyr/init.h>
-#include <zephyr/kernel.h>
-#include <zephyr/logging/log.h>
+#include "cros_version.h"
LOG_MODULE_REGISTER(gpio_int, LOG_LEVEL_ERR);
diff --git a/zephyr/shim/src/hooks.c b/zephyr/shim/src/hooks.c
index b8f9b917e4..3f11a578c5 100644
--- a/zephyr/shim/src/hooks.c
+++ b/zephyr/shim/src/hooks.c
@@ -3,19 +3,18 @@
* found in the LICENSE file.
*/
+#include <zephyr/kernel.h>
+
+#include <ap_power/ap_power.h>
+#include <ap_power/ap_power_events.h>
#include "common.h"
#include "console.h"
#include "ec_tasks.h"
-#include "hook_types.h"
#include "hooks.h"
+#include "hook_types.h"
#include "task.h"
#include "timer.h"
-#include <zephyr/kernel.h>
-
-#include <ap_power/ap_power.h>
-#include <ap_power/ap_power_events.h>
-
/*
* hook_registry maps each hook_type to the list of handlers for that hook type.
*
diff --git a/zephyr/shim/src/host_command.c b/zephyr/shim/src/host_command.c
index 16f5ae66d8..c5a51332a1 100644
--- a/zephyr/shim/src/host_command.c
+++ b/zephyr/shim/src/host_command.c
@@ -3,11 +3,11 @@
* found in the LICENSE file.
*/
+#include <zephyr/kernel.h>
+
#include "host_command.h"
#include "task.h"
-#include <zephyr/kernel.h>
-
struct host_command *zephyr_find_host_command(int command)
{
STRUCT_SECTION_FOREACH(host_command, cmd)
diff --git a/zephyr/shim/src/hwtimer.c b/zephyr/shim/src/hwtimer.c
index cefbe4eb7f..d99f7a826b 100644
--- a/zephyr/shim/src/hwtimer.c
+++ b/zephyr/shim/src/hwtimer.c
@@ -3,11 +3,10 @@
* found in the LICENSE file.
*/
-#include "hwtimer.h"
-
+#include <zephyr/kernel.h>
#include <stdint.h>
-#include <zephyr/kernel.h>
+#include "hwtimer.h"
uint64_t __hw_clock_source_read64(void)
{
diff --git a/zephyr/shim/src/i2c.c b/zephyr/shim/src/i2c.c
index 53766f1683..0074327826 100644
--- a/zephyr/shim/src/i2c.c
+++ b/zephyr/shim/src/i2c.c
@@ -3,12 +3,19 @@
* found in the LICENSE file.
*/
+#include <zephyr/sys/util.h>
+#include <zephyr/drivers/i2c.h>
+
#include "console.h"
#include "i2c.h"
#include "i2c/i2c.h"
-#include <zephyr/drivers/i2c.h>
-#include <zephyr/sys/util.h>
+/*
+ * The named-i2c-ports node is required by the I2C shim
+ */
+#if !DT_NODE_EXISTS(DT_PATH(named_i2c_ports))
+#error I2C shim requires the named-i2c-ports node to be defined.
+#endif
/*
* Initialize device bindings in i2c_devices.
diff --git a/zephyr/shim/src/ioex.c b/zephyr/shim/src/ioex.c
index afda051c8a..a5d685bc48 100644
--- a/zephyr/shim/src/ioex.c
+++ b/zephyr/shim/src/ioex.c
@@ -3,16 +3,15 @@
* found in the LICENSE file.
*/
+#include <zephyr/init.h>
+#include <zephyr/kernel.h>
+#include <zephyr/logging/log.h>
+#include "common.h"
#ifdef __REQUIRE_ZEPHYR_GPIOS__
#undef __REQUIRE_ZEPHYR_GPIOS__
#endif
-#include "common.h"
#include "ioexpander.h"
-#include <zephyr/init.h>
-#include <zephyr/kernel.h>
-#include <zephyr/logging/log.h>
-
LOG_MODULE_REGISTER(ioex_shim, LOG_LEVEL_ERR);
int ioex_init(int ioex)
diff --git a/zephyr/shim/src/ioex_drv.c b/zephyr/shim/src/ioex_drv.c
index 98f67a4459..3baa4777fd 100644
--- a/zephyr/shim/src/ioex_drv.c
+++ b/zephyr/shim/src/ioex_drv.c
@@ -3,15 +3,38 @@
* found in the LICENSE file.
*/
+#define DT_DRV_COMPAT cros_ioex_port
+#define DT_DRV_COMPAT_CHIP cros_ioex_chip
+
+#include <zephyr/device.h>
+#include <zephyr/drivers/gpio.h>
+#include <zephyr/drivers/i2c.h>
+#include <errno.h>
#ifdef __REQUIRE_ZEPHYR_GPIOS__
#undef __REQUIRE_ZEPHYR_GPIOS__
#endif
+#include "gpio.h"
+#include <zephyr/drivers/gpio/gpio_utils.h>
+#include <zephyr/init.h>
+#include <zephyr/kernel.h>
+#include <zephyr/logging/log.h>
+#include <zephyr/sys/byteorder.h>
+#include <zephyr/sys/util.h>
#include "common.h"
#include "config.h"
+#include "i2c.h"
+#include "ioexpander.h"
+
/* Include drivers if enabled */
+#ifdef CONFIG_PLATFORM_EC_IOEX_CCGXXF
+#include "driver/tcpm/ccgxxf.h"
+#endif
#ifdef CONFIG_PLATFORM_EC_IOEX_IT8801
#include "driver/ioexpander/it8801.h"
#endif
+#ifdef CONFIG_PLATFORM_EC_IOEX_NCT38XX
+#include "driver/tcpm/nct38xx.h"
+#endif
#ifdef CONFIG_PLATFORM_EC_IOEX_PCA9675
#include "driver/ioexpander/pca9675.h"
#endif
@@ -21,30 +44,6 @@
#ifdef CONFIG_PLATFORM_EC_IOEX_TCA64XXA
#include "driver/ioexpander/tca64xxa.h"
#endif
-#ifdef CONFIG_PLATFORM_EC_IOEX_CCGXXF
-#include "driver/tcpm/ccgxxf.h"
-#endif
-#ifdef CONFIG_PLATFORM_EC_IOEX_NCT38XX
-#include "driver/tcpm/nct38xx.h"
-#endif
-#include "gpio.h"
-#include "i2c.h"
-#include "ioexpander.h"
-
-#include <errno.h>
-
-#include <zephyr/device.h>
-#include <zephyr/drivers/gpio.h>
-#include <zephyr/drivers/gpio/gpio_utils.h>
-#include <zephyr/drivers/i2c.h>
-#include <zephyr/init.h>
-#include <zephyr/kernel.h>
-#include <zephyr/logging/log.h>
-#include <zephyr/sys/byteorder.h>
-#include <zephyr/sys/util.h>
-
-#define DT_DRV_COMPAT cros_ioex_port
-#define DT_DRV_COMPAT_CHIP cros_ioex_chip
LOG_MODULE_REGISTER(cros_ioex_port, CONFIG_GPIO_LOG_LEVEL);
diff --git a/zephyr/shim/src/keyboard_raw.c b/zephyr/shim/src/keyboard_raw.c
index 73b3c2acaf..c9f465d06d 100644
--- a/zephyr/shim/src/keyboard_raw.c
+++ b/zephyr/shim/src/keyboard_raw.c
@@ -5,14 +5,13 @@
/* Functions needed by keyboard scanner module for Chrome EC */
-#include "drivers/cros_kb_raw.h"
-#include "keyboard_raw.h"
-
#include <zephyr/device.h>
-#include <zephyr/kernel.h>
#include <zephyr/logging/log.h>
-
#include <soc.h>
+#include <zephyr/kernel.h>
+
+#include "drivers/cros_kb_raw.h"
+#include "keyboard_raw.h"
LOG_MODULE_REGISTER(shim_cros_kb_raw, LOG_LEVEL_ERR);
@@ -64,11 +63,3 @@ void keyboard_raw_enable_interrupt(int enable)
{
cros_kb_raw_enable_interrupt(cros_kb_raw_dev, enable);
}
-
-/**
- * Enable or disable keyboard alternative function.
- */
-void keybaord_raw_config_alt(bool enable)
-{
- cros_kb_raw_config_alt(cros_kb_raw_dev, enable);
-}
diff --git a/zephyr/shim/src/keyscan.c b/zephyr/shim/src/keyscan.c
index 46bb5fcc7f..514885379b 100644
--- a/zephyr/shim/src/keyscan.c
+++ b/zephyr/shim/src/keyscan.c
@@ -3,18 +3,15 @@
* found in the LICENSE file.
*/
-#define DT_DRV_COMPAT cros_ec_keyscan
-
-#include "keyboard_scan.h"
+#define DT_DRV_COMPAT cros_keyscan
#include <assert.h>
-
#include <zephyr/kernel.h>
-
#include <soc.h>
-BUILD_ASSERT(DT_NUM_INST_STATUS_OKAY(DT_DRV_COMPAT) == 1,
- "Exactly one instance of cros-ec,keyscan should be defined.");
+#include "keyboard_scan.h"
+
+#if DT_NODE_EXISTS(DT_INST(0, cros_keyscan))
/* The keyboard matrix should have at least enough columns for the
* standard keyboard with no keypad.
@@ -34,3 +31,4 @@ __override struct keyboard_scan_config keyscan_config = {
.poll_timeout_us = DT_INST_PROP(0, poll_timeout),
.actual_key_mask = DT_INST_PROP(0, actual_key_mask),
};
+#endif
diff --git a/zephyr/shim/src/led_driver/CMakeLists.txt b/zephyr/shim/src/led_driver/CMakeLists.txt
index 7f513ed425..179f540fe1 100644
--- a/zephyr/shim/src/led_driver/CMakeLists.txt
+++ b/zephyr/shim/src/led_driver/CMakeLists.txt
@@ -3,5 +3,5 @@
# found in the LICENSE file.
zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_LED_DT led.c)
-zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_LED_DT_GPIO led_gpio.c)
-zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_LED_DT_PWM led_pwm.c)
+zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_LED_DT led_gpio.c)
+zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_LED_DT led_pwm.c)
diff --git a/zephyr/shim/src/led_driver/led.c b/zephyr/shim/src/led_driver/led.c
index 9a1c07b310..011632ac83 100644
--- a/zephyr/shim/src/led_driver/led.c
+++ b/zephyr/shim/src/led_driver/led.c
@@ -5,7 +5,7 @@
* Power and battery LED control.
*/
-#define DT_DRV_COMPAT cros_ec_led_policy
+#include <zephyr/drivers/gpio.h>
#include "battery.h"
#include "charge_manager.h"
@@ -21,12 +21,10 @@
#include "util.h"
#include <zephyr/devicetree.h>
-#include <zephyr/drivers/gpio.h>
#include <zephyr/logging/log.h>
LOG_MODULE_REGISTER(led, LOG_LEVEL_ERR);
-BUILD_ASSERT(DT_NUM_INST_STATUS_OKAY(DT_DRV_COMPAT) == 1,
- "Exactly one instance of cros-ec,led-policy should be defined.");
+#define LED_COLOR_NODE DT_PATH(led_colors)
struct led_color_node_t {
struct led_pins_node_t *pins_node;
@@ -35,12 +33,10 @@ struct led_color_node_t {
#define DECLARE_PINS_NODE(id) extern struct led_pins_node_t PINS_NODE(id);
-#if CONFIG_PLATFORM_EC_LED_DT_PWM
-DT_FOREACH_CHILD(DT_COMPAT_GET_ANY_STATUS_OKAY(cros_ec_pwm_led_pins),
- DECLARE_PINS_NODE)
-#elif CONFIG_PLATFORM_EC_LED_DT_GPIO
-DT_FOREACH_CHILD(DT_COMPAT_GET_ANY_STATUS_OKAY(cros_ec_gpio_led_pins),
- DECLARE_PINS_NODE)
+#if DT_HAS_COMPAT_STATUS_OKAY(COMPAT_PWM_LED)
+DT_FOREACH_CHILD(PWM_LED_PINS_NODE, DECLARE_PINS_NODE)
+#elif DT_HAS_COMPAT_STATUS_OKAY(COMPAT_GPIO_LED)
+DT_FOREACH_CHILD(GPIO_LED_PINS_NODE, DECLARE_PINS_NODE)
#endif
/*
@@ -117,8 +113,8 @@ struct node_prop_t {
LED_COLOR_INIT(3, 4, state_id), \
} },
-static const struct node_prop_t node_array[] = { DT_INST_FOREACH_CHILD(
- 0, SET_LED_VALUES) };
+static const struct node_prop_t node_array[] = { DT_FOREACH_CHILD(
+ LED_COLOR_NODE, SET_LED_VALUES) };
test_export_static enum power_state get_chipset_state(void)
{
diff --git a/zephyr/shim/src/led_driver/led.h b/zephyr/shim/src/led_driver/led.h
index a186d97da9..b8cedf5af7 100644
--- a/zephyr/shim/src/led_driver/led.h
+++ b/zephyr/shim/src/led_driver/led.h
@@ -10,6 +10,9 @@
#include <zephyr/drivers/gpio.h>
#include <zephyr/drivers/pwm.h>
+#define COMPAT_GPIO_LED cros_ec_gpio_led_pins
+#define COMPAT_PWM_LED cros_ec_pwm_led_pins
+
#define PINS_NODE(id) DT_CAT(PIN_NODE_, id)
#define PINS_ARRAY(id) DT_CAT(PINS_ARRAY_, id)
@@ -32,6 +35,9 @@
COND_CODE_1(DT_NODE_HAS_PROP(id, enum_name), \
(LED_ENUM(id, enum_name), ), ())
+#define GPIO_LED_PINS_NODE DT_PATH(gpio_led_pins)
+#define PWM_LED_PINS_NODE DT_PATH(pwm_led_pins)
+
enum led_color {
LED_OFF,
LED_RED,
@@ -79,12 +85,12 @@ struct led_pins_node_t {
/* Brightness Range color, only used to support ectool functionality */
enum ec_led_colors br_color;
-#if CONFIG_PLATFORM_EC_LED_DT_GPIO
+#if DT_HAS_COMPAT_STATUS_OKAY(COMPAT_GPIO_LED)
/* Array of GPIO pins to set to enable particular color */
struct gpio_pin_t *gpio_pins;
#endif
-#if CONFIG_PLATFORM_EC_LED_DT_PWM
+#if DT_HAS_COMPAT_STATUS_OKAY(COMPAT_PWM_LED)
/* Array of PWM pins to set to enable particular color */
struct pwm_pin_t *pwm_pins;
#endif
diff --git a/zephyr/shim/src/led_driver/led_gpio.c b/zephyr/shim/src/led_driver/led_gpio.c
index d6af1772c2..122794dc82 100644
--- a/zephyr/shim/src/led_driver/led_gpio.c
+++ b/zephyr/shim/src/led_driver/led_gpio.c
@@ -5,8 +5,6 @@
* GPIO LED control.
*/
-#define DT_DRV_COMPAT cros_ec_gpio_led_pins
-
#include "ec_commands.h"
#include "led.h"
#include "util.h"
@@ -15,21 +13,20 @@
#include <zephyr/drivers/gpio.h>
#include <zephyr/logging/log.h>
-LOG_MODULE_REGISTER(gpio_led, LOG_LEVEL_ERR);
+#if DT_HAS_COMPAT_STATUS_OKAY(COMPAT_GPIO_LED)
-BUILD_ASSERT(DT_NUM_INST_STATUS_OKAY(DT_DRV_COMPAT) == 1,
- "Exactly one instance of cros-ec,gpio-led-pins should be defined.");
+LOG_MODULE_REGISTER(gpio_led, LOG_LEVEL_ERR);
#define SET_PIN(node_id, prop, i) \
{ .signal = GPIO_SIGNAL(DT_PHANDLE_BY_IDX(node_id, prop, i)), \
- .val = DT_PROP_BY_IDX(node_id, led_values, i) },
+ .val = DT_PHA_BY_IDX(node_id, prop, i, value) },
#define SET_GPIO_PIN(node_id) \
{ DT_FOREACH_PROP_ELEM(node_id, led_pins, SET_PIN) };
#define GEN_PINS_ARRAY(id) struct gpio_pin_t PINS_ARRAY(id)[] = SET_GPIO_PIN(id)
-DT_INST_FOREACH_CHILD(0, GEN_PINS_ARRAY)
+DT_FOREACH_CHILD(GPIO_LED_PINS_NODE, GEN_PINS_ARRAY)
#define SET_PIN_NODE(node_id) \
{ .led_color = GET_PROP(node_id, led_color), \
@@ -44,14 +41,14 @@ DT_INST_FOREACH_CHILD(0, GEN_PINS_ARRAY)
#define GEN_PINS_NODES(id) \
const struct led_pins_node_t PINS_NODE(id) = SET_PIN_NODE(id)
-DT_INST_FOREACH_CHILD(0, GEN_PINS_NODES)
+DT_FOREACH_CHILD(GPIO_LED_PINS_NODE, GEN_PINS_NODES)
/*
* Array of pointers to each pin node
*/
#define PINS_NODE_PTR(id) &PINS_NODE(id),
-const struct led_pins_node_t *pins_node[] = { DT_INST_FOREACH_CHILD(
- 0, PINS_NODE_PTR) };
+const struct led_pins_node_t *pins_node[] = { DT_FOREACH_CHILD(
+ GPIO_LED_PINS_NODE, PINS_NODE_PTR) };
/*
* Set all the GPIO pins defined in the node to the defined value,
@@ -141,3 +138,5 @@ const struct led_pins_node_t *led_get_node(enum led_color color,
return pin_node;
}
#endif /* TEST_BUILD */
+
+#endif /* DT_HAS_COMPAT_STATUS_OKAY(COMPAT_GPIO_LED) */
diff --git a/zephyr/shim/src/led_driver/led_pwm.c b/zephyr/shim/src/led_driver/led_pwm.c
index 9fcafeea53..00002fc32e 100644
--- a/zephyr/shim/src/led_driver/led_pwm.c
+++ b/zephyr/shim/src/led_driver/led_pwm.c
@@ -5,8 +5,6 @@
* PWM LED control.
*/
-#define DT_DRV_COMPAT cros_ec_pwm_led_pins
-
#include "ec_commands.h"
#include "led.h"
#include "util.h"
@@ -15,10 +13,9 @@
#include <zephyr/drivers/pwm.h>
#include <zephyr/logging/log.h>
-LOG_MODULE_REGISTER(pwm_led, LOG_LEVEL_ERR);
+#if DT_HAS_COMPAT_STATUS_OKAY(COMPAT_PWM_LED)
-BUILD_ASSERT(DT_NUM_INST_STATUS_OKAY(DT_DRV_COMPAT) == 1,
- "Exactly one instance of cros-ec,pwm-led-pins should be defined.");
+LOG_MODULE_REGISTER(pwm_led, LOG_LEVEL_ERR);
/*
* Period in ns from frequency(Hz) defined in pins node
@@ -36,23 +33,23 @@ BUILD_ASSERT(DT_NUM_INST_STATUS_OKAY(DT_DRV_COMPAT) == 1,
.pwm = PWM_DT_SPEC_GET(DT_PHANDLE_BY_IDX(node_id, prop, i)), \
.pulse_ns = DIV_ROUND_NEAREST( \
DT_PWMS_PERIOD(DT_PHANDLE_BY_IDX(node_id, prop, i)) * \
- DT_PROP_BY_IDX(node_id, led_values, i), \
+ DT_PHA_BY_IDX(node_id, prop, i, value), \
100), \
},
#define SET_PWM_PIN(node_id) \
- { DT_FOREACH_PROP_ELEM(node_id, led_pwms, SET_PIN) };
+ { DT_FOREACH_PROP_ELEM(node_id, led_pins, SET_PIN) };
#define GEN_PINS_ARRAY(id) struct pwm_pin_t PINS_ARRAY(id)[] = SET_PWM_PIN(id)
-DT_INST_FOREACH_CHILD(0, GEN_PINS_ARRAY)
+DT_FOREACH_CHILD(PWM_LED_PINS_NODE, GEN_PINS_ARRAY)
#define SET_PIN_NODE(node_id) \
{ .led_color = GET_PROP(node_id, led_color), \
.led_id = GET_PROP(node_id, led_id), \
.br_color = GET_PROP_NVE(node_id, br_color), \
.pwm_pins = PINS_ARRAY(node_id), \
- .pins_count = DT_PROP_LEN(node_id, led_pwms) };
+ .pins_count = DT_PROP_LEN(node_id, led_pins) };
/*
* Initialize led_pins_node_t struct for each pin node defined
@@ -60,14 +57,14 @@ DT_INST_FOREACH_CHILD(0, GEN_PINS_ARRAY)
#define GEN_PINS_NODES(id) \
const struct led_pins_node_t PINS_NODE(id) = SET_PIN_NODE(id)
-DT_INST_FOREACH_CHILD(0, GEN_PINS_NODES)
+DT_FOREACH_CHILD(PWM_LED_PINS_NODE, GEN_PINS_NODES)
/*
* Array of pointers to each pin node
*/
#define PINS_NODE_PTR(id) &PINS_NODE(id),
-const struct led_pins_node_t *pins_node[] = { DT_INST_FOREACH_CHILD(
- 0, PINS_NODE_PTR) };
+const struct led_pins_node_t *pins_node[] = { DT_FOREACH_CHILD(
+ PWM_LED_PINS_NODE, PINS_NODE_PTR) };
/*
* Set all the PWM channels defined in the node to the defined value,
@@ -150,3 +147,4 @@ __override int led_is_supported(enum ec_led_id led_id)
return ((1 << (int)led_id) & supported_leds);
}
+#endif /* DT_HAS_COMPAT_STATUS_OKAY(COMPAT_PWM_LED) */
diff --git a/zephyr/shim/src/log_backend_console_buffer.c b/zephyr/shim/src/log_backend_console_buffer.c
index 3f455469c4..cafb690b87 100644
--- a/zephyr/shim/src/log_backend_console_buffer.c
+++ b/zephyr/shim/src/log_backend_console_buffer.c
@@ -1,13 +1,13 @@
-/* Copyright 2022 The ChromiumOS Authors
+/* Copyright 2022 The ChromiumOS Authors.
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
-#include "console.h"
-
#include <zephyr/logging/log_backend.h>
-#include <zephyr/logging/log_backend_std.h>
#include <zephyr/logging/log_output.h>
+#include <zephyr/logging/log_backend_std.h>
+
+#include "console.h"
static uint8_t
char_out_buf[CONFIG_PLATFORM_EC_LOG_BACKEND_CONSOLE_BUFFER_TMP_BUF_SIZE];
diff --git a/zephyr/shim/src/motionsense_sensors.c b/zephyr/shim/src/motionsense_sensors.c
index 72bb677af6..8d886192ac 100644
--- a/zephyr/shim/src/motionsense_sensors.c
+++ b/zephyr/shim/src/motionsense_sensors.c
@@ -3,15 +3,14 @@
* found in the LICENSE file.
*/
-#include "accelgyro.h"
+#include <zephyr/logging/log.h>
#include "common.h"
+#include "accelgyro.h"
#include "cros_cbi.h"
-#include "gpio/gpio_int.h"
#include "hooks.h"
+#include "gpio/gpio_int.h"
#include "motionsense_sensors.h"
-#include <zephyr/logging/log.h>
-
LOG_MODULE_REGISTER(shim_cros_motionsense_sensors);
#define SENSOR_MUTEX_NODE DT_PATH(motionsense_mutex)
diff --git a/zephyr/shim/src/panic.c b/zephyr/shim/src/panic.c
index 2ac8328e9e..9ff8a46f62 100644
--- a/zephyr/shim/src/panic.c
+++ b/zephyr/shim/src/panic.c
@@ -3,14 +3,14 @@
* found in the LICENSE file.
*/
-#include "common.h"
-#include "panic.h"
-
#include <zephyr/arch/cpu.h>
#include <zephyr/fatal.h>
-#include <zephyr/kernel.h>
#include <zephyr/logging/log.h>
#include <zephyr/logging/log_ctrl.h>
+#include <zephyr/kernel.h>
+
+#include "common.h"
+#include "panic.h"
/*
* Arch-specific configuration
diff --git a/zephyr/shim/src/power.c b/zephyr/shim/src/power.c
index ab58cf391d..007c40ab71 100644
--- a/zephyr/shim/src/power.c
+++ b/zephyr/shim/src/power.c
@@ -3,38 +3,16 @@
* found in the LICENSE file.
*/
+#include <zephyr/sys/util.h>
+
#include "console.h"
#include "power.h"
#include "power/power.h"
-#include <zephyr/sys/util.h>
-
-#define GEN_POWER_SIGNAL_STRUCT_ENTRY_GPIO(cid) \
- DT_STRING_UPPER_TOKEN(DT_PROP(cid, power_gpio_pin), enum_name)
-#define GEN_POWER_SIGNAL_STRUCT_ENTRY_FLAGS(cid) \
- (DT_GPIO_FLAGS(DT_PROP(cid, power_gpio_pin), gpios) & \
- GPIO_ACTIVE_LOW ? \
- POWER_SIGNAL_ACTIVE_LOW : \
- POWER_SIGNAL_ACTIVE_HIGH)
-#define GEN_POWER_SIGNAL_STRUCT_ENTRY_NAME(cid) DT_PROP(cid, power_enum_name)
-
-#define GEN_POWER_SIGNAL_STRUCT_ENTRY(cid) \
- { \
- .gpio = GEN_POWER_SIGNAL_STRUCT_ENTRY_GPIO(cid), \
- .flags = GEN_POWER_SIGNAL_STRUCT_ENTRY_FLAGS(cid), \
- .name = GEN_POWER_SIGNAL_STRUCT_ENTRY_NAME(cid) \
- }
-#define GEN_POWER_SIGNAL_STRUCT(cid) \
- [GEN_POWER_SIGNAL_ENUM_ENTRY(cid)] = GEN_POWER_SIGNAL_STRUCT_ENTRY(cid),
+#if (SYSTEM_DT_POWER_SIGNAL_CONFIG)
const struct power_signal_info power_signal_list[] = { DT_FOREACH_CHILD(
POWER_SIGNAL_LIST_NODE, GEN_POWER_SIGNAL_STRUCT) };
BUILD_ASSERT(ARRAY_SIZE(power_signal_list) == POWER_SIGNAL_COUNT);
-/*
- * Verify the number of required power-signals are specified in
- * the DeviceTree
- */
-#define POWER_SIGNALS_REQUIRED \
- DT_PROP(POWER_SIGNAL_LIST_NODE, power_signals_required)
-BUILD_ASSERT(POWER_SIGNALS_REQUIRED == POWER_SIGNAL_COUNT);
+#endif /* SYSTEM_DT_POWER_SIGNAL_CONFIG */
diff --git a/zephyr/shim/src/ppc.c b/zephyr/shim/src/ppc.c
index c15c6900b1..c4c54d002f 100644
--- a/zephyr/shim/src/ppc.c
+++ b/zephyr/shim/src/ppc.c
@@ -3,15 +3,14 @@
* found in the LICENSE file.
*/
-#include "usbc/ppc.h"
+#include <zephyr/devicetree.h>
+#include "usbc_ppc.h"
#include "usbc/ppc_aoz1380.h"
#include "usbc/ppc_nx20p348x.h"
#include "usbc/ppc_rt1739.h"
#include "usbc/ppc_sn5s330.h"
#include "usbc/ppc_syv682x.h"
-#include "usbc_ppc.h"
-
-#include <zephyr/devicetree.h>
+#include "usbc/ppc.h"
#if DT_HAS_COMPAT_STATUS_OKAY(AOZ1380_COMPAT) || \
DT_HAS_COMPAT_STATUS_OKAY(NX20P348X_COMPAT) || \
diff --git a/zephyr/shim/src/pwm_hc.c b/zephyr/shim/src/pwm_hc.c
index 3c7b2f1737..c0350c733f 100644
--- a/zephyr/shim/src/pwm_hc.c
+++ b/zephyr/shim/src/pwm_hc.c
@@ -3,20 +3,20 @@
* found in the LICENSE file.
*/
+#include <zephyr/device.h>
+#include <zephyr/devicetree.h>
+#include <zephyr/drivers/pwm.h>
+#include <zephyr/logging/log.h>
+
#include "common.h"
#include "console.h"
#include "drivers/cros_displight.h"
#include "ec_commands.h"
#include "host_command.h"
-#include "keyboard_backlight.h"
#include "pwm.h"
+#include "keyboard_backlight.h"
#include "util.h"
-#include <zephyr/device.h>
-#include <zephyr/devicetree.h>
-#include <zephyr/drivers/pwm.h>
-#include <zephyr/logging/log.h>
-
LOG_MODULE_REGISTER(pwm_shim, LOG_LEVEL_ERR);
#define HAS_PWM_GENERIC_CHANNEL(compat) \
diff --git a/zephyr/shim/src/pwm_led.c b/zephyr/shim/src/pwm_led.c
index 81cc3a9c28..498c543ffb 100644
--- a/zephyr/shim/src/pwm_led.c
+++ b/zephyr/shim/src/pwm_led.c
@@ -6,7 +6,6 @@
#define DT_DRV_COMPAT cros_ec_pwm_leds
#include <string.h>
-
#include <zephyr/devicetree.h>
#if DT_HAS_COMPAT_STATUS_OKAY(DT_DRV_COMPAT)
diff --git a/zephyr/shim/src/rtc.c b/zephyr/shim/src/rtc.c
index 3acf6a3bb6..c8a0511c95 100644
--- a/zephyr/shim/src/rtc.c
+++ b/zephyr/shim/src/rtc.c
@@ -3,6 +3,9 @@
* found in the LICENSE file.
*/
+#include <zephyr/logging/log.h>
+#include <zephyr/kernel.h>
+
#include "console.h"
#include "drivers/cros_rtc.h"
#include "hooks.h"
@@ -10,9 +13,6 @@
#include "system.h"
#include "util.h"
-#include <zephyr/kernel.h>
-#include <zephyr/logging/log.h>
-
LOG_MODULE_REGISTER(shim_cros_rtc, LOG_LEVEL_ERR);
#define CROS_RTC_NODE DT_CHOSEN(cros_rtc)
diff --git a/zephyr/shim/src/switchcap_gpio.c b/zephyr/shim/src/switchcap_gpio.c
index 982e5ff98c..23bed493c8 100644
--- a/zephyr/shim/src/switchcap_gpio.c
+++ b/zephyr/shim/src/switchcap_gpio.c
@@ -3,24 +3,33 @@
* found in the LICENSE file.
*/
-#define DT_DRV_COMPAT cros_ec_switchcap_gpio
-
-#include "common.h"
-
#include <zephyr/devicetree.h>
#include <zephyr/drivers/gpio.h>
#include <zephyr/kernel.h>
+#include "common.h"
/* TODO(b/218600962): Consolidate switchcap code. */
-#define SC_PIN_ENABLE_GPIO DT_INST_PROP(0, enable_pin)
-#define SC_PIN_ENABLE GPIO_DT_FROM_NODE(SC_PIN_ENABLE_GPIO)
+#if DT_NODE_EXISTS(DT_PATH(switchcap))
+
+#if !DT_NODE_HAS_COMPAT(DT_PATH(switchcap), switchcap_gpio)
+#error "Invalid /switchcap node in device tree"
+#endif
-#define SC_PIN_POWER_GOOD_GPIO DT_INST_PROP(0, power_good_pin)
-#define SC_PIN_POWER_GOOD_EXISTS DT_NODE_EXISTS(SC_PIN_POWER_GOOD_GPIO)
-#define SC_PIN_POWER_GOOD GPIO_DT_FROM_NODE(SC_PIN_POWER_GOOD_GPIO)
+#define SC_PIN_ENABLE_PHANDLE \
+ DT_PHANDLE_BY_IDX(DT_PATH(switchcap), enable_pin, 0)
+#define SC_PIN_ENABLE GPIO_DT_FROM_NODE(SC_PIN_ENABLE_PHANDLE)
-static const int32_t poff_delay_ms = DT_INST_PROP_OR(0, poff_delay_ms, 0);
+#define SC_PIN_POWER_GOOD_PHANDLE \
+ DT_PHANDLE_BY_IDX(DT_PATH(switchcap), power_good_pin, 0)
+#define SC_PIN_POWER_GOOD_EXISTS DT_NODE_EXISTS(SC_PIN_POWER_GOOD_PHANDLE)
+#define SC_PIN_POWER_GOOD GPIO_DT_FROM_NODE(SC_PIN_POWER_GOOD_PHANDLE)
+
+#if DT_NODE_HAS_PROP(DT_PATH(switchcap), poff_delay_ms)
+static const int32_t poff_delay_ms = DT_PROP(DT_PATH(switchcap), poff_delay_ms);
+#else
+static const int32_t poff_delay_ms;
+#endif
void board_set_switchcap_power(int enable)
{
@@ -42,3 +51,5 @@ int board_is_switchcap_power_good(void)
return 1;
#endif
}
+
+#endif
diff --git a/zephyr/shim/src/switchcap_ln9310.c b/zephyr/shim/src/switchcap_ln9310.c
index 54087ef6f2..7c5fd4ed8d 100644
--- a/zephyr/shim/src/switchcap_ln9310.c
+++ b/zephyr/shim/src/switchcap_ln9310.c
@@ -3,23 +3,27 @@
* found in the LICENSE file.
*/
-#define DT_DRV_COMPAT lion_ln9310
-
-#include "common.h"
-#include "ln9310.h"
-
#include <zephyr/devicetree.h>
#include <zephyr/drivers/gpio.h>
+#include "common.h"
+#include "ln9310.h"
/* TODO(b/218600962): Consolidate switchcap code. */
-#define SC_PIN_ENABLE_GPIO DT_INST_PROP(0, enable_pin)
-#define SC_PIN_ENABLE GPIO_DT_FROM_NODE(SC_PIN_ENABLE_GPIO)
+#if DT_NODE_EXISTS(DT_PATH(switchcap))
+
+#if !DT_NODE_HAS_COMPAT(DT_PATH(switchcap), switchcap_ln9310)
+#error "Invalid /switchcap node in device tree"
+#endif
-#define SC_PORT_NODE DT_INST_PHANDLE(0, port)
-#define SC_PORT DT_STRING_UPPER_TOKEN_BY_IDX(SC_PORT_NODE, enum_names, 0)
+#define SC_PIN_ENABLE_PHANDLE \
+ DT_PHANDLE_BY_IDX(DT_PATH(switchcap), enable_pin, 0)
+#define SC_PIN_ENABLE GPIO_DT_FROM_NODE(SC_PIN_ENABLE_PHANDLE)
-#define SC_ADDR_FLAGS DT_INST_STRING_UPPER_TOKEN(0, addr_flags)
+#define SC_PORT_PHANDLE DT_PHANDLE(DT_PATH(switchcap), port)
+#define SC_PORT DT_STRING_UPPER_TOKEN_BY_IDX(SC_PORT_PHANDLE, enum_names, 0)
+
+#define SC_ADDR_FLAGS DT_STRING_UPPER_TOKEN(DT_PATH(switchcap), addr_flags)
void board_set_switchcap_power(int enable)
{
@@ -41,3 +45,5 @@ const struct ln9310_config_t ln9310_config = {
.i2c_port = SC_PORT,
.i2c_addr_flags = SC_ADDR_FLAGS,
};
+
+#endif
diff --git a/zephyr/shim/src/system.c b/zephyr/shim/src/system.c
index 0b47782b42..53e651ec03 100644
--- a/zephyr/shim/src/system.c
+++ b/zephyr/shim/src/system.c
@@ -3,18 +3,17 @@
* found in the LICENSE file.
*/
+#include <zephyr/device.h>
+#include <zephyr/drivers/bbram.h>
+#include <drivers/cros_system.h>
+#include <zephyr/logging/log.h>
+
#include "common.h"
#include "console.h"
#include "cros_version.h"
#include "system.h"
#include "watchdog.h"
-#include <zephyr/device.h>
-#include <zephyr/drivers/bbram.h>
-#include <zephyr/logging/log.h>
-
-#include <drivers/cros_system.h>
-
#define BBRAM_REGION_PD0 DT_PATH(named_bbram_regions, pd0)
#define BBRAM_REGION_PD1 DT_PATH(named_bbram_regions, pd1)
#define BBRAM_REGION_PD2 DT_PATH(named_bbram_regions, pd2)
@@ -343,7 +342,7 @@ static int check_reset_cause(void)
return 0;
}
-test_export_static int system_preinitialize(const struct device *unused)
+static int system_preinitialize(const struct device *unused)
{
ARG_UNUSED(unused);
diff --git a/zephyr/shim/src/tasks.c b/zephyr/shim/src/tasks.c
index 68ebbbc482..35d4ab7c42 100644
--- a/zephyr/shim/src/tasks.c
+++ b/zephyr/shim/src/tasks.c
@@ -3,15 +3,15 @@
* found in the LICENSE file.
*/
+#include <zephyr/kernel.h>
+#include <zephyr/init.h>
+#include <zephyr/sys/atomic.h>
+#include <zephyr/shell/shell.h>
+
#include "common.h"
#include "host_command.h"
-#include "task.h"
#include "timer.h"
-
-#include <zephyr/init.h>
-#include <zephyr/kernel.h>
-#include <zephyr/shell/shell.h>
-#include <zephyr/sys/atomic.h>
+#include "task.h"
/* Ensure that the idle task is at lower priority than lowest priority task. */
BUILD_ASSERT(EC_TASK_PRIORITY(EC_TASK_PRIO_LOWEST) < K_IDLE_PRIO,
@@ -105,7 +105,7 @@ atomic_t *task_get_event_bitmap(task_id_t cros_task_id)
data = task_get_base_data(cros_task_id);
- return data == NULL ? NULL : &data->event_mask;
+ return &data->event_mask;
}
void task_set_event(task_id_t cros_task_id, uint32_t event)
@@ -114,10 +114,8 @@ void task_set_event(task_id_t cros_task_id, uint32_t event)
data = task_get_base_data(cros_task_id);
- if (data != NULL) {
- atomic_or(&data->event_mask, event);
- k_poll_signal_raise(&data->new_event, 0);
- }
+ atomic_or(&data->event_mask, event);
+ k_poll_signal_raise(&data->new_event, 0);
}
uint32_t task_wait_event(int timeout_us)
@@ -126,8 +124,6 @@ uint32_t task_wait_event(int timeout_us)
data = task_get_base_data(task_get_current());
- __ASSERT_NO_MSG(data != NULL);
-
const k_timeout_t timeout = (timeout_us == -1) ? K_FOREVER :
K_USEC(timeout_us);
const int64_t tick_deadline =
@@ -156,12 +152,12 @@ uint32_t task_wait_event(int timeout_us)
if (events == 0) {
const int64_t ticks_left = tick_deadline - k_uptime_ticks();
- events |= TASK_EVENT_TIMER;
-
if (ticks_left > 0) {
return task_wait_event(
k_ticks_to_us_near64(ticks_left));
}
+
+ events |= TASK_EVENT_TIMER;
}
return events;
@@ -313,26 +309,18 @@ int task_start_called(void)
{
return tasks_started;
}
-/*
- * TODO(b/190203712): Implement this
- * LCOV_EXCL_START
- */
+
void task_disable_task(task_id_t tskid)
{
+ /* TODO(b/190203712): Implement this */
}
-/* LCOV_EXCL_STOP */
-/*
- * This function cannot be tested since it is architecture specific.
- * LCOV_EXCL_START
- */
void task_clear_pending_irq(int irq)
{
#if CONFIG_ITE_IT8XXX2_INTC
ite_intc_isr_clear(irq);
#endif
}
-/* LCOV_EXCL_STOP */
void task_enable_irq(int irq)
{
@@ -351,3 +339,11 @@ inline bool in_deferred_context(void)
*/
return (k_current_get() == &k_sys_work_q.thread);
}
+
+#if IS_ENABLED(CONFIG_KERNEL_SHELL) && IS_ENABLED(CONFIG_THREAD_MONITOR)
+static int taskinfo(const struct shell *shell, size_t argc, char **argv)
+{
+ return shell_execute_cmd(shell, "kernel threads");
+}
+SHELL_CMD_REGISTER(taskinfo, NULL, "Threads statistics", taskinfo);
+#endif
diff --git a/zephyr/shim/src/tcpc.c b/zephyr/shim/src/tcpc.c
index 6ddad71535..ba251a196b 100644
--- a/zephyr/shim/src/tcpc.c
+++ b/zephyr/shim/src/tcpc.c
@@ -3,8 +3,10 @@
* found in the LICENSE file.
*/
-#include "usb_pd.h"
+#include <zephyr/devicetree.h>
+#include <zephyr/sys/util.h>
#include "usb_pd_tcpm.h"
+#include "usb_pd.h"
#include "usbc/tcpc_anx7447.h"
#include "usbc/tcpc_anx7447_emul.h"
#include "usbc/tcpc_ccgxxf.h"
@@ -14,14 +16,10 @@
#include "usbc/tcpc_nct38xx.h"
#include "usbc/tcpc_ps8xxx.h"
#include "usbc/tcpc_ps8xxx_emul.h"
-#include "usbc/tcpc_raa489000.h"
#include "usbc/tcpc_rt1718s.h"
#include "usbc/tcpci.h"
#include "usbc/utils.h"
-#include <zephyr/devicetree.h>
-#include <zephyr/sys/util.h>
-
#define HAS_TCPC_PROP(usbc_id) \
COND_CODE_1(DT_NODE_HAS_PROP(usbc_id, tcpc), (|| 1), ())
@@ -59,8 +57,6 @@
CHECK_COMPAT(PS8XXX_COMPAT, usbc_id, tcpc_id, TCPC_CONFIG_PS8XXX) \
CHECK_COMPAT(NCT38XX_TCPC_COMPAT, usbc_id, tcpc_id, \
TCPC_CONFIG_NCT38XX) \
- CHECK_COMPAT(RAA489000_TCPC_COMPAT, usbc_id, tcpc_id, \
- TCPC_CONFIG_RAA489000) \
CHECK_COMPAT(RT1718S_TCPC_COMPAT, usbc_id, tcpc_id, \
TCPC_CONFIG_RT1718S) \
CHECK_COMPAT(TCPCI_COMPAT, usbc_id, tcpc_id, TCPC_CONFIG_TCPCI) \
diff --git a/zephyr/shim/src/tcpc_nct38xx.c b/zephyr/shim/src/tcpc_nct38xx.c
index 5d3f5ac25c..9580759a6c 100644
--- a/zephyr/shim/src/tcpc_nct38xx.c
+++ b/zephyr/shim/src/tcpc_nct38xx.c
@@ -3,13 +3,13 @@
* found in the LICENSE file.
*/
+#include <zephyr/device.h>
+#include <zephyr/devicetree.h>
+
#include "config.h"
#include "usbc/tcpc_nct38xx.h"
#include "usbc/utils.h"
-#include <zephyr/device.h>
-#include <zephyr/devicetree.h>
-
#define GPIO_DEV_WITH_COMMA(id) DEVICE_DT_GET(DT_PHANDLE(id, gpio_dev)),
#define GPIO_DEV_BINDING(usbc_id, tcpc_id) \
diff --git a/zephyr/shim/src/temp_sensors.c b/zephyr/shim/src/temp_sensors.c
index ae3a367252..371d7d7fc9 100644
--- a/zephyr/shim/src/temp_sensors.c
+++ b/zephyr/shim/src/temp_sensors.c
@@ -6,7 +6,6 @@
#include "adc.h"
#include "charger/chg_rt9490.h"
#include "driver/charger/rt9490.h"
-#include "hooks.h"
#include "temp_sensor.h"
#include "temp_sensor/pct2075.h"
#include "temp_sensor/sb_tsi.h"
@@ -80,7 +79,6 @@ static int thermistor_get_temp(const struct temp_sensor_t *sensor,
.read = &thermistor_get_temp, \
.thermistor = GET_THERMISTOR_INFO( \
DT_PHANDLE(sensor_id, thermistor)), \
- .update_temperature = NULL, \
FILL_POWER_GOOD(named_id) })
#define TEMP_THERMISTOR(named_id, sensor_id) \
@@ -112,12 +110,10 @@ __maybe_unused static int pct2075_get_temp(const struct temp_sensor_t *sensor,
(DT_REG_ADDR(node_id) | I2C_FLAG_BIG_ENDIAN), \
},
-#define GET_ZEPHYR_TEMP_SENSOR_PCT2075(named_id) \
- (&(const struct zephyr_temp_sensor){ \
- .read = &pct2075_get_temp, \
- .thermistor = NULL, \
- .update_temperature = pct2075_update_temperature, \
- FILL_POWER_GOOD(named_id) })
+#define GET_ZEPHYR_TEMP_SENSOR_PCT2075(named_id) \
+ (&(const struct zephyr_temp_sensor){ .read = &pct2075_get_temp, \
+ .thermistor = NULL, \
+ FILL_POWER_GOOD(named_id) })
#define TEMP_PCT2075(named_id, sensor_id) \
[TEMP_SENSOR_ID(named_id)] = { \
@@ -148,10 +144,9 @@ __maybe_unused static int sb_tsi_get_temp(const struct temp_sensor_t *sensor,
#endif /* SB_TSI_COMPAT */
-#define GET_ZEPHYR_TEMP_SENSOR_SB_TSI(named_id) \
- (&(const struct zephyr_temp_sensor){ .read = &sb_tsi_get_temp, \
- .thermistor = NULL, \
- .update_temperature = NULL, \
+#define GET_ZEPHYR_TEMP_SENSOR_SB_TSI(named_id) \
+ (&(const struct zephyr_temp_sensor){ .read = &sb_tsi_get_temp, \
+ .thermistor = NULL, \
FILL_POWER_GOOD(named_id) })
#define TEMP_SB_TSI(named_id, sensor_id) \
@@ -179,12 +174,10 @@ __maybe_unused static int tmp112_get_temp(const struct temp_sensor_t *sensor,
.i2c_addr_flags = DT_REG_ADDR(node_id), \
},
-#define GET_ZEPHYR_TEMP_SENSOR_TMP112(named_id) \
- (&(const struct zephyr_temp_sensor){ \
- .read = &tmp112_get_temp, \
- .thermistor = NULL, \
- .update_temperature = tmp112_update_temperature, \
- FILL_POWER_GOOD(named_id) })
+#define GET_ZEPHYR_TEMP_SENSOR_TMP112(named_id) \
+ (&(const struct zephyr_temp_sensor){ .read = &tmp112_get_temp, \
+ .thermistor = NULL, \
+ FILL_POWER_GOOD(named_id) })
#define TEMP_TMP112(named_id, sensor_id) \
[TEMP_SENSOR_ID(named_id)] = { \
@@ -211,7 +204,6 @@ const struct tmp112_sensor_t tmp112_sensors[TMP112_COUNT] = {
.read = &rt9490_get_thermistor_val, \
.thermistor = GET_THERMISTOR_INFO( \
DT_PHANDLE(sensor_id, thermistor)), \
- .update_temperature = NULL, \
FILL_POWER_GOOD(named_id) })
#define TEMP_RT9490(named_id, sensor_id) \
@@ -243,20 +235,6 @@ const struct tmp112_sensor_t tmp112_sensors[TMP112_COUNT] = {
const struct temp_sensor_t temp_sensors[] = { DT_FOREACH_CHILD_SEP(
TEMP_SENSORS_NODEID, TEMP_SENSOR_ENTRY, (, )) };
-BUILD_ASSERT(ARRAY_SIZE(temp_sensors) == TEMP_SENSOR_COUNT);
-
-static bool temp_sensor_check_power(const struct temp_sensor_t *sensor)
-{
-#if ANY_INST_HAS_POWER_GOOD_PIN
- if (sensor->zephyr_info->power_good_dev) {
- if (!gpio_pin_get(sensor->zephyr_info->power_good_dev,
- sensor->zephyr_info->power_good_pin))
- return false;
- }
-#endif
- return true;
-}
-
int temp_sensor_read(enum temp_sensor_id id, int *temp_ptr)
{
const struct temp_sensor_t *sensor;
@@ -265,26 +243,15 @@ int temp_sensor_read(enum temp_sensor_id id, int *temp_ptr)
return EC_ERROR_INVAL;
sensor = temp_sensors + id;
- if (!temp_sensor_check_power(sensor))
- return EC_ERROR_NOT_POWERED;
+#if ANY_INST_HAS_POWER_GOOD_PIN
+ if (sensor->zephyr_info->power_good_dev) {
+ if (!gpio_pin_get(sensor->zephyr_info->power_good_dev,
+ sensor->zephyr_info->power_good_pin))
+ return EC_ERROR_NOT_POWERED;
+ }
+#endif
return sensor->zephyr_info->read(sensor, temp_ptr);
}
-void temp_sensors_update(void)
-{
- for (int i = 0; i < TEMP_SENSOR_COUNT; i++) {
- const struct temp_sensor_t *sensor = temp_sensors + i;
-
- if (!sensor->zephyr_info->update_temperature)
- continue;
-
- if (!temp_sensor_check_power(sensor))
- continue;
-
- sensor->zephyr_info->update_temperature(sensor->idx);
- }
-}
-DECLARE_HOOK(HOOK_SECOND, temp_sensors_update, HOOK_PRIO_TEMP_SENSOR);
-
#endif /* DT_HAS_COMPAT_STATUS_OKAY(TEMP_SENSORS_COMPAT) */
diff --git a/zephyr/shim/src/thermal.c b/zephyr/shim/src/thermal.c
index fd1b0bfb52..abe6b7da9e 100644
--- a/zephyr/shim/src/thermal.c
+++ b/zephyr/shim/src/thermal.c
@@ -3,9 +3,9 @@
* found in the LICENSE file.
*/
-#include "ec_commands.h"
#include "temp_sensor.h"
#include "temp_sensor/temp_sensor.h"
+#include "ec_commands.h"
#define THERMAL_CONFIG(node_id) \
[TEMP_SENSOR_ID(node_id)] = { \
diff --git a/zephyr/shim/src/usb_muxes.c b/zephyr/shim/src/usb_muxes.c
index b3854e2ca8..3f81e97787 100644
--- a/zephyr/shim/src/usb_muxes.c
+++ b/zephyr/shim/src/usb_muxes.c
@@ -3,11 +3,16 @@
* found in the LICENSE file.
*/
+#include <zephyr/devicetree.h>
+#include <zephyr/sys/util_macro.h>
#include "usb_mux.h"
#include "usbc/usb_muxes.h"
-#include <zephyr/devicetree.h>
-#include <zephyr/sys/util_macro.h>
+/**
+ * This prevents creating struct usb_mux usb_muxes[] for platforms that didn't
+ * migrate USB mux configuration to DTS yet.
+ */
+#if DT_HAS_COMPAT_STATUS_OKAY(cros_ec_usb_mux_chain)
/**
* @brief Check if @p mux_id is not part of @p chain_id or if @p chain_id USBC
@@ -90,3 +95,5 @@ BUILD_ASSERT(ARRAY_SIZE(usb_muxes) == CONFIG_USB_PD_PORT_MAX_COUNT);
* MAYBE_CONST struct usb_mux USB_MUX_NODE_<node_id> = { ... };
*/
USB_MUX_FOREACH_MUX(USB_MUX_DEFINE)
+
+#endif /* #if DT_HAS_COMPAT_STATUS_OKAY(cros_ec_usb_mux_chain) */
diff --git a/zephyr/shim/src/usba.c b/zephyr/shim/src/usba.c
index a7360a9ddb..4db8c31e6a 100644
--- a/zephyr/shim/src/usba.c
+++ b/zephyr/shim/src/usba.c
@@ -5,9 +5,10 @@
#define DT_DRV_COMPAT cros_ec_usba_port_enable_pins
+#include <zephyr/devicetree.h>
#include "hooks.h"
-#include <zephyr/devicetree.h>
+#if DT_HAS_COMPAT_STATUS_OKAY(DT_DRV_COMPAT)
#define PIN(node_id, prop, idx) \
GPIO_SIGNAL(DT_PHANDLE_BY_IDX(node_id, prop, idx)),
@@ -22,3 +23,5 @@ const
#endif
int usb_port_enable[] = { DT_INST_FOREACH_STATUS_OKAY(
USBA_ENABLE_PINS) };
+
+#endif /* DT_HAS_COMPAT_STATUS_OKAY(DT_DRV_COMPAT) */
diff --git a/zephyr/shim/src/watchdog.c b/zephyr/shim/src/watchdog.c
index 413ba50484..eb82f228d5 100644
--- a/zephyr/shim/src/watchdog.c
+++ b/zephyr/shim/src/watchdog.c
@@ -3,14 +3,14 @@
* found in the LICENSE file.
*/
-#include "config.h"
-#include "hooks.h"
-#include "watchdog.h"
-
#include <zephyr/device.h>
#include <zephyr/drivers/watchdog.h>
-#include <zephyr/kernel.h>
#include <zephyr/logging/log.h>
+#include <zephyr/kernel.h>
+
+#include "config.h"
+#include "hooks.h"
+#include "watchdog.h"
LOG_MODULE_REGISTER(watchdog_shim, LOG_LEVEL_ERR);
diff --git a/zephyr/shim/src/ztest_system.c b/zephyr/shim/src/ztest_system.c
index 13614ec8f0..5933f18f05 100644
--- a/zephyr/shim/src/ztest_system.c
+++ b/zephyr/shim/src/ztest_system.c
@@ -12,7 +12,7 @@
#define CPRINTS(format, args...) cprints(CC_SYSTEM, format, ##args)
-char mock_jump_data[CONFIG_PLATFORM_EC_PRESERVED_END_OF_RAM_SIZE];
+char mock_jump_data[sizeof(struct jump_data) + 256];
/* When CONFIG_RAM_SIZE is defined, this is provided by common/system.c */
#ifndef CONFIG_RAM_SIZE