summaryrefslogtreecommitdiff
path: root/zephyr/shim/include
diff options
context:
space:
mode:
Diffstat (limited to 'zephyr/shim/include')
-rw-r--r--zephyr/shim/include/adc_chip.h2
-rw-r--r--zephyr/shim/include/atomic.h4
-rw-r--r--zephyr/shim/include/battery_enum.h8
-rw-r--r--zephyr/shim/include/board.h9
-rw-r--r--zephyr/shim/include/board_led.h12
-rw-r--r--zephyr/shim/include/builtin/assert.h2
-rw-r--r--zephyr/shim/include/charger/chg_bq25710.h12
-rw-r--r--zephyr/shim/include/charger/chg_isl923x.h13
-rw-r--r--zephyr/shim/include/charger/chg_isl9241.h12
-rw-r--r--zephyr/shim/include/charger/chg_rt9490.h13
-rw-r--r--zephyr/shim/include/charger/chg_sm5803.h12
-rw-r--r--zephyr/shim/include/charger_chips.h32
-rw-r--r--zephyr/shim/include/charger_enum.h2
-rw-r--r--zephyr/shim/include/config_chip.h336
-rw-r--r--zephyr/shim/include/cpu.h2
-rw-r--r--zephyr/shim/include/cros_cbi.h27
-rw-r--r--zephyr/shim/include/ec_tasks.h2
-rw-r--r--zephyr/shim/include/fpu.h18
-rw-r--r--zephyr/shim/include/gpio/gpio.h6
-rw-r--r--zephyr/shim/include/gpio/gpio_int.h25
-rw-r--r--zephyr/shim/include/hook_types.h4
-rw-r--r--zephyr/shim/include/i2c/i2c.h184
-rw-r--r--zephyr/shim/include/linker.h4
-rw-r--r--zephyr/shim/include/motionsense_sensors.h20
-rw-r--r--zephyr/shim/include/motionsense_sensors_defs.h21
-rw-r--r--zephyr/shim/include/mpu.h2
-rw-r--r--zephyr/shim/include/power/power.h84
-rw-r--r--zephyr/shim/include/power_host_sleep.h47
-rw-r--r--zephyr/shim/include/registers.h2
-rw-r--r--zephyr/shim/include/shimmed_task_id.h230
-rw-r--r--zephyr/shim/include/shimmed_tasks.h2
-rw-r--r--zephyr/shim/include/temp_sensor/temp_sensor.h143
-rw-r--r--zephyr/shim/include/usbc/amd_fp6_usb_mux.h21
-rw-r--r--zephyr/shim/include/usbc/anx7447_usb_mux.h22
-rw-r--r--zephyr/shim/include/usbc/anx7483_usb_mux.h17
-rw-r--r--zephyr/shim/include/usbc/bb_retimer_usb_mux.h109
-rw-r--r--zephyr/shim/include/usbc/bc12_pi3usb9201.h7
-rw-r--r--zephyr/shim/include/usbc/bc12_rt1718s.h13
-rw-r--r--zephyr/shim/include/usbc/bc12_rt1739.h9
-rw-r--r--zephyr/shim/include/usbc/bc12_rt9490.h7
-rw-r--r--zephyr/shim/include/usbc/it5205_usb_mux.h17
-rw-r--r--zephyr/shim/include/usbc/ppc.h41
-rw-r--r--zephyr/shim/include/usbc/ppc_aoz1380.h11
-rw-r--r--zephyr/shim/include/usbc/ppc_nx20p348x.h13
-rw-r--r--zephyr/shim/include/usbc/ppc_rt1739.h20
-rw-r--r--zephyr/shim/include/usbc/ppc_sn5s330.h12
-rw-r--r--zephyr/shim/include/usbc/ppc_syv682x.h18
-rw-r--r--zephyr/shim/include/usbc/ps8743_usb_mux.h21
-rw-r--r--zephyr/shim/include/usbc/ps8818_usb_mux.h21
-rw-r--r--zephyr/shim/include/usbc/tcpc_anx7447.h20
-rw-r--r--zephyr/shim/include/usbc/tcpc_ccgxxf.h21
-rw-r--r--zephyr/shim/include/usbc/tcpc_fusb302.h19
-rw-r--r--zephyr/shim/include/usbc/tcpc_generic_emul.h20
-rw-r--r--zephyr/shim/include/usbc/tcpc_it8xxx2.h14
-rw-r--r--zephyr/shim/include/usbc/tcpc_nct38xx.h21
-rw-r--r--zephyr/shim/include/usbc/tcpc_ps8xxx.h21
-rw-r--r--zephyr/shim/include/usbc/tcpc_ps8xxx_emul.h19
-rw-r--r--zephyr/shim/include/usbc/tcpc_rt1718s.h20
-rw-r--r--zephyr/shim/include/usbc/tcpci.h18
-rw-r--r--zephyr/shim/include/usbc/tcpci_usb_mux.h49
-rw-r--r--zephyr/shim/include/usbc/tusb1064_usb_mux.h45
-rw-r--r--zephyr/shim/include/usbc/usb_muxes.h474
-rw-r--r--zephyr/shim/include/usbc/utils.h21
-rw-r--r--zephyr/shim/include/usbc/virtual_usb_mux.h14
-rw-r--r--zephyr/shim/include/zephyr_adc.h16
-rw-r--r--zephyr/shim/include/zephyr_console_shim.h19
-rw-r--r--zephyr/shim/include/zephyr_espi_shim.h2
-rw-r--r--zephyr/shim/include/zephyr_gpio_signal.h56
-rw-r--r--zephyr/shim/include/zephyr_hooks_shim.h5
-rw-r--r--zephyr/shim/include/zephyr_host_command.h25
-rw-r--r--zephyr/shim/include/zephyr_mkbp_event.h17
-rw-r--r--zephyr/shim/include/zephyr_write_protect.h2
72 files changed, 1653 insertions, 956 deletions
diff --git a/zephyr/shim/include/adc_chip.h b/zephyr/shim/include/adc_chip.h
index c51cdfbb30..f5580a52ab 100644
--- a/zephyr/shim/include/adc_chip.h
+++ b/zephyr/shim/include/adc_chip.h
@@ -1,4 +1,4 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
+/* Copyright 2021 The ChromiumOS Authors
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
diff --git a/zephyr/shim/include/atomic.h b/zephyr/shim/include/atomic.h
index 6b44bf02a5..beb8b111ed 100644
--- a/zephyr/shim/include/atomic.h
+++ b/zephyr/shim/include/atomic.h
@@ -1,4 +1,4 @@
-/* Copyright 2020 The Chromium OS Authors. All rights reserved.
+/* Copyright 2020 The ChromiumOS Authors
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
@@ -13,4 +13,4 @@ static inline atomic_val_t atomic_clear_bits(atomic_t *addr, atomic_val_t bits)
return atomic_and(addr, ~bits);
}
-#endif /* __CROS_EC_ATOMIC_H */
+#endif /* __CROS_EC_ATOMIC_H */
diff --git a/zephyr/shim/include/battery_enum.h b/zephyr/shim/include/battery_enum.h
index 7497edea0b..c0d10a6ed5 100644
--- a/zephyr/shim/include/battery_enum.h
+++ b/zephyr/shim/include/battery_enum.h
@@ -1,4 +1,4 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
+/* Copyright 2021 The ChromiumOS Authors
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
@@ -8,16 +8,16 @@
"included in all zephyr builds automatically"
#endif
-#define BATTERY_ENUM(val) DT_CAT(BATTERY_, val)
+#define BATTERY_ENUM(val) DT_CAT(BATTERY_, val)
#define BATTERY_TYPE(id) BATTERY_ENUM(DT_STRING_UPPER_TOKEN(id, enum_name))
-#define BATTERY_TYPE_WITH_COMMA(id) BATTERY_TYPE(id),
+#define BATTERY_TYPE_WITH_COMMA(id) BATTERY_TYPE(id),
/* This produces a list of BATTERY_<ENUM_NAME> identifiers */
enum battery_type {
#if DT_HAS_COMPAT_STATUS_OKAY(battery_smart)
DT_FOREACH_STATUS_OKAY(battery_smart, BATTERY_TYPE_WITH_COMMA)
#endif
- BATTERY_TYPE_COUNT,
+ BATTERY_TYPE_COUNT,
};
#undef BATTERY_TYPE_WITH_COMMA
diff --git a/zephyr/shim/include/board.h b/zephyr/shim/include/board.h
index 1c8da8b209..3e12568155 100644
--- a/zephyr/shim/include/board.h
+++ b/zephyr/shim/include/board.h
@@ -1,4 +1,4 @@
-/* Copyright 2020 The Chromium OS Authors. All rights reserved.
+/* Copyright 2020 The ChromiumOS Authors
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
@@ -15,11 +15,6 @@
/* Include shimmed version of power signal */
#include "power/power.h"
-/* Include board specific gpio mapping/aliases if named_pgios node exists */
-#if !defined(TEST_BUILD) && DT_NODE_EXISTS(DT_PATH(named_gpios))
-#include "gpio_map.h"
-#endif
-
/* Include board specific i2c mapping if I2C is enabled. */
#if defined(CONFIG_I2C)
#include "i2c/i2c.h"
@@ -37,4 +32,4 @@
#include "charger_enum.h"
#endif
-#endif /* __BOARD_H */
+#endif /* __BOARD_H */
diff --git a/zephyr/shim/include/board_led.h b/zephyr/shim/include/board_led.h
index 205c96c4c3..074ffa0256 100644
--- a/zephyr/shim/include/board_led.h
+++ b/zephyr/shim/include/board_led.h
@@ -1,4 +1,4 @@
-/* Copyright 2022 The Chromium OS Authors. All rights reserved.
+/* 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.
*/
@@ -12,13 +12,13 @@ struct board_led_pwm_dt_channel {
pwm_flags_t flags;
};
-#define BOARD_LED_PWM_DT_CHANNEL_INITIALIZER(node_id) \
- { \
+#define BOARD_LED_PWM_DT_CHANNEL_INITIALIZER(node_id) \
+ { \
.dev = DEVICE_DT_GET(DT_PWMS_CTLR(node_id)), \
- .channel = DT_PWMS_CHANNEL(node_id), \
- .flags = DT_PWMS_FLAGS(node_id), \
+ .channel = DT_PWMS_CHANNEL(node_id), \
+ .flags = DT_PWMS_FLAGS(node_id), \
}
#define BOARD_LED_HZ_TO_PERIOD_NS(freq_hz) (NSEC_PER_SEC / freq_hz)
-#endif /* __BOARD_LED_H */
+#endif /* __BOARD_LED_H */
diff --git a/zephyr/shim/include/builtin/assert.h b/zephyr/shim/include/builtin/assert.h
index c3c43f2ba1..27dce8f2c4 100644
--- a/zephyr/shim/include/builtin/assert.h
+++ b/zephyr/shim/include/builtin/assert.h
@@ -1,4 +1,4 @@
-/* Copyright 2020 The Chromium OS Authors. All rights reserved.
+/* Copyright 2020 The ChromiumOS Authors
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
diff --git a/zephyr/shim/include/charger/chg_bq25710.h b/zephyr/shim/include/charger/chg_bq25710.h
index 6458545946..91d100a7de 100644
--- a/zephyr/shim/include/charger/chg_bq25710.h
+++ b/zephyr/shim/include/charger/chg_bq25710.h
@@ -1,4 +1,4 @@
-/* Copyright 2022 The Chromium OS Authors. All rights reserved.
+/* 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.
*/
@@ -10,10 +10,10 @@
#define BQ25710_CHG_COMPAT ti_bq25710
-#define CHG_CONFIG_BQ25710(id) \
- { \
- .i2c_port = I2C_PORT(DT_PHANDLE(id, port)), \
- .i2c_addr_flags = BQ25710_SMBUS_ADDR1_FLAGS, \
- .drv = &bq25710_drv, \
+#define CHG_CONFIG_BQ25710(id) \
+ { \
+ .i2c_port = I2C_PORT_BY_DEV(id), \
+ .i2c_addr_flags = DT_REG_ADDR(id), \
+ .drv = &bq25710_drv, \
},
#endif
diff --git a/zephyr/shim/include/charger/chg_isl923x.h b/zephyr/shim/include/charger/chg_isl923x.h
index fea25e7391..b0323cd1b8 100644
--- a/zephyr/shim/include/charger/chg_isl923x.h
+++ b/zephyr/shim/include/charger/chg_isl923x.h
@@ -1,4 +1,4 @@
-/* Copyright 2022 The Chromium OS Authors. All rights reserved.
+/* 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.
*/
@@ -7,10 +7,11 @@
#include "driver/charger/isl923x_public.h"
#define ISL923X_CHG_COMPAT intersil_isl923x
+#define ISL923X_EMUL_COMPAT cros_isl923x_emul
-#define CHG_CONFIG_ISL923X(id) \
- { \
- .i2c_port = I2C_PORT(DT_PHANDLE(id, port)), \
- .i2c_addr_flags = ISL923X_ADDR_FLAGS, \
- .drv = &isl923x_drv, \
+#define CHG_CONFIG_ISL923X(id) \
+ { \
+ .i2c_port = I2C_PORT_BY_DEV(id), \
+ .i2c_addr_flags = DT_REG_ADDR(id), \
+ .drv = &isl923x_drv, \
},
diff --git a/zephyr/shim/include/charger/chg_isl9241.h b/zephyr/shim/include/charger/chg_isl9241.h
index 8e19e2643e..711a581c2f 100644
--- a/zephyr/shim/include/charger/chg_isl9241.h
+++ b/zephyr/shim/include/charger/chg_isl9241.h
@@ -1,4 +1,4 @@
-/* Copyright 2022 The Chromium OS Authors. All rights reserved.
+/* 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.
*/
@@ -8,9 +8,9 @@
#define ISL9241_CHG_COMPAT intersil_isl9241
-#define CHG_CONFIG_ISL9241(id) \
- { \
- .i2c_port = I2C_PORT(DT_PHANDLE(id, port)), \
- .i2c_addr_flags = ISL9241_ADDR_FLAGS, \
- .drv = &isl9241_drv, \
+#define CHG_CONFIG_ISL9241(id) \
+ { \
+ .i2c_port = I2C_PORT_BY_DEV(id), \
+ .i2c_addr_flags = DT_REG_ADDR(id), \
+ .drv = &isl9241_drv, \
},
diff --git a/zephyr/shim/include/charger/chg_rt9490.h b/zephyr/shim/include/charger/chg_rt9490.h
index 03059078e9..3ac596d482 100644
--- a/zephyr/shim/include/charger/chg_rt9490.h
+++ b/zephyr/shim/include/charger/chg_rt9490.h
@@ -1,4 +1,4 @@
-/* Copyright 2022 The Chromium OS Authors. All rights reserved.
+/* 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.
*/
@@ -7,10 +7,11 @@
#include "driver/charger/rt9490.h"
#define RT9490_CHG_COMPAT richtek_rt9490
+#define RT9490_EMUL_COMPAT zephyr_rt9490_emul
-#define CHG_CONFIG_RT9490(id) \
- { \
- .i2c_port = I2C_PORT(DT_PHANDLE(id, port)), \
- .i2c_addr_flags = RT9490_ADDR_FLAGS, \
- .drv = &rt9490_drv, \
+#define CHG_CONFIG_RT9490(id) \
+ { \
+ .i2c_port = I2C_PORT_BY_DEV(id), \
+ .i2c_addr_flags = DT_REG_ADDR(id), \
+ .drv = &rt9490_drv, \
},
diff --git a/zephyr/shim/include/charger/chg_sm5803.h b/zephyr/shim/include/charger/chg_sm5803.h
index 7e18a5554b..65ef066970 100644
--- a/zephyr/shim/include/charger/chg_sm5803.h
+++ b/zephyr/shim/include/charger/chg_sm5803.h
@@ -1,4 +1,4 @@
-/* Copyright 2022 The Chromium OS Authors. All rights reserved.
+/* 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.
*/
@@ -8,9 +8,9 @@
#define SM5803_CHG_COMPAT siliconmitus_sm5803
-#define CHG_CONFIG_SM5803(id) \
- { \
- .i2c_port = I2C_PORT(DT_PHANDLE(id, port)), \
- .i2c_addr_flags = SM5803_ADDR_CHARGER_FLAGS, \
- .drv = &sm5803_drv, \
+#define CHG_CONFIG_SM5803(id) \
+ { \
+ .i2c_port = I2C_PORT_BY_DEV(id), \
+ .i2c_addr_flags = DT_REG_ADDR(id), \
+ .drv = &sm5803_drv, \
},
diff --git a/zephyr/shim/include/charger_chips.h b/zephyr/shim/include/charger_chips.h
new file mode 100644
index 0000000000..b24fa246bf
--- /dev/null
+++ b/zephyr/shim/include/charger_chips.h
@@ -0,0 +1,32 @@
+/* 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.
+ */
+
+#ifndef __CROS_EC_CHARGER_CHIPS_H
+#define __CROS_EC_CHARGER_CHIPS_H
+
+#include "charger.h"
+#include <zephyr/devicetree.h>
+
+extern const struct charger_config_t chg_chips_alt[];
+
+#define ALT_CHG_CHIP_CHK(usbc_id, usb_port_num) \
+ COND_CODE_1(DT_REG_HAS_IDX(usbc_id, usb_port_num), \
+ (COND_CODE_1(DT_NODE_HAS_PROP(usbc_id, chg_alt), (|| 1), \
+ (|| 0))), \
+ (|| 0))
+
+#define CHG_ENABLE_ALTERNATE(usb_port_num) \
+ do { \
+ BUILD_ASSERT( \
+ (0 DT_FOREACH_STATUS_OKAY_VARGS(named_usbc_port, \
+ ALT_CHG_CHIP_CHK, \
+ usb_port_num)), \
+ "Selected USB node does not exist or does not specify" \
+ "a charger alternate chip"); \
+ memcpy(&chg_chips[usb_port_num], &chg_chips_alt[usb_port_num], \
+ sizeof(struct charger_config_t)); \
+ } while (0)
+
+#endif /* __CROS_EC_CHARGER_CHIPS_H */
diff --git a/zephyr/shim/include/charger_enum.h b/zephyr/shim/include/charger_enum.h
index a2acc3e000..a10a274e28 100644
--- a/zephyr/shim/include/charger_enum.h
+++ b/zephyr/shim/include/charger_enum.h
@@ -1,4 +1,4 @@
-/* Copyright 2022 The Chromium OS Authors. All rights reserved.
+/* 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.
*/
diff --git a/zephyr/shim/include/config_chip.h b/zephyr/shim/include/config_chip.h
index 73f38a72f4..75c27dd32d 100644
--- a/zephyr/shim/include/config_chip.h
+++ b/zephyr/shim/include/config_chip.h
@@ -1,4 +1,4 @@
-/* Copyright 2020 The Chromium OS Authors. All rights reserved.
+/* Copyright 2020 The ChromiumOS Authors
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
@@ -9,9 +9,9 @@
#include <zephyr/devicetree.h>
#include <autoconf.h>
-#define SENSOR_NODE DT_PATH(motionsense_sensor)
-#define SENSOR_INFO_NODE DT_PATH(motionsense_sensor_info)
-#define SENSOR_ALT_NODE DT_PATH(motionsense_sensor_alt)
+#define SENSOR_NODE DT_PATH(motionsense_sensor)
+#define SENSOR_INFO_NODE DT_PATH(motionsense_sensor_info)
+#define SENSOR_ALT_NODE DT_PATH(motionsense_sensor_alt)
/*
* The battery enum is used in various drivers and these assume that it is
@@ -66,14 +66,16 @@
#undef CONFIG_CONSOLE_UART /* Only used by the Chromium EC chip drivers */
#undef CONFIG_I2C_MULTI_PORT_CONTROLLER /* Not required by I2C shim */
#undef CONFIG_IRQ_COUNT /* Only used by Chromium EC core drivers */
-#undef CONFIG_KEYBOARD_KSO_HIGH_DRIVE /* Used by the Chromium EC chip drivers */
+#undef CONFIG_KEYBOARD_KSO_HIGH_DRIVE /* Used by the Chromium EC chip drivers \
+ */
#undef CONFIG_LTO /* Link time optimization enabled by Zephyr build system */
#undef CONFIG_STACK_SIZE /* Only used in Chromium EC core init code */
#ifndef CONFIG_FPU
#undef CONFIG_FPU /* Used in Zephyr as well, enabled in Kconfig directly */
#endif
#ifndef CONFIG_WATCHDOG
-#undef CONFIG_WATCHDOG /* Used in Zephyr as well, enabled in Kconfig directly */
+#undef CONFIG_WATCHDOG /* Used in Zephyr as well, enabled in Kconfig directly \
+ */
#endif
/*
@@ -103,8 +105,8 @@
#endif
/* EC chipset configuration */
-#define HOOK_TICK_INTERVAL CONFIG_CROS_EC_HOOK_TICK_INTERVAL
-#define HOOK_TICK_INTERVAL_MS (HOOK_TICK_INTERVAL / 1000)
+#define HOOK_TICK_INTERVAL CONFIG_CROS_EC_HOOK_TICK_INTERVAL
+#define HOOK_TICK_INTERVAL_MS (HOOK_TICK_INTERVAL / 1000)
/* Chipset and power configuration */
#ifdef CONFIG_AP_ARM_QUALCOMM_SC7180
@@ -242,7 +244,7 @@
#undef CONFIG_BATTERY_PRESENT_GPIO
#ifdef CONFIG_PLATFORM_EC_BATTERY_PRESENT_GPIO
/* This is always GPIO_BATT_PRES_ODL with Zephyr */
-#define CONFIG_BATTERY_PRESENT_GPIO GPIO_BATT_PRES_ODL
+#define CONFIG_BATTERY_PRESENT_GPIO GPIO_BATT_PRES_ODL
#endif
#undef CONFIG_BATTERY_CRITICAL_SHUTDOWN_CUT_OFF
@@ -283,9 +285,9 @@
#undef CONFIG_BATT_FULL_CHIPSET_OFF_INPUT_LIMIT_MV
#if defined(CONFIG_PLATFORM_EC_BATT_FULL_CHIPSET_OFF_INPUT_LIMIT_MV) && \
- (CONFIG_PLATFORM_EC_BATT_FULL_CHIPSET_OFF_INPUT_LIMIT_MV > 0)
+ (CONFIG_PLATFORM_EC_BATT_FULL_CHIPSET_OFF_INPUT_LIMIT_MV > 0)
#define CONFIG_BATT_FULL_CHIPSET_OFF_INPUT_LIMIT_MV \
- CONFIG_PLATFORM_EC_BATT_FULL_CHIPSET_OFF_INPUT_LIMIT_MV
+ CONFIG_PLATFORM_EC_BATT_FULL_CHIPSET_OFF_INPUT_LIMIT_MV
#endif
#undef CONFIG_BOARD_RESET_AFTER_POWER_ON
@@ -428,29 +430,30 @@
#endif
/* eSPI signals */
-#undef CONFIG_HOSTCMD_ESPI_VW_SLP_S3
-#ifdef CONFIG_PLATFORM_EC_ESPI_VW_SLP_S3
-#define CONFIG_HOSTCMD_ESPI_VW_SLP_S3
+#undef CONFIG_HOST_INTERFACE_ESPI_VW_SLP_S3
+#ifdef CONFIG_PLATFORM_EC_HOST_INTERFACE_ESPI_VW_SLP_S3
+#define CONFIG_HOST_INTERFACE_ESPI_VW_SLP_S3
#endif
-#undef CONFIG_HOSTCMD_ESPI_VW_SLP_S4
-#ifdef CONFIG_PLATFORM_EC_ESPI_VW_SLP_S4
-#define CONFIG_HOSTCMD_ESPI_VW_SLP_S4
+#undef CONFIG_HOST_INTERFACE_ESPI_VW_SLP_S4
+#ifdef CONFIG_PLATFORM_EC_HOST_INTERFACE_ESPI_VW_SLP_S4
+#define CONFIG_HOST_INTERFACE_ESPI_VW_SLP_S4
#endif
-#undef CONFIG_HOSTCMD_ESPI_VW_SLP_S5
-#ifdef CONFIG_PLATFORM_EC_ESPI_VW_SLP_S5
-#define CONFIG_HOSTCMD_ESPI_VW_SLP_S5
+#undef CONFIG_HOST_INTERFACE_ESPI_VW_SLP_S5
+#ifdef CONFIG_PLATFORM_EC_HOST_INTERFACE_ESPI_VW_SLP_S5
+#define CONFIG_HOST_INTERFACE_ESPI_VW_SLP_S5
#endif
-#undef CONFIG_HOSTCMD_ESPI_RESET_SLP_SX_VW_ON_ESPI_RST
-#ifdef CONFIG_PLATFORM_EC_ESPI_RESET_SLP_SX_VW_ON_ESPI_RST
-#define CONFIG_HOSTCMD_ESPI_RESET_SLP_SX_VW_ON_ESPI_RST
+#undef CONFIG_HOST_INTERFACE_ESPI_RESET_SLP_SX_VW_ON_ESPI_RST
+#ifdef CONFIG_PLATFORM_EC_HOST_INTERFACE_ESPI_RESET_SLP_SX_VW_ON_ESPI_RST
+#define CONFIG_HOST_INTERFACE_ESPI_RESET_SLP_SX_VW_ON_ESPI_RST
#endif
-#undef CONFIG_ESPI_DEFAULT_VW_WIDTH_US
+#undef CONFIG_HOST_INTERFACE_ESPI_DEFAULT_VW_WIDTH_US
#ifdef CONFIG_PLATFORM_EC_DEFAULT_SCI_WIDTH_US
-#define CONFIG_ESPI_DEFAULT_VW_WIDTH_US CONFIG_PLATFORM_EC_DEFAULT_SCI_WIDTH_US
+#define CONFIG_HOST_INTERFACE_ESPI_DEFAULT_VW_WIDTH_US \
+ CONFIG_PLATFORM_EC_DEFAULT_SCI_WIDTH_US
#endif
#if DT_HAS_CHOSEN(zephyr_flash)
@@ -466,10 +469,11 @@
/* 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 struct jump_data mock_jump_data;
+#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) + sizeof(struct jump_data))
+ (((uintptr_t)&mock_jump_data) + sizeof(mock_jump_data))
#else
#error "A zephyr,sram device must be chosen in the device tree"
#endif
@@ -479,16 +483,16 @@ extern struct jump_data mock_jump_data;
#define CONFIG_RW_MEM_OFF CONFIG_CROS_EC_RW_MEM_OFF
#define CONFIG_RW_MEM_SIZE CONFIG_CROS_EC_RW_MEM_SIZE
-#define CONFIG_WP_STORAGE_OFF CONFIG_EC_PROTECTED_STORAGE_OFF
-#define CONFIG_WP_STORAGE_SIZE CONFIG_EC_PROTECTED_STORAGE_SIZE
-#define CONFIG_RO_SIZE CONFIG_CROS_EC_RO_SIZE
-#define CONFIG_RW_SIZE CONFIG_CROS_EC_RW_SIZE
+#define CONFIG_WP_STORAGE_OFF CONFIG_EC_PROTECTED_STORAGE_OFF
+#define CONFIG_WP_STORAGE_SIZE CONFIG_EC_PROTECTED_STORAGE_SIZE
+#define CONFIG_RO_SIZE CONFIG_CROS_EC_RO_SIZE
+#define CONFIG_RW_SIZE CONFIG_CROS_EC_RW_SIZE
/*
* ROM resident area in flash used to store data objects that are not copied
* into code RAM. Enable using the CONFIG_CHIP_INIT_ROM_REGION option.
*/
-#define CONFIG_RO_ROM_RESIDENT_MEM_OFF CONFIG_RO_SIZE
+#define CONFIG_RO_ROM_RESIDENT_MEM_OFF CONFIG_RO_SIZE
#define CONFIG_RO_ROM_RESIDENT_SIZE \
(CONFIG_EC_PROTECTED_STORAGE_SIZE - CONFIG_RO_SIZE)
@@ -496,7 +500,7 @@ extern struct jump_data mock_jump_data;
* RW firmware in program memory - Identical to RO, only one image loaded at
* a time.
*/
-#define CONFIG_RW_ROM_RESIDENT_MEM_OFF CONFIG_RW_SIZE
+#define CONFIG_RW_ROM_RESIDENT_MEM_OFF CONFIG_RW_SIZE
#define CONFIG_RW_ROM_RESIDENT_SIZE \
(CONFIG_EC_WRITABLE_STORAGE_SIZE - CONFIG_RW_SIZE)
@@ -560,22 +564,9 @@ extern struct jump_data mock_jump_data;
#undef CONFIG_FLASH_SIZE_BYTES
#ifdef CONFIG_PLATFORM_EC_FLASH_SIZE_BYTES
-/*
- * Flash size of IT81202 is 1MB.
- * We use only 3/4 space of flash to save time of erasing RW image from flash.
- */
-#ifdef CONFIG_SOC_IT8XXX2
-#define CONFIG_FLASH_SIZE_BYTES (CONFIG_PLATFORM_EC_FLASH_SIZE_BYTES * 3 / 4)
-#else
#define CONFIG_FLASH_SIZE_BYTES CONFIG_PLATFORM_EC_FLASH_SIZE_BYTES
-#endif
#endif /* CONFIG_PLATFORM_EC_FLASH_SIZE_BYTES */
-#undef CONFIG_ADC
-#ifdef CONFIG_PLATFORM_EC_ADC
-#define CONFIG_ADC
-#endif
-
#undef CONFIG_ADC_CHANNELS_RUNTIME_CONFIG
#ifdef CONFIG_PLATFORM_EC_ADC_CHANNELS_RUNTIME_CONFIG
#define CONFIG_ADC_CHANNELS_RUNTIME_CONFIG
@@ -621,6 +612,11 @@ extern struct jump_data mock_jump_data;
#define CONFIG_FANS CONFIG_PLATFORM_EC_NUM_FANS
#endif
+#undef CONFIG_FAN_BYPASS_SLOW_RESPONSE
+#ifdef PLATFORM_EC_FAN_BYPASS_SLOW_RESPONSE
+#define CONFIG_FAN_BYPASS_SLOW_RESPONSE
+#endif
+
#ifdef CONFIG_PLATFORM_EC_I2C
/* Also see shim/include/i2c/i2c.h which defines the ports enum */
#define CONFIG_I2C_CONTROLLER
@@ -659,7 +655,7 @@ extern struct jump_data mock_jump_data;
#undef CONFIG_KEYBOARD_DISCRETE
#ifdef CONFIG_PLATFORM_EC_KEYBOARD_DISCRETE
#define CONFIG_KEYBOARD_DISCRETE
-#define KB_DISCRETE_I2C_ADDR_FLAGS DT_REG_ADDR(DT_NODELABEL(kb_discrete))
+#define KB_DISCRETE_I2C_ADDR_FLAGS DT_REG_ADDR(DT_NODELABEL(kb_discrete))
#endif
#undef CONFIG_MKBP_INPUT_DEVICES
@@ -669,16 +665,16 @@ extern struct jump_data mock_jump_data;
#undef CONFIG_MKBP_EVENT_WAKEUP_MASK
#if defined(CONFIG_PLATFORM_EC_MKBP_EVENT_WAKEUP_MASK) && \
- DT_NODE_EXISTS(DT_PATH(ec_mkbp_event_wakeup_mask))
+ DT_NODE_EXISTS(DT_PATH(ec_mkbp_event_wakeup_mask))
#define CONFIG_MKBP_EVENT_WAKEUP_MASK \
- DT_PROP(DT_PATH(ec_mkbp_event_wakeup_mask), wakeup_mask)
+ DT_PROP(DT_PATH(ec_mkbp_event_wakeup_mask), wakeup_mask)
#endif
#undef CONFIG_MKBP_HOST_EVENT_WAKEUP_MASK
#if defined(CONFIG_PLATFORM_EC_MKBP_HOST_EVENT_WAKEUP_MASK) && \
- DT_NODE_EXISTS(DT_PATH(ec_mkbp_host_event_wakeup_mask))
+ DT_NODE_EXISTS(DT_PATH(ec_mkbp_host_event_wakeup_mask))
#define CONFIG_MKBP_HOST_EVENT_WAKEUP_MASK \
- DT_PROP(DT_PATH(ec_mkbp_host_event_wakeup_mask), wakeup_mask)
+ DT_PROP(DT_PATH(ec_mkbp_host_event_wakeup_mask), wakeup_mask)
#endif
#undef CONFIG_CMD_KEYBOARD
@@ -689,12 +685,12 @@ extern struct jump_data mock_jump_data;
#undef CONFIG_KEYBOARD_COL2_INVERTED
#ifdef CONFIG_PLATFORM_EC_KEYBOARD_COL2_INVERTED
#define CONFIG_KEYBOARD_COL2_INVERTED
-#endif /* CONFIG_PLATFORM_EC_KEYBOARD_COL2_INVERTED */
+#endif /* CONFIG_PLATFORM_EC_KEYBOARD_COL2_INVERTED */
#undef CONFIG_KEYBOARD_REFRESH_ROW3
#ifdef CONFIG_PLATFORM_EC_KEYBOARD_REFRESH_ROW3
#define CONFIG_KEYBOARD_REFRESH_ROW3
-#endif /* CONFIG_PLATFORM_EC_KEYBOARD_REFRESH_ROW3 */
+#endif /* CONFIG_PLATFORM_EC_KEYBOARD_REFRESH_ROW3 */
#undef CONFIG_KEYBOARD_KEYPAD
#ifdef CONFIG_PLATFORM_EC_KEYBOARD_KEYPAD
@@ -743,6 +739,11 @@ extern struct jump_data mock_jump_data;
#define CONFIG_KBLIGHT_ENABLE_PIN
#endif
+#undef CONFIG_KEYBOARD_STRICT_DEBOUNCE
+#ifdef CONFIG_PLATFORM_EC_KEYBOARD_STRICT_DEBOUNCE
+#define CONFIG_KEYBOARD_STRICT_DEBOUNCE
+#endif
+
#undef CONFIG_LED_COMMON
#ifdef CONFIG_PLATFORM_EC_LED_COMMON
#define CONFIG_LED_COMMON
@@ -765,8 +766,7 @@ extern struct jump_data mock_jump_data;
#ifdef CONFIG_PLATFORM_EC_LED_PWM_CHARGE_COLOR
#undef CONFIG_LED_PWM_CHARGE_COLOR
-#define CONFIG_LED_PWM_CHARGE_COLOR \
- CONFIG_PLATFORM_EC_LED_PWM_CHARGE_COLOR
+#define CONFIG_LED_PWM_CHARGE_COLOR CONFIG_PLATFORM_EC_LED_PWM_CHARGE_COLOR
#endif
#ifdef CONFIG_PLATFORM_EC_LED_PWM_NEAR_FULL_COLOR
@@ -783,8 +783,7 @@ extern struct jump_data mock_jump_data;
#ifdef CONFIG_PLATFORM_EC_LED_PWM_SOC_ON_COLOR
#undef CONFIG_LED_PWM_SOC_ON_COLOR
-#define CONFIG_LED_PWM_SOC_ON_COLOR \
- CONFIG_PLATFORM_EC_LED_PWM_SOC_ON_COLOR
+#define CONFIG_LED_PWM_SOC_ON_COLOR CONFIG_PLATFORM_EC_LED_PWM_SOC_ON_COLOR
#endif
#ifdef CONFIG_PLATFORM_EC_LED_PWM_SOC_SUSPEND_COLOR
@@ -795,8 +794,7 @@ extern struct jump_data mock_jump_data;
#ifdef CONFIG_PLATFORM_EC_LED_PWM_LOW_BATT_COLOR
#undef CONFIG_LED_PWM_LOW_BATT_COLOR
-#define CONFIG_LED_PWM_LOW_BATT_COLOR \
- CONFIG_PLATFORM_EC_LED_PWM_LOW_BATT_COLOR
+#define CONFIG_LED_PWM_LOW_BATT_COLOR CONFIG_PLATFORM_EC_LED_PWM_LOW_BATT_COLOR
#endif
#undef CONFIG_CMD_LEDTEST
@@ -812,7 +810,7 @@ extern struct jump_data mock_jump_data;
#undef CONFIG_LED_ONOFF_STATES_BAT_LOW
#ifdef CONFIG_PLATFORM_EC_LED_ONOFF_STATES_BAT_LOW
#define CONFIG_LED_ONOFF_STATES_BAT_LOW \
- CONFIG_PLATFORM_EC_LED_ONOFF_STATES_BAT_LOW
+ CONFIG_PLATFORM_EC_LED_ONOFF_STATES_BAT_LOW
#endif
#undef CONFIG_PWM_DISPLIGHT
@@ -872,8 +870,7 @@ extern struct jump_data mock_jump_data;
#endif
#undef CONFIG_POWER_S0IX
-#if defined(CONFIG_PLATFORM_EC_POWERSEQ_S0IX) || \
- defined(CONFIG_AP_PWRSEQ_S0IX)
+#if defined(CONFIG_PLATFORM_EC_POWERSEQ_S0IX) || defined(CONFIG_AP_PWRSEQ_S0IX)
#define CONFIG_POWER_S0IX
#endif
@@ -898,7 +895,6 @@ extern struct jump_data mock_jump_data;
CONFIG_PLATFORM_EC_POWER_BUTTON_INIT_TIMEOUT
#endif
-
#undef CONFIG_POWERSEQ_FAKE_CONTROL
#ifdef CONFIG_PLATFORM_EC_POWERSEQ_FAKE_CONTROL
#define CONFIG_POWERSEQ_FAKE_CONTROL
@@ -931,19 +927,19 @@ extern struct jump_data mock_jump_data;
#undef CONFIG_CMD_GETTIME
#ifdef CONFIG_PLATFORM_EC_CONSOLE_CMD_GETTIME
#define CONFIG_CMD_GETTIME
-#endif /* CONFIG_PLATFORM_EC_CONSOLE_CMD_GETTIME */
+#endif /* CONFIG_PLATFORM_EC_CONSOLE_CMD_GETTIME */
#undef CONFIG_CMD_TIMERINFO
#ifdef CONFIG_PLATFORM_EC_CONSOLE_CMD_TIMERINFO
#define CONFIG_CMD_TIMERINFO
-#endif /* CONFIG_PLATFORM_EC_CONSOLE_CMD_TIMERINFO */
+#endif /* CONFIG_PLATFORM_EC_CONSOLE_CMD_TIMERINFO */
#undef CONFIG_CMD_WAITMS
#ifdef CONFIG_PLATFORM_EC_CONSOLE_CMD_WAITMS
#define CONFIG_CMD_WAITMS
-#endif /* CONFIG_PLATFORM_EC_CONSOLE_CMD_TIMERINFO */
+#endif /* CONFIG_PLATFORM_EC_CONSOLE_CMD_TIMERINFO */
-#endif /* CONFIG_PLATFORM_EC_TIMER */
+#endif /* CONFIG_PLATFORM_EC_TIMER */
/* USB-C things */
#ifdef CONFIG_PLATFORM_EC_USBC
@@ -954,18 +950,21 @@ extern struct jump_data mock_jump_data;
/*
* Define these here for now. They are not actually CONFIG options in the EC
* code base. Ideally they would be defined in the devicetree (perhaps for a
- * 'board' driver if not in the USB chip driver itself).
+ * 'board' driver if not in the USB chip driver itself). Use Kconfig to allow
+ * projects to overwrite the power configurations.
*
* SN5S30 PPC supports up to 24V VBUS source and sink, however passive USB-C
* cables only support up to 60W.
*/
-#define PD_OPERATING_POWER_MW 15000
-#define PD_MAX_POWER_MW 60000
-#define PD_MAX_CURRENT_MA 3000
-#define PD_MAX_VOLTAGE_MV 20000
+#define PD_OPERATING_POWER_MW CONFIG_PLATFORM_EC_PD_OPERATING_POWER_MW
+#define PD_MAX_POWER_MW CONFIG_PLATFORM_EC_PD_MAX_POWER_MW
+#define PD_MAX_CURRENT_MA CONFIG_PLATFORM_EC_PD_MAX_CURRENT_MA
+#define PD_MAX_VOLTAGE_MV CONFIG_PLATFORM_EC_PD_MAX_VOLTAGE_MV
-#define PD_POWER_SUPPLY_TURN_ON_DELAY 30000 /* us */
-#define PD_POWER_SUPPLY_TURN_OFF_DELAY 30000 /* us */
+#define PD_POWER_SUPPLY_TURN_ON_DELAY \
+ CONFIG_PLATFORM_EC_PD_POWER_SUPPLY_TURN_ON_DELAY
+#define PD_POWER_SUPPLY_TURN_OFF_DELAY \
+ CONFIG_PLATFORM_EC_PD_POWER_SUPPLY_TURN_OFF_DELAY
#endif
#undef CONFIG_CMD_PPC_DUMP
@@ -973,6 +972,11 @@ extern struct jump_data mock_jump_data;
#define CONFIG_CMD_PPC_DUMP
#endif
+#undef CONFIG_USBC_PPC_LOGGING
+#ifdef CONFIG_PLATFORM_EC_USBC_PPC_LOGGING
+#define CONFIG_USBC_PPC_LOGGING
+#endif
+
#undef CONFIG_CMD_TCPC_DUMP
#ifdef CONFIG_PLATFORM_EC_CONSOLE_CMD_TCPC_DUMP
#define CONFIG_CMD_TCPC_DUMP
@@ -990,8 +994,8 @@ extern struct jump_data mock_jump_data;
#define CONFIG_CHARGER
/* TODO: Put these charger defines in the devicetree? */
-#define CONFIG_CHARGER_SENSE_RESISTOR 10
-#define CONFIG_CHARGER_SENSE_RESISTOR_AC 10
+#define CONFIG_CHARGER_SENSE_RESISTOR 10
+#define CONFIG_CHARGER_SENSE_RESISTOR_AC 10
#endif
@@ -1013,31 +1017,31 @@ extern struct jump_data mock_jump_data;
#undef CONFIG_CHARGER_INPUT_CURRENT
#ifdef CONFIG_PLATFORM_EC_CHARGER_INPUT_CURRENT
-#define CONFIG_CHARGER_INPUT_CURRENT 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
#ifdef CONFIG_PLATFORM_EC_CHARGER_MIN_BAT_PCT_FOR_POWER_ON
#define CONFIG_CHARGER_MIN_BAT_PCT_FOR_POWER_ON \
- CONFIG_PLATFORM_EC_CHARGER_MIN_BAT_PCT_FOR_POWER_ON
+ CONFIG_PLATFORM_EC_CHARGER_MIN_BAT_PCT_FOR_POWER_ON
#endif
#undef CONFIG_CHARGER_MIN_BAT_PCT_FOR_POWER_ON_WITH_AC
#ifdef CONFIG_PLATFORM_EC_CHARGER_MIN_BAT_PCT_FOR_POWER_ON_WITH_AC
#define CONFIG_CHARGER_MIN_BAT_PCT_FOR_POWER_ON_WITH_AC \
- CONFIG_PLATFORM_EC_CHARGER_MIN_BAT_PCT_FOR_POWER_ON_WITH_AC
+ CONFIG_PLATFORM_EC_CHARGER_MIN_BAT_PCT_FOR_POWER_ON_WITH_AC
#endif
#undef CONFIG_CHARGER_MIN_POWER_MW_FOR_POWER_ON_WITH_BATT
#ifdef CONFIG_PLATFORM_EC_CHARGER_MIN_POWER_MW_FOR_POWER_ON_WITH_BATT
#define CONFIG_CHARGER_MIN_POWER_MW_FOR_POWER_ON_WITH_BATT \
- CONFIG_PLATFORM_EC_CHARGER_MIN_POWER_MW_FOR_POWER_ON_WITH_BATT
+ CONFIG_PLATFORM_EC_CHARGER_MIN_POWER_MW_FOR_POWER_ON_WITH_BATT
#endif
#undef CONFIG_CHARGER_MIN_POWER_MW_FOR_POWER_ON
#ifdef CONFIG_PLATFORM_EC_CHARGER_MIN_POWER_MW_FOR_POWER_ON
#define CONFIG_CHARGER_MIN_POWER_MW_FOR_POWER_ON \
- CONFIG_PLATFORM_EC_CHARGER_MIN_POWER_MW_FOR_POWER_ON
+ CONFIG_PLATFORM_EC_CHARGER_MIN_POWER_MW_FOR_POWER_ON
#endif
#undef CONFIG_CHARGE_RAMP_SW
@@ -1062,22 +1066,22 @@ extern struct jump_data mock_jump_data;
#undef CONFIG_USB_PID
#ifdef CONFIG_PLATFORM_EC_USB_PID
-#define CONFIG_USB_PID CONFIG_PLATFORM_EC_USB_PID
+#define CONFIG_USB_PID CONFIG_PLATFORM_EC_USB_PID
#endif
#undef CONFIG_USB_BCD_DEV
#ifdef CONFIG_PLATFORM_EC_USB_BCD_DEV
-#define CONFIG_USB_BCD_DEV CONFIG_PLATFORM_EC_USB_BCD_DEV
+#define CONFIG_USB_BCD_DEV CONFIG_PLATFORM_EC_USB_BCD_DEV
#endif
#undef CONFIG_USB_VID
#ifdef CONFIG_PLATFORM_EC_USB_VID
-#define CONFIG_USB_VID CONFIG_PLATFORM_EC_USB_VID
+#define CONFIG_USB_VID CONFIG_PLATFORM_EC_USB_VID
#endif
#undef CONFIG_USB_MS_EXTENDED_COMPAT_ID_DESCRIPTOR
#ifdef CONFIG_PLATFORM_EC_USB_MS_EXTENDED_COMPAT_ID_DESCRIPTOR
-#define CONFIG_USB_MS_EXTENDED_COMPAT_ID_DESCRIPTOR \
+#define CONFIG_USB_MS_EXTENDED_COMPAT_ID_DESCRIPTOR \
CONFIG_PLATFORM_EC_USB_MS_EXTENDED_COMPAT_ID_DESCRIPTOR
#endif
@@ -1145,11 +1149,25 @@ extern struct jump_data mock_jump_data;
#define CONFIG_USB_PORT_POWER_SMART_SIMPLE
#endif
+#undef CONFIG_USB_PORT_POWER_SMART_DEFAULT_MODE
+#ifdef CONFIG_PLATFORM_EC_USB_PORT_POWER_SMART_DEFAULT_DISABLED
+#define CONFIG_USB_PORT_POWER_SMART_DEFAULT_MODE USB_CHARGE_MODE_DISABLED
+#elif defined(CONFIG_PLATFORM_EC_USB_PORT_POWER_SMART_DEFAULT_SDP)
+#define CONFIG_USB_PORT_POWER_SMART_DEFAULT_MODE USB_CHARGE_MODE_SDP2
+#elif defined(CONFIG_PLATFORM_EC_USB_PORT_POWER_SMART_DEFAULT_CDP)
+#define CONFIG_USB_PORT_POWER_SMART_DEFAULT_MODE USB_CHARGE_MODE_CDP
+#endif
+
#undef CONFIG_USB_PORT_POWER_SMART_INVERTED
#ifdef CONFIG_PLATFORM_EC_USB_PORT_POWER_SMART_INVERTED
#define CONFIG_USB_PORT_POWER_SMART_INVERTED
#endif
+#undef CONFIG_BC12_CLIENT_MODE_ONLY_PI3USB9201
+#ifdef CONFIG_PLATFORM_EC_BC12_CLIENT_MODE_ONLY_PI3USB9201
+#define CONFIG_BC12_CLIENT_MODE_ONLY_PI3USB9201
+#endif
+
#undef CONFIG_BC12_DETECT_PI3USB9201
#ifdef CONFIG_PLATFORM_EC_BC12_DETECT_PI3USB9201
#define CONFIG_BC12_DETECT_PI3USB9201
@@ -1310,6 +1328,16 @@ extern struct jump_data mock_jump_data;
#define CONFIG_USB_PD_TCPM_NCT38XX
#endif
+#undef CONFIG_USB_PD_TCPM_PS8745
+#ifdef CONFIG_PLATFORM_EC_USB_PD_TCPM_PS8745
+#define CONFIG_USB_PD_TCPM_PS8745
+#endif
+
+#undef CONFIG_USB_PD_TCPM_PS8745_FORCE_ID
+#ifdef CONFIG_PLATFORM_EC_USB_PD_TCPM_PS8745_FORCE_ID
+#define CONFIG_USB_PD_TCPM_PS8745_FORCE_ID
+#endif
+
#undef CONFIG_USB_PD_TCPM_PS8751
#ifdef CONFIG_PLATFORM_EC_USB_PD_TCPM_PS8751
#define CONFIG_USB_PD_TCPM_PS8751
@@ -1364,8 +1392,11 @@ extern struct jump_data mock_jump_data;
#ifdef CONFIG_PLATFORM_EC_USB_PD_TCPM_ITE_ON_CHIP
#define CONFIG_USB_PD_TCPM_ITE_ON_CHIP
-/* TODO(b:189855648): hard-code a few things here; move to zephyr? */
-#define IT83XX_USBPD_PHY_PORT_COUNT 2
+#define IT83XX_USBPD_PHY_PORT_COUNT \
+ COND_CODE_1(DT_NODE_EXISTS(DT_INST(1, ite_it8xxx2_usbpd)), (2), (1))
+
+#define CONFIG_USB_PD_ITE_ACTIVE_PORT_COUNT \
+ DT_NUM_INST_STATUS_OKAY(ite_it8xxx2_usbpd)
#endif
#undef CONFIG_USB_PD_TCPM_DRIVER_IT8XXX2
@@ -1446,31 +1477,6 @@ extern struct jump_data mock_jump_data;
#endif /* CONFIG_PLATFORM_EC_USB_POWER_DELIVERY */
-#ifdef CONFIG_PLATFORM_EC_USB_CHARGER
-#ifndef CONFIG_PLATFORM_EC_USB_CHARGER_SINGLE_TASK
-#define HAS_TASK_USB_CHG_P0 1
-
-#if CONFIG_USB_PD_PORT_MAX_COUNT > 1
-#define HAS_TASK_USB_CHG_P1 1
-#endif /* CONFIG_USB_PD_PORT_MAX_COUNT > 1 */
-
-#if CONFIG_USB_PD_PORT_MAX_COUNT > 2
-#define HAS_TASK_USB_CHG_P2 1
-#endif /* CONFIG_USB_PD_PORT_MAX_COUNT > 2 */
-
-#if CONFIG_USB_PD_PORT_MAX_COUNT > 3
-#define HAS_TASK_USB_CHG_P3 1
-#endif /* CONFIG_USB_PD_PORT_MAX_COUNT > 3 */
-
-#endif /* !PLATFORM_EC_USB_CHARGER_SINGLE_TASK */
-#endif /* CONFIG_PLATFORM_EC_USB_CHARGER */
-
-#undef CONFIG_USB_PD_ITE_ACTIVE_PORT_COUNT
-#ifdef CONFIG_PLATFORM_EC_USB_PD_ITE_ACTIVE_PORT_COUNT
-#define CONFIG_USB_PD_ITE_ACTIVE_PORT_COUNT \
- CONFIG_PLATFORM_EC_USB_PD_ITE_ACTIVE_PORT_COUNT
-#endif
-
/* Remove PD_INT_C* task for ports managed by ITE embedded TCPC */
#ifdef CONFIG_USB_PD_ITE_ACTIVE_PORT_COUNT
#if CONFIG_USB_PD_ITE_ACTIVE_PORT_COUNT >= 1
@@ -1512,6 +1518,11 @@ extern struct jump_data mock_jump_data;
#define CONFIG_USBC_PPC_NX20P3483
#endif
+#undef CONFIG_USBC_NX20P348X_RCP_5VSRC_MASK_ENABLE
+#ifdef CONFIG_PLATFORM_EC_USBC_NX20P348X_RCP_5VSRC_MASK_ENABLE
+#define CONFIG_USBC_NX20P348X_RCP_5VSRC_MASK_ENABLE
+#endif
+
#undef CONFIG_USBC_PPC_RT1718S
#ifdef CONFIG_PLATFORM_EC_USBC_PPC_RT1718S
#define CONFIG_USBC_PPC_RT1718S
@@ -1594,13 +1605,13 @@ extern struct jump_data mock_jump_data;
#ifdef CONFIG_PLATFORM_EC_USBC_RETIMER_INTEL_HB
#define USBC_PORT_C0_HB_RETIMER_I2C_ADDR \
- DT_REG_ADDR(DT_NODELABEL(usb_c0_hb_retimer))
+ DT_REG_ADDR(DT_NODELABEL(usb_c0_hb_retimer))
#define USBC_PORT_C1_HB_RETIMER_I2C_ADDR \
- DT_REG_ADDR(DT_NODELABEL(usb_c1_hb_retimer))
+ DT_REG_ADDR(DT_NODELABEL(usb_c1_hb_retimer))
#define USBC_PORT_C2_HB_RETIMER_I2C_ADDR \
- DT_REG_ADDR(DT_NODELABEL(usb_c2_hb_retimer))
+ DT_REG_ADDR(DT_NODELABEL(usb_c2_hb_retimer))
#define USBC_PORT_C3_HB_RETIMER_I2C_ADDR \
- DT_REG_ADDR(DT_NODELABEL(usb_c3_hb_retimer))
+ DT_REG_ADDR(DT_NODELABEL(usb_c3_hb_retimer))
#define CONFIG_USBC_RETIMER_INTEL_HB
#endif
@@ -1731,18 +1742,24 @@ extern struct jump_data mock_jump_data;
#ifdef CONFIG_PLATFORM_EC_USB_PD_TCPC_LOW_POWER
#define CONFIG_USB_PD_TCPC_LOW_POWER
#define CONFIG_USB_PD_TCPC_LPM_EXIT_DEBOUNCE \
- CONFIG_PLATFORM_EC_USB_PD_TCPC_LPM_EXIT_DEBOUNCE_US
+ CONFIG_PLATFORM_EC_USB_PD_TCPC_LPM_EXIT_DEBOUNCE_US
#endif /* CONFIG_PLATFORM_EC_USB_PD_TCPC_LOW_POWER */
#undef CONFIG_USB_PD_DEBUG_LEVEL
#ifdef CONFIG_PLATFORM_EC_USB_PD_DEBUG_FIXED_LEVEL
-#define CONFIG_USB_PD_DEBUG_LEVEL CONFIG_PLATFORM_EC_USB_PD_DEBUG_LEVEL
+#define CONFIG_USB_PD_DEBUG_LEVEL CONFIG_PLATFORM_EC_USB_PD_DEBUG_LEVEL
+#endif
+
+#undef CONFIG_USB_PD_INITIAL_DEBUG_LEVEL
+#ifdef CONFIG_PLATFORM_EC_USB_PD_INITIAL_DEBUG_LEVEL
+#define CONFIG_USB_PD_INITIAL_DEBUG_LEVEL \
+ CONFIG_PLATFORM_EC_USB_PD_INITIAL_DEBUG_LEVEL
#endif
#undef CONFIG_USB_PD_STARTUP_DELAY_MS
#ifdef CONFIG_PLATFORM_EC_USB_PD_STARTUP_DELAY_MS
-#define CONFIG_USB_PD_STARTUP_DELAY_MS \
- CONFIG_PLATFORM_EC_USB_PD_STARTUP_DELAY_MS
+#define CONFIG_USB_PD_STARTUP_DELAY_MS \
+ CONFIG_PLATFORM_EC_USB_PD_STARTUP_DELAY_MS
#endif
#undef CONFIG_USB_PD_3A_PORTS
@@ -1755,6 +1772,18 @@ extern struct jump_data mock_jump_data;
#define CONFIG_USB_PD_TEMP_SENSOR CONFIG_PLATFORM_EC_USB_PD_TEMP_SENSOR
#endif
+#undef CONFIG_USB_PD_SHORT_PRESS_MAX_MS
+#ifdef CONFIG_PLATFORM_EC_USB_PD_SHORT_PRESS_MAX_MS
+#define CONFIG_USB_PD_SHORT_PRESS_MAX_MS \
+ CONFIG_PLATFORM_EC_USB_PD_SHORT_PRESS_MAX_MS
+#endif
+
+#undef CONFIG_USB_PD_LONG_PRESS_MAX_MS
+#ifdef CONFIG_PLATFORM_EC_USB_PD_LONG_PRESS_MAX_MS
+#define CONFIG_USB_PD_LONG_PRESS_MAX_MS \
+ CONFIG_PLATFORM_EC_USB_PD_LONG_PRESS_MAX_MS
+#endif
+
#undef CONFIG_USBC_VCONN
#ifdef CONFIG_PLATFORM_EC_USBC_VCONN
#define CONFIG_USBC_VCONN
@@ -1818,6 +1847,11 @@ extern struct jump_data mock_jump_data;
#define CONFIG_USB_PD_USB4
#endif
+#undef CONFIG_USB_PD_DATA_RESET_MSG
+#ifdef CONFIG_PLATFORM_EC_USB_PD_DATA_RESET_MSG
+#define CONFIG_USB_PD_DATA_RESET_MSG
+#endif
+
#undef CONFIG_USB_PD_FRS
#ifdef CONFIG_PLATFORM_EC_USB_PD_FRS
#define CONFIG_USB_PD_FRS
@@ -1837,7 +1871,7 @@ extern struct jump_data mock_jump_data;
#undef VSTORE_SLOT_COUNT
#ifdef CONFIG_PLATFORM_EC_VSTORE
#define CONFIG_VSTORE
-#define CONFIG_VSTORE_SLOT_COUNT CONFIG_PLATFORM_EC_VSTORE_SLOT_COUNT
+#define CONFIG_VSTORE_SLOT_COUNT CONFIG_PLATFORM_EC_VSTORE_SLOT_COUNT
#endif
/* motion sense */
@@ -1871,7 +1905,8 @@ extern struct jump_data mock_jump_data;
#undef CONFIG_EC_MAX_SENSOR_FREQ_MILLIHZ
#ifdef CONFIG_PLATFORM_EC_MAX_SENSOR_FREQ_MILLIHZ
-#define CONFIG_EC_MAX_SENSOR_FREQ_MILLIHZ CONFIG_PLATFORM_EC_MAX_SENSOR_FREQ_MILLIHZ
+#define CONFIG_EC_MAX_SENSOR_FREQ_MILLIHZ \
+ CONFIG_PLATFORM_EC_MAX_SENSOR_FREQ_MILLIHZ
#endif
#undef CONFIG_CMD_ACCEL_SPOOF
@@ -1984,6 +2019,11 @@ extern struct jump_data mock_jump_data;
#define CONFIG_ACCELGYRO_LSM6DSO
#endif
+#undef CONFIG_ACCELGYRO_LSM6DSM
+#ifdef CONFIG_PLATFORM_EC_ACCELGYRO_LSM6DSM
+#define CONFIG_ACCELGYRO_LSM6DSM
+#endif
+
#endif /* CONFIG_PLATFORM_EC_MOTIONSENSE */
#undef CONFIG_MATH_UTIL
@@ -2027,6 +2067,11 @@ extern struct jump_data mock_jump_data;
#define CONFIG_SOFTWARE_PANIC
#endif
+#undef CONFIG_DEBUG_ASSSERT_BRIEF
+#ifdef CONFIG_PLATFORM_EC_DEBUG_ASSERT_BRIEF
+#define CONFIG_DEBUG_ASSSERT_BRIEF
+#endif
+
#undef CONFIG_PANIC_CONSOLE_OUTPUT
#ifdef CONFIG_PLATFORM_EC_PANIC_CONSOLE_OUTPUT
#define CONFIG_PANIC_CONSOLE_OUTPUT
@@ -2108,6 +2153,11 @@ extern struct jump_data mock_jump_data;
#define I2C_ADDR_EEPROM_FLAGS DT_REG_ADDR(DT_NODELABEL(cbi_eeprom))
#endif
+#undef CONFIG_EEPROM_CBI_WP
+#ifdef CONFIG_PLATFORM_EC_EEPROM_CBI_WP
+#define CONFIG_EEPROM_CBI_WP
+#endif
+
#undef CONFIG_CBI_GPIO
#ifdef CONFIG_PLATFORM_EC_CBI_GPIO
#define CONFIG_CBI_GPIO
@@ -2125,14 +2175,14 @@ extern struct jump_data mock_jump_data;
#undef CONFIG_RO_HDR_MEM_OFF
#ifdef CONFIG_PLATFORM_EC_RO_HEADER_OFFSET
-#define CONFIG_RO_HDR_MEM_OFF CONFIG_PLATFORM_EC_RO_HEADER_OFFSET
+#define CONFIG_RO_HDR_MEM_OFF CONFIG_PLATFORM_EC_RO_HEADER_OFFSET
#else
#define CONFIG_RO_HDR_MEM_OFF 0
#endif
#undef CONFIG_RO_HDR_SIZE
#ifdef CONFIG_PLATFORM_EC_RO_HEADER_SIZE
-#define CONFIG_RO_HDR_SIZE CONFIG_PLATFORM_EC_RO_HEADER_SIZE
+#define CONFIG_RO_HDR_SIZE CONFIG_PLATFORM_EC_RO_HEADER_SIZE
#else
#define CONFIG_RO_HDR_SIZE 0
#endif
@@ -2172,11 +2222,6 @@ extern struct jump_data mock_jump_data;
#define CONFIG_DEBUG_ASSERT_REBOOTS
#endif
-#undef CONFIG_MPU
-#ifdef CONFIG_PLATFORM_EC_MPU
-#define CONFIG_MPU
-#endif
-
#undef CONFIG_CMD_SYSINFO
#ifdef CONFIG_PLATFORM_EC_CONSOLE_CMD_SYSINFO
#define CONFIG_CMD_SYSINFO
@@ -2199,7 +2244,7 @@ extern struct jump_data mock_jump_data;
#undef CONFIG_WATCHDOG_WARNING_LEADING_TIME_MS
#if defined(CONFIG_PLATFORM_EC_WATCHDOG_WARNING_LEADING_TIME_MS) || \
- defined(CONFIG_WDT_NPCX_DELAY_CYCLES) || \
+ defined(CONFIG_WDT_NPCX_DELAY_CYCLES) || \
defined(CONFIG_WDT_ITE_WARNING_LEADING_TIME_MS)
/*
* Note:
@@ -2319,7 +2364,7 @@ extern struct jump_data mock_jump_data;
#undef CONFIG_BATTERY_DEVICE_CHEMISTRY
#ifdef CONFIG_PLATFORM_EC_USE_BATTERY_DEVICE_CHEMISTRY
-#define CONFIG_BATTERY_DEVICE_CHEMISTRY \
+#define CONFIG_BATTERY_DEVICE_CHEMISTRY \
CONFIG_PLATFORM_EC_BATTERY_DEVICE_CHEMISTRY
#endif
@@ -2366,13 +2411,13 @@ extern struct jump_data mock_jump_data;
#undef CONFIG_CHARGER_BQ25710_SENSE_RESISTOR
#ifdef CONFIG_PLATFORM_EC_CHARGER_BQ25710_SENSE_RESISTOR
-#define CONFIG_CHARGER_BQ25710_SENSE_RESISTOR \
+#define CONFIG_CHARGER_BQ25710_SENSE_RESISTOR \
CONFIG_PLATFORM_EC_CHARGER_BQ25710_SENSE_RESISTOR
#endif
#undef CONFIG_CHARGER_BQ25710_SENSE_RESISTOR_AC
#ifdef CONFIG_PLATFORM_EC_CHARGER_BQ25710_SENSE_RESISTOR_AC
-#define CONFIG_CHARGER_BQ25710_SENSE_RESISTOR_AC \
+#define CONFIG_CHARGER_BQ25710_SENSE_RESISTOR_AC \
CONFIG_PLATFORM_EC_CHARGER_BQ25710_SENSE_RESISTOR_AC
#endif
@@ -2413,13 +2458,12 @@ extern struct jump_data mock_jump_data;
#undef CONFIG_CHARGER_SENSE_RESISTOR
#ifdef CONFIG_PLATFORM_EC_CHARGER_SENSE_RESISTOR
-#define CONFIG_CHARGER_SENSE_RESISTOR \
- CONFIG_PLATFORM_EC_CHARGER_SENSE_RESISTOR
+#define CONFIG_CHARGER_SENSE_RESISTOR CONFIG_PLATFORM_EC_CHARGER_SENSE_RESISTOR
#endif
#undef CONFIG_CHARGER_SENSE_RESISTOR_AC
#ifdef CONFIG_PLATFORM_EC_CHARGER_SENSE_RESISTOR_AC
-#define CONFIG_CHARGER_SENSE_RESISTOR_AC \
+#define CONFIG_CHARGER_SENSE_RESISTOR_AC \
CONFIG_PLATFORM_EC_CHARGER_SENSE_RESISTOR_AC
#endif
@@ -2454,8 +2498,7 @@ extern struct jump_data mock_jump_data;
#undef CONFIG_MP2964
#ifdef CONFIG_PLATFORM_EC_MP2964
#define CONFIG_MP2964
-#define I2C_ADDR_MP2964_FLAGS \
- DT_REG_ADDR(DT_NODELABEL(pmic_mp2964))
+#define I2C_ADDR_MP2964_FLAGS DT_REG_ADDR(DT_NODELABEL(pmic_mp2964))
#endif
#undef CONFIG_ACCELGYRO_ICM_COMM_SPI
@@ -2503,6 +2546,11 @@ extern struct jump_data mock_jump_data;
#define CONFIG_PORT80_4_BYTE
#endif
+#undef CONFIG_PORT80_QUIET
+#ifdef CONFIG_PLATFORM_EC_PORT80_QUIET
+#define CONFIG_PORT80_QUIET
+#endif
+
#undef CONFIG_ASSERT_CCD_MODE_ON_DTS_CONNECT
#ifdef CONFIG_PLATFORM_EC_ASSERT_CCD_MODE_ON_DTS_CONNECT
#define CONFIG_ASSERT_CCD_MODE_ON_DTS_CONNECT
@@ -2597,4 +2645,14 @@ extern struct jump_data mock_jump_data;
#define CONFIG_IO_EXPANDER_CCGXXF
#endif
-#endif /* __CROS_EC_CONFIG_CHIP_H */
+#undef CONFIG_PERIPHERAL_CHARGER
+#ifdef CONFIG_PLATFORM_EC_PERIPHERAL_CHARGER
+#define CONFIG_PERIPHERAL_CHARGER
+#endif
+
+#undef CONFIG_CPS8100
+#ifdef CONFIG_PLATFORM_EC_CPS8100
+#define CONFIG_CPS8100
+#endif
+
+#endif /* __CROS_EC_CONFIG_CHIP_H */
diff --git a/zephyr/shim/include/cpu.h b/zephyr/shim/include/cpu.h
index 617f644fa9..3e65aa0061 100644
--- a/zephyr/shim/include/cpu.h
+++ b/zephyr/shim/include/cpu.h
@@ -1,4 +1,4 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
+/* Copyright 2021 The ChromiumOS Authors
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
diff --git a/zephyr/shim/include/cros_cbi.h b/zephyr/shim/include/cros_cbi.h
index 40a2b9d8ec..1f8a1b3dfa 100644
--- a/zephyr/shim/include/cros_cbi.h
+++ b/zephyr/shim/include/cros_cbi.h
@@ -1,4 +1,4 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
+/* Copyright 2021 The ChromiumOS Authors
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
@@ -14,18 +14,17 @@
* Macros are _INST_ types, so require DT_DRV_COMPAT to be defined.
*/
#define DT_DRV_COMPAT named_cbi_ssfc_value
-#define CROS_CBI_LABEL "cros_cbi"
+#define CROS_CBI_LABEL "cros_cbi"
-#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_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, _) \
CBI_SSFC_VALUE_ID_WITH_COMMA(DT_INST(inst, CBI_SSFC_VALUE_COMPAT))
enum cbi_ssfc_value_id {
LISTIFY(DT_NUM_INST_STATUS_OKAY(CBI_SSFC_VALUE_COMPAT),
- CBI_SSFC_VALUE_INST_ENUM, ())
- CBI_SSFC_VALUE_COUNT
+ CBI_SSFC_VALUE_INST_ENUM, ()) CBI_SSFC_VALUE_COUNT
};
#undef DT_DRV_COMPAT
@@ -34,19 +33,18 @@ enum cbi_ssfc_value_id {
* Macros to help generate the enum list of field and value names
* for the FW_CONFIG CBI data.
*/
-#define CBI_FW_CONFIG_COMPAT cros_ec_cbi_fw_config
-#define CBI_FW_CONFIG_VALUE_COMPAT cros_ec_cbi_fw_config_value
+#define CBI_FW_CONFIG_COMPAT cros_ec_cbi_fw_config
+#define CBI_FW_CONFIG_VALUE_COMPAT cros_ec_cbi_fw_config_value
/*
* Retrieve the enum-name property for this node.
*/
-#define CBI_FW_CONFIG_ENUM(node) DT_STRING_TOKEN(node, enum_name)
+#define CBI_FW_CONFIG_ENUM(node) DT_STRING_TOKEN(node, enum_name)
/*
* Create an enum entry without a value (an enum with a following comma).
*/
-#define CBI_FW_CONFIG_ENUM_WITH_COMMA(node) \
- CBI_FW_CONFIG_ENUM(node),
+#define CBI_FW_CONFIG_ENUM_WITH_COMMA(node) CBI_FW_CONFIG_ENUM(node),
/*
* Create a single enum entry with assignment to the node's value,
@@ -67,7 +65,7 @@ enum cbi_ssfc_value_id {
enum cbi_fw_config_field_id {
DT_FOREACH_STATUS_OKAY(CBI_FW_CONFIG_COMPAT,
CBI_FW_CONFIG_CHILD_ENUM_LIST)
- CBI_FW_CONFIG_FIELDS_COUNT
+ CBI_FW_CONFIG_FIELDS_COUNT
};
/*
@@ -76,7 +74,8 @@ enum cbi_fw_config_field_id {
enum cbi_fw_config_value_id {
DT_FOREACH_STATUS_OKAY(CBI_FW_CONFIG_VALUE_COMPAT,
CBI_FW_CONFIG_ENUM_WITH_VALUE)
- CBI_FW_CONFIG_VALUES_LAST /* added to ensure at least one entry */
+ CBI_FW_CONFIG_VALUES_LAST /* added to ensure at least one entry
+ */
};
/**
diff --git a/zephyr/shim/include/ec_tasks.h b/zephyr/shim/include/ec_tasks.h
index 9b2998b64a..793beb25ae 100644
--- a/zephyr/shim/include/ec_tasks.h
+++ b/zephyr/shim/include/ec_tasks.h
@@ -1,4 +1,4 @@
-/* Copyright 2020 The Chromium OS Authors. All rights reserved.
+/* Copyright 2020 The ChromiumOS Authors
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
diff --git a/zephyr/shim/include/fpu.h b/zephyr/shim/include/fpu.h
index 8f78fb587d..d1e4460827 100644
--- a/zephyr/shim/include/fpu.h
+++ b/zephyr/shim/include/fpu.h
@@ -1,4 +1,4 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
+/* Copyright 2021 The ChromiumOS Authors
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
@@ -25,11 +25,7 @@ static inline float sqrtf(float v)
float root;
/* Use the CPU instruction */
- __asm__ volatile(
- "fsqrts %0, %1"
- : "=w" (root)
- : "w" (v)
- );
+ __asm__ volatile("fsqrts %0, %1" : "=w"(root) : "w"(v));
return root;
}
@@ -39,11 +35,7 @@ static inline float fabsf(float v)
float root;
/* Use the CPU instruction */
- __asm__ volatile(
- "fabss %0, %1"
- : "=w" (root)
- : "w" (v)
- );
+ __asm__ volatile("fabss %0, %1" : "=w"(root) : "w"(v));
return root;
}
@@ -67,6 +59,6 @@ static inline float fabsf(float v)
#error "Unsupported core: please add an implementation"
#endif
-#endif /* CONFIG_PLATFORM_EC_FPU */
+#endif /* CONFIG_PLATFORM_EC_FPU */
-#endif /* __CROS_EC_MATH_H */
+#endif /* __CROS_EC_MATH_H */
diff --git a/zephyr/shim/include/gpio/gpio.h b/zephyr/shim/include/gpio/gpio.h
index 6f92ed5795..3f95bdbbe0 100644
--- a/zephyr/shim/include/gpio/gpio.h
+++ b/zephyr/shim/include/gpio/gpio.h
@@ -1,4 +1,4 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
+/* Copyright 2021 The ChromiumOS Authors
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
@@ -74,8 +74,8 @@ int gpio_config_unused_pins(void) __attribute__((weak));
*/
#define UNUSED_GPIO_CONFIG_BY_IDX(i, _) \
{ \
- .dev_name = DT_GPIO_LABEL_BY_IDX(UNUSED_PINS_LIST, \
- unused_gpios, i), \
+ .dev_name = DEVICE_DT_NAME(DT_GPIO_CTLR_BY_IDX( \
+ UNUSED_PINS_LIST, unused_gpios, i)), \
.pin = DT_GPIO_PIN_BY_IDX(UNUSED_PINS_LIST, unused_gpios, i), \
.flags = DT_GPIO_FLAGS_BY_IDX(UNUSED_PINS_LIST, unused_gpios, \
i), \
diff --git a/zephyr/shim/include/gpio/gpio_int.h b/zephyr/shim/include/gpio/gpio_int.h
index 5cbddf76ca..835c5503ba 100644
--- a/zephyr/shim/include/gpio/gpio_int.h
+++ b/zephyr/shim/include/gpio/gpio_int.h
@@ -1,4 +1,4 @@
-/* Copyright 2022 The Chromium OS Authors. All rights reserved.
+/* 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.
*/
@@ -23,8 +23,7 @@
/*
* Maps nodelabel of interrupt node to internal configuration block.
*/
-#define GPIO_INT_FROM_NODELABEL(lbl) \
- (GPIO_INT_FROM_NODE(DT_NODELABEL(lbl)))
+#define GPIO_INT_FROM_NODELABEL(lbl) (GPIO_INT_FROM_NODE(DT_NODELABEL(lbl)))
/*
* Unique enum name for the interrupt.
@@ -34,17 +33,15 @@
/*
* Create an enum list of the interrupts
*/
-#define GPIO_INT_ENUM_WITH_COMMA(id) GPIO_INT_ENUM(id),
enum gpio_interrupts {
#if DT_HAS_COMPAT_STATUS_OKAY(cros_ec_gpio_interrupts)
- DT_FOREACH_CHILD(DT_COMPAT_GET_ANY_STATUS_OKAY(cros_ec_gpio_interrupts),
- GPIO_INT_ENUM_WITH_COMMA)
+ DT_FOREACH_CHILD_SEP(
+ DT_COMPAT_GET_ANY_STATUS_OKAY(cros_ec_gpio_interrupts),
+ GPIO_INT_ENUM, (, )),
#endif
- GPIO_INT_COUNT
+ GPIO_INT_COUNT
};
-#undef GPIO_INT_ENUM_WITH_COMMA
-
/*
* Forward reference to avoiding exposing internal structure
* defined in gpio_int.c
@@ -60,24 +57,24 @@ struct gpio_int_config;
* ... // set up device
* gpio_enable_dt_interrupt(GPIO_INT_FROM_NODELABEL(my_interrupt_node));
*/
-int gpio_enable_dt_interrupt(const struct gpio_int_config * const ic);
+int gpio_enable_dt_interrupt(const struct gpio_int_config *const ic);
/*
* Disable the interrupt.
*/
-int gpio_disable_dt_interrupt(const struct gpio_int_config * const ic);
+int gpio_disable_dt_interrupt(const struct gpio_int_config *const ic);
/*
* Get the interrupt config for this interrupt.
*/
const struct gpio_int_config *
- gpio_interrupt_get_config(enum gpio_interrupts intr);
+gpio_interrupt_get_config(enum gpio_interrupts intr);
/*
* Declare interrupt configuration data structures.
*/
-#define GPIO_INT_DECLARE(id) \
- extern const struct gpio_int_config * const GPIO_INT_FROM_NODE(id);
+#define GPIO_INT_DECLARE(id) \
+ extern const struct gpio_int_config *const GPIO_INT_FROM_NODE(id);
#if DT_HAS_COMPAT_STATUS_OKAY(cros_ec_gpio_interrupts)
DT_FOREACH_CHILD(DT_COMPAT_GET_ANY_STATUS_OKAY(cros_ec_gpio_interrupts),
diff --git a/zephyr/shim/include/hook_types.h b/zephyr/shim/include/hook_types.h
index bcd1d0119c..004e5a52db 100644
--- a/zephyr/shim/include/hook_types.h
+++ b/zephyr/shim/include/hook_types.h
@@ -1,4 +1,4 @@
-/* Copyright 2022 The Chromium OS Authors. All rights reserved.
+/* 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.
*/
@@ -47,6 +47,6 @@
HOOK_POWER_BUTTON_CHANGE, HOOK_BATTERY_SOC_CHANGE, \
HOOK_TYPES_USB_SUSPEND, HOOK_TICK, HOOK_SECOND, \
HOOK_USB_PD_DISCONNECT, HOOK_USB_PD_CONNECT, \
- HOOK_TYPES_TEST_BUILD)
+ HOOK_POWER_SUPPLY_CHANGE, HOOK_TYPES_TEST_BUILD)
#endif
diff --git a/zephyr/shim/include/i2c/i2c.h b/zephyr/shim/include/i2c/i2c.h
index c7e29e79e5..3e95fbc9d3 100644
--- a/zephyr/shim/include/i2c/i2c.h
+++ b/zephyr/shim/include/i2c/i2c.h
@@ -1,4 +1,4 @@
-/* Copyright 2020 The Chromium OS Authors. All rights reserved.
+/* Copyright 2020 The ChromiumOS Authors
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
@@ -12,36 +12,170 @@
#ifdef CONFIG_PLATFORM_EC_I2C
#if DT_NODE_EXISTS(DT_PATH(named_i2c_ports))
-#define I2C_PORT(id) DT_STRING_UPPER_TOKEN(id, enum_name)
-#define I2C_PORT_WITH_COMMA(id) I2C_PORT(id),
+#define NPCX_PORT_COMPAT nuvoton_npcx_i2c_port
+#define ITE_IT8XXX2_PORT_COMPAT ite_it8xxx2_i2c
+#define ITE_ENHANCE_PORT_COMPAT ite_enhance_i2c
+#define MICROCHIP_XEC_COMPAT microchip_xec_i2c_v2
+#define I2C_EMUL_COMPAT zephyr_i2c_emul_controller
+#define I2C_FOREACH_PORT(fn) \
+ DT_FOREACH_STATUS_OKAY(NPCX_PORT_COMPAT, fn) \
+ DT_FOREACH_STATUS_OKAY(ITE_IT8XXX2_PORT_COMPAT, fn) \
+ DT_FOREACH_STATUS_OKAY(ITE_ENHANCE_PORT_COMPAT, fn) \
+ DT_FOREACH_STATUS_OKAY(MICROCHIP_XEC_COMPAT, fn) \
+ DT_FOREACH_STATUS_OKAY(I2C_EMUL_COMPAT, fn)
+/*
+ * Get the legacy I2C port enum value from the I2C bus node identifier.
+ * The value returned by this macro is passed as the 'int port' parameter to all
+ * the legacy APIs provided by i2c_controller.h
+ *
+ * Example devicetree fragment:
+ *
+ * / {
+ * soc-if {
+ * i2c2_0: io_i2c_ctrl2_port0 {
+ * compatible = "nuvoton,npcx-i2c-port";
+ * #address-cells = <1>;
+ * #size-cells = <0>;
+ * port = <0x20>;
+ * controller = <&i2c_ctrl2>;
+ * label = "I2C_2_PORT_0";
+ * status = "disabled";
+ * };
+ * }.
+ * };
+ *
+ * Example usage to get the I2C port enum value for i2c2_0:
+ *
+ * I2C_PORT_BUS(DT_NODELABEL(i2c2_0))
+ * // I2C_BUS_DT_N_S_soc_if_S_io_i2c_ctrl2_port0
+ *
+ * @param i2c_port_id: node id of a I2C port device
+ */
+#define I2C_PORT_BUS(i2c_port_id) DT_CAT(I2C_BUS_, i2c_port_id)
+#define I2C_PORT_BUS_WITH_COMMA(i2c_port_id) I2C_PORT_BUS(i2c_port_id),
+
+/*
+ * Get the legacy I2C port enum value from a named-i2c-ports child node.
+ *
+ * Example devicetree fragment:
+ *
+ * i2c0_0: io_i2c_ctrl0_port0 {
+ * compatible = "nuvoton,npcx-i2c-port";
+ * #address-cells = <1>;
+ * #size-cells = <0>;
+ * port = <0x00>;
+ * controller = <&i2c_ctrl0>;
+ * label = "I2C_0_PORT_0";
+ * status = "disabled";
+ * };
+ *
+ * named-i2c-ports {
+ * compatible = "named-i2c-ports";
+ * i2c_sensor: sensor {
+ * i2c-port = <&i2c0_0>;
+ * enum-names = "I2C_PORT_SENSOR";
+ * };
+ * };
+ *
+ * Example usage to get the I2C port enum value for i2c_sensor:
+ *
+ * I2C_PORT(DT_NODELABEL(i2c_sensor))
+ *
+ * which equals:
+ *
+ * I2C_PORT_BUS(DT_NODELABEL(i2c0_0))
+ *
+ * @param i2c_named_id: node id of a child of the named-i2c-ports node
+ */
+#define I2C_PORT(i2c_named_id) I2C_PORT_BUS(DT_PHANDLE(i2c_named_id, i2c_port))
+
+/*
+ * Get the legacy I2C port enum from the I2C bus nodelabel. This macro should be
+ * used with the I2C port device node, not the named-i2c-port child node.
+ *
+ * / {
+ * soc-if {
+ * i2c2_0: io_i2c_ctrl2_port0 {
+ * compatible = "nuvoton,npcx-i2c-port";
+ * #address-cells = <1>;
+ * #size-cells = <0>;
+ * port = <0x20>;
+ * controller = <&i2c_ctrl2>;
+ * label = "I2C_2_PORT_0";
+ * status = "disabled";
+ * };
+ * }.
+ * };
+ *
+ * Example usage to get the I2C port enum value for i2c2_0:
+ *
+ * I2C_PORT_NODELABEL(i2c2_0)
+ * // I2C_BUS_DT_N_S_soc_if_S_io_i2c_ctrl2_port0
+ *
+ * @param label: nodelabel of a I2C port device
+ */
+#define I2C_PORT_NODELABEL(label) I2C_PORT_BUS(DT_NODELABEL(label))
+
+/*
+ * Get the legacy I2C port enum for a child device on an I2C bus.
+ *
+ * Example devicetree fragment:
+ *
+ * i2c2_0: io_i2c_ctrl2_port0 {
+ * compatible = "nuvoton,npcx-i2c-port";
+ * #address-cells = <1>;
+ * #size-cells = <0>;
+ * port = <0x20>;
+ * controller = <&i2c_ctrl2>;
+ * label = "I2C_2_PORT_0";
+ * status = "disabled";
+ * };
+ *
+ * &i2c2_0 {
+ * bc12_port0: pi3usb9201@5f {
+ * compatible = "pericom,pi3usb9201";
+ * status = "okay";
+ * reg = <0x5f>;
+ * irq = <&int_usb_c0_bc12>;
+ * };
+ * };
+ *
+ * Example usage to get the I2C port enum value for bc12_port0:
+ *
+ * I2C_PORT_BY_DEV(DT_NODELABEL(bc12_port0))
+ *
+ * * which equals:
+ *
+ * I2C_PORT_BUS(DT_NODELABEL(i2c2_0))
+ *
+ * @param dev_id: node id of a device on the I2C bus
+ */
+#define I2C_PORT_BY_DEV(dev_id) I2C_PORT_BUS(DT_BUS(dev_id))
+
+enum i2c_ports_chip {
+ I2C_FOREACH_PORT(I2C_PORT_BUS_WITH_COMMA) I2C_PORT_COUNT
+};
+
+BUILD_ASSERT(I2C_PORT_COUNT != 0, "No I2C devices defined");
+
+#define I2C_PORT_ENUM_IDX_COMMA(i2c_named_id, prop, idx) \
+ DT_STRING_UPPER_TOKEN_BY_IDX(i2c_named_id, prop, idx) = \
+ I2C_PORT(i2c_named_id),
+#define NAMED_I2C_PORT_COMMA(i2c_named_id) \
+ DT_FOREACH_PROP_ELEM(i2c_named_id, enum_names, I2C_PORT_ENUM_IDX_COMMA)
+
+/*
+ * The enum i2c_ports maps the hard-coded I2C port names (such as
+ * I2C_PORT_BATTERY or I2C_PORT_SENSOR) to the unique port numbers created by
+ * enum i2c_ports_chip above for every I2C port devicetree node.
+ */
enum i2c_ports {
- DT_FOREACH_CHILD(DT_PATH(named_i2c_ports), I2C_PORT_WITH_COMMA)
- I2C_PORT_COUNT
+ DT_FOREACH_CHILD(DT_PATH(named_i2c_ports), NAMED_I2C_PORT_COMMA)
};
-#define NAMED_I2C(name) I2C_PORT(DT_PATH(named_i2c_ports, name))
#endif /* named_i2c_ports */
#endif /* CONFIG_PLATFORM_EC_I2C */
-#ifdef CONFIG_I2C_NPCX
-#define I2C_COMPAT nuvoton_npcx_i2c_port
-#elif CONFIG_I2C_ITE_IT8XXX2
-#define I2C_COMPAT ite_it8xxx2_i2c
-#elif CONFIG_I2C_XEC_V2
-#define I2C_COMPAT microchip_xec_i2c_v2
-#elif CONFIG_I2C_EMUL
-#define I2C_COMPAT zephyr_i2c_emul_controller
-#else
-#error An undefined I2C driver is used.
-#endif
-
-#if defined(CONFIG_I2C_ITE_IT8XXX2) && defined(CONFIG_I2C_ITE_ENHANCE)
-#define I2C_DEVICE_COUNT DT_NUM_INST_STATUS_OKAY(ite_it8xxx2_i2c) + \
- DT_NUM_INST_STATUS_OKAY(ite_enhance_i2c)
-#else
-#define I2C_DEVICE_COUNT DT_NUM_INST_STATUS_OKAY(I2C_COMPAT)
-#endif
-
/**
* @brief Adaptation of platform/ec's port IDs which map a port/bus to a device.
*
diff --git a/zephyr/shim/include/linker.h b/zephyr/shim/include/linker.h
index 335f4f0f19..92dc8f5981 100644
--- a/zephyr/shim/include/linker.h
+++ b/zephyr/shim/include/linker.h
@@ -1,4 +1,4 @@
-/* Copyright 2020 The Chromium OS Authors. All rights reserved.
+/* Copyright 2020 The ChromiumOS Authors
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
@@ -7,6 +7,6 @@
#define __CROS_EC_LINKER_H
/* Put the start of shared memory after all allocated RAM symbols */
-#define __shared_mem_buf _image_ram_end
+#define __shared_mem_buf _image_ram_end
#endif
diff --git a/zephyr/shim/include/motionsense_sensors.h b/zephyr/shim/include/motionsense_sensors.h
index f3bd6befe0..e00eae426e 100644
--- a/zephyr/shim/include/motionsense_sensors.h
+++ b/zephyr/shim/include/motionsense_sensors.h
@@ -1,4 +1,4 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
+/* Copyright 2021 The ChromiumOS Authors
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
@@ -14,14 +14,14 @@ extern struct motion_sensor_t motion_sensors_alt[];
/*
* Common macros.
*/
-#define SENSOR_ROT_STD_REF_NAME(id) DT_CAT(ROT_REF_, id)
-#define SENSOR_ROT_REF_NODE DT_PATH(motionsense_rotation_ref)
+#define SENSOR_ROT_STD_REF_NAME(id) DT_CAT(ROT_REF_, id)
+#define SENSOR_ROT_REF_NODE DT_PATH(motionsense_rotation_ref)
/*
* Declare rotation parameters, since they may be
* dynamically selected.
*/
-#define DECLARE_EXTERN_SENSOR_ROT_REF(id) \
+#define DECLARE_EXTERN_SENSOR_ROT_REF(id) \
extern const mat33_fp_t SENSOR_ROT_STD_REF_NAME(id);
#if DT_NODE_EXISTS(SENSOR_ROT_REF_NODE)
@@ -45,18 +45,18 @@ int motion_sense_probe(enum sensor_alt_id alt_idx);
*/
void motion_sensors_check_ssfc(void);
-#define ENABLE_ALT_MOTION_SENSOR(alt_id) \
+#define ENABLE_ALT_MOTION_SENSOR(alt_id) \
motion_sensors[SENSOR_ID(DT_PHANDLE(alt_id, alternate_for))] = \
motion_sensors_alt[SENSOR_ID(alt_id)];
/*
* Replaces a default motion sensor with an alternate one pointed by nodelabel.
*/
-#define MOTIONSENSE_ENABLE_ALTERNATE(nodelabel) \
- do { \
- BUILD_ASSERT(DT_NODE_EXISTS(DT_NODELABEL(nodelabel)), \
- "Motionsense alternate node does not exist"); \
- ENABLE_ALT_MOTION_SENSOR(DT_NODELABEL(nodelabel)); \
+#define MOTIONSENSE_ENABLE_ALTERNATE(nodelabel) \
+ do { \
+ BUILD_ASSERT(DT_NODE_EXISTS(DT_NODELABEL(nodelabel)), \
+ "Motionsense alternate node does not exist"); \
+ ENABLE_ALT_MOTION_SENSOR(DT_NODELABEL(nodelabel)); \
} while (0)
/*
diff --git a/zephyr/shim/include/motionsense_sensors_defs.h b/zephyr/shim/include/motionsense_sensors_defs.h
index a9535d3b5d..ac0fc6bf56 100644
--- a/zephyr/shim/include/motionsense_sensors_defs.h
+++ b/zephyr/shim/include/motionsense_sensors_defs.h
@@ -1,4 +1,4 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
+/* Copyright 2021 The ChromiumOS Authors
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
@@ -10,7 +10,7 @@
#include "common.h"
-#define SENSOR_ID(id) DT_CAT(SENSOR_, id)
+#define SENSOR_ID(id) DT_CAT(SENSOR_, id)
/* Define the SENSOR_ID if:
* DT_NODE_HAS_STATUS(id, okay) && !DT_NODE_HAS_PROP(id, alternate_for)
@@ -24,7 +24,7 @@ enum sensor_id {
#if DT_NODE_EXISTS(SENSOR_NODE)
DT_FOREACH_CHILD(SENSOR_NODE, SENSOR_ID_WITH_COMMA)
#endif
- SENSOR_COUNT,
+ SENSOR_COUNT,
};
#undef SENSOR_ID_WITH_COMMA
@@ -39,7 +39,7 @@ enum sensor_alt_id {
#if DT_NODE_EXISTS(SENSOR_ALT_NODE)
DT_FOREACH_CHILD(SENSOR_ALT_NODE, SENSOR_ID_WITH_COMMA)
#endif
- SENSOR_ALT_COUNT,
+ SENSOR_ALT_COUNT,
};
/*
@@ -73,8 +73,8 @@ enum sensor_alt_id {
* };
*/
#ifdef CONFIG_LID_ANGLE
-#define CONFIG_LID_ANGLE_SENSOR_LID SENSOR_ID(DT_NODELABEL(lid_accel))
-#define CONFIG_LID_ANGLE_SENSOR_BASE SENSOR_ID(DT_NODELABEL(base_accel))
+#define CONFIG_LID_ANGLE_SENSOR_LID SENSOR_ID(DT_NODELABEL(lid_accel))
+#define CONFIG_LID_ANGLE_SENSOR_BASE SENSOR_ID(DT_NODELABEL(base_accel))
#endif
/*
@@ -90,12 +90,11 @@ enum sensor_alt_id {
* };
*/
#if DT_NODE_HAS_PROP(SENSOR_INFO_NODE, accel_force_mode_sensors)
-#define SENSOR_IN_FORCE_MODE(i, id) \
+#define SENSOR_IN_FORCE_MODE(i, id) \
| BIT(SENSOR_ID(DT_PHANDLE_BY_IDX(id, accel_force_mode_sensors, i)))
-#define CONFIG_ACCEL_FORCE_MODE_MASK \
- (0 LISTIFY(DT_PROP_LEN(SENSOR_INFO_NODE, \
- accel_force_mode_sensors), SENSOR_IN_FORCE_MODE, (), \
- SENSOR_INFO_NODE))
+#define CONFIG_ACCEL_FORCE_MODE_MASK \
+ (0 LISTIFY(DT_PROP_LEN(SENSOR_INFO_NODE, accel_force_mode_sensors), \
+ SENSOR_IN_FORCE_MODE, (), SENSOR_INFO_NODE))
#endif
#endif /* __CROS_EC_MOTIONSENSE_SENSORS_DEFS_H */
diff --git a/zephyr/shim/include/mpu.h b/zephyr/shim/include/mpu.h
index 3555ef0db1..29771c9fe0 100644
--- a/zephyr/shim/include/mpu.h
+++ b/zephyr/shim/include/mpu.h
@@ -1,4 +1,4 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
+/* Copyright 2021 The ChromiumOS Authors
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
diff --git a/zephyr/shim/include/power/power.h b/zephyr/shim/include/power/power.h
index 6ea2444705..1e780646af 100644
--- a/zephyr/shim/include/power/power.h
+++ b/zephyr/shim/include/power/power.h
@@ -1,4 +1,4 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
+/* Copyright 2021 The ChromiumOS Authors
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
@@ -9,63 +9,36 @@
#include <zephyr/devicetree.h>
#include <zephyr/drivers/gpio.h>
-#define POWER_SIGNAL_LIST_NODE \
- DT_NODELABEL(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)
+#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 \
- )
-#define GEN_POWER_SIGNAL_ENUM_ENTRY_COMMA(cid) \
- GEN_POWER_SIGNAL_ENUM_ENTRY(cid),
+#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)
enum power_signal {
- DT_FOREACH_CHILD(
- POWER_SIGNAL_LIST_NODE,
- GEN_POWER_SIGNAL_ENUM_ENTRY_COMMA)
+ DT_FOREACH_CHILD_SEP(POWER_SIGNAL_LIST_NODE,
+ GEN_POWER_SIGNAL_ENUM_ENTRY, (, )),
POWER_SIGNAL_COUNT
};
@@ -73,11 +46,8 @@ enum power_signal {
* 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 \
- )
+#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/include/power_host_sleep.h b/zephyr/shim/include/power_host_sleep.h
index cc7fe04847..8bc23fc785 100644
--- a/zephyr/shim/include/power_host_sleep.h
+++ b/zephyr/shim/include/power_host_sleep.h
@@ -1,4 +1,4 @@
-/* Copyright 2022 The Chromium OS Authors. All rights reserved.
+/* 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.
*/
@@ -24,31 +24,31 @@
/* power.h */
enum power_state {
/* Steady states */
- POWER_G3 = 0, /*
- * System is off (not technically all the way into G3,
- * which means totally unpowered...)
- */
- POWER_S5, /* System is soft-off */
- POWER_S4, /* System is suspended to disk */
- POWER_S3, /* Suspend; RAM on, processor is asleep */
- POWER_S0, /* System is on */
+ POWER_G3 = 0, /*
+ * System is off (not technically all the way into G3,
+ * which means totally unpowered...)
+ */
+ POWER_S5, /* System is soft-off */
+ POWER_S4, /* System is suspended to disk */
+ POWER_S3, /* Suspend; RAM on, processor is asleep */
+ POWER_S0, /* System is on */
#if CONFIG_AP_PWRSEQ_S0IX
POWER_S0ix,
#endif
/* Transitions */
- POWER_G3S5, /* G3 -> S5 (at system init time) */
- POWER_S5S3, /* S5 -> S3 (skips S4 on non-Intel systems) */
- POWER_S3S0, /* S3 -> S0 */
- POWER_S0S3, /* S0 -> S3 */
- POWER_S3S5, /* S3 -> S5 (skips S4 on non-Intel systems) */
- POWER_S5G3, /* S5 -> G3 */
- POWER_S3S4, /* S3 -> S4 */
- POWER_S4S3, /* S4 -> S3 */
- POWER_S4S5, /* S4 -> S5 */
- POWER_S5S4, /* S5 -> S4 */
+ POWER_G3S5, /* G3 -> S5 (at system init time) */
+ POWER_S5S3, /* S5 -> S3 (skips S4 on non-Intel systems) */
+ POWER_S3S0, /* S3 -> S0 */
+ POWER_S0S3, /* S0 -> S3 */
+ POWER_S3S5, /* S3 -> S5 (skips S4 on non-Intel systems) */
+ POWER_S5G3, /* S5 -> G3 */
+ POWER_S3S4, /* S3 -> S4 */
+ POWER_S4S3, /* S4 -> S3 */
+ POWER_S4S5, /* S4 -> S5 */
+ POWER_S5S4, /* S5 -> S4 */
#if CONFIG_AP_PWRSEQ_S0IX
- POWER_S0ixS0, /* S0ix -> S0 */
- POWER_S0S0ix, /* S0 -> S0ix */
+ POWER_S0ixS0, /* S0ix -> S0 */
+ POWER_S0S0ix, /* S0 -> S0ix */
#endif
};
@@ -56,12 +56,11 @@ enum power_state {
/* Context to pass to a host sleep command handler. */
struct host_sleep_event_context {
uint32_t sleep_transitions; /* Number of sleep transitions observed */
- uint16_t sleep_timeout_ms; /* Timeout in milliseconds */
+ uint16_t sleep_timeout_ms; /* Timeout in milliseconds */
};
void ap_power_chipset_handle_host_sleep_event(
- enum host_sleep_event state,
- struct host_sleep_event_context *ctx);
+ enum host_sleep_event state, struct host_sleep_event_context *ctx);
void power_set_host_sleep_state(enum host_sleep_event state);
#endif /* CONFIG_AP_PWRSEQ_HOST_SLEEP */
diff --git a/zephyr/shim/include/registers.h b/zephyr/shim/include/registers.h
index b693733a21..f17b05f5f8 100644
--- a/zephyr/shim/include/registers.h
+++ b/zephyr/shim/include/registers.h
@@ -1,4 +1,4 @@
-/* Copyright 2020 The Chromium OS Authors. All rights reserved.
+/* Copyright 2020 The ChromiumOS Authors
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
diff --git a/zephyr/shim/include/shimmed_task_id.h b/zephyr/shim/include/shimmed_task_id.h
index 31df4daece..1a29acafdf 100644
--- a/zephyr/shim/include/shimmed_task_id.h
+++ b/zephyr/shim/include/shimmed_task_id.h
@@ -1,4 +1,4 @@
-/* Copyright 2020 The Chromium OS Authors. All rights reserved.
+/* Copyright 2020 The ChromiumOS Authors
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
@@ -14,14 +14,13 @@ typedef uint8_t task_id_t;
/*
* Bitmask of port enable bits, expanding to a value like `BIT(0) | BIT(2) | 0`.
*/
-#define PD_INT_SHARED_PORT_MASK ( \
- FOR_EACH_NONEMPTY_TERM(BIT, (|), \
- IF_ENABLED(CONFIG_PLATFORM_EC_USB_PD_PORT_0_SHARED, (0)), \
- IF_ENABLED(CONFIG_PLATFORM_EC_USB_PD_PORT_1_SHARED, (1)), \
- IF_ENABLED(CONFIG_PLATFORM_EC_USB_PD_PORT_2_SHARED, (2)), \
- IF_ENABLED(CONFIG_PLATFORM_EC_USB_PD_PORT_3_SHARED, (3)), \
- ) 0 \
-)
+#define PD_INT_SHARED_PORT_MASK \
+ (FOR_EACH_NONEMPTY_TERM( \
+ BIT, (|), \
+ IF_ENABLED(CONFIG_PLATFORM_EC_USB_PD_PORT_0_SHARED, (0)), \
+ IF_ENABLED(CONFIG_PLATFORM_EC_USB_PD_PORT_1_SHARED, (1)), \
+ IF_ENABLED(CONFIG_PLATFORM_EC_USB_PD_PORT_2_SHARED, (2)), \
+ IF_ENABLED(CONFIG_PLATFORM_EC_USB_PD_PORT_3_SHARED, (3)), ) 0)
/* Highest priority on bottom -- same as in platform/ec. */
enum {
@@ -29,10 +28,6 @@ enum {
EC_SYSWORKQ_PRIO = EC_TASK_PRIO_LOWEST,
EC_TASK_CHG_RAMP_PRIO,
EC_TASK_USB_CHG_PRIO,
- EC_TASK_USB_CHG_P0_PRIO,
- EC_TASK_USB_CHG_P1_PRIO,
- EC_TASK_USB_CHG_P2_PRIO,
- EC_TASK_USB_CHG_P3_PRIO,
EC_TASK_DPS_PRIO,
EC_TASK_CHARGER_PRIO,
EC_TASK_CHIPSET_PRIO,
@@ -64,104 +59,106 @@ enum {
* CONFIG_HAS_TEST_TASKS and not CONFIG_SHIMMED_TASKS.
*/
#ifdef CONFIG_SHIMMED_TASKS
-#define CROS_EC_TASK_LIST \
- COND_CODE_1(HAS_TASK_CHG_RAMP, \
- (CROS_EC_TASK(CHG_RAMP, chg_ramp_task, 0, \
- CONFIG_TASK_CHG_RAMP_STACK_SIZE, \
- EC_TASK_CHG_RAMP_PRIO)), ()) \
- COND_CODE_1(CONFIG_PLATFORM_EC_USB_CHARGER_SINGLE_TASK, \
- (CROS_EC_TASK(USB_CHG, usb_charger_task_shared, 0, \
- CONFIG_TASK_USB_CHG_STACK_SIZE, \
- EC_TASK_USB_CHG_PRIO)), ()) \
- COND_CODE_1(HAS_TASK_USB_CHG_P0, \
- (CROS_EC_TASK(USB_CHG_P0, usb_charger_task, 0, \
- CONFIG_TASK_USB_CHG_STACK_SIZE, \
- EC_TASK_USB_CHG_P0_PRIO)), ()) \
- COND_CODE_1(HAS_TASK_USB_CHG_P1, \
- (CROS_EC_TASK(USB_CHG_P1, usb_charger_task, 0, \
- CONFIG_TASK_USB_CHG_STACK_SIZE, \
- EC_TASK_USB_CHG_P1_PRIO)), ()) \
- COND_CODE_1(HAS_TASK_USB_CHG_P2, \
- (CROS_EC_TASK(USB_CHG_P2, usb_charger_task, 0, \
- CONFIG_TASK_USB_CHG_STACK_SIZE, \
- EC_TASK_USB_CHG_P2_PRIO)), ()) \
- COND_CODE_1(HAS_TASK_USB_CHG_P3, \
- (CROS_EC_TASK(USB_CHG_P3, usb_charger_task, 0, \
- CONFIG_TASK_USB_CHG_STACK_SIZE, \
- EC_TASK_USB_CHG_P3_PRIO)), ()) \
- COND_CODE_1(HAS_TASK_DPS, \
- (CROS_EC_TASK(DPS, dps_task, 0, \
- CONFIG_TASK_DPS_STACK_SIZE, \
- EC_TASK_DPS_PRIO)), ()) \
- COND_CODE_1(HAS_TASK_CHARGER, \
- (CROS_EC_TASK(CHARGER, charger_task, 0, \
- CONFIG_TASK_CHARGER_STACK_SIZE, \
- EC_TASK_CHARGER_PRIO)), ()) \
- COND_CODE_1(HAS_TASK_CHIPSET, \
- (CROS_EC_TASK(CHIPSET, chipset_task, 0, \
- CONFIG_TASK_CHIPSET_STACK_SIZE, \
- EC_TASK_CHIPSET_PRIO)), ()) \
- COND_CODE_1(HAS_TASK_MOTIONSENSE, \
- (CROS_EC_TASK(MOTIONSENSE, motion_sense_task, 0, \
- CONFIG_TASK_MOTIONSENSE_STACK_SIZE, \
- EC_TASK_MOTIONSENSE_PRIO)), ()) \
- IF_ENABLED(HAS_TASK_USB_MUX, \
- (CROS_EC_TASK(USB_MUX, usb_mux_task, 0, \
- CONFIG_TASK_USB_MUX_STACK_SIZE, \
- EC_TASK_USB_MUX_PRIO))) \
- COND_CODE_1(CONFIG_TASK_HOSTCMD_THREAD_DEDICATED, \
- (CROS_EC_TASK(HOSTCMD, host_command_task, 0, \
- CONFIG_TASK_HOSTCMD_STACK_SIZE, \
- EC_TASK_HOSTCMD_PRIO)), ()) \
- COND_CODE_1(HAS_TASK_KEYPROTO, \
- (CROS_EC_TASK(KEYPROTO, keyboard_protocol_task, 0, \
- CONFIG_TASK_KEYPROTO_STACK_SIZE, \
- EC_TASK_KEYPROTO_PRIO)), ()) \
- COND_CODE_1(HAS_TASK_POWERBTN, \
- (CROS_EC_TASK(POWERBTN, power_button_task, 0, \
- CONFIG_TASK_POWERBTN_STACK_SIZE, \
- EC_TASK_POWERBTN_PRIO)), ()) \
- COND_CODE_1(HAS_TASK_KEYSCAN, \
- (CROS_EC_TASK(KEYSCAN, keyboard_scan_task, 0, \
- CONFIG_TASK_KEYSCAN_STACK_SIZE, \
- EC_TASK_KEYSCAN_PRIO)), ()) \
- COND_CODE_1(HAS_TASK_PD_C0, \
- (CROS_EC_TASK(PD_C0, pd_task, 0, \
- CONFIG_TASK_PD_STACK_SIZE, \
- EC_TASK_PD_C0_PRIO)), ()) \
- COND_CODE_1(HAS_TASK_PD_C1, \
- (CROS_EC_TASK(PD_C1, pd_task, 0, \
- CONFIG_TASK_PD_STACK_SIZE, \
- EC_TASK_PD_C1_PRIO)), ()) \
- COND_CODE_1(HAS_TASK_PD_C2, \
- (CROS_EC_TASK(PD_C2, pd_task, 0, \
- CONFIG_TASK_PD_STACK_SIZE, \
- EC_TASK_PD_C2_PRIO)), ()) \
- COND_CODE_1(HAS_TASK_PD_C3, \
- (CROS_EC_TASK(PD_C3, pd_task, 0, \
- CONFIG_TASK_PD_STACK_SIZE, \
- EC_TASK_PD_C3_PRIO)), ()) \
- IF_ENABLED(CONFIG_HAS_TASK_PD_INT_SHARED, \
- (CROS_EC_TASK(PD_INT_SHARED, pd_shared_alert_task, \
- PD_INT_SHARED_PORT_MASK, \
- CONFIG_TASK_PD_INT_STACK_SIZE, \
- EC_TASK_PD_INT_SHARED_PRIO))) \
- COND_CODE_1(HAS_TASK_PD_INT_C0, \
- (CROS_EC_TASK(PD_INT_C0, pd_interrupt_handler_task, 0, \
- CONFIG_TASK_PD_INT_STACK_SIZE, \
- EC_TASK_PD_INT_C0_PRIO)), ()) \
- COND_CODE_1(HAS_TASK_PD_INT_C1, \
- (CROS_EC_TASK(PD_INT_C1, pd_interrupt_handler_task, 1, \
- CONFIG_TASK_PD_INT_STACK_SIZE, \
- EC_TASK_PD_INT_C1_PRIO)), ()) \
- COND_CODE_1(HAS_TASK_PD_INT_C2, \
- (CROS_EC_TASK(PD_INT_C2, pd_interrupt_handler_task, 2, \
- CONFIG_TASK_PD_INT_STACK_SIZE, \
- EC_TASK_PD_INT_C2_PRIO)), ()) \
- COND_CODE_1(HAS_TASK_PD_INT_C3, \
- (CROS_EC_TASK(PD_INT_C3, pd_interrupt_handler_task, 3, \
- CONFIG_TASK_PD_INT_STACK_SIZE, \
- EC_TASK_PD_INT_C3_PRIO)), ())
+#define CROS_EC_TASK_LIST \
+ COND_CODE_1(HAS_TASK_CHG_RAMP, \
+ (CROS_EC_TASK(CHG_RAMP, chg_ramp_task, 0, \
+ CONFIG_TASK_CHG_RAMP_STACK_SIZE, \
+ EC_TASK_CHG_RAMP_PRIO)), \
+ ()) \
+ COND_CODE_1(CONFIG_PLATFORM_EC_USB_CHARGER, \
+ (CROS_EC_TASK(USB_CHG, usb_charger_task_shared, 0, \
+ CONFIG_TASK_USB_CHG_STACK_SIZE, \
+ EC_TASK_USB_CHG_PRIO)), \
+ ()) \
+ COND_CODE_1(HAS_TASK_DPS, \
+ (CROS_EC_TASK(DPS, dps_task, 0, \
+ CONFIG_TASK_DPS_STACK_SIZE, \
+ EC_TASK_DPS_PRIO)), \
+ ()) \
+ COND_CODE_1(HAS_TASK_CHARGER, \
+ (CROS_EC_TASK(CHARGER, charger_task, 0, \
+ CONFIG_TASK_CHARGER_STACK_SIZE, \
+ EC_TASK_CHARGER_PRIO)), \
+ ()) \
+ COND_CODE_1(HAS_TASK_CHIPSET, \
+ (CROS_EC_TASK(CHIPSET, chipset_task, 0, \
+ CONFIG_TASK_CHIPSET_STACK_SIZE, \
+ EC_TASK_CHIPSET_PRIO)), \
+ ()) \
+ COND_CODE_1(HAS_TASK_MOTIONSENSE, \
+ (CROS_EC_TASK(MOTIONSENSE, motion_sense_task, 0, \
+ CONFIG_TASK_MOTIONSENSE_STACK_SIZE, \
+ EC_TASK_MOTIONSENSE_PRIO)), \
+ ()) \
+ IF_ENABLED(HAS_TASK_USB_MUX, \
+ (CROS_EC_TASK(USB_MUX, usb_mux_task, 0, \
+ CONFIG_TASK_USB_MUX_STACK_SIZE, \
+ EC_TASK_USB_MUX_PRIO))) \
+ COND_CODE_1(CONFIG_TASK_HOSTCMD_THREAD_DEDICATED, \
+ (CROS_EC_TASK(HOSTCMD, host_command_task, 0, \
+ CONFIG_TASK_HOSTCMD_STACK_SIZE, \
+ EC_TASK_HOSTCMD_PRIO)), \
+ ()) \
+ COND_CODE_1(HAS_TASK_KEYPROTO, \
+ (CROS_EC_TASK(KEYPROTO, keyboard_protocol_task, 0, \
+ CONFIG_TASK_KEYPROTO_STACK_SIZE, \
+ EC_TASK_KEYPROTO_PRIO)), \
+ ()) \
+ COND_CODE_1(HAS_TASK_POWERBTN, \
+ (CROS_EC_TASK(POWERBTN, power_button_task, 0, \
+ CONFIG_TASK_POWERBTN_STACK_SIZE, \
+ EC_TASK_POWERBTN_PRIO)), \
+ ()) \
+ COND_CODE_1(HAS_TASK_KEYSCAN, \
+ (CROS_EC_TASK(KEYSCAN, keyboard_scan_task, 0, \
+ CONFIG_TASK_KEYSCAN_STACK_SIZE, \
+ EC_TASK_KEYSCAN_PRIO)), \
+ ()) \
+ COND_CODE_1(HAS_TASK_PD_C0, \
+ (CROS_EC_TASK(PD_C0, pd_task, 0, \
+ CONFIG_TASK_PD_STACK_SIZE, \
+ EC_TASK_PD_C0_PRIO)), \
+ ()) \
+ COND_CODE_1(HAS_TASK_PD_C1, \
+ (CROS_EC_TASK(PD_C1, pd_task, 0, \
+ CONFIG_TASK_PD_STACK_SIZE, \
+ EC_TASK_PD_C1_PRIO)), \
+ ()) \
+ COND_CODE_1(HAS_TASK_PD_C2, \
+ (CROS_EC_TASK(PD_C2, pd_task, 0, \
+ CONFIG_TASK_PD_STACK_SIZE, \
+ EC_TASK_PD_C2_PRIO)), \
+ ()) \
+ COND_CODE_1(HAS_TASK_PD_C3, \
+ (CROS_EC_TASK(PD_C3, pd_task, 0, \
+ CONFIG_TASK_PD_STACK_SIZE, \
+ EC_TASK_PD_C3_PRIO)), \
+ ()) \
+ IF_ENABLED(CONFIG_HAS_TASK_PD_INT_SHARED, \
+ (CROS_EC_TASK(PD_INT_SHARED, pd_shared_alert_task, \
+ PD_INT_SHARED_PORT_MASK, \
+ CONFIG_TASK_PD_INT_STACK_SIZE, \
+ EC_TASK_PD_INT_SHARED_PRIO))) \
+ COND_CODE_1(HAS_TASK_PD_INT_C0, \
+ (CROS_EC_TASK(PD_INT_C0, pd_interrupt_handler_task, 0, \
+ CONFIG_TASK_PD_INT_STACK_SIZE, \
+ EC_TASK_PD_INT_C0_PRIO)), \
+ ()) \
+ COND_CODE_1(HAS_TASK_PD_INT_C1, \
+ (CROS_EC_TASK(PD_INT_C1, pd_interrupt_handler_task, 1, \
+ CONFIG_TASK_PD_INT_STACK_SIZE, \
+ EC_TASK_PD_INT_C1_PRIO)), \
+ ()) \
+ COND_CODE_1(HAS_TASK_PD_INT_C2, \
+ (CROS_EC_TASK(PD_INT_C2, pd_interrupt_handler_task, 2, \
+ CONFIG_TASK_PD_INT_STACK_SIZE, \
+ EC_TASK_PD_INT_C2_PRIO)), \
+ ()) \
+ COND_CODE_1(HAS_TASK_PD_INT_C3, \
+ (CROS_EC_TASK(PD_INT_C3, pd_interrupt_handler_task, 3, \
+ CONFIG_TASK_PD_INT_STACK_SIZE, \
+ EC_TASK_PD_INT_C3_PRIO)), \
+ ())
#elif defined(CONFIG_HAS_TEST_TASKS)
#include "shimmed_test_tasks.h"
/*
@@ -191,7 +188,7 @@ enum {
TASK_ID_IDLE = -1, /* We don't shim the idle task */
CROS_EC_TASK_LIST
#ifdef TEST_BUILD
- TASK_ID_TEST_RUNNER,
+ TASK_ID_TEST_RUNNER,
#endif
TASK_ID_COUNT,
TASK_ID_INVALID = 0xff, /* Unable to find the task */
@@ -203,20 +200,17 @@ enum {
* Additional task IDs for features that runs on non shimmed threads,
* task_get_current() needs to be updated to identify these ones.
*/
-#define CROS_EC_EXTRA_TASKS(fn) \
+#define CROS_EC_EXTRA_TASKS(fn) \
COND_CODE_1(CONFIG_TASK_HOSTCMD_THREAD_MAIN, (fn(HOSTCMD)), ()) \
fn(SYSWORKQ)
#define EXTRA_TASK_INTERNAL_ID(name) EXTRA_TASK_##name,
enum {
- CROS_EC_EXTRA_TASKS(EXTRA_TASK_INTERNAL_ID)
- EXTRA_TASK_COUNT,
+ CROS_EC_EXTRA_TASKS(EXTRA_TASK_INTERNAL_ID) EXTRA_TASK_COUNT,
};
#define EXTRA_TASK_ID(name) \
TASK_ID_##name = (TASK_ID_COUNT + EXTRA_TASK_##name),
-enum {
- CROS_EC_EXTRA_TASKS(EXTRA_TASK_ID)
-};
+enum { CROS_EC_EXTRA_TASKS(EXTRA_TASK_ID) };
#endif /* __CROS_EC_SHIMMED_TASK_ID_H */
diff --git a/zephyr/shim/include/shimmed_tasks.h b/zephyr/shim/include/shimmed_tasks.h
index d1fb6129d3..75be968f4a 100644
--- a/zephyr/shim/include/shimmed_tasks.h
+++ b/zephyr/shim/include/shimmed_tasks.h
@@ -1,4 +1,4 @@
-/* Copyright 2020 The Chromium OS Authors. All rights reserved.
+/* Copyright 2020 The ChromiumOS Authors
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
diff --git a/zephyr/shim/include/temp_sensor/temp_sensor.h b/zephyr/shim/include/temp_sensor/temp_sensor.h
index 2c6eabe485..9be18987eb 100644
--- a/zephyr/shim/include/temp_sensor/temp_sensor.h
+++ b/zephyr/shim/include/temp_sensor/temp_sensor.h
@@ -1,4 +1,4 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
+/* Copyright 2021 The ChromiumOS Authors
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
@@ -8,53 +8,134 @@
#include <zephyr/devicetree.h>
#include "include/temp_sensor.h"
+#include "charger/chg_rt9490.h"
#ifdef CONFIG_PLATFORM_EC_TEMP_SENSOR
-#define ZSHIM_TEMP_SENSOR_ID(node_id) DT_STRING_UPPER_TOKEN(node_id, enum_name)
-#define TEMP_SENSOR_ID_WITH_COMMA(node_id) ZSHIM_TEMP_SENSOR_ID(node_id),
+#define PCT2075_COMPAT nxp_pct2075
+#define TMP112_COMPAT cros_ec_temp_sensor_tmp112
+#define SB_TSI_COMPAT amd_sb_tsi
+#define THERMISTOR_COMPAT cros_ec_temp_sensor_thermistor
+#define TEMP_SENSORS_COMPAT cros_ec_temp_sensors
+
+#define TEMP_SENSORS_NODEID DT_INST(0, TEMP_SENSORS_COMPAT)
+
+#define TEMP_RT9490_FN(node_id, fn) \
+ COND_CODE_1(DT_NODE_HAS_PROP(node_id, thermistor), (fn(node_id)), ())
+
+#define FOREACH_TEMP_SENSOR(fn) \
+ DT_FOREACH_STATUS_OKAY(PCT2075_COMPAT, fn) \
+ DT_FOREACH_STATUS_OKAY(TMP112_COMPAT, fn) \
+ DT_FOREACH_STATUS_OKAY_VARGS(RT9490_CHG_COMPAT, TEMP_RT9490_FN, fn) \
+ DT_FOREACH_STATUS_OKAY(SB_TSI_COMPAT, fn) \
+ DT_FOREACH_STATUS_OKAY(THERMISTOR_COMPAT, fn)
#define HAS_POWER_GOOD_PIN(node_id) DT_NODE_HAS_PROP(node_id, power_good_pin) ||
-#define ANY_INST_HAS_POWER_GOOD_PIN \
- (DT_FOREACH_STATUS_OKAY(cros_ec_temp_sensor, HAS_POWER_GOOD_PIN) \
- 0)
+
+#define ANY_INST_HAS_POWER_GOOD_PIN \
+ (DT_FOREACH_CHILD(TEMP_SENSORS_NODEID, HAS_POWER_GOOD_PIN) 0)
+
+/*
+ * Get the enum temp_sensor_id value from a child node under
+ * "cros-ec,temp-sensors".
+ *
+ * Example devicetree fragment:
+ *
+ * temp_charger_thermistor: charger-thermistor {
+ * compatible = "cros-ec,temp-sensor-thermistor";
+ * thermistor = <&thermistor_3V3_30K9_47K_4050B>;
+ * adc = <&adc_temp_charger>;
+ * };
+ *
+ * named-temp-sensors {
+ * compatible = "cros-ec,temp-sensors";
+ * temp_charger: charger-thermistor {
+ * temp_host_high = <100>;
+ * temp_host_halt = <105>;
+ * temp_host_release_high = <80>;
+ * sensor = <&temp_charger_thermistor>;
+ * };
+ * };
+ *
+ * Example usage to get the temperature sensor ID:
+ *
+ * TEMP_SENSOR_ID(DT_NODELABEL(temp_charger))
+ *
+ * @param node_id: node id of a child of "cros-ec,temp-sensors" node
+ */
+#define TEMP_SENSOR_ID(node_id) DT_CAT(TEMP_SENSOR_, node_id)
+
+/*
+ * Get the enum temp_sensor_id value from a hardware device node.
+ *
+ * Example devicetree fragment:
+ *
+ * temp_charger_thermistor: charger-thermistor {
+ * compatible = "cros-ec,temp-sensor-thermistor";
+ * thermistor = <&thermistor_3V3_30K9_47K_4050B>;
+ * adc = <&adc_temp_charger>;
+ * };
+ *
+ * named-temp-sensors {
+ * compatible = "cros-ec,temp-sensors";
+ * temp_charger: charger-thermistor {
+ * temp_host_high = <100>;
+ * temp_host_halt = <105>;
+ * temp_host_release_high = <80>;
+ * sensor = <&temp_charger_thermistor>;
+ * };
+ * };
+ *
+ * Example usage to get the temperature sensor ID:
+ *
+ * TEMP_SENSOR_ID_BY_DEV(DT_NODELABEL(temp_charger_thermistor))
+ *
+ * which equals:
+ *
+ * TEMP_SENSOR_ID(DT_NODELABEL(temp_charger))
+ *
+ * @param node_id: node id of a hardware device node
+ */
+#define TEMP_SENSOR_ID_BY_DEV(node_id) DT_CAT(TEMP_SENSOR_DEV, node_id)
+
+#define TEMP_SENSOR_ID_DEV(named_id) \
+ TEMP_SENSOR_ID_BY_DEV(DT_PHANDLE(named_id, sensor)) = \
+ TEMP_SENSOR_ID(named_id)
enum temp_sensor_id {
-#if DT_NODE_EXISTS(DT_PATH(named_temp_sensors))
- DT_FOREACH_CHILD(DT_PATH(named_temp_sensors),
- TEMP_SENSOR_ID_WITH_COMMA)
-#endif /* named_temp_sensors */
- TEMP_SENSOR_COUNT
+ DT_FOREACH_CHILD_SEP(TEMP_SENSORS_NODEID, TEMP_SENSOR_ID, (, )),
+ DT_FOREACH_CHILD_SEP(TEMP_SENSORS_NODEID, TEMP_SENSOR_ID_DEV, (, )),
+ TEMP_SENSOR_COUNT,
};
-#undef TEMP_SENSOR_ID_WITH_COMMA
-
/* PCT2075 access array */
-#define ZSHIM_PCT2075_SENSOR_ID(node_id) DT_STRING_UPPER_TOKEN(node_id, \
- pct2075_name)
-#define PCT2075_SENSOR_ID_WITH_COMMA(node_id) ZSHIM_PCT2075_SENSOR_ID(node_id),
+/*
+ * Get the PCT2075 sensor ID from a hardware device node.
+ *
+ * @param node_id: node id of a hardware PCT2075 sensor node
+ */
+#define PCT2075_SENSOR_ID(node_id) DT_CAT(PCT2075_, node_id)
+#define PCT2075_SENSOR_ID_WITH_COMMA(node_id) PCT2075_SENSOR_ID(node_id),
enum pct2075_sensor {
-#if DT_HAS_COMPAT_STATUS_OKAY(cros_ec_temp_sensor_pct2075)
- DT_FOREACH_STATUS_OKAY(cros_ec_temp_sensor_pct2075,
- PCT2075_SENSOR_ID_WITH_COMMA)
-#endif
- PCT2075_COUNT,
+ DT_FOREACH_STATUS_OKAY(PCT2075_COMPAT, PCT2075_SENSOR_ID_WITH_COMMA)
+ PCT2075_COUNT,
};
#undef PCT2075_SENSOR_ID_WITH_COMMA
/* TMP112 access array */
-#define ZSHIM_TMP112_SENSOR_ID(node_id) DT_STRING_UPPER_TOKEN(node_id, \
- tmp112_name)
-#define TMP112_SENSOR_ID_WITH_COMMA(node_id) ZSHIM_TMP112_SENSOR_ID(node_id),
+/*
+ * Get the TMP112 sensor ID from a hardware device node.
+ *
+ * @param node_id: node id of a hardware TMP112 sensor node
+ */
+#define TMP112_SENSOR_ID(node_id) DT_CAT(TMP112_, node_id)
+#define TMP112_SENSOR_ID_WITH_COMMA(node_id) TMP112_SENSOR_ID(node_id),
enum tmp112_sensor {
-#if DT_HAS_COMPAT_STATUS_OKAY(cros_ec_temp_sensor_tmp112)
- DT_FOREACH_STATUS_OKAY(cros_ec_temp_sensor_tmp112,
- TMP112_SENSOR_ID_WITH_COMMA)
-#endif
- TMP112_COUNT,
+ DT_FOREACH_STATUS_OKAY(TMP112_COMPAT, TMP112_SENSOR_ID_WITH_COMMA)
+ TMP112_COUNT,
};
#undef TMP112_SENSOR_ID_WITH_COMMA
@@ -62,11 +143,11 @@ 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);
- struct thermistor_info *thermistor;
+ const struct thermistor_info *thermistor;
#if ANY_INST_HAS_POWER_GOOD_PIN
const struct device *power_good_dev;
gpio_pin_t power_good_pin;
-#endif
+#endif /* ANY_INST_HAS_POWER_GOOD_PIN */
};
#endif /* CONFIG_PLATFORM_EC_TEMP_SENSOR */
diff --git a/zephyr/shim/include/usbc/amd_fp6_usb_mux.h b/zephyr/shim/include/usbc/amd_fp6_usb_mux.h
new file mode 100644
index 0000000000..a474a4eee4
--- /dev/null
+++ b/zephyr/shim/include/usbc/amd_fp6_usb_mux.h
@@ -0,0 +1,21 @@
+/* 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.
+ */
+
+#ifndef __ZEPHYR_SHIM_AMD_FP6_USB_MUX_H
+#define __ZEPHYR_SHIM_AMD_FP6_USB_MUX_H
+
+#include "usb_mux.h"
+
+#define AMD_FP6_USB_MUX_COMPAT amd_usbc_mux_amd_fp6
+
+#define USB_MUX_CONFIG_AMD_FP6(mux_id) \
+ { \
+ USB_MUX_COMMON_FIELDS(mux_id), \
+ .driver = &amd_fp6_usb_mux_driver, \
+ .i2c_port = I2C_PORT_BY_DEV(mux_id), \
+ .i2c_addr_flags = DT_REG_ADDR(mux_id), \
+ }
+
+#endif /* __ZEPHYR_SHIM_AMD_FP6_USB_MUX_H */
diff --git a/zephyr/shim/include/usbc/anx7447_usb_mux.h b/zephyr/shim/include/usbc/anx7447_usb_mux.h
new file mode 100644
index 0000000000..874958c04c
--- /dev/null
+++ b/zephyr/shim/include/usbc/anx7447_usb_mux.h
@@ -0,0 +1,22 @@
+/* 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.
+ */
+
+#ifndef __ZEPHYR_SHIM_ANX7447_USB_MUX_H
+#define __ZEPHYR_SHIM_ANX7447_USB_MUX_H
+
+#include "tcpm/anx7447_public.h"
+
+#define ANX7447_USB_MUX_COMPAT analogix_usbc_mux_anx7447
+
+#define USB_MUX_CONFIG_ANX7447(mux_id) \
+ { \
+ USB_MUX_COMMON_FIELDS(mux_id), \
+ .driver = &anx7447_usb_mux_driver, \
+ .hpd_update = COND_CODE_1( \
+ DT_PROP(mux_id, hpd_update_enable), \
+ (&anx7447_tcpc_update_hpd_status), (NULL)), \
+ }
+
+#endif /* __ZEPHYR_SHIM_ANX7447_USB_MUX_H */
diff --git a/zephyr/shim/include/usbc/anx7483_usb_mux.h b/zephyr/shim/include/usbc/anx7483_usb_mux.h
index 606928b016..5e56837e3a 100644
--- a/zephyr/shim/include/usbc/anx7483_usb_mux.h
+++ b/zephyr/shim/include/usbc/anx7483_usb_mux.h
@@ -1,4 +1,4 @@
-/* Copyright 2022 The Chromium OS Authors. All rights reserved.
+/* 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.
*/
@@ -8,15 +8,14 @@
#include "driver/retimer/anx7483_public.h"
-#define ANX7483_USB_MUX_COMPAT analogix_anx7483
+#define ANX7483_USB_MUX_COMPAT analogix_anx7483
-#define USB_MUX_CONFIG_ANX7483(mux_id, port_id, idx) \
- { \
- USB_MUX_COMMON_FIELDS(mux_id, port_id, idx), \
- .driver = &anx7483_usb_retimer_driver, \
- .i2c_port = I2C_PORT(DT_PHANDLE(mux_id, port)), \
- .i2c_addr_flags = \
- DT_STRING_UPPER_TOKEN(mux_id, i2c_addr_flags), \
+#define USB_MUX_CONFIG_ANX7483(mux_id) \
+ { \
+ USB_MUX_COMMON_FIELDS(mux_id), \
+ .driver = &anx7483_usb_retimer_driver, \
+ .i2c_port = I2C_PORT_BY_DEV(mux_id), \
+ .i2c_addr_flags = DT_REG_ADDR(mux_id), \
}
#endif /* __ZEPHYR_SHIM_ANX7483_USB_MUX_H */
diff --git a/zephyr/shim/include/usbc/bb_retimer_usb_mux.h b/zephyr/shim/include/usbc/bb_retimer_usb_mux.h
index 611c52e081..64e1e2693d 100644
--- a/zephyr/shim/include/usbc/bb_retimer_usb_mux.h
+++ b/zephyr/shim/include/usbc/bb_retimer_usb_mux.h
@@ -1,4 +1,4 @@
-/* Copyright 2022 The Chromium OS Authors. All rights reserved.
+/* 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.
*/
@@ -10,23 +10,100 @@
#define BB_RETIMER_USB_MUX_COMPAT intel_jhl8040r
-#define USB_MUX_CONFIG_BB_RETIMER(mux_id, port_id, idx) \
- { \
- USB_MUX_COMMON_FIELDS(mux_id, port_id, idx), \
- .driver = &bb_usb_retimer, \
- .hpd_update = bb_retimer_hpd_update, \
- .i2c_port = I2C_PORT(DT_PHANDLE(mux_id, port)), \
- .i2c_addr_flags = DT_PROP(mux_id, i2c_addr_flags), \
+#define USB_MUX_CONFIG_BB_RETIMER(mux_id) \
+ { \
+ USB_MUX_COMMON_FIELDS(mux_id), \
+ .driver = &bb_usb_retimer, \
+ .hpd_update = bb_retimer_hpd_update, \
+ .i2c_port = I2C_PORT_BY_DEV(mux_id), \
+ .i2c_addr_flags = DT_REG_ADDR(mux_id), \
}
-#define BB_RETIMER_CONTROLS_CONFIG(mux_id, port_id, idx) \
- { \
- .retimer_rst_gpio = \
- GPIO_SIGNAL(DT_PHANDLE(mux_id, reset_pin)), \
- .usb_ls_en_gpio = COND_CODE_1( \
- DT_NODE_HAS_PROP(mux_id, ls_en_pin), \
- (GPIO_SIGNAL(DT_PHANDLE(mux_id, ls_en_pin))), \
- (GPIO_UNIMPLEMENTED)), \
+/**
+ * @brief Get reset gpio for @p mux_id retimer
+ *
+ * @param mux_id BB retimer DTS node
+ */
+#define BB_RETIMER_RESET_GPIO(mux_id) GPIO_SIGNAL(DT_PHANDLE(mux_id, reset_pin))
+
+/**
+ * @brief Get LS_EN gpio for @p mux_id retimer
+ *
+ * @param mux_id BB retimer DTS node
+ */
+#define BB_RETIMER_LS_EN_GPIO(mux_id) \
+ COND_CODE_1(DT_NODE_HAS_PROP(mux_id, ls_en_pin), \
+ (GPIO_SIGNAL(DT_PHANDLE(mux_id, ls_en_pin))), \
+ (GPIO_UNIMPLEMENTED))
+
+#define BB_RETIMER_CONTROLS_CONFIG(mux_id) \
+ { \
+ .retimer_rst_gpio = BB_RETIMER_RESET_GPIO(mux_id), \
+ .usb_ls_en_gpio = BB_RETIMER_LS_EN_GPIO(mux_id), \
}
+/**
+ * @brief Set entry in bb_controls array
+ *
+ * @param mux_id BB retimer node ID
+ */
+#define USB_MUX_BB_RETIMER_CONTROL_ARRAY(mux_id) \
+ [USB_MUX_PORT(mux_id)] = BB_RETIMER_CONTROLS_CONFIG(mux_id),
+
+/**
+ * @brief Call USB_MUX_BB_RETIMER_CONTROL_ARRAY for every BB retimer in DTS
+ */
+#define USB_MUX_BB_RETIMERS_CONTROLS_ARRAY \
+ DT_FOREACH_STATUS_OKAY(BB_RETIMER_USB_MUX_COMPAT, \
+ USB_MUX_BB_RETIMER_CONTROL_ARRAY)
+
+/**
+ * @brief Check if BB retimers @p id_1 and @p id_2 has matching configuration
+ * Configuration match if reset and ls_en pins are the same for muxes
+ * which are on the same USB-C port.
+ *
+ * @param id_1 First BB retimer DTS node
+ * @param id_2 Second BB retimer DTS node
+ */
+#define BB_RETIMER_CHECK_PAIR(id_1, id_2) \
+ BUILD_ASSERT(USB_MUX_PORT(id_1) != USB_MUX_PORT(id_2) || \
+ (BB_RETIMER_RESET_GPIO(id_1) == \
+ BB_RETIMER_RESET_GPIO(id_2) && \
+ BB_RETIMER_LS_EN_GPIO(id_1) == \
+ BB_RETIMER_LS_EN_GPIO(id_2)), \
+ "BB retimers " #id_1 " and " #id_2 " have different pin " \
+ "configuration and same USB-C port")
+
+/**
+ * @brief Check if BB retimers with @p inst instance number has matching
+ * configuration with muxes of higher instance number on @p bb_list list.
+ * Configuration match if reset and ls_en pins are the same for muxes
+ * which are on the same USB-C port.
+ *
+ * @param inst Instance number of BB retimer mux
+ * @param bb_list List of BB retimers in instance number order
+ */
+#define BB_RETIMER_CHECK_INSTANCE_WITH_LIST(inst, bb_list) \
+ FOR_EACH_FIXED_ARG(BB_RETIMER_CHECK_PAIR, (;), \
+ DT_INST(inst, BB_RETIMER_USB_MUX_COMPAT), \
+ GET_ARGS_LESS_N(inst, __DEBRACKET bb_list))
+
+/**
+ * @brief Check if BB retimers on the @p bb_list list have matching
+ * configurations (i.e. reset and ls_en pins are the same for muxes
+ * which are on the same USB-C port). This check is required, because
+ * USB_MUX_ENABLE_ALTERNATE() doesn't update bb_control[] array, so all
+ * BB retimers needs to use the same GPIO pins.
+ *
+ * @param bb_list List of BB retimers in instance number order
+ */
+#define BB_RETIMER_CHECK_SAME_CONTROLS(bb_list) \
+ LISTIFY(DT_NUM_INST_STATUS_OKAY(BB_RETIMER_USB_MUX_COMPAT), \
+ BB_RETIMER_CHECK_INSTANCE_WITH_LIST, (;), bb_list);
+
+/** List of all BB retimers in DTS in instance number order */
+#define BB_RETIMER_INSTANCES_LIST \
+ (LISTIFY(DT_NUM_INST_STATUS_OKAY(BB_RETIMER_USB_MUX_COMPAT), DT_INST, \
+ (, ), BB_RETIMER_USB_MUX_COMPAT))
+
#endif /* __ZEPHYR_SHIM_BB_RETIMER_USB_MUX_H */
diff --git a/zephyr/shim/include/usbc/bc12_pi3usb9201.h b/zephyr/shim/include/usbc/bc12_pi3usb9201.h
index 59b84cd868..701090133f 100644
--- a/zephyr/shim/include/usbc/bc12_pi3usb9201.h
+++ b/zephyr/shim/include/usbc/bc12_pi3usb9201.h
@@ -1,4 +1,4 @@
-/* Copyright 2022 The Chromium OS Authors. All rights reserved.
+/* 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.
*/
@@ -7,4 +7,7 @@
#define PI3USB9201_COMPAT pericom_pi3usb9201
-#define BC12_CHIP_PI3USB9201(id) { .drv = &pi3usb9201_drv, },
+#define BC12_CHIP_PI3USB9201(id) \
+ { \
+ .drv = &pi3usb9201_drv, \
+ },
diff --git a/zephyr/shim/include/usbc/bc12_rt1718s.h b/zephyr/shim/include/usbc/bc12_rt1718s.h
new file mode 100644
index 0000000000..e34f21c9e0
--- /dev/null
+++ b/zephyr/shim/include/usbc/bc12_rt1718s.h
@@ -0,0 +1,13 @@
+/* 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 "tcpm/rt1718s_public.h"
+
+#define RT1718S_BC12_COMPAT richtek_rt1718s_bc12
+
+#define BC12_CHIP_RT1718S(id) \
+ { \
+ .drv = &rt1718s_bc12_drv, \
+ },
diff --git a/zephyr/shim/include/usbc/bc12_rt1739.h b/zephyr/shim/include/usbc/bc12_rt1739.h
index 3347d7d717..8d7427b271 100644
--- a/zephyr/shim/include/usbc/bc12_rt1739.h
+++ b/zephyr/shim/include/usbc/bc12_rt1739.h
@@ -1,10 +1,13 @@
-/* Copyright 2022 The Chromium OS Authors. All rights reserved.
+/* 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/ppc/rt1739.h"
-#define RT1739_BC12_COMPAT richtek_rt1739_bc12
+#define RT1739_BC12_COMPAT richtek_rt1739
-#define BC12_CHIP_RT1739(id) { .drv = &rt1739_bc12_drv, },
+#define BC12_CHIP_RT1739(id) \
+ { \
+ .drv = &rt1739_bc12_drv, \
+ },
diff --git a/zephyr/shim/include/usbc/bc12_rt9490.h b/zephyr/shim/include/usbc/bc12_rt9490.h
index f9bc82f292..a9371ddeea 100644
--- a/zephyr/shim/include/usbc/bc12_rt9490.h
+++ b/zephyr/shim/include/usbc/bc12_rt9490.h
@@ -1,4 +1,4 @@
-/* Copyright 2022 The Chromium OS Authors. All rights reserved.
+/* 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.
*/
@@ -7,4 +7,7 @@
#define RT9490_BC12_COMPAT richtek_rt9490_bc12
-#define BC12_CHIP_RT9490(id) { .drv = &rt9490_bc12_drv, },
+#define BC12_CHIP_RT9490(id) \
+ { \
+ .drv = &rt9490_bc12_drv, \
+ },
diff --git a/zephyr/shim/include/usbc/it5205_usb_mux.h b/zephyr/shim/include/usbc/it5205_usb_mux.h
index 58412e0bd3..983248f3e2 100644
--- a/zephyr/shim/include/usbc/it5205_usb_mux.h
+++ b/zephyr/shim/include/usbc/it5205_usb_mux.h
@@ -1,4 +1,4 @@
-/* Copyright 2022 The Chromium OS Authors. All rights reserved.
+/* 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.
*/
@@ -8,15 +8,14 @@
#include "usb_mux/it5205_public.h"
-#define IT5205_USB_MUX_COMPAT ite_it5205
+#define IT5205_USB_MUX_COMPAT ite_it5205
-#define USB_MUX_CONFIG_IT5205(mux_id, port_id, idx) \
- { \
- USB_MUX_COMMON_FIELDS(mux_id, port_id, idx), \
- .driver = &it5205_usb_mux_driver, \
- .i2c_port = I2C_PORT(DT_PHANDLE(mux_id, port)), \
- .i2c_addr_flags = \
- DT_STRING_UPPER_TOKEN(mux_id, i2c_addr_flags), \
+#define USB_MUX_CONFIG_IT5205(mux_id) \
+ { \
+ USB_MUX_COMMON_FIELDS(mux_id), \
+ .driver = &it5205_usb_mux_driver, \
+ .i2c_port = I2C_PORT_BY_DEV(mux_id), \
+ .i2c_addr_flags = DT_REG_ADDR(mux_id), \
}
#endif /* __ZEPHYR_SHIM_IT5205_USB_MUX_H */
diff --git a/zephyr/shim/include/usbc/ppc.h b/zephyr/shim/include/usbc/ppc.h
index 94aee49f36..28e518a3ef 100644
--- a/zephyr/shim/include/usbc/ppc.h
+++ b/zephyr/shim/include/usbc/ppc.h
@@ -1,4 +1,4 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
+/* Copyright 2021 The ChromiumOS Authors
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
@@ -9,35 +9,30 @@
#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"
-#define PPC_ID(id) DT_CAT(PPC_, id)
-#define PPC_ID_WITH_COMMA(id) PPC_ID(id),
-#define PPC_ALT_FOR(alt_id) USBC_PORT(DT_PHANDLE(alt_id, alternate_for))
-
-#define PPC_ALT_ENUM(id) \
- COND_CODE_1(DT_NODE_HAS_PROP(id, alternate_for), \
- (PPC_ID_WITH_COMMA(id)), ())
-
-enum ppc_chips_alt_id {
- DT_FOREACH_STATUS_OKAY(RT1739_PPC_COMPAT, PPC_ALT_ENUM)
- DT_FOREACH_STATUS_OKAY(SN5S330_COMPAT, PPC_ALT_ENUM)
- DT_FOREACH_STATUS_OKAY(SYV682X_COMPAT, PPC_ALT_ENUM)
- PPC_CHIP_ALT_COUNT
-};
-
extern struct ppc_config_t ppc_chips_alt[];
-#define PPC_ENABLE_ALTERNATE(nodelabel) \
- do { \
- BUILD_ASSERT(DT_NODE_EXISTS(DT_NODELABEL(nodelabel)), \
- "PPC alternate node does not exist"); \
- memcpy(&ppc_chips[PPC_ALT_FOR(DT_NODELABEL(nodelabel))], \
- &ppc_chips_alt[PPC_ID(DT_NODELABEL(nodelabel))], \
- sizeof(struct ppc_config_t)); \
+#define ALT_PPC_CHIP_CHK(usbc_id, usb_port_num) \
+ COND_CODE_1(DT_REG_HAS_IDX(usbc_id, usb_port_num), \
+ (COND_CODE_1(DT_NODE_HAS_PROP(usbc_id, ppc_alt), (|| 1), \
+ (|| 0))), \
+ (|| 0))
+
+#define PPC_ENABLE_ALTERNATE(usb_port_num) \
+ do { \
+ BUILD_ASSERT( \
+ (0 DT_FOREACH_STATUS_OKAY_VARGS(named_usbc_port, \
+ ALT_PPC_CHIP_CHK, \
+ usb_port_num)), \
+ "Selected USB node does not exist or does not specify a PPC " \
+ "alternate chip"); \
+ memcpy(&ppc_chips[usb_port_num], &ppc_chips_alt[usb_port_num], \
+ sizeof(struct ppc_config_t)); \
} while (0)
#endif /* ZEPHYR_CHROME_USBC_PPC_H */
diff --git a/zephyr/shim/include/usbc/ppc_aoz1380.h b/zephyr/shim/include/usbc/ppc_aoz1380.h
new file mode 100644
index 0000000000..1ff20b802f
--- /dev/null
+++ b/zephyr/shim/include/usbc/ppc_aoz1380.h
@@ -0,0 +1,11 @@
+/* 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 "ppc/aoz1380_public.h"
+
+#define AOZ1380_COMPAT aoz_aoz1380
+
+/* Note: This chip has no i2c interface */
+#define PPC_CHIP_AOZ1380(id) { .drv = &aoz1380_drv },
diff --git a/zephyr/shim/include/usbc/ppc_nx20p348x.h b/zephyr/shim/include/usbc/ppc_nx20p348x.h
new file mode 100644
index 0000000000..2d36ab09f6
--- /dev/null
+++ b/zephyr/shim/include/usbc/ppc_nx20p348x.h
@@ -0,0 +1,13 @@
+/* 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 "ppc/nx20p348x_public.h"
+
+#define NX20P348X_COMPAT nxp_nx20p348x
+
+#define PPC_CHIP_NX20P348X(id) \
+ { .i2c_port = I2C_PORT_BY_DEV(id), \
+ .i2c_addr_flags = DT_REG_ADDR(id), \
+ .drv = &nx20p348x_drv },
diff --git a/zephyr/shim/include/usbc/ppc_rt1739.h b/zephyr/shim/include/usbc/ppc_rt1739.h
index 19e169a436..5b71b9ff9c 100644
--- a/zephyr/shim/include/usbc/ppc_rt1739.h
+++ b/zephyr/shim/include/usbc/ppc_rt1739.h
@@ -1,18 +1,18 @@
-/* Copyright 2022 The Chromium OS Authors. All rights reserved.
+/* 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/ppc/rt1739.h"
-#define RT1739_PPC_COMPAT richtek_rt1739_ppc
+#define RT1739_PPC_COMPAT richtek_rt1739
-#define PPC_CHIP_RT1739(id) \
- { \
- .i2c_port = I2C_PORT(DT_PHANDLE(id, port)), \
- .i2c_addr_flags = DT_STRING_UPPER_TOKEN(id, i2c_addr_flags), \
- .drv = &rt1739_ppc_drv, \
- .frs_en = COND_CODE_1(DT_NODE_HAS_PROP(id, irq), \
- (GPIO_SIGNAL(DT_PHANDLE(id, irq))), \
- (0)), \
+#define PPC_CHIP_RT1739(id) \
+ { \
+ .i2c_port = I2C_PORT_BY_DEV(id), \
+ .i2c_addr_flags = DT_REG_ADDR(id), \
+ .drv = &rt1739_ppc_drv, \
+ .frs_en = COND_CODE_1(DT_NODE_HAS_PROP(id, irq), \
+ (GPIO_SIGNAL(DT_PHANDLE(id, irq))), \
+ (0)), \
},
diff --git a/zephyr/shim/include/usbc/ppc_sn5s330.h b/zephyr/shim/include/usbc/ppc_sn5s330.h
index 1c48777107..ecbcb53deb 100644
--- a/zephyr/shim/include/usbc/ppc_sn5s330.h
+++ b/zephyr/shim/include/usbc/ppc_sn5s330.h
@@ -1,4 +1,4 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
+/* Copyright 2021 The ChromiumOS Authors
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
@@ -7,9 +7,7 @@
#define SN5S330_COMPAT ti_sn5s330
-#define PPC_CHIP_SN5S330(id) \
- { \
- .i2c_port = I2C_PORT(DT_PHANDLE(id, port)), \
- .i2c_addr_flags = DT_STRING_UPPER_TOKEN(id, i2c_addr_flags), \
- .drv = &sn5s330_drv \
- },
+#define PPC_CHIP_SN5S330(id) \
+ { .i2c_port = I2C_PORT_BY_DEV(id), \
+ .i2c_addr_flags = DT_REG_ADDR(id), \
+ .drv = &sn5s330_drv },
diff --git a/zephyr/shim/include/usbc/ppc_syv682x.h b/zephyr/shim/include/usbc/ppc_syv682x.h
index 1c2691f684..33813a5256 100644
--- a/zephyr/shim/include/usbc/ppc_syv682x.h
+++ b/zephyr/shim/include/usbc/ppc_syv682x.h
@@ -1,4 +1,4 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
+/* Copyright 2021 The ChromiumOS Authors
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
@@ -7,12 +7,12 @@
#define SYV682X_COMPAT silergy_syv682x
-#define PPC_CHIP_SYV682X(id) \
- { \
- .i2c_port = I2C_PORT(DT_PHANDLE(id, port)), \
- .i2c_addr_flags = DT_STRING_UPPER_TOKEN(id, i2c_addr_flags),\
- .drv = &syv682x_drv, \
- .frs_en = COND_CODE_1(DT_NODE_HAS_PROP(id, frs_en_gpio), \
- (GPIO_SIGNAL(DT_PHANDLE(id, frs_en_gpio))), \
- (0)), \
+#define PPC_CHIP_SYV682X(id) \
+ { \
+ .i2c_port = I2C_PORT_BY_DEV(id), \
+ .i2c_addr_flags = DT_REG_ADDR(id), \
+ .drv = &syv682x_drv, \
+ .frs_en = COND_CODE_1( \
+ DT_NODE_HAS_PROP(id, frs_en_gpio), \
+ (GPIO_SIGNAL(DT_PHANDLE(id, frs_en_gpio))), (0)), \
},
diff --git a/zephyr/shim/include/usbc/ps8743_usb_mux.h b/zephyr/shim/include/usbc/ps8743_usb_mux.h
new file mode 100644
index 0000000000..75ce778bac
--- /dev/null
+++ b/zephyr/shim/include/usbc/ps8743_usb_mux.h
@@ -0,0 +1,21 @@
+/* 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.
+ */
+
+#ifndef __ZEPHYR_SHIM_PS8743_USB_MUX_H
+#define __ZEPHYR_SHIM_PS8743_USB_MUX_H
+
+#include "usb_mux/ps8743_public.h"
+
+#define PS8743_USB_MUX_COMPAT parade_ps8743
+
+#define USB_MUX_CONFIG_PS8743(mux_id) \
+ { \
+ USB_MUX_COMMON_FIELDS(mux_id), \
+ .driver = &ps8743_usb_mux_driver, \
+ .i2c_port = I2C_PORT_BY_DEV(mux_id), \
+ .i2c_addr_flags = DT_REG_ADDR(mux_id), \
+ }
+
+#endif /* __ZEPHYR_SHIM_PS8743_USB_MUX_H */
diff --git a/zephyr/shim/include/usbc/ps8818_usb_mux.h b/zephyr/shim/include/usbc/ps8818_usb_mux.h
new file mode 100644
index 0000000000..c45e69aee3
--- /dev/null
+++ b/zephyr/shim/include/usbc/ps8818_usb_mux.h
@@ -0,0 +1,21 @@
+/* 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.
+ */
+
+#ifndef __ZEPHYR_SHIM_PS8818_USB_MUX_H
+#define __ZEPHYR_SHIM_PS8818_USB_MUX_H
+
+#include "driver/retimer/ps8818_public.h"
+
+#define PS8818_USB_MUX_COMPAT parade_ps8818
+
+#define USB_MUX_CONFIG_PS8818(mux_id) \
+ { \
+ USB_MUX_COMMON_FIELDS(mux_id), \
+ .driver = &ps8818_usb_retimer_driver, \
+ .i2c_port = I2C_PORT_BY_DEV(mux_id), \
+ .i2c_addr_flags = DT_REG_ADDR(mux_id), \
+ }
+
+#endif /* __ZEPHYR_SHIM_PS8818_USB_MUX_H */
diff --git a/zephyr/shim/include/usbc/tcpc_anx7447.h b/zephyr/shim/include/usbc/tcpc_anx7447.h
new file mode 100644
index 0000000000..7a59296e74
--- /dev/null
+++ b/zephyr/shim/include/usbc/tcpc_anx7447.h
@@ -0,0 +1,20 @@
+/* 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 "tcpm/anx7447_public.h"
+
+#define ANX7447_TCPC_COMPAT anologix_anx7447_tcpc
+
+#define TCPC_CONFIG_ANX7447(id) \
+ { \
+ .bus_type = EC_BUS_TYPE_I2C, \
+ .i2c_info = { \
+ .port = I2C_PORT_BY_DEV(id), \
+ .addr_flags = DT_REG_ADDR(id), \
+ }, \
+ .drv = &anx7447_tcpm_drv, \
+ .flags = DT_PROP(id, tcpc_flags), \
+ },
diff --git a/zephyr/shim/include/usbc/tcpc_ccgxxf.h b/zephyr/shim/include/usbc/tcpc_ccgxxf.h
index 566fed03d6..0c02cf6846 100644
--- a/zephyr/shim/include/usbc/tcpc_ccgxxf.h
+++ b/zephyr/shim/include/usbc/tcpc_ccgxxf.h
@@ -1,4 +1,4 @@
-/* Copyright 2022 The Chromium OS Authors. All rights reserved.
+/* 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.
*/
@@ -8,14 +8,13 @@
#define CCGXXF_TCPC_COMPAT cypress_ccgxxf
-#define TCPC_CONFIG_CCGXXF(id) \
- { \
- .bus_type = EC_BUS_TYPE_I2C, \
- .i2c_info = { \
- .port = I2C_PORT(DT_PHANDLE(id, port)), \
- .addr_flags = DT_STRING_UPPER_TOKEN( \
- id, i2c_addr_flags), \
- }, \
- .drv = &ccgxxf_tcpm_drv, \
- .flags = TCPC_FLAGS_TCPCI_REV2_0, \
+#define TCPC_CONFIG_CCGXXF(id) \
+ { \
+ .bus_type = EC_BUS_TYPE_I2C, \
+ .i2c_info = { \
+ .port = I2C_PORT_BY_DEV(id), \
+ .addr_flags = DT_REG_ADDR(id), \
+ }, \
+ .drv = &ccgxxf_tcpm_drv, \
+ .flags = TCPC_FLAGS_TCPCI_REV2_0, \
},
diff --git a/zephyr/shim/include/usbc/tcpc_fusb302.h b/zephyr/shim/include/usbc/tcpc_fusb302.h
index fefb54af7d..a2e512d938 100644
--- a/zephyr/shim/include/usbc/tcpc_fusb302.h
+++ b/zephyr/shim/include/usbc/tcpc_fusb302.h
@@ -1,4 +1,4 @@
-/* Copyright 2022 The Chromium OS Authors. All rights reserved.
+/* 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.
*/
@@ -8,13 +8,12 @@
#define FUSB302_TCPC_COMPAT fairchild_fusb302
-#define TCPC_CONFIG_FUSB302(id) \
- { \
- .bus_type = EC_BUS_TYPE_I2C, \
- .i2c_info = { \
- .port = I2C_PORT(DT_PHANDLE(id, port)), \
- .addr_flags = DT_STRING_UPPER_TOKEN( \
- id, i2c_addr_flags), \
- }, \
- .drv = &fusb302_tcpm_drv, \
+#define TCPC_CONFIG_FUSB302(id) \
+ { \
+ .bus_type = EC_BUS_TYPE_I2C, \
+ .i2c_info = { \
+ .port = I2C_PORT_BY_DEV(id), \
+ .addr_flags = DT_REG_ADDR(id), \
+ }, \
+ .drv = &fusb302_tcpm_drv, \
},
diff --git a/zephyr/shim/include/usbc/tcpc_generic_emul.h b/zephyr/shim/include/usbc/tcpc_generic_emul.h
new file mode 100644
index 0000000000..7dc46c51ba
--- /dev/null
+++ b/zephyr/shim/include/usbc/tcpc_generic_emul.h
@@ -0,0 +1,20 @@
+/* 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 "driver/tcpm/tcpci.h"
+
+#define TCPCI_EMUL_COMPAT cros_tcpci_generic_emul
+
+#define TCPC_CONFIG_TCPCI_EMUL(id) \
+ { \
+ .bus_type = EC_BUS_TYPE_I2C, \
+ .i2c_info = { \
+ .port = I2C_PORT_BY_DEV(id), \
+ .addr_flags = DT_REG_ADDR(id), \
+ }, \
+ .drv = &tcpci_tcpm_drv, \
+ },
diff --git a/zephyr/shim/include/usbc/tcpc_it8xxx2.h b/zephyr/shim/include/usbc/tcpc_it8xxx2.h
index be275441d8..c619656667 100644
--- a/zephyr/shim/include/usbc/tcpc_it8xxx2.h
+++ b/zephyr/shim/include/usbc/tcpc_it8xxx2.h
@@ -1,4 +1,4 @@
-/* Copyright 2022 The Chromium OS Authors. All rights reserved.
+/* 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.
*/
@@ -6,11 +6,11 @@
#include <zephyr/devicetree.h>
#include "driver/tcpm/it8xxx2_pd_public.h"
-#define IT8XXX2_TCPC_COMPAT ite_it8xxx2_tcpc
+#define IT8XXX2_TCPC_COMPAT ite_it8xxx2_usbpd
-#define TCPC_CONFIG_IT8XXX2(id) \
- { \
- .bus_type = EC_BUS_TYPE_EMBEDDED, \
- .drv = &it8xxx2_tcpm_drv, \
- .flags = 0, \
+#define TCPC_CONFIG_IT8XXX2(id) \
+ { \
+ .bus_type = EC_BUS_TYPE_EMBEDDED, \
+ .drv = &it8xxx2_tcpm_drv, \
+ .flags = 0, \
},
diff --git a/zephyr/shim/include/usbc/tcpc_nct38xx.h b/zephyr/shim/include/usbc/tcpc_nct38xx.h
index 87b222c794..87ba3379c8 100644
--- a/zephyr/shim/include/usbc/tcpc_nct38xx.h
+++ b/zephyr/shim/include/usbc/tcpc_nct38xx.h
@@ -1,4 +1,4 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
+/* Copyright 2021 The ChromiumOS Authors
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
@@ -11,16 +11,15 @@
#define NCT38XX_TCPC_COMPAT nuvoton_nct38xx
-#define TCPC_CONFIG_NCT38XX(id) \
- { \
- .bus_type = EC_BUS_TYPE_I2C, \
- .i2c_info = { \
- .port = I2C_PORT(DT_PHANDLE(id, port)), \
- .addr_flags = DT_STRING_UPPER_TOKEN( \
- id, i2c_addr_flags), \
- }, \
- .drv = &nct38xx_tcpm_drv, \
- .flags = DT_PROP(id, tcpc_flags), \
+#define TCPC_CONFIG_NCT38XX(id) \
+ { \
+ .bus_type = EC_BUS_TYPE_I2C, \
+ .i2c_info = { \
+ .port = I2C_PORT_BY_DEV(id), \
+ .addr_flags = DT_REG_ADDR(id), \
+ }, \
+ .drv = &nct38xx_tcpm_drv, \
+ .flags = DT_PROP(id, tcpc_flags), \
},
/**
diff --git a/zephyr/shim/include/usbc/tcpc_ps8xxx.h b/zephyr/shim/include/usbc/tcpc_ps8xxx.h
index d47f6cc9df..1a457af09b 100644
--- a/zephyr/shim/include/usbc/tcpc_ps8xxx.h
+++ b/zephyr/shim/include/usbc/tcpc_ps8xxx.h
@@ -1,4 +1,4 @@
-/* Copyright 2022 The Chromium OS Authors. All rights reserved.
+/* 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.
*/
@@ -8,14 +8,13 @@
#define PS8XXX_COMPAT parade_ps8xxx
-#define TCPC_CONFIG_PS8XXX(id) \
- { \
- .bus_type = EC_BUS_TYPE_I2C, \
- .i2c_info = { \
- .port = I2C_PORT(DT_PHANDLE(id, port)), \
- .addr_flags = DT_STRING_UPPER_TOKEN( \
- id, i2c_addr_flags), \
- }, \
- .drv = &ps8xxx_tcpm_drv, \
- .flags = DT_PROP(id, tcpc_flags), \
+#define TCPC_CONFIG_PS8XXX(id) \
+ { \
+ .bus_type = EC_BUS_TYPE_I2C, \
+ .i2c_info = { \
+ .port = I2C_PORT_BY_DEV(id), \
+ .addr_flags = DT_REG_ADDR(id), \
+ }, \
+ .drv = &ps8xxx_tcpm_drv, \
+ .flags = DT_PROP(id, tcpc_flags), \
},
diff --git a/zephyr/shim/include/usbc/tcpc_ps8xxx_emul.h b/zephyr/shim/include/usbc/tcpc_ps8xxx_emul.h
new file mode 100644
index 0000000000..fbd2e4bfd1
--- /dev/null
+++ b/zephyr/shim/include/usbc/tcpc_ps8xxx_emul.h
@@ -0,0 +1,19 @@
+/* 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 "driver/tcpm/ps8xxx_public.h"
+
+#define PS8XXX_EMUL_COMPAT cros_ps8xxx_emul
+
+#define TCPC_CONFIG_PS8XXX_EMUL(id) \
+ { \
+ .bus_type = EC_BUS_TYPE_I2C, \
+ .i2c_info = { \
+ .port = I2C_PORT_BY_DEV(id), \
+ .addr_flags = DT_REG_ADDR(id), \
+ }, \
+ .drv = &ps8xxx_tcpm_drv, \
+ },
diff --git a/zephyr/shim/include/usbc/tcpc_rt1718s.h b/zephyr/shim/include/usbc/tcpc_rt1718s.h
new file mode 100644
index 0000000000..794fb99480
--- /dev/null
+++ b/zephyr/shim/include/usbc/tcpc_rt1718s.h
@@ -0,0 +1,20 @@
+/* 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 "tcpm/rt1718s_public.h"
+
+#define RT1718S_TCPC_COMPAT richtek_rt1718s_tcpc
+
+#define TCPC_CONFIG_RT1718S(id) \
+ { \
+ .bus_type = EC_BUS_TYPE_I2C, \
+ .i2c_info = { \
+ .port = I2C_PORT_BY_DEV(id), \
+ .addr_flags = DT_REG_ADDR(id), \
+ }, \
+ .drv = &rt1718s_tcpm_drv, \
+ .flags = DT_PROP(id, tcpc_flags), \
+ },
diff --git a/zephyr/shim/include/usbc/tcpci.h b/zephyr/shim/include/usbc/tcpci.h
index 35f706d09b..67138dbe99 100644
--- a/zephyr/shim/include/usbc/tcpci.h
+++ b/zephyr/shim/include/usbc/tcpci.h
@@ -1,4 +1,4 @@
-/* Copyright 2022 The Chromium OS Authors. All rights reserved.
+/* 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.
*/
@@ -9,12 +9,12 @@
#define TCPCI_COMPAT cros_ec_tcpci
-#define TCPC_CONFIG_TCPCI(id) \
- { \
- .bus_type = EC_BUS_TYPE_I2C, \
- .i2c_info = { \
- .port = I2C_PORT(DT_PHANDLE(id, port)), \
- .addr_flags = DT_PROP(id, i2c_addr_flags), \
- }, \
- .drv = &tcpci_tcpm_drv, \
+#define TCPC_CONFIG_TCPCI(id) \
+ { \
+ .bus_type = EC_BUS_TYPE_I2C, \
+ .i2c_info = { \
+ .port = I2C_PORT_BY_DEV(id), \
+ .addr_flags = DT_REG_ADDR(id), \
+ }, \
+ .drv = &tcpci_tcpm_drv, \
},
diff --git a/zephyr/shim/include/usbc/tcpci_usb_mux.h b/zephyr/shim/include/usbc/tcpci_usb_mux.h
index 9fa29c7c85..1a5dd38241 100644
--- a/zephyr/shim/include/usbc/tcpci_usb_mux.h
+++ b/zephyr/shim/include/usbc/tcpci_usb_mux.h
@@ -1,4 +1,4 @@
-/* Copyright 2022 The Chromium OS Authors. All rights reserved.
+/* 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.
*/
@@ -10,41 +10,36 @@
#include "tcpm/ps8xxx_public.h"
#include "tcpm/tcpci.h"
-#define TCPCI_TCPM_USB_MUX_COMPAT cros_ec_usbc_mux_tcpci
-#define PS8XXX_USB_MUX_COMPAT parade_usbc_mux_ps8xxx
+#define TCPCI_TCPM_USB_MUX_COMPAT cros_ec_usbc_mux_tcpci
+#define PS8XXX_USB_MUX_COMPAT parade_usbc_mux_ps8xxx
/**
* Add I2C configuration and USB_MUX_FLAG_NOT_TCPC to enforce it when
* mux_read()/mux_write() functions are used.
*/
-#define USB_MUX_CONFIG_TCPCI_TCPM_WITH_I2C(mux_id, port_id, idx) \
- { \
- USB_MUX_COMMON_FIELDS_WITH_FLAGS(mux_id, port_id, idx, \
- USB_MUX_FLAG_NOT_TCPC, \
- USB_MUX_FLAG_NOT_TCPC),\
- .driver = &tcpci_tcpm_usb_mux_driver, \
- .hpd_update = USB_MUX_CALLBACK_OR_NULL(mux_id, \
- hpd_update), \
- .i2c_port = I2C_PORT(DT_PHANDLE(mux_id, port)), \
- .i2c_addr_flags = DT_PROP(mux_id, i2c_addr_flags), \
+#define USB_MUX_CONFIG_TCPCI_TCPM_WITH_I2C(mux_id) \
+ { \
+ USB_MUX_COMMON_FIELDS_WITH_FLAGS( \
+ mux_id, USB_MUX_FLAG_NOT_TCPC, USB_MUX_FLAG_NOT_TCPC), \
+ .driver = &tcpci_tcpm_usb_mux_driver, \
+ .hpd_update = \
+ USB_MUX_CALLBACK_OR_NULL(mux_id, hpd_update), \
+ .i2c_port = I2C_PORT_BY_DEV(mux_id), \
+ .i2c_addr_flags = DT_REG_ADDR(mux_id), \
}
/** Use I2C configuration from TCPC */
-#define USB_MUX_CONFIG_TCPCI_TCPM_WO_I2C(mux_id, port_id, idx) \
- { \
- USB_MUX_COMMON_FIELDS(mux_id, port_id, idx), \
- .driver = &tcpci_tcpm_usb_mux_driver, \
- .hpd_update = USB_MUX_CALLBACK_OR_NULL(mux_id, \
- hpd_update), \
+#define USB_MUX_CONFIG_TCPCI_TCPM_WO_I2C(mux_id) \
+ { \
+ USB_MUX_COMMON_FIELDS(mux_id), \
+ .driver = &tcpci_tcpm_usb_mux_driver, \
+ .hpd_update = \
+ USB_MUX_CALLBACK_OR_NULL(mux_id, hpd_update), \
}
-/** This macro will fail if only port or i2c_addr_flags property is present */
-#define USB_MUX_CONFIG_TCPCI_TCPM(mux_id, port_id, idx) \
- COND_CODE_1(UTIL_OR(DT_NODE_HAS_PROP(mux_id, port), \
- DT_NODE_HAS_PROP(mux_id, i2c_addr_flags)), \
- (USB_MUX_CONFIG_TCPCI_TCPM_WITH_I2C(mux_id, port_id,\
- idx)), \
- (USB_MUX_CONFIG_TCPCI_TCPM_WO_I2C(mux_id, port_id, \
- idx)))
+#define USB_MUX_CONFIG_TCPCI_TCPM(mux_id) \
+ COND_CODE_1(DT_NODE_HAS_PROP(mux_id, reg), \
+ (USB_MUX_CONFIG_TCPCI_TCPM_WITH_I2C(mux_id)), \
+ (USB_MUX_CONFIG_TCPCI_TCPM_WO_I2C(mux_id)))
#endif /* __ZEPHYR_SHIM_TCPCI_USB_MUX_H */
diff --git a/zephyr/shim/include/usbc/tusb1064_usb_mux.h b/zephyr/shim/include/usbc/tusb1064_usb_mux.h
index 159f42c500..55dc8d4645 100644
--- a/zephyr/shim/include/usbc/tusb1064_usb_mux.h
+++ b/zephyr/shim/include/usbc/tusb1064_usb_mux.h
@@ -1,4 +1,4 @@
-/* Copyright 2022 The Chromium OS Authors. All rights reserved.
+/* 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.
*/
@@ -8,35 +8,32 @@
#include "driver/usb_mux/tusb1064.h"
-#define TUSB1064_USB_MUX_COMPAT ti_tusb1064
+#define TUSB1064_USB_MUX_COMPAT ti_tusb1064
#if defined(CONFIG_USB_MUX_TUSB1044)
-#define USB_MUX_CONFIG_TUSB1064(mux_id, port_id, idx) \
- { \
- USB_MUX_COMMON_FIELDS(mux_id, port_id, idx), \
- .driver = &tusb1064_usb_mux_driver, \
- .i2c_port = I2C_PORT(DT_PHANDLE(mux_id, port)), \
- .i2c_addr_flags = \
- DT_STRING_UPPER_TOKEN(mux_id, i2c_addr_flags), \
- .hpd_update = &tusb1044_hpd_update, \
+#define USB_MUX_CONFIG_TUSB1064(mux_id) \
+ { \
+ USB_MUX_COMMON_FIELDS(mux_id), \
+ .driver = &tusb1064_usb_mux_driver, \
+ .i2c_port = I2C_PORT_BY_DEV(mux_id), \
+ .i2c_addr_flags = DT_REG_ADDR(mux_id), \
+ .hpd_update = &tusb1044_hpd_update, \
}
#elif defined(CONFIG_USB_MUX_TUSB546)
-#define USB_MUX_CONFIG_TUSB1064(mux_id, port_id, idx) \
- { \
- USB_MUX_COMMON_FIELDS(mux_id, port_id, idx), \
- .driver = &tusb1064_usb_mux_driver, \
- .i2c_port = I2C_PORT(DT_PHANDLE(mux_id, port)), \
- .i2c_addr_flags = \
- DT_STRING_UPPER_TOKEN(mux_id, i2c_addr_flags), \
+#define USB_MUX_CONFIG_TUSB1064(mux_id) \
+ { \
+ USB_MUX_COMMON_FIELDS(mux_id), \
+ .driver = &tusb1064_usb_mux_driver, \
+ .i2c_port = I2C_PORT_BY_DEV(mux_id), \
+ .i2c_addr_flags = DT_REG_ADDR(mux_id), \
}
#else
-#define USB_MUX_CONFIG_TUSB1064(mux_id, port_id, idx) \
- { \
- USB_MUX_COMMON_FIELDS(mux_id, port_id, idx), \
- .driver = &tusb1064_usb_mux_driver, \
- .i2c_port = I2C_PORT(DT_PHANDLE(mux_id, port)), \
- .i2c_addr_flags = \
- DT_STRING_UPPER_TOKEN(mux_id, i2c_addr_flags), \
+#define USB_MUX_CONFIG_TUSB1064(mux_id) \
+ { \
+ USB_MUX_COMMON_FIELDS(mux_id), \
+ .driver = &tusb1064_usb_mux_driver, \
+ .i2c_port = I2C_PORT_BY_DEV(mux_id), \
+ .i2c_addr_flags = DT_REG_ADDR(mux_id), \
}
#endif /* defined(CONFIG_USB_MUX_TUSB1044) */
diff --git a/zephyr/shim/include/usbc/usb_muxes.h b/zephyr/shim/include/usbc/usb_muxes.h
index 9422d4008d..d161b72b08 100644
--- a/zephyr/shim/include/usbc/usb_muxes.h
+++ b/zephyr/shim/include/usbc/usb_muxes.h
@@ -1,4 +1,4 @@
-/* Copyright 2022 The Chromium OS Authors. All rights reserved.
+/* 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.
*/
@@ -9,108 +9,158 @@
#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"
#include "usbc/anx7483_usb_mux.h"
#include "usbc/bb_retimer_usb_mux.h"
#include "usbc/it5205_usb_mux.h"
+#include "usbc/ps8743_usb_mux.h"
+#include "usbc/ps8818_usb_mux.h"
#include "usbc/tcpci_usb_mux.h"
#include "usbc/tusb1064_usb_mux.h"
+#include "usbc/utils.h"
#include "usbc/virtual_usb_mux.h"
/**
* @brief List of USB mux drivers compatibles and their configurations. Each
* element of list has to have (compatible, config) format.
*/
-#define USB_MUX_DRIVERS \
- (ANX7483_USB_MUX_COMPAT, USB_MUX_CONFIG_ANX7483), \
- (BB_RETIMER_USB_MUX_COMPAT, USB_MUX_CONFIG_BB_RETIMER), \
- (IT5205_USB_MUX_COMPAT, USB_MUX_CONFIG_IT5205), \
- (PS8XXX_USB_MUX_COMPAT, USB_MUX_CONFIG_TCPCI_TCPM), \
- (TCPCI_TCPM_USB_MUX_COMPAT, USB_MUX_CONFIG_TCPCI_TCPM), \
- (TUSB1064_USB_MUX_COMPAT, USB_MUX_CONFIG_TUSB1064), \
- (VIRTUAL_USB_MUX_COMPAT, USB_MUX_CONFIG_VIRTUAL)
+#define USB_MUX_DRIVERS \
+ (AMD_FP6_USB_MUX_COMPAT, USB_MUX_CONFIG_AMD_FP6), \
+ (ANX7447_USB_MUX_COMPAT, USB_MUX_CONFIG_ANX7447), \
+ (ANX7483_USB_MUX_COMPAT, USB_MUX_CONFIG_ANX7483), \
+ (BB_RETIMER_USB_MUX_COMPAT, USB_MUX_CONFIG_BB_RETIMER), \
+ (IT5205_USB_MUX_COMPAT, USB_MUX_CONFIG_IT5205), \
+ (PS8743_USB_MUX_COMPAT, USB_MUX_CONFIG_PS8743), \
+ (PS8818_USB_MUX_COMPAT, USB_MUX_CONFIG_PS8818), \
+ (PS8XXX_USB_MUX_COMPAT, USB_MUX_CONFIG_TCPCI_TCPM), \
+ (TCPCI_TCPM_USB_MUX_COMPAT, USB_MUX_CONFIG_TCPCI_TCPM), \
+ (TUSB1064_USB_MUX_COMPAT, USB_MUX_CONFIG_TUSB1064), \
+ (VIRTUAL_USB_MUX_COMPAT, USB_MUX_CONFIG_VIRTUAL)
/**
* @brief Get compatible from @p driver
*
* @param driver USB mux driver description in format (compatible, config)
*/
-#define USB_MUX_DRIVER_GET_COMPAT(driver) GET_ARG_N(1, __DEBRACKET driver)
+#define USB_MUX_DRIVER_GET_COMPAT(driver) GET_ARG_N(1, __DEBRACKET driver)
/**
* @brief Get configuration from @p driver
*
* @param driver USB mux driver description in format (compatible, config)
*/
-#define USB_MUX_DRIVER_GET_CONFIG(driver) GET_ARG_N(2, __DEBRACKET driver)
+#define USB_MUX_DRIVER_GET_CONFIG(driver) GET_ARG_N(2, __DEBRACKET driver)
/**
- * @brief USB mux port number based on parent node in DTS
+ * @brief Name of USB mux chain structure for given port and place in chain.
+ * Note, that root of chain is not referred by this name, but
+ * usb_muxes[@p port_id].
*
- * @param port_id USBC node ID
+ * @param idx Place in chain
+ * @param port_id USBC port id
*/
-#define USB_MUX_PORT(port_id) DT_REG_ADDR(port_id)
+#define USB_MUX_CHAIN_STRUCT_NAME(idx, port_id) \
+ DT_CAT4(USB_MUX_chain_port_, port_id, _mux_, idx)
/**
- * @brief Name of USB mux structure if node is not EMPTY. Note, that root of
- * chain is not referred by this name, but usb_muxes[USB_MUX_PORT(id)].
+ * @brief Declaration of USB mux chain structure for @p idx mux in @p port_id
+ * USB-C port's chain
+ *
+ * @param port_id USBC port ID (number)
+ * @param idx Place in chain
+ */
+#define USB_MUX_CHAIN_STRUCT_DECLARE(port_id, idx) \
+ MAYBE_CONST struct usb_mux_chain USB_MUX_CHAIN_STRUCT_NAME(idx, port_id)
+
+/**
+ * @brief Name of USB mux structure if node @p mux_id is not EMPTY.
*
* @param mux_id USB mux node ID
*/
-#define USB_MUX_STRUCT_NAME(mux_id) \
+#define USB_MUX_STRUCT_NAME(mux_id) \
COND_CODE_0(IS_EMPTY(mux_id), (DT_CAT(USB_MUX_NODE_, mux_id)), (EMPTY))
/**
* @brief USB muxes in chain should be constant only if configuration
* cannot change in runtime
*/
-#define MAYBE_CONST COND_CODE_1(CONFIG_PLATFORM_EC_USB_MUX_RUNTIME_CONFIG, \
- (), (const))
+#define MAYBE_CONST \
+ COND_CODE_1(CONFIG_PLATFORM_EC_USB_MUX_RUNTIME_CONFIG, (), (const))
/**
* @brief Declaration of USB mux structure
*
* @param mux_id USB mux node ID
*/
-#define USB_MUX_STRUCT_DECLARE(mux_id) \
+#define USB_MUX_STRUCT_DECLARE(mux_id) \
MAYBE_CONST struct usb_mux USB_MUX_STRUCT_NAME(mux_id)
/**
+ * @brief Declaration of USB mux board_init function
+ *
+ * @param mux_id USB mux node ID
+ */
+#define USB_MUX_CB_BOARD_INIT_DECLARE(mux_id) \
+ int DT_STRING_TOKEN(mux_id, board_init)(const struct usb_mux *);
+
+/**
+ * @brief Declaration of USB mux board_set function
+ *
+ * @param mux_id USB mux node ID
+ */
+#define USB_MUX_CB_BOARD_SET_DECLARE(mux_id) \
+ int DT_STRING_TOKEN(mux_id, board_set)(const struct usb_mux *, \
+ mux_state_t);
+
+/**
* @brief Get pointer by referencing @p name or NULL if @p name is EMPTY
*
* @param name Identifier to reference
*/
-#define USB_MUX_POINTER_OR_NULL(name) \
+#define USB_MUX_POINTER_OR_NULL(name) \
COND_CODE_0(IS_EMPTY(name), (&name), (NULL))
/**
* @brief Get node id of @p idx USB mux in chain
*
+ * @param chain_id USB mux chain node ID
* @param idx Position of USB mux in chain
- * @param port_id USBC node ID
*/
-#define USB_MUX_GET_CHAIN_N(idx, port_id) \
- DT_PHANDLE_BY_IDX(port_id, usb_muxes, idx)
+#define USB_MUX_GET_CHAIN_N(chain_id, idx) \
+ DT_PHANDLE_BY_IDX(chain_id, usb_muxes, idx)
/**
- * @brief Get node id of next USB mux in chain or EMPTY if it is last mux
+ * @brief Get next USB mux chain structure name or EMPTY if it is last mux
*
- * @param port_id USBC node ID
+ * @param chain_id USB mux chain node ID
* @param idx Position of USB mux in chain
*/
-#define USB_MUX_NEXT(port_id, idx) \
- GET_ARG_N(2, GET_ARGS_LESS_N(idx, \
- LISTIFY(DT_PROP_LEN(port_id, usb_muxes), \
- USB_MUX_GET_CHAIN_N, (,), port_id)), \
+#define USB_MUX_CHAIN_NEXT_NAME(chain_id, idx) \
+ GET_ARG_N(2, \
+ GET_ARGS_LESS_N(idx, \
+ LISTIFY(DT_PROP_LEN(chain_id, usb_muxes), \
+ USB_MUX_CHAIN_STRUCT_NAME, (, ), \
+ USBC_PORT(chain_id))), \
EMPTY)
/**
* @brief Get pointer to next USB mux in chain or NULL if it is last mux
*
- * @param port_id USBC node ID
+ * @param chain_id USB mux chain node ID
* @param idx Position of USB mux in chain
*/
-#define USB_MUX_NEXT_POINTER(port_id, idx) \
- USB_MUX_POINTER_OR_NULL(USB_MUX_STRUCT_NAME(USB_MUX_NEXT(port_id, idx)))
+#define USB_MUX_CHAIN_NEXT_POINTER(chain_id, idx) \
+ USB_MUX_POINTER_OR_NULL(USB_MUX_CHAIN_NEXT_NAME(chain_id, idx))
+
+/**
+ * @brief Get pointer to USB mux that is @p idx in chain @p chain_id
+ *
+ * @param chain_id USB mux chain node ID
+ * @param idx Position of USB mux in chain
+ */
+#define USB_MUX_POINTER(chain_id, idx) \
+ &USB_MUX_STRUCT_NAME(USB_MUX_GET_CHAIN_N(chain_id, idx))
/**
* @brief Generate pointer to function from @p cb_name property or NULL
@@ -119,217 +169,335 @@
* @param mux_id USB mux node ID
* @param cb_name Name of property with callback function
*/
-#define USB_MUX_CALLBACK_OR_NULL(mux_id, cb_name) \
+#define USB_MUX_CALLBACK_OR_NULL(mux_id, cb_name) \
USB_MUX_POINTER_OR_NULL(DT_STRING_TOKEN_OR(mux_id, cb_name, EMPTY))
/**
* @brief Set struct usb_mux fields common for all USB muxes and alter flags
*
* @param mux_id USB mux node ID
- * @param port_id USBC node ID
- * @param idx Position of USB mux in chain
* @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, port_id, idx, \
- flags_mask, flags_val) \
- .usb_port = USB_MUX_PORT(port_id), \
- .next_mux = USB_MUX_NEXT_POINTER(port_id, idx), \
- .board_init = USB_MUX_CALLBACK_OR_NULL(mux_id, board_init), \
- .board_set = USB_MUX_CALLBACK_OR_NULL(mux_id, board_set), \
+#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(mux_id, flags) & ~(flags_mask)) | (flags_val)
/**
* @brief Set struct usb_mux fields common for all USB muxes
*
* @param mux_id USB mux node ID
- * @param port_id USBC node ID
- * @param idx Position of USB mux in chain
*/
-#define USB_MUX_COMMON_FIELDS(mux_id, port_id, idx) \
- USB_MUX_COMMON_FIELDS_WITH_FLAGS(mux_id, port_id, idx, 0, 0)
+#define USB_MUX_COMMON_FIELDS(mux_id) \
+ USB_MUX_COMMON_FIELDS_WITH_FLAGS(mux_id, 0, 0)
/**
- * @brief Expands to 1 if @p mux_id has @p compat compatible. It is required
- * to makes sure that @p compat is expanded before DT_NODE_HAS_COMPAT
+ * @brief Declare USB mux structure
*
* @param mux_id USB mux node ID
- * @param compat USB mux driver compatible
+ * @param conf Driver configuration function
*/
-#define USB_MUX_IS_COMPATIBLE(mux_id, compat) \
- DT_NODE_HAS_COMPAT(mux_id, compat)
+#define USB_MUX_DECLARE(mux_id, conf) extern USB_MUX_STRUCT_DECLARE(mux_id);
/**
- * @brief Expands to @p driver config if @p mux_id is compatible with @p driver
+ * @brief Define USB mux structure using driver USB_MUX_CONFIG_* macro
*
- * @param driver USB mux driver description in format (compatible, config)
* @param mux_id USB mux node ID
+ * @param conf Driver configuration function
*/
-#define USB_MUX_DRIVER_CONFIG_IF_COMPAT(driver, mux_id) \
- COND_CODE_1(USB_MUX_IS_COMPATIBLE( \
- mux_id, USB_MUX_DRIVER_GET_COMPAT(driver)), \
- (USB_MUX_DRIVER_GET_CONFIG(driver)), ())
+#define USB_MUX_DEFINE(mux_id, conf) \
+ USB_MUX_STRUCT_DECLARE(mux_id) = conf(mux_id);
/**
- * @brief Find driver from USB_MUX_DRIVERS that is compatible with @p mux_id
+ * @brief Call @p cb_op if @p mux_id has @p cb_prop property
*
* @param mux_id USB mux node ID
+ * @param cb_prop The callback property name
+ * @param cb_op Operation to perform on USB muxes
*/
-#define USB_MUX_FIND_DRIVER_CONFIG(mux_id) \
- FOR_EACH_FIXED_ARG(USB_MUX_DRIVER_CONFIG_IF_COMPAT, (), mux_id, \
- USB_MUX_DRIVERS)
+#define USB_MUX_CB_DECLARE_IF_EXIST(mux_id, cb_prop, cb_op) \
+ COND_CODE_1(DT_NODE_HAS_PROP(mux_id, cb_prop), (cb_op(mux_id)), ())
/**
- * @brief Get driver configuration macro for @p mux_id and call @p op
+ * @brief Declare USB mux board_set function @p mux_id has board_set property
*
* @param mux_id USB mux node ID
- * @param port_id USBC node ID
- * @param idx Position of USB mux in chain
- * @param op Operation to perform on USB muxes
+ * @param conf Driver configuration function
*/
-#define USB_MUX_CALL_OP(mux_id, port_id, idx, op) \
- op(mux_id, port_id, idx, USB_MUX_FIND_DRIVER_CONFIG(mux_id))
+#define USB_MUX_CB_BOARD_SET_DECLARE_IF_EXISTS(mux_id, conf) \
+ USB_MUX_CB_DECLARE_IF_EXIST(mux_id, board_set, \
+ USB_MUX_CB_BOARD_SET_DECLARE)
/**
- * @brief Get USB mux node ID and call USB_MUX_CALL_OP
+ * @brief Declare USB mux board_init function @p mux_id has board_init property
*
- * @param port_id USBC node ID
- * @param idx Position of USB mux in chain
- * @param op Operation to perform on USB muxes
+ * @param mux_id USB mux node ID
+ * @param conf Driver configuration function
*/
-#define USB_MUX_DO(port_id, idx, op) \
- USB_MUX_CALL_OP(USB_MUX_GET_CHAIN_N(idx, port_id), port_id, idx, op)
+#define USB_MUX_CB_BOARD_INIT_DECLARE_IF_EXISTS(mux_id, conf) \
+ USB_MUX_CB_DECLARE_IF_EXIST(mux_id, board_init, \
+ USB_MUX_CB_BOARD_INIT_DECLARE)
/**
- * @brief Declare USB mux structure
+ * @brief Call @p op operation for each node that is compatible with @p driver
*
- * @param mux_id USB mux node ID
- * @param port_id USBC node ID
- * @param idx Position of USB mux in chain
- * @param conf Driver configuration function
+ * @param driver USB mux driver description in format (compatible, config)
+ * @param op Operation to perform on each USB mux. Should accept mux node ID and
+ * driver config as arguments.
*/
-#define USB_MUX_DECLARE(mux_id, port_id, idx, conf) \
- extern USB_MUX_STRUCT_DECLARE(mux_id);
+#define USB_MUX_DRIVER_CONFIG(driver, op) \
+ DT_FOREACH_STATUS_OKAY_VARGS(USB_MUX_DRIVER_GET_COMPAT(driver), op, \
+ USB_MUX_DRIVER_GET_CONFIG(driver))
/**
- * @brief Define USB mux structure using driver USB_MUX_CONFIG_* macro
+ * @brief Call @p op operation for each USB mux node that is compatible with
+ * any driver from the USB_MUX_DRIVERS list.
+ * DT_FOREACH_STATUS_OKAY_VARGS() macro can not be used in @p op
*
- * @param mux_id USB mux node ID
- * @param port_id USBC node ID
- * @param idx Position of USB mux in chain
- * @param conf Driver configuration function
+ * @param op Operation to perform on each USB mux. Should accept mux node ID and
+ * driver config as arguments.
*/
-#define USB_MUX_DEFINE(mux_id, port_id, idx, conf) \
- USB_MUX_STRUCT_DECLARE(mux_id) = conf(mux_id, port_id, idx);
+#define USB_MUX_FOREACH_MUX_DT_VARGS(op) \
+ FOR_EACH_FIXED_ARG(USB_MUX_DRIVER_CONFIG, (), op, USB_MUX_DRIVERS)
/**
- * @brief Define entry of usb_muxes array using driver USB_MUX_CONFIG_* macro
+ * @brief Convert @p mux_id and @p conf pair into USB_MUX_LIST entry
*
* @param mux_id USB mux node ID
- * @param port_id USBC node ID
- * @param idx Position of USB mux in chain
* @param conf Driver configuration function
*/
-#define USB_MUX_ARRAY(mux_id, port_id, idx, conf) \
- [USB_MUX_PORT(port_id)] = conf(mux_id, port_id, idx),
+#define USB_MUX_TO_LIST(mux_id, conf) , (mux_id, conf)
+
+/**
+ * @brief List of all USB muxes with config matched by compatible. List is in
+ * format (mux1_id, conf1) , (mux2_id, conf2) ...
+ */
+#define USB_MUX_LIST \
+ LIST_DROP_EMPTY(USB_MUX_FOREACH_MUX_DT_VARGS(USB_MUX_TO_LIST))
+
+/**
+ * @brief Call @p op with @p args arguments
+ *
+ * @param op Operation to perform on USB mux. Should accept mux node ID and
+ * driver config as arguments.
+ * @param args Arguments for @p op. Should be in format (mux_id, conf).
+ */
+#define USB_MUX_CALL_OP(args, op) op args
/**
- * @brief Call @p op with first mux in chain
+ * @brief Call @p op operation for each USB mux node from USB_MUX_LIST. This is
+ * like USB_MUX_FOREACH_MUX_DT_VARGS(), except
+ * DT_FOREACH_STATUS_OKAY_VARGS() macro can be used in @p op
*
- * @param port_id USBC node ID
- * @param op Operation to perform on USB mux first in chain. Needs to accept
- * USB mux node ID, USBC port node ID, position in chain, and driver
- * config as arguments.
+ * @param op Operation to perform on each USB mux. Should accept mux node ID and
+ * driver config as arguments.
*/
-#define USB_MUX_FIRST(port_id, op) \
- USB_MUX_DO(port_id, 0, op)
+#define USB_MUX_FOREACH_MUX(op) \
+ COND_CODE_0( \
+ IS_EMPTY(USB_MUX_LIST), \
+ (FOR_EACH_FIXED_ARG(USB_MUX_CALL_OP, (), op, USB_MUX_LIST)), \
+ (EMPTY))
/**
- * @brief Call USB_MUX_DO if @p idx is not 0 (is not first mux in chain)
+ * @brief Initialise chain structure for @p idx mux
*
- * @param port_id USBC node ID
+ * @param chain_id Chain DTS node ID
+ * @param idx USB mux index
+ */
+#define USB_MUX_CHAIN_STRUCT_INIT(chain_id, idx) \
+ { \
+ .mux = USB_MUX_POINTER(chain_id, idx), \
+ .next = USB_MUX_CHAIN_NEXT_POINTER(chain_id, idx), \
+ }
+
+/**
+ * @brief Helper macro to set chain structure value for @p idx mux
+ *
+ * @param chain_id Chain DTS node ID
+ * @param idx USB mux index
+ */
+#define USB_MUX_CHAIN_STRUCT_SET(chain_id, idx) \
+ (struct usb_mux_chain) USB_MUX_CHAIN_STRUCT_INIT(chain_id, idx)
+
+/**
+ * @brief Declaration of USB mux chain extern structure for @p idx mux in
+ * @p chain_id chain
+ *
+ * @param chain_id USB mux chain node ID
+ * @param idx Place in chain
+ */
+#define USB_MUX_CHAIN_STRUCT_DECLARE_EXTERN_OP(chain_id, idx) \
+ extern USB_MUX_CHAIN_STRUCT_DECLARE(USBC_PORT(chain_id), idx);
+
+/**
+ * @brief Declaration of USB mux chain structure for @p idx mux in @p chain_id
+ * chain
+ *
+ * @param chain_id USB mux chain node ID
+ * @param idx Place in chain
+ */
+#define USB_MUX_CHAIN_STRUCT_DECLARE_OP(chain_id, idx) \
+ USB_MUX_CHAIN_STRUCT_DECLARE(USBC_PORT(chain_id), idx);
+
+/**
+ * @brief Definition of USB mux chain structure for @p idx mux in @p chain_id
+ * chain
+ *
+ * @param chain_id USB mux chain node ID
+ * @param idx Place in chain
+ */
+#define USB_MUX_CHAIN_STRUCT_DEFINE_OP(chain_id, idx) \
+ USB_MUX_CHAIN_STRUCT_DECLARE(USBC_PORT(chain_id), idx) = \
+ USB_MUX_CHAIN_STRUCT_INIT(chain_id, idx);
+
+/**
+ * @brief Call @p op if @p idx is not 0 (is not the root mux of chain)
+ *
+ * @param chain_id Chain DTS node ID
* @param unused2 This argument is expected by DT_FOREACH_PROP_ELEM_VARGS
* @param idx Position of USB mux in chain
* @param op Operation to perform on USB muxes
*/
-#define USB_MUX_DO_SKIP_FIRST(port_id, unused2, idx, op) \
- COND_CODE_1(UTIL_BOOL(idx), (USB_MUX_DO(port_id, idx, op)), ())
+#define USB_MUX_SKIP_ROOT(chain_id, unused2, idx, op) \
+ COND_CODE_1(UTIL_BOOL(idx), (op(chain_id, idx)), ())
+
+/**
+ * @brief Call @p op for each mux in @p chain_id chain except the root mux
+ *
+ * @param chain_id Chain DTS node ID
+ * @param op Operation to perform on USB muxes
+ */
+#define USB_MUX_FOREACH_NO_ROOT_MUX(chain_id, op) \
+ DT_FOREACH_PROP_ELEM_VARGS(chain_id, usb_muxes, USB_MUX_SKIP_ROOT, op)
+
+/**
+ * @brief Create usb_muxes array entry for @p chain_id chain
+ *
+ * @param chain_id Chain DTS node ID
+ */
+#define USB_MUX_DEFINE_ROOT_MUX(chain_id) \
+ [USBC_PORT(chain_id)] = USB_MUX_CHAIN_STRUCT_INIT(chain_id, 0),
+
+/**
+ * @brief Call @p op only if chain @p chain_id is not alternative
+ *
+ * @param chain_id Chain DTS node ID
+ * @param op Operation to perform on main USB mux chain
+ * @param ... Arguments to pass to the @p op operation
+ */
+#define USB_MUX_FOR_MAIN_CHAIN(chain_id, op, ...) \
+ COND_CODE_0(DT_PROP(chain_id, alternative_chain), \
+ (op(chain_id, ##__VA_ARGS__)), ())
/**
- * @brief Call @p op with every mux in chain expect the first one
+ * @brief Call @p op for each USB mux chain
*
- * @param port_id USBC node ID
- * @param op Operation to perform on USB muxes. Needs to accept USB mux node
- * ID, USBC port node ID, position in chain, and driver config as
- * arguments.
+ * @param op Operation to perform on USB mux chain
*/
-#define USB_MUX_NO_FIRST(port_id, op) \
- DT_FOREACH_PROP_ELEM_VARGS(port_id, usb_muxes, \
- USB_MUX_DO_SKIP_FIRST, op)
+#define USB_MUX_FOREACH_CHAIN(op) \
+ DT_FOREACH_STATUS_OKAY(cros_ec_usb_mux_chain, op)
/**
- * @brief Call @p op if @p idx mux in chain has BB retimer compatible
+ * @brief Call @p op for each USB mux chain with arguments
*
- * @param port_id USBC node ID
+ * @param op Operation to perform on USB mux chain
+ * @param ... Arguments to pass to the @p op operation
+ */
+#define USB_MUX_FOREACH_CHAIN_VARGS(op, ...) \
+ DT_FOREACH_STATUS_OKAY_VARGS(cros_ec_usb_mux_chain, op, __VA_ARGS__)
+
+/**
+ * @brief Construct first half of conditional expression (?:) that evaluates to
+ * @p chain_id USB port if @p idx mux in @p chain_id is the same as
+ * @p mux_id
+ *
+ * @param chain_id USB mux chain node ID
* @param unused2 This argument is expected by DT_FOREACH_PROP_ELEM_VARGS
* @param idx Position of USB mux in chain
- * @param op Operation to perform on BB retimer
+ * @param mux_id USB mux node ID to compare with @p idx mux
*/
-#define USB_MUX_ONLY_BB_RETIMER(port_id, unused2, idx, op) \
- COND_CODE_1(USB_MUX_IS_COMPATIBLE( \
- USB_MUX_GET_CHAIN_N(idx, port_id), \
- BB_RETIMER_USB_MUX_COMPAT), \
- (op(USB_MUX_GET_CHAIN_N(idx, port_id), port_id, \
- idx, BB_RETIMER_CONTROLS_CONFIG)), ())
+#define USB_MUX_PORT_IF_SAME_NODES(chain_id, unused2, idx, mux_id) \
+ DT_SAME_NODE(mux_id, USB_MUX_GET_CHAIN_N(chain_id, idx)) ? \
+ USBC_PORT(chain_id):
/**
- * @brief Call @p op with every BB retimer in chain
+ * @brief Compare @p mux_id with all muxes in @p chain_id
*
- * @param port_id USBC node ID
- * @param op Operation to perform on BB retimers. Needs to accept USB mux node
- * ID, USBC port node ID, position in chain, and driver config as
- * arguments.
+ * @param chain_id USB mux chain node ID
+ * @param mux_id USB mux node ID
*/
-#define USB_MUX_BB_RETIMERS(port_id, op) \
- DT_FOREACH_PROP_ELEM_VARGS(port_id, usb_muxes, \
- USB_MUX_ONLY_BB_RETIMER, op)
+#define USB_MUX_FIND_PORT(chain_id, mux_id) \
+ DT_FOREACH_PROP_ELEM_VARGS(chain_id, usb_muxes, \
+ USB_MUX_PORT_IF_SAME_NODES, mux_id)
/**
- * @brief If @p port_id has usb_muxes property, call @p op with every mux in
- * chain that passes @p filter
+ * @brief Get port for @p mux_id by looking for an usb mux chain where @p mux_id
+ * is present. If the mux is not present in any chain, this macro
+ * evaluate to -1.
+ *
+ * This expands to:
+ * (DT_DEP_ORD(mux_id) == DT_DEP_ORD(USB_MUX_GET_CHAIN_N(chain1_id, 0))) ?
+ * USBC_PORT(chain1_id) :
+ * (DT_DEP_ORD(mux_id) == DT_DEP_ORD(USB_MUX_GET_CHAIN_N(chain1_id, 1))) ?
+ * USBC_PORT(chain1_id) :
+ * ...
+ * (DT_DEP_ORD(mux_id) == DT_DEP_ORD(USB_MUX_GET_CHAIN_N(chain1_id, n))) ?
+ * USBC_PORT(chain1_id) :
+ * (DT_DEP_ORD(mux_id) == DT_DEP_ORD(USB_MUX_GET_CHAIN_N(chain2_id, 0))) ?
+ * USBC_PORT(chain2_id) :
+ * ...
+ * (DT_DEP_ORD(mux_id) == DT_DEP_ORD(USB_MUX_GET_CHAIN_N(chainm_id, k))) ?
+ * USBC_PORT(chainm_id) : (-1)
*
- * @param port_id USBC node ID
- * @param filter Macro that should filter USB muxes and call @p op on them.
- * It has @p port_id and @p op as arguments. It is called
- * only for @p port_id that has usb_muxes property.
- * @param op Operation to perform on USB muxes. Needs to accept USB mux node
- * ID, USBC port node ID, position in chain, and driver config as
- * arguments.
+ * @param mux_id USB mux node ID
+ */
+#define USB_MUX_PORT(mux_id) \
+ (USB_MUX_FOREACH_CHAIN_VARGS(USB_MUX_FIND_PORT, mux_id)(-1))
+
+/**
+ * @brief Set usb_mux_chain structure for mux @p idx in chain @p chain_id
+ *
+ * @param chain_id Alternative USB mux chain node ID
+ * @param idx Position of the mux in chain
+ */
+#define USB_MUX_SET_ALTERNATIVE(chain_id, idx) \
+ USB_MUX_CHAIN_STRUCT_NAME(idx, USBC_PORT(chain_id)) = \
+ USB_MUX_CHAIN_STRUCT_SET(chain_id, idx);
+
+/**
+ * @brief Enable alternative USB mux chain
+ *
+ * @param chain_id Alternative USB mux chain node ID
*/
-#define USB_MUX_USBC_PORT_HAS_MUXES(port_id, filter, op) \
- COND_CODE_1(DT_NODE_HAS_PROP(port_id, usb_muxes), \
- (filter(port_id, op)), ())
+#define USB_MUX_ENABLE_ALTERNATIVE_NODE(chain_id) \
+ do { \
+ usb_muxes[USBC_PORT(chain_id)] = \
+ USB_MUX_CHAIN_STRUCT_SET(chain_id, 0); \
+ USB_MUX_FOREACH_NO_ROOT_MUX(chain_id, USB_MUX_SET_ALTERNATIVE) \
+ } while (0)
/**
- * @brief For every USBC port that has muxes, call @p op with every mux in chain
- * that passes @p filter
+ * @brief Enable alternative USB mux chain
*
- * @param filter Macro that should filter USB muxes and call @p op on them.
- * It has USBC port node ID and @p op as arguments. It is called
- * only for USBC ports that have usb_muxes property.
- * @param op Operation to perform on USB muxes. Needs to accept USB mux node
- * ID, USBC port node ID, position in chain, and driver config as
- * arguments.
+ * @param nodelabel Label of alternative USB mux chain
*/
-#define USB_MUX_FOREACH_USBC_PORT(filter, op) \
- DT_FOREACH_STATUS_OKAY_VARGS(named_usbc_port, \
- USB_MUX_USBC_PORT_HAS_MUXES, \
- filter, op)
+#define USB_MUX_ENABLE_ALTERNATIVE(nodelabel) \
+ USB_MUX_ENABLE_ALTERNATIVE_NODE(DT_NODELABEL(nodelabel))
/**
* Forward declare all usb_mux structures e.g.
* MAYBE_CONST struct usb_mux USB_MUX_NODE_<node_id>;
*/
-USB_MUX_FOREACH_USBC_PORT(USB_MUX_NO_FIRST, USB_MUX_DECLARE)
+USB_MUX_FOREACH_MUX(USB_MUX_DECLARE)
+
+/**
+ * Forward declare all usb_mux_chain structures e.g.
+ * extern MAYBE_CONST struct usb_mux_chain
+ * USB_MUX_chain_port_<node_id>_mux_<position_id>;
+ */
+USB_MUX_FOREACH_CHAIN_VARGS(USB_MUX_FOREACH_NO_ROOT_MUX,
+ USB_MUX_CHAIN_STRUCT_DECLARE_EXTERN_OP)
#endif /* ZEPHYR_CHROME_USBC_USB_MUXES_H */
diff --git a/zephyr/shim/include/usbc/utils.h b/zephyr/shim/include/usbc/utils.h
index 49b9aa4b71..53e9a34856 100644
--- a/zephyr/shim/include/usbc/utils.h
+++ b/zephyr/shim/include/usbc/utils.h
@@ -1,22 +1,19 @@
-/* Copyright 2022 The Chromium OS Authors. All rights reserved.
+/* 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.
*/
#ifndef __CROS_EC_ZEPHYR_SHIM_USBC_UTIL
-
/*
* Enable interrupt from the `irq` property of an instance's node.
*
* @param inst: instance number
*/
-#define BC12_GPIO_ENABLE_INTERRUPT(inst) \
- IF_ENABLED(DT_INST_NODE_HAS_PROP(inst, irq), \
- (gpio_enable_dt_interrupt( \
- GPIO_INT_FROM_NODE(DT_INST_PHANDLE(inst, irq)));\
- ) \
- )
+#define BC12_GPIO_ENABLE_INTERRUPT(inst) \
+ IF_ENABLED(DT_INST_NODE_HAS_PROP(inst, irq), \
+ (gpio_enable_dt_interrupt( \
+ GPIO_INT_FROM_NODE(DT_INST_PHANDLE(inst, irq)));))
/*
* Get the port number from a child of `named-usbc-port` node.
@@ -26,11 +23,17 @@
#define USBC_PORT(id) DT_REG_ADDR(DT_PARENT(id))
/*
+ * Get the port number from a `named-usbc-port` node.
+ *
+ * @param id: `named-usbc-port` node id
+ */
+#define USBC_PORT_NEW(id) DT_REG_ADDR(id)
+
+/*
* Get the port number from a child of `named-usbc-port` node.
*
* @param inst: instance number of the node
*/
#define USBC_PORT_FROM_INST(inst) USBC_PORT(DT_DRV_INST(inst))
-
#endif /* __CROS_EC_ZEPHYR_SHIM_USBC_UTIL */
diff --git a/zephyr/shim/include/usbc/virtual_usb_mux.h b/zephyr/shim/include/usbc/virtual_usb_mux.h
index 5f4c2fb466..bbb2d8730e 100644
--- a/zephyr/shim/include/usbc/virtual_usb_mux.h
+++ b/zephyr/shim/include/usbc/virtual_usb_mux.h
@@ -1,4 +1,4 @@
-/* Copyright 2022 The Chromium OS Authors. All rights reserved.
+/* 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.
*/
@@ -8,13 +8,13 @@
#include "usb_mux.h"
-#define VIRTUAL_USB_MUX_COMPAT cros_ec_usbc_mux_virtual
+#define VIRTUAL_USB_MUX_COMPAT cros_ec_usbc_mux_virtual
-#define USB_MUX_CONFIG_VIRTUAL(mux_id, port_id, idx) \
- { \
- USB_MUX_COMMON_FIELDS(mux_id, port_id, idx), \
- .driver = &virtual_usb_mux_driver, \
- .hpd_update = &virtual_hpd_update, \
+#define USB_MUX_CONFIG_VIRTUAL(mux_id) \
+ { \
+ USB_MUX_COMMON_FIELDS(mux_id), \
+ .driver = &virtual_usb_mux_driver, \
+ .hpd_update = &virtual_hpd_update, \
}
#endif /* __ZEPHYR_SHIM_VIRTUAL_USB_MUX_H */
diff --git a/zephyr/shim/include/zephyr_adc.h b/zephyr/shim/include/zephyr_adc.h
index aff6d7a5b6..d4139692f7 100644
--- a/zephyr/shim/include/zephyr_adc.h
+++ b/zephyr/shim/include/zephyr_adc.h
@@ -1,4 +1,4 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
+/* Copyright 2021 The ChromiumOS Authors
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
@@ -8,20 +8,18 @@
#include <zephyr/drivers/adc.h>
-#ifdef CONFIG_PLATFORM_EC_ADC
+#ifdef CONFIG_ADC
#define ZSHIM_ADC_ID(node_id) DT_STRING_UPPER_TOKEN(node_id, enum_name)
-#define ADC_ID_WITH_COMMA(node_id) ZSHIM_ADC_ID(node_id),
enum adc_channel {
#if DT_NODE_EXISTS(DT_INST(0, named_adc_channels))
- DT_FOREACH_CHILD(DT_INST(0, named_adc_channels), ADC_ID_WITH_COMMA)
+ DT_FOREACH_CHILD_SEP(DT_INST(0, named_adc_channels), ZSHIM_ADC_ID,
+ (, )),
#endif /* named_adc_channels */
ADC_CH_COUNT
};
-#undef ADC_ID_WITH_COMMA
-
struct adc_t {
const char *name;
const struct device *dev;
@@ -38,9 +36,7 @@ extern struct adc_t adc_channels[];
#endif /* CONFIG_ADC_CHANNELS_RUNTIME_CONFIG */
#else
/* Empty declaration to avoid warnings if adc.h is included */
-enum adc_channel {
- ADC_CH_COUNT
-};
-#endif /* CONFIG_PLATFORM_EC_ADC */
+enum adc_channel { ADC_CH_COUNT };
+#endif /* CONFIG_ADC */
#endif /* __CROS_EC_ZEPHYR_ADC_H */
diff --git a/zephyr/shim/include/zephyr_console_shim.h b/zephyr/shim/include/zephyr_console_shim.h
index 5880c3f400..42ac3e693b 100644
--- a/zephyr/shim/include/zephyr_console_shim.h
+++ b/zephyr/shim/include/zephyr_console_shim.h
@@ -1,4 +1,4 @@
-/* Copyright 2020 The Chromium OS Authors. All rights reserved.
+/* Copyright 2020 The ChromiumOS Authors
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
@@ -10,7 +10,7 @@
struct zephyr_console_command {
/* Handler for the command. argv[0] will be the command name. */
- int (*handler)(int argc, char **argv);
+ int (*handler)(int argc, const char **argv);
#ifdef CONFIG_SHELL_HELP
/* Description of args */
const char *argdesc;
@@ -20,9 +20,7 @@ struct zephyr_console_command {
};
#ifdef CONFIG_SHELL_HELP
-#define _HELP_ARGS(A, H) \
- .argdesc = A, \
- .help = H,
+#define _HELP_ARGS(A, H) .argdesc = A, .help = H,
#else
#define _HELP_ARGS(A, H)
#endif
@@ -38,17 +36,16 @@ struct zephyr_console_command {
* Return: the return value from the handler.
*/
int zshim_run_ec_console_command(const struct zephyr_console_command *command,
- size_t argc, char **argv);
+ size_t argc, const char **argv);
/* Internal wrappers for DECLARE_CONSOLE_COMMAND_* macros. */
#define _ZEPHYR_SHELL_COMMAND_SHIM_2(NAME, ROUTINE_ID, ARGDESC, HELP, \
WRAPPER_ID, ENTRY_ID) \
static const struct zephyr_console_command ENTRY_ID = { \
- .handler = ROUTINE_ID, \
- _HELP_ARGS(ARGDESC, HELP) \
+ .handler = ROUTINE_ID, _HELP_ARGS(ARGDESC, HELP) \
}; \
static int WRAPPER_ID(const struct shell *shell, size_t argc, \
- char **argv) \
+ const char **argv) \
{ \
return zshim_run_ec_console_command(&ENTRY_ID, argc, argv); \
} \
@@ -79,7 +76,9 @@ int zshim_run_ec_console_command(const struct zephyr_console_command *command,
*
* @s: The pointer to the string.
* @len: The size of the string.
+ *
+ * Return: the number of bytes consumed.
*/
-void console_buf_notify_chars(const char *s, size_t len);
+size_t console_buf_notify_chars(const char *s, size_t len);
#endif /* __CROS_EC_ZEPHYR_CONSOLE_SHIM_H */
diff --git a/zephyr/shim/include/zephyr_espi_shim.h b/zephyr/shim/include/zephyr_espi_shim.h
index 4f147752d7..ddc4da075c 100644
--- a/zephyr/shim/include/zephyr_espi_shim.h
+++ b/zephyr/shim/include/zephyr_espi_shim.h
@@ -1,4 +1,4 @@
-/* Copyright 2020 The Chromium OS Authors. All rights reserved.
+/* Copyright 2020 The ChromiumOS Authors
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
diff --git a/zephyr/shim/include/zephyr_gpio_signal.h b/zephyr/shim/include/zephyr_gpio_signal.h
index 8949826987..1a98071d6d 100644
--- a/zephyr/shim/include/zephyr_gpio_signal.h
+++ b/zephyr/shim/include/zephyr_gpio_signal.h
@@ -1,4 +1,4 @@
-/* Copyright 2020 The Chromium OS Authors. All rights reserved.
+/* Copyright 2020 The ChromiumOS Authors
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
@@ -34,27 +34,48 @@
* a GPIO signal name from either the enum-name or a
* unique name generated using the DTS ordinal.
*/
-#define GPIO_SIGNAL_NAME(id) \
- COND_CODE_1(DT_NODE_HAS_PROP(id, enum_name), \
- (GPIO_SIGNAL_NAME_FROM_ENUM(id)), \
- (GPIO_SIGNAL_NAME_FROM_ORD(id ## _ORD)))
-
-#define GPIO_SIGNAL(id) GPIO_SIGNAL_NAME(id)
-#define GPIO_SIGNAL_WITH_COMMA(id) \
- GPIO_SIGNAL(id),
+#define GPIO_SIGNAL_NAME(id) \
+ COND_CODE_1(DT_NODE_HAS_PROP(id, enum_name), \
+ (GPIO_SIGNAL_NAME_FROM_ENUM(id)), \
+ (GPIO_SIGNAL_NAME_FROM_ORD(id##_ORD)))
+
+#define GPIO_SIGNAL(id) GPIO_SIGNAL_NAME(id)
+
+#define GPIO_IMPL_SIGNAL(id) \
+ COND_CODE_1(DT_NODE_HAS_PROP(id, gpios), (GPIO_SIGNAL(id), ), ())
+
+#define GPIO_UNIMPL_SIGNAL(id) \
+ COND_CODE_1(DT_NODE_HAS_PROP(id, gpios), (), \
+ (GPIO_SIGNAL_NAME(id) = GPIO_UNIMPLEMENTED, ))
+/*
+ * Create a list of aliases to allow remapping of aliased names.
+ */
+#define GPIO_DT_MK_ALIAS(id) \
+ DT_STRING_UPPER_TOKEN(id, alias) = DT_STRING_UPPER_TOKEN(id, enum_name),
+
+#define GPIO_DT_ALIAS_LIST(id) \
+ COND_CODE_1(DT_NODE_HAS_PROP(id, alias), (GPIO_DT_MK_ALIAS(id)), ())
+
enum gpio_signal {
GPIO_UNIMPLEMENTED = -1,
#if DT_NODE_EXISTS(DT_PATH(named_gpios))
- DT_FOREACH_CHILD(DT_PATH(named_gpios), GPIO_SIGNAL_WITH_COMMA)
+ DT_FOREACH_CHILD(DT_PATH(named_gpios), GPIO_IMPL_SIGNAL)
#endif
- GPIO_COUNT,
- GPIO_LIMIT = 0x0FFF,
+ GPIO_COUNT,
+#if DT_NODE_EXISTS(DT_PATH(named_gpios))
+ DT_FOREACH_CHILD(DT_PATH(named_gpios), GPIO_UNIMPL_SIGNAL)
+ DT_FOREACH_CHILD(DT_PATH(named_gpios), GPIO_DT_ALIAS_LIST)
+#endif
+ GPIO_LIMIT = 0x0FFF,
IOEX_SIGNAL_START = GPIO_LIMIT + 1,
IOEX_SIGNAL_END = IOEX_SIGNAL_START,
IOEX_LIMIT = 0x1FFF,
};
-#undef GPIO_SIGNAL_WITH_COMMA
+#undef GPIO_DT_ALIAS_LIST
+#undef GPIO_DT_MK_ALIAS
+#undef GPIO_IMPL_SIGNAL
+#undef GPIO_UNIMPL_SIGNAL
BUILD_ASSERT(GPIO_COUNT < GPIO_LIMIT);
@@ -118,8 +139,8 @@ BUILD_ASSERT(GPIO_COUNT < GPIO_LIMIT);
*/
struct gpio_dt_spec;
-#define GPIO_DT_PTR_DECL(id) extern const struct gpio_dt_spec * const \
- GPIO_DT_NAME(GPIO_SIGNAL(id));
+#define GPIO_DT_PTR_DECL(id) \
+ extern const struct gpio_dt_spec *const GPIO_DT_NAME(GPIO_SIGNAL(id));
DT_FOREACH_CHILD(DT_PATH(named_gpios), GPIO_DT_PTR_DECL)
@@ -127,14 +148,13 @@ DT_FOREACH_CHILD(DT_PATH(named_gpios), GPIO_DT_PTR_DECL)
#endif /* DT_NODE_EXISTS(DT_PATH(named_gpios)) */
-
#define IOEXPANDER_ID_EXPAND(id) ioex_chip_##id
#define IOEXPANDER_ID(id) IOEXPANDER_ID_EXPAND(id)
#define IOEXPANDER_ID_FROM_INST_WITH_COMMA(id) IOEXPANDER_ID(id),
enum ioexpander_id {
DT_FOREACH_STATUS_OKAY(cros_ioex_chip,
- IOEXPANDER_ID_FROM_INST_WITH_COMMA)
- CONFIG_IO_EXPANDER_PORT_COUNT
+ IOEXPANDER_ID_FROM_INST_WITH_COMMA)
+ CONFIG_IO_EXPANDER_PORT_COUNT
};
/**
diff --git a/zephyr/shim/include/zephyr_hooks_shim.h b/zephyr/shim/include/zephyr_hooks_shim.h
index 1798a42aeb..f3949787bd 100644
--- a/zephyr/shim/include/zephyr_hooks_shim.h
+++ b/zephyr/shim/include/zephyr_hooks_shim.h
@@ -1,4 +1,4 @@
-/* Copyright 2020 The Chromium OS Authors. All rights reserved.
+/* Copyright 2020 The ChromiumOS Authors
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
@@ -10,7 +10,6 @@
#include <zephyr/init.h>
#include <zephyr/kernel.h>
-#include <zephyr/zephyr.h>
#include "common.h"
#include "cros_version.h"
@@ -31,7 +30,7 @@ int hook_call_deferred(const struct deferred_data *data, int us);
K_WORK_DELAYABLE_DEFINE(routine##_work_data, \
(void (*)(struct k_work *))routine); \
__maybe_unused const struct deferred_data routine##_data = { \
- .work = &routine##_work_data, \
+ .work = &routine##_work_data, \
}
/**
diff --git a/zephyr/shim/include/zephyr_host_command.h b/zephyr/shim/include/zephyr_host_command.h
index cc67049614..e2f0a7c296 100644
--- a/zephyr/shim/include/zephyr_host_command.h
+++ b/zephyr/shim/include/zephyr_host_command.h
@@ -1,4 +1,4 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
+/* Copyright 2021 The ChromiumOS Authors
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
@@ -27,24 +27,19 @@ bool in_host_command_main(void);
/**
* See include/host_command.h for documentation.
*/
-#define DECLARE_HOST_COMMAND(_command, _routine, _version_mask) \
- STRUCT_SECTION_ITERABLE(host_command, _cros_hcmd_##_command) = { \
- .command = _command, \
- .handler = _routine, \
- .version_mask = _version_mask, \
+#define DECLARE_HOST_COMMAND(_command, _routine, _version_mask) \
+ STRUCT_SECTION_ITERABLE(host_command, _cros_hcmd_##_command) = { \
+ .command = _command, \
+ .handler = _routine, \
+ .version_mask = _version_mask, \
}
#else /* !CONFIG_PLATFORM_EC_HOSTCMD */
/*
- * Create a fake routine to call the function. The linker should
- * garbage-collect it since it is behind 'if (0)'
+ * Create a global var to reference the host command. The linker should remove
+ * it since it is never referenced.
*/
-#define DECLARE_HOST_COMMAND(command, routine, version_mask) \
- int __remove_ ## command(void) \
- { \
- if (0) \
- routine(NULL); \
- return 0; \
- }
+#define DECLARE_HOST_COMMAND(command, routine, version_mask) \
+ int __remove_##command = ((int)(routine))
#endif /* CONFIG_PLATFORM_EC_HOSTCMD */
diff --git a/zephyr/shim/include/zephyr_mkbp_event.h b/zephyr/shim/include/zephyr_mkbp_event.h
index 159aebc8e1..b8cb88029d 100644
--- a/zephyr/shim/include/zephyr_mkbp_event.h
+++ b/zephyr/shim/include/zephyr_mkbp_event.h
@@ -1,23 +1,22 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
+/* Copyright 2021 The ChromiumOS Authors
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
-#if !defined(__CROS_EC_MKBP_EVENT_H) || \
- defined(__CROS_EC_ZEPHYR_MKBP_EVENT_H)
+#if !defined(__CROS_EC_MKBP_EVENT_H) || defined(__CROS_EC_ZEPHYR_MKBP_EVENT_H)
#error "This file must only be included from mkbp_event.h. " \
"Include mkbp_event.h directly"
#endif
#define __CROS_EC_ZEPHYR_MKBP_EVENT_H
-const struct mkbp_event_source *zephyr_find_mkbp_event_source(
- uint8_t event_type);
+const struct mkbp_event_source *
+zephyr_find_mkbp_event_source(uint8_t event_type);
/**
* See include/mkbp_event.h for documentation.
*/
-#define DECLARE_EVENT_SOURCE(_type, _func) \
- STRUCT_SECTION_ITERABLE(mkbp_event_source, _cros_evtsrc_##_func) = { \
- .event_type = _type, \
- .get_data = _func, \
+#define DECLARE_EVENT_SOURCE(_type, _func) \
+ STRUCT_SECTION_ITERABLE(mkbp_event_source, _cros_evtsrc_##_func) = { \
+ .event_type = _type, \
+ .get_data = _func, \
}
diff --git a/zephyr/shim/include/zephyr_write_protect.h b/zephyr/shim/include/zephyr_write_protect.h
index 3af2fb3576..227af16bd0 100644
--- a/zephyr/shim/include/zephyr_write_protect.h
+++ b/zephyr/shim/include/zephyr_write_protect.h
@@ -1,4 +1,4 @@
-/* Copyright 2022 The Chromium OS Authors. All rights reserved.
+/* 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.
*/