summaryrefslogtreecommitdiff
path: root/zephyr/shim
diff options
context:
space:
mode:
Diffstat (limited to 'zephyr/shim')
-rw-r--r--zephyr/shim/chip/it8xxx2/clock.c7
-rw-r--r--zephyr/shim/chip/it8xxx2/gpio.c5
-rw-r--r--zephyr/shim/chip/it8xxx2/keyboard_raw.c9
-rw-r--r--zephyr/shim/chip/it8xxx2/power_policy.c7
-rw-r--r--zephyr/shim/chip/mchp/clock.c7
-rw-r--r--zephyr/shim/chip/mchp/gpio.c3
-rw-r--r--zephyr/shim/chip/mchp/keyboard_raw.c9
-rw-r--r--zephyr/shim/chip/mchp/system.c6
-rw-r--r--zephyr/shim/chip/mchp/system_download_from_flash.c7
-rw-r--r--zephyr/shim/chip/mchp/system_external_storage.c11
-rw-r--r--zephyr/shim/chip/npcx/clock.c7
-rw-r--r--zephyr/shim/chip/npcx/gpio.c11
-rw-r--r--zephyr/shim/chip/npcx/keyboard_raw.c9
-rw-r--r--zephyr/shim/chip/npcx/npcx_monitor/npcx_monitor.c6
-rw-r--r--zephyr/shim/chip/npcx/power_policy.c9
-rw-r--r--zephyr/shim/chip/npcx/shi.c15
-rw-r--r--zephyr/shim/chip/npcx/system.c6
-rw-r--r--zephyr/shim/chip/npcx/system_download_from_flash.c9
-rw-r--r--zephyr/shim/chip/npcx/system_external_storage.c6
-rw-r--r--zephyr/shim/core/cortex-m/irq_command.c3
-rw-r--r--zephyr/shim/core/cortex-m/mpu.c7
-rw-r--r--zephyr/shim/include/board_led.h4
-rw-r--r--zephyr/shim/include/charger/chg_isl923x.h3
-rw-r--r--zephyr/shim/include/charger/chg_isl9241.h3
-rw-r--r--zephyr/shim/include/charger/chg_rt9490.h3
-rw-r--r--zephyr/shim/include/charger/chg_sm5803.h3
-rw-r--r--zephyr/shim/include/charger_chips.h1
-rw-r--r--zephyr/shim/include/config_chip.h129
-rw-r--r--zephyr/shim/include/cros_cbi.h7
-rw-r--r--zephyr/shim/include/fpu.h6
-rw-r--r--zephyr/shim/include/gpio/gpio.h1
-rw-r--r--zephyr/shim/include/motionsense_sensors.h3
-rw-r--r--zephyr/shim/include/motionsense_sensors_defs.h4
-rw-r--r--zephyr/shim/include/power/power.h34
-rw-r--r--zephyr/shim/include/temp_sensor/temp_sensor.h6
-rw-r--r--zephyr/shim/include/usbc/bc12_rt9490.h2
-rw-r--r--zephyr/shim/include/usbc/ppc.h7
-rw-r--r--zephyr/shim/include/usbc/tcpc_anx7447.h3
-rw-r--r--zephyr/shim/include/usbc/tcpc_anx7447_emul.h5
-rw-r--r--zephyr/shim/include/usbc/tcpc_ccgxxf.h3
-rw-r--r--zephyr/shim/include/usbc/tcpc_fusb302.h3
-rw-r--r--zephyr/shim/include/usbc/tcpc_generic_emul.h4
-rw-r--r--zephyr/shim/include/usbc/tcpc_it8xxx2.h3
-rw-r--r--zephyr/shim/include/usbc/tcpc_nct38xx.h3
-rw-r--r--zephyr/shim/include/usbc/tcpc_ps8xxx.h3
-rw-r--r--zephyr/shim/include/usbc/tcpc_ps8xxx_emul.h3
-rw-r--r--zephyr/shim/include/usbc/tcpc_raa489000.h21
-rw-r--r--zephyr/shim/include/usbc/tcpc_rt1718s.h3
-rw-r--r--zephyr/shim/include/usbc/tcpci.h4
-rw-r--r--zephyr/shim/include/usbc/usb_muxes.h9
-rw-r--r--zephyr/shim/include/zephyr_hooks_shim.h6
-rw-r--r--zephyr/shim/include/zephyr_host_command.h3
-rw-r--r--zephyr/shim/include/zephyr_shim.h3
-rw-r--r--zephyr/shim/include/zephyr_write_protect.h1
-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
111 files changed, 542 insertions, 752 deletions
diff --git a/zephyr/shim/chip/it8xxx2/clock.c b/zephyr/shim/chip/it8xxx2/clock.c
index a4df87dc1d..14dbc0e7eb 100644
--- a/zephyr/shim/chip/it8xxx2/clock.c
+++ b/zephyr/shim/chip/it8xxx2/clock.c
@@ -3,16 +3,15 @@
* found in the LICENSE file.
*/
-#include "module_id.h"
-
#include <zephyr/device.h>
#include <zephyr/drivers/clock_control.h>
#include <zephyr/kernel.h>
#include <zephyr/logging/log.h>
-#include <zephyr/sys/util.h>
-
#include <soc.h>
#include <soc/ite_it8xxx2/reg_def_cros.h>
+#include <zephyr/sys/util.h>
+
+#include "module_id.h"
LOG_MODULE_REGISTER(shim_clock, LOG_LEVEL_ERR);
diff --git a/zephyr/shim/chip/it8xxx2/gpio.c b/zephyr/shim/chip/it8xxx2/gpio.c
index 16eb7a3963..7106b2a294 100644
--- a/zephyr/shim/chip/it8xxx2/gpio.c
+++ b/zephyr/shim/chip/it8xxx2/gpio.c
@@ -3,13 +3,14 @@
* found in the LICENSE file.
*/
-#include "gpio/gpio.h"
-
#include <zephyr/device.h>
#include <zephyr/drivers/gpio.h>
#include <zephyr/kernel.h>
+
#include <zephyr/logging/log.h>
+#include "gpio/gpio.h"
+
LOG_MODULE_REGISTER(shim_cros_gpio, LOG_LEVEL_ERR);
static const struct unused_pin_config unused_pin_configs[] = {
diff --git a/zephyr/shim/chip/it8xxx2/keyboard_raw.c b/zephyr/shim/chip/it8xxx2/keyboard_raw.c
index 5fe99b7efa..0a117cda14 100644
--- a/zephyr/shim/chip/it8xxx2/keyboard_raw.c
+++ b/zephyr/shim/chip/it8xxx2/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"
/**
* Return true if the current value of the given input GPIO port is zero
diff --git a/zephyr/shim/chip/it8xxx2/power_policy.c b/zephyr/shim/chip/it8xxx2/power_policy.c
index c6e73d53a4..c8efb0ca96 100644
--- a/zephyr/shim/chip/it8xxx2/power_policy.c
+++ b/zephyr/shim/chip/it8xxx2/power_policy.c
@@ -3,13 +3,12 @@
* found in the LICENSE file.
*/
-#include "system.h"
-
-#include <zephyr/kernel.h>
#include <zephyr/pm/pm.h>
#include <zephyr/pm/policy.h>
-
#include <soc.h>
+#include <zephyr/kernel.h>
+
+#include "system.h"
static const struct pm_state_info pm_states[] =
PM_STATE_INFO_LIST_FROM_DT_CPU(DT_NODELABEL(cpu0));
diff --git a/zephyr/shim/chip/mchp/clock.c b/zephyr/shim/chip/mchp/clock.c
index 5fb39bfd43..6ee4cd931c 100644
--- a/zephyr/shim/chip/mchp/clock.c
+++ b/zephyr/shim/chip/mchp/clock.c
@@ -3,17 +3,16 @@
* found in the LICENSE file.
*/
-#include "clock_chip.h"
-#include "module_id.h"
-
#include <zephyr/device.h>
#include <zephyr/drivers/clock_control.h>
#include <zephyr/dt-bindings/clock/mchp_xec_pcr.h>
#include <zephyr/kernel.h>
#include <zephyr/logging/log.h>
-
#include <soc.h>
+#include "clock_chip.h"
+#include "module_id.h"
+
LOG_MODULE_REGISTER(shim_clock, LOG_LEVEL_ERR);
#define PCR_NODE DT_INST(0, microchip_xec_pcr)
diff --git a/zephyr/shim/chip/mchp/gpio.c b/zephyr/shim/chip/mchp/gpio.c
index d772a566d8..7801c6f7cc 100644
--- a/zephyr/shim/chip/mchp/gpio.c
+++ b/zephyr/shim/chip/mchp/gpio.c
@@ -3,12 +3,11 @@
* found in the LICENSE file.
*/
-#include "gpio/gpio.h"
-
#include <zephyr/device.h>
#include <zephyr/drivers/gpio.h>
#include <zephyr/kernel.h>
#include <zephyr/logging/log.h>
+#include "gpio/gpio.h"
LOG_MODULE_REGISTER(shim_cros_gpio, LOG_LEVEL_ERR);
diff --git a/zephyr/shim/chip/mchp/keyboard_raw.c b/zephyr/shim/chip/mchp/keyboard_raw.c
index 9183e4d7dd..95ad642d12 100644
--- a/zephyr/shim/chip/mchp/keyboard_raw.c
+++ b/zephyr/shim/chip/mchp/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"
/**
* Return true if the current value of the given input GPIO port is zero
diff --git a/zephyr/shim/chip/mchp/system.c b/zephyr/shim/chip/mchp/system.c
index 6e5da9aa80..35ba806533 100644
--- a/zephyr/shim/chip/mchp/system.c
+++ b/zephyr/shim/chip/mchp/system.c
@@ -3,12 +3,12 @@
* found in the LICENSE file.
*/
-#include "system.h"
-#include "system_chip.h"
-
#include <zephyr/drivers/bbram.h>
#include <zephyr/logging/log.h>
+#include "system.h"
+#include "system_chip.h"
+
LOG_MODULE_REGISTER(shim_xec_system, LOG_LEVEL_ERR);
#define GET_BBRAM_OFS(node) DT_PROP(DT_PATH(named_bbram_regions, node), offset)
diff --git a/zephyr/shim/chip/mchp/system_download_from_flash.c b/zephyr/shim/chip/mchp/system_download_from_flash.c
index 8f6304274f..51cdc5aab6 100644
--- a/zephyr/shim/chip/mchp/system_download_from_flash.c
+++ b/zephyr/shim/chip/mchp/system_download_from_flash.c
@@ -2,14 +2,13 @@
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
+#include <zephyr/dt-bindings/clock/npcx_clock.h>
+#include <stdnoreturn.h>
+
#include "common.h"
#include "soc.h"
#include "system_chip.h"
-#include <zephyr/dt-bindings/clock/npcx_clock.h>
-
-#include <stdnoreturn.h>
-
/* Modules Map */
#define WDT_NODE DT_INST(0, microchip_xec_watchdog)
#define STRUCT_WDT_REG_BASE_ADDR ((struct wdt_regs *)(DT_REG_ADDR(WDT_NODE)))
diff --git a/zephyr/shim/chip/mchp/system_external_storage.c b/zephyr/shim/chip/mchp/system_external_storage.c
index 5887e045a4..4250b05fe3 100644
--- a/zephyr/shim/chip/mchp/system_external_storage.c
+++ b/zephyr/shim/chip/mchp/system_external_storage.c
@@ -3,16 +3,15 @@
* found in the LICENSE file.
*/
+#include <zephyr/devicetree.h>
+#include <zephyr/drivers/bbram.h>
+#include <soc.h>
+
#include "clock_chip.h"
#include "common.h"
-#include "config_chip.h"
#include "system.h"
#include "system_chip.h"
-
-#include <zephyr/devicetree.h>
-#include <zephyr/drivers/bbram.h>
-
-#include <soc.h>
+#include "config_chip.h"
#define MCHP_ECRO_WORD 0x4F524345u /* ASCII ECRO */
#define MCHP_ECRW_WORD 0x57524345u /* ASCII ECRW */
diff --git a/zephyr/shim/chip/npcx/clock.c b/zephyr/shim/chip/npcx/clock.c
index 2a6fe27ef4..fc483ef775 100644
--- a/zephyr/shim/chip/npcx/clock.c
+++ b/zephyr/shim/chip/npcx/clock.c
@@ -3,17 +3,16 @@
* found in the LICENSE file.
*/
-#include "clock_chip.h"
-#include "module_id.h"
-
#include <zephyr/device.h>
#include <zephyr/drivers/clock_control.h>
#include <zephyr/dt-bindings/clock/npcx_clock.h>
#include <zephyr/kernel.h>
#include <zephyr/logging/log.h>
-
#include <soc.h>
+#include "clock_chip.h"
+#include "module_id.h"
+
LOG_MODULE_REGISTER(shim_clock, LOG_LEVEL_ERR);
#define CDCG_NODE DT_INST(0, nuvoton_npcx_pcc)
diff --git a/zephyr/shim/chip/npcx/gpio.c b/zephyr/shim/chip/npcx/gpio.c
index 1d51c00f61..850123e17b 100644
--- a/zephyr/shim/chip/npcx/gpio.c
+++ b/zephyr/shim/chip/npcx/gpio.c
@@ -3,16 +3,17 @@
* found in the LICENSE file.
*/
-#include "gpio/gpio.h"
-#include "soc_gpio.h"
-#include "util.h"
-
#include <zephyr/device.h>
#include <zephyr/drivers/gpio.h>
#include <zephyr/kernel.h>
-#include <zephyr/logging/log.h>
#include <zephyr/shell/shell.h>
+#include <zephyr/logging/log.h>
+
+#include "gpio/gpio.h"
+#include "soc_gpio.h"
+#include "util.h"
+
LOG_MODULE_REGISTER(shim_cros_gpio, LOG_LEVEL_ERR);
static const struct unused_pin_config unused_pin_configs[] = {
diff --git a/zephyr/shim/chip/npcx/keyboard_raw.c b/zephyr/shim/chip/npcx/keyboard_raw.c
index 1f01952ab9..4d43134482 100644
--- a/zephyr/shim/chip/npcx/keyboard_raw.c
+++ b/zephyr/shim/chip/npcx/keyboard_raw.c
@@ -5,16 +5,15 @@
/* 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/drivers/gpio.h>
-#include <zephyr/kernel.h>
#include <zephyr/logging/log.h>
-
#include <soc.h>
#include <soc_gpio.h>
+#include <zephyr/kernel.h>
+
+#include "drivers/cros_kb_raw.h"
+#include "keyboard_raw.h"
/**
* Return true if the current value of the given input GPIO port is zero
diff --git a/zephyr/shim/chip/npcx/npcx_monitor/npcx_monitor.c b/zephyr/shim/chip/npcx/npcx_monitor/npcx_monitor.c
index 3062ed98a4..e3fecc0cbd 100644
--- a/zephyr/shim/chip/npcx/npcx_monitor/npcx_monitor.c
+++ b/zephyr/shim/chip/npcx/npcx_monitor/npcx_monitor.c
@@ -5,14 +5,12 @@
* NPCX SoC spi flash update tool - monitor firmware
*/
+#include <stdint.h>
+#include <zephyr/sys/util.h>
#include "config_chip.h"
#include "npcx_monitor.h"
#include "registers.h"
-#include <stdint.h>
-
-#include <zephyr/sys/util.h>
-
/*
* TODO(b/197162681): This was copied from chip/npcx/spiflashfw but this
* needs to be moved to Zephyr upstream
diff --git a/zephyr/shim/chip/npcx/power_policy.c b/zephyr/shim/chip/npcx/power_policy.c
index 29ebcbd542..aea6e62d30 100644
--- a/zephyr/shim/chip/npcx/power_policy.c
+++ b/zephyr/shim/chip/npcx/power_policy.c
@@ -3,16 +3,15 @@
* found in the LICENSE file.
*/
-#include "console.h"
-#include "cros_version.h"
-#include "system.h"
-
#include <zephyr/kernel.h>
#include <zephyr/pm/pm.h>
#include <zephyr/pm/policy.h>
-
#include <soc.h>
+#include "console.h"
+#include "cros_version.h"
+#include "system.h"
+
static const struct pm_state_info residency_info[] =
PM_STATE_INFO_LIST_FROM_DT_CPU(DT_NODELABEL(cpu0));
diff --git a/zephyr/shim/chip/npcx/shi.c b/zephyr/shim/chip/npcx/shi.c
index 0cecc2c56e..8bec57252d 100644
--- a/zephyr/shim/chip/npcx/shi.c
+++ b/zephyr/shim/chip/npcx/shi.c
@@ -5,19 +5,18 @@
/* Functions needed by Serial Host Interface module for Chrome EC */
-#include "chipset.h"
-#include "drivers/cros_shi.h"
-#include "hooks.h"
-#include "host_command.h"
-#include "system.h"
-
#include <zephyr/device.h>
#include <zephyr/dt-bindings/clock/npcx_clock.h>
-#include <zephyr/kernel.h>
#include <zephyr/logging/log.h>
+#include <soc.h>
+#include <zephyr/kernel.h>
#include <ap_power/ap_power.h>
-#include <soc.h>
+#include "chipset.h"
+#include "drivers/cros_shi.h"
+#include "hooks.h"
+#include "host_command.h"
+#include "system.h"
LOG_MODULE_REGISTER(shim_cros_shi, LOG_LEVEL_DBG);
diff --git a/zephyr/shim/chip/npcx/system.c b/zephyr/shim/chip/npcx/system.c
index 1fbdca0803..2240acea54 100644
--- a/zephyr/shim/chip/npcx/system.c
+++ b/zephyr/shim/chip/npcx/system.c
@@ -3,12 +3,12 @@
* found in the LICENSE file.
*/
-#include "system.h"
-#include "system_chip.h"
-
#include <zephyr/drivers/bbram.h>
#include <zephyr/logging/log.h>
+#include "system.h"
+#include "system_chip.h"
+
LOG_MODULE_REGISTER(shim_npcx_system, LOG_LEVEL_ERR);
static void chip_bbram_status_check(void)
diff --git a/zephyr/shim/chip/npcx/system_download_from_flash.c b/zephyr/shim/chip/npcx/system_download_from_flash.c
index 53e22d4839..1aef9560d1 100644
--- a/zephyr/shim/chip/npcx/system_download_from_flash.c
+++ b/zephyr/shim/chip/npcx/system_download_from_flash.c
@@ -2,14 +2,13 @@
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
-#include "common.h"
-#include "soc.h"
-#include "system_chip.h"
-
#include <zephyr/dt-bindings/clock/npcx_clock.h>
+#include <stdnoreturn.h>
#include <zephyr/sys/__assert.h>
-#include <stdnoreturn.h>
+#include "common.h"
+#include "soc.h"
+#include "system_chip.h"
/* Modules Map */
#define NPCX_PMC_BASE_ADDR 0x4000D000
diff --git a/zephyr/shim/chip/npcx/system_external_storage.c b/zephyr/shim/chip/npcx/system_external_storage.c
index d3b2d26362..81e1968cf4 100644
--- a/zephyr/shim/chip/npcx/system_external_storage.c
+++ b/zephyr/shim/chip/npcx/system_external_storage.c
@@ -3,15 +3,15 @@
* found in the LICENSE file.
*/
+#include <zephyr/devicetree.h>
+#include <zephyr/drivers/syscon.h>
+
#include "clock_chip.h"
#include "common.h"
#include "rom_chip.h"
#include "system.h"
#include "system_chip.h"
-#include <zephyr/devicetree.h>
-#include <zephyr/drivers/syscon.h>
-
/* TODO (b:179900857) Make this implementation not npcx specific. */
static const struct device *mdc_dev = DEVICE_DT_GET(DT_NODELABEL(mdc));
diff --git a/zephyr/shim/core/cortex-m/irq_command.c b/zephyr/shim/core/cortex-m/irq_command.c
index 651f804800..1cf1a213e4 100644
--- a/zephyr/shim/core/cortex-m/irq_command.c
+++ b/zephyr/shim/core/cortex-m/irq_command.c
@@ -3,9 +3,8 @@
* found in the LICENSE file.
*/
-#include "console.h"
-
#include <zephyr/arch/arm/aarch32/cortex_m/cmsis.h>
+#include "console.h"
/* IRQ counters */
int irq_count[CONFIG_NUM_IRQS];
diff --git a/zephyr/shim/core/cortex-m/mpu.c b/zephyr/shim/core/cortex-m/mpu.c
index 601961225c..8025227700 100644
--- a/zephyr/shim/core/cortex-m/mpu.c
+++ b/zephyr/shim/core/cortex-m/mpu.c
@@ -3,12 +3,13 @@
* found in the LICENSE file.
*/
-#include "config.h"
-#include "mpu.h"
-
#include <zephyr/arch/arm/aarch32/cortex_m/cmsis.h>
#include <zephyr/arch/cpu.h>
#include <zephyr/init.h>
+
+#include "config.h"
+#include "mpu.h"
+
#include <zephyr/logging/log.h>
LOG_MODULE_REGISTER(shim_mpu, LOG_LEVEL_ERR);
diff --git a/zephyr/shim/include/board_led.h b/zephyr/shim/include/board_led.h
index ae4b23d74e..074ffa0256 100644
--- a/zephyr/shim/include/board_led.h
+++ b/zephyr/shim/include/board_led.h
@@ -6,10 +6,6 @@
#ifndef __BOARD_LED_H
#define __BOARD_LED_H
-#include <stdint.h>
-
-#include <zephyr/drivers/pwm.h>
-
struct board_led_pwm_dt_channel {
const struct device *dev;
uint32_t channel;
diff --git a/zephyr/shim/include/charger/chg_isl923x.h b/zephyr/shim/include/charger/chg_isl923x.h
index 9156e574de..b0323cd1b8 100644
--- a/zephyr/shim/include/charger/chg_isl923x.h
+++ b/zephyr/shim/include/charger/chg_isl923x.h
@@ -3,9 +3,8 @@
* found in the LICENSE file.
*/
-#include "driver/charger/isl923x_public.h"
-
#include <zephyr/devicetree.h>
+#include "driver/charger/isl923x_public.h"
#define ISL923X_CHG_COMPAT intersil_isl923x
#define ISL923X_EMUL_COMPAT cros_isl923x_emul
diff --git a/zephyr/shim/include/charger/chg_isl9241.h b/zephyr/shim/include/charger/chg_isl9241.h
index c6d2239038..711a581c2f 100644
--- a/zephyr/shim/include/charger/chg_isl9241.h
+++ b/zephyr/shim/include/charger/chg_isl9241.h
@@ -3,9 +3,8 @@
* found in the LICENSE file.
*/
-#include "driver/charger/isl9241_public.h"
-
#include <zephyr/devicetree.h>
+#include "driver/charger/isl9241_public.h"
#define ISL9241_CHG_COMPAT intersil_isl9241
diff --git a/zephyr/shim/include/charger/chg_rt9490.h b/zephyr/shim/include/charger/chg_rt9490.h
index 44d81eac48..3ac596d482 100644
--- a/zephyr/shim/include/charger/chg_rt9490.h
+++ b/zephyr/shim/include/charger/chg_rt9490.h
@@ -3,9 +3,8 @@
* found in the LICENSE file.
*/
-#include "driver/charger/rt9490.h"
-
#include <zephyr/devicetree.h>
+#include "driver/charger/rt9490.h"
#define RT9490_CHG_COMPAT richtek_rt9490
#define RT9490_EMUL_COMPAT zephyr_rt9490_emul
diff --git a/zephyr/shim/include/charger/chg_sm5803.h b/zephyr/shim/include/charger/chg_sm5803.h
index 853dd06a63..65ef066970 100644
--- a/zephyr/shim/include/charger/chg_sm5803.h
+++ b/zephyr/shim/include/charger/chg_sm5803.h
@@ -3,9 +3,8 @@
* found in the LICENSE file.
*/
-#include "driver/charger/sm5803.h"
-
#include <zephyr/devicetree.h>
+#include "driver/charger/sm5803.h"
#define SM5803_CHG_COMPAT siliconmitus_sm5803
diff --git a/zephyr/shim/include/charger_chips.h b/zephyr/shim/include/charger_chips.h
index 503a53330d..b24fa246bf 100644
--- a/zephyr/shim/include/charger_chips.h
+++ b/zephyr/shim/include/charger_chips.h
@@ -7,7 +7,6 @@
#define __CROS_EC_CHARGER_CHIPS_H
#include "charger.h"
-
#include <zephyr/devicetree.h>
extern const struct charger_config_t chg_chips_alt[];
diff --git a/zephyr/shim/include/config_chip.h b/zephyr/shim/include/config_chip.h
index 28a93739c5..7c63ca31f9 100644
--- a/zephyr/shim/include/config_chip.h
+++ b/zephyr/shim/include/config_chip.h
@@ -15,8 +15,6 @@
#line 16
#include <zephyr/devicetree.h>
-#include <zephyr/toolchain.h>
-
#include <autoconf.h>
#define SENSOR_NODE DT_PATH(motionsense_sensor)
@@ -314,11 +312,6 @@
#ifdef CONFIG_PLATFORM_EC_OCPC
#define CONFIG_OCPC
#define CONFIG_OCPC_DEF_RBATT_MOHMS CONFIG_PLATFORM_EC_OCPC_DEF_RBATT_MOHMS
-#ifdef CONFIG_PLATFORM_EC_OCPC_DEF_DRIVELIMIT_MILLIVOLTS
-#undef CONFIG_OCPC_DEF_DRIVELIMIT_MILLIVOLTS
-#define CONFIG_OCPC_DEF_DRIVELIMIT_MILLIVOLTS \
- CONFIG_PLATFORM_EC_OCPC_DEF_DRIVELIMIT_MILLIVOLTS
-#endif
#endif
#undef CONFIG_CHARGER_SINGLE_CHIP
@@ -495,23 +488,17 @@
/* The jump data goes at the end of data ram, so for posix, the end of ram is
* wherever the jump data ended up.
*/
-extern char mock_jump_data[CONFIG_PLATFORM_EC_PRESERVED_END_OF_RAM_SIZE];
+#include "sysjump.h"
+extern char mock_jump_data[sizeof(struct jump_data) + 256];
#define CONFIG_RAM_BASE 0x0
-#define CONFIG_DATA_RAM_SIZE \
- (((uintptr_t)&mock_jump_data) + \
- CONFIG_PLATFORM_EC_PRESERVED_END_OF_RAM_SIZE)
+#define CONFIG_DATA_RAM_SIZE \
+ (((uintptr_t)&mock_jump_data) + sizeof(mock_jump_data))
#else
#error "A zephyr,sram device must be chosen in the device tree"
#endif
#define CONFIG_RAM_SIZE CONFIG_DATA_RAM_SIZE
-#undef CONFIG_PRESERVED_END_OF_RAM_SIZE
-#ifdef CONFIG_PLATFORM_EC_PRESERVED_END_OF_RAM_SIZE
-#define CONFIG_PRESERVED_END_OF_RAM_SIZE \
- CONFIG_PLATFORM_EC_PRESERVED_END_OF_RAM_SIZE
-#endif
-
#define CONFIG_RO_MEM_OFF CONFIG_CROS_EC_RO_MEM_OFF
#define CONFIG_RO_MEM_SIZE CONFIG_CROS_EC_RO_MEM_SIZE
#define CONFIG_RW_MEM_OFF CONFIG_CROS_EC_RW_MEM_OFF
@@ -649,11 +636,6 @@ extern char mock_jump_data[CONFIG_PLATFORM_EC_PRESERVED_END_OF_RAM_SIZE];
#define CONFIG_FAN_BYPASS_SLOW_RESPONSE
#endif
-#undef CONFIG_CUSTOM_FAN_CONTROL
-#ifdef CONFIG_PLATFORM_EC_CUSTOM_FAN_CONTROL
-#define CONFIG_CUSTOM_FAN_CONTROL
-#endif
-
#ifdef CONFIG_PLATFORM_EC_I2C
/* Also see shim/include/i2c/i2c.h which defines the ports enum */
#define CONFIG_I2C_CONTROLLER
@@ -729,11 +711,6 @@ extern char mock_jump_data[CONFIG_PLATFORM_EC_PRESERVED_END_OF_RAM_SIZE];
#define CONFIG_KEYBOARD_REFRESH_ROW3
#endif /* CONFIG_PLATFORM_EC_KEYBOARD_REFRESH_ROW3 */
-#undef CONFIG_KEYBOARD_FACTORY_TEST
-#ifdef CONFIG_PLATFORM_EC_KEYBOARD_FACTORY_TEST
-#define CONFIG_KEYBOARD_FACTORY_TEST
-#endif
-
#undef CONFIG_KEYBOARD_KEYPAD
#ifdef CONFIG_PLATFORM_EC_KEYBOARD_KEYPAD
#define CONFIG_KEYBOARD_KEYPAD
@@ -1017,9 +994,6 @@ extern char mock_jump_data[CONFIG_PLATFORM_EC_PRESERVED_END_OF_RAM_SIZE];
CONFIG_PLATFORM_EC_PD_POWER_SUPPLY_TURN_OFF_DELAY
#endif
-#undef CONFIG_EXTPOWER_DEBOUNCE_MS
-#define CONFIG_EXTPOWER_DEBOUNCE_MS CONFIG_PLATFORM_EC_EXTPOWER_DEBOUNCE_MS
-
#undef CONFIG_CMD_PPC_DUMP
#ifdef CONFIG_PLATFORM_EC_CONSOLE_CMD_PPC_DUMP
#define CONFIG_CMD_PPC_DUMP
@@ -1052,16 +1026,6 @@ extern char mock_jump_data[CONFIG_PLATFORM_EC_PRESERVED_END_OF_RAM_SIZE];
#endif
-#undef CONFIG_CHARGE_STATE_DEBUG
-#ifdef CONFIG_PLATFORM_EC_CHARGE_STATE_DEBUG
-#define CONFIG_CHARGE_STATE_DEBUG
-#endif
-
-#undef CONFIG_CMD_PWR_AVG
-#ifdef CONFIG_PLATFORM_EC_CMD_PWR_AVG
-#define CONFIG_CMD_PWR_AVG
-#endif
-
#undef CONFIG_CHARGESPLASH
#ifdef CONFIG_PLATFORM_EC_CHARGESPLASH
#define CONFIG_CHARGESPLASH
@@ -1078,22 +1042,9 @@ extern char mock_jump_data[CONFIG_PLATFORM_EC_PRESERVED_END_OF_RAM_SIZE];
CONFIG_PLATFORM_EC_CHARGESPLASH_MAX_REQUESTS_PER_PERIOD
#endif
-#undef CONFIG_CHARGER_DEFAULT_CURRENT_LIMIT
-#ifdef CONFIG_PLATFORM_EC_CHARGER_DEFAULT_CURRENT_LIMIT
-#define CONFIG_CHARGER_DEFAULT_CURRENT_LIMIT \
- CONFIG_PLATFORM_EC_CHARGER_DEFAULT_CURRENT_LIMIT
-#endif
-
-#undef CONFIG_CHARGER_MIN_INPUT_CURRENT_LIMIT
-#ifdef CONFIG_PLATFORM_EC_CHARGER_MIN_INPUT_CURRENT_LIMIT
-#define CONFIG_CHARGER_MIN_INPUT_CURRENT_LIMIT \
- CONFIG_PLATFORM_EC_CHARGER_MIN_INPUT_CURRENT_LIMIT
-#endif
-
-#undef CONFIG_CHARGER_INPUT_CURRENT_DERATE_PCT
-#ifdef CONFIG_PLATFORM_EC_CHARGER_INPUT_CURRENT_DERATE_PCT
-#define CONFIG_CHARGER_INPUT_CURRENT_DERATE_PCT \
- CONFIG_PLATFORM_EC_CHARGER_INPUT_CURRENT_DERATE_PCT
+#undef CONFIG_CHARGER_INPUT_CURRENT
+#ifdef CONFIG_PLATFORM_EC_CHARGER_INPUT_CURRENT
+#define CONFIG_CHARGER_INPUT_CURRENT CONFIG_PLATFORM_EC_CHARGER_INPUT_CURRENT
#endif
#undef CONFIG_CHARGER_MIN_BAT_PCT_FOR_POWER_ON
@@ -1376,11 +1327,6 @@ extern char mock_jump_data[CONFIG_PLATFORM_EC_PRESERVED_END_OF_RAM_SIZE];
#define CONFIG_USB_PE_SM
#endif
-#undef CONFIG_USB_DPM_SM
-#ifdef CONFIG_PLATFORM_EC_USB_DPM_SM
-#define CONFIG_USB_DPM_SM
-#endif
-
#undef CONFIG_USB_PD_DECODE_SOP
#ifdef CONFIG_PLATFORM_EC_USB_PD_DECODE_SOP
#define CONFIG_USB_PD_DECODE_SOP
@@ -1981,42 +1927,6 @@ extern char mock_jump_data[CONFIG_PLATFORM_EC_PRESERVED_END_OF_RAM_SIZE];
#define CONFIG_ACCEL_FIFO_THRES CONFIG_PLATFORM_EC_ACCEL_FIFO_THRES
#endif /* CONFIG_PLATFORM_EC_ACCEL_FIFO */
-#undef CONFIG_BODY_DETECTION
-#undef CONFIG_BODY_DETECTION_SENSOR
-#undef CONFIG_BODY_DETECTION_MAX_WINDOW_SIZE
-#undef CONFIG_BODY_DETECTION_VAR_THRESHOLD
-#undef CONFIG_BODY_DETECTION_CONFIDENCE_DELTA
-#undef CONFIG_BODY_DETECTION_VAR_NOISE_FACTOR
-#undef CONFIG_BODY_DETECTION_ON_BODY_CON
-#undef CONFIG_BODY_DETECTION_OFF_BODY_CON
-#undef CONFIG_BODY_DETECTION_STATIONARY_DURATION
-#undef CONFIG_BODY_DETECTION_NOTIFY_MODE_CHANGE
-#undef CONFIG_BODY_DETECTION_ALWAYS_ENABLE_IN_S0
-#ifdef CONFIG_PLATFORM_EC_BODY_DETECTION
-#define CONFIG_BODY_DETECTION
-#define CONFIG_BODY_DETECTION_SENSOR SENSOR_ID(DT_ALIAS(on_body_sensor))
-#define CONFIG_BODY_DETECTION_MAX_WINDOW_SIZE \
- CONFIG_PLATFORM_EC_BODY_DETECTION_MAX_WINDOW_SIZE
-#define CONFIG_BODY_DETECTION_VAR_THRESHOLD \
- CONFIG_PLATFORM_EC_BODY_DETECTION_VAR_THRESHOLD
-#define CONFIG_BODY_DETECTION_CONFIDENCE_DELTA \
- CONFIG_PLATFORM_EC_BODY_DETECTION_CONFIDENCE_DELTA
-#define CONFIG_BODY_DETECTION_VAR_NOISE_FACTOR \
- CONFIG_PLATFORM_EC_BODY_DETECTION_VAR_NOISE_FACTOR
-#define CONFIG_BODY_DETECTION_ON_BODY_CON \
- CONFIG_PLATFORM_EC_BODY_DETECTION_ON_BODY_CON
-#define CONFIG_BODY_DETECTION_OFF_BODY_CON \
- CONFIG_PLATFORM_EC_BODY_DETECTION_OFF_BODY_CON
-#define CONFIG_BODY_DETECTION_STATIONARY_DURATION \
- CONFIG_PLATFORM_EC_BODY_DETECTION_STATIONARY_DURATION
-#ifdef CONFIG_PLATFORM_EC_BODY_DETECTION_NOTIFY_MODE_CHANGE
-#define CONFIG_BODY_DETECTION_NOTIFY_MODE_CHANGE
-#endif /* CONFIG_PLATFORM_EC_BODY_DETECTION_NOTIFY_MODE_CHANGE */
-#ifdef CONFIG_PLATFORM_EC_BODY_DETECTION_ALWAYS_ENABLE_IN_S0
-#define CONFIG_BODY_DETECTION_ALWAYS_ENABLE_IN_S0
-#endif
-#endif /* CONFIG_PLATFORM_EC_BODY_DETECTION */
-
#undef CONFIG_CMD_ACCELS
#ifdef CONFIG_PLATFORM_EC_CONSOLE_CMD_ACCELS
#define CONFIG_CMD_ACCELS
@@ -2043,11 +1953,6 @@ extern char mock_jump_data[CONFIG_PLATFORM_EC_PRESERVED_END_OF_RAM_SIZE];
#define CONFIG_CMD_ACCEL_SPOOF
#endif
-#undef CONFIG_GESTURE_HOST_DETECTION
-#ifdef CONFIG_PLATFORM_EC_GESTURE_HOST_DETECTION
-#define CONFIG_GESTURE_HOST_DETECTION
-#endif
-
#undef CONFIG_SENSOR_TIGHT_TIMESTAMPS
#ifdef CONFIG_PLATFORM_EC_SENSOR_TIGHT_TIMESTAMPS
#define CONFIG_SENSOR_TIGHT_TIMESTAMPS
@@ -2168,10 +2073,7 @@ extern char mock_jump_data[CONFIG_PLATFORM_EC_PRESERVED_END_OF_RAM_SIZE];
#undef CONFIG_MAX695X_SEVEN_SEGMENT_DISPLAY
#ifdef CONFIG_PLATFORM_EC_MAX695X_SEVEN_SEGMENT_DISPLAY
#define CONFIG_MAX695X_SEVEN_SEGMENT_DISPLAY
-#define PORT80_I2C_ADDR \
- DT_REG_ADDR(DT_COMPAT_GET_ANY_STATUS_OKAY(maxim_max695x))
-BUILD_ASSERT((DT_NUM_INST_STATUS_OKAY(maxim_max695x)) == 1,
- "Only one instance of maxim,max695x should be defined");
+#define PORT80_I2C_ADDR DT_REG_ADDR(DT_NODELABEL(seven_seg_display))
#endif
#undef CONFIG_CMD_SEVEN_SEG_DISPLAY
@@ -2499,16 +2401,6 @@ BUILD_ASSERT((DT_NUM_INST_STATUS_OKAY(maxim_max695x)) == 1,
#define CONFIG_HIBERNATE_PSL
#endif
-#ifdef CONFIG_PLATFORM_EC_HIBERNATE_DELAY_SEC
-#undef CONFIG_HIBERNATE_DELAY_SEC
-#define CONFIG_HIBERNATE_DELAY_SEC CONFIG_PLATFORM_EC_HIBERNATE_DELAY_SEC
-#endif
-
-#undef CONFIG_HIBERNATE
-#ifdef CONFIG_PLATFORM_EC_HIBERNATE
-#define CONFIG_HIBERNATE
-#endif
-
#undef CONFIG_BATTERY_DEVICE_CHEMISTRY
#ifdef CONFIG_PLATFORM_EC_USE_BATTERY_DEVICE_CHEMISTRY
#define CONFIG_BATTERY_DEVICE_CHEMISTRY \
@@ -2645,10 +2537,7 @@ BUILD_ASSERT((DT_NUM_INST_STATUS_OKAY(maxim_max695x)) == 1,
#undef CONFIG_MP2964
#ifdef CONFIG_PLATFORM_EC_MP2964
#define CONFIG_MP2964
-#define I2C_ADDR_MP2964_FLAGS \
- DT_REG_ADDR(DT_COMPAT_GET_ANY_STATUS_OKAY(mps_mp2964))
-BUILD_ASSERT((DT_NUM_INST_STATUS_OKAY(mps_mp2964)) == 1,
- "Only one instance of mps,mp2964 should be defined");
+#define I2C_ADDR_MP2964_FLAGS DT_REG_ADDR(DT_NODELABEL(pmic_mp2964))
#endif
#undef CONFIG_ACCELGYRO_ICM_COMM_SPI
diff --git a/zephyr/shim/include/cros_cbi.h b/zephyr/shim/include/cros_cbi.h
index 603be590c1..1f8a1b3dfa 100644
--- a/zephyr/shim/include/cros_cbi.h
+++ b/zephyr/shim/include/cros_cbi.h
@@ -6,16 +6,17 @@
#ifndef __CROS_EC_CROS_CBI_H
#define __CROS_EC_CROS_CBI_H
+#include <zephyr/kernel.h>
#include <zephyr/device.h>
#include <zephyr/devicetree.h>
-#include <zephyr/kernel.h>
/*
* Macros are _INST_ types, so require DT_DRV_COMPAT to be defined.
*/
-#define DT_DRV_COMPAT cros_ec_cbi_ssfc_value
+#define DT_DRV_COMPAT named_cbi_ssfc_value
+#define CROS_CBI_LABEL "cros_cbi"
-#define CBI_SSFC_VALUE_COMPAT DT_DRV_COMPAT
+#define CBI_SSFC_VALUE_COMPAT named_cbi_ssfc_value
#define CBI_SSFC_VALUE_ID(id) DT_CAT(CBI_SSFC_VALUE_, id)
#define CBI_SSFC_VALUE_ID_WITH_COMMA(id) CBI_SSFC_VALUE_ID(id),
#define CBI_SSFC_VALUE_INST_ENUM(inst, _) \
diff --git a/zephyr/shim/include/fpu.h b/zephyr/shim/include/fpu.h
index 20df108b87..d1e4460827 100644
--- a/zephyr/shim/include/fpu.h
+++ b/zephyr/shim/include/fpu.h
@@ -16,7 +16,7 @@
* This code is taken from core/cortex-m/include/fpu.h
*/
-#ifdef CONFIG_FPU
+#ifdef CONFIG_PLATFORM_EC_FPU
/* Implementation for Cortex-M */
#ifdef CONFIG_CPU_CORTEX_M
@@ -55,12 +55,10 @@ static inline float fabsf(float v)
__asm__("fabs.s %0, %1" : "=f"(abs) : "f"(v));
return abs;
}
-#elif CONFIG_BOARD_NATIVE_POSIX
-#include <math.h>
#else
#error "Unsupported core: please add an implementation"
#endif
-#endif /* CONFIG_FPU */
+#endif /* CONFIG_PLATFORM_EC_FPU */
#endif /* __CROS_EC_MATH_H */
diff --git a/zephyr/shim/include/gpio/gpio.h b/zephyr/shim/include/gpio/gpio.h
index fbe57729fe..7d41c0fa02 100644
--- a/zephyr/shim/include/gpio/gpio.h
+++ b/zephyr/shim/include/gpio/gpio.h
@@ -8,7 +8,6 @@
#include <zephyr/device.h>
#include <zephyr/devicetree.h>
-#include <zephyr/drivers/gpio.h>
/*
* Validate interrupt flags are valid for the Zephyr GPIO driver.
diff --git a/zephyr/shim/include/motionsense_sensors.h b/zephyr/shim/include/motionsense_sensors.h
index f83a8c63ad..e00eae426e 100644
--- a/zephyr/shim/include/motionsense_sensors.h
+++ b/zephyr/shim/include/motionsense_sensors.h
@@ -6,9 +6,8 @@
#ifndef __CROS_EC_MOTIONSENSE_SENSORS_H
#define __CROS_EC_MOTIONSENSE_SENSORS_H
-#include "motion_sense.h"
-
#include <zephyr/devicetree.h>
+#include "motion_sense.h"
extern struct motion_sensor_t motion_sensors_alt[];
diff --git a/zephyr/shim/include/motionsense_sensors_defs.h b/zephyr/shim/include/motionsense_sensors_defs.h
index b4b0274237..ac0fc6bf56 100644
--- a/zephyr/shim/include/motionsense_sensors_defs.h
+++ b/zephyr/shim/include/motionsense_sensors_defs.h
@@ -6,10 +6,10 @@
#ifndef __CROS_EC_MOTIONSENSE_SENSORS_DEFS_H
#define __CROS_EC_MOTIONSENSE_SENSORS_DEFS_H
-#include "common.h"
-
#include <zephyr/devicetree.h>
+#include "common.h"
+
#define SENSOR_ID(id) DT_CAT(SENSOR_, id)
/* Define the SENSOR_ID if:
diff --git a/zephyr/shim/include/power/power.h b/zephyr/shim/include/power/power.h
index a764e0c8b5..1e780646af 100644
--- a/zephyr/shim/include/power/power.h
+++ b/zephyr/shim/include/power/power.h
@@ -9,10 +9,30 @@
#include <zephyr/devicetree.h>
#include <zephyr/drivers/gpio.h>
-#if CONFIG_CROS_EC_POWER_SIGNAL_LIST
-
#define POWER_SIGNAL_LIST_NODE DT_NODELABEL(power_signal_list)
+#define SYSTEM_DT_POWER_SIGNAL_CONFIG DT_NODE_EXISTS(POWER_SIGNAL_LIST_NODE)
+
+#if (SYSTEM_DT_POWER_SIGNAL_CONFIG)
+
+#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),
+
#define GEN_POWER_SIGNAL_ENUM_ENTRY(cid) \
DT_STRING_UPPER_TOKEN(cid, power_enum_name)
@@ -22,5 +42,13 @@ enum power_signal {
POWER_SIGNAL_COUNT
};
-#endif /* CONFIG_CROS_EC_POWER_SIGNAL_LIST */
+/*
+ * 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 */
#endif /* ZEPHYR_CHROME_POWER_POWER_H */
diff --git a/zephyr/shim/include/temp_sensor/temp_sensor.h b/zephyr/shim/include/temp_sensor/temp_sensor.h
index c4770ce767..9be18987eb 100644
--- a/zephyr/shim/include/temp_sensor/temp_sensor.h
+++ b/zephyr/shim/include/temp_sensor/temp_sensor.h
@@ -6,10 +6,9 @@
#ifndef ZEPHYR_SHIM_INCLUDE_TEMP_SENSOR_TEMP_SENSOR_H_
#define ZEPHYR_SHIM_INCLUDE_TEMP_SENSOR_TEMP_SENSOR_H_
-#include "charger/chg_rt9490.h"
-#include "include/temp_sensor.h"
-
#include <zephyr/devicetree.h>
+#include "include/temp_sensor.h"
+#include "charger/chg_rt9490.h"
#ifdef CONFIG_PLATFORM_EC_TEMP_SENSOR
@@ -144,7 +143,6 @@ enum tmp112_sensor {
struct zephyr_temp_sensor {
/* Read sensor value in K into temp_ptr; return non-zero if error. */
int (*read)(const struct temp_sensor_t *sensor, int *temp_ptr);
- void (*update_temperature)(int idx);
const struct thermistor_info *thermistor;
#if ANY_INST_HAS_POWER_GOOD_PIN
const struct device *power_good_dev;
diff --git a/zephyr/shim/include/usbc/bc12_rt9490.h b/zephyr/shim/include/usbc/bc12_rt9490.h
index c4323728f9..a9371ddeea 100644
--- a/zephyr/shim/include/usbc/bc12_rt9490.h
+++ b/zephyr/shim/include/usbc/bc12_rt9490.h
@@ -5,7 +5,7 @@
#include "driver/charger/rt9490.h"
-#define RT9490_BC12_COMPAT richtek_rt9490
+#define RT9490_BC12_COMPAT richtek_rt9490_bc12
#define BC12_CHIP_RT9490(id) \
{ \
diff --git a/zephyr/shim/include/usbc/ppc.h b/zephyr/shim/include/usbc/ppc.h
index fa38145f66..28e518a3ef 100644
--- a/zephyr/shim/include/usbc/ppc.h
+++ b/zephyr/shim/include/usbc/ppc.h
@@ -6,16 +6,15 @@
#ifndef ZEPHYR_CHROME_USBC_PPC_H
#define ZEPHYR_CHROME_USBC_PPC_H
-#include "usbc/ppc_nx20p348x.h"
+#include <zephyr/device.h>
+#include <zephyr/devicetree.h>
#include "usbc/ppc_rt1739.h"
+#include "usbc/ppc_nx20p348x.h"
#include "usbc/ppc_sn5s330.h"
#include "usbc/ppc_syv682x.h"
#include "usbc/utils.h"
#include "usbc_ppc.h"
-#include <zephyr/device.h>
-#include <zephyr/devicetree.h>
-
extern struct ppc_config_t ppc_chips_alt[];
#define ALT_PPC_CHIP_CHK(usbc_id, usb_port_num) \
diff --git a/zephyr/shim/include/usbc/tcpc_anx7447.h b/zephyr/shim/include/usbc/tcpc_anx7447.h
index 89076c8c49..b45e03393c 100644
--- a/zephyr/shim/include/usbc/tcpc_anx7447.h
+++ b/zephyr/shim/include/usbc/tcpc_anx7447.h
@@ -3,9 +3,8 @@
* found in the LICENSE file.
*/
-#include "tcpm/anx7447_public.h"
-
#include <zephyr/devicetree.h>
+#include "tcpm/anx7447_public.h"
#define ANX7447_TCPC_COMPAT analogix_anx7447_tcpc
diff --git a/zephyr/shim/include/usbc/tcpc_anx7447_emul.h b/zephyr/shim/include/usbc/tcpc_anx7447_emul.h
index 3367286dd9..78322a7329 100644
--- a/zephyr/shim/include/usbc/tcpc_anx7447_emul.h
+++ b/zephyr/shim/include/usbc/tcpc_anx7447_emul.h
@@ -3,11 +3,10 @@
* found in the LICENSE file.
*/
-#include "driver/tcpm/anx7447_public.h"
-
#include <zephyr/devicetree.h>
+#include "driver/tcpm/anx7447_public.h"
-#define ANX7447_EMUL_COMPAT cros_anx7447_tcpc_emul
+#define ANX7447_EMUL_COMPAT cros_anx7447_emul
#define TCPC_CONFIG_ANX7447_EMUL(id) \
{ \
diff --git a/zephyr/shim/include/usbc/tcpc_ccgxxf.h b/zephyr/shim/include/usbc/tcpc_ccgxxf.h
index fb7bdcabcf..0c02cf6846 100644
--- a/zephyr/shim/include/usbc/tcpc_ccgxxf.h
+++ b/zephyr/shim/include/usbc/tcpc_ccgxxf.h
@@ -3,9 +3,8 @@
* found in the LICENSE file.
*/
-#include "driver/tcpm/ccgxxf.h"
-
#include <zephyr/devicetree.h>
+#include "driver/tcpm/ccgxxf.h"
#define CCGXXF_TCPC_COMPAT cypress_ccgxxf
diff --git a/zephyr/shim/include/usbc/tcpc_fusb302.h b/zephyr/shim/include/usbc/tcpc_fusb302.h
index fa309051cd..a2e512d938 100644
--- a/zephyr/shim/include/usbc/tcpc_fusb302.h
+++ b/zephyr/shim/include/usbc/tcpc_fusb302.h
@@ -3,9 +3,8 @@
* found in the LICENSE file.
*/
-#include "driver/tcpm/fusb302.h"
-
#include <zephyr/devicetree.h>
+#include "driver/tcpm/fusb302.h"
#define FUSB302_TCPC_COMPAT fairchild_fusb302
diff --git a/zephyr/shim/include/usbc/tcpc_generic_emul.h b/zephyr/shim/include/usbc/tcpc_generic_emul.h
index 9000dfdf20..7dc46c51ba 100644
--- a/zephyr/shim/include/usbc/tcpc_generic_emul.h
+++ b/zephyr/shim/include/usbc/tcpc_generic_emul.h
@@ -3,10 +3,10 @@
* found in the LICENSE file.
*/
-#include "driver/tcpm/tcpci.h"
-
#include <zephyr/devicetree.h>
+#include "driver/tcpm/tcpci.h"
+
#define TCPCI_EMUL_COMPAT cros_tcpci_generic_emul
#define TCPC_CONFIG_TCPCI_EMUL(id) \
diff --git a/zephyr/shim/include/usbc/tcpc_it8xxx2.h b/zephyr/shim/include/usbc/tcpc_it8xxx2.h
index b9084782e0..c619656667 100644
--- a/zephyr/shim/include/usbc/tcpc_it8xxx2.h
+++ b/zephyr/shim/include/usbc/tcpc_it8xxx2.h
@@ -3,9 +3,8 @@
* found in the LICENSE file.
*/
-#include "driver/tcpm/it8xxx2_pd_public.h"
-
#include <zephyr/devicetree.h>
+#include "driver/tcpm/it8xxx2_pd_public.h"
#define IT8XXX2_TCPC_COMPAT ite_it8xxx2_usbpd
diff --git a/zephyr/shim/include/usbc/tcpc_nct38xx.h b/zephyr/shim/include/usbc/tcpc_nct38xx.h
index 7a0752904e..87ba3379c8 100644
--- a/zephyr/shim/include/usbc/tcpc_nct38xx.h
+++ b/zephyr/shim/include/usbc/tcpc_nct38xx.h
@@ -6,9 +6,8 @@
#ifndef __CROS_EC_TCPC_NCT38XX_H
#define __CROS_EC_TCPC_NCT38XX_H
-#include "driver/tcpm/nct38xx.h"
-
#include <zephyr/devicetree.h>
+#include "driver/tcpm/nct38xx.h"
#define NCT38XX_TCPC_COMPAT nuvoton_nct38xx
diff --git a/zephyr/shim/include/usbc/tcpc_ps8xxx.h b/zephyr/shim/include/usbc/tcpc_ps8xxx.h
index 7d3b9c6ccc..1a457af09b 100644
--- a/zephyr/shim/include/usbc/tcpc_ps8xxx.h
+++ b/zephyr/shim/include/usbc/tcpc_ps8xxx.h
@@ -3,9 +3,8 @@
* found in the LICENSE file.
*/
-#include "driver/tcpm/ps8xxx_public.h"
-
#include <zephyr/devicetree.h>
+#include "driver/tcpm/ps8xxx_public.h"
#define PS8XXX_COMPAT parade_ps8xxx
diff --git a/zephyr/shim/include/usbc/tcpc_ps8xxx_emul.h b/zephyr/shim/include/usbc/tcpc_ps8xxx_emul.h
index b1ea6f1705..fbd2e4bfd1 100644
--- a/zephyr/shim/include/usbc/tcpc_ps8xxx_emul.h
+++ b/zephyr/shim/include/usbc/tcpc_ps8xxx_emul.h
@@ -3,9 +3,8 @@
* found in the LICENSE file.
*/
-#include "driver/tcpm/ps8xxx_public.h"
-
#include <zephyr/devicetree.h>
+#include "driver/tcpm/ps8xxx_public.h"
#define PS8XXX_EMUL_COMPAT cros_ps8xxx_emul
diff --git a/zephyr/shim/include/usbc/tcpc_raa489000.h b/zephyr/shim/include/usbc/tcpc_raa489000.h
deleted file mode 100644
index 47e7706ae1..0000000000
--- a/zephyr/shim/include/usbc/tcpc_raa489000.h
+++ /dev/null
@@ -1,21 +0,0 @@
-/* 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 "driver/tcpm/raa489000.h"
-
-#include <zephyr/devicetree.h>
-
-#define RAA489000_TCPC_COMPAT renesas_raa489000
-
-#define TCPC_CONFIG_RAA489000(id) \
- { \
- .bus_type = EC_BUS_TYPE_I2C, \
- .i2c_info = { \
- .port = I2C_PORT_BY_DEV(id), \
- .addr_flags = DT_REG_ADDR(id), \
- }, \
- .drv = &raa489000_tcpm_drv, \
- .flags = DT_PROP(id, tcpc_flags), \
- },
diff --git a/zephyr/shim/include/usbc/tcpc_rt1718s.h b/zephyr/shim/include/usbc/tcpc_rt1718s.h
index 861b474ecf..794fb99480 100644
--- a/zephyr/shim/include/usbc/tcpc_rt1718s.h
+++ b/zephyr/shim/include/usbc/tcpc_rt1718s.h
@@ -3,9 +3,8 @@
* found in the LICENSE file.
*/
-#include "tcpm/rt1718s_public.h"
-
#include <zephyr/devicetree.h>
+#include "tcpm/rt1718s_public.h"
#define RT1718S_TCPC_COMPAT richtek_rt1718s_tcpc
diff --git a/zephyr/shim/include/usbc/tcpci.h b/zephyr/shim/include/usbc/tcpci.h
index 15cea4b332..67138dbe99 100644
--- a/zephyr/shim/include/usbc/tcpci.h
+++ b/zephyr/shim/include/usbc/tcpci.h
@@ -3,10 +3,10 @@
* found in the LICENSE file.
*/
-#include "driver/tcpm/tcpci.h"
-
#include <zephyr/devicetree.h>
+#include "driver/tcpm/tcpci.h"
+
#define TCPCI_COMPAT cros_ec_tcpci
#define TCPC_CONFIG_TCPCI(id) \
diff --git a/zephyr/shim/include/usbc/usb_muxes.h b/zephyr/shim/include/usbc/usb_muxes.h
index 6ee9c691a8..f94aed488d 100644
--- a/zephyr/shim/include/usbc/usb_muxes.h
+++ b/zephyr/shim/include/usbc/usb_muxes.h
@@ -6,6 +6,8 @@
#ifndef ZEPHYR_CHROME_USBC_USB_MUXES_H
#define ZEPHYR_CHROME_USBC_USB_MUXES_H
+#include <zephyr/devicetree.h>
+#include <zephyr/sys/util_macro.h>
#include "usb_mux.h"
#include "usbc/amd_fp6_usb_mux.h"
#include "usbc/anx7447_usb_mux.h"
@@ -19,9 +21,6 @@
#include "usbc/utils.h"
#include "usbc/virtual_usb_mux.h"
-#include <zephyr/devicetree.h>
-#include <zephyr/sys/util_macro.h>
-
/**
* @brief List of USB mux drivers compatibles and their configurations. Each
* element of list has to have (compatible, config) format.
@@ -178,14 +177,14 @@
* @brief Set struct usb_mux fields common for all USB muxes and alter flags
*
* @param mux_id USB mux node ID
- * @param flags_mask Mask for bits that should be ignored in flags property
+ * @param flags_mask Mask for bits that should be igonred in flags property
* @param flags_val Value that should be used instead for masked bits
*/
#define USB_MUX_COMMON_FIELDS_WITH_FLAGS(mux_id, flags_mask, flags_val) \
.usb_port = USB_MUX_PORT(mux_id), \
.board_init = USB_MUX_CALLBACK_OR_NULL(mux_id, board_init), \
.board_set = USB_MUX_CALLBACK_OR_NULL(mux_id, board_set), \
- .flags = (DT_PROP_OR(mux_id, flags, 0) & ~(flags_mask)) | (flags_val)
+ .flags = (DT_PROP(mux_id, flags) & ~(flags_mask)) | (flags_val)
/**
* @brief Set struct usb_mux fields common for all USB muxes
diff --git a/zephyr/shim/include/zephyr_hooks_shim.h b/zephyr/shim/include/zephyr_hooks_shim.h
index f1c25c6e8f..f3949787bd 100644
--- a/zephyr/shim/include/zephyr_hooks_shim.h
+++ b/zephyr/shim/include/zephyr_hooks_shim.h
@@ -8,12 +8,12 @@
#endif
#define __CROS_EC_ZEPHYR_HOOKS_SHIM_H
-#include "common.h"
-#include "cros_version.h"
-
#include <zephyr/init.h>
#include <zephyr/kernel.h>
+#include "common.h"
+#include "cros_version.h"
+
/**
* The internal data structure stored for a deferred function.
*/
diff --git a/zephyr/shim/include/zephyr_host_command.h b/zephyr/shim/include/zephyr_host_command.h
index 9271c6c368..e2f0a7c296 100644
--- a/zephyr/shim/include/zephyr_host_command.h
+++ b/zephyr/shim/include/zephyr_host_command.h
@@ -10,9 +10,8 @@
#endif
#define __CROS_EC_ZEPHYR_HOST_COMMAND_H
-#include <stdbool.h>
-
#include <zephyr/init.h>
+#include <stdbool.h>
/* Initializes and runs the host command handler loop. */
void host_command_task(void *u);
diff --git a/zephyr/shim/include/zephyr_shim.h b/zephyr/shim/include/zephyr_shim.h
index dce1706c5b..3e12568155 100644
--- a/zephyr/shim/include/zephyr_shim.h
+++ b/zephyr/shim/include/zephyr_shim.h
@@ -6,9 +6,8 @@
#ifndef __BOARD_H
#define __BOARD_H
-#include "common.h"
-
#include <zephyr/devicetree.h>
+#include "common.h"
/* Included shimed version of gpio signal. */
#include "gpio_signal.h"
diff --git a/zephyr/shim/include/zephyr_write_protect.h b/zephyr/shim/include/zephyr_write_protect.h
index 59a305a0f9..227af16bd0 100644
--- a/zephyr/shim/include/zephyr_write_protect.h
+++ b/zephyr/shim/include/zephyr_write_protect.h
@@ -8,7 +8,6 @@
#include "gpio/gpio_int.h"
#include "gpio_signal.h"
-
#include <zephyr/drivers/gpio.h>
/**
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