diff options
author | Karthikeyan Ramasubramanian <kramasub@google.com> | 2019-10-02 14:27:47 -0600 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2019-11-01 18:43:42 +0000 |
commit | 9577704f30c7e824c0590264df22d95a2c706575 (patch) | |
tree | 566b5beeeae8b343803718101ba0b00c940506cb | |
parent | e8121e83e478fef2d5a29304be900311f3f020c4 (diff) | |
download | chrome-ec-9577704f30c7e824c0590264df22d95a2c706575.tar.gz |
Rename CONFIG_USB_PD_PORT_COUNT as CONFIG_USB_PD_PORT_MAX_COUNT
Certain SKUs of certain boards have lesser number of USB PD ports than
defined by CONFIG_USB_PD_PORT_COUNT. Hence rename
CONFIG_USB_PD_PORT_COUNT as CONFIG_USB_PD_PORT_MAX_COUNT.
BUG=b:140816510, b:143196487
BRANCH=octopus
TEST=make -j buildall; Boot to ChromeOS
Change-Id: I7c33b27150730a1a3b5813b7b4a72fd24ab73c6a
Signed-off-by: Karthikeyan Ramasubramanian <kramasub@google.com>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1879337
Tested-by: Karthikeyan Ramasubramanian <kramasub@chromium.org>
Reviewed-by: Jett Rink <jettrink@chromium.org>
Commit-Queue: Jett Rink <jettrink@chromium.org>
204 files changed, 549 insertions, 533 deletions
diff --git a/baseboard/dragonegg/baseboard.c b/baseboard/dragonegg/baseboard.c index 36f054c376..7414421c15 100644 --- a/baseboard/dragonegg/baseboard.c +++ b/baseboard/dragonegg/baseboard.c @@ -137,7 +137,7 @@ void board_hibernate(void) } /******************************************************************************/ /* USB-C TPCP Configuration */ -const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_COUNT] = { +const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_MAX_COUNT] = { [USB_PD_PORT_ITE_0] = { .bus_type = EC_BUS_TYPE_EMBEDDED, /* TCPC is embedded within EC so no i2c config needed */ @@ -168,7 +168,7 @@ const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_COUNT] = { /******************************************************************************/ /* USB-C PPC Configuration */ -struct ppc_config_t ppc_chips[CONFIG_USB_PD_PORT_COUNT] = { +struct ppc_config_t ppc_chips[CONFIG_USB_PD_PORT_MAX_COUNT] = { [USB_PD_PORT_ITE_0] = { .i2c_port = I2C_PORT_USBC0, .i2c_addr_flags = SN5S330_ADDR0_FLAGS, @@ -189,7 +189,7 @@ struct ppc_config_t ppc_chips[CONFIG_USB_PD_PORT_COUNT] = { }; unsigned int ppc_cnt = ARRAY_SIZE(ppc_chips); -struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_COUNT] = { +struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_MAX_COUNT] = { [USB_PD_PORT_ITE_0] = { .driver = &virtual_usb_mux_driver, .hpd_update = &virtual_hpd_update, @@ -209,7 +209,7 @@ struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_COUNT] = { /******************************************************************************/ /* BC 1.2 chip Configuration */ -const struct max14637_config_t max14637_config[CONFIG_USB_PD_PORT_COUNT] = { +const struct max14637_config_t max14637_config[CONFIG_USB_PD_PORT_MAX_COUNT] = { { .chip_enable_pin = GPIO_USB_C0_BC12_VBUS_ON_ODL, .chg_det_pin = GPIO_USB_C0_BC12_CHG_MAX, @@ -284,7 +284,7 @@ void board_pd_vconn_ctrl(int port, enum usbpd_cc_pin cc_pin, int enabled) int board_set_active_charge_port(int port) { int is_valid_port = (port >= 0 && - port < CONFIG_USB_PD_PORT_COUNT); + port < CONFIG_USB_PD_PORT_MAX_COUNT); int i; if (!is_valid_port && port != CHARGE_PORT_NONE) diff --git a/baseboard/dragonegg/baseboard.h b/baseboard/dragonegg/baseboard.h index 9046d4e5c3..e34f5d11c3 100644 --- a/baseboard/dragonegg/baseboard.h +++ b/baseboard/dragonegg/baseboard.h @@ -86,7 +86,7 @@ * on the MLB for now. In addition, this config option will likely move to * board.h as it likely board dependent and not same across all follower boards. */ -#define CONFIG_USB_PD_PORT_COUNT 3 +#define CONFIG_USB_PD_PORT_MAX_COUNT 3 #define CONFIG_USB_PD_MAX_SINGLE_SOURCE_CURRENT TYPEC_RP_3A0 #define CONFIG_USB_PD_DUAL_ROLE #define CONFIG_USB_PD_LOGGING diff --git a/baseboard/dragonegg/usb_pd_policy.c b/baseboard/dragonegg/usb_pd_policy.c index 37a9b51dc9..cf9d3c4885 100644 --- a/baseboard/dragonegg/usb_pd_policy.c +++ b/baseboard/dragonegg/usb_pd_policy.c @@ -277,8 +277,8 @@ int pd_custom_vdm(int port, int cnt, uint32_t *payload, } #ifdef CONFIG_USB_PD_ALT_MODE_DFP -static int dp_flags[CONFIG_USB_PD_PORT_COUNT]; -static uint32_t dp_status[CONFIG_USB_PD_PORT_COUNT]; +static int dp_flags[CONFIG_USB_PD_PORT_MAX_COUNT]; +static uint32_t dp_status[CONFIG_USB_PD_PORT_MAX_COUNT]; static void svdm_safe_dp_mode(int port) { diff --git a/baseboard/grunt/baseboard.c b/baseboard/grunt/baseboard.c index 02641f9e66..977b4fc6ed 100644 --- a/baseboard/grunt/baseboard.c +++ b/baseboard/grunt/baseboard.c @@ -78,7 +78,7 @@ const struct power_signal_info power_signal_list[] = { }; BUILD_ASSERT(ARRAY_SIZE(power_signal_list) == POWER_SIGNAL_COUNT); -const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_COUNT] = { +const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_MAX_COUNT] = { #ifdef VARIANT_GRUNT_TCPC_0_ANX3429 [USB_PD_PORT_ANX74XX] = { .bus_type = EC_BUS_TYPE_I2C, @@ -156,7 +156,7 @@ void board_tcpc_init(void) * Initialize HPD to low; after sysjump SOC needs to see * HPD pulse to enable video path */ - for (port = 0; port < CONFIG_USB_PD_PORT_COUNT; port++) { + for (port = 0; port < CONFIG_USB_PD_PORT_MAX_COUNT; port++) { const struct usb_mux *mux = &usb_muxes[port]; mux->hpd_update(port, 0, 0); @@ -288,7 +288,7 @@ static int ps8751_tune_mux(int port) return EC_SUCCESS; } -struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_COUNT] = { +struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_MAX_COUNT] = { #ifdef VARIANT_GRUNT_TCPC_0_ANX3429 [USB_PD_PORT_ANX74XX] = { .driver = &anx74xx_tcpm_usb_mux_driver, @@ -349,7 +349,7 @@ void board_overcurrent_event(int port, int is_overcurrented) } /* BC 1.2 chip Configuration */ -const struct max14637_config_t max14637_config[CONFIG_USB_PD_PORT_COUNT] = { +const struct max14637_config_t max14637_config[CONFIG_USB_PD_PORT_MAX_COUNT] = { [USB_PD_PORT_ANX74XX] = { .chip_enable_pin = GPIO_USB_C0_BC12_VBUS_ON_L, .chg_det_pin = GPIO_USB_C0_BC12_CHG_DET, diff --git a/baseboard/grunt/baseboard.h b/baseboard/grunt/baseboard.h index 65fbf57383..7a2504dcfe 100644 --- a/baseboard/grunt/baseboard.h +++ b/baseboard/grunt/baseboard.h @@ -117,7 +117,7 @@ #define CONFIG_USB_PD_DUAL_ROLE #define CONFIG_USB_PD_DUAL_ROLE_AUTO_TOGGLE #define CONFIG_USB_PD_LOGGING -#define CONFIG_USB_PD_PORT_COUNT 2 +#define CONFIG_USB_PD_PORT_MAX_COUNT 2 #define CONFIG_USB_PD_TCPC_LOW_POWER #ifdef VARIANT_GRUNT_TCPC_0_ANX3429 #define CONFIG_USB_PD_TCPM_ANX3429 diff --git a/baseboard/grunt/usb_pd_policy.c b/baseboard/grunt/usb_pd_policy.c index c24dc92942..9b3cfc647e 100644 --- a/baseboard/grunt/usb_pd_policy.c +++ b/baseboard/grunt/usb_pd_policy.c @@ -235,8 +235,8 @@ int pd_custom_vdm(int port, int cnt, uint32_t *payload, } #ifdef CONFIG_USB_PD_ALT_MODE_DFP -static int dp_flags[CONFIG_USB_PD_PORT_COUNT]; -static uint32_t dp_status[CONFIG_USB_PD_PORT_COUNT]; +static int dp_flags[CONFIG_USB_PD_PORT_MAX_COUNT]; +static uint32_t dp_status[CONFIG_USB_PD_PORT_MAX_COUNT]; static int svdm_enter_dp_mode(int port, uint32_t mode_caps) { @@ -316,7 +316,7 @@ static int svdm_dp_config(int port, uint32_t *payload) * timestamp of the next possible toggle to ensure the 2-ms spacing * between IRQ_HPD. */ -static uint64_t hpd_deadline[CONFIG_USB_PD_PORT_COUNT]; +static uint64_t hpd_deadline[CONFIG_USB_PD_PORT_MAX_COUNT]; #define PORT_TO_HPD(port) ((port) ? GPIO_USB_C1_DP_HPD : GPIO_USB_C0_DP_HPD) static void svdm_dp_post_config(int port) diff --git a/baseboard/hatch/baseboard.c b/baseboard/hatch/baseboard.c index b495c539fb..209dbb9bf7 100644 --- a/baseboard/hatch/baseboard.c +++ b/baseboard/hatch/baseboard.c @@ -142,7 +142,7 @@ void board_hibernate(void) * if it is later connected to ensure that AC_PRESENT * will wake up the EC from this state */ - for (port = 0; port < CONFIG_USB_PD_PORT_COUNT; ++port) + for (port = 0; port < CONFIG_USB_PD_PORT_MAX_COUNT; ++port) ppc_vbus_sink_enable(port, 1); /* @@ -155,7 +155,7 @@ void board_hibernate(void) /******************************************************************************/ /* USB-C PPC Configuration */ -struct ppc_config_t ppc_chips[CONFIG_USB_PD_PORT_COUNT] = { +struct ppc_config_t ppc_chips[CONFIG_USB_PD_PORT_MAX_COUNT] = { [USB_PD_PORT_TCPC_0] = { .i2c_port = I2C_PORT_PPC0, .i2c_addr_flags = SN5S330_ADDR0_FLAGS, @@ -254,7 +254,7 @@ void board_reset_pd_mcu(void) int board_set_active_charge_port(int port) { int is_valid_port = (port >= 0 && - port < CONFIG_USB_PD_PORT_COUNT); + port < CONFIG_USB_PD_PORT_MAX_COUNT); int i; if (!is_valid_port && port != CHARGE_PORT_NONE) diff --git a/baseboard/hatch/baseboard.h b/baseboard/hatch/baseboard.h index 2b8b94ca00..ffe104c7bf 100644 --- a/baseboard/hatch/baseboard.h +++ b/baseboard/hatch/baseboard.h @@ -116,7 +116,7 @@ /* USB Type C and USB PD defines */ #define CONFIG_USB_POWER_DELIVERY -#define CONFIG_USB_PD_PORT_COUNT 2 +#define CONFIG_USB_PD_PORT_MAX_COUNT 2 #define CONFIG_USB_PD_MAX_SINGLE_SOURCE_CURRENT TYPEC_RP_3A0 #define CONFIG_USB_PD_TCPC_LOW_POWER #define CONFIG_USB_PD_DUAL_ROLE_AUTO_TOGGLE diff --git a/baseboard/hatch/usb_pd_policy.c b/baseboard/hatch/usb_pd_policy.c index 46ca0a84c3..0477edb499 100644 --- a/baseboard/hatch/usb_pd_policy.c +++ b/baseboard/hatch/usb_pd_policy.c @@ -252,8 +252,8 @@ int pd_custom_vdm(int port, int cnt, uint32_t *payload, } #ifdef CONFIG_USB_PD_ALT_MODE_DFP -static int dp_flags[CONFIG_USB_PD_PORT_COUNT]; -static uint32_t dp_status[CONFIG_USB_PD_PORT_COUNT]; +static int dp_flags[CONFIG_USB_PD_PORT_MAX_COUNT]; +static uint32_t dp_status[CONFIG_USB_PD_PORT_MAX_COUNT]; static void svdm_safe_dp_mode(int port) { diff --git a/baseboard/intelrvp/bc12.c b/baseboard/intelrvp/bc12.c index 4f1d1808cc..5a5807a325 100644 --- a/baseboard/intelrvp/bc12.c +++ b/baseboard/intelrvp/bc12.c @@ -10,7 +10,7 @@ /* BC1.2 chip Configuration */ #ifdef CONFIG_BC12_DETECT_MAX14637 -const struct max14637_config_t max14637_config[CONFIG_USB_PD_PORT_COUNT] = { +const struct max14637_config_t max14637_config[CONFIG_USB_PD_PORT_MAX_COUNT] = { [TYPE_C_PORT_0] = { .chip_enable_pin = GPIO_USB_C0_BC12_VBUS_ON_ODL, .chg_det_pin = GPIO_USB_C0_BC12_CHG_DET_L, @@ -24,5 +24,5 @@ const struct max14637_config_t max14637_config[CONFIG_USB_PD_PORT_COUNT] = { }, #endif /* HAS_TASK_PD_C1 */ }; -BUILD_ASSERT(ARRAY_SIZE(max14637_config) == CONFIG_USB_PD_PORT_COUNT); +BUILD_ASSERT(ARRAY_SIZE(max14637_config) == CONFIG_USB_PD_PORT_MAX_COUNT); #endif /* CONFIG_BC12_DETECT_MAX14637 */ diff --git a/baseboard/intelrvp/chg_usb_pd.c b/baseboard/intelrvp/chg_usb_pd.c index 86360caeae..7c8834806a 100644 --- a/baseboard/intelrvp/chg_usb_pd.c +++ b/baseboard/intelrvp/chg_usb_pd.c @@ -93,7 +93,7 @@ void board_tcpc_init(void) board_reset_pd_mcu(); /* Enable TCPCx interrupt */ - for (i = 0; i < CONFIG_USB_PD_PORT_COUNT; i++) + for (i = 0; i < CONFIG_USB_PD_PORT_MAX_COUNT; i++) gpio_enable_interrupt(tcpc_gpios[i].vbus.pin); } DECLARE_HOOK(HOOK_INIT, board_tcpc_init, HOOK_PRIO_INIT_I2C + 1); @@ -170,7 +170,7 @@ int board_set_active_charge_port(int port) } /* Make sure non-charging ports are disabled */ - for (i = 0; i < CONFIG_USB_PD_PORT_COUNT; i++) { + for (i = 0; i < CONFIG_USB_PD_PORT_MAX_COUNT; i++) { if (i == port) continue; diff --git a/baseboard/intelrvp/ite_ec.c b/baseboard/intelrvp/ite_ec.c index b5a3547269..2faa17ad08 100644 --- a/baseboard/intelrvp/ite_ec.c +++ b/baseboard/intelrvp/ite_ec.c @@ -14,7 +14,7 @@ #include "usb_pd_tcpm.h" /* USB-C TPCP Configuration */ -const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_COUNT] = { +const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_MAX_COUNT] = { [TYPE_C_PORT_0] = { .bus_type = EC_BUS_TYPE_EMBEDDED, /* TCPC is embedded within EC so no i2c config needed */ @@ -34,7 +34,7 @@ const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_COUNT] = { }, #endif /* HAS_TASK_PD_C1 */ }; -BUILD_ASSERT(ARRAY_SIZE(tcpc_config) == CONFIG_USB_PD_PORT_COUNT); +BUILD_ASSERT(ARRAY_SIZE(tcpc_config) == CONFIG_USB_PD_PORT_MAX_COUNT); /* Reset PD MCU */ void board_reset_pd_mcu(void) diff --git a/baseboard/intelrvp/retimer.c b/baseboard/intelrvp/retimer.c index 54c350017e..4ab6785d6f 100644 --- a/baseboard/intelrvp/retimer.c +++ b/baseboard/intelrvp/retimer.c @@ -11,7 +11,7 @@ /* USB Retimers configuration */ #ifdef CONFIG_USB_PD_RETIMER_INTEL_BB -struct bb_retimer bb_retimers[CONFIG_USB_PD_PORT_COUNT] = { +struct bb_retimer bb_retimers[CONFIG_USB_PD_PORT_MAX_COUNT] = { [TYPE_C_PORT_0] = { .i2c_port = I2C_PORT0_BB_RETIMER, .i2c_addr = I2C_PORT0_BB_RETIMER_ADDR, @@ -31,5 +31,5 @@ struct bb_retimer bb_retimers[CONFIG_USB_PD_PORT_COUNT] = { }, #endif /* HAS_TASK_PD_C1 */ }; -BUILD_ASSERT(ARRAY_SIZE(bb_retimers) == CONFIG_USB_PD_PORT_COUNT); +BUILD_ASSERT(ARRAY_SIZE(bb_retimers) == CONFIG_USB_PD_PORT_MAX_COUNT); #endif /* CONFIG_USB_PD_RETIMER_INTEL_BB */ diff --git a/baseboard/intelrvp/usb_mux.c b/baseboard/intelrvp/usb_mux.c index e4e45de188..2526fa5450 100644 --- a/baseboard/intelrvp/usb_mux.c +++ b/baseboard/intelrvp/usb_mux.c @@ -10,7 +10,7 @@ /* USB muxes Configuration */ #ifdef CONFIG_USB_MUX_VIRTUAL -struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_COUNT] = { +struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_MAX_COUNT] = { [TYPE_C_PORT_0] = { .driver = &virtual_usb_mux_driver, .hpd_update = &virtual_hpd_update, @@ -22,5 +22,5 @@ struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_COUNT] = { }, #endif /* HAS_TASK_PD_C1 */ }; -BUILD_ASSERT(ARRAY_SIZE(usb_muxes) == CONFIG_USB_PD_PORT_COUNT); +BUILD_ASSERT(ARRAY_SIZE(usb_muxes) == CONFIG_USB_PD_PORT_MAX_COUNT); #endif /* CONFIG_USB_MUX_VIRTUAL */ diff --git a/baseboard/intelrvp/usb_pd_policy.c b/baseboard/intelrvp/usb_pd_policy.c index dff7a89e46..db03f227b0 100644 --- a/baseboard/intelrvp/usb_pd_policy.c +++ b/baseboard/intelrvp/usb_pd_policy.c @@ -213,8 +213,8 @@ int pd_custom_vdm(int port, int cnt, uint32_t *payload, } #ifdef CONFIG_USB_PD_ALT_MODE_DFP -static int dp_flags[CONFIG_USB_PD_PORT_COUNT]; -static uint32_t dp_status[CONFIG_USB_PD_PORT_COUNT]; +static int dp_flags[CONFIG_USB_PD_PORT_MAX_COUNT]; +static uint32_t dp_status[CONFIG_USB_PD_PORT_MAX_COUNT]; static void svdm_safe_dp_mode(int port) { diff --git a/baseboard/kalista/baseboard.c b/baseboard/kalista/baseboard.c index c3c2fa4970..b466517496 100644 --- a/baseboard/kalista/baseboard.c +++ b/baseboard/kalista/baseboard.c @@ -138,7 +138,7 @@ const struct i2c_port_t i2c_ports[] = { const unsigned int i2c_ports_used = ARRAY_SIZE(i2c_ports); /* TCPC mux configuration */ -const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_COUNT] = { +const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_MAX_COUNT] = { /* Alert is active-low, push-pull */ { .bus_type = EC_BUS_TYPE_I2C, @@ -157,7 +157,7 @@ static int ps8751_tune_mux(int port) return EC_SUCCESS; } -struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_COUNT] = { +struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_MAX_COUNT] = { { .driver = &tcpci_tcpm_usb_mux_driver, .hpd_update = &ps8xxx_tcpc_update_hpd_status, @@ -202,7 +202,7 @@ void board_tcpc_init(void) * Initialize HPD to low; after sysjump SOC needs to see * HPD pulse to enable video path */ - for (port = 0; port < CONFIG_USB_PD_PORT_COUNT; port++) { + for (port = 0; port < CONFIG_USB_PD_PORT_MAX_COUNT; port++) { const struct usb_mux *mux = &usb_muxes[port]; mux->hpd_update(port, 0, 0); } diff --git a/baseboard/kalista/baseboard.h b/baseboard/kalista/baseboard.h index 751a1ae8a9..7f576cdb4f 100644 --- a/baseboard/kalista/baseboard.h +++ b/baseboard/kalista/baseboard.h @@ -89,7 +89,7 @@ #define CONFIG_USB_PD_ALT_MODE_DFP #define CONFIG_USB_PD_DISCHARGE_TCPC #define CONFIG_USB_PD_LOGGING -#define CONFIG_USB_PD_PORT_COUNT 1 +#define CONFIG_USB_PD_PORT_MAX_COUNT 1 #define CONFIG_USB_PD_VBUS_DETECT_GPIO #define CONFIG_USB_PD_TCPM_MUX #define CONFIG_USB_PD_TCPM_TCPCI diff --git a/baseboard/kalista/usb_pd_policy.c b/baseboard/kalista/usb_pd_policy.c index 107543a82a..ad40a95436 100644 --- a/baseboard/kalista/usb_pd_policy.c +++ b/baseboard/kalista/usb_pd_policy.c @@ -168,8 +168,8 @@ int pd_custom_vdm(int port, int cnt, uint32_t *payload, return 0; } -static int dp_flags[CONFIG_USB_PD_PORT_COUNT]; -static uint32_t dp_status[CONFIG_USB_PD_PORT_COUNT]; +static int dp_flags[CONFIG_USB_PD_PORT_MAX_COUNT]; +static uint32_t dp_status[CONFIG_USB_PD_PORT_MAX_COUNT]; static void svdm_safe_dp_mode(int port) { diff --git a/baseboard/kukui/baseboard.h b/baseboard/kukui/baseboard.h index 4b6467462c..2a1e5d43b0 100644 --- a/baseboard/kukui/baseboard.h +++ b/baseboard/kukui/baseboard.h @@ -174,7 +174,7 @@ #define CONFIG_USB_PD_ALT_MODE_DFP #define CONFIG_USB_PD_DUAL_ROLE #define CONFIG_USB_PD_LOGGING -#define CONFIG_USB_PD_PORT_COUNT 1 +#define CONFIG_USB_PD_PORT_MAX_COUNT 1 #define CONFIG_USB_PD_TCPM_TCPCI #define CONFIG_USB_PD_VBUS_DETECT_TCPC #define CONFIG_USB_PD_5V_EN_CUSTOM diff --git a/baseboard/kukui/usb_pd_policy.c b/baseboard/kukui/usb_pd_policy.c index 3258aef847..260cff54cc 100644 --- a/baseboard/kukui/usb_pd_policy.c +++ b/baseboard/kukui/usb_pd_policy.c @@ -236,9 +236,9 @@ int pd_custom_vdm(int port, int cnt, uint32_t *payload, } #ifdef CONFIG_USB_PD_ALT_MODE_DFP -static int dp_flags[CONFIG_USB_PD_PORT_COUNT]; +static int dp_flags[CONFIG_USB_PD_PORT_MAX_COUNT]; /* DP Status VDM as returned by UFP */ -static uint32_t dp_status[CONFIG_USB_PD_PORT_COUNT]; +static uint32_t dp_status[CONFIG_USB_PD_PORT_MAX_COUNT]; __overridable int board_has_virtual_mux(void) { @@ -326,7 +326,7 @@ static int svdm_dp_config(int port, uint32_t *payload) * timestamp of the next possible toggle to ensure the 2-ms spacing * between IRQ_HPD. */ -static uint64_t hpd_deadline[CONFIG_USB_PD_PORT_COUNT]; +static uint64_t hpd_deadline[CONFIG_USB_PD_PORT_MAX_COUNT]; static void svdm_dp_post_config(int port) { diff --git a/baseboard/octopus/baseboard.c b/baseboard/octopus/baseboard.c index 9bf8347756..f263f4a97e 100644 --- a/baseboard/octopus/baseboard.c +++ b/baseboard/octopus/baseboard.c @@ -64,7 +64,7 @@ const int usb_port_enable[USB_PORT_COUNT] = { /******************************************************************************/ /* BC 1.2 chip Configuration */ -const struct max14637_config_t max14637_config[CONFIG_USB_PD_PORT_COUNT] = { +const struct max14637_config_t max14637_config[CONFIG_USB_PD_PORT_MAX_COUNT] = { { .chip_enable_pin = GPIO_USB_C0_BC12_VBUS_ON, .chg_det_pin = GPIO_USB_C0_BC12_CHG_DET_L, @@ -211,7 +211,7 @@ void baseboard_tcpc_init(void) * Initialize HPD to low; after sysjump SOC needs to see * HPD pulse to enable video path */ - for (port = 0; port < CONFIG_USB_PD_PORT_COUNT; port++) { + for (port = 0; port < CONFIG_USB_PD_PORT_MAX_COUNT; port++) { const struct usb_mux *mux = &usb_muxes[port]; mux->hpd_update(port, 0, 0); @@ -223,7 +223,7 @@ DECLARE_HOOK(HOOK_INIT, baseboard_tcpc_init, HOOK_PRIO_INIT_I2C + 2); int board_set_active_charge_port(int port) { int is_valid_port = (port >= 0 && - port < CONFIG_USB_PD_PORT_COUNT); + port < CONFIG_USB_PD_PORT_MAX_COUNT); int i; if (!is_valid_port && port != CHARGE_PORT_NONE) @@ -329,7 +329,7 @@ void board_hibernate(void) * low power mode or open the SNK FET based on which signals wake up * the EC from hibernate. */ - for (port = 0; port < CONFIG_USB_PD_PORT_COUNT; port++) { + for (port = 0; port < CONFIG_USB_PD_PORT_MAX_COUNT; port++) { if (!pd_is_vbus_present(port)) { #ifdef VARIANT_OCTOPUS_EC_ITE8320 /* diff --git a/baseboard/octopus/baseboard.h b/baseboard/octopus/baseboard.h index 83e708715d..4001c2bb2d 100644 --- a/baseboard/octopus/baseboard.h +++ b/baseboard/octopus/baseboard.h @@ -184,7 +184,7 @@ /* Common USB-C defines */ #define CONFIG_USB_POWER_DELIVERY -#define CONFIG_USB_PD_PORT_COUNT 2 +#define CONFIG_USB_PD_PORT_MAX_COUNT 2 #define CONFIG_USB_PD_DUAL_ROLE #define CONFIG_USB_PD_LOGGING #define CONFIG_USB_PD_ALT_MODE diff --git a/baseboard/octopus/usb_pd_policy.c b/baseboard/octopus/usb_pd_policy.c index 0f4bc06440..1dccc424d6 100644 --- a/baseboard/octopus/usb_pd_policy.c +++ b/baseboard/octopus/usb_pd_policy.c @@ -254,8 +254,8 @@ int pd_custom_vdm(int port, int cnt, uint32_t *payload, } #ifdef CONFIG_USB_PD_ALT_MODE_DFP -static int dp_flags[CONFIG_USB_PD_PORT_COUNT]; -static uint32_t dp_status[CONFIG_USB_PD_PORT_COUNT]; +static int dp_flags[CONFIG_USB_PD_PORT_MAX_COUNT]; +static uint32_t dp_status[CONFIG_USB_PD_PORT_MAX_COUNT]; static void svdm_safe_dp_mode(int port) { diff --git a/baseboard/octopus/variant_usbc_ec_tcpcs.c b/baseboard/octopus/variant_usbc_ec_tcpcs.c index cd119acc80..a247ef6452 100644 --- a/baseboard/octopus/variant_usbc_ec_tcpcs.c +++ b/baseboard/octopus/variant_usbc_ec_tcpcs.c @@ -27,7 +27,7 @@ /******************************************************************************/ /* USB-C TPCP Configuration */ -const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_COUNT] = { +const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_MAX_COUNT] = { [USB_PD_PORT_ITE_0] = { .bus_type = EC_BUS_TYPE_EMBEDDED, /* TCPC is embedded within EC so no i2c config needed */ @@ -65,7 +65,7 @@ static void board_it83xx_hpd_status(int port, int hpd_lvl, int hpd_irq) } /* This configuration might be override by each boards */ -struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_COUNT] = { +struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_MAX_COUNT] = { [USB_PD_PORT_ITE_0] = { /* Driver uses I2C_PORT_USB_MUX as I2C port */ .port_addr = IT5205_I2C_ADDR1_FLAGS, @@ -84,7 +84,7 @@ struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_COUNT] = { /******************************************************************************/ /* USB-C PPC Configuration */ -struct ppc_config_t ppc_chips[CONFIG_USB_PD_PORT_COUNT] = { +struct ppc_config_t ppc_chips[CONFIG_USB_PD_PORT_MAX_COUNT] = { [USB_PD_PORT_ITE_0] = { .i2c_port = I2C_PORT_USBC0, .i2c_addr_flags = SN5S330_ADDR0_FLAGS, diff --git a/baseboard/octopus/variant_usbc_standalone_tcpcs.c b/baseboard/octopus/variant_usbc_standalone_tcpcs.c index 567d26341a..41025de7fa 100644 --- a/baseboard/octopus/variant_usbc_standalone_tcpcs.c +++ b/baseboard/octopus/variant_usbc_standalone_tcpcs.c @@ -29,7 +29,7 @@ /******************************************************************************/ /* USB-C TPCP Configuration */ -const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_COUNT] = { +const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_MAX_COUNT] = { [USB_PD_PORT_TCPC_0] = { #if defined(VARIANT_OCTOPUS_TCPC_0_PS8751) .bus_type = EC_BUS_TYPE_I2C, @@ -69,7 +69,7 @@ static int ps8751_tune_mux(int port) } #endif -struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_COUNT] = { +struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_MAX_COUNT] = { [USB_PD_PORT_TCPC_0] = { #if defined(VARIANT_OCTOPUS_TCPC_0_PS8751) .driver = &tcpci_tcpm_usb_mux_driver, @@ -88,7 +88,7 @@ struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_COUNT] = { /******************************************************************************/ /* USB-C PPC Configuration */ -struct ppc_config_t ppc_chips[CONFIG_USB_PD_PORT_COUNT] = { +struct ppc_config_t ppc_chips[CONFIG_USB_PD_PORT_MAX_COUNT] = { [USB_PD_PORT_TCPC_0] = { .i2c_port = I2C_PORT_TCPC0, .i2c_addr_flags = NX20P3483_ADDR2_FLAGS, diff --git a/baseboard/zork/baseboard.c b/baseboard/zork/baseboard.c index 2bbf4cc1bb..44f23a4938 100644 --- a/baseboard/zork/baseboard.c +++ b/baseboard/zork/baseboard.c @@ -244,7 +244,7 @@ void ppc_interrupt(enum gpio_signal signal) int board_set_active_charge_port(int port) { int is_valid_port = (port >= 0 && - port < CONFIG_USB_PD_PORT_COUNT); + port < CONFIG_USB_PD_PORT_MAX_COUNT); int i; if (port == CHARGE_PORT_NONE) { @@ -314,7 +314,7 @@ const struct tcpc_config_t tcpc_config[] = { }, }; BUILD_ASSERT(ARRAY_SIZE(tcpc_config) == USBC_PORT_COUNT); -BUILD_ASSERT(CONFIG_USB_PD_PORT_COUNT == USBC_PORT_COUNT); +BUILD_ASSERT(CONFIG_USB_PD_PORT_MAX_COUNT == USBC_PORT_COUNT); const struct pi3usb9201_config_t pi3usb9201_bc12_chips[] = { [USBC_PORT_C0] = { diff --git a/baseboard/zork/baseboard.h b/baseboard/zork/baseboard.h index 66d12bb316..b0070e86f3 100644 --- a/baseboard/zork/baseboard.h +++ b/baseboard/zork/baseboard.h @@ -125,7 +125,7 @@ #define CONFIG_USB_PD_DUAL_ROLE_AUTO_TOGGLE #define CONFIG_USB_PD_LOGGING #define CONFIG_USB_PD_MAX_SINGLE_SOURCE_CURRENT TYPEC_RP_3A0 -#define CONFIG_USB_PD_PORT_COUNT 2 +#define CONFIG_USB_PD_PORT_MAX_COUNT 2 #define CONFIG_USB_PD_TCPC_LOW_POWER #define CONFIG_USB_PD_TCPM_MUX #define CONFIG_USB_PD_TCPM_NCT38XX diff --git a/baseboard/zork/usb_pd_policy.c b/baseboard/zork/usb_pd_policy.c index 48b9101c01..9c61a020db 100644 --- a/baseboard/zork/usb_pd_policy.c +++ b/baseboard/zork/usb_pd_policy.c @@ -252,8 +252,8 @@ int pd_custom_vdm(int port, int cnt, uint32_t *payload, } #ifdef CONFIG_USB_PD_ALT_MODE_DFP -static int dp_flags[CONFIG_USB_PD_PORT_COUNT]; -static uint32_t dp_status[CONFIG_USB_PD_PORT_COUNT]; +static int dp_flags[CONFIG_USB_PD_PORT_MAX_COUNT]; +static uint32_t dp_status[CONFIG_USB_PD_PORT_MAX_COUNT]; static int svdm_enter_dp_mode(int port, uint32_t mode_caps) { @@ -348,7 +348,7 @@ static int svdm_dp_config(int port, uint32_t *payload) * timestamp of the next possible toggle to ensure the 2-ms spacing * between IRQ_HPD. */ -static uint64_t hpd_deadline[CONFIG_USB_PD_PORT_COUNT]; +static uint64_t hpd_deadline[CONFIG_USB_PD_PORT_MAX_COUNT]; #define PORT_TO_HPD(port) ((port) ? GPIO_DP2_HPD : GPIO_USB_C0_HPD) static void svdm_dp_post_config(int port) diff --git a/board/akemi/board.c b/board/akemi/board.c index ab973bb581..f4af724a8d 100644 --- a/board/akemi/board.c +++ b/board/akemi/board.c @@ -120,7 +120,7 @@ BUILD_ASSERT(ARRAY_SIZE(pwm_channels) == PWM_CH_COUNT); /******************************************************************************/ /* USB-C TPCP Configuration */ -const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_COUNT] = { +const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_MAX_COUNT] = { [USB_PD_PORT_TCPC_0] = { .bus_type = EC_BUS_TYPE_I2C, .i2c_info = { @@ -140,7 +140,7 @@ const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_COUNT] = { }, }; -struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_COUNT] = { +struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_MAX_COUNT] = { [USB_PD_PORT_TCPC_0] = { .driver = &anx7447_usb_mux_driver, .hpd_update = &anx7447_tcpc_update_hpd_status, @@ -368,7 +368,7 @@ DECLARE_HOOK(HOOK_INIT, board_init, HOOK_PRIO_DEFAULT); void board_overcurrent_event(int port, int is_overcurrented) { /* Sanity check the port. */ - if ((port < 0) || (port >= CONFIG_USB_PD_PORT_COUNT)) + if ((port < 0) || (port >= CONFIG_USB_PD_PORT_MAX_COUNT)) return; /* Note that the level is inverted because the pin is active low. */ diff --git a/board/ampton/battery.c b/board/ampton/battery.c index 2bc0aa3482..481216cf61 100644 --- a/board/ampton/battery.c +++ b/board/ampton/battery.c @@ -133,7 +133,7 @@ static void reduce_input_voltage_when_full(void) else max_pd_voltage_mv = PD_MAX_VOLTAGE_MV; if (pd_get_max_voltage() != max_pd_voltage_mv) { - for (port = 0; port < CONFIG_USB_PD_PORT_COUNT; port++) + for (port = 0; port < CONFIG_USB_PD_PORT_MAX_COUNT; port++) pd_set_external_voltage_limit(port, max_pd_voltage_mv); } } diff --git a/board/ampton/board.c b/board/ampton/board.c index 8c821eeb62..0025ae2567 100644 --- a/board/ampton/board.c +++ b/board/ampton/board.c @@ -68,7 +68,7 @@ int ppc_get_alert_status(int port) static int tune_mux(int port); -struct usb_mux ampton_usb_muxes[CONFIG_USB_PD_PORT_COUNT] = { +struct usb_mux ampton_usb_muxes[CONFIG_USB_PD_PORT_MAX_COUNT] = { [USB_PD_PORT_ITE_0] = { /* Use PS8751 as mux only */ .port_addr = MUX_PORT_AND_ADDR( diff --git a/board/atlas/board.c b/board/atlas/board.c index 10c918679b..76fd2c1b22 100644 --- a/board/atlas/board.c +++ b/board/atlas/board.c @@ -152,7 +152,7 @@ const struct i2c_port_t i2c_ports[] = { const unsigned int i2c_ports_used = ARRAY_SIZE(i2c_ports); /* TCPC mux configuration */ -const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_COUNT] = { +const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_MAX_COUNT] = { { /* left port */ .bus_type = EC_BUS_TYPE_I2C, @@ -177,7 +177,7 @@ const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_COUNT] = { }, }; -struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_COUNT] = { +struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_MAX_COUNT] = { { .driver = &tcpci_tcpm_usb_mux_driver, .hpd_update = &ps8xxx_tcpc_update_hpd_status, @@ -210,7 +210,7 @@ void board_tcpc_init(void) * Initialize HPD to low; after sysjump SOC needs to see * HPD pulse to enable video path */ - for (port = 0; port < CONFIG_USB_PD_PORT_COUNT; port++) { + for (port = 0; port < CONFIG_USB_PD_PORT_MAX_COUNT; port++) { const struct usb_mux *mux = &usb_muxes[port]; mux->hpd_update(port, 0, 0); @@ -482,7 +482,7 @@ int board_set_active_charge_port(int charge_port) { /* charge port is a physical port */ int is_real_port = (charge_port >= 0 && - charge_port < CONFIG_USB_PD_PORT_COUNT); + charge_port < CONFIG_USB_PD_PORT_MAX_COUNT); /* check if we are sourcing VBUS on the port */ int is_source = gpio_get_level(charge_port == 0 ? GPIO_USB_C0_5V_EN : GPIO_USB_C1_5V_EN); diff --git a/board/atlas/board.h b/board/atlas/board.h index 23ce6b22c5..b7c64b96da 100644 --- a/board/atlas/board.h +++ b/board/atlas/board.h @@ -132,7 +132,7 @@ #define CONFIG_USB_PD_DUAL_ROLE_AUTO_TOGGLE #define CONFIG_USB_PD_LOGGING #define CONFIG_USB_PD_MAX_SINGLE_SOURCE_CURRENT TYPEC_RP_3A0 -#define CONFIG_USB_PD_PORT_COUNT 2 +#define CONFIG_USB_PD_PORT_MAX_COUNT 2 #define CONFIG_USB_PD_VBUS_DETECT_TCPC #define CONFIG_USB_PD_TCPC_LOW_POWER #define CONFIG_USB_PD_TCPM_MUX diff --git a/board/atlas/usb_pd_policy.c b/board/atlas/usb_pd_policy.c index a65a018752..a66411f931 100644 --- a/board/atlas/usb_pd_policy.c +++ b/board/atlas/usb_pd_policy.c @@ -55,8 +55,9 @@ void pd_transition_voltage(int idx) /* No-operation: we are always 5V */ } -static uint8_t vbus_en[CONFIG_USB_PD_PORT_COUNT]; -static uint8_t vbus_rp[CONFIG_USB_PD_PORT_COUNT] = {TYPEC_RP_1A5, TYPEC_RP_1A5}; +static uint8_t vbus_en[CONFIG_USB_PD_PORT_MAX_COUNT]; +static uint8_t vbus_rp[CONFIG_USB_PD_PORT_MAX_COUNT] = {TYPEC_RP_1A5, + TYPEC_RP_1A5}; int board_vbus_source_enabled(int port) { @@ -280,8 +281,8 @@ int pd_custom_vdm(int port, int cnt, uint32_t *payload, } #ifdef CONFIG_USB_PD_ALT_MODE_DFP -static int dp_flags[CONFIG_USB_PD_PORT_COUNT]; -static uint32_t dp_status[CONFIG_USB_PD_PORT_COUNT]; +static int dp_flags[CONFIG_USB_PD_PORT_MAX_COUNT]; +static uint32_t dp_status[CONFIG_USB_PD_PORT_MAX_COUNT]; static void svdm_safe_dp_mode(int port) { diff --git a/board/bloog/board.c b/board/bloog/board.c index 14f522a285..42049d0ef7 100644 --- a/board/bloog/board.c +++ b/board/bloog/board.c @@ -305,7 +305,7 @@ const int keyboard_factory_scan_pins_used = void board_overcurrent_event(int port, int is_overcurrented) { /* Sanity check the port. */ - if ((port < 0) || (port >= CONFIG_USB_PD_PORT_COUNT)) + if ((port < 0) || (port >= CONFIG_USB_PD_PORT_MAX_COUNT)) return; /* Note that the level is inverted because the pin is active low. */ diff --git a/board/bobba/board.c b/board/bobba/board.c index 9f34cbc815..61503cce4d 100644 --- a/board/bobba/board.c +++ b/board/bobba/board.c @@ -399,7 +399,7 @@ void lid_angle_peripheral_enable(int enable) void board_overcurrent_event(int port, int is_overcurrented) { /* Sanity check the port. */ - if ((port < 0) || (port >= CONFIG_USB_PD_PORT_COUNT)) + if ((port < 0) || (port >= CONFIG_USB_PD_PORT_MAX_COUNT)) return; /* Note that the level is inverted because the pin is active low. */ diff --git a/board/casta/board.c b/board/casta/board.c index 6d7bd9cf46..a14e669a01 100644 --- a/board/casta/board.c +++ b/board/casta/board.c @@ -146,7 +146,7 @@ DECLARE_HOOK(HOOK_INIT, board_init, HOOK_PRIO_DEFAULT); void board_overcurrent_event(int port, int is_overcurrented) { /* Sanity check the port. */ - if ((port < 0) || (port >= CONFIG_USB_PD_PORT_COUNT)) + if ((port < 0) || (port >= CONFIG_USB_PD_PORT_MAX_COUNT)) return; /* Note that the level is inverted because the pin is active low. */ diff --git a/board/chell/board.c b/board/chell/board.c index 64e4e13b5f..7b56ca621a 100644 --- a/board/chell/board.c +++ b/board/chell/board.c @@ -106,7 +106,7 @@ const struct i2c_port_t i2c_ports[] = { }; const unsigned int i2c_ports_used = ARRAY_SIZE(i2c_ports); -const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_COUNT] = { +const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_MAX_COUNT] = { { .bus_type = EC_BUS_TYPE_I2C, .i2c_info = { @@ -181,7 +181,7 @@ static int ps874x_tune_mux(int port) return EC_SUCCESS; } -struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_COUNT] = { +struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_MAX_COUNT] = { { .port_addr = 0x1A, .driver = &ps874x_usb_mux_driver, @@ -303,7 +303,7 @@ int board_set_active_charge_port(int charge_port) { /* charge port is a realy physical port */ int is_real_port = (charge_port >= 0 && - charge_port < CONFIG_USB_PD_PORT_COUNT); + charge_port < CONFIG_USB_PD_PORT_MAX_COUNT); /* check if we are source vbus on that port */ int source = gpio_get_level(charge_port == 0 ? GPIO_USB_C0_5V_EN : GPIO_USB_C1_5V_EN); diff --git a/board/chell/board.h b/board/chell/board.h index 5686d0aa28..c11e9218fc 100644 --- a/board/chell/board.h +++ b/board/chell/board.h @@ -75,7 +75,7 @@ #define CONFIG_USB_PD_COMM_LOCKED #define CONFIG_USB_PD_DUAL_ROLE #define CONFIG_USB_PD_LOGGING -#define CONFIG_USB_PD_PORT_COUNT 2 +#define CONFIG_USB_PD_PORT_MAX_COUNT 2 #define CONFIG_USB_PD_TCPM_TCPCI #define CONFIG_USB_PD_TRY_SRC #define CONFIG_USB_PD_VBUS_DETECT_GPIO diff --git a/board/chell/usb_pd_policy.c b/board/chell/usb_pd_policy.c index 7031a39bcc..3a2a6b2afc 100644 --- a/board/chell/usb_pd_policy.c +++ b/board/chell/usb_pd_policy.c @@ -196,9 +196,9 @@ int pd_custom_vdm(int port, int cnt, uint32_t *payload, } #ifdef CONFIG_USB_PD_ALT_MODE_DFP -static int dp_flags[CONFIG_USB_PD_PORT_COUNT]; +static int dp_flags[CONFIG_USB_PD_PORT_MAX_COUNT]; /* DP Status VDM as returned by UFP */ -static uint32_t dp_status[CONFIG_USB_PD_PORT_COUNT]; +static uint32_t dp_status[CONFIG_USB_PD_PORT_MAX_COUNT]; static void svdm_safe_dp_mode(int port) { @@ -261,7 +261,7 @@ static int svdm_dp_config(int port, uint32_t *payload) * timestamp of the next possible toggle to ensure the 2-ms spacing * between IRQ_HPD. */ -static uint64_t hpd_deadline[CONFIG_USB_PD_PORT_COUNT]; +static uint64_t hpd_deadline[CONFIG_USB_PD_PORT_MAX_COUNT]; #define PORT_TO_HPD(port) ((port) ? GPIO_USB_C1_DP_HPD : GPIO_USB_C0_DP_HPD) static void svdm_dp_post_config(int port) diff --git a/board/cheza/board.c b/board/cheza/board.c index 1a8400fadb..8fb927d436 100644 --- a/board/cheza/board.c +++ b/board/cheza/board.c @@ -255,7 +255,7 @@ struct ppc_config_t ppc_chips[] = { unsigned int ppc_cnt = ARRAY_SIZE(ppc_chips); /* TCPC mux configuration */ -const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_COUNT] = { +const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_MAX_COUNT] = { /* Alert is active-low, open-drain */ [USB_PD_PORT_ANX3429] = { .bus_type = EC_BUS_TYPE_I2C, @@ -354,7 +354,7 @@ const struct usb_mux_driver port1_usb_mux_driver = { .enter_low_power_mode = &port1_usb_mux_enter_low_power, }; -struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_COUNT] = { +struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_MAX_COUNT] = { { .driver = &port0_usb_mux_driver, .hpd_update = &virtual_hpd_update, @@ -417,7 +417,7 @@ void board_tcpc_init(void) * Initialize HPD to low; after sysjump SOC needs to see * HPD pulse to enable video path */ - for (port = 0; port < CONFIG_USB_PD_PORT_COUNT; port++) { + for (port = 0; port < CONFIG_USB_PD_PORT_MAX_COUNT; port++) { const struct usb_mux *mux = &usb_muxes[port]; mux->hpd_update(port, 0, 0); @@ -534,7 +534,7 @@ void board_overcurrent_event(int port, int is_overcurrented) int board_set_active_charge_port(int port) { int is_real_port = (port >= 0 && - port < CONFIG_USB_PD_PORT_COUNT); + port < CONFIG_USB_PD_PORT_MAX_COUNT); int i; int rv; @@ -545,7 +545,7 @@ int board_set_active_charge_port(int port) if (port == CHARGE_PORT_NONE) { /* Disable all ports. */ - for (i = 0; i < CONFIG_USB_PD_PORT_COUNT; i++) { + for (i = 0; i < CONFIG_USB_PD_PORT_MAX_COUNT; i++) { rv = board_vbus_sink_enable(i, 0); if (rv) { CPRINTS("Disabling p%d sink path failed.", i); @@ -566,7 +566,7 @@ int board_set_active_charge_port(int port) * Turn off the other ports' sink path FETs, before enabling the * requested charge port. */ - for (i = 0; i < CONFIG_USB_PD_PORT_COUNT; i++) { + for (i = 0; i < CONFIG_USB_PD_PORT_MAX_COUNT; i++) { if (i == port) continue; diff --git a/board/cheza/board.h b/board/cheza/board.h index e7e524c06a..76e64277b5 100644 --- a/board/cheza/board.h +++ b/board/cheza/board.h @@ -106,7 +106,7 @@ #define CONFIG_USB_PD_DUAL_ROLE_AUTO_TOGGLE #define CONFIG_USB_PD_LOGGING #define CONFIG_USB_PD_MAX_SINGLE_SOURCE_CURRENT TYPEC_RP_3A0 -#define CONFIG_USB_PD_PORT_COUNT 2 +#define CONFIG_USB_PD_PORT_MAX_COUNT 2 #define CONFIG_USB_PD_TCPC_LOW_POWER #define CONFIG_USB_PD_TCPM_ANX3429 #define CONFIG_USB_PD_TCPM_PS8751 diff --git a/board/cheza/usb_pd_policy.c b/board/cheza/usb_pd_policy.c index d0ef297431..502a773150 100644 --- a/board/cheza/usb_pd_policy.c +++ b/board/cheza/usb_pd_policy.c @@ -133,8 +133,9 @@ int pd_is_valid_input_voltage(int mv) return 1; } -static uint8_t vbus_en[CONFIG_USB_PD_PORT_COUNT]; -static uint8_t vbus_rp[CONFIG_USB_PD_PORT_COUNT] = {TYPEC_RP_1A5, TYPEC_RP_1A5}; +static uint8_t vbus_en[CONFIG_USB_PD_PORT_MAX_COUNT]; +static uint8_t vbus_rp[CONFIG_USB_PD_PORT_MAX_COUNT] = {TYPEC_RP_1A5, + TYPEC_RP_1A5}; static void board_vbus_update_source_current(int port) { @@ -300,8 +301,8 @@ int pd_custom_vdm(int port, int cnt, uint32_t *payload, } #ifdef CONFIG_USB_PD_ALT_MODE_DFP -static int dp_flags[CONFIG_USB_PD_PORT_COUNT]; -static uint32_t dp_status[CONFIG_USB_PD_PORT_COUNT]; +static int dp_flags[CONFIG_USB_PD_PORT_MAX_COUNT]; +static uint32_t dp_status[CONFIG_USB_PD_PORT_MAX_COUNT]; static void svdm_safe_dp_mode(int port) { @@ -374,7 +375,7 @@ static int is_dp_muxable(int port) int i; const char *dp_str, *usb_str; - for (i = 0; i < CONFIG_USB_PD_PORT_COUNT; i++) + for (i = 0; i < CONFIG_USB_PD_PORT_MAX_COUNT; i++) if (i != port) { usb_mux_get(i, &dp_str, &usb_str); if (dp_str) diff --git a/board/chocodile_vpdmcu/board.h b/board/chocodile_vpdmcu/board.h index dc90b5f764..0ddf3374c0 100644 --- a/board/chocodile_vpdmcu/board.h +++ b/board/chocodile_vpdmcu/board.h @@ -57,7 +57,7 @@ #undef CONFIG_UART_TX_DMA #undef CONFIG_UART_RX_DMA #define CONFIG_UART_TX_BUF_SIZE 128 -#define CONFIG_USB_PD_PORT_COUNT 1 +#define CONFIG_USB_PD_PORT_MAX_COUNT 1 #define CONFIG_USB_PD_TCPC #define CONFIG_USB_PD_VBUS_DETECT_NONE #define CONFIG_USB_PD_TCPM_STUB diff --git a/board/coffeecake/board.h b/board/coffeecake/board.h index 77abfa7f99..62dea70847 100644 --- a/board/coffeecake/board.h +++ b/board/coffeecake/board.h @@ -49,7 +49,7 @@ #define CONFIG_USB_PD_LOGGING #undef CONFIG_EVENT_LOG_SIZE #define CONFIG_EVENT_LOG_SIZE 256 -#define CONFIG_USB_PD_PORT_COUNT 1 +#define CONFIG_USB_PD_PORT_MAX_COUNT 1 #define CONFIG_USB_PD_TCPC #define CONFIG_USB_PD_TCPM_STUB #define CONFIG_USB_PD_VBUS_DETECT_NONE diff --git a/board/coral/board.c b/board/coral/board.c index 40d7a211b3..91df786a1a 100644 --- a/board/coral/board.c +++ b/board/coral/board.c @@ -221,7 +221,7 @@ struct i2c_stress_test i2c_stress_tests[] = { const int i2c_test_dev_used = ARRAY_SIZE(i2c_stress_tests); #endif /* CONFIG_CMD_I2C_STRESS_TEST */ -const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_COUNT] = { +const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_MAX_COUNT] = { [USB_PD_PORT_ANX74XX] = { .bus_type = EC_BUS_TYPE_I2C, .i2c_info = { @@ -272,7 +272,7 @@ static int ps8751_tune_mux(int port) return EC_SUCCESS; } -struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_COUNT] = { +struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_MAX_COUNT] = { [USB_PD_PORT_ANX74XX] = { .driver = &anx74xx_tcpm_usb_mux_driver, .hpd_update = &anx74xx_tcpc_update_hpd_status, @@ -389,7 +389,7 @@ static void board_tcpc_init(void) * Initialize HPD to low; after sysjump SOC needs to see * HPD pulse to enable video path */ - for (port = 0; port < CONFIG_USB_PD_PORT_COUNT; port++) { + for (port = 0; port < CONFIG_USB_PD_PORT_MAX_COUNT; port++) { const struct usb_mux *mux = &usb_muxes[port]; mux->hpd_update(port, 0, 0); diff --git a/board/coral/board.h b/board/coral/board.h index 4bb007ea5e..a4d4f393b4 100644 --- a/board/coral/board.h +++ b/board/coral/board.h @@ -85,7 +85,7 @@ #define CONFIG_USB_PD_DISCHARGE_TCPC #define CONFIG_USB_PD_LOGGING #define CONFIG_USB_PD_MAX_SINGLE_SOURCE_CURRENT TYPEC_RP_3A0 -#define CONFIG_USB_PD_PORT_COUNT 2 +#define CONFIG_USB_PD_PORT_MAX_COUNT 2 #define CONFIG_USB_PD_VBUS_DETECT_CHARGER #define CONFIG_USB_PD_TCPC_LOW_POWER #define CONFIG_USB_PD_TCPM_MUX /* for both PS8751 and ANX3429 */ diff --git a/board/coral/usb_pd_policy.c b/board/coral/usb_pd_policy.c index d2ceecf074..9765b540d1 100644 --- a/board/coral/usb_pd_policy.c +++ b/board/coral/usb_pd_policy.c @@ -56,8 +56,9 @@ void pd_transition_voltage(int idx) /* No-operation: we are always 5V */ } -static uint8_t vbus_en[CONFIG_USB_PD_PORT_COUNT]; -static uint8_t vbus_rp[CONFIG_USB_PD_PORT_COUNT] = {TYPEC_RP_1A5, TYPEC_RP_1A5}; +static uint8_t vbus_en[CONFIG_USB_PD_PORT_MAX_COUNT]; +static uint8_t vbus_rp[CONFIG_USB_PD_PORT_MAX_COUNT] = {TYPEC_RP_1A5, + TYPEC_RP_1A5}; int board_vbus_source_enabled(int port) { @@ -270,8 +271,8 @@ int pd_custom_vdm(int port, int cnt, uint32_t *payload, } #ifdef CONFIG_USB_PD_ALT_MODE_DFP -static int dp_flags[CONFIG_USB_PD_PORT_COUNT]; -static uint32_t dp_status[CONFIG_USB_PD_PORT_COUNT]; +static int dp_flags[CONFIG_USB_PD_PORT_MAX_COUNT]; +static uint32_t dp_status[CONFIG_USB_PD_PORT_MAX_COUNT]; static void svdm_safe_dp_mode(int port) { diff --git a/board/dingdong/board.h b/board/dingdong/board.h index 56d6495d78..8a0a835f92 100644 --- a/board/dingdong/board.h +++ b/board/dingdong/board.h @@ -39,7 +39,7 @@ #define CONFIG_USB_PD_LOGGING #undef CONFIG_EVENT_LOG_SIZE #define CONFIG_EVENT_LOG_SIZE 256 -#define CONFIG_USB_PD_PORT_COUNT 1 +#define CONFIG_USB_PD_PORT_MAX_COUNT 1 #define CONFIG_USB_PD_TCPC #define CONFIG_USB_PD_TCPM_STUB #undef CONFIG_WATCHDOG_HELP diff --git a/board/dood/board.c b/board/dood/board.c index 04fcdd6663..b246b83e1d 100644 --- a/board/dood/board.c +++ b/board/dood/board.c @@ -281,7 +281,7 @@ void lid_angle_peripheral_enable(int enable) void board_overcurrent_event(int port, int is_overcurrented) { /* Sanity check the port. */ - if ((port < 0) || (port >= CONFIG_USB_PD_PORT_COUNT)) + if ((port < 0) || (port >= CONFIG_USB_PD_PORT_MAX_COUNT)) return; /* Note that the level is inverted because the pin is active low. */ diff --git a/board/dratini/board.c b/board/dratini/board.c index f86436f856..2b0f8ef83c 100644 --- a/board/dratini/board.c +++ b/board/dratini/board.c @@ -126,7 +126,7 @@ BUILD_ASSERT(ARRAY_SIZE(pwm_channels) == PWM_CH_COUNT); /******************************************************************************/ /* USB-C TPCP Configuration */ -const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_COUNT] = { +const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_MAX_COUNT] = { [USB_PD_PORT_TCPC_0] = { .bus_type = EC_BUS_TYPE_I2C, .i2c_info = { @@ -146,7 +146,7 @@ const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_COUNT] = { }, }; -struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_COUNT] = { +struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_MAX_COUNT] = { [USB_PD_PORT_TCPC_0] = { .driver = &anx7447_usb_mux_driver, .hpd_update = &anx7447_tcpc_update_hpd_status, @@ -399,7 +399,7 @@ DECLARE_HOOK(HOOK_INIT, board_init, HOOK_PRIO_DEFAULT); void board_overcurrent_event(int port, int is_overcurrented) { /* Sanity check the port. */ - if ((port < 0) || (port >= CONFIG_USB_PD_PORT_COUNT)) + if ((port < 0) || (port >= CONFIG_USB_PD_PORT_MAX_COUNT)) return; /* Note that the level is inverted because the pin is active low. */ diff --git a/board/elm/board.c b/board/elm/board.c index 7dfc0a503d..80cc6ff02f 100644 --- a/board/elm/board.c +++ b/board/elm/board.c @@ -123,7 +123,7 @@ const struct spi_device_t spi_devices[] = { const unsigned int spi_devices_used = ARRAY_SIZE(spi_devices); /* TCPC */ -const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_COUNT] = { +const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_MAX_COUNT] = { { .bus_type = EC_BUS_TYPE_I2C, .i2c_info = { @@ -162,7 +162,7 @@ const struct temp_sensor_t temp_sensors[] = { }; BUILD_ASSERT(ARRAY_SIZE(temp_sensors) == TEMP_SENSOR_COUNT); -struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_COUNT] = { +struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_MAX_COUNT] = { { .driver = &anx7688_usb_mux_driver, }, @@ -291,7 +291,7 @@ int board_set_active_charge_port(int charge_port) { /* charge port is a physical port */ int is_real_port = (charge_port >= 0 && - charge_port < CONFIG_USB_PD_PORT_COUNT); + charge_port < CONFIG_USB_PD_PORT_MAX_COUNT); /* check if we are source VBUS on the port */ int source = gpio_get_level(GPIO_USB_C0_5V_EN); diff --git a/board/elm/board.h b/board/elm/board.h index 555447f06b..e9269b0775 100644 --- a/board/elm/board.h +++ b/board/elm/board.h @@ -92,7 +92,7 @@ #define CONFIG_USB_PD_LOGGING -#define CONFIG_USB_PD_PORT_COUNT 1 +#define CONFIG_USB_PD_PORT_MAX_COUNT 1 #define CONFIG_USB_PD_TCPM_MUX #define CONFIG_USB_PD_TCPM_ANX7688 #define CONFIG_USB_PD_TCPM_TCPCI diff --git a/board/elm/usb_pd_policy.c b/board/elm/usb_pd_policy.c index 766d38cc5c..11e1ca2c6a 100644 --- a/board/elm/usb_pd_policy.c +++ b/board/elm/usb_pd_policy.c @@ -209,9 +209,9 @@ int pd_custom_vdm(int port, int cnt, uint32_t *payload, } #ifdef CONFIG_USB_PD_ALT_MODE_DFP -static int dp_flags[CONFIG_USB_PD_PORT_COUNT]; +static int dp_flags[CONFIG_USB_PD_PORT_MAX_COUNT]; /* DP Status VDM as returned by UFP */ -static uint32_t dp_status[CONFIG_USB_PD_PORT_COUNT]; +static uint32_t dp_status[CONFIG_USB_PD_PORT_MAX_COUNT]; static void svdm_safe_dp_mode(int port) { diff --git a/board/eve/board.c b/board/eve/board.c index 4d408915f7..e58bca9efd 100644 --- a/board/eve/board.c +++ b/board/eve/board.c @@ -202,7 +202,7 @@ const struct i2c_port_t i2c_ports[] = { const unsigned int i2c_ports_used = ARRAY_SIZE(i2c_ports); /* TCPC mux configuration */ -const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_COUNT] = { +const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_MAX_COUNT] = { { .bus_type = EC_BUS_TYPE_I2C, .i2c_info = { @@ -221,7 +221,7 @@ const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_COUNT] = { }, }; -struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_COUNT] = { +struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_MAX_COUNT] = { { .driver = &anx74xx_tcpm_usb_mux_driver, .hpd_update = &anx74xx_tcpc_update_hpd_status, @@ -310,7 +310,7 @@ void board_tcpc_init(void) * Initialize HPD to low; after sysjump SOC needs to see * HPD pulse to enable video path */ - for (port = 0; port < CONFIG_USB_PD_PORT_COUNT; port++) { + for (port = 0; port < CONFIG_USB_PD_PORT_MAX_COUNT; port++) { const struct usb_mux *mux = &usb_muxes[port]; mux->hpd_update(port, 0, 0); diff --git a/board/eve/board.h b/board/eve/board.h index 8b1f5e85ca..fb75e67791 100644 --- a/board/eve/board.h +++ b/board/eve/board.h @@ -163,7 +163,7 @@ #define CONFIG_BD9995X_DELAY_INPUT_PORT_SELECT #define CONFIG_USB_PD_LOGGING #define CONFIG_USB_PD_MAX_SINGLE_SOURCE_CURRENT TYPEC_RP_3A0 -#define CONFIG_USB_PD_PORT_COUNT 2 +#define CONFIG_USB_PD_PORT_MAX_COUNT 2 #define CONFIG_USB_PD_VBUS_DETECT_CHARGER #define CONFIG_USB_PD_TCPC_LOW_POWER #define CONFIG_USB_PD_TCPM_MUX diff --git a/board/eve/led.c b/board/eve/led.c index a98a6d53e0..e851092672 100644 --- a/board/eve/led.c +++ b/board/eve/led.c @@ -439,7 +439,7 @@ static void eve_led_set_power_battery(void) /* Get active charge port which maps directly to left/right LED */ side = charge_manager_get_active_charge_port(); /* Ensure that side can be safely used as an index */ - if (side < 0 || side >= CONFIG_USB_PD_PORT_COUNT) + if (side < 0 || side >= CONFIG_USB_PD_PORT_MAX_COUNT) side = LED_BOTH; /* Get percent charge */ diff --git a/board/eve/usb_pd_policy.c b/board/eve/usb_pd_policy.c index eda49eb08d..02e3bab978 100644 --- a/board/eve/usb_pd_policy.c +++ b/board/eve/usb_pd_policy.c @@ -56,8 +56,9 @@ void pd_transition_voltage(int idx) /* No-operation: we are always 5V */ } -static uint8_t vbus_en[CONFIG_USB_PD_PORT_COUNT]; -static uint8_t vbus_rp[CONFIG_USB_PD_PORT_COUNT] = {TYPEC_RP_1A5, TYPEC_RP_1A5}; +static uint8_t vbus_en[CONFIG_USB_PD_PORT_MAX_COUNT]; +static uint8_t vbus_rp[CONFIG_USB_PD_PORT_MAX_COUNT] = {TYPEC_RP_1A5, + TYPEC_RP_1A5}; int board_vbus_source_enabled(int port) { @@ -302,8 +303,8 @@ int pd_custom_vdm(int port, int cnt, uint32_t *payload, } #ifdef CONFIG_USB_PD_ALT_MODE_DFP -static int dp_flags[CONFIG_USB_PD_PORT_COUNT]; -static uint32_t dp_status[CONFIG_USB_PD_PORT_COUNT]; +static int dp_flags[CONFIG_USB_PD_PORT_MAX_COUNT]; +static uint32_t dp_status[CONFIG_USB_PD_PORT_MAX_COUNT]; static void svdm_safe_dp_mode(int port) { diff --git a/board/fizz/board.c b/board/fizz/board.c index 6d3d3378d2..027bfdbb1a 100644 --- a/board/fizz/board.c +++ b/board/fizz/board.c @@ -174,7 +174,7 @@ const struct i2c_port_t i2c_ports[] = { const unsigned int i2c_ports_used = ARRAY_SIZE(i2c_ports); /* TCPC mux configuration */ -const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_COUNT] = { +const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_MAX_COUNT] = { { .bus_type = EC_BUS_TYPE_I2C, .i2c_info = { @@ -192,7 +192,7 @@ static int ps8751_tune_mux(int port) return EC_SUCCESS; } -struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_COUNT] = { +struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_MAX_COUNT] = { { .driver = &tcpci_tcpm_usb_mux_driver, .hpd_update = &ps8xxx_tcpc_update_hpd_status, @@ -238,7 +238,7 @@ void board_tcpc_init(void) * Initialize HPD to low; after sysjump SOC needs to see * HPD pulse to enable video path */ - for (port = 0; port < CONFIG_USB_PD_PORT_COUNT; port++) { + for (port = 0; port < CONFIG_USB_PD_PORT_MAX_COUNT; port++) { const struct usb_mux *mux = &usb_muxes[port]; mux->hpd_update(port, 0, 0); } diff --git a/board/fizz/board.h b/board/fizz/board.h index cabce30b3e..5471e77f1d 100644 --- a/board/fizz/board.h +++ b/board/fizz/board.h @@ -99,7 +99,7 @@ #define CONFIG_USB_PD_DUAL_ROLE #define CONFIG_USB_PD_DUAL_ROLE_AUTO_TOGGLE #define CONFIG_USB_PD_LOGGING -#define CONFIG_USB_PD_PORT_COUNT 1 +#define CONFIG_USB_PD_PORT_MAX_COUNT 1 #define CONFIG_USB_PD_VBUS_DETECT_GPIO #define CONFIG_USB_PD_TCPC_LOW_POWER #define CONFIG_USB_PD_TCPM_MUX diff --git a/board/fizz/usb_pd_policy.c b/board/fizz/usb_pd_policy.c index bac29cfa52..fe4a4c4192 100644 --- a/board/fizz/usb_pd_policy.c +++ b/board/fizz/usb_pd_policy.c @@ -266,8 +266,8 @@ int board_get_battery_soc(void) } #ifdef CONFIG_USB_PD_ALT_MODE_DFP -static int dp_flags[CONFIG_USB_PD_PORT_COUNT]; -static uint32_t dp_status[CONFIG_USB_PD_PORT_COUNT]; +static int dp_flags[CONFIG_USB_PD_PORT_MAX_COUNT]; +static uint32_t dp_status[CONFIG_USB_PD_PORT_MAX_COUNT]; static void svdm_safe_dp_mode(int port) { diff --git a/board/flapjack/board.c b/board/flapjack/board.c index e84a5b947a..84d8e5016b 100644 --- a/board/flapjack/board.c +++ b/board/flapjack/board.c @@ -283,7 +283,7 @@ const struct spi_device_t spi_devices[] = { const unsigned int spi_devices_used = ARRAY_SIZE(spi_devices); /******************************************************************************/ -const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_COUNT] = { +const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_MAX_COUNT] = { { .bus_type = EC_BUS_TYPE_I2C, .i2c_info = { @@ -293,7 +293,7 @@ const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_COUNT] = { .drv = &mt6370_tcpm_drv}, }; -struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_COUNT] = { +struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_MAX_COUNT] = { { .driver = &virtual_usb_mux_driver, .hpd_update = &virtual_hpd_update, diff --git a/board/flapjack/board.h b/board/flapjack/board.h index 9d75d49012..af3f05ce9b 100644 --- a/board/flapjack/board.h +++ b/board/flapjack/board.h @@ -141,7 +141,7 @@ #define CONFIG_USB_PD_DUAL_ROLE #define CONFIG_USB_PD_DUAL_ROLE_AUTO_TOGGLE #define CONFIG_USB_PD_LOGGING -#define CONFIG_USB_PD_PORT_COUNT 1 +#define CONFIG_USB_PD_PORT_MAX_COUNT 1 #define CONFIG_USB_PD_TCPC_LOW_POWER #define CONFIG_USB_PD_TCPM_MT6370 #define CONFIG_USB_PD_TCPM_TCPCI diff --git a/board/flapjack/usb_pd_policy.c b/board/flapjack/usb_pd_policy.c index d4a5c0aa5c..b2c992b4e2 100644 --- a/board/flapjack/usb_pd_policy.c +++ b/board/flapjack/usb_pd_policy.c @@ -219,9 +219,9 @@ int pd_custom_vdm(int port, int cnt, uint32_t *payload, } #ifdef CONFIG_USB_PD_ALT_MODE_DFP -static int dp_flags[CONFIG_USB_PD_PORT_COUNT]; +static int dp_flags[CONFIG_USB_PD_PORT_MAX_COUNT]; /* DP Status VDM as returned by UFP */ -static uint32_t dp_status[CONFIG_USB_PD_PORT_COUNT]; +static uint32_t dp_status[CONFIG_USB_PD_PORT_MAX_COUNT]; static void svdm_safe_dp_mode(int port) { @@ -280,7 +280,7 @@ static int svdm_dp_config(int port, uint32_t *payload) * timestamp of the next possible toggle to ensure the 2-ms spacing * between IRQ_HPD. */ -static uint64_t hpd_deadline[CONFIG_USB_PD_PORT_COUNT]; +static uint64_t hpd_deadline[CONFIG_USB_PD_PORT_MAX_COUNT]; static void svdm_dp_post_config(int port) { diff --git a/board/fleex/board.c b/board/fleex/board.c index 57f13b5e49..7ee6495b86 100644 --- a/board/fleex/board.c +++ b/board/fleex/board.c @@ -258,7 +258,7 @@ void lid_angle_peripheral_enable(int enable) void board_overcurrent_event(int port, int is_overcurrented) { /* Sanity check the port. */ - if ((port < 0) || (port >= CONFIG_USB_PD_PORT_COUNT)) + if ((port < 0) || (port >= CONFIG_USB_PD_PORT_MAX_COUNT)) return; /* Note that the level is inverted because the pin is active low. */ diff --git a/board/garg/board.c b/board/garg/board.c index db37841560..8da97ef1c8 100644 --- a/board/garg/board.c +++ b/board/garg/board.c @@ -295,7 +295,7 @@ void lid_angle_peripheral_enable(int enable) void board_overcurrent_event(int port, int is_overcurrented) { /* Sanity check the port. */ - if ((port < 0) || (port >= CONFIG_USB_PD_PORT_COUNT)) + if ((port < 0) || (port >= CONFIG_USB_PD_PORT_MAX_COUNT)) return; /* Note that the level is inverted because the pin is active low. */ diff --git a/board/glados/board.c b/board/glados/board.c index 5dabd57c7e..7a5a6247d2 100644 --- a/board/glados/board.c +++ b/board/glados/board.c @@ -118,7 +118,7 @@ const struct i2c_port_t i2c_ports[] = { }; const unsigned int i2c_ports_used = ARRAY_SIZE(i2c_ports); -const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_COUNT] = { +const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_MAX_COUNT] = { { .bus_type = EC_BUS_TYPE_I2C, .i2c_info = { @@ -164,7 +164,7 @@ struct pi3usb9281_config pi3usb9281_chips[] = { BUILD_ASSERT(ARRAY_SIZE(pi3usb9281_chips) == CONFIG_BC12_DETECT_PI3USB9281_CHIP_COUNT); -struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_COUNT] = { +struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_MAX_COUNT] = { { .port_addr = 0x54, .driver = &pi3usb30532_usb_mux_driver, @@ -275,7 +275,7 @@ int board_set_active_charge_port(int charge_port) { /* charge port is a realy physical port */ int is_real_port = (charge_port >= 0 && - charge_port < CONFIG_USB_PD_PORT_COUNT); + charge_port < CONFIG_USB_PD_PORT_MAX_COUNT); /* check if we are source vbus on that port */ int source = gpio_get_level(charge_port == 0 ? GPIO_USB_C0_5V_EN : GPIO_USB_C1_5V_EN); diff --git a/board/glados/board.h b/board/glados/board.h index 040e01cc26..9e783d3c09 100644 --- a/board/glados/board.h +++ b/board/glados/board.h @@ -73,7 +73,7 @@ #define CONFIG_USB_PD_ALT_MODE_DFP #define CONFIG_USB_PD_DUAL_ROLE #define CONFIG_USB_PD_LOGGING -#define CONFIG_USB_PD_PORT_COUNT 2 +#define CONFIG_USB_PD_PORT_MAX_COUNT 2 #define CONFIG_USB_PD_TCPM_TCPCI #define CONFIG_USB_PD_TRY_SRC #define CONFIG_USB_PD_VBUS_DETECT_GPIO diff --git a/board/glados/usb_pd_policy.c b/board/glados/usb_pd_policy.c index 10fefd8c11..1870791358 100644 --- a/board/glados/usb_pd_policy.c +++ b/board/glados/usb_pd_policy.c @@ -209,9 +209,9 @@ int pd_custom_vdm(int port, int cnt, uint32_t *payload, } #ifdef CONFIG_USB_PD_ALT_MODE_DFP -static int dp_flags[CONFIG_USB_PD_PORT_COUNT]; +static int dp_flags[CONFIG_USB_PD_PORT_MAX_COUNT]; /* DP Status VDM as returned by UFP */ -static uint32_t dp_status[CONFIG_USB_PD_PORT_COUNT]; +static uint32_t dp_status[CONFIG_USB_PD_PORT_MAX_COUNT]; static void svdm_safe_dp_mode(int port) { @@ -273,7 +273,7 @@ static int svdm_dp_config(int port, uint32_t *payload) * timestamp of the next possible toggle to ensure the 2-ms spacing * between IRQ_HPD. */ -static uint64_t hpd_deadline[CONFIG_USB_PD_PORT_COUNT]; +static uint64_t hpd_deadline[CONFIG_USB_PD_PORT_MAX_COUNT]; #define PORT_TO_HPD(port) ((port) ? GPIO_USB_C1_DP_HPD : GPIO_USB_C0_DP_HPD) static void svdm_dp_post_config(int port) diff --git a/board/glados_pd/board.h b/board/glados_pd/board.h index e2c26e1afe..287cb32b09 100644 --- a/board/glados_pd/board.h +++ b/board/glados_pd/board.h @@ -61,7 +61,7 @@ #define CONFIG_UART_TX_BUF_SIZE 128 #define CONFIG_USB_PD_DUAL_ROLE #define CONFIG_USB_PD_INTERNAL_COMP -#define CONFIG_USB_PD_PORT_COUNT 2 +#define CONFIG_USB_PD_PORT_MAX_COUNT 2 #define CONFIG_USB_PD_TCPC #define CONFIG_USB_PD_TCPC_TRACK_VBUS #define CONFIG_USBC_VCONN diff --git a/board/glkrvp/board.h b/board/glkrvp/board.h index 7ef92652f6..fd8963d8be 100644 --- a/board/glkrvp/board.h +++ b/board/glkrvp/board.h @@ -63,7 +63,7 @@ /* USB PD config */ #define CONFIG_USB_PD_DUAL_ROLE #define CONFIG_USB_PD_MAX_SINGLE_SOURCE_CURRENT TYPEC_RP_3A0 -#define CONFIG_USB_PD_PORT_COUNT 2 +#define CONFIG_USB_PD_PORT_MAX_COUNT 2 #define CONFIG_USB_PD_TCPM_TCPCI #define CONFIG_USB_PD_TRY_SRC #define CONFIG_USB_PD_VBUS_DETECT_TCPC diff --git a/board/glkrvp/chg_usb_pd.c b/board/glkrvp/chg_usb_pd.c index 2536c051c3..f143dcece5 100644 --- a/board/glkrvp/chg_usb_pd.c +++ b/board/glkrvp/chg_usb_pd.c @@ -30,7 +30,7 @@ enum glkrvp_charge_ports { DC_JACK_PORT_0 = DEDICATED_CHARGE_PORT, }; -const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_COUNT] = { +const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_MAX_COUNT] = { { .bus_type = EC_BUS_TYPE_I2C, .i2c_info = { @@ -48,9 +48,9 @@ const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_COUNT] = { .drv = &tcpci_tcpm_drv, }, }; -BUILD_ASSERT(ARRAY_SIZE(tcpc_config) == CONFIG_USB_PD_PORT_COUNT); +BUILD_ASSERT(ARRAY_SIZE(tcpc_config) == CONFIG_USB_PD_PORT_MAX_COUNT); -struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_COUNT] = { +struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_MAX_COUNT] = { { .port_addr = 0x10, .driver = &ps874x_usb_mux_driver, @@ -200,7 +200,7 @@ DECLARE_HOOK(HOOK_INIT, board_charge_init, HOOK_PRIO_DEFAULT); int board_set_active_charge_port(int port) { /* if it's a PD port and sourcing VBUS, don't enable */ - if (port >= 0 && port < CONFIG_USB_PD_PORT_COUNT) + if (port >= 0 && port < CONFIG_USB_PD_PORT_MAX_COUNT) if (board_charger_port_is_sourcing_vbus(port)) { CPRINTS("Skip enable p%d", port); return EC_ERROR_INVAL; diff --git a/board/glkrvp/usb_pd_policy.c b/board/glkrvp/usb_pd_policy.c index 57b114fe5d..72c54d3ec3 100644 --- a/board/glkrvp/usb_pd_policy.c +++ b/board/glkrvp/usb_pd_policy.c @@ -202,8 +202,8 @@ int pd_custom_vdm(int port, int cnt, uint32_t *payload, } #ifdef CONFIG_USB_PD_ALT_MODE_DFP -static int dp_flags[CONFIG_USB_PD_PORT_COUNT]; -static uint32_t dp_status[CONFIG_USB_PD_PORT_COUNT]; +static int dp_flags[CONFIG_USB_PD_PORT_MAX_COUNT]; +static uint32_t dp_status[CONFIG_USB_PD_PORT_MAX_COUNT]; static void svdm_safe_dp_mode(int port) { diff --git a/board/glkrvp_ite/board.h b/board/glkrvp_ite/board.h index d76e582262..f761625136 100644 --- a/board/glkrvp_ite/board.h +++ b/board/glkrvp_ite/board.h @@ -63,7 +63,7 @@ /* USB PD config */ #define CONFIG_USB_PD_DUAL_ROLE #define CONFIG_USB_PD_MAX_SINGLE_SOURCE_CURRENT TYPEC_RP_3A0 -#define CONFIG_USB_PD_PORT_COUNT 2 +#define CONFIG_USB_PD_PORT_MAX_COUNT 2 #define CONFIG_USB_PD_TCPM_TCPCI #define CONFIG_USB_PD_TRY_SRC #define CONFIG_USB_PD_VBUS_DETECT_TCPC diff --git a/board/glkrvp_ite/chg_usb_pd.c b/board/glkrvp_ite/chg_usb_pd.c index 45621c3202..0dbf286b7e 100644 --- a/board/glkrvp_ite/chg_usb_pd.c +++ b/board/glkrvp_ite/chg_usb_pd.c @@ -30,7 +30,7 @@ enum glkrvp_charge_ports { DC_JACK_PORT_0 = DEDICATED_CHARGE_PORT, }; -const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_COUNT] = { +const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_MAX_COUNT] = { { .bus_type = EC_BUS_TYPE_I2C, .i2c_info = { @@ -48,9 +48,9 @@ const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_COUNT] = { .drv = &tcpci_tcpm_drv, }, }; -BUILD_ASSERT(ARRAY_SIZE(tcpc_config) == CONFIG_USB_PD_PORT_COUNT); +BUILD_ASSERT(ARRAY_SIZE(tcpc_config) == CONFIG_USB_PD_PORT_MAX_COUNT); -struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_COUNT] = { +struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_MAX_COUNT] = { { .port_addr = 0x10, .driver = &ps874x_usb_mux_driver, diff --git a/board/glkrvp_ite/usb_pd_policy.c b/board/glkrvp_ite/usb_pd_policy.c index bd11eb4d8f..e269d217f5 100644 --- a/board/glkrvp_ite/usb_pd_policy.c +++ b/board/glkrvp_ite/usb_pd_policy.c @@ -202,8 +202,8 @@ int pd_custom_vdm(int port, int cnt, uint32_t *payload, } #ifdef CONFIG_USB_PD_ALT_MODE_DFP -static int dp_flags[CONFIG_USB_PD_PORT_COUNT]; -static uint32_t dp_status[CONFIG_USB_PD_PORT_COUNT]; +static int dp_flags[CONFIG_USB_PD_PORT_MAX_COUNT]; +static uint32_t dp_status[CONFIG_USB_PD_PORT_MAX_COUNT]; static void svdm_safe_dp_mode(int port) { diff --git a/board/hatch/board.c b/board/hatch/board.c index 1fede75512..679686fafb 100644 --- a/board/hatch/board.c +++ b/board/hatch/board.c @@ -125,7 +125,7 @@ BUILD_ASSERT(ARRAY_SIZE(pwm_channels) == PWM_CH_COUNT); /******************************************************************************/ /* USB-C TPCP Configuration */ -const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_COUNT] = { +const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_MAX_COUNT] = { [USB_PD_PORT_TCPC_0] = { .bus_type = EC_BUS_TYPE_I2C, .i2c_info = { @@ -145,7 +145,7 @@ const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_COUNT] = { }, }; -struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_COUNT] = { +struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_MAX_COUNT] = { [USB_PD_PORT_TCPC_0] = { .driver = &anx7447_usb_mux_driver, .hpd_update = &anx7447_tcpc_update_hpd_status, @@ -485,7 +485,7 @@ DECLARE_HOOK(HOOK_INIT, board_init, HOOK_PRIO_DEFAULT); void board_overcurrent_event(int port, int is_overcurrented) { /* Sanity check the port. */ - if ((port < 0) || (port >= CONFIG_USB_PD_PORT_COUNT)) + if ((port < 0) || (port >= CONFIG_USB_PD_PORT_MAX_COUNT)) return; /* Note that the level is inverted because the pin is active low. */ diff --git a/board/helios/board.c b/board/helios/board.c index 4ad7596a2e..9dd31ef613 100644 --- a/board/helios/board.c +++ b/board/helios/board.c @@ -148,7 +148,7 @@ BUILD_ASSERT(ARRAY_SIZE(pwm_channels) == PWM_CH_COUNT); /******************************************************************************/ /* USB-C TPCP Configuration */ -const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_COUNT] = { +const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_MAX_COUNT] = { [USB_PD_PORT_TCPC_0] = { .bus_type = EC_BUS_TYPE_I2C, .i2c_info = { @@ -167,7 +167,7 @@ const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_COUNT] = { }, }; -struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_COUNT] = { +struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_MAX_COUNT] = { [USB_PD_PORT_TCPC_0] = { .driver = &tcpci_tcpm_usb_mux_driver, .hpd_update = &ps8xxx_tcpc_update_hpd_status, @@ -389,7 +389,7 @@ DECLARE_HOOK(HOOK_INIT, board_init, HOOK_PRIO_DEFAULT); void board_overcurrent_event(int port, int is_overcurrented) { /* Sanity check the port. */ - if ((port < 0) || (port >= CONFIG_USB_PD_PORT_COUNT)) + if ((port < 0) || (port >= CONFIG_USB_PD_PORT_MAX_COUNT)) return; /* Note that the level is inverted because the pin is active low. */ diff --git a/board/hoho/board.h b/board/hoho/board.h index 39027f7757..f052ad5de4 100644 --- a/board/hoho/board.h +++ b/board/hoho/board.h @@ -44,7 +44,7 @@ #define CONFIG_USB_PD_LOGGING #undef CONFIG_EVENT_LOG_SIZE #define CONFIG_EVENT_LOG_SIZE 256 -#define CONFIG_USB_PD_PORT_COUNT 1 +#define CONFIG_USB_PD_PORT_MAX_COUNT 1 #define CONFIG_USB_PD_TCPC #define CONFIG_USB_PD_TCPM_STUB #define CONFIG_USB_PD_VBUS_DETECT_NONE diff --git a/board/it83xx_evb/board.c b/board/it83xx_evb/board.c index 1ac7637ae5..b433856d36 100644 --- a/board/it83xx_evb/board.c +++ b/board/it83xx_evb/board.c @@ -38,7 +38,7 @@ int board_get_battery_soc(void) return 100; } -const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_COUNT] = { +const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_MAX_COUNT] = { {-1, -1, &it83xx_tcpm_drv}, {-1, -1, &it83xx_tcpm_drv}, }; diff --git a/board/it83xx_evb/board.h b/board/it83xx_evb/board.h index 34cae4c144..8620ba19c6 100644 --- a/board/it83xx_evb/board.h +++ b/board/it83xx_evb/board.h @@ -40,7 +40,7 @@ #define CONFIG_USB_PD_ALT_MODE_DFP #define CONFIG_USB_PD_CHECK_MAX_REQUEST_ALLOWED #define CONFIG_USB_PD_DUAL_ROLE -#define CONFIG_USB_PD_PORT_COUNT 2 +#define CONFIG_USB_PD_PORT_MAX_COUNT 2 #define CONFIG_USB_PD_TCPM_ITE83XX #define CONFIG_USB_PD_TRY_SRC #define CONFIG_USB_PD_VBUS_DETECT_GPIO diff --git a/board/it83xx_evb/usb_pd_policy.c b/board/it83xx_evb/usb_pd_policy.c index 81e243dc61..03d83f02f3 100644 --- a/board/it83xx_evb/usb_pd_policy.c +++ b/board/it83xx_evb/usb_pd_policy.c @@ -195,9 +195,9 @@ int pd_custom_vdm(int port, int cnt, uint32_t *payload, } #ifdef CONFIG_USB_PD_ALT_MODE_DFP -static int dp_flags[CONFIG_USB_PD_PORT_COUNT]; +static int dp_flags[CONFIG_USB_PD_PORT_MAX_COUNT]; /* DP Status VDM as returned by UFP */ -static uint32_t dp_status[CONFIG_USB_PD_PORT_COUNT]; +static uint32_t dp_status[CONFIG_USB_PD_PORT_MAX_COUNT]; static void svdm_safe_dp_mode(int port) { diff --git a/board/jacuzzi/board.c b/board/jacuzzi/board.c index ec1ca3160e..f8274dd6a5 100644 --- a/board/jacuzzi/board.c +++ b/board/jacuzzi/board.c @@ -94,7 +94,7 @@ const struct pi3usb9201_config_t pi3usb9201_bc12_chips[] = { }; /******************************************************************************/ -const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_COUNT] = { +const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_MAX_COUNT] = { { .bus_type = EC_BUS_TYPE_I2C, .i2c_info = { @@ -114,7 +114,7 @@ static void board_hpd_status(int port, int hpd_lvl, int hpd_irq) host_set_single_event(EC_HOST_EVENT_USB_MUX); } -struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_COUNT] = { +struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_MAX_COUNT] = { { /* Driver uses I2C_PORT_USB_MUX as I2C port */ .port_addr = IT5205_I2C_ADDR1_FLAGS, diff --git a/board/kindred/board.c b/board/kindred/board.c index 80619d24d9..c70ac61cda 100644 --- a/board/kindred/board.c +++ b/board/kindred/board.c @@ -126,7 +126,7 @@ BUILD_ASSERT(ARRAY_SIZE(pwm_channels) == PWM_CH_COUNT); /******************************************************************************/ /* USB-C TPCP Configuration */ -const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_COUNT] = { +const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_MAX_COUNT] = { [USB_PD_PORT_TCPC_0] = { .bus_type = EC_BUS_TYPE_I2C, .i2c_info = { @@ -147,7 +147,7 @@ const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_COUNT] = { }, }; -struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_COUNT] = { +struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_MAX_COUNT] = { [USB_PD_PORT_TCPC_0] = { .driver = &anx7447_usb_mux_driver, .hpd_update = &anx7447_tcpc_update_hpd_status, @@ -438,7 +438,7 @@ DECLARE_HOOK(HOOK_INIT, board_init, HOOK_PRIO_DEFAULT); void board_overcurrent_event(int port, int is_overcurrented) { /* Sanity check the port. */ - if ((port < 0) || (port >= CONFIG_USB_PD_PORT_COUNT)) + if ((port < 0) || (port >= CONFIG_USB_PD_PORT_MAX_COUNT)) return; /* Note that the level is inverted because the pin is active low. */ diff --git a/board/kodama/board.c b/board/kodama/board.c index 0e1d4bf0c0..905930963a 100644 --- a/board/kodama/board.c +++ b/board/kodama/board.c @@ -80,7 +80,7 @@ const struct spi_device_t spi_devices[] = { const unsigned int spi_devices_used = ARRAY_SIZE(spi_devices); /******************************************************************************/ -const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_COUNT] = { +const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_MAX_COUNT] = { { .bus_type = EC_BUS_TYPE_I2C, .i2c_info = { @@ -100,7 +100,7 @@ static void board_hpd_status(int port, int hpd_lvl, int hpd_irq) host_set_single_event(EC_HOST_EVENT_USB_MUX); } -struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_COUNT] = { +struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_MAX_COUNT] = { { .port_addr = IT5205_I2C_ADDR1_FLAGS, .driver = &it5205_usb_mux_driver, diff --git a/board/kohaku/board.c b/board/kohaku/board.c index a569ff131d..636bbf6c9f 100644 --- a/board/kohaku/board.c +++ b/board/kohaku/board.c @@ -112,7 +112,7 @@ BUILD_ASSERT(ARRAY_SIZE(pwm_channels) == PWM_CH_COUNT); /******************************************************************************/ /* USB-C TPCP Configuration */ -const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_COUNT] = { +const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_MAX_COUNT] = { [USB_PD_PORT_TCPC_0] = { .bus_type = EC_BUS_TYPE_I2C, .i2c_info = { @@ -131,7 +131,7 @@ const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_COUNT] = { }, }; -struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_COUNT] = { +struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_MAX_COUNT] = { [USB_PD_PORT_TCPC_0] = { .driver = &tcpci_tcpm_usb_mux_driver, .hpd_update = &ps8xxx_tcpc_update_hpd_status, @@ -143,7 +143,7 @@ struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_COUNT] = { }; /* BC 1.2 chip Configuration */ -const struct max14637_config_t max14637_config[CONFIG_USB_PD_PORT_COUNT] = { +const struct max14637_config_t max14637_config[CONFIG_USB_PD_PORT_MAX_COUNT] = { { .chip_enable_pin = GPIO_USB_C0_BC12_VBUS_ON, .chg_det_pin = GPIO_USB_C0_BC12_CHG_DET_L, @@ -473,7 +473,7 @@ DECLARE_HOOK(HOOK_INIT, board_init, HOOK_PRIO_DEFAULT); void board_overcurrent_event(int port, int is_overcurrented) { /* Sanity check the port. */ - if ((port < 0) || (port >= CONFIG_USB_PD_PORT_COUNT)) + if ((port < 0) || (port >= CONFIG_USB_PD_PORT_MAX_COUNT)) return; /* Note that the level is inverted because the pin is active low. */ diff --git a/board/kukui/board.c b/board/kukui/board.c index b2a5f6dd59..bd7a2f9284 100644 --- a/board/kukui/board.c +++ b/board/kukui/board.c @@ -91,7 +91,7 @@ const struct spi_device_t spi_devices[] = { const unsigned int spi_devices_used = ARRAY_SIZE(spi_devices); /******************************************************************************/ -const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_COUNT] = { +const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_MAX_COUNT] = { { .bus_type = EC_BUS_TYPE_I2C, .i2c_info = { @@ -135,7 +135,7 @@ __override const struct rt946x_init_setting *board_rt946x_init_setting(void) return &battery_init_setting; } -struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_COUNT] = { +struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_MAX_COUNT] = { { .port_addr = IT5205_I2C_ADDR1_FLAGS, .driver = &it5205_usb_mux_driver, diff --git a/board/liara/battery.c b/board/liara/battery.c index b88b446473..ecb1202aa1 100644 --- a/board/liara/battery.c +++ b/board/liara/battery.c @@ -179,7 +179,7 @@ static void reduce_input_voltage_when_full(void) max_pd_voltage_mv = PD_MAX_VOLTAGE_MV; if (pd_get_max_voltage() != max_pd_voltage_mv) { - for (port = 0; port < CONFIG_USB_PD_PORT_COUNT; port++) + for (port = 0; port < CONFIG_USB_PD_PORT_MAX_COUNT; port++) pd_set_external_voltage_limit(port, max_pd_voltage_mv); } } diff --git a/board/mchpevb1/board.c b/board/mchpevb1/board.c index 33cb8a48ae..8ce5ea658d 100644 --- a/board/mchpevb1/board.c +++ b/board/mchpevb1/board.c @@ -263,7 +263,7 @@ int board_i2c_p2c(int port) } #ifdef CONFIG_USB_POWER_DELIVERY -const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_COUNT] = { +const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_MAX_COUNT] = { {I2C_PORT_TCPC, CONFIG_TCPC_I2C_BASE_ADDR_FLAGS, &tcpci_tcpm_drv}, @@ -387,7 +387,7 @@ struct pi3usb9281_config pi3usb9281_chips[] = { BUILD_ASSERT(ARRAY_SIZE(pi3usb9281_chips) == CONFIG_BC12_DETECT_PI3USB9281_CHIP_COUNT); -struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_COUNT] = { +struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_MAX_COUNT] = { { .port_addr = 0x54, .driver = &pi3usb30532_usb_mux_driver, @@ -593,7 +593,7 @@ int board_set_active_charge_port(int charge_port) { /* charge port is a realy physical port */ int is_real_port = (charge_port >= 0 && - charge_port < CONFIG_USB_PD_PORT_COUNT); + charge_port < CONFIG_USB_PD_PORT_MAX_COUNT); /* check if we are source vbus on that port */ int source = gpio_get_level(charge_port == 0 ? GPIO_USB_C0_5V_EN : GPIO_USB_C1_5V_EN); @@ -748,20 +748,20 @@ void board_hibernate_late(void) */ gpio_set_level(GPIO_USB_PD_WAKE, 0); -#ifdef CONFIG_USB_PD_PORT_COUNT +#ifdef CONFIG_USB_PD_PORT_MAX_COUNT /* * Leave USB-C charging enabled in hibernate, in order to * allow wake-on-plug. 5V enable must be pulled low. */ -#if CONFIG_USB_PD_PORT_COUNT > 0 +#if CONFIG_USB_PD_PORT_MAX_COUNT > 0 gpio_set_flags(GPIO_USB_C0_5V_EN, GPIO_PULL_DOWN | GPIO_INPUT); gpio_set_level(GPIO_USB_C0_CHARGE_EN_L, 0); #endif -#if CONFIG_USB_PD_PORT_COUNT > 1 +#if CONFIG_USB_PD_PORT_MAX_COUNT > 1 gpio_set_flags(GPIO_USB_C1_5V_EN, GPIO_PULL_DOWN | GPIO_INPUT); gpio_set_level(GPIO_USB_C1_CHARGE_EN_L, 0); #endif -#endif /* CONFIG_USB_PD_PORT_COUNT */ +#endif /* CONFIG_USB_PD_PORT_MAX_COUNT */ } /* Any glados boards post version 2 should have ROP_LDO_EN stuffed. */ diff --git a/board/mchpevb1/board.h b/board/mchpevb1/board.h index a2fdeca7f7..33aa2719b9 100644 --- a/board/mchpevb1/board.h +++ b/board/mchpevb1/board.h @@ -235,7 +235,7 @@ #define CONFIG_USB_PD_ALT_MODE_DFP #define CONFIG_USB_PD_DUAL_ROLE #define CONFIG_USB_PD_LOGGING -#define CONFIG_USB_PD_PORT_COUNT 2 +#define CONFIG_USB_PD_PORT_MAX_COUNT 2 #define CONFIG_USB_PD_TCPM_TCPCI #endif /* diff --git a/board/mchpevb1/usb_pd_policy.c b/board/mchpevb1/usb_pd_policy.c index d5eff63316..f763c3aa0e 100644 --- a/board/mchpevb1/usb_pd_policy.c +++ b/board/mchpevb1/usb_pd_policy.c @@ -212,9 +212,9 @@ int pd_custom_vdm(int port, int cnt, uint32_t *payload, } #ifdef CONFIG_USB_PD_ALT_MODE_DFP -static int dp_flags[CONFIG_USB_PD_PORT_COUNT]; +static int dp_flags[CONFIG_USB_PD_PORT_MAX_COUNT]; /* DP Status VDM as returned by UFP */ -static uint32_t dp_status[CONFIG_USB_PD_PORT_COUNT]; +static uint32_t dp_status[CONFIG_USB_PD_PORT_MAX_COUNT]; static void svdm_safe_dp_mode(int port) { @@ -277,7 +277,7 @@ static int svdm_dp_config(int port, uint32_t *payload) * timestamp of the next possible toggle to ensure the 2-ms spacing * between IRQ_HPD. */ -static uint64_t hpd_deadline[CONFIG_USB_PD_PORT_COUNT]; +static uint64_t hpd_deadline[CONFIG_USB_PD_PORT_MAX_COUNT]; #define PORT_TO_HPD(port) \ ((port) ? GPIO_USB_C1_DP_HPD : GPIO_USB_C0_DP_HPD) diff --git a/board/meep/board.c b/board/meep/board.c index c62065e58b..200909dca0 100644 --- a/board/meep/board.c +++ b/board/meep/board.c @@ -303,7 +303,7 @@ const int keyboard_factory_scan_pins_used = void board_overcurrent_event(int port, int is_overcurrented) { /* Sanity check the port. */ - if ((port < 0) || (port >= CONFIG_USB_PD_PORT_COUNT)) + if ((port < 0) || (port >= CONFIG_USB_PD_PORT_MAX_COUNT)) return; /* Note that the level is inverted because the pin is active low. */ diff --git a/board/nami/board.c b/board/nami/board.c index 104f892566..24e9311acb 100644 --- a/board/nami/board.c +++ b/board/nami/board.c @@ -228,7 +228,7 @@ const struct i2c_port_t i2c_ports[] = { const unsigned int i2c_ports_used = ARRAY_SIZE(i2c_ports); /* TCPC mux configuration */ -const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_COUNT] = { +const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_MAX_COUNT] = { [USB_PD_PORT_PS8751] = { .bus_type = EC_BUS_TYPE_I2C, .i2c_info = { @@ -258,7 +258,7 @@ static int ps8751_tune_mux(int port) return EC_SUCCESS; } -struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_COUNT] = { +struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_MAX_COUNT] = { [USB_PD_PORT_PS8751] = { .driver = &tcpci_tcpm_usb_mux_driver, .hpd_update = &ps8xxx_tcpc_update_hpd_status, @@ -320,7 +320,7 @@ void board_tcpc_init(void) * Initialize HPD to low; after sysjump SOC needs to see * HPD pulse to enable video path */ - for (port = 0; port < CONFIG_USB_PD_PORT_COUNT; port++) { + for (port = 0; port < CONFIG_USB_PD_PORT_MAX_COUNT; port++) { const struct usb_mux *mux = &usb_muxes[port]; mux->hpd_update(port, 0, 0); } @@ -640,7 +640,7 @@ int board_set_active_charge_port(int charge_port) { /* charge port is a physical port */ int is_real_port = (charge_port >= 0 && - charge_port < CONFIG_USB_PD_PORT_COUNT); + charge_port < CONFIG_USB_PD_PORT_MAX_COUNT); /* check if we are sourcing VBUS on the port */ /* dnojiri: revisit */ int is_source = gpio_get_level(charge_port == 0 ? diff --git a/board/nami/board.h b/board/nami/board.h index 084e12c70d..4a99aed383 100644 --- a/board/nami/board.h +++ b/board/nami/board.h @@ -170,7 +170,7 @@ #define CONFIG_USB_PD_DUAL_ROLE_AUTO_TOGGLE #define CONFIG_USB_PD_LOGGING #define CONFIG_USB_PD_MAX_SINGLE_SOURCE_CURRENT TYPEC_RP_3A0 -#define CONFIG_USB_PD_PORT_COUNT 2 +#define CONFIG_USB_PD_PORT_MAX_COUNT 2 #define CONFIG_USB_PD_MAX_TOTAL_SOURCE_CURRENT 4500 #define CONFIG_USB_PD_VBUS_DETECT_GPIO #define CONFIG_USB_PD_TCPC_LOW_POWER diff --git a/board/nami/usb_pd_policy.c b/board/nami/usb_pd_policy.c index b32dd3e31d..2aa2f66ae3 100644 --- a/board/nami/usb_pd_policy.c +++ b/board/nami/usb_pd_policy.c @@ -55,8 +55,9 @@ void pd_transition_voltage(int idx) /* No-operation: we are always 5V */ } -static uint8_t vbus_en[CONFIG_USB_PD_PORT_COUNT]; -static uint8_t vbus_rp[CONFIG_USB_PD_PORT_COUNT] = {TYPEC_RP_1A5, TYPEC_RP_1A5}; +static uint8_t vbus_en[CONFIG_USB_PD_PORT_MAX_COUNT]; +static uint8_t vbus_rp[CONFIG_USB_PD_PORT_MAX_COUNT] = {TYPEC_RP_1A5, + TYPEC_RP_1A5}; int board_vbus_source_enabled(int port) { @@ -271,8 +272,8 @@ int pd_custom_vdm(int port, int cnt, uint32_t *payload, } #ifdef CONFIG_USB_PD_ALT_MODE_DFP -static int dp_flags[CONFIG_USB_PD_PORT_COUNT]; -static uint32_t dp_status[CONFIG_USB_PD_PORT_COUNT]; +static int dp_flags[CONFIG_USB_PD_PORT_MAX_COUNT]; +static uint32_t dp_status[CONFIG_USB_PD_PORT_MAX_COUNT]; static void svdm_safe_dp_mode(int port) { diff --git a/board/nautilus/board.c b/board/nautilus/board.c index 48b316cd45..c305d67250 100644 --- a/board/nautilus/board.c +++ b/board/nautilus/board.c @@ -146,7 +146,7 @@ const struct i2c_port_t i2c_ports[] = { const unsigned int i2c_ports_used = ARRAY_SIZE(i2c_ports); /* TCPC mux configuration */ -const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_COUNT] = { +const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_MAX_COUNT] = { { .bus_type = EC_BUS_TYPE_I2C, .i2c_info = { @@ -165,7 +165,7 @@ const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_COUNT] = { }, }; -struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_COUNT] = { +struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_MAX_COUNT] = { { .driver = &tcpci_tcpm_usb_mux_driver, .hpd_update = &ps8xxx_tcpc_update_hpd_status, @@ -220,7 +220,7 @@ void board_tcpc_init(void) * Initialize HPD to low; after sysjump SOC needs to see * HPD pulse to enable video path */ - for (port = 0; port < CONFIG_USB_PD_PORT_COUNT; port++) { + for (port = 0; port < CONFIG_USB_PD_PORT_MAX_COUNT; port++) { const struct usb_mux *mux = &usb_muxes[port]; mux->hpd_update(port, 0, 0); @@ -464,7 +464,7 @@ int board_set_active_charge_port(int charge_port) { /* charge port is a physical port */ int is_real_port = (charge_port >= 0 && - charge_port < CONFIG_USB_PD_PORT_COUNT); + charge_port < CONFIG_USB_PD_PORT_MAX_COUNT); /* check if we are source VBUS on the port */ int source = gpio_get_level(charge_port == 0 ? GPIO_USB_C0_5V_EN : GPIO_USB_C1_5V_EN); diff --git a/board/nautilus/board.h b/board/nautilus/board.h index 55105d461b..58ddc2d8ac 100644 --- a/board/nautilus/board.h +++ b/board/nautilus/board.h @@ -145,7 +145,7 @@ #define CONFIG_USB_PD_DUAL_ROLE_AUTO_TOGGLE #define CONFIG_USB_PD_LOGGING #define CONFIG_USB_PD_MAX_SINGLE_SOURCE_CURRENT TYPEC_RP_3A0 -#define CONFIG_USB_PD_PORT_COUNT 2 +#define CONFIG_USB_PD_PORT_MAX_COUNT 2 #define CONFIG_USB_PD_VBUS_DETECT_GPIO #define CONFIG_USB_PD_TCPC_LOW_POWER #define CONFIG_USB_PD_TCPM_MUX diff --git a/board/nautilus/usb_pd_policy.c b/board/nautilus/usb_pd_policy.c index 85cc85dd78..2c162a47c1 100644 --- a/board/nautilus/usb_pd_policy.c +++ b/board/nautilus/usb_pd_policy.c @@ -54,8 +54,9 @@ void pd_transition_voltage(int idx) /* No-operation: we are always 5V */ } -static uint8_t vbus_en[CONFIG_USB_PD_PORT_COUNT]; -static uint8_t vbus_rp[CONFIG_USB_PD_PORT_COUNT] = {TYPEC_RP_1A5, TYPEC_RP_1A5}; +static uint8_t vbus_en[CONFIG_USB_PD_PORT_MAX_COUNT]; +static uint8_t vbus_rp[CONFIG_USB_PD_PORT_MAX_COUNT] = {TYPEC_RP_1A5, + TYPEC_RP_1A5}; int board_vbus_source_enabled(int port) { @@ -300,8 +301,8 @@ int pd_custom_vdm(int port, int cnt, uint32_t *payload, } #ifdef CONFIG_USB_PD_ALT_MODE_DFP -static int dp_flags[CONFIG_USB_PD_PORT_COUNT]; -static uint32_t dp_status[CONFIG_USB_PD_PORT_COUNT]; +static int dp_flags[CONFIG_USB_PD_PORT_MAX_COUNT]; +static uint32_t dp_status[CONFIG_USB_PD_PORT_MAX_COUNT]; static void svdm_safe_dp_mode(int port) { diff --git a/board/nocturne/board.c b/board/nocturne/board.c index 4750b3c433..f97fc83945 100644 --- a/board/nocturne/board.c +++ b/board/nocturne/board.c @@ -298,7 +298,7 @@ struct ppc_config_t ppc_chips[] = { }; unsigned int ppc_cnt = ARRAY_SIZE(ppc_chips); -const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_COUNT] = { +const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_MAX_COUNT] = { { .bus_type = EC_BUS_TYPE_I2C, .i2c_info = { @@ -317,7 +317,7 @@ const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_COUNT] = { }, }; -struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_COUNT] = { +struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_MAX_COUNT] = { { .driver = &tcpci_tcpm_usb_mux_driver, .hpd_update = &ps8xxx_tcpc_update_hpd_status, @@ -573,7 +573,7 @@ void board_overcurrent_event(int port, int is_overcurrented) int lvl; /* Sanity check the port. */ - if ((port < 0) || (port >= CONFIG_USB_PD_PORT_COUNT)) + if ((port < 0) || (port >= CONFIG_USB_PD_PORT_MAX_COUNT)) return; /* Note that the levels are inverted because the pin is active low. */ @@ -688,7 +688,7 @@ void board_set_tcpc_power_mode(int port, int mode) int board_set_active_charge_port(int port) { int is_real_port = (port >= 0 && - port < CONFIG_USB_PD_PORT_COUNT); + port < CONFIG_USB_PD_PORT_MAX_COUNT); int i; int rv; int old_port; diff --git a/board/nocturne/board.h b/board/nocturne/board.h index b836fbdf99..2334488fcf 100644 --- a/board/nocturne/board.h +++ b/board/nocturne/board.h @@ -131,7 +131,7 @@ #define CONFIG_USB_PD_DUAL_ROLE #define CONFIG_USB_PD_DUAL_ROLE_AUTO_TOGGLE #define CONFIG_USB_PD_LOGGING -#define CONFIG_USB_PD_PORT_COUNT 2 +#define CONFIG_USB_PD_PORT_MAX_COUNT 2 #define CONFIG_USB_PD_TCPC_LOW_POWER #define CONFIG_USB_PD_TCPM_PS8805 #define CONFIG_USB_PD_TCPM_TCPCI diff --git a/board/nocturne/usb_pd_policy.c b/board/nocturne/usb_pd_policy.c index 26cd49f09c..4e4474648f 100644 --- a/board/nocturne/usb_pd_policy.c +++ b/board/nocturne/usb_pd_policy.c @@ -252,8 +252,8 @@ int pd_custom_vdm(int port, int cnt, uint32_t *payload, } #ifdef CONFIG_USB_PD_ALT_MODE_DFP -static int dp_flags[CONFIG_USB_PD_PORT_COUNT]; -static uint32_t dp_status[CONFIG_USB_PD_PORT_COUNT]; +static int dp_flags[CONFIG_USB_PD_PORT_MAX_COUNT]; +static uint32_t dp_status[CONFIG_USB_PD_PORT_MAX_COUNT]; static void svdm_safe_dp_mode(int port) { @@ -360,7 +360,7 @@ static int svdm_dp_config(int port, uint32_t *payload) * timestamp of the next possible toggle to ensure the 2-ms spacing * between IRQ_HPD. */ -static uint64_t hpd_deadline[CONFIG_USB_PD_PORT_COUNT]; +static uint64_t hpd_deadline[CONFIG_USB_PD_PORT_MAX_COUNT]; #define PORT_TO_HPD(port) ((port) ? GPIO_USB_C1_DP_HPD : GPIO_USB_C0_DP_HPD) diff --git a/board/oak/board.c b/board/oak/board.c index 2cc9b23457..3cd77454f1 100644 --- a/board/oak/board.c +++ b/board/oak/board.c @@ -112,7 +112,7 @@ const struct spi_device_t spi_devices[] = { const unsigned int spi_devices_used = ARRAY_SIZE(spi_devices); #endif -const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_COUNT] = { +const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_MAX_COUNT] = { { .bus_type = EC_BUS_TYPE_I2C, .i2c_info = { @@ -174,7 +174,7 @@ struct als_t als[] = { BUILD_ASSERT(ARRAY_SIZE(als) == ALS_COUNT); #endif -struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_COUNT] = { +struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_MAX_COUNT] = { { .port_addr = 0x54, .driver = &pi3usb30532_usb_mux_driver, @@ -290,7 +290,7 @@ int board_set_active_charge_port(int charge_port) { /* charge port is a physical port */ int is_real_port = (charge_port >= 0 && - charge_port < CONFIG_USB_PD_PORT_COUNT); + charge_port < CONFIG_USB_PD_PORT_MAX_COUNT); /* check if we are source VBUS on the port */ int source = gpio_get_level(charge_port == 0 ? GPIO_USB_C0_5V_EN : GPIO_USB_C1_5V_EN); @@ -338,7 +338,7 @@ void board_set_charge_limit(int port, int supplier, int charge_ma, * timestamp of the next possible toggle to ensure the 2-ms spacing * between IRQ_HPD. */ -static uint64_t hpd_deadline[CONFIG_USB_PD_PORT_COUNT]; +static uint64_t hpd_deadline[CONFIG_USB_PD_PORT_MAX_COUNT]; static void board_typec_set_dp_hpd(int port, int level) { @@ -479,11 +479,11 @@ void vbus_task(void) uint8_t device_type; uint8_t charger_status; uint8_t vbus; - } bc12[CONFIG_USB_PD_PORT_COUNT]; + } bc12[CONFIG_USB_PD_PORT_MAX_COUNT]; uint8_t port, vbus, reg, wake; while (1) { - for (port = 0; port < CONFIG_USB_PD_PORT_COUNT; port++) { + for (port = 0; port < CONFIG_USB_PD_PORT_MAX_COUNT; port++) { #if BOARD_REV == OAK_REV3 vbus = !gpio_get_level(port ? GPIO_USB_C1_VBUS_WAKE_L : GPIO_USB_C0_VBUS_WAKE_L); diff --git a/board/oak/board.h b/board/oak/board.h index b2e07c8107..afd063a4f9 100644 --- a/board/oak/board.h +++ b/board/oak/board.h @@ -95,7 +95,7 @@ #define CONFIG_USB_PD_ALT_MODE_DFP #define CONFIG_USB_PD_DUAL_ROLE #define CONFIG_USB_PD_LOGGING -#define CONFIG_USB_PD_PORT_COUNT 2 +#define CONFIG_USB_PD_PORT_MAX_COUNT 2 #define CONFIG_USB_PD_TCPM_TCPCI #define CONFIG_USB_PD_TRY_SRC #define CONFIG_USB_PD_VBUS_DETECT_TCPC diff --git a/board/oak/usb_pd_policy.c b/board/oak/usb_pd_policy.c index 2268945144..be6868f268 100644 --- a/board/oak/usb_pd_policy.c +++ b/board/oak/usb_pd_policy.c @@ -207,9 +207,9 @@ int pd_custom_vdm(int port, int cnt, uint32_t *payload, } #ifdef CONFIG_USB_PD_ALT_MODE_DFP -static int dp_flags[CONFIG_USB_PD_PORT_COUNT]; +static int dp_flags[CONFIG_USB_PD_PORT_MAX_COUNT]; /* DP Status VDM as returned by UFP */ -static uint32_t dp_status[CONFIG_USB_PD_PORT_COUNT]; +static uint32_t dp_status[CONFIG_USB_PD_PORT_MAX_COUNT]; static void svdm_safe_dp_mode(int port) { diff --git a/board/pdeval-stm32f072/PD_evaluation.md b/board/pdeval-stm32f072/PD_evaluation.md index 395466f477..95e31996fc 100644 --- a/board/pdeval-stm32f072/PD_evaluation.md +++ b/board/pdeval-stm32f072/PD_evaluation.md @@ -35,7 +35,7 @@ then document the new `CONFIG_USB_PD_TCPM_` variable in the [include/config.h](. ### Board configuration -In [board/pdeval-stm32f072/board.h](board.h), you can update `CONFIG_USB_PD_PORT_COUNT` to the actual number of ports on your board. +In [board/pdeval-stm32f072/board.h](board.h), you can update `CONFIG_USB_PD_PORT_MAX_COUNT` to the actual number of ports on your board. You also need to create/delete the corresponding `PD_Cx` tasks in [board/pdeval-stm32f072/ec.tasklist](ec.tasklist). By default, the firmware is using I2C1 with SCL/SDA on pins PB6 and PB7, running with a 100kHz clock, and tries to talk to TCPCs at i2c slave addresses 0x9c and 0x9e. diff --git a/board/pdeval-stm32f072/board.c b/board/pdeval-stm32f072/board.c index d9462f4e1d..93f3f87082 100644 --- a/board/pdeval-stm32f072/board.c +++ b/board/pdeval-stm32f072/board.c @@ -57,7 +57,7 @@ const struct i2c_port_t i2c_ports[] = { }; const unsigned int i2c_ports_used = ARRAY_SIZE(i2c_ports); -const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_COUNT] = { +const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_MAX_COUNT] = { { .bus_type = EC_BUS_TYPE_I2C, .i2c_info = { diff --git a/board/pdeval-stm32f072/board.h b/board/pdeval-stm32f072/board.h index 7d25def826..b008edc860 100644 --- a/board/pdeval-stm32f072/board.h +++ b/board/pdeval-stm32f072/board.h @@ -25,7 +25,7 @@ #define CONFIG_USB_PD_ALT_MODE #define CONFIG_USB_PD_ALT_MODE_DFP #define CONFIG_USB_PD_DUAL_ROLE -#define CONFIG_USB_PD_PORT_COUNT 1 +#define CONFIG_USB_PD_PORT_MAX_COUNT 1 #define CONFIG_USB_PD_TCPM_TCPCI #define CONFIG_USB_PD_VBUS_DETECT_TCPC #define CONFIG_USB_PD_TCPM_ANX7447 diff --git a/board/pdeval-stm32f072/usb_pd_policy.c b/board/pdeval-stm32f072/usb_pd_policy.c index 283483d566..5821437f20 100644 --- a/board/pdeval-stm32f072/usb_pd_policy.c +++ b/board/pdeval-stm32f072/usb_pd_policy.c @@ -36,7 +36,7 @@ const uint32_t pd_snk_pdo[] = { const int pd_snk_pdo_cnt = ARRAY_SIZE(pd_snk_pdo); #if defined(CONFIG_USB_PD_TCPM_MUX) && defined(CONFIG_USB_PD_TCPM_ANX7447) -struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_COUNT] = { +struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_MAX_COUNT] = { { .driver = &anx7447_usb_mux_driver, }, @@ -253,8 +253,8 @@ int pd_custom_vdm(int port, int cnt, uint32_t *payload, } #ifdef CONFIG_USB_PD_ALT_MODE_DFP -static int dp_flags[CONFIG_USB_PD_PORT_COUNT]; -static uint32_t dp_status[CONFIG_USB_PD_PORT_COUNT]; +static int dp_flags[CONFIG_USB_PD_PORT_MAX_COUNT]; +static uint32_t dp_status[CONFIG_USB_PD_PORT_MAX_COUNT]; static void svdm_safe_dp_mode(int port) { diff --git a/board/phaser/board.c b/board/phaser/board.c index fb0878122a..009bbfb25a 100644 --- a/board/phaser/board.c +++ b/board/phaser/board.c @@ -294,7 +294,7 @@ DECLARE_HOOK(HOOK_CHIPSET_SUSPEND, board_chipset_suspend, HOOK_PRIO_DEFAULT); void board_overcurrent_event(int port, int is_overcurrented) { /* Sanity check the port. */ - if ((port < 0) || (port >= CONFIG_USB_PD_PORT_COUNT)) + if ((port < 0) || (port >= CONFIG_USB_PD_PORT_MAX_COUNT)) return; /* Note that the level is inverted because the pin is active low. */ diff --git a/board/plankton/board.h b/board/plankton/board.h index f78a2825ec..92201ca68b 100644 --- a/board/plankton/board.h +++ b/board/plankton/board.h @@ -25,7 +25,7 @@ #define CONFIG_USB_PD_IDENTITY_HW_VERS 1 #define CONFIG_USB_PD_IDENTITY_SW_VERS 1 #define CONFIG_USB_PD_INTERNAL_COMP -#define CONFIG_USB_PD_PORT_COUNT 1 +#define CONFIG_USB_PD_PORT_MAX_COUNT 1 #define CONFIG_USB_PD_TCPC #define CONFIG_USB_PD_TCPM_STUB #define CONFIG_USB_PD_VBUS_DETECT_GPIO diff --git a/board/poppy/board.c b/board/poppy/board.c index b4eae018f3..f99b06fbf9 100644 --- a/board/poppy/board.c +++ b/board/poppy/board.c @@ -188,7 +188,7 @@ const struct i2c_port_t i2c_ports[] = { const unsigned int i2c_ports_used = ARRAY_SIZE(i2c_ports); /* TCPC mux configuration */ -const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_COUNT] = { +const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_MAX_COUNT] = { { .bus_type = EC_BUS_TYPE_I2C, .i2c_info = { @@ -207,7 +207,7 @@ const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_COUNT] = { }, }; -struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_COUNT] = { +struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_MAX_COUNT] = { { .driver = &anx74xx_tcpm_usb_mux_driver, .hpd_update = &anx74xx_tcpc_update_hpd_status, @@ -306,7 +306,7 @@ void board_tcpc_init(void) * Initialize HPD to low; after sysjump SOC needs to see * HPD pulse to enable video path */ - for (port = 0; port < CONFIG_USB_PD_PORT_COUNT; port++) { + for (port = 0; port < CONFIG_USB_PD_PORT_MAX_COUNT; port++) { const struct usb_mux *mux = &usb_muxes[port]; mux->hpd_update(port, 0, 0); @@ -599,7 +599,7 @@ int board_set_active_charge_port(int charge_port) { /* charge port is a physical port */ int is_real_port = (charge_port >= 0 && - charge_port < CONFIG_USB_PD_PORT_COUNT); + charge_port < CONFIG_USB_PD_PORT_MAX_COUNT); /* check if we are source VBUS on the port */ int source = gpio_get_level(charge_port == 0 ? GPIO_USB_C0_5V_EN : GPIO_USB_C1_5V_EN); diff --git a/board/poppy/board.h b/board/poppy/board.h index 0896685d96..8c9d687665 100644 --- a/board/poppy/board.h +++ b/board/poppy/board.h @@ -155,7 +155,7 @@ #define CONFIG_USB_PD_DUAL_ROLE_AUTO_TOGGLE #define CONFIG_USB_PD_LOGGING #define CONFIG_USB_PD_MAX_SINGLE_SOURCE_CURRENT TYPEC_RP_3A0 -#define CONFIG_USB_PD_PORT_COUNT 2 +#define CONFIG_USB_PD_PORT_MAX_COUNT 2 #define CONFIG_USB_PD_VBUS_DETECT_GPIO #define CONFIG_USB_PD_TCPC_LOW_POWER #define CONFIG_USB_PD_TCPM_MUX diff --git a/board/poppy/usb_pd_policy.c b/board/poppy/usb_pd_policy.c index 678f547231..e6dbee1729 100644 --- a/board/poppy/usb_pd_policy.c +++ b/board/poppy/usb_pd_policy.c @@ -55,8 +55,9 @@ void pd_transition_voltage(int idx) /* No-operation: we are always 5V */ } -static uint8_t vbus_en[CONFIG_USB_PD_PORT_COUNT]; -static uint8_t vbus_rp[CONFIG_USB_PD_PORT_COUNT] = {TYPEC_RP_1A5, TYPEC_RP_1A5}; +static uint8_t vbus_en[CONFIG_USB_PD_PORT_MAX_COUNT]; +static uint8_t vbus_rp[CONFIG_USB_PD_PORT_MAX_COUNT] = {TYPEC_RP_1A5, + TYPEC_RP_1A5}; int board_vbus_source_enabled(int port) { @@ -301,8 +302,8 @@ int pd_custom_vdm(int port, int cnt, uint32_t *payload, } #ifdef CONFIG_USB_PD_ALT_MODE_DFP -static int dp_flags[CONFIG_USB_PD_PORT_COUNT]; -static uint32_t dp_status[CONFIG_USB_PD_PORT_COUNT]; +static int dp_flags[CONFIG_USB_PD_PORT_MAX_COUNT]; +static uint32_t dp_status[CONFIG_USB_PD_PORT_MAX_COUNT]; static void svdm_safe_dp_mode(int port) { diff --git a/board/puff/board.c b/board/puff/board.c index de837d4db7..0797c24a93 100644 --- a/board/puff/board.c +++ b/board/puff/board.c @@ -56,9 +56,9 @@ const struct pwm_t pwm_channels[] = { /******************************************************************************/ /* USB-C TPCP Configuration */ -const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_COUNT] = { +const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_MAX_COUNT] = { }; -struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_COUNT] = { +struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_MAX_COUNT] = { }; /******************************************************************************/ @@ -132,7 +132,7 @@ DECLARE_HOOK(HOOK_INIT, board_init, HOOK_PRIO_DEFAULT); /******************************************************************************/ /* USB-C PPC Configuration */ -struct ppc_config_t ppc_chips[CONFIG_USB_PD_PORT_COUNT] = { +struct ppc_config_t ppc_chips[CONFIG_USB_PD_PORT_MAX_COUNT] = { }; unsigned int ppc_cnt = ARRAY_SIZE(ppc_chips); diff --git a/board/puff/board.h b/board/puff/board.h index 1122b27bfa..7a6ea0848e 100644 --- a/board/puff/board.h +++ b/board/puff/board.h @@ -130,7 +130,7 @@ #define CONFIG_USB_PD_DUAL_ROLE #define CONFIG_USB_PD_DUAL_ROLE_AUTO_TOGGLE #define CONFIG_USB_PD_LOGGING -#define CONFIG_USB_PD_PORT_COUNT 1 +#define CONFIG_USB_PD_PORT_MAX_COUNT 1 #define CONFIG_USB_PD_VBUS_DETECT_GPIO #define CONFIG_USB_PD_VBUS_DETECT_PPC #define CONFIG_USB_PD_TCPC_LOW_POWER diff --git a/board/puff/usb_pd_policy.c b/board/puff/usb_pd_policy.c index 49de8abbea..bcca6774da 100644 --- a/board/puff/usb_pd_policy.c +++ b/board/puff/usb_pd_policy.c @@ -212,8 +212,8 @@ int pd_custom_vdm(int port, int cnt, uint32_t *payload, } #ifdef CONFIG_USB_PD_ALT_MODE_DFP -static int dp_flags[CONFIG_USB_PD_PORT_COUNT]; -static uint32_t dp_status[CONFIG_USB_PD_PORT_COUNT]; +static int dp_flags[CONFIG_USB_PD_PORT_MAX_COUNT]; +static uint32_t dp_status[CONFIG_USB_PD_PORT_MAX_COUNT]; static void svdm_safe_dp_mode(int port) { diff --git a/board/rainier/board.c b/board/rainier/board.c index 39da51f73d..4caefa94fb 100644 --- a/board/rainier/board.c +++ b/board/rainier/board.c @@ -126,7 +126,7 @@ const enum gpio_signal hibernate_wake_pins[] = { const int hibernate_wake_pins_used = ARRAY_SIZE(hibernate_wake_pins); /******************************************************************************/ -const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_COUNT] = { +const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_MAX_COUNT] = { { .bus_type = EC_BUS_TYPE_I2C, .i2c_info = { @@ -137,7 +137,7 @@ const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_COUNT] = { }, }; -struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_COUNT] = { +struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_MAX_COUNT] = { { .driver = &virtual_usb_mux_driver, .hpd_update = &virtual_hpd_update, diff --git a/board/rainier/board.h b/board/rainier/board.h index fe633e12b3..da673c22ec 100644 --- a/board/rainier/board.h +++ b/board/rainier/board.h @@ -94,7 +94,7 @@ #define CONFIG_USB_PD_ALT_MODE_DFP #define CONFIG_USB_PD_DISCHARGE_GPIO #define CONFIG_USB_PD_DUAL_ROLE -#define CONFIG_USB_PD_PORT_COUNT 1 +#define CONFIG_USB_PD_PORT_MAX_COUNT 1 #define CONFIG_USB_PD_TCPM_FUSB302 #define CONFIG_USB_PD_TCPM_TCPCI #define CONFIG_USB_PD_VBUS_DETECT_TCPC diff --git a/board/rainier/usb_pd_policy.c b/board/rainier/usb_pd_policy.c index 3b5ceb2152..e6c092ded9 100644 --- a/board/rainier/usb_pd_policy.c +++ b/board/rainier/usb_pd_policy.c @@ -215,9 +215,9 @@ int pd_custom_vdm(int port, int cnt, uint32_t *payload, } #ifdef CONFIG_USB_PD_ALT_MODE_DFP -static int dp_flags[CONFIG_USB_PD_PORT_COUNT]; +static int dp_flags[CONFIG_USB_PD_PORT_MAX_COUNT]; /* DP Status VDM as returned by UFP */ -static uint32_t dp_status[CONFIG_USB_PD_PORT_COUNT]; +static uint32_t dp_status[CONFIG_USB_PD_PORT_MAX_COUNT]; static void svdm_safe_dp_mode(int port) { diff --git a/board/rammus/board.c b/board/rammus/board.c index 660ca860bc..a854416dda 100644 --- a/board/rammus/board.c +++ b/board/rammus/board.c @@ -146,7 +146,7 @@ const struct i2c_port_t i2c_ports[] = { const unsigned int i2c_ports_used = ARRAY_SIZE(i2c_ports); /* TCPC mux configuration */ -struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_COUNT] = { +struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_MAX_COUNT] = { [USB_PD_PORT_PS8751] = { .bus_type = EC_BUS_TYPE_I2C, .i2c_info = { @@ -166,7 +166,7 @@ struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_COUNT] = { }, }; -struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_COUNT] = { +struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_MAX_COUNT] = { [USB_PD_PORT_PS8751] = { .driver = &tcpci_tcpm_usb_mux_driver, .hpd_update = &ps8xxx_tcpc_update_hpd_status, @@ -247,7 +247,7 @@ void board_tcpc_init(void) * Initialize HPD to low; after sysjump SOC needs to see * HPD pulse to enable video path */ - for (port = 0; port < CONFIG_USB_PD_PORT_COUNT; port++) { + for (port = 0; port < CONFIG_USB_PD_PORT_MAX_COUNT; port++) { const struct usb_mux *mux = &usb_muxes[port]; mux->hpd_update(port, 0, 0); } @@ -490,7 +490,7 @@ int board_set_active_charge_port(int charge_port) { /* charge port is a physical port */ int is_real_port = (charge_port >= 0 && - charge_port < CONFIG_USB_PD_PORT_COUNT); + charge_port < CONFIG_USB_PD_PORT_MAX_COUNT); /* check if we are source VBUS on the port */ int source = gpio_get_level(charge_port == 0 ? GPIO_USB_C0_5V_EN : GPIO_USB_C1_5V_EN); diff --git a/board/rammus/board.h b/board/rammus/board.h index caccc9cbe9..ed2489a84f 100644 --- a/board/rammus/board.h +++ b/board/rammus/board.h @@ -147,7 +147,7 @@ #define CONFIG_USB_PD_DUAL_ROLE_AUTO_TOGGLE #define CONFIG_USB_PD_LOGGING #define CONFIG_USB_PD_MAX_SINGLE_SOURCE_CURRENT TYPEC_RP_3A0 -#define CONFIG_USB_PD_PORT_COUNT 2 +#define CONFIG_USB_PD_PORT_MAX_COUNT 2 #define CONFIG_USB_PD_VBUS_DETECT_GPIO #define CONFIG_USB_PD_TCPC_LOW_POWER /* TODO(b:121222079): Remove the config before FSI */ diff --git a/board/rammus/usb_pd_policy.c b/board/rammus/usb_pd_policy.c index 433d8d59c1..b46618feb6 100644 --- a/board/rammus/usb_pd_policy.c +++ b/board/rammus/usb_pd_policy.c @@ -54,8 +54,9 @@ void pd_transition_voltage(int idx) /* No-operation: we are always 5V */ } -static uint8_t vbus_en[CONFIG_USB_PD_PORT_COUNT]; -static uint8_t vbus_rp[CONFIG_USB_PD_PORT_COUNT] = {TYPEC_RP_1A5, TYPEC_RP_1A5}; +static uint8_t vbus_en[CONFIG_USB_PD_PORT_MAX_COUNT]; +static uint8_t vbus_rp[CONFIG_USB_PD_PORT_MAX_COUNT] = {TYPEC_RP_1A5, + TYPEC_RP_1A5}; int board_vbus_source_enabled(int port) { @@ -271,8 +272,8 @@ int pd_custom_vdm(int port, int cnt, uint32_t *payload, } #ifdef CONFIG_USB_PD_ALT_MODE_DFP -static int dp_flags[CONFIG_USB_PD_PORT_COUNT]; -static uint32_t dp_status[CONFIG_USB_PD_PORT_COUNT]; +static int dp_flags[CONFIG_USB_PD_PORT_MAX_COUNT]; +static uint32_t dp_status[CONFIG_USB_PD_PORT_MAX_COUNT]; static void svdm_safe_dp_mode(int port) { diff --git a/board/reef/board.c b/board/reef/board.c index 8a73f6c3c7..8754d17bd0 100644 --- a/board/reef/board.c +++ b/board/reef/board.c @@ -226,7 +226,7 @@ struct i2c_stress_test i2c_stress_tests[] = { const int i2c_test_dev_used = ARRAY_SIZE(i2c_stress_tests); #endif /* CONFIG_CMD_I2C_STRESS_TEST */ -const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_COUNT] = { +const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_MAX_COUNT] = { [USB_PD_PORT_ANX74XX] = { .bus_type = EC_BUS_TYPE_I2C, .i2c_info = { @@ -277,7 +277,7 @@ static int ps8751_tune_mux(int port) return EC_SUCCESS; } -struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_COUNT] = { +struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_MAX_COUNT] = { [USB_PD_PORT_ANX74XX] = { .driver = &anx74xx_tcpm_usb_mux_driver, .hpd_update = &anx74xx_tcpc_update_hpd_status, @@ -383,7 +383,7 @@ void board_tcpc_init(void) * Initialize HPD to low; after sysjump SOC needs to see * HPD pulse to enable video path */ - for (port = 0; port < CONFIG_USB_PD_PORT_COUNT; port++) { + for (port = 0; port < CONFIG_USB_PD_PORT_MAX_COUNT; port++) { const struct usb_mux *mux = &usb_muxes[port]; mux->hpd_update(port, 0, 0); diff --git a/board/reef/board.h b/board/reef/board.h index a4d6e22593..4d6a65ffcc 100644 --- a/board/reef/board.h +++ b/board/reef/board.h @@ -83,7 +83,7 @@ #define CONFIG_USB_PD_DISCHARGE_TCPC #define CONFIG_USB_PD_LOGGING #define CONFIG_USB_PD_MAX_SINGLE_SOURCE_CURRENT TYPEC_RP_3A0 -#define CONFIG_USB_PD_PORT_COUNT 2 +#define CONFIG_USB_PD_PORT_MAX_COUNT 2 #define CONFIG_USB_PD_VBUS_DETECT_CHARGER #define CONFIG_USB_PD_TCPC_LOW_POWER #define CONFIG_USB_PD_TCPM_MUX /* for both PS8751 and ANX3429 */ diff --git a/board/reef/usb_pd_policy.c b/board/reef/usb_pd_policy.c index d2ceecf074..9765b540d1 100644 --- a/board/reef/usb_pd_policy.c +++ b/board/reef/usb_pd_policy.c @@ -56,8 +56,9 @@ void pd_transition_voltage(int idx) /* No-operation: we are always 5V */ } -static uint8_t vbus_en[CONFIG_USB_PD_PORT_COUNT]; -static uint8_t vbus_rp[CONFIG_USB_PD_PORT_COUNT] = {TYPEC_RP_1A5, TYPEC_RP_1A5}; +static uint8_t vbus_en[CONFIG_USB_PD_PORT_MAX_COUNT]; +static uint8_t vbus_rp[CONFIG_USB_PD_PORT_MAX_COUNT] = {TYPEC_RP_1A5, + TYPEC_RP_1A5}; int board_vbus_source_enabled(int port) { @@ -270,8 +271,8 @@ int pd_custom_vdm(int port, int cnt, uint32_t *payload, } #ifdef CONFIG_USB_PD_ALT_MODE_DFP -static int dp_flags[CONFIG_USB_PD_PORT_COUNT]; -static uint32_t dp_status[CONFIG_USB_PD_PORT_COUNT]; +static int dp_flags[CONFIG_USB_PD_PORT_MAX_COUNT]; +static uint32_t dp_status[CONFIG_USB_PD_PORT_MAX_COUNT]; static void svdm_safe_dp_mode(int port) { diff --git a/board/reef_it8320/board.c b/board/reef_it8320/board.c index 010bfd48b5..e268de83ed 100644 --- a/board/reef_it8320/board.c +++ b/board/reef_it8320/board.c @@ -73,7 +73,7 @@ const struct i2c_port_t i2c_ports[] = { }; const unsigned int i2c_ports_used = ARRAY_SIZE(i2c_ports); -const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_COUNT] = { +const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_MAX_COUNT] = { { .bus_type = EC_BUS_TYPE_EMBEDDED, .drv = &it83xx_tcpm_drv @@ -160,7 +160,7 @@ static void it83xx_tcpc_update_hpd_status(int port, int hpd_lvl, int hpd_irq) } } -struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_COUNT] = { +struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_MAX_COUNT] = { { .port_addr = 0x54, .driver = &pi3usb30532_usb_mux_driver, @@ -247,7 +247,7 @@ static void board_init(void) * Initialize HPD to low; after sysjump SOC needs to see * HPD pulse to enable video path */ - for (port = 0; port < CONFIG_USB_PD_PORT_COUNT; port++) + for (port = 0; port < CONFIG_USB_PD_PORT_MAX_COUNT; port++) usb_muxes[port].hpd_update(port, 0, 0); } DECLARE_HOOK(HOOK_INIT, board_init, HOOK_PRIO_INIT_I2C + 1); diff --git a/board/reef_it8320/board.h b/board/reef_it8320/board.h index 16038bddfa..1273e93a75 100644 --- a/board/reef_it8320/board.h +++ b/board/reef_it8320/board.h @@ -72,7 +72,7 @@ #define CONFIG_USB_PD_DISCHARGE_GPIO #define CONFIG_USB_PD_LOGGING #define CONFIG_USB_PD_MAX_SINGLE_SOURCE_CURRENT TYPEC_RP_3A0 -#define CONFIG_USB_PD_PORT_COUNT 2 +#define CONFIG_USB_PD_PORT_MAX_COUNT 2 #define CONFIG_USB_PD_VBUS_DETECT_CHARGER #define CONFIG_USB_PD_TCPM_ITE83XX #define CONFIG_USB_PD_TCPM_TCPCI diff --git a/board/reef_it8320/usb_pd_policy.c b/board/reef_it8320/usb_pd_policy.c index 8dbbc04102..03c7569682 100644 --- a/board/reef_it8320/usb_pd_policy.c +++ b/board/reef_it8320/usb_pd_policy.c @@ -56,8 +56,9 @@ void pd_transition_voltage(int idx) /* No-operation: we are always 5V */ } -static uint8_t vbus_en[CONFIG_USB_PD_PORT_COUNT]; -static uint8_t vbus_rp[CONFIG_USB_PD_PORT_COUNT] = {TYPEC_RP_1A5, TYPEC_RP_1A5}; +static uint8_t vbus_en[CONFIG_USB_PD_PORT_MAX_COUNT]; +static uint8_t vbus_rp[CONFIG_USB_PD_PORT_MAX_COUNT] = {TYPEC_RP_1A5, + TYPEC_RP_1A5}; int board_vbus_source_enabled(int port) { @@ -263,8 +264,8 @@ int pd_custom_vdm(int port, int cnt, uint32_t *payload, } #ifdef CONFIG_USB_PD_ALT_MODE_DFP -static int dp_flags[CONFIG_USB_PD_PORT_COUNT]; -static uint32_t dp_status[CONFIG_USB_PD_PORT_COUNT]; +static int dp_flags[CONFIG_USB_PD_PORT_MAX_COUNT]; +static uint32_t dp_status[CONFIG_USB_PD_PORT_MAX_COUNT]; static void svdm_safe_dp_mode(int port) { diff --git a/board/reef_mchp/board.c b/board/reef_mchp/board.c index 3b90eb4934..769f96197b 100644 --- a/board/reef_mchp/board.c +++ b/board/reef_mchp/board.c @@ -337,7 +337,7 @@ struct i2c_stress_test i2c_stress_tests[] = { const int i2c_test_dev_used = ARRAY_SIZE(i2c_stress_tests); #endif /* CONFIG_CMD_I2C_STRESS_TEST */ -const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_COUNT] = { +const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_MAX_COUNT] = { [USB_PD_PORT_ANX74XX] = { .bus_type = EC_BUS_TYPE_I2C, .i2c_info = { @@ -414,7 +414,7 @@ static int ps8751_tune_mux(int port) * tcpc_config array. The tcpc_config array contains the actual EC I2C * port, device slave address, and a function pointer into the driver code. */ -struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_COUNT] = { +struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_MAX_COUNT] = { [USB_PD_PORT_ANX74XX] = { .driver = &anx74xx_tcpm_usb_mux_driver, .hpd_update = &anx74xx_tcpc_update_hpd_status, @@ -529,7 +529,7 @@ void board_tcpc_init(void) * Initialize HPD to low; after sysjump SOC needs to see * HPD pulse to enable video path */ - for (port = 0; port < CONFIG_USB_PD_PORT_COUNT; port++) { + for (port = 0; port < CONFIG_USB_PD_PORT_MAX_COUNT; port++) { const struct usb_mux *mux = &usb_muxes[port]; mux->hpd_update(port, 0, 0); diff --git a/board/reef_mchp/board.h b/board/reef_mchp/board.h index a427abad0d..acaf8d19be 100644 --- a/board/reef_mchp/board.h +++ b/board/reef_mchp/board.h @@ -83,7 +83,7 @@ #define CONFIG_USB_PD_DISCHARGE_TCPC #define CONFIG_USB_PD_LOGGING #define CONFIG_USB_PD_MAX_SINGLE_SOURCE_CURRENT TYPEC_RP_3A0 -#define CONFIG_USB_PD_PORT_COUNT 2 +#define CONFIG_USB_PD_PORT_MAX_COUNT 2 #define CONFIG_USB_PD_VBUS_DETECT_CHARGER #define CONFIG_USB_PD_TCPC_LOW_POWER #define CONFIG_USB_PD_TCPM_MUX /* for both PS8751 and ANX3429 */ diff --git a/board/reef_mchp/usb_pd_policy.c b/board/reef_mchp/usb_pd_policy.c index 230a8efee0..1d4212fdcb 100644 --- a/board/reef_mchp/usb_pd_policy.c +++ b/board/reef_mchp/usb_pd_policy.c @@ -58,8 +58,9 @@ void pd_transition_voltage(int idx) /* No-operation: we are always 5V */ } -static uint8_t vbus_en[CONFIG_USB_PD_PORT_COUNT]; -static uint8_t vbus_rp[CONFIG_USB_PD_PORT_COUNT] = {TYPEC_RP_1A5, TYPEC_RP_1A5}; +static uint8_t vbus_en[CONFIG_USB_PD_PORT_MAX_COUNT]; +static uint8_t vbus_rp[CONFIG_USB_PD_PORT_MAX_COUNT] = {TYPEC_RP_1A5, + TYPEC_RP_1A5}; int board_vbus_source_enabled(int port) { @@ -278,8 +279,8 @@ int pd_custom_vdm(int port, int cnt, uint32_t *payload, } #ifdef CONFIG_USB_PD_ALT_MODE_DFP -static int dp_flags[CONFIG_USB_PD_PORT_COUNT]; -static uint32_t dp_status[CONFIG_USB_PD_PORT_COUNT]; +static int dp_flags[CONFIG_USB_PD_PORT_MAX_COUNT]; +static uint32_t dp_status[CONFIG_USB_PD_PORT_MAX_COUNT]; static void svdm_safe_dp_mode(int port) { diff --git a/board/samus_pd/board.c b/board/samus_pd/board.c index c942418ee6..69a67f6e44 100644 --- a/board/samus_pd/board.c +++ b/board/samus_pd/board.c @@ -318,7 +318,7 @@ int board_set_active_charge_port(int charge_port) { /* charge port is a realy physical port */ int is_real_port = (charge_port >= 0 && - charge_port < CONFIG_USB_PD_PORT_COUNT); + charge_port < CONFIG_USB_PD_PORT_MAX_COUNT); /* check if we are source vbus on that port */ if (is_real_port && usb_charger_port_is_sourcing_vbus(charge_port)) { CPRINTS("Skip enable p%d", charge_port); diff --git a/board/samus_pd/board.h b/board/samus_pd/board.h index a6e6d3ecec..9fc09340c1 100644 --- a/board/samus_pd/board.h +++ b/board/samus_pd/board.h @@ -63,7 +63,7 @@ #define CONFIG_USB_PD_FLASH_ERASE_CHECK #define CONFIG_USB_PD_INTERNAL_COMP #define CONFIG_USB_PD_LOGGING -#define CONFIG_USB_PD_PORT_COUNT 2 +#define CONFIG_USB_PD_PORT_MAX_COUNT 2 #define CONFIG_USB_PD_TCPC #define CONFIG_USB_PD_TCPM_STUB #define CONFIG_USB_PD_VBUS_DETECT_GPIO diff --git a/board/samus_pd/usb_mux.c b/board/samus_pd/usb_mux.c index 268c0c5843..2c3a0b3a45 100644 --- a/board/samus_pd/usb_mux.c +++ b/board/samus_pd/usb_mux.c @@ -37,7 +37,7 @@ static const struct usb_port_mux mux_gpios[] = { .ss2_dp_mode = GPIO_USB_C1_SS2_DP_MODE, }, }; -BUILD_ASSERT(ARRAY_SIZE(mux_gpios) == CONFIG_USB_PD_PORT_COUNT); +BUILD_ASSERT(ARRAY_SIZE(mux_gpios) == CONFIG_USB_PD_PORT_MAX_COUNT); static int board_init_usb_mux(int port) @@ -105,7 +105,7 @@ const struct usb_mux_driver board_custom_usb_mux_driver = { .get = board_get_usb_mux, }; -struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_COUNT] = { +struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_MAX_COUNT] = { { .driver = &board_custom_usb_mux_driver, }, diff --git a/board/samus_pd/usb_pd_policy.c b/board/samus_pd/usb_pd_policy.c index 595c3b6929..40277da8f8 100644 --- a/board/samus_pd/usb_pd_policy.c +++ b/board/samus_pd/usb_pd_policy.c @@ -214,9 +214,9 @@ int pd_custom_vdm(int port, int cnt, uint32_t *payload, return 0; } -static int dp_flags[CONFIG_USB_PD_PORT_COUNT]; +static int dp_flags[CONFIG_USB_PD_PORT_MAX_COUNT]; /* DP Status VDM as returned by UFP */ -static uint32_t dp_status[CONFIG_USB_PD_PORT_COUNT]; +static uint32_t dp_status[CONFIG_USB_PD_PORT_MAX_COUNT]; static void svdm_safe_dp_mode(int port) { diff --git a/board/scarlet/board.c b/board/scarlet/board.c index 1ba595479b..4321d53179 100644 --- a/board/scarlet/board.c +++ b/board/scarlet/board.c @@ -122,7 +122,7 @@ const struct spi_device_t spi_devices[] = { const unsigned int spi_devices_used = ARRAY_SIZE(spi_devices); /******************************************************************************/ -const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_COUNT] = { +const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_MAX_COUNT] = { { .bus_type = EC_BUS_TYPE_I2C, .i2c_info = { @@ -133,7 +133,7 @@ const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_COUNT] = { }, }; -struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_COUNT] = { +struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_MAX_COUNT] = { { .driver = &virtual_usb_mux_driver, .hpd_update = &virtual_hpd_update, diff --git a/board/scarlet/board.h b/board/scarlet/board.h index 2569f41e14..adcca92cdb 100644 --- a/board/scarlet/board.h +++ b/board/scarlet/board.h @@ -113,7 +113,7 @@ #define CONFIG_USB_PD_DISCHARGE_GPIO #define CONFIG_USB_PD_DUAL_ROLE #define CONFIG_USB_PD_LOGGING -#define CONFIG_USB_PD_PORT_COUNT 1 +#define CONFIG_USB_PD_PORT_MAX_COUNT 1 #define CONFIG_USB_PD_TCPM_FUSB302 #define CONFIG_USB_PD_TCPM_TCPCI #define CONFIG_USB_PD_VBUS_DETECT_TCPC diff --git a/board/scarlet/usb_pd_policy.c b/board/scarlet/usb_pd_policy.c index 75ddb97d8c..69064fdcf6 100644 --- a/board/scarlet/usb_pd_policy.c +++ b/board/scarlet/usb_pd_policy.c @@ -216,9 +216,9 @@ int pd_custom_vdm(int port, int cnt, uint32_t *payload, } #ifdef CONFIG_USB_PD_ALT_MODE_DFP -static int dp_flags[CONFIG_USB_PD_PORT_COUNT]; +static int dp_flags[CONFIG_USB_PD_PORT_MAX_COUNT]; /* DP Status VDM as returned by UFP */ -static uint32_t dp_status[CONFIG_USB_PD_PORT_COUNT]; +static uint32_t dp_status[CONFIG_USB_PD_PORT_MAX_COUNT]; static void svdm_safe_dp_mode(int port) { diff --git a/board/servo_v4/board.h b/board/servo_v4/board.h index be906787ad..ace902a4c3 100644 --- a/board/servo_v4/board.h +++ b/board/servo_v4/board.h @@ -106,7 +106,7 @@ #define CONFIG_USB_PD_DUAL_ROLE #define CONFIG_USB_PD_DYNAMIC_SRC_CAP #define CONFIG_USB_PD_INTERNAL_COMP -#define CONFIG_USB_PD_PORT_COUNT 2 +#define CONFIG_USB_PD_PORT_MAX_COUNT 2 #define CONFIG_USB_PD_TCPC #define CONFIG_USB_PD_TCPM_STUB #undef CONFIG_USB_PD_PULLUP diff --git a/board/servo_v4/usb_pd_policy.c b/board/servo_v4/usb_pd_policy.c index 138f53a4a7..5c8019dc08 100644 --- a/board/servo_v4/usb_pd_policy.c +++ b/board/servo_v4/usb_pd_policy.c @@ -108,7 +108,7 @@ struct vbus_prop { int mv; int ma; }; -static struct vbus_prop vbus[CONFIG_USB_PD_PORT_COUNT]; +static struct vbus_prop vbus[CONFIG_USB_PD_PORT_MAX_COUNT]; static int active_charge_port = CHARGE_PORT_NONE; static enum charge_supplier active_charge_supplier; static uint8_t vbus_rp = TYPEC_RP_RESERVED; diff --git a/board/strago/board.c b/board/strago/board.c index f63d95da27..03c4c814be 100644 --- a/board/strago/board.c +++ b/board/strago/board.c @@ -105,7 +105,7 @@ const struct i2c_port_t i2c_ports[] = { }; const unsigned int i2c_ports_used = ARRAY_SIZE(i2c_ports); -const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_COUNT] = { +const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_MAX_COUNT] = { { .bus_type = EC_BUS_TYPE_I2C, .i2c_info = { @@ -139,7 +139,7 @@ struct pi3usb9281_config pi3usb9281_chips[] = { BUILD_ASSERT(ARRAY_SIZE(pi3usb9281_chips) == CONFIG_BC12_DETECT_PI3USB9281_CHIP_COUNT); -struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_COUNT] = { +struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_MAX_COUNT] = { { .port_addr = 0x55, .driver = &pi3usb30532_usb_mux_driver, @@ -285,7 +285,7 @@ int board_set_active_charge_port(int charge_port) { /* charge port is a realy physical port */ int is_real_port = (charge_port >= 0 && - charge_port < CONFIG_USB_PD_PORT_COUNT); + charge_port < CONFIG_USB_PD_PORT_MAX_COUNT); /* check if we are source vbus on that port */ int source = gpio_get_level(GPIO_USB_C0_5V_EN); diff --git a/board/strago/board.h b/board/strago/board.h index db6adcea63..1b44868e0a 100644 --- a/board/strago/board.h +++ b/board/strago/board.h @@ -40,7 +40,7 @@ #define CONFIG_USB_PD_ALT_MODE #define CONFIG_USB_PD_ALT_MODE_DFP #define CONFIG_USB_PD_DUAL_ROLE -#define CONFIG_USB_PD_PORT_COUNT 1 +#define CONFIG_USB_PD_PORT_MAX_COUNT 1 #define CONFIG_USB_PD_TCPM_TCPCI #define CONFIG_USB_PD_TRY_SRC #define CONFIG_USB_PD_VBUS_DETECT_GPIO diff --git a/board/strago/usb_pd_policy.c b/board/strago/usb_pd_policy.c index 748e08a40e..0a12fec103 100644 --- a/board/strago/usb_pd_policy.c +++ b/board/strago/usb_pd_policy.c @@ -245,7 +245,7 @@ static int svdm_dp_config(int port, uint32_t *payload) * timestamp of the next possible toggle to ensure the 2-ms spacing * between IRQ_HPD. */ -static uint64_t hpd_deadline[CONFIG_USB_PD_PORT_COUNT]; +static uint64_t hpd_deadline[CONFIG_USB_PD_PORT_MAX_COUNT]; static void svdm_dp_post_config(int port) { diff --git a/board/tglrvpu_ite/board.c b/board/tglrvpu_ite/board.c index c98e5035e7..93a7d18984 100644 --- a/board/tglrvpu_ite/board.c +++ b/board/tglrvpu_ite/board.c @@ -71,7 +71,7 @@ const struct tcpc_gpio_config_t tcpc_gpios[] = { }, }, }; -BUILD_ASSERT(ARRAY_SIZE(tcpc_gpios) == CONFIG_USB_PD_PORT_COUNT); +BUILD_ASSERT(ARRAY_SIZE(tcpc_gpios) == CONFIG_USB_PD_PORT_MAX_COUNT); /* I2C ports */ const struct i2c_port_t i2c_ports[] = { diff --git a/board/tglrvpu_ite/board.h b/board/tglrvpu_ite/board.h index 9a050d2d5c..df6b892c5d 100644 --- a/board/tglrvpu_ite/board.h +++ b/board/tglrvpu_ite/board.h @@ -35,7 +35,7 @@ #define CONFIG_DEDICATED_CHARGE_PORT_COUNT 1 /* USB ports */ -#define CONFIG_USB_PD_PORT_COUNT 2 +#define CONFIG_USB_PD_PORT_MAX_COUNT 2 #define DEDICATED_CHARGE_PORT 2 /* USB-C port's USB2 & USB3 port numbers */ diff --git a/board/twinkie/board.h b/board/twinkie/board.h index 60f359e282..42944f37f1 100644 --- a/board/twinkie/board.h +++ b/board/twinkie/board.h @@ -23,7 +23,7 @@ #define CONFIG_USB_POWER_DELIVERY #define CONFIG_USB_PD_DUAL_ROLE #define CONFIG_USB_PD_INTERNAL_COMP -#define CONFIG_USB_PD_PORT_COUNT 1 +#define CONFIG_USB_PD_PORT_MAX_COUNT 1 #define CONFIG_USB_PD_TCPC #define CONFIG_USB_PD_TCPM_STUB #define CONFIG_USB_PD_VBUS_DETECT_GPIO diff --git a/board/yorp/board.c b/board/yorp/board.c index cc44a6c088..89dee7fb41 100644 --- a/board/yorp/board.c +++ b/board/yorp/board.c @@ -249,7 +249,7 @@ DECLARE_HOOK(HOOK_INIT, post_old_board_warning, HOOK_PRIO_INIT_I2C + 1); void board_overcurrent_event(int port, int is_overcurrented) { /* Sanity check the port. */ - if ((port < 0) || (port >= CONFIG_USB_PD_PORT_COUNT)) + if ((port < 0) || (port >= CONFIG_USB_PD_PORT_MAX_COUNT)) return; /* Note that the level is inverted because the pin is active low. */ diff --git a/board/zinger/board.h b/board/zinger/board.h index cc34b2f8b7..83ec02221c 100644 --- a/board/zinger/board.h +++ b/board/zinger/board.h @@ -60,7 +60,7 @@ #undef CONFIG_EVENT_LOG_SIZE #define CONFIG_EVENT_LOG_SIZE 256 #define CONFIG_USB_PD_LOW_POWER_IDLE_WHEN_CONNECTED -#define CONFIG_USB_PD_PORT_COUNT 1 +#define CONFIG_USB_PD_PORT_MAX_COUNT 1 #define CONFIG_USB_PD_TCPC #define CONFIG_USB_PD_TCPM_STUB #undef CONFIG_USB_PD_RX_COMP_IRQ diff --git a/chip/host/usb_pd_phy.c b/chip/host/usb_pd_phy.c index c44b8eea02..0ca92604b8 100644 --- a/chip/host/usb_pd_phy.c +++ b/chip/host/usb_pd_phy.c @@ -35,7 +35,7 @@ static struct pd_physical { int last_edge_written; uint8_t out_msg[PD_BIT_LEN / 5]; int verified_idx; -} pd_phy[CONFIG_USB_PD_PORT_COUNT]; +} pd_phy[CONFIG_USB_PD_PORT_MAX_COUNT]; static const uint16_t enc4b5b[] = { 0x1E, 0x09, 0x14, 0x15, 0x0A, 0x0B, 0x0E, 0x0F, 0x12, 0x13, 0x16, diff --git a/chip/mec1322/system.c b/chip/mec1322/system.c index 4938f07b75..6fa837f6f4 100644 --- a/chip/mec1322/system.c +++ b/chip/mec1322/system.c @@ -292,20 +292,20 @@ void system_hibernate(uint32_t seconds, uint32_t microseconds) if (board_hibernate_late) board_hibernate_late(); -#ifdef CONFIG_USB_PD_PORT_COUNT +#ifdef CONFIG_USB_PD_PORT_MAX_COUNT /* * Leave USB-C charging enabled in hibernate, in order to * allow wake-on-plug. 5V enable must be pulled low. */ -#if CONFIG_USB_PD_PORT_COUNT > 0 +#if CONFIG_USB_PD_PORT_MAX_COUNT > 0 gpio_set_flags(GPIO_USB_C0_5V_EN, GPIO_PULL_DOWN | GPIO_INPUT); gpio_set_level(GPIO_USB_C0_CHARGE_EN_L, 0); #endif -#if CONFIG_USB_PD_PORT_COUNT > 1 +#if CONFIG_USB_PD_PORT_MAX_COUNT > 1 gpio_set_flags(GPIO_USB_C1_5V_EN, GPIO_PULL_DOWN | GPIO_INPUT); gpio_set_level(GPIO_USB_C1_CHARGE_EN_L, 0); #endif -#endif /* CONFIG_USB_PD_PORT_COUNT */ +#endif /* CONFIG_USB_PD_PORT_MAX_COUNT */ if (hibernate_wake_pins_used > 0) { for (i = 0; i < hibernate_wake_pins_used; ++i) { diff --git a/chip/stm32/system.c b/chip/stm32/system.c index 27e2f8fc79..ddba03958a 100644 --- a/chip/stm32/system.c +++ b/chip/stm32/system.c @@ -78,7 +78,7 @@ enum bkpdata_index { BUILD_ASSERT(STM32_BKP_ENTRIES >= BKPDATA_COUNT); #ifdef CONFIG_USB_PD_DUAL_ROLE -BUILD_ASSERT(CONFIG_USB_PD_PORT_COUNT <= 2); +BUILD_ASSERT(CONFIG_USB_PD_PORT_MAX_COUNT <= 2); #endif /** diff --git a/chip/stm32/usb_pd_phy.c b/chip/stm32/usb_pd_phy.c index 833b3b0f3a..7296ae245f 100644 --- a/chip/stm32/usb_pd_phy.c +++ b/chip/stm32/usb_pd_phy.c @@ -70,14 +70,15 @@ static struct pd_physical { /* Pointers to timer register for each port */ timer_ctlr_t *tim_tx; timer_ctlr_t *tim_rx; -} pd_phy[CONFIG_USB_PD_PORT_COUNT]; +} pd_phy[CONFIG_USB_PD_PORT_MAX_COUNT]; /* keep track of RX edge timing in order to trigger receive */ -static timestamp_t rx_edge_ts[CONFIG_USB_PD_PORT_COUNT][PD_RX_TRANSITION_COUNT]; -static int rx_edge_ts_idx[CONFIG_USB_PD_PORT_COUNT]; +static timestamp_t + rx_edge_ts[CONFIG_USB_PD_PORT_MAX_COUNT][PD_RX_TRANSITION_COUNT]; +static int rx_edge_ts_idx[CONFIG_USB_PD_PORT_MAX_COUNT]; /* keep track of transmit polarity for DMA interrupt */ -static int tx_dma_polarities[CONFIG_USB_PD_PORT_COUNT]; +static int tx_dma_polarities[CONFIG_USB_PD_PORT_MAX_COUNT]; void pd_init_dequeue(int port) { @@ -462,7 +463,7 @@ void pd_rx_handler(void) } #endif - for (i = 0; i < CONFIG_USB_PD_PORT_COUNT; i++) { + for (i = 0; i < CONFIG_USB_PD_PORT_MAX_COUNT; i++) { if (pending & EXTI_COMP_MASK(i)) { rx_edge_ts[i][rx_edge_ts_idx[i]].val = get_time().val; next_idx = (rx_edge_ts_idx[i] == diff --git a/common/charge_manager.c b/common/charge_manager.c index 176781234f..6f8a796999 100644 --- a/common/charge_manager.c +++ b/common/charge_manager.c @@ -103,11 +103,11 @@ static int override_port = OVERRIDE_OFF; static int delayed_override_port = OVERRIDE_OFF; static timestamp_t delayed_override_deadline; -static uint8_t source_port_rp[CONFIG_USB_PD_PORT_COUNT]; +static uint8_t source_port_rp[CONFIG_USB_PD_PORT_MAX_COUNT]; #ifdef CONFIG_USB_PD_MAX_TOTAL_SOURCE_CURRENT /* 3A on one port and 1.5A on the rest */ -BUILD_ASSERT(CONFIG_USB_PD_PORT_COUNT * 1500 + 1500 <= +BUILD_ASSERT(CONFIG_USB_PD_PORT_MAX_COUNT * 1500 + 1500 <= CONFIG_USB_PD_MAX_TOTAL_SOURCE_CURRENT); #endif @@ -140,7 +140,7 @@ enum charge_manager_change_type { static int is_pd_port(int port) { - return 0 <= port && port < CONFIG_USB_PD_PORT_COUNT; + return port >= 0 && port < CONFIG_USB_PD_PORT_MAX_COUNT; } static int is_sink(int port) @@ -761,7 +761,7 @@ static void charge_manager_refresh(void) if (updated_old_port != CHARGE_PORT_NONE) save_log[updated_old_port] = 1; - for (i = 0; i < CONFIG_USB_PD_PORT_COUNT; ++i) + for (i = 0; i < CONFIG_USB_PD_PORT_MAX_COUNT; ++i) if (save_log[i]) charge_manager_save_log(i); #endif @@ -1111,7 +1111,7 @@ int charge_manager_get_power_limit_uw(void) /* Bitmap of ports used as power source */ static volatile uint32_t source_port_bitmap; -BUILD_ASSERT(sizeof(source_port_bitmap)*8 >= CONFIG_USB_PD_PORT_COUNT); +BUILD_ASSERT(sizeof(source_port_bitmap)*8 >= CONFIG_USB_PD_PORT_MAX_COUNT); static inline int has_other_active_source(int port) { @@ -1138,7 +1138,7 @@ static int can_supply_max_current(int port) if (!is_active_source(port)) /* Non-active ports don't get 3A */ return 0; - for (p = 0; p < CONFIG_USB_PD_PORT_COUNT; p++) { + for (p = 0; p < CONFIG_USB_PD_PORT_MAX_COUNT; p++) { if (p == port) continue; if (source_port_rp[p] == @@ -1166,7 +1166,7 @@ void charge_manager_source_port(int port, int enable) return; /* Set port limit according to policy */ - for (p = 0; p < CONFIG_USB_PD_PORT_COUNT; p++) { + for (p = 0; p < CONFIG_USB_PD_PORT_MAX_COUNT; p++) { rp = can_supply_max_current(p) ? CONFIG_USB_PD_MAX_SINGLE_SOURCE_CURRENT : CONFIG_USB_PD_PULLUP; @@ -1309,7 +1309,7 @@ static void charge_manager_set_external_power_limit(int current_lim, if (voltage_lim == EC_POWER_LIMIT_NONE) voltage_lim = PD_MAX_VOLTAGE_MV; - for (port = 0; port < CONFIG_USB_PD_PORT_COUNT; ++port) { + for (port = 0; port < CONFIG_USB_PD_PORT_MAX_COUNT; ++port) { charge_manager_set_ceil(port, CEIL_REQUESTOR_HOST, current_lim); pd_set_external_voltage_limit(port, voltage_lim); } diff --git a/common/charge_ramp_sw.c b/common/charge_ramp_sw.c index 1e1289654e..33dbff656b 100644 --- a/common/charge_ramp_sw.c +++ b/common/charge_ramp_sw.c @@ -59,8 +59,8 @@ struct oc_info { }; /* OCP info for each over-current */ -static struct oc_info oc_info[CONFIG_USB_PD_PORT_COUNT][RAMP_COUNT]; -static int oc_info_idx[CONFIG_USB_PD_PORT_COUNT]; +static struct oc_info oc_info[CONFIG_USB_PD_PORT_MAX_COUNT][RAMP_COUNT]; +static int oc_info_idx[CONFIG_USB_PD_PORT_MAX_COUNT]; #define ACTIVE_OC_INFO (oc_info[active_port][oc_info_idx[active_port]]) /* Active charging information */ @@ -157,7 +157,7 @@ void chg_ramp_task(void *u) int active_icl_new; /* Clear last OCP supplier to guarantee we ramp on first connect */ - for (i = 0; i < CONFIG_USB_PD_PORT_COUNT; i++) + for (i = 0; i < CONFIG_USB_PD_PORT_MAX_COUNT; i++) oc_info[i][0].sup = CHARGE_SUPPLIER_NONE; /* @@ -364,7 +364,7 @@ static int command_chgramp(int argc, char **argv) ccprintf("Chg Ramp:\nState: %d\nMin ICL: %d\nActive ICL: %d\n", ramp_st, min_icl, active_icl); - for (port = 0; port < CONFIG_USB_PD_PORT_COUNT; port++) { + for (port = 0; port < CONFIG_USB_PD_PORT_MAX_COUNT; port++) { ccprintf("Port %d:\n", port); ccprintf(" OC idx:%d\n", oc_info_idx[port]); for (i = 0; i < RAMP_COUNT; i++) { diff --git a/common/host_command_pd.c b/common/host_command_pd.c index 3f0f83c4b2..593ac335ec 100644 --- a/common/host_command_pd.c +++ b/common/host_command_pd.c @@ -139,7 +139,7 @@ static void pd_service_tcpc_ports(uint16_t port_status) { int i; - for (i = 0; i < CONFIG_USB_PD_PORT_COUNT; i++) { + for (i = 0; i < CONFIG_USB_PD_PORT_MAX_COUNT; i++) { if ((port_status & (PD_STATUS_TCPC_ALERT_0 << i)) && pd_is_port_enabled(i)) tcpc_alert(i); diff --git a/common/i2c_master.c b/common/i2c_master.c index 091ea7f423..37090c0ad6 100644 --- a/common/i2c_master.c +++ b/common/i2c_master.c @@ -912,7 +912,7 @@ static void i2c_passthru_protect_port(uint32_t port) static void i2c_passthru_protect_tcpc_ports(void) { -#ifdef CONFIG_USB_PD_PORT_COUNT +#ifdef CONFIG_USB_PD_PORT_MAX_COUNT int i; /* @@ -924,7 +924,7 @@ static void i2c_passthru_protect_tcpc_ports(void) return; } - for (i = 0; i < CONFIG_USB_PD_PORT_COUNT; i++) { + for (i = 0; i < CONFIG_USB_PD_PORT_MAX_COUNT; i++) { /* TCPC tunnel not configured. No need to protect anything */ if (!I2C_GET_ADDR(tcpc_config[i].i2c_info.addr_flags)) continue; diff --git a/common/pd_log.c b/common/pd_log.c index b91a58762c..1eb5d3e3ab 100644 --- a/common/pd_log.c +++ b/common/pd_log.c @@ -68,7 +68,7 @@ dequeue_retry: if (r->type == PD_EVENT_NO_ENTRY) { int i, res; incoming_logs = 0; - for (i = 0; i < CONFIG_USB_PD_PORT_COUNT; ++i) { + for (i = 0; i < CONFIG_USB_PD_PORT_MAX_COUNT; ++i) { /* only accessories who knows Google logging format */ if (pd_get_identity_vid(i) != USB_VID_GOOGLE) continue; @@ -96,7 +96,7 @@ static enum ec_status hc_pd_write_log_entry(struct host_cmd_handler_args *args) if (type < PD_EVENT_MCU_BASE || type >= PD_EVENT_ACC_BASE) return EC_RES_INVALID_PARAM; - if (port > 0 && port >= CONFIG_USB_PD_PORT_COUNT) + if (port > 0 && port >= CONFIG_USB_PD_PORT_MAX_COUNT) return EC_RES_INVALID_PARAM; switch (type) { diff --git a/common/peripheral.c b/common/peripheral.c index 686368fd02..7e567974ec 100644 --- a/common/peripheral.c +++ b/common/peripheral.c @@ -29,8 +29,8 @@ static enum ec_status hc_locate_chip(struct host_cmd_handler_args *args) #endif /* CONFIG_CROS_BOARD_INFO */ break; case EC_CHIP_TYPE_TCPC: -#if defined(CONFIG_USB_PD_PORT_COUNT) && !defined(CONFIG_USB_PD_TCPC) - if (params->index >= CONFIG_USB_PD_PORT_COUNT) +#if defined(CONFIG_USB_PD_PORT_MAX_COUNT) && !defined(CONFIG_USB_PD_TCPC) + if (params->index >= CONFIG_USB_PD_PORT_MAX_COUNT) return EC_RES_OVERFLOW; resp->bus_type = tcpc_config[params->index].bus_type; if (resp->bus_type == EC_BUS_TYPE_I2C) { @@ -44,7 +44,7 @@ static enum ec_status hc_locate_chip(struct host_cmd_handler_args *args) #endif #else return EC_RES_UNAVAILABLE; -#endif /* CONFIG_USB_PD_PORT_COUNT */ +#endif /* CONFIG_USB_PD_PORT_MAX_COUNT */ break; default: /* The type was unrecognized */ diff --git a/common/system.c b/common/system.c index 5ae642a560..90029d88b4 100644 --- a/common/system.c +++ b/common/system.c @@ -857,7 +857,8 @@ static int handle_pending_reboot(enum ec_reboot_cmd cmd) { int port; - for (port = 0; port < CONFIG_USB_PD_PORT_COUNT; port++) + for (port = 0; port < CONFIG_USB_PD_PORT_MAX_COUNT; + port++) pd_set_suspend(port, 1); } #endif diff --git a/common/usb_charger.c b/common/usb_charger.c index 4d0d615a9b..c2dd062f6f 100644 --- a/common/usb_charger.c +++ b/common/usb_charger.c @@ -52,7 +52,7 @@ int usb_charger_port_is_sourcing_vbus(int port) { if (port == 0) return USB_5V_EN(0); -#if CONFIG_USB_PD_PORT_COUNT >= 2 +#if CONFIG_USB_PD_PORT_MAX_COUNT >= 2 else if (port == 1) return USB_5V_EN(1); #endif @@ -111,7 +111,7 @@ void usb_charger_reset_charge(int port) static void usb_charger_init(void) { int i; - for (i = 0; i < CONFIG_USB_PD_PORT_COUNT; i++) { + for (i = 0; i < CONFIG_USB_PD_PORT_MAX_COUNT; i++) { usb_charger_reset_charge(i); /* Initialize VBUS supplier based on whether VBUS is present. */ update_vbus_supplier(i, pd_is_vbus_present(i)); diff --git a/common/usb_pd_policy.c b/common/usb_pd_policy.c index 090588a034..f36ec396ab 100644 --- a/common/usb_pd_policy.c +++ b/common/usb_pd_policy.c @@ -99,22 +99,22 @@ __attribute__((weak)) int pd_board_check_request(uint32_t rdo, int pdo_cnt) #ifdef CONFIG_USB_PD_DUAL_ROLE /* Last received source cap */ -static uint32_t pd_src_caps[CONFIG_USB_PD_PORT_COUNT][PDO_MAX_OBJECTS]; -static uint8_t pd_src_cap_cnt[CONFIG_USB_PD_PORT_COUNT]; +static uint32_t pd_src_caps[CONFIG_USB_PD_PORT_MAX_COUNT][PDO_MAX_OBJECTS]; +static uint8_t pd_src_cap_cnt[CONFIG_USB_PD_PORT_MAX_COUNT]; /* Cap on the max voltage requested as a sink (in millivolts) */ static unsigned max_request_mv = PD_MAX_VOLTAGE_MV; /* no cap */ const uint32_t * const pd_get_src_caps(int port) { - ASSERT(port < CONFIG_USB_PD_PORT_COUNT); + ASSERT(port < CONFIG_USB_PD_PORT_MAX_COUNT); return pd_src_caps[port]; } uint8_t pd_get_src_cap_cnt(int port) { - ASSERT(port < CONFIG_USB_PD_PORT_COUNT); + ASSERT(port < CONFIG_USB_PD_PORT_MAX_COUNT); return pd_src_cap_cnt[port]; } @@ -164,7 +164,7 @@ int pd_charge_from_device(uint16_t vid, uint16_t pid) } #endif /* CONFIG_USB_PD_DUAL_ROLE */ -static struct pd_cable cable[CONFIG_USB_PD_PORT_COUNT]; +static struct pd_cable cable[CONFIG_USB_PD_PORT_MAX_COUNT]; static uint8_t is_transmit_msg_sop_prime(int port) { @@ -209,7 +209,7 @@ enum idh_ptype get_usb_pd_mux_cable_type(int port) #ifdef CONFIG_USB_PD_ALT_MODE_DFP -static struct pd_policy pe[CONFIG_USB_PD_PORT_COUNT]; +static struct pd_policy pe[CONFIG_USB_PD_PORT_MAX_COUNT]; static int is_vdo_present(int cnt, int index) { @@ -629,7 +629,7 @@ static int command_pe(int argc, char **argv) return EC_ERROR_PARAM_COUNT; /* command: pe <port> <subcmd> <args> */ port = strtoi(argv[1], &e, 10); - if (*e || port >= CONFIG_USB_PD_PORT_COUNT) + if (*e || port >= CONFIG_USB_PD_PORT_MAX_COUNT) return EC_ERROR_PARAM2; if (!strncasecmp(argv[2], "dump", 4)) dump_pe(port); @@ -884,7 +884,7 @@ static int command_cable(int argc, char **argv) if (argc < 2) return EC_ERROR_PARAM_COUNT; port = strtoi(argv[1], &e, 0); - if (*e || port >= CONFIG_USB_PD_PORT_COUNT) + if (*e || port >= CONFIG_USB_PD_PORT_MAX_COUNT) return EC_ERROR_PARAM2; if (!cable[port].is_identified) { @@ -984,7 +984,7 @@ static enum ec_status hc_remote_pd_discovery(struct host_cmd_handler_args *args) const uint8_t *port = args->params; struct ec_params_usb_pd_discovery_entry *r = args->response; - if (*port >= CONFIG_USB_PD_PORT_COUNT) + if (*port >= CONFIG_USB_PD_PORT_MAX_COUNT) return EC_RES_INVALID_PARAM; r->vid = pd_get_identity_vid(*port); @@ -1006,7 +1006,7 @@ static enum ec_status hc_remote_pd_get_amode(struct host_cmd_handler_args *args) const struct ec_params_usb_pd_get_mode_request *p = args->params; struct ec_params_usb_pd_get_mode_response *r = args->response; - if (p->port >= CONFIG_USB_PD_PORT_COUNT) + if (p->port >= CONFIG_USB_PD_PORT_MAX_COUNT) return EC_RES_INVALID_PARAM; /* no more to send */ @@ -1135,17 +1135,17 @@ int pd_custom_flash_vdm(int port, int cnt, uint32_t *payload) #ifdef CONFIG_USB_PD_DISCHARGE void pd_set_vbus_discharge(int port, int enable) { - static struct mutex discharge_lock[CONFIG_USB_PD_PORT_COUNT]; + static struct mutex discharge_lock[CONFIG_USB_PD_PORT_MAX_COUNT]; mutex_lock(&discharge_lock[port]); enable &= !board_vbus_source_enabled(port); #ifdef CONFIG_USB_PD_DISCHARGE_GPIO if (!port) gpio_set_level(GPIO_USB_C0_DISCHARGE, enable); -#if CONFIG_USB_PD_PORT_COUNT > 1 +#if CONFIG_USB_PD_PORT_MAX_COUNT > 1 else gpio_set_level(GPIO_USB_C1_DISCHARGE, enable); -#endif /* CONFIG_USB_PD_PORT_COUNT */ +#endif /* CONFIG_USB_PD_PORT_MAX_COUNT */ #elif defined(CONFIG_USB_PD_DISCHARGE_TCPC) tcpc_discharge_vbus(port, enable); #elif defined(CONFIG_USB_PD_DISCHARGE_PPC) diff --git a/common/usb_pd_protocol.c b/common/usb_pd_protocol.c index a08027ad5e..5d5df2d4e5 100644 --- a/common/usb_pd_protocol.c +++ b/common/usb_pd_protocol.c @@ -36,7 +36,7 @@ #define CPRINTF(format, args...) cprintf(CC_USBPD, format, ## args) #define CPRINTS(format, args...) cprints(CC_USBPD, format, ## args) -BUILD_ASSERT(CONFIG_USB_PD_PORT_COUNT <= EC_USB_PD_MAX_PORTS); +BUILD_ASSERT(CONFIG_USB_PD_PORT_MAX_COUNT <= EC_USB_PD_MAX_PORTS); /* * If we are trying to upgrade the TCPC port that is supplying power, then we @@ -69,7 +69,7 @@ static int debug_level; * detects source/sink connection and disconnection, and will still * provide VBUS, but never sends any PD communication. */ -static uint8_t pd_comm_enabled[CONFIG_USB_PD_PORT_COUNT]; +static uint8_t pd_comm_enabled[CONFIG_USB_PD_PORT_MAX_COUNT]; #else /* CONFIG_COMMON_RUNTIME */ #define CPRINTF(format, args...) #define CPRINTS(format, args...) @@ -125,8 +125,8 @@ enum vdm_states { #ifdef CONFIG_USB_PD_DUAL_ROLE /* Port dual-role state */ -enum pd_dual_role_states drp_state[CONFIG_USB_PD_PORT_COUNT] = { - [0 ... (CONFIG_USB_PD_PORT_COUNT - 1)] = +enum pd_dual_role_states drp_state[CONFIG_USB_PD_PORT_MAX_COUNT] = { + [0 ... (CONFIG_USB_PD_PORT_MAX_COUNT - 1)] = CONFIG_USB_PD_INITIAL_DRP_STATE}; /* Enable variable for Try.SRC states */ @@ -272,7 +272,7 @@ static struct pd_protocol { * When we can give up on a HARD_RESET transmission. */ uint64_t hard_reset_complete_timer; -} pd[CONFIG_USB_PD_PORT_COUNT]; +} pd[CONFIG_USB_PD_PORT_MAX_COUNT]; #ifdef CONFIG_COMMON_RUNTIME static const char * const pd_state_names[] = { @@ -851,11 +851,11 @@ static inline void set_state(int port, enum pd_states next_state) #ifdef CONFIG_LOW_POWER_IDLE /* If a PD device is attached then disable deep sleep */ - for (i = 0; i < CONFIG_USB_PD_PORT_COUNT; i++) { + for (i = 0; i < CONFIG_USB_PD_PORT_MAX_COUNT; i++) { if (pd_capable(i)) break; } - if (i == CONFIG_USB_PD_PORT_COUNT) + if (i == CONFIG_USB_PD_PORT_MAX_COUNT) enable_sleep(SLEEP_MASK_USB_PD); else disable_sleep(SLEEP_MASK_USB_PD); @@ -1477,7 +1477,7 @@ void pd_soft_reset(void) { int i; - for (i = 0; i < CONFIG_USB_PD_PORT_COUNT; ++i) + for (i = 0; i < CONFIG_USB_PD_PORT_MAX_COUNT; ++i) if (pd_is_connected(i)) { set_state(i, PD_STATE_SOFT_RESET); task_wake(PD_PORT_TO_TASK_ID(i)); @@ -2378,7 +2378,7 @@ static void pd_update_try_source(void) int batt_soc = usb_get_battery_soc(); try_src = 0; - for (i = 0; i < CONFIG_USB_PD_PORT_COUNT; i++) + for (i = 0; i < CONFIG_USB_PD_PORT_MAX_COUNT; i++) try_src |= drp_state[i] == PD_DRP_TOGGLE_ON; /* @@ -2411,7 +2411,7 @@ static void pd_update_try_source(void) * mode went from enabled to disabled and trying_source * was active at that time. */ - for (i = 0; i < CONFIG_USB_PD_PORT_COUNT; i++) + for (i = 0; i < CONFIG_USB_PD_PORT_MAX_COUNT; i++) pd[i].flags &= ~PD_FLAGS_TRY_SRC; } #endif /* CONFIG_USB_PD_TRY_SRC */ @@ -2425,7 +2425,7 @@ static void pd_update_snk_reset(void) if (batt_soc < CONFIG_USB_PD_RESET_MIN_BATT_SOC) return; - for (i = 0; i < CONFIG_USB_PD_PORT_COUNT; i++) { + for (i = 0; i < CONFIG_USB_PD_PORT_MAX_COUNT; i++) { if (pd[i].flags & PD_FLAGS_SNK_WAITING_BATT) { /* * Battery has gained sufficient charge to kick off PD @@ -2669,7 +2669,7 @@ int pd_get_partner_data_swap_capable(int port) #ifdef CONFIG_COMMON_RUNTIME void pd_comm_enable(int port, int enable) { - /* We don't check port >= CONFIG_USB_PD_PORT_COUNT deliberately */ + /* We don't check port >= CONFIG_USB_PD_PORT_MAX_COUNT deliberately */ pd_comm_enabled[port] = enable; /* If type-C connection, then update the TCPC RX enable */ @@ -2734,13 +2734,13 @@ static void pd_init_tasks(void) #if defined(HAS_TASK_CHIPSET) && defined(CONFIG_USB_PD_DUAL_ROLE) /* Set dual-role state based on chipset power state */ if (chipset_in_state(CHIPSET_STATE_ANY_OFF)) - for (i = 0; i < CONFIG_USB_PD_PORT_COUNT; i++) + for (i = 0; i < CONFIG_USB_PD_PORT_MAX_COUNT; i++) drp_state[i] = PD_DRP_FORCE_SINK; else if (chipset_in_state(CHIPSET_STATE_ANY_SUSPEND)) - for (i = 0; i < CONFIG_USB_PD_PORT_COUNT; i++) + for (i = 0; i < CONFIG_USB_PD_PORT_MAX_COUNT; i++) drp_state[i] = PD_DRP_TOGGLE_OFF; else /* CHIPSET_STATE_ON */ - for (i = 0; i < CONFIG_USB_PD_PORT_COUNT; i++) + for (i = 0; i < CONFIG_USB_PD_PORT_MAX_COUNT; i++) drp_state[i] = PD_DRP_TOGGLE_ON; #endif @@ -2755,7 +2755,7 @@ static void pd_init_tasks(void) enable = 1; #endif #endif - for (i = 0; i < CONFIG_USB_PD_PORT_COUNT; i++) + for (i = 0; i < CONFIG_USB_PD_PORT_MAX_COUNT; i++) pd_comm_enabled[i] = enable; CPRINTS("PD comm %sabled", enable ? "en" : "dis"); @@ -2784,7 +2784,7 @@ static int pd_restart_tcpc(int port) /* Events for pd_interrupt_handler_task */ #define PD_PROCESS_INTERRUPT BIT(0) -static uint8_t pd_int_task_id[CONFIG_USB_PD_PORT_COUNT]; +static uint8_t pd_int_task_id[CONFIG_USB_PD_PORT_MAX_COUNT]; void schedule_deferred_pd_interrupt(const int port) { @@ -2812,9 +2812,9 @@ void pd_interrupt_handler_task(void *p) struct { int count; uint32_t time; - } storm_tracker[CONFIG_USB_PD_PORT_COUNT] = {}; + } storm_tracker[CONFIG_USB_PD_PORT_MAX_COUNT] = {}; - ASSERT(port >= 0 && port < CONFIG_USB_PD_PORT_COUNT); + ASSERT(port >= 0 && port < CONFIG_USB_PD_PORT_MAX_COUNT); pd_int_task_id[port] = task_get_current(); @@ -4735,7 +4735,7 @@ static void pd_chipset_resume(void) { int i; - for (i = 0; i < CONFIG_USB_PD_PORT_COUNT; i++) { + for (i = 0; i < CONFIG_USB_PD_PORT_MAX_COUNT; i++) { #ifdef CONFIG_CHARGE_MANAGER if (charge_manager_get_active_charge_port() != i) #endif @@ -4752,7 +4752,7 @@ static void pd_chipset_suspend(void) { int i; - for (i = 0; i < CONFIG_USB_PD_PORT_COUNT; i++) + for (i = 0; i < CONFIG_USB_PD_PORT_MAX_COUNT; i++) pd_set_dual_role(i, PD_DRP_TOGGLE_OFF); CPRINTS("PD:S0->S3"); } @@ -4762,7 +4762,7 @@ static void pd_chipset_startup(void) { int i; - for (i = 0; i < CONFIG_USB_PD_PORT_COUNT; i++) { + for (i = 0; i < CONFIG_USB_PD_PORT_MAX_COUNT; i++) { pd_set_dual_role_no_wakeup(i, PD_DRP_TOGGLE_OFF); pd[i].flags |= PD_FLAGS_CHECK_IDENTITY; /* Reset cable attributes and flags */ @@ -4780,7 +4780,7 @@ static void pd_chipset_shutdown(void) { int i; - for (i = 0; i < CONFIG_USB_PD_PORT_COUNT; i++) { + for (i = 0; i < CONFIG_USB_PD_PORT_MAX_COUNT; i++) { pd_set_dual_role_no_wakeup(i, PD_DRP_FORCE_SINK); task_set_event(PD_PORT_TO_TASK_ID(i), PD_EVENT_POWER_STATE_CHANGE | @@ -4799,7 +4799,7 @@ void pd_prepare_sysjump(void) int i; /* Exit modes before sysjump so we can cleanly enter again later */ - for (i = 0; i < CONFIG_USB_PD_PORT_COUNT; i++) { + for (i = 0; i < CONFIG_USB_PD_PORT_MAX_COUNT; i++) { /* * We can't be in an alternate mode if PD comm is disabled or * the port is suspended, so no need to send the event @@ -4922,13 +4922,13 @@ static int remote_flashing(int argc, char **argv) int port, cnt, cmd; uint32_t data[VDO_MAX_SIZE-1]; char *e; - static int flash_offset[CONFIG_USB_PD_PORT_COUNT]; + static int flash_offset[CONFIG_USB_PD_PORT_MAX_COUNT]; if (argc < 4 || argc > (VDO_MAX_SIZE + 4 - 1)) return EC_ERROR_PARAM_COUNT; port = strtoi(argv[1], &e, 10); - if (*e || port >= CONFIG_USB_PD_PORT_COUNT) + if (*e || port >= CONFIG_USB_PD_PORT_MAX_COUNT) return EC_ERROR_PARAM2; cnt = 0; @@ -5169,7 +5169,7 @@ static int command_pd(int argc, char **argv) port = strtoi(argv[1], &e, 10); if (argc < 3) return EC_ERROR_PARAM_COUNT; - if (*e || port >= CONFIG_USB_PD_PORT_COUNT) + if (*e || port >= CONFIG_USB_PD_PORT_MAX_COUNT) return EC_ERROR_PARAM2; #if defined(CONFIG_CMD_PD) && defined(CONFIG_USB_PD_DUAL_ROLE) @@ -5358,7 +5358,7 @@ DECLARE_CONSOLE_COMMAND(pd, command_pd, static enum ec_status hc_pd_ports(struct host_cmd_handler_args *args) { struct ec_response_usb_pd_ports *r = args->response; - r->num_ports = CONFIG_USB_PD_PORT_COUNT; + r->num_ports = CONFIG_USB_PD_PORT_MAX_COUNT; args->response_size = sizeof(*r); return EC_RES_SUCCESS; @@ -5399,7 +5399,7 @@ static enum ec_status hc_usb_pd_control(struct host_cmd_handler_args *args) struct ec_response_usb_pd_control_v1 *r_v1 = args->response; struct ec_response_usb_pd_control *r = args->response; - if (p->port >= CONFIG_USB_PD_PORT_COUNT) + if (p->port >= CONFIG_USB_PD_PORT_MAX_COUNT) return EC_RES_INVALID_PARAM; if (p->role >= USB_PD_CTRL_ROLE_COUNT || @@ -5499,7 +5499,7 @@ static enum ec_status hc_remote_flash(struct host_cmd_handler_args *args) int i, size, rv = EC_RES_SUCCESS; timestamp_t timeout; - if (port >= CONFIG_USB_PD_PORT_COUNT) + if (port >= CONFIG_USB_PD_PORT_MAX_COUNT) return EC_RES_INVALID_PARAM; if (p->size + sizeof(*p) > args->params_size) @@ -5628,7 +5628,7 @@ static enum ec_status hc_remote_pd_dev_info(struct host_cmd_handler_args *args) const uint8_t *port = args->params; struct ec_params_usb_pd_rw_hash_entry *r = args->response; - if (*port >= CONFIG_USB_PD_PORT_COUNT) + if (*port >= CONFIG_USB_PD_PORT_MAX_COUNT) return EC_RES_INVALID_PARAM; r->dev_id = pd[*port].dev_id; @@ -5654,7 +5654,7 @@ static enum ec_status hc_remote_pd_chip_info(struct host_cmd_handler_args *args) const struct ec_params_pd_chip_info *p = args->params; struct ec_response_pd_chip_info_v1 *info; - if (p->port >= CONFIG_USB_PD_PORT_COUNT) + if (p->port >= CONFIG_USB_PD_PORT_MAX_COUNT) return EC_RES_INVALID_PARAM; if (tcpm_get_chip_info(p->port, p->live, &info)) @@ -5683,7 +5683,8 @@ static enum ec_status hc_remote_pd_set_amode(struct host_cmd_handler_args *args) { const struct ec_params_usb_pd_set_mode_request *p = args->params; - if ((p->port >= CONFIG_USB_PD_PORT_COUNT) || (!p->svid) || (!p->opos)) + if ((p->port >= CONFIG_USB_PD_PORT_MAX_COUNT) || + (!p->svid) || (!p->opos)) return EC_RES_INVALID_PARAM; switch (p->cmd) { @@ -5717,11 +5718,11 @@ DECLARE_HOST_COMMAND(EC_CMD_USB_PD_SET_AMODE, static enum ec_status pd_control(struct host_cmd_handler_args *args) { - static int pd_control_disabled[CONFIG_USB_PD_PORT_COUNT]; + static int pd_control_disabled[CONFIG_USB_PD_PORT_MAX_COUNT]; const struct ec_params_pd_control *cmd = args->params; int enable = 0; - if (cmd->chip >= CONFIG_USB_PD_PORT_COUNT) + if (cmd->chip >= CONFIG_USB_PD_PORT_MAX_COUNT) return EC_RES_INVALID_PARAM; /* Always allow disable command */ diff --git a/common/usb_pd_tcpc.c b/common/usb_pd_tcpc.c index 5decbb0dec..44c6d58a96 100644 --- a/common/usb_pd_tcpc.c +++ b/common/usb_pd_tcpc.c @@ -263,7 +263,7 @@ static struct pd_port_controller { uint16_t tx_head; uint32_t tx_payload[7]; const uint32_t *tx_data; -} pd[CONFIG_USB_PD_PORT_COUNT]; +} pd[CONFIG_USB_PD_PORT_MAX_COUNT]; static int rx_buf_is_full(int port) { @@ -1111,11 +1111,11 @@ int tcpc_set_rx_enable(int port, int enable) #if defined(CONFIG_LOW_POWER_IDLE) && !defined(CONFIG_USB_POWER_DELIVERY) /* If any PD port is connected, then disable deep sleep */ - for (i = 0; i < CONFIG_USB_PD_PORT_COUNT; ++i) + for (i = 0; i < CONFIG_USB_PD_PORT_MAX_COUNT; ++i) if (pd[i].rx_enabled) break; - if (i == CONFIG_USB_PD_PORT_COUNT) + if (i == CONFIG_USB_PD_PORT_MAX_COUNT) enable_sleep(SLEEP_MASK_USB_PD); else disable_sleep(SLEEP_MASK_USB_PD); @@ -1163,7 +1163,7 @@ void tcpc_pre_init(void) int i; /* Mark as uninitialized */ - for (i = 0; i < CONFIG_USB_PD_PORT_COUNT; i++) + for (i = 0; i < CONFIG_USB_PD_PORT_MAX_COUNT; i++) pd[i].power_status |= TCPC_REG_POWER_STATUS_UNINIT | TCPC_REG_POWER_STATUS_VBUS_DET; } @@ -1194,13 +1194,13 @@ void tcpc_init(int port) } #ifdef CONFIG_USB_PD_TCPC_TRACK_VBUS -#if CONFIG_USB_PD_PORT_COUNT >= 2 +#if CONFIG_USB_PD_PORT_MAX_COUNT >= 2 tcpc_set_power_status(port, !gpio_get_level(port ? GPIO_USB_C1_VBUS_WAKE_L : GPIO_USB_C0_VBUS_WAKE_L)); #else tcpc_set_power_status(port, !gpio_get_level(GPIO_USB_C0_VBUS_WAKE_L)); -#endif /* CONFIG_USB_PD_PORT_COUNT >= 2 */ +#endif /* CONFIG_USB_PD_PORT_MAX_COUNT >= 2 */ #endif /* CONFIG_USB_PD_TCPC_TRACK_VBUS */ /* set default alert and power mask register values */ @@ -1219,7 +1219,7 @@ void pd_vbus_evt_p0(enum gpio_signal signal) task_wake(TASK_ID_PD_C0); } -#if CONFIG_USB_PD_PORT_COUNT >= 2 +#if CONFIG_USB_PD_PORT_MAX_COUNT >= 2 void pd_vbus_evt_p1(enum gpio_signal signal) { tcpc_set_power_status(TASK_ID_TO_PD_PORT(TASK_ID_PD_C1), @@ -1423,7 +1423,7 @@ static int command_tcpc(int argc, char **argv) port = strtoi(argv[1], &e, 10); if (argc < 3) return EC_ERROR_PARAM_COUNT; - if (*e || port >= CONFIG_USB_PD_PORT_COUNT) + if (*e || port >= CONFIG_USB_PD_PORT_MAX_COUNT) return EC_ERROR_PARAM2; if (!strcasecmp(argv[2], "clock")) { diff --git a/common/usbc/usb_pe_ctvpd_sm.c b/common/usbc/usb_pe_ctvpd_sm.c index 4f18ed774e..5fe7a6b5a3 100644 --- a/common/usbc/usb_pe_ctvpd_sm.c +++ b/common/usbc/usb_pe_ctvpd_sm.c @@ -29,7 +29,7 @@ static struct policy_engine { struct sm_ctx ctx; /* port flags, see PE_FLAGS_* */ uint32_t flags; -} pe[CONFIG_USB_PD_PORT_COUNT]; +} pe[CONFIG_USB_PD_PORT_MAX_COUNT]; /* List of all policy-engine-level states */ enum usb_pe_state { @@ -55,7 +55,7 @@ static void pe_init(int port) void pe_run(int port, int evt, int en) { - static enum sm_local_state local_state[CONFIG_USB_PD_PORT_COUNT]; + static enum sm_local_state local_state[CONFIG_USB_PD_PORT_MAX_COUNT]; switch (local_state[port]) { case SM_PAUSED: diff --git a/common/usbc/usb_pe_drp_sm.c b/common/usbc/usb_pe_drp_sm.c index 15d6c7b356..c6d528516f 100644 --- a/common/usbc/usb_pe_drp_sm.c +++ b/common/usbc/usb_pe_drp_sm.c @@ -251,7 +251,7 @@ enum sub_state { PE_SUB2 }; -static enum sm_local_state local_state[CONFIG_USB_PD_PORT_COUNT]; +static enum sm_local_state local_state[CONFIG_USB_PD_PORT_MAX_COUNT]; /* * Policy Engine State Machine Object @@ -415,7 +415,7 @@ static struct policy_engine { uint32_t src_caps[PDO_MAX_OBJECTS]; int src_cap_cnt; -} pe[CONFIG_USB_PD_PORT_COUNT]; +} pe[CONFIG_USB_PD_PORT_MAX_COUNT]; /* * As a sink, this is the max voltage (in millivolts) we can request @@ -4395,19 +4395,19 @@ int pd_charge_from_device(uint16_t vid, uint16_t pid) #ifdef CONFIG_USB_PD_DISCHARGE void pd_set_vbus_discharge(int port, int enable) { - static struct mutex discharge_lock[CONFIG_USB_PD_PORT_COUNT]; + static struct mutex discharge_lock[CONFIG_USB_PD_PORT_MAX_COUNT]; mutex_lock(&discharge_lock[port]); enable &= !board_vbus_source_enabled(port); #ifdef CONFIG_USB_PD_DISCHARGE_GPIO -#if CONFIG_USB_PD_PORT_COUNT == 0 +#if CONFIG_USB_PD_PORT_MAX_COUNT == 0 gpio_set_level(GPIO_USB_C0_DISCHARGE, enable); -#elif CONFIG_USB_PD_PORT_COUNT == 1 +#elif CONFIG_USB_PD_PORT_MAX_COUNT == 1 gpio_set_level(GPIO_USB_C1_DISCHARGE, enable); -#elif CONFIG_USB_PD_PORT_COUNT == 2 +#elif CONFIG_USB_PD_PORT_MAX_COUNT == 2 gpio_set_level(GPIO_USB_C2_DISCHARGE, enable); -#elif CONFIG_USB_PD_PORT_COUNT == 3 +#elif CONFIG_USB_PD_PORT_MAX_COUNT == 3 gpio_set_level(GPIO_USB_C3_DISCHARGE, enable); #endif #else @@ -4838,7 +4838,7 @@ static int command_pe(int argc, char **argv) /* command: pe <port> <subcmd> <args> */ port = strtoi(argv[1], &e, 10); - if (*e || port >= CONFIG_USB_PD_PORT_COUNT) + if (*e || port >= CONFIG_USB_PD_PORT_MAX_COUNT) return EC_ERROR_PARAM2; if (!strncasecmp(argv[2], "dump", 4)) dump_pe(port); @@ -4856,7 +4856,7 @@ static enum ec_status hc_remote_pd_discovery(struct host_cmd_handler_args *args) const uint8_t *port = args->params; struct ec_params_usb_pd_discovery_entry *r = args->response; - if (*port >= CONFIG_USB_PD_PORT_COUNT) + if (*port >= CONFIG_USB_PD_PORT_MAX_COUNT) return EC_RES_INVALID_PARAM; r->vid = pd_get_identity_vid(*port); @@ -4879,7 +4879,7 @@ static enum ec_status hc_remote_pd_get_amode(struct host_cmd_handler_args *args) const struct ec_params_usb_pd_get_mode_request *p = args->params; struct ec_params_usb_pd_get_mode_response *r = args->response; - if (p->port >= CONFIG_USB_PD_PORT_COUNT) + if (p->port >= CONFIG_USB_PD_PORT_MAX_COUNT) return EC_RES_INVALID_PARAM; /* no more to send */ diff --git a/common/usbc/usb_prl_sm.c b/common/usbc/usb_prl_sm.c index e95f2a3c9e..c92faec8ac 100644 --- a/common/usbc/usb_prl_sm.c +++ b/common/usbc/usb_prl_sm.c @@ -68,7 +68,7 @@ /* PD counter definitions */ #define PD_MESSAGE_ID_COUNT 7 -static enum sm_local_state local_state[CONFIG_USB_PD_PORT_COUNT]; +static enum sm_local_state local_state[CONFIG_USB_PD_PORT_MAX_COUNT]; /* Protocol Transmit States (Section 6.11.2.2) */ enum usb_prl_tx_state { @@ -128,7 +128,7 @@ static struct rx_chunked { uint32_t flags; /* protocol timer */ uint64_t chunk_sender_response_timer; -} rch[CONFIG_USB_PD_PORT_COUNT]; +} rch[CONFIG_USB_PD_PORT_MAX_COUNT]; /* Chunked Tx State Machine Object */ static struct tx_chunked { @@ -140,13 +140,13 @@ static struct tx_chunked { uint64_t chunk_sender_request_timer; /* error to report when moving to tch_report_error state */ enum pe_error error; -} tch[CONFIG_USB_PD_PORT_COUNT]; +} tch[CONFIG_USB_PD_PORT_MAX_COUNT]; /* Message Reception State Machine Object */ static struct protocol_layer_rx { /* message ids for all valid port partners */ int msg_id[NUM_SOP_STAR_TYPES]; -} prl_rx[CONFIG_USB_PD_PORT_COUNT]; +} prl_rx[CONFIG_USB_PD_PORT_MAX_COUNT]; /* Message Transmission State Machine Object */ static struct protocol_layer_tx { @@ -166,7 +166,7 @@ static struct protocol_layer_tx { uint32_t retry_counter; /* transmit status */ int xmit_status; -} prl_tx[CONFIG_USB_PD_PORT_COUNT]; +} prl_tx[CONFIG_USB_PD_PORT_MAX_COUNT]; /* Hard Reset State Machine Object */ static struct protocol_hard_reset { @@ -176,7 +176,7 @@ static struct protocol_hard_reset { uint32_t flags; /* protocol timer */ uint64_t hard_reset_complete_timer; -} prl_hr[CONFIG_USB_PD_PORT_COUNT]; +} prl_hr[CONFIG_USB_PD_PORT_MAX_COUNT]; /* Chunking Message Object */ static struct pd_message { @@ -200,9 +200,9 @@ static struct pd_message { uint32_t num_bytes_received; uint32_t chunk_number_to_send; uint32_t send_offset; -} pdmsg[CONFIG_USB_PD_PORT_COUNT]; +} pdmsg[CONFIG_USB_PD_PORT_MAX_COUNT]; -struct extended_msg emsg[CONFIG_USB_PD_PORT_COUNT]; +struct extended_msg emsg[CONFIG_USB_PD_PORT_MAX_COUNT]; /* Common Protocol Layer Message Transmission */ static void prl_tx_construct_message(int port); diff --git a/common/usbc/usb_tc_ctvpd_sm.c b/common/usbc/usb_tc_ctvpd_sm.c index c935be380f..996b38b6fb 100644 --- a/common/usbc/usb_tc_ctvpd_sm.c +++ b/common/usbc/usb_tc_ctvpd_sm.c @@ -72,7 +72,7 @@ static struct type_c { /* The cc state */ enum pd_cc_states cc_state; uint64_t next_role_swap; -} tc[CONFIG_USB_PD_PORT_COUNT]; +} tc[CONFIG_USB_PD_PORT_MAX_COUNT]; /* List of all TypeC-level states */ enum usb_tc_state { diff --git a/common/usbc/usb_tc_drp_acc_trysrc_sm.c b/common/usbc/usb_tc_drp_acc_trysrc_sm.c index 2423855c8f..2accd67d6e 100644 --- a/common/usbc/usb_tc_drp_acc_trysrc_sm.c +++ b/common/usbc/usb_tc_drp_acc_trysrc_sm.c @@ -159,12 +159,12 @@ static struct type_c { uint16_t dev_id; uint32_t dev_rw_hash[PD_RW_HASH_SIZE/4]; enum ec_current_image current_image; -} tc[CONFIG_USB_PD_PORT_COUNT]; +} tc[CONFIG_USB_PD_PORT_MAX_COUNT]; /* Port dual-role state */ static __maybe_unused -enum pd_dual_role_states drp_state[CONFIG_USB_PD_PORT_COUNT] = { - [0 ... (CONFIG_USB_PD_PORT_COUNT - 1)] = +enum pd_dual_role_states drp_state[CONFIG_USB_PD_PORT_MAX_COUNT] = { + [0 ... (CONFIG_USB_PD_PORT_MAX_COUNT - 1)] = CONFIG_USB_PD_INITIAL_DRP_STATE}; #ifdef CONFIG_USBC_VCONN @@ -602,7 +602,7 @@ void pd_prepare_sysjump(void) * Exit modes before sysjump so we can cleanly enter again * later */ - for (i = 0; i < CONFIG_USB_PD_PORT_COUNT; i++) { + for (i = 0; i < CONFIG_USB_PD_PORT_MAX_COUNT; i++) { /* * We can't be in an alternate mode if PD comm is * disabled, so no need to send the event @@ -832,7 +832,7 @@ static void pd_update_try_source(void) int batt_soc = usb_get_battery_soc(); try_src = 0; - for (i = 0; i < CONFIG_USB_PD_PORT_COUNT; i++) + for (i = 0; i < CONFIG_USB_PD_PORT_MAX_COUNT; i++) try_src |= drp_state[i] == PD_DRP_TOGGLE_ON; /* @@ -977,7 +977,7 @@ static enum ec_status hc_pd_ports(struct host_cmd_handler_args *args) { struct ec_response_usb_pd_ports *r = args->response; - r->num_ports = CONFIG_USB_PD_PORT_COUNT; + r->num_ports = CONFIG_USB_PD_PORT_MAX_COUNT; args->response_size = sizeof(*r); return EC_RES_SUCCESS; @@ -1018,7 +1018,7 @@ static enum ec_status hc_usb_pd_control(struct host_cmd_handler_args *args) struct ec_response_usb_pd_control_v2 *r_v2 = args->response; struct ec_response_usb_pd_control *r = args->response; - if (p->port >= CONFIG_USB_PD_PORT_COUNT) + if (p->port >= CONFIG_USB_PD_PORT_MAX_COUNT) return EC_RES_INVALID_PARAM; if (p->role >= USB_PD_CTRL_ROLE_COUNT || @@ -1113,7 +1113,7 @@ static enum ec_status hc_remote_flash(struct host_cmd_handler_args *args) const uint32_t *data = &(p->size) + 1; int i, size; - if (port >= CONFIG_USB_PD_PORT_COUNT) + if (port >= CONFIG_USB_PD_PORT_MAX_COUNT) return EC_RES_INVALID_PARAM; if (p->size + sizeof(*p) > args->params_size) @@ -1210,7 +1210,7 @@ static enum ec_status hc_remote_pd_dev_info(struct host_cmd_handler_args *args) const uint8_t *port = args->params; struct ec_params_usb_pd_rw_hash_entry *r = args->response; - if (*port >= CONFIG_USB_PD_PORT_COUNT) + if (*port >= CONFIG_USB_PD_PORT_MAX_COUNT) return EC_RES_INVALID_PARAM; r->dev_id = tc[*port].dev_id; @@ -1235,7 +1235,7 @@ static enum ec_status hc_remote_pd_chip_info(struct host_cmd_handler_args *args) const struct ec_params_pd_chip_info *p = args->params; struct ec_response_pd_chip_info_v1 *info; - if (p->port >= CONFIG_USB_PD_PORT_COUNT) + if (p->port >= CONFIG_USB_PD_PORT_MAX_COUNT) return EC_RES_INVALID_PARAM; if (tcpm_get_chip_info(p->port, p->live, &info)) @@ -1281,7 +1281,8 @@ static enum ec_status hc_remote_pd_set_amode(struct host_cmd_handler_args *args) { const struct ec_params_usb_pd_set_mode_request *p = args->params; - if ((p->port >= CONFIG_USB_PD_PORT_COUNT) || (!p->svid) || (!p->opos)) + if ((p->port >= CONFIG_USB_PD_PORT_MAX_COUNT) || + (!p->svid) || (!p->opos)) return EC_RES_INVALID_PARAM; switch (p->cmd) { diff --git a/common/usbc/usb_tc_vpd_sm.c b/common/usbc/usb_tc_vpd_sm.c index dedba97513..8dfed4226b 100644 --- a/common/usbc/usb_tc_vpd_sm.c +++ b/common/usbc/usb_tc_vpd_sm.c @@ -42,7 +42,7 @@ static struct type_c { /* VPD host port cc state */ enum pd_cc_states host_cc_state; uint8_t ct_cc; -} tc[CONFIG_USB_PD_PORT_COUNT]; +} tc[CONFIG_USB_PD_PORT_MAX_COUNT]; /* List of all TypeC-level states */ enum usb_tc_state { diff --git a/common/usbc/usbc_task.c b/common/usbc/usbc_task.c index 48c53af3d2..86f1bcc12d 100644 --- a/common/usbc/usbc_task.c +++ b/common/usbc/usbc_task.c @@ -97,7 +97,7 @@ void set_usb_mux_with_current_data_role(int port) /* Events for pd_interrupt_handler_task */ #define PD_PROCESS_INTERRUPT (1<<0) -static uint8_t pd_int_task_id[CONFIG_USB_PD_PORT_COUNT]; +static uint8_t pd_int_task_id[CONFIG_USB_PD_PORT_MAX_COUNT]; void schedule_deferred_pd_interrupt(const int port) { @@ -115,7 +115,7 @@ void pd_interrupt_handler_task(void *p) const int port = (int) p; const int port_mask = (PD_STATUS_TCPC_ALERT_0 << port); - ASSERT(port >= 0 && port < CONFIG_USB_PD_PORT_COUNT); + ASSERT(port >= 0 && port < CONFIG_USB_PD_PORT_MAX_COUNT); pd_int_task_id[port] = task_get_current(); diff --git a/common/usbc_ppc.c b/common/usbc_ppc.c index 4274443a3d..816c53d06e 100644 --- a/common/usbc_ppc.c +++ b/common/usbc_ppc.c @@ -26,7 +26,7 @@ * occurred. This table is cleared after detecting a physical disconnect of the * sink. */ -static uint8_t oc_event_cnt_tbl[CONFIG_USB_PD_PORT_COUNT]; +static uint8_t oc_event_cnt_tbl[CONFIG_USB_PD_PORT_MAX_COUNT]; static uint32_t connected_ports; diff --git a/driver/bc12/max14637.c b/driver/bc12/max14637.c index 26156480be..ca06b26aeb 100644 --- a/driver/bc12/max14637.c +++ b/driver/bc12/max14637.c @@ -152,7 +152,7 @@ void usb_charger_task(void *u) const int port = (intptr_t)u; uint32_t evt; - ASSERT(port >= 0 && port < CONFIG_USB_PD_PORT_COUNT); + ASSERT(port >= 0 && port < CONFIG_USB_PD_PORT_MAX_COUNT); detect_or_power_down_ic(port); diff --git a/driver/bc12/max14637.h b/driver/bc12/max14637.h index 38e88b4ee2..789504b1eb 100644 --- a/driver/bc12/max14637.h +++ b/driver/bc12/max14637.h @@ -28,4 +28,5 @@ struct max14637_config_t { /* * Array that contains boards-specific configuration for BC 1.2 charging chips. */ -extern const struct max14637_config_t max14637_config[CONFIG_USB_PD_PORT_COUNT]; +extern const struct max14637_config_t + max14637_config[CONFIG_USB_PD_PORT_MAX_COUNT]; diff --git a/driver/bc12/pi3usb9201.c b/driver/bc12/pi3usb9201.c index 0facefdced..be2844e3e3 100644 --- a/driver/bc12/pi3usb9201.c +++ b/driver/bc12/pi3usb9201.c @@ -38,7 +38,7 @@ struct bc12_status { }; /* Used to store last BC1.2 detection result */ -static enum charge_supplier bc12_supplier[CONFIG_USB_PD_PORT_COUNT]; +static enum charge_supplier bc12_supplier[CONFIG_USB_PD_PORT_MAX_COUNT]; static const struct bc12_status bc12_chg_limits[] = { [CHG_OTHER] = {CHARGE_SUPPLIER_OTHER, 500}, @@ -244,7 +244,7 @@ void usb_charger_task(void *u) * Set most recent bc1.2 detection supplier result to * CHARGE_SUPPLIER_NONE for all ports. */ - for (i = 0; i < CONFIG_USB_PD_PORT_COUNT; i++) + for (i = 0; i < CONFIG_USB_PD_PORT_MAX_COUNT; i++) bc12_supplier[port] = CHARGE_SUPPLIER_NONE; /* diff --git a/driver/bc12/pi3usb9281.c b/driver/bc12/pi3usb9281.c index b0610f693b..db5d039fd9 100644 --- a/driver/bc12/pi3usb9281.c +++ b/driver/bc12/pi3usb9281.c @@ -36,7 +36,7 @@ #define PI3USB9281_RESET_STARTUP_DELAY_INTERVAL_MS 40 /* Store the state of our USB data switches so that they can be restored. */ -static int usb_switch_state[CONFIG_USB_PD_PORT_COUNT]; +static int usb_switch_state[CONFIG_USB_PD_PORT_MAX_COUNT]; static int pi3usb9281_reset(int port); static int pi3usb9281_get_interrupts(int port); diff --git a/driver/charger/bd9995x.c b/driver/charger/bd9995x.c index f121b858dd..dc3125928f 100644 --- a/driver/charger/bd9995x.c +++ b/driver/charger/bd9995x.c @@ -345,7 +345,7 @@ static int bd9995x_get_charger_op_status(int *status) } #ifdef HAS_TASK_USB_CHG -static int bc12_detected_type[CONFIG_USB_PD_PORT_COUNT]; +static int bc12_detected_type[CONFIG_USB_PD_PORT_MAX_COUNT]; /* Mutex for UCD_SET regsiters, lock before read / mask / write. */ static struct mutex ucd_set_mutex[BD9995X_CHARGE_PORT_COUNT]; @@ -1263,7 +1263,7 @@ void usb_charger_task(void *u) static int initialized; int changed, port, interrupts; int sleep_usec; - uint64_t bc12_det_mark[CONFIG_USB_PD_PORT_COUNT]; + uint64_t bc12_det_mark[CONFIG_USB_PD_PORT_MAX_COUNT]; #ifdef CONFIG_USB_PD_DISCHARGE int vbus_reg, voltage; #endif @@ -1273,7 +1273,7 @@ void usb_charger_task(void *u) vbus_voltage = 0; #endif - for (port = 0; port < CONFIG_USB_PD_PORT_COUNT; port++) { + for (port = 0; port < CONFIG_USB_PD_PORT_MAX_COUNT; port++) { bc12_detected_type[port] = CHARGE_SUPPLIER_NONE; bd9995x_enable_vbus_detect_interrupts(port, 1); bc12_det_mark[port] = 0; @@ -1282,7 +1282,7 @@ void usb_charger_task(void *u) while (1) { sleep_usec = -1; changed = 0; - for (port = 0; port < CONFIG_USB_PD_PORT_COUNT; port++) { + for (port = 0; port < CONFIG_USB_PD_PORT_MAX_COUNT; port++) { /* Get port interrupts */ interrupts = bd9995x_get_interrupts(port); if (interrupts & BD9995X_CMD_INT_VBUS_DET || diff --git a/driver/ppc/aoz1380.c b/driver/ppc/aoz1380.c index 8ac81daed3..f077a5e07d 100644 --- a/driver/ppc/aoz1380.c +++ b/driver/ppc/aoz1380.c @@ -27,7 +27,7 @@ static uint32_t irq_pending; /* Bitmask of ports signaling an interrupt. */ #define AOZ1380_FLAGS_SOURCE_ENABLED BIT(0) -static uint8_t flags[CONFIG_USB_PD_PORT_COUNT]; +static uint8_t flags[CONFIG_USB_PD_PORT_MAX_COUNT]; static int aoz1380_init(int port) { @@ -93,7 +93,7 @@ static void aoz1380_irq_deferred(void) int i; uint32_t pending = atomic_read_clear(&irq_pending); - for (i = 0; i < CONFIG_USB_PD_PORT_COUNT; i++) + for (i = 0; i < CONFIG_USB_PD_PORT_MAX_COUNT; i++) if (BIT(i) & pending) aoz1380_handle_interrupt(i); } diff --git a/driver/ppc/nx20p348x.c b/driver/ppc/nx20p348x.c index d7596d5c37..bdbd02d6b2 100644 --- a/driver/ppc/nx20p348x.c +++ b/driver/ppc/nx20p348x.c @@ -25,10 +25,10 @@ static uint32_t irq_pending; /* Bitmask of ports signaling an interrupt. */ #define NX20P348X_DB_EXIT_FAIL_THRESHOLD 10 -static int db_exit_fail_count[CONFIG_USB_PD_PORT_COUNT]; +static int db_exit_fail_count[CONFIG_USB_PD_PORT_MAX_COUNT]; #define NX20P348X_FLAGS_SOURCE_ENABLED BIT(0) -static uint8_t flags[CONFIG_USB_PD_PORT_COUNT]; +static uint8_t flags[CONFIG_USB_PD_PORT_MAX_COUNT]; static int read_reg(uint8_t port, int reg, int *regval) { @@ -384,7 +384,7 @@ static void nx20p348x_irq_deferred(void) int i; uint32_t pending = atomic_read_clear(&irq_pending); - for (i = 0; i < CONFIG_USB_PD_PORT_COUNT; i++) + for (i = 0; i < CONFIG_USB_PD_PORT_MAX_COUNT; i++) if (BIT(i) & pending) nx20p348x_handle_interrupt(i); } diff --git a/driver/ppc/sn5s330.c b/driver/ppc/sn5s330.c index 3f3423b058..6a877b0808 100644 --- a/driver/ppc/sn5s330.c +++ b/driver/ppc/sn5s330.c @@ -27,7 +27,7 @@ #define CPRINTS(format, args...) cprints(CC_USBPD, format, ## args) static uint32_t irq_pending; /* Bitmask of ports signaling an interrupt. */ -static int source_enabled[CONFIG_USB_PD_PORT_COUNT]; +static int source_enabled[CONFIG_USB_PD_PORT_MAX_COUNT]; static int read_reg(uint8_t port, int reg, int *regval) { @@ -750,7 +750,7 @@ static void sn5s330_irq_deferred(void) int i; uint32_t pending = atomic_read_clear(&irq_pending); - for (i = 0; i < CONFIG_USB_PD_PORT_COUNT; i++) + for (i = 0; i < CONFIG_USB_PD_PORT_MAX_COUNT; i++) if (BIT(i) & pending) sn5s330_handle_interrupt(i); } diff --git a/driver/ppc/syv682x.c b/driver/ppc/syv682x.c index 5f80dd3d90..9e0ff28388 100644 --- a/driver/ppc/syv682x.c +++ b/driver/ppc/syv682x.c @@ -17,7 +17,7 @@ /* 0 -> CC1, 1 -> CC2 */ #define SYV682X_FLAGS_CC_POLARITY BIT(1) #define SYV682X_FLAGS_VBUS_PRESENT BIT(2) -static uint8_t flags[CONFIG_USB_PD_PORT_COUNT]; +static uint8_t flags[CONFIG_USB_PD_PORT_MAX_COUNT]; #define SYV682X_VBUS_DET_THRESH_MV 4000 diff --git a/driver/retimer/bb_retimer.c b/driver/retimer/bb_retimer.c index c89ae925f3..e211c10d58 100644 --- a/driver/retimer/bb_retimer.c +++ b/driver/retimer/bb_retimer.c @@ -235,7 +235,7 @@ static int console_command_bb_retimer(int argc, char **argv) /* Get port number */ port = strtoi(argv[1], &e, 0); - if (*e || port < 0 || port > CONFIG_USB_PD_PORT_COUNT) + if (*e || port < 0 || port > CONFIG_USB_PD_PORT_MAX_COUNT) return EC_ERROR_PARAM1; /* Validate r/w selection */ diff --git a/driver/tcpm/anx7447.c b/driver/tcpm/anx7447.c index 59f8e59bfa..0af495251c 100644 --- a/driver/tcpm/anx7447.c +++ b/driver/tcpm/anx7447.c @@ -50,8 +50,8 @@ struct anx_usb_mux { static int anx7447_mux_set(int port, mux_state_t mux_state); -static struct anx_state anx[CONFIG_USB_PD_PORT_COUNT]; -static struct anx_usb_mux mux[CONFIG_USB_PD_PORT_COUNT]; +static struct anx_state anx[CONFIG_USB_PD_PORT_MAX_COUNT]; +static struct anx_usb_mux mux[CONFIG_USB_PD_PORT_MAX_COUNT]; /* * ANX7447 has two co-existence I2C slave addresses, TCPC slave address and @@ -286,7 +286,7 @@ static int anx7447_init(int port) { int rv, reg, i; - ASSERT(port < CONFIG_USB_PD_PORT_COUNT); + ASSERT(port < CONFIG_USB_PD_PORT_MAX_COUNT); memset(&anx[port], 0, sizeof(struct anx_state)); @@ -451,7 +451,7 @@ static void anx7447_tcpc_alert(int port) * timestamp of the next possible toggle to ensure the 2-ms spacing * between IRQ_HPD. */ -static uint64_t hpd_deadline[CONFIG_USB_PD_PORT_COUNT]; +static uint64_t hpd_deadline[CONFIG_USB_PD_PORT_MAX_COUNT]; void anx7447_tcpc_update_hpd_status(int port, int hpd_lvl, int hpd_irq) { @@ -494,7 +494,7 @@ void anx7447_tcpc_clear_hpd_status(int port) #ifdef CONFIG_USB_PD_TCPM_MUX static int anx7447_mux_init(int port) { - ASSERT(port < CONFIG_USB_PD_PORT_COUNT); + ASSERT(port < CONFIG_USB_PD_PORT_MAX_COUNT); memset(&mux[port], 0, sizeof(struct anx_usb_mux)); diff --git a/driver/tcpm/anx74xx.c b/driver/tcpm/anx74xx.c index 36c29f0701..0e7ec021d8 100644 --- a/driver/tcpm/anx74xx.c +++ b/driver/tcpm/anx74xx.c @@ -43,14 +43,14 @@ struct anx_state { reg | 0x01); \ } while (0) -static struct anx_state anx[CONFIG_USB_PD_PORT_COUNT]; +static struct anx_state anx[CONFIG_USB_PD_PORT_MAX_COUNT]; /* Save the selected rp value */ -static int selected_rp[CONFIG_USB_PD_PORT_COUNT]; +static int selected_rp[CONFIG_USB_PD_PORT_MAX_COUNT]; #ifdef CONFIG_USB_PD_DECODE_SOP /* Save the message address */ -static int msg_sop[CONFIG_USB_PD_PORT_COUNT]; +static int msg_sop[CONFIG_USB_PD_PORT_MAX_COUNT]; #endif static int anx74xx_tcpm_init(int port); @@ -227,7 +227,7 @@ static void anx74xx_tcpc_discharge_vbus(int port, int enable) * timestamp of the next possible toggle to ensure the 2-ms spacing * between IRQ_HPD. */ -static uint64_t hpd_deadline[CONFIG_USB_PD_PORT_COUNT]; +static uint64_t hpd_deadline[CONFIG_USB_PD_PORT_MAX_COUNT]; void anx74xx_tcpc_update_hpd_status(int port, int hpd_lvl, int hpd_irq) { diff --git a/driver/tcpm/fusb302.c b/driver/tcpm/fusb302.c index 3e85fbe713..66c131fb37 100644 --- a/driver/tcpm/fusb302.c +++ b/driver/tcpm/fusb302.c @@ -34,7 +34,7 @@ static struct fusb302_chip_state { int rx_enable; uint8_t mdac_vnc; uint8_t mdac_rd; -} state[CONFIG_USB_PD_PORT_COUNT]; +} state[CONFIG_USB_PD_PORT_MAX_COUNT]; /* * Bring the FUSB302 out of reset after Hard Reset signaling. This will diff --git a/driver/tcpm/it83xx.c b/driver/tcpm/it83xx.c index c805e445a2..4b2dc4fc6e 100644 --- a/driver/tcpm/it83xx.c +++ b/driver/tcpm/it83xx.c @@ -544,11 +544,11 @@ static int it83xx_tcpm_set_rx_enable(int port, int enable) } /* If any PD port is connected, then disable deep sleep */ - for (i = 0; i < CONFIG_USB_PD_PORT_COUNT; ++i) + for (i = 0; i < CONFIG_USB_PD_PORT_MAX_COUNT; ++i) if (IT83XX_USBPD_GCR(i) | USBPD_REG_MASK_BMC_PHY) break; - if (i == CONFIG_USB_PD_PORT_COUNT) + if (i == CONFIG_USB_PD_PORT_MAX_COUNT) enable_sleep(SLEEP_MASK_USB_PD); else disable_sleep(SLEEP_MASK_USB_PD); diff --git a/driver/tcpm/nct38xx.c b/driver/tcpm/nct38xx.c index 1196621e71..9d91c21b30 100644 --- a/driver/tcpm/nct38xx.c +++ b/driver/tcpm/nct38xx.c @@ -24,11 +24,11 @@ #define POLARITY_FLIPPED 1 #define POLARITY_NONE 3 -static int cable_polarity[CONFIG_USB_PD_PORT_COUNT]; +static int cable_polarity[CONFIG_USB_PD_PORT_MAX_COUNT]; static unsigned char txBuf[33]; static unsigned char rxBuf[33]; /* Save the selected rp value */ -static int selected_rp[CONFIG_USB_PD_PORT_COUNT]; +static int selected_rp[CONFIG_USB_PD_PORT_MAX_COUNT]; static int nct38xx_tcpm_init(int port) { diff --git a/driver/tcpm/ps8xxx.c b/driver/tcpm/ps8xxx.c index 9740933eeb..81117a5af1 100644 --- a/driver/tcpm/ps8xxx.c +++ b/driver/tcpm/ps8xxx.c @@ -36,7 +36,7 @@ * timestamp of the next possible toggle to ensure the 2-ms spacing * between IRQ_HPD. */ -static uint64_t hpd_deadline[CONFIG_USB_PD_PORT_COUNT]; +static uint64_t hpd_deadline[CONFIG_USB_PD_PORT_MAX_COUNT]; static int dp_set_hpd(int port, int enable) { diff --git a/driver/tcpm/tcpci.c b/driver/tcpm/tcpci.c index 2bb6a21c11..ba8e9f2f42 100644 --- a/driver/tcpm/tcpci.c +++ b/driver/tcpm/tcpci.c @@ -25,13 +25,13 @@ #define CPRINTS(format, args...) cprints(CC_USBPD, format, ## args) #ifdef CONFIG_USB_PD_DECODE_SOP -static int vconn_en[CONFIG_USB_PD_PORT_COUNT]; -static int rx_en[CONFIG_USB_PD_PORT_COUNT]; +static int vconn_en[CONFIG_USB_PD_PORT_MAX_COUNT]; +static int rx_en[CONFIG_USB_PD_PORT_MAX_COUNT]; #endif -static int tcpc_vbus[CONFIG_USB_PD_PORT_COUNT]; +static int tcpc_vbus[CONFIG_USB_PD_PORT_MAX_COUNT]; /* Save the selected rp value */ -static int selected_rp[CONFIG_USB_PD_PORT_COUNT]; +static int selected_rp[CONFIG_USB_PD_PORT_MAX_COUNT]; #ifdef CONFIG_USB_PD_TCPC_LOW_POWER @@ -483,7 +483,7 @@ struct queue { uint32_t tail; struct cached_tcpm_message buffer[CACHE_DEPTH]; }; -static struct queue cached_messages[CONFIG_USB_PD_PORT_COUNT]; +static struct queue cached_messages[CONFIG_USB_PD_PORT_MAX_COUNT]; /* Note this method can be called from an interrupt context. */ int tcpm_enqueue_message(const int port) @@ -739,12 +739,12 @@ int tcpci_get_chip_info(int port, int live, struct ec_response_pd_chip_info_v1 **chip_info) { static struct ec_response_pd_chip_info_v1 - info[CONFIG_USB_PD_PORT_COUNT]; + info[CONFIG_USB_PD_PORT_MAX_COUNT]; struct ec_response_pd_chip_info_v1 *i; int error; int val; - if (port >= CONFIG_USB_PD_PORT_COUNT) + if (port >= CONFIG_USB_PD_PORT_MAX_COUNT) return EC_ERROR_INVAL; i = &info[port]; diff --git a/driver/usb_mux/usb_mux.c b/driver/usb_mux/usb_mux.c index 122c206b98..0d08fbc99c 100644 --- a/driver/usb_mux/usb_mux.c +++ b/driver/usb_mux/usb_mux.c @@ -21,7 +21,7 @@ static int enable_debug_prints; * Flags will reset to 0 after sysjump; This works for current flags as LPM will * get reset in the init method which is called during PD task startup. */ -static uint8_t flags[CONFIG_USB_PD_PORT_COUNT]; +static uint8_t flags[CONFIG_USB_PD_PORT_MAX_COUNT]; #define USB_MUX_FLAG_IN_LPM BIT(0) /* Device is in low power mode. */ @@ -60,7 +60,7 @@ void usb_mux_init(int port) const struct usb_mux *mux = &usb_muxes[port]; int res; - ASSERT(port >= 0 && port < CONFIG_USB_PD_PORT_COUNT); + ASSERT(port >= 0 && port < CONFIG_USB_PD_PORT_MAX_COUNT); res = mux->driver->init(port); if (res) { @@ -195,7 +195,7 @@ static int command_typec(int argc, char **argv) return EC_ERROR_PARAM_COUNT; port = strtoi(argv[1], &e, 10); - if (*e || port >= CONFIG_USB_PD_PORT_COUNT) + if (*e || port >= CONFIG_USB_PD_PORT_MAX_COUNT) return EC_ERROR_PARAM1; if (argc < 3) { @@ -234,7 +234,7 @@ static enum ec_status hc_usb_pd_mux_info(struct host_cmd_handler_args *args) int port = p->port; const struct usb_mux *mux; - if (port >= CONFIG_USB_PD_PORT_COUNT) + if (port >= CONFIG_USB_PD_PORT_MAX_COUNT) return EC_RES_INVALID_PARAM; mux = &usb_muxes[port]; diff --git a/driver/usb_mux/virtual.c b/driver/usb_mux/virtual.c index e012b943f0..70a51953ad 100644 --- a/driver/usb_mux/virtual.c +++ b/driver/usb_mux/virtual.c @@ -22,7 +22,7 @@ USB_PD_MUX_DP_ENABLED | USB_PD_MUX_POLARITY_INVERTED | \ USB_PD_MUX_SAFE_MODE) -static mux_state_t virtual_mux_state[CONFIG_USB_PD_PORT_COUNT]; +static mux_state_t virtual_mux_state[CONFIG_USB_PD_PORT_MAX_COUNT]; static inline void virtual_mux_update_state(int port, mux_state_t mux_state) { diff --git a/fuzz/fuzz_config.h b/fuzz/fuzz_config.h index f4c325bd99..ba4d9c8458 100644 --- a/fuzz/fuzz_config.h +++ b/fuzz/fuzz_config.h @@ -109,14 +109,14 @@ enum nvmem_users { #ifdef TEST_USB_PD_FUZZ #define CONFIG_USB_POWER_DELIVERY #define CONFIG_USB_PD_DUAL_ROLE -#define CONFIG_USB_PD_PORT_COUNT 2 +#define CONFIG_USB_PD_PORT_MAX_COUNT 2 #define CONFIG_SHA256 #define CONFIG_SW_CRC #endif /* TEST_USB_PD_FUZZ */ #ifdef TEST_USB_TCPM_V2_FUZZ #define CONFIG_USB_PD_DUAL_ROLE -#define CONFIG_USB_PD_PORT_COUNT 2 +#define CONFIG_USB_PD_PORT_MAX_COUNT 2 #define CONFIG_USB_PD_TCPC_LOW_POWER #define CONFIG_USB_PD_TRY_SRC #define CONFIG_USB_PID 0x5555 diff --git a/fuzz/usb_pd_fuzz.c b/fuzz/usb_pd_fuzz.c index 3c97d7b0bb..ba74148229 100644 --- a/fuzz/usb_pd_fuzz.c +++ b/fuzz/usb_pd_fuzz.c @@ -58,7 +58,7 @@ struct tcpc_state { struct message message; }; -static struct tcpc_state mock_tcpc_state[CONFIG_USB_PD_PORT_COUNT]; +static struct tcpc_state mock_tcpc_state[CONFIG_USB_PD_PORT_MAX_COUNT]; static int mock_tcpm_get_cc(int port, enum tcpc_cc_voltage_status *cc1, enum tcpc_cc_voltage_status *cc2) @@ -133,7 +133,7 @@ static const struct tcpm_drv mock_tcpm_drv = { }; /* TCPC mux configuration */ -const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_COUNT] = { +const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_MAX_COUNT] = { { .drv = &mock_tcpm_drv, }, diff --git a/include/charge_manager.h b/include/charge_manager.h index 4c29ea15a5..2a3ca27d74 100644 --- a/include/charge_manager.h +++ b/include/charge_manager.h @@ -113,8 +113,8 @@ enum ceil_requestor { CEIL_REQUESTOR_COUNT, }; -#define CHARGE_PORT_COUNT \ - (CONFIG_USB_PD_PORT_COUNT + CONFIG_DEDICATED_CHARGE_PORT_COUNT) +#define CHARGE_PORT_COUNT (CONFIG_USB_PD_PORT_MAX_COUNT + \ + CONFIG_DEDICATED_CHARGE_PORT_COUNT) #if (CONFIG_DEDICATED_CHARGE_PORT_COUNT > 0) /** @@ -133,7 +133,7 @@ enum ceil_requestor { */ #if !defined(DEDICATED_CHARGE_PORT) #error "DEDICATED_CHARGE_PORT must be defined" -#elif DEDICATED_CHARGE_PORT < CONFIG_USB_PD_PORT_COUNT +#elif DEDICATED_CHARGE_PORT < CONFIG_USB_PD_PORT_MAX_COUNT #error "DEDICATED_CHARGE_PORT must larger than pd port numbers" #endif /* !defined(DEDICATED_CHARGE_PORT) */ diff --git a/include/config.h b/include/config.h index 853f4c6f7a..a6f4af7630 100644 --- a/include/config.h +++ b/include/config.h @@ -3738,7 +3738,7 @@ #undef CONFIG_USB_PD_LOW_POWER_IDLE_WHEN_CONNECTED /* Number of USB PD ports */ -#undef CONFIG_USB_PD_PORT_COUNT +#undef CONFIG_USB_PD_PORT_MAX_COUNT /* Simple DFP, such as power adapter, will not send discovery VDM on connect */ #undef CONFIG_USB_PD_SIMPLE_DFP @@ -4973,12 +4973,12 @@ /* * If USB PD Discharge is enabled, verify that CONFIG_USB_PD_DISCHARGE_GPIO - * and CONFIG_USB_PD_PORT_COUNT, CONFIG_USB_PD_DISCHARGE_TCPC, or + * and CONFIG_USB_PD_PORT_MAX_COUNT, CONFIG_USB_PD_DISCHARGE_TCPC, or * CONFIG_USB_PD_DISCHARGE_PPC is defined. */ #ifdef CONFIG_USB_PD_DISCHARGE #ifdef CONFIG_USB_PD_DISCHARGE_GPIO -#if !defined(CONFIG_USB_PD_PORT_COUNT) +#if !defined(CONFIG_USB_PD_PORT_MAX_COUNT) #error "PD discharge port not defined" #endif #else diff --git a/include/ec_commands.h b/include/ec_commands.h index 6e5e3b6990..50b23f6ef3 100644 --- a/include/ec_commands.h +++ b/include/ec_commands.h @@ -5301,7 +5301,7 @@ struct ec_params_usb_pd_discovery_entry { enum usb_pd_override_ports { OVERRIDE_DONT_CHARGE = -2, OVERRIDE_OFF = -1, - /* [0, CONFIG_USB_PD_PORT_COUNT): Port# */ + /* [0, CONFIG_USB_PD_PORT_MAX_COUNT): Port# */ }; struct ec_params_charge_port_override { diff --git a/include/usb_emsg.h b/include/usb_emsg.h index ffbaa93a0e..7847cf6967 100644 --- a/include/usb_emsg.h +++ b/include/usb_emsg.h @@ -18,6 +18,6 @@ struct extended_msg { }; /* Defined in usb_prl_sm.c */ -extern struct extended_msg emsg[CONFIG_USB_PD_PORT_COUNT]; +extern struct extended_msg emsg[CONFIG_USB_PD_PORT_MAX_COUNT]; #endif /* __CROS_EC_USB_EBUF_H */ diff --git a/include/usb_pd.h b/include/usb_pd.h index 2593762a59..c5e778d35b 100644 --- a/include/usb_pd.h +++ b/include/usb_pd.h @@ -14,7 +14,7 @@ /* PD Host command timeout */ #define PD_HOST_COMMAND_TIMEOUT_US SECOND -#ifdef CONFIG_USB_PD_PORT_COUNT +#ifdef CONFIG_USB_PD_PORT_MAX_COUNT /* * Define PD_PORT_TO_TASK_ID() and TASK_ID_TO_PD_PORT() macros to * go between PD port number and task ID. Assume that TASK_ID_PD_C0 is the @@ -27,7 +27,7 @@ #define PD_PORT_TO_TASK_ID(port) -1 /* dummy task ID */ #define TASK_ID_TO_PD_PORT(id) 0 #endif /* CONFIG_COMMON_RUNTIME */ -#endif /* CONFIG_USB_PD_PORT_COUNT */ +#endif /* CONFIG_USB_PD_PORT_MAX_COUNT */ enum pd_rx_errors { PD_RX_ERR_INVAL = -1, /* Invalid packet */ diff --git a/test/charge_manager.c b/test/charge_manager.c index e50e0e38ee..30c9efc69b 100644 --- a/test/charge_manager.c +++ b/test/charge_manager.c @@ -35,8 +35,8 @@ BUILD_ASSERT(ARRAY_SIZE(supplier_priority) == CHARGE_SUPPLIER_COUNT); static unsigned int active_charge_limit = CHARGE_SUPPLIER_NONE; static unsigned int active_charge_port = CHARGE_PORT_NONE; static unsigned int charge_port_to_reject = CHARGE_PORT_NONE; -static int new_power_request[CONFIG_USB_PD_PORT_COUNT]; -static int power_role[CONFIG_USB_PD_PORT_COUNT]; +static int new_power_request[CONFIG_USB_PD_PORT_MAX_COUNT]; +static int power_role[CONFIG_USB_PD_PORT_MAX_COUNT]; /* Callback functions called by CM on state change */ void board_set_charge_limit(int port, int supplier, int charge_ma, @@ -78,7 +78,7 @@ enum battery_present battery_is_present(void) static void clear_new_power_requests(void) { int i; - for (i = 0; i < CONFIG_USB_PD_PORT_COUNT; ++i) + for (i = 0; i < CONFIG_USB_PD_PORT_MAX_COUNT; ++i) new_power_request[i] = 0; } @@ -115,7 +115,7 @@ static void initialize_charge_table(int current, int voltage, int ceil) charge.current = current; charge.voltage = voltage; - for (i = 0; i < CONFIG_USB_PD_PORT_COUNT; ++i) { + for (i = 0; i < CONFIG_USB_PD_PORT_MAX_COUNT; ++i) { for (j = 0; j < CEIL_REQUESTOR_COUNT; ++j) charge_manager_set_ceil(i, j, ceil); charge_manager_update_dualrole(i, CAP_DEDICATED); @@ -141,12 +141,12 @@ static int test_initialization(void) /* Initialize all supplier/port pairs, except for the last one */ for (i = 0; i < CHARGE_SUPPLIER_COUNT; ++i) - for (j = 0; j < CONFIG_USB_PD_PORT_COUNT; ++j) { + for (j = 0; j < CONFIG_USB_PD_PORT_MAX_COUNT; ++j) { if (i == 0) charge_manager_update_dualrole(j, CAP_DEDICATED); if (i == CHARGE_SUPPLIER_COUNT - 1 && - j == CONFIG_USB_PD_PORT_COUNT - 1) + j == CONFIG_USB_PD_PORT_MAX_COUNT - 1) break; charge_manager_update_charge(i, j, &charge); } @@ -157,7 +157,7 @@ static int test_initialization(void) /* Update last pair and verify a charge port has been selected */ charge_manager_update_charge(CHARGE_SUPPLIER_COUNT-1, - CONFIG_USB_PD_PORT_COUNT-1, + CONFIG_USB_PD_PORT_MAX_COUNT-1, &charge); wait_for_charge_manager_refresh(); TEST_ASSERT(active_charge_port != CHARGE_PORT_NONE); diff --git a/test/fake_prl.c b/test/fake_prl.c index abdc27763f..58f3c17130 100644 --- a/test/fake_prl.c +++ b/test/fake_prl.c @@ -8,7 +8,7 @@ #include "usb_emsg.h" #include "usb_prl_sm.h" -struct extended_msg emsg[CONFIG_USB_PD_PORT_COUNT]; +struct extended_msg emsg[CONFIG_USB_PD_PORT_MAX_COUNT]; void prl_end_ams(int port) {} @@ -32,7 +32,7 @@ int prl_is_running(int port) void prl_reset(int port) {} -static enum pd_ctrl_msg_type last_ctrl_msg[CONFIG_USB_PD_PORT_COUNT]; +static enum pd_ctrl_msg_type last_ctrl_msg[CONFIG_USB_PD_PORT_MAX_COUNT]; void prl_send_ctrl_msg(int port, enum tcpm_transmit_type type, enum pd_ctrl_msg_type msg) { diff --git a/test/test_config.h b/test/test_config.h index 30a82ba863..8a947d1717 100644 --- a/test/test_config.h +++ b/test/test_config.h @@ -232,7 +232,7 @@ int ncp15wb_calculate_temp(uint16_t adc); #ifdef TEST_USB_COMMON #define CONFIG_USB_POWER_DELIVERY -#define CONFIG_USB_PD_PORT_COUNT 1 +#define CONFIG_USB_PD_PORT_MAX_COUNT 1 #define CONFIG_USB_PD_TCPC #define CONFIG_USB_PD_TCPM_STUB #define CONFIG_SHA256 @@ -240,7 +240,7 @@ int ncp15wb_calculate_temp(uint16_t adc); #endif #if defined(TEST_USB_SM_FRAMEWORK_H3) -#define CONFIG_USB_PD_PORT_COUNT 1 +#define CONFIG_USB_PD_PORT_MAX_COUNT 1 #undef CONFIG_USB_PRL_SM #undef CONFIG_USB_PE_SM #undef CONFIG_USB_TYPEC_SM @@ -248,7 +248,7 @@ int ncp15wb_calculate_temp(uint16_t adc); #endif #if defined(TEST_USB_SM_FRAMEWORK_H2) -#define CONFIG_USB_PD_PORT_COUNT 1 +#define CONFIG_USB_PD_PORT_MAX_COUNT 1 #undef CONFIG_USB_PRL_SM #undef CONFIG_USB_PE_SM #undef CONFIG_USB_TYPEC_SM @@ -256,7 +256,7 @@ int ncp15wb_calculate_temp(uint16_t adc); #endif #if defined(TEST_USB_SM_FRAMEWORK_H1) -#define CONFIG_USB_PD_PORT_COUNT 1 +#define CONFIG_USB_PD_PORT_MAX_COUNT 1 #undef CONFIG_USB_PRL_SM #undef CONFIG_USB_PE_SM #undef CONFIG_USB_TYPEC_SM @@ -264,7 +264,7 @@ int ncp15wb_calculate_temp(uint16_t adc); #endif #if defined(TEST_USB_SM_FRAMEWORK_H0) -#define CONFIG_USB_PD_PORT_COUNT 1 +#define CONFIG_USB_PD_PORT_MAX_COUNT 1 #undef CONFIG_USB_PRL_SM #undef CONFIG_USB_PE_SM #undef CONFIG_USB_TYPEC_SM @@ -272,7 +272,7 @@ int ncp15wb_calculate_temp(uint16_t adc); #endif #if defined(TEST_USB_PRL) -#define CONFIG_USB_PD_PORT_COUNT 2 +#define CONFIG_USB_PD_PORT_MAX_COUNT 2 #define CONFIG_USB_SM_FRAMEWORK #undef CONFIG_USB_PE_SM #undef CONFIG_USB_TYPEC_SM @@ -286,7 +286,7 @@ int ncp15wb_calculate_temp(uint16_t adc); #if defined(TEST_USB_PE_DRP) #define CONFIG_TEST_USB_PE_SM -#define CONFIG_USB_PD_PORT_COUNT 1 +#define CONFIG_USB_PD_PORT_MAX_COUNT 1 #define CONFIG_USB_PE_SM #define CONFIG_USB_PID 0x5036 #define CONFIG_USB_POWER_DELIVERY @@ -311,7 +311,7 @@ int ncp15wb_calculate_temp(uint16_t adc); /* GND impedance in milliohms */ #define VPD_GND_IMPEDANCE 33 -#define CONFIG_USB_PD_PORT_COUNT 1 +#define CONFIG_USB_PD_PORT_MAX_COUNT 1 #define CONFIG_USB_SM_FRAMEWORK #define CONFIG_USB_PE_SM #define CONFIG_USB_PRL_SM @@ -336,7 +336,7 @@ int ncp15wb_calculate_temp(uint16_t adc); #define CONFIG_USB_PD_TRY_SRC #define CONFIG_USB_TYPEC_SM #define CONFIG_USB_SM_FRAMEWORK -#define CONFIG_USB_PD_PORT_COUNT 1 +#define CONFIG_USB_PD_PORT_MAX_COUNT 1 #define CONFIG_USBC_SS_MUX #define CONFIG_USB_PD_VBUS_DETECT_TCPC #define CONFIG_USB_POWER_DELIVERY @@ -348,7 +348,7 @@ int ncp15wb_calculate_temp(uint16_t adc); defined(TEST_USB_PD_REV30) #define CONFIG_USB_POWER_DELIVERY #define CONFIG_USB_PD_DUAL_ROLE -#define CONFIG_USB_PD_PORT_COUNT 2 +#define CONFIG_USB_PD_PORT_MAX_COUNT 2 #define CONFIG_USB_PD_TCPC #define CONFIG_USB_PD_TCPM_STUB #define CONFIG_SHA256 @@ -363,7 +363,7 @@ int ncp15wb_calculate_temp(uint16_t adc); #endif /* TEST_USB_PD || TEST_USB_PD_GIVEBACK || TEST_USB_PD_REV30 */ #ifdef TEST_USB_PPC -#define CONFIG_USB_PD_PORT_COUNT 1 +#define CONFIG_USB_PD_PORT_MAX_COUNT 1 #define CONFIG_USB_PD_VBUS_DETECT_PPC #define CONFIG_USBC_PPC #define CONFIG_USBC_PPC_POLARITY @@ -374,7 +374,7 @@ int ncp15wb_calculate_temp(uint16_t adc); #if defined(TEST_CHARGE_MANAGER) || defined(TEST_CHARGE_MANAGER_DRP_CHARGING) #define CONFIG_CHARGE_MANAGER #define CONFIG_USB_PD_DUAL_ROLE -#define CONFIG_USB_PD_PORT_COUNT 2 +#define CONFIG_USB_PD_PORT_MAX_COUNT 2 #define CONFIG_BATTERY #define CONFIG_BATTERY_SMART #define CONFIG_I2C @@ -390,7 +390,7 @@ int ncp15wb_calculate_temp(uint16_t adc); #ifdef TEST_CHARGE_RAMP #define CONFIG_CHARGE_RAMP_SW -#define CONFIG_USB_PD_PORT_COUNT 2 +#define CONFIG_USB_PD_PORT_MAX_COUNT 2 #endif #if defined(TEST_NVMEM) || defined(TEST_NVMEM_VARS) diff --git a/test/usb_pd.c b/test/usb_pd.c index 2ca0d1d115..96d18beafd 100644 --- a/test/usb_pd.c +++ b/test/usb_pd.c @@ -31,7 +31,7 @@ struct pd_port_t { int partner_role; /* -1 for none */ int partner_polarity; int rev; -} pd_port[CONFIG_USB_PD_PORT_COUNT]; +} pd_port[CONFIG_USB_PD_PORT_MAX_COUNT]; static int give_back_called; @@ -147,7 +147,7 @@ static void init_ports(void) { int i; - for (i = 0; i < CONFIG_USB_PD_PORT_COUNT; ++i) { + for (i = 0; i < CONFIG_USB_PD_PORT_MAX_COUNT; ++i) { pd_port[i].host_mode = 0; pd_port[i].partner_role = -1; pd_port[i].has_vbus = 0; diff --git a/test/usb_prl.c b/test/usb_prl.c index 3843c49381..90cadbb230 100644 --- a/test/usb_prl.c +++ b/test/usb_prl.c @@ -106,7 +106,7 @@ static struct pd_prl { int mock_pe_got_hard_reset; int mock_pe_message_received; int mock_got_soft_reset; -} pd_port[CONFIG_USB_PD_PORT_COUNT]; +} pd_port[CONFIG_USB_PD_PORT_MAX_COUNT]; static void init_port(int port, int rev) { diff --git a/test/usb_typec_ctvpd.c b/test/usb_typec_ctvpd.c index 75d620fd85..0253bd75d1 100644 --- a/test/usb_typec_ctvpd.c +++ b/test/usb_typec_ctvpd.c @@ -64,7 +64,7 @@ struct pd_port_t { int partner_role; /* -1 for none */ int partner_polarity; int rev; -} pd_port[CONFIG_USB_PD_PORT_COUNT]; +} pd_port[CONFIG_USB_PD_PORT_MAX_COUNT]; uint64_t wait_for_state_change(int port, uint64_t timeout) { diff --git a/test/usb_typec_drp_acc_trysrc.c b/test/usb_typec_drp_acc_trysrc.c index 5981001344..07496ca600 100644 --- a/test/usb_typec_drp_acc_trysrc.c +++ b/test/usb_typec_drp_acc_trysrc.c @@ -17,13 +17,13 @@ #define PORT0 0 /* Install Mock TCPC and MUX drivers */ -const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_COUNT] = { +const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_MAX_COUNT] = { { .drv = &mock_tcpc_driver, }, }; -struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_COUNT] = { +struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_MAX_COUNT] = { { .driver = &mock_usb_mux_driver, } |