diff options
55 files changed, 443 insertions, 497 deletions
diff --git a/board/dingdong/board.h b/board/dingdong/board.h index 77b557b4b1..85f4374e68 100644 --- a/board/dingdong/board.h +++ b/board/dingdong/board.h @@ -38,6 +38,7 @@ #define CONFIG_USB_PD_NO_VBUS_DETECT #define CONFIG_USB_PD_LOGGING #define CONFIG_USB_PD_LOG_SIZE 256 +#define CONFIG_USB_PD_PORT_COUNT 1 #define CONFIG_USB_PD_TCPC #define CONFIG_USB_PD_TCPM_STUB #undef CONFIG_WATCHDOG_HELP @@ -77,6 +78,19 @@ enum usb_strings { USB_STR_COUNT }; +/* we are acting only as a sink */ +#define PD_DEFAULT_STATE PD_STATE_SNK_DISCONNECTED + +/* we are never a source : don't care about power supply */ +#define PD_POWER_SUPPLY_TURN_ON_DELAY 0 /* us */ +#define PD_POWER_SUPPLY_TURN_OFF_DELAY 0 /* us */ + +/* Define typical operating power and max power */ +#define PD_OPERATING_POWER_MW 1000 +#define PD_MAX_POWER_MW 1500 +#define PD_MAX_CURRENT_MA 300 +#define PD_MAX_VOLTAGE_MV 5000 + #endif /* !__ASSEMBLER__ */ /* USB Device class */ diff --git a/board/dingdong/usb_pd_config.h b/board/dingdong/usb_pd_config.h index 0d9cf41b7c..894a63867b 100644 --- a/board/dingdong/usb_pd_config.h +++ b/board/dingdong/usb_pd_config.h @@ -8,11 +8,6 @@ #ifndef __USB_PD_CONFIG_H #define __USB_PD_CONFIG_H -/* Port and task configuration */ -#define PD_PORT_COUNT 1 -#define PORT_TO_TASK_ID(port) TASK_ID_PD -#define TASK_ID_TO_PORT(id) 0 - /* Timer selection for baseband PD communication */ #define TIM_CLOCK_PD_TX_C0 17 #define TIM_CLOCK_PD_RX_C0 1 @@ -130,28 +125,4 @@ static inline int pd_adc_read(int port, int cc) return (cc == 0) ? adc_read_channel(ADC_CH_CC1_PD) : 0; } -static inline int pd_snk_is_vbus_provided(int port) -{ - return 1; -} - -/* 3.0A DFP : no-connect voltage is 2.45V */ -#define PD_SRC_VNC 2450 /* mV */ - -/* UFP-side : threshold for DFP connection detection */ -#define PD_SNK_VA 250 /* mV */ - -/* we are acting only as a sink */ -#define PD_DEFAULT_STATE PD_STATE_SNK_DISCONNECTED - -/* we are never a source : don't care about power supply */ -#define PD_POWER_SUPPLY_TURN_ON_DELAY 0 /* us */ -#define PD_POWER_SUPPLY_TURN_OFF_DELAY 0 /* us */ - -/* Define typical operating power and max power */ -#define PD_OPERATING_POWER_MW 1000 -#define PD_MAX_POWER_MW 1500 -#define PD_MAX_CURRENT_MA 300 -#define PD_MAX_VOLTAGE_MV 5000 - #endif /* __USB_PD_CONFIG_H */ diff --git a/board/dingdong/usb_pd_policy.c b/board/dingdong/usb_pd_policy.c index 3d14329e59..103a4c26b8 100644 --- a/board/dingdong/usb_pd_policy.c +++ b/board/dingdong/usb_pd_policy.c @@ -69,6 +69,11 @@ void pd_power_supply_reset(int port) { } +int pd_snk_is_vbus_provided(int port) +{ + return 1; +} + int pd_board_checks(void) { return EC_SUCCESS; diff --git a/board/firefly/board.h b/board/firefly/board.h index 43b324c0d3..1ca109662f 100644 --- a/board/firefly/board.h +++ b/board/firefly/board.h @@ -19,6 +19,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_TCPC #define CONFIG_USB_PD_TCPM_STUB #define CONFIG_ADC @@ -55,6 +56,19 @@ enum adc_channel { ADC_CH_COUNT }; +/* we are acting only as a sink */ +#define PD_DEFAULT_STATE PD_STATE_SNK_DISCONNECTED + +/* we are never a source : don't care about power supply */ +#define PD_POWER_SUPPLY_TURN_ON_DELAY 0 /* us */ +#define PD_POWER_SUPPLY_TURN_OFF_DELAY 0 /* us */ + +/* Define typical operating power and max power */ +#define PD_OPERATING_POWER_MW 1000 +#define PD_MAX_POWER_MW 1500 +#define PD_MAX_CURRENT_MA 300 +#define PD_MAX_VOLTAGE_MV 20000 + #endif /* !__ASSEMBLER__ */ #endif /* __BOARD_H */ diff --git a/board/firefly/usb_pd_config.h b/board/firefly/usb_pd_config.h index f006e30709..be0f0b3670 100644 --- a/board/firefly/usb_pd_config.h +++ b/board/firefly/usb_pd_config.h @@ -8,11 +8,6 @@ #ifndef __USB_PD_CONFIG_H #define __USB_PD_CONFIG_H -/* Port and task configuration */ -#define PD_PORT_COUNT 1 -#define PORT_TO_TASK_ID(port) TASK_ID_PD -#define TASK_ID_TO_PORT(id) 0 - /* Timer selection for baseband PD communication */ #define TIM_CLOCK_PD_TX_C0 17 #define TIM_CLOCK_PD_RX_C0 1 @@ -139,29 +134,4 @@ static inline int pd_adc_read(int port, int cc) return adc_read_channel(ADC_CH_CC2_PD); } -static inline int pd_snk_is_vbus_provided(int port) -{ - /* VBUS_WAKE is broken (not detecting 5V), use the ADC instead */ - return adc_read_channel(ADC_CH_VBUS_SENSE) > 4000; -} - -/* Standard-current DFP : no-connect voltage is 1.55V */ -#define PD_SRC_VNC 1550 /* mV */ - -/* UFP-side : threshold for DFP connection detection */ -#define PD_SNK_VA 250 /* mV */ - -/* we are acting only as a sink */ -#define PD_DEFAULT_STATE PD_STATE_SNK_DISCONNECTED - -/* we are never a source : don't care about power supply */ -#define PD_POWER_SUPPLY_TURN_ON_DELAY 0 /* us */ -#define PD_POWER_SUPPLY_TURN_OFF_DELAY 0 /* us */ - -/* Define typical operating power and max power */ -#define PD_OPERATING_POWER_MW 1000 -#define PD_MAX_POWER_MW 1500 -#define PD_MAX_CURRENT_MA 300 -#define PD_MAX_VOLTAGE_MV 20000 - #endif /* __USB_PD_CONFIG_H */ diff --git a/board/firefly/usb_pd_policy.c b/board/firefly/usb_pd_policy.c index 2784f7799a..3750fb67a4 100644 --- a/board/firefly/usb_pd_policy.c +++ b/board/firefly/usb_pd_policy.c @@ -71,6 +71,12 @@ void pd_power_supply_reset(int port) { } +int pd_snk_is_vbus_provided(int port) +{ + /* VBUS_WAKE is broken (not detecting 5V), use the ADC instead */ + return adc_read_channel(ADC_CH_VBUS_SENSE) > 4000; +} + int pd_board_checks(void) { static int blinking; diff --git a/board/fruitpie/board.h b/board/fruitpie/board.h index a2213baa1c..429a0a110c 100644 --- a/board/fruitpie/board.h +++ b/board/fruitpie/board.h @@ -24,6 +24,7 @@ #define CONFIG_USB_PD_CUSTOM_VDM #define CONFIG_USB_PD_DUAL_ROLE #define CONFIG_USB_PD_INTERNAL_COMP +#define CONFIG_USB_PD_PORT_COUNT 1 #define CONFIG_USB_PD_TCPC #define CONFIG_USB_PD_TCPM_STUB #define CONFIG_USBC_SS_MUX @@ -106,6 +107,23 @@ enum usb_strings { USB_STR_COUNT }; +/* Standard-current Rp */ +#define PD_SRC_VNC PD_SRC_DEF_VNC_MV +#define PD_SRC_RD_THRESHOLD PD_SRC_DEF_RD_THRESH_MV + +/* start as a sink in case we have no other power supply/battery */ +#define PD_DEFAULT_STATE PD_STATE_SNK_DISCONNECTED + +/* delay necessary for the voltage transition on the power supply */ +#define PD_POWER_SUPPLY_TURN_ON_DELAY 50000 /* us */ +#define PD_POWER_SUPPLY_TURN_OFF_DELAY 50000 /* us */ + +/* Define typical operating power and max power */ +#define PD_OPERATING_POWER_MW 1000 +#define PD_MAX_POWER_MW 60000 +#define PD_MAX_CURRENT_MA 3000 +#define PD_MAX_VOLTAGE_MV 20000 + #endif /* !__ASSEMBLER__ */ /* USB interface indexes (use define rather than enum to expand them) */ diff --git a/board/fruitpie/usb_pd_config.h b/board/fruitpie/usb_pd_config.h index c3e11ec7e1..e7e81e4e58 100644 --- a/board/fruitpie/usb_pd_config.h +++ b/board/fruitpie/usb_pd_config.h @@ -8,11 +8,6 @@ #ifndef __USB_PD_CONFIG_H #define __USB_PD_CONFIG_H -/* Port and task configuration */ -#define PD_PORT_COUNT 1 -#define PORT_TO_TASK_ID(port) TASK_ID_PD -#define TASK_ID_TO_PORT(id) 0 - /* Timer selection for baseband PD communication */ #define TIM_CLOCK_PD_TX_C0 17 #define TIM_CLOCK_PD_RX_C0 1 @@ -176,28 +171,4 @@ static inline void pd_set_vconn(int port, int polarity, int enable) GPIO_VCONN2_EN, enable); } -static inline int pd_snk_is_vbus_provided(int port) -{ - return gpio_get_level(GPIO_VBUS_WAKE); -} - -/* Standard-current DFP : no-connect voltage is 1.55V */ -#define PD_SRC_VNC 1550 /* mV */ - -/* UFP-side : threshold for DFP connection detection */ -#define PD_SNK_VA 200 /* mV */ - -/* start as a sink in case we have no other power supply/battery */ -#define PD_DEFAULT_STATE PD_STATE_SNK_DISCONNECTED - -/* delay necessary for the voltage transition on the power supply */ -#define PD_POWER_SUPPLY_TURN_ON_DELAY 50000 /* us */ -#define PD_POWER_SUPPLY_TURN_OFF_DELAY 50000 /* us */ - -/* Define typical operating power and max power */ -#define PD_OPERATING_POWER_MW 1000 -#define PD_MAX_POWER_MW 60000 -#define PD_MAX_CURRENT_MA 3000 -#define PD_MAX_VOLTAGE_MV 20000 - #endif /* __USB_PD_CONFIG_H */ diff --git a/board/fruitpie/usb_pd_policy.c b/board/fruitpie/usb_pd_policy.c index 4c6eb7d798..ff27c46b43 100644 --- a/board/fruitpie/usb_pd_policy.c +++ b/board/fruitpie/usb_pd_policy.c @@ -95,6 +95,11 @@ void pd_power_supply_reset(int port) gpio_set_level(GPIO_USB_C_5V_EN, 0); } +int pd_snk_is_vbus_provided(int port) +{ + return gpio_get_level(GPIO_VBUS_WAKE); +} + int pd_board_checks(void) { return EC_SUCCESS; diff --git a/board/hoho/board.h b/board/hoho/board.h index 4ce3a5320e..b83bd832ec 100644 --- a/board/hoho/board.h +++ b/board/hoho/board.h @@ -44,6 +44,7 @@ #define CONFIG_USB_PD_IDENTITY_SW_VERS 1 #define CONFIG_USB_PD_LOGGING #define CONFIG_USB_PD_LOG_SIZE 256 +#define CONFIG_USB_PD_PORT_COUNT 1 #define CONFIG_USB_PD_TCPC #define CONFIG_USB_PD_TCPM_STUB #define CONFIG_USB_PD_NO_VBUS_DETECT @@ -89,6 +90,19 @@ enum usb_strings { USB_STR_COUNT }; +/* we are acting only as a sink */ +#define PD_DEFAULT_STATE PD_STATE_SNK_DISCONNECTED + +/* we are never a source : don't care about power supply */ +#define PD_POWER_SUPPLY_TURN_ON_DELAY 0 /* us */ +#define PD_POWER_SUPPLY_TURN_OFF_DELAY 0 /* us */ + +/* Define typical operating power and max power */ +#define PD_OPERATING_POWER_MW 1000 +#define PD_MAX_POWER_MW 1500 +#define PD_MAX_CURRENT_MA 300 +#define PD_MAX_VOLTAGE_MV 5000 + #endif /* !__ASSEMBLER__ */ /* USB Device class */ diff --git a/board/hoho/usb_pd_config.h b/board/hoho/usb_pd_config.h index 0d9cf41b7c..894a63867b 100644 --- a/board/hoho/usb_pd_config.h +++ b/board/hoho/usb_pd_config.h @@ -8,11 +8,6 @@ #ifndef __USB_PD_CONFIG_H #define __USB_PD_CONFIG_H -/* Port and task configuration */ -#define PD_PORT_COUNT 1 -#define PORT_TO_TASK_ID(port) TASK_ID_PD -#define TASK_ID_TO_PORT(id) 0 - /* Timer selection for baseband PD communication */ #define TIM_CLOCK_PD_TX_C0 17 #define TIM_CLOCK_PD_RX_C0 1 @@ -130,28 +125,4 @@ static inline int pd_adc_read(int port, int cc) return (cc == 0) ? adc_read_channel(ADC_CH_CC1_PD) : 0; } -static inline int pd_snk_is_vbus_provided(int port) -{ - return 1; -} - -/* 3.0A DFP : no-connect voltage is 2.45V */ -#define PD_SRC_VNC 2450 /* mV */ - -/* UFP-side : threshold for DFP connection detection */ -#define PD_SNK_VA 250 /* mV */ - -/* we are acting only as a sink */ -#define PD_DEFAULT_STATE PD_STATE_SNK_DISCONNECTED - -/* we are never a source : don't care about power supply */ -#define PD_POWER_SUPPLY_TURN_ON_DELAY 0 /* us */ -#define PD_POWER_SUPPLY_TURN_OFF_DELAY 0 /* us */ - -/* Define typical operating power and max power */ -#define PD_OPERATING_POWER_MW 1000 -#define PD_MAX_POWER_MW 1500 -#define PD_MAX_CURRENT_MA 300 -#define PD_MAX_VOLTAGE_MV 5000 - #endif /* __USB_PD_CONFIG_H */ diff --git a/board/hoho/usb_pd_policy.c b/board/hoho/usb_pd_policy.c index fff0399184..aa91668242 100644 --- a/board/hoho/usb_pd_policy.c +++ b/board/hoho/usb_pd_policy.c @@ -69,6 +69,11 @@ void pd_power_supply_reset(int port) { } +int pd_snk_is_vbus_provided(int port) +{ + return 1; +} + int pd_board_checks(void) { return EC_SUCCESS; diff --git a/board/honeybuns/board.h b/board/honeybuns/board.h index bf31953269..324346662b 100644 --- a/board/honeybuns/board.h +++ b/board/honeybuns/board.h @@ -29,6 +29,7 @@ #define CONFIG_USB_PD_CUSTOM_VDM #define CONFIG_USB_PD_DUAL_ROLE #define CONFIG_USB_PD_INTERNAL_COMP +#define CONFIG_USB_PD_PORT_COUNT 1 #define CONFIG_USB_PD_TCPC #define CONFIG_USB_PD_TCPM_STUB #define CONFIG_USBC_SS_MUX @@ -79,6 +80,26 @@ enum usb_strings { USB_STR_COUNT }; +/* 3.0A Rp */ +#define PD_SRC_VNC PD_SRC_3_0_VNC_MV +#define PD_SRC_RD_THRESHOLD PD_SRC_3_0_RD_THRESH_MV + +/* we are acting only as a source */ +#define PD_DEFAULT_STATE PD_STATE_SRC_DISCONNECTED + +/* delay necessary for the voltage transition on the power supply */ +/* TODO (code.google.com/p/chrome-os-partner/issues/detail?id=37078) + * Need to measure these and adjust for honeybuns. + */ +#define PD_POWER_SUPPLY_TURN_ON_DELAY 50000 /* us */ +#define PD_POWER_SUPPLY_TURN_OFF_DELAY 50000 /* us */ + +/* Define typical operating power and max power */ +#define PD_OPERATING_POWER_MW 1000 +#define PD_MAX_POWER_MW 60000 +#define PD_MAX_CURRENT_MA 3000 +#define PD_MAX_VOLTAGE_MV 20000 + #endif /* !__ASSEMBLER__ */ /* USB interface indexes (use define rather than enum to expand them) */ diff --git a/board/honeybuns/usb_pd_config.h b/board/honeybuns/usb_pd_config.h index 35f47ff5ad..cbb5214546 100644 --- a/board/honeybuns/usb_pd_config.h +++ b/board/honeybuns/usb_pd_config.h @@ -8,11 +8,6 @@ #ifndef __USB_PD_CONFIG_H #define __USB_PD_CONFIG_H -/* Port and task configuration */ -#define PD_PORT_COUNT 1 -#define PORT_TO_TASK_ID(port) TASK_ID_PD -#define TASK_ID_TO_PORT(id) 0 - /* Timer selection for baseband PD communication */ #define TIM_CLOCK_PD_TX_C0 17 #define TIM_CLOCK_PD_RX_C0 1 @@ -143,31 +138,4 @@ static inline void pd_set_vconn(int port, int polarity, int enable) } -static inline int pd_snk_is_vbus_provided(int port) -{ - return 0; -} - -/* 3.0A DFP : no-connect voltage is 2.45V */ -#define PD_SRC_VNC 2450 /* mV */ - -/* UFP-side : threshold for DFP connection detection */ -#define PD_SNK_VA 200 /* mV */ - -/* we are acting only as a source */ -#define PD_DEFAULT_STATE PD_STATE_SRC_DISCONNECTED - -/* delay necessary for the voltage transition on the power supply */ -/* TODO (code.google.com/p/chrome-os-partner/issues/detail?id=37078) - * Need to measure these and adjust for honeybuns. - */ -#define PD_POWER_SUPPLY_TURN_ON_DELAY 50000 /* us */ -#define PD_POWER_SUPPLY_TURN_OFF_DELAY 50000 /* us */ - -/* Define typical operating power and max power */ -#define PD_OPERATING_POWER_MW 1000 -#define PD_MAX_POWER_MW 60000 -#define PD_MAX_CURRENT_MA 3000 -#define PD_MAX_VOLTAGE_MV 20000 - #endif /* __USB_PD_CONFIG_H */ diff --git a/board/honeybuns/usb_pd_policy.c b/board/honeybuns/usb_pd_policy.c index 22433b318a..43d28c3e8b 100644 --- a/board/honeybuns/usb_pd_policy.c +++ b/board/honeybuns/usb_pd_policy.c @@ -94,6 +94,11 @@ void pd_power_supply_reset(int port) gpio_set_level(GPIO_PPVAR_VBUS_EN, 0); } +int pd_snk_is_vbus_provided(int port) +{ + return 0; +} + int pd_board_checks(void) { return EC_SUCCESS; diff --git a/board/host/board.h b/board/host/board.h index d33a4a56dc..677237ab43 100644 --- a/board/host/board.h +++ b/board/host/board.h @@ -56,4 +56,21 @@ enum charge_supplier { /* supplier_priority table defined in board.c */ extern const int supplier_priority[]; +/* Standard-current Rp */ +#define PD_SRC_VNC PD_SRC_DEF_VNC_MV +#define PD_SRC_RD_THRESHOLD PD_SRC_DEF_RD_THRESH_MV + +/* start as a sink in case we have no other power supply/battery */ +#define PD_DEFAULT_STATE PD_STATE_SNK_DISCONNECTED + +/* delay necessary for the voltage transition on the power supply */ +#define PD_POWER_SUPPLY_TURN_ON_DELAY 20000 /* us */ +#define PD_POWER_SUPPLY_TURN_OFF_DELAY 20000 /* us */ + +/* Define typical operating power and max power */ +#define PD_OPERATING_POWER_MW 15000 +#define PD_MAX_POWER_MW 60000 +#define PD_MAX_CURRENT_MA 3000 +#define PD_MAX_VOLTAGE_MV 20000 + #endif /* __BOARD_H */ diff --git a/board/host/usb_pd_config.c b/board/host/usb_pd_config.c index 15ea815d47..0363b1ec78 100644 --- a/board/host/usb_pd_config.c +++ b/board/host/usb_pd_config.c @@ -33,8 +33,3 @@ test_mockable int pd_adc_read(int port, int cc) return 0; } -test_mockable int pd_snk_is_vbus_provided(int port) -{ - /* Not implemented */ - return 1; -} diff --git a/board/host/usb_pd_config.h b/board/host/usb_pd_config.h index ed4f8e5960..8055591770 100644 --- a/board/host/usb_pd_config.h +++ b/board/host/usb_pd_config.h @@ -8,11 +8,6 @@ #ifndef __USB_PD_CONFIG_H #define __USB_PD_CONFIG_H -/* Port and task configuration */ -#define PD_PORT_COUNT 2 -#define PORT_TO_TASK_ID(port) ((port) ? TASK_ID_PD_C1 : TASK_ID_PD_C0) -#define TASK_ID_TO_PORT(id) ((id) == TASK_ID_PD_C0 ? 0 : 1) - /* Use software CRC */ #define CONFIG_SW_CRC @@ -26,25 +21,4 @@ void pd_config_init(int port, uint8_t power_role); int pd_adc_read(int port, int cc); -int pd_snk_is_vbus_provided(int port); - -/* Standard-current DFP : no-connect voltage is 1.55V */ -#define PD_SRC_VNC 1550 /* mV */ - -/* UFP-side : threshold for DFP connection detection */ -#define PD_SNK_VA 200 /* mV */ - -/* start as a sink in case we have no other power supply/battery */ -#define PD_DEFAULT_STATE PD_STATE_SNK_DISCONNECTED - -/* delay necessary for the voltage transition on the power supply */ -#define PD_POWER_SUPPLY_TURN_ON_DELAY 20000 /* us */ -#define PD_POWER_SUPPLY_TURN_OFF_DELAY 20000 /* us */ - -/* Define typical operating power and max power */ -#define PD_OPERATING_POWER_MW 15000 -#define PD_MAX_POWER_MW 60000 -#define PD_MAX_CURRENT_MA 3000 -#define PD_MAX_VOLTAGE_MV 20000 - #endif /* __USB_PD_CONFIG_H */ diff --git a/board/host/usb_pd_policy.c b/board/host/usb_pd_policy.c index a515f58800..dbc15b1788 100644 --- a/board/host/usb_pd_policy.c +++ b/board/host/usb_pd_policy.c @@ -79,6 +79,12 @@ void pd_set_input_current_limit(int port, uint32_t max_ma, /* Not implemented */ } +test_mockable int pd_snk_is_vbus_provided(int port) +{ + /* Not implemented */ + return 1; +} + int pd_board_checks(void) { return EC_SUCCESS; diff --git a/board/plankton/board.c b/board/plankton/board.c index 487b165a67..40b0c2b2d8 100644 --- a/board/plankton/board.c +++ b/board/plankton/board.c @@ -18,7 +18,6 @@ #include "task.h" #include "timer.h" #include "usb_pd.h" -#include "usb_pd_config.h" #include "util.h" void button_event(enum gpio_signal signal); diff --git a/board/plankton/board.h b/board/plankton/board.h index 25826395eb..f367879a70 100644 --- a/board/plankton/board.h +++ b/board/plankton/board.h @@ -21,10 +21,11 @@ #define CONFIG_USB_PD_ALT_MODE #define CONFIG_USB_PD_CUSTOM_VDM #define CONFIG_USB_PD_DUAL_ROLE +#define CONFIG_USB_PD_DYNAMIC_SRC_CAP #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_DYNAMIC_SRC_CAP +#define CONFIG_USB_PD_PORT_COUNT 1 #define CONFIG_USB_PD_TCPC #define CONFIG_USB_PD_TCPM_STUB #define CONFIG_ADC @@ -71,6 +72,23 @@ enum board_src_cap { SRC_CAP_20V, }; +/* 3.0A Rp */ +#define PD_SRC_VNC PD_SRC_3_0_VNC_MV +#define PD_SNK_RD_THRESHOLD PD_SRC_3_0_RD_THRESH_MV + +/* we are acting only as a sink */ +#define PD_DEFAULT_STATE PD_STATE_SNK_DISCONNECTED + +/* delay necessary for the voltage transition on the power supply */ +#define PD_POWER_SUPPLY_TURN_ON_DELAY 50000 /* us */ +#define PD_POWER_SUPPLY_TURN_OFF_DELAY 50000 /* us */ + +/* Define typical operating power and max power */ +#define PD_OPERATING_POWER_MW 5000 +#define PD_MAX_POWER_MW 60000 +#define PD_MAX_CURRENT_MA 3000 +#define PD_MAX_VOLTAGE_MV 20000 + /* Set USB PD source capability */ void board_set_source_cap(enum board_src_cap cap); diff --git a/board/plankton/usb_pd_config.h b/board/plankton/usb_pd_config.h index 23bdd82d0e..4946695c09 100644 --- a/board/plankton/usb_pd_config.h +++ b/board/plankton/usb_pd_config.h @@ -10,11 +10,6 @@ #include "board.h" -/* USB-PD configuration */ -#define PD_PORT_COUNT 1 -#define PORT_TO_TASK_ID(port) TASK_ID_PD -#define TASK_ID_TO_PORT(id) 0 - /* Timer selection for baseband PD communication */ #define TIM_CLOCK_PD_TX_C0 17 #define TIM_CLOCK_PD_RX_C0 1 @@ -166,28 +161,4 @@ static inline int pd_adc_read(int port, int cc) return adc_read_channel(ADC_CH_CC2_PD); } -static inline int pd_snk_is_vbus_provided(int port) -{ - return gpio_get_level(GPIO_VBUS_WAKE); -} - -/* 3.0A DFP : no-connect voltage is 2.45V */ -#define PD_SRC_VNC 2450 /* mV */ - -/* UFP-side : threshold for DFP connection detection */ -#define PD_SNK_VA 250 /* mV */ - -/* we are acting only as a sink */ -#define PD_DEFAULT_STATE PD_STATE_SNK_DISCONNECTED - -/* delay necessary for the voltage transition on the power supply */ -#define PD_POWER_SUPPLY_TURN_ON_DELAY 50000 /* us */ -#define PD_POWER_SUPPLY_TURN_OFF_DELAY 50000 /* us */ - -/* Define typical operating power and max power */ -#define PD_OPERATING_POWER_MW 5000 -#define PD_MAX_POWER_MW 60000 -#define PD_MAX_CURRENT_MA 3000 -#define PD_MAX_VOLTAGE_MV 20000 - #endif /* __USB_PD_CONFIG_H */ diff --git a/board/plankton/usb_pd_policy.c b/board/plankton/usb_pd_policy.c index f510dc7268..691f8bff6c 100644 --- a/board/plankton/usb_pd_policy.c +++ b/board/plankton/usb_pd_policy.c @@ -121,6 +121,11 @@ void pd_power_supply_reset(int port) gpio_set_level(GPIO_USBC_VSEL_1, 0); } +int pd_snk_is_vbus_provided(int port) +{ + return gpio_get_level(GPIO_VBUS_WAKE); +} + int pd_board_checks(void) { static int was_connected = -1; diff --git a/board/ryu/board.c b/board/ryu/board.c index e5f2a38b21..51f34de305 100644 --- a/board/ryu/board.c +++ b/board/ryu/board.c @@ -31,7 +31,6 @@ #include "task.h" #include "usb.h" #include "usb_pd.h" -#include "usb_pd_config.h" #include "usb_spi.h" #include "usb-stm32f3.h" #include "usb-stream.h" @@ -535,9 +534,9 @@ int board_set_active_charge_port(int charge_port) { int ret = EC_SUCCESS; /* check if we are source vbus on that port */ - int source = gpio_get_level(GPIO_CHGR_OTG); + int src = gpio_get_level(GPIO_CHGR_OTG); - if (charge_port >= 0 && charge_port < PD_PORT_COUNT && source) { + if (charge_port >= 0 && charge_port < CONFIG_USB_PD_PORT_COUNT && src) { CPRINTS("Port %d is not a sink, skipping enable", charge_port); charge_port = CHARGE_PORT_NONE; ret = EC_ERROR_INVAL; diff --git a/board/ryu/board.h b/board/ryu/board.h index 61beea4afc..c6793aa157 100644 --- a/board/ryu/board.h +++ b/board/ryu/board.h @@ -30,6 +30,7 @@ #define CONFIG_USB_PD_DUAL_ROLE #define CONFIG_USB_PD_FLASH_ERASE_CHECK #define CONFIG_USB_PD_INTERNAL_COMP +#define CONFIG_USB_PD_PORT_COUNT 1 #define CONFIG_USB_PD_TCPC #define CONFIG_USB_PD_TCPM_STUB #define CONFIG_USB_SWITCH_PI3USB9281 @@ -193,6 +194,29 @@ enum usb_strings { USB_STR_COUNT }; +/* 1.5A Rp */ +#define PD_SRC_VNC PD_SRC_1_5_VNC_MV +#define PD_SRC_RD_THRESHOLD PD_SRC_1_5_RD_THRESH_MV + +/* start as a sink in case we have no other power supply/battery */ +#define PD_DEFAULT_STATE PD_STATE_SNK_DISCONNECTED + +/* delay for the voltage transition on the power supply, BQ25x spec is 30ms */ +#define PD_POWER_SUPPLY_TURN_ON_DELAY 40000 /* us */ +#define PD_POWER_SUPPLY_TURN_OFF_DELAY 20000 /* us */ + +/* delay to turn on/off vconn */ +#define PD_VCONN_SWAP_DELAY 5000 /* us */ + +/* Define typical operating power and max power */ +#define PD_OPERATING_POWER_MW 10000 +#define PD_MAX_POWER_MW 24000 +#define PD_MAX_CURRENT_MA 3000 +#define PD_MAX_VOLTAGE_MV 12000 + +/* The lower the input voltage, the higher the power efficiency. */ +#define PD_PREFER_LOW_VOLTAGE + /* Discharge battery when on AC power for factory test. */ int board_discharge_on_ac(int enable); diff --git a/board/ryu/usb_pd_config.h b/board/ryu/usb_pd_config.h index c6d6882b0f..6c5252be70 100644 --- a/board/ryu/usb_pd_config.h +++ b/board/ryu/usb_pd_config.h @@ -14,11 +14,6 @@ #include "gpio.h" #include "registers.h" -/* Port and task configuration */ -#define PD_PORT_COUNT 1 -#define PORT_TO_TASK_ID(port) TASK_ID_PD -#define TASK_ID_TO_PORT(id) 0 - /* Timer selection for baseband PD communication */ #define TIM_CLOCK_PD_TX_C0 3 #define TIM_CLOCK_PD_RX_C0 2 @@ -200,36 +195,4 @@ static inline void pd_set_vconn(int port, int polarity, int enable) GPIO_USBC_VCONN2_EN_L, !enable); } -static inline int pd_snk_is_vbus_provided(int port) -{ - return gpio_get_level(GPIO_CHGR_ACOK); -} - -/* 1.5A DFP : no-connect voltage threshold is 1.60V */ -#define PD_SRC_VNC 1600 /* mV */ -/* 1.5A DFP : Ra/Rd detection voltage threshold is 400mV */ -#define PD_SRC_RD_THRESHOLD 400 /* mV */ - -/* UFP-side : threshold for DFP connection detection */ -#define PD_SNK_VA 200 /* mV */ - -/* start as a sink in case we have no other power supply/battery */ -#define PD_DEFAULT_STATE PD_STATE_SNK_DISCONNECTED - -/* delay for the voltage transition on the power supply, BQ25x spec is 30ms */ -#define PD_POWER_SUPPLY_TURN_ON_DELAY 40000 /* us */ -#define PD_POWER_SUPPLY_TURN_OFF_DELAY 20000 /* us */ - -/* delay to turn on/off vconn */ -#define PD_VCONN_SWAP_DELAY 5000 /* us */ - -/* Define typical operating power and max power */ -#define PD_OPERATING_POWER_MW 10000 -#define PD_MAX_POWER_MW 24000 -#define PD_MAX_CURRENT_MA 3000 -#define PD_MAX_VOLTAGE_MV 12000 - -/* The lower the input voltage, the higher the power efficiency. */ -#define PD_PREFER_LOW_VOLTAGE - #endif /* __USB_PD_CONFIG_H */ diff --git a/board/ryu/usb_pd_policy.c b/board/ryu/usb_pd_policy.c index b171e3e9aa..c64d59e41c 100644 --- a/board/ryu/usb_pd_policy.c +++ b/board/ryu/usb_pd_policy.c @@ -106,6 +106,11 @@ void pd_power_supply_reset(int port) gpio_set_level(GPIO_CHGR_OTG, 0); } +int pd_snk_is_vbus_provided(int port) +{ + return gpio_get_level(GPIO_CHGR_ACOK); +} + int pd_board_checks(void) { return EC_SUCCESS; diff --git a/board/ryu_p4p5/board.c b/board/ryu_p4p5/board.c index 484f01f66f..ec383dc72b 100644 --- a/board/ryu_p4p5/board.c +++ b/board/ryu_p4p5/board.c @@ -29,7 +29,6 @@ #include "task.h" #include "usb.h" #include "usb_pd.h" -#include "usb_pd_config.h" #include "usb_spi.h" #include "usb-stm32f3.h" #include "usb-stream.h" @@ -549,9 +548,9 @@ int board_set_active_charge_port(int charge_port) { int ret = EC_SUCCESS; /* check if we are source vbus on that port */ - int source = gpio_get_level(GPIO_USBC_5V_EN); + int src = gpio_get_level(GPIO_USBC_5V_EN); - if (charge_port >= 0 && charge_port < PD_PORT_COUNT && source) { + if (charge_port >= 0 && charge_port < CONFIG_USB_PD_PORT_COUNT && src) { CPRINTS("Port %d is not a sink, skipping enable", charge_port); charge_port = CHARGE_PORT_NONE; ret = EC_ERROR_INVAL; diff --git a/board/ryu_p4p5/board.h b/board/ryu_p4p5/board.h index 44816b4848..7cfb1266b4 100644 --- a/board/ryu_p4p5/board.h +++ b/board/ryu_p4p5/board.h @@ -29,6 +29,7 @@ #define CONFIG_USB_PD_DUAL_ROLE #define CONFIG_USB_PD_FLASH_ERASE_CHECK #define CONFIG_USB_PD_INTERNAL_COMP +#define CONFIG_USB_PD_PORT_COUNT 1 #define CONFIG_USB_PD_TCPC #define CONFIG_USB_PD_TCPM_STUB #define CONFIG_USB_SWITCH_PI3USB9281 @@ -191,6 +192,29 @@ enum usb_strings { USB_STR_COUNT }; +/* 1.5A Rp */ +#define PD_SRC_VNC PD_SRC_1_5_VNC_MV +#define PD_SRC_RD_THRESHOLD PD_SRC_1_5_RD_THRESH_MV + +/* start as a sink in case we have no other power supply/battery */ +#define PD_DEFAULT_STATE PD_STATE_SNK_DISCONNECTED + +/* delay for the voltage transition on the power supply, chip max is 16us */ +#define PD_POWER_SUPPLY_TURN_ON_DELAY 20000 /* us */ +#define PD_POWER_SUPPLY_TURN_OFF_DELAY 20000 /* us */ + +/* delay to turn on/off vconn */ +#define PD_VCONN_SWAP_DELAY 5000 /* us */ + +/* Define typical operating power and max power */ +#define PD_OPERATING_POWER_MW 10000 +#define PD_MAX_POWER_MW 24000 +#define PD_MAX_CURRENT_MA 3000 +#define PD_MAX_VOLTAGE_MV 20000 + +/* The lower the input voltage, the higher the power efficiency. */ +#define PD_PREFER_LOW_VOLTAGE + /* Discharge battery when on AC power for factory test. */ int board_discharge_on_ac(int enable); diff --git a/board/ryu_p4p5/usb_pd_config.h b/board/ryu_p4p5/usb_pd_config.h index bb7392f450..6cfa5511ba 100644 --- a/board/ryu_p4p5/usb_pd_config.h +++ b/board/ryu_p4p5/usb_pd_config.h @@ -14,11 +14,6 @@ #include "gpio.h" #include "registers.h" -/* Port and task configuration */ -#define PD_PORT_COUNT 1 -#define PORT_TO_TASK_ID(port) TASK_ID_PD -#define TASK_ID_TO_PORT(id) 0 - /* Timer selection for baseband PD communication */ #define TIM_CLOCK_PD_TX_C0 3 #define TIM_CLOCK_PD_RX_C0 2 @@ -197,34 +192,4 @@ static inline void pd_set_vconn(int port, int polarity, int enable) GPIO_USBC_VCONN2_EN_L, !enable); } -static inline int pd_snk_is_vbus_provided(int port) -{ - return gpio_get_level(GPIO_CHGR_ACOK); -} - -/* Standard-current DFP : no-connect voltage is 1.55V */ -#define PD_SRC_VNC 1550 /* mV */ - -/* UFP-side : threshold for DFP connection detection */ -#define PD_SNK_VA 200 /* mV */ - -/* start as a sink in case we have no other power supply/battery */ -#define PD_DEFAULT_STATE PD_STATE_SNK_DISCONNECTED - -/* delay for the voltage transition on the power supply, chip max is 16us */ -#define PD_POWER_SUPPLY_TURN_ON_DELAY 20000 /* us */ -#define PD_POWER_SUPPLY_TURN_OFF_DELAY 20000 /* us */ - -/* delay to turn on/off vconn */ -#define PD_VCONN_SWAP_DELAY 5000 /* us */ - -/* Define typical operating power and max power */ -#define PD_OPERATING_POWER_MW 10000 -#define PD_MAX_POWER_MW 24000 -#define PD_MAX_CURRENT_MA 3000 -#define PD_MAX_VOLTAGE_MV 20000 - -/* The lower the input voltage, the higher the power efficiency. */ -#define PD_PREFER_LOW_VOLTAGE - #endif /* __USB_PD_CONFIG_H */ diff --git a/board/ryu_p4p5/usb_pd_policy.c b/board/ryu_p4p5/usb_pd_policy.c index b20c0774cc..07563aebbd 100644 --- a/board/ryu_p4p5/usb_pd_policy.c +++ b/board/ryu_p4p5/usb_pd_policy.c @@ -101,6 +101,11 @@ void pd_power_supply_reset(int port) gpio_set_level(GPIO_USBC_5V_EN, 0); } +int pd_snk_is_vbus_provided(int port) +{ + return gpio_get_level(GPIO_CHGR_ACOK); +} + int pd_board_checks(void) { return EC_SUCCESS; diff --git a/board/samus_pd/board.c b/board/samus_pd/board.c index 165c8ebe4f..59b562f888 100644 --- a/board/samus_pd/board.c +++ b/board/samus_pd/board.c @@ -25,7 +25,6 @@ #include "task.h" #include "usb.h" #include "usb_pd.h" -#include "usb_pd_config.h" #include "util.h" #define CPRINTS(format, args...) cprints(CC_USBCHARGE, format, ## args) @@ -69,8 +68,8 @@ static int desired_charge_rate_ma = -1; * Store the state of our USB data switches so that they can be restored * after pericom reset. */ -static int usb_switch_state[PD_PORT_COUNT]; -static struct mutex usb_switch_lock[PD_PORT_COUNT]; +static int usb_switch_state[CONFIG_USB_PD_PORT_COUNT]; +static struct mutex usb_switch_lock[CONFIG_USB_PD_PORT_COUNT]; /* PWM channels. Must be in the exact same order as in enum pwm_channel. */ const struct pwm_t pwm_channels[] = { @@ -403,7 +402,7 @@ static void board_init(void) /* Initialize all pericom charge suppliers to 0 */ charge_none.voltage = USB_BC12_CHARGE_VOLTAGE; charge_none.current = 0; - for (i = 0; i < PD_PORT_COUNT; i++) { + for (i = 0; i < CONFIG_USB_PD_PORT_COUNT; i++) { charge_manager_update_charge(CHARGE_SUPPLIER_PROPRIETARY, i, &charge_none); @@ -548,7 +547,7 @@ const struct usb_port_mux usb_muxes[] = { .ss2_dp_mode = GPIO_USB_C1_SS2_DP_MODE, }, }; -BUILD_ASSERT(ARRAY_SIZE(usb_muxes) == PD_PORT_COUNT); +BUILD_ASSERT(ARRAY_SIZE(usb_muxes) == CONFIG_USB_PD_PORT_COUNT); static void board_set_usb_switches(int port, int open) @@ -684,7 +683,8 @@ static void pd_send_ec_int(void) 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 < PD_PORT_COUNT); + int is_real_port = (charge_port >= 0 && + charge_port < CONFIG_USB_PD_PORT_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/samus_pd/board.h b/board/samus_pd/board.h index 5585055f35..dbcd97fec5 100644 --- a/board/samus_pd/board.h +++ b/board/samus_pd/board.h @@ -57,6 +57,7 @@ #define CONFIG_USB_PD_INTERNAL_COMP #define CONFIG_USB_PD_LOGGING #define CONFIG_USB_PD_LOG_SIZE 512 +#define CONFIG_USB_PD_PORT_COUNT 2 #define CONFIG_USB_PD_TCPC #define CONFIG_USB_PD_TCPM_STUB #define CONFIG_USB_SWITCH_PI3USB9281 @@ -129,6 +130,29 @@ enum charge_supplier { /* supplier_priority table defined in board.c */ extern const int supplier_priority[]; +/* Standard-current Rp */ +#define PD_SRC_VNC PD_SRC_DEF_VNC_MV +#define PD_SRC_RD_THRESHOLD PD_SRC_DEF_RD_THRESH_MV + +/* start as a sink in case we have no other power supply/battery */ +#define PD_DEFAULT_STATE PD_STATE_SNK_DISCONNECTED + +/* + * delay to turn on the power supply max is ~16ms. + * delay to turn off the power supply max is about ~180ms. + */ +#define PD_POWER_SUPPLY_TURN_ON_DELAY 30000 /* us */ +#define PD_POWER_SUPPLY_TURN_OFF_DELAY 250000 /* us */ + +/* delay to turn on/off vconn */ +#define PD_VCONN_SWAP_DELAY 5000 /* us */ + +/* Define typical operating power and max power */ +#define PD_OPERATING_POWER_MW 15000 +#define PD_MAX_POWER_MW 60000 +#define PD_MAX_CURRENT_MA 3000 +#define PD_MAX_VOLTAGE_MV 20000 + /* Charge current limit min / max, based on PWM duty cycle */ #define PWM_0_MA 500 #define PWM_100_MA 4000 diff --git a/board/samus_pd/usb_pd_config.h b/board/samus_pd/usb_pd_config.h index b655c8e914..5ec5af9416 100644 --- a/board/samus_pd/usb_pd_config.h +++ b/board/samus_pd/usb_pd_config.h @@ -12,11 +12,6 @@ #ifndef __USB_PD_CONFIG_H #define __USB_PD_CONFIG_H -/* Port and task configuration */ -#define PD_PORT_COUNT 2 -#define PORT_TO_TASK_ID(port) ((port) ? TASK_ID_PD_C1 : TASK_ID_PD_C0) -#define TASK_ID_TO_PORT(id) ((id) == TASK_ID_PD_C0 ? 0 : 1) - /* Timer selection for baseband PD communication */ #define TIM_CLOCK_PD_TX_C0 17 #define TIM_CLOCK_PD_RX_C0 1 @@ -279,35 +274,4 @@ static inline void pd_set_vconn(int port, int polarity, int enable) GPIO_USB_C1_CC2_VCONN1_EN_L, !enable); } -static inline int pd_snk_is_vbus_provided(int port) -{ - return gpio_get_level(port ? GPIO_USB_C1_VBUS_WAKE : - GPIO_USB_C0_VBUS_WAKE); -} - -/* Standard-current DFP : no-connect voltage is 1.55V */ -#define PD_SRC_VNC 1550 /* mV */ - -/* UFP-side : threshold for DFP connection detection */ -#define PD_SNK_VA 200 /* mV */ - -/* start as a sink in case we have no other power supply/battery */ -#define PD_DEFAULT_STATE PD_STATE_SNK_DISCONNECTED - -/* - * delay to turn on the power supply max is ~16ms. - * delay to turn off the power supply max is about ~180ms. - */ -#define PD_POWER_SUPPLY_TURN_ON_DELAY 30000 /* us */ -#define PD_POWER_SUPPLY_TURN_OFF_DELAY 250000 /* us */ - -/* delay to turn on/off vconn */ -#define PD_VCONN_SWAP_DELAY 5000 /* us */ - -/* Define typical operating power and max power */ -#define PD_OPERATING_POWER_MW 15000 -#define PD_MAX_POWER_MW 60000 -#define PD_MAX_CURRENT_MA 3000 -#define PD_MAX_VOLTAGE_MV 20000 - #endif /* __USB_PD_CONFIG_H */ diff --git a/board/samus_pd/usb_pd_policy.c b/board/samus_pd/usb_pd_policy.c index 05df870be9..154a1303e7 100644 --- a/board/samus_pd/usb_pd_policy.c +++ b/board/samus_pd/usb_pd_policy.c @@ -16,7 +16,6 @@ #include "timer.h" #include "util.h" #include "usb_pd.h" -#include "usb_pd_config.h" #define CPRINTF(format, args...) cprintf(CC_USBPD, format, ## args) #define CPRINTS(format, args...) cprints(CC_USBPD, format, ## args) @@ -129,6 +128,12 @@ void typec_set_input_current_limit(int port, uint32_t max_ma, pd_send_host_event(PD_EVENT_POWER_CHANGE); } +int pd_snk_is_vbus_provided(int port) +{ + return gpio_get_level(port ? GPIO_USB_C1_VBUS_WAKE : + GPIO_USB_C0_VBUS_WAKE); +} + int pd_board_checks(void) { return EC_SUCCESS; @@ -257,9 +262,9 @@ int pd_custom_vdm(int port, int cnt, uint32_t *payload, return 0; } -static int dp_flags[PD_PORT_COUNT]; +static int dp_flags[CONFIG_USB_PD_PORT_COUNT]; /* DP Status VDM as returned by UFP */ -static uint32_t dp_status[PD_PORT_COUNT]; +static uint32_t dp_status[CONFIG_USB_PD_PORT_COUNT]; static void svdm_safe_dp_mode(int port) { diff --git a/board/twinkie/board.h b/board/twinkie/board.h index d8550ff9cd..3181be1a2d 100644 --- a/board/twinkie/board.h +++ b/board/twinkie/board.h @@ -21,6 +21,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_TCPC #define CONFIG_USB_PD_TCPM_STUB #define CONFIG_PD_USE_DAC_AS_REF @@ -96,6 +97,23 @@ enum usb_strings { USB_STR_COUNT }; +/* Standard-current Rp */ +#define PD_SRC_VNC PD_SRC_DEF_VNC_MV +#define PD_SRC_RD_THRESHOLD PD_SRC_DEF_RD_THRESH_MV + +/* start as a sink in case we have no other power supply/battery */ +#define PD_DEFAULT_STATE PD_STATE_SNK_DISCONNECTED + +/* delay necessary for the voltage transition on the power supply */ +#define PD_POWER_SUPPLY_TURN_ON_DELAY 50000 /* us */ +#define PD_POWER_SUPPLY_TURN_OFF_DELAY 50000 /* us */ + +/* Define typical operating power and max power */ +#define PD_OPERATING_POWER_MW 15000 +#define PD_MAX_POWER_MW 60000 +#define PD_MAX_CURRENT_MA 3000 +#define PD_MAX_VOLTAGE_MV 20000 + #endif /* !__ASSEMBLER__ */ /* USB interface indexes (use define rather than enum to expand them) */ diff --git a/board/twinkie/injector.c b/board/twinkie/injector.c index 6c5116c9e6..62e1ccd940 100644 --- a/board/twinkie/injector.c +++ b/board/twinkie/injector.c @@ -62,7 +62,6 @@ static const struct res_cfg { {GPIO_C, 0x8000, GPIO_OUT_HIGH} } }, }; -#define PD_SRC_RD_THRESHOLD 200 /* mV */ #define CC_RA(cc) (cc < PD_SRC_RD_THRESHOLD) #define CC_RD(cc) ((cc > PD_SRC_RD_THRESHOLD) && (cc < PD_SRC_VNC)) #define GET_POLARITY(cc1, cc2) (CC_RD(cc2) || CC_RA(cc1)) diff --git a/board/twinkie/usb_pd_config.h b/board/twinkie/usb_pd_config.h index 7645d7500b..73cb7b578f 100644 --- a/board/twinkie/usb_pd_config.h +++ b/board/twinkie/usb_pd_config.h @@ -10,15 +10,6 @@ #include "ina2xx.h" -/* Port and task configuration */ -#define PD_PORT_COUNT 1 -#ifdef HAS_TASK_PD /* PD message injector mode */ -#define PORT_TO_TASK_ID(port) TASK_ID_PD -#else -#define PORT_TO_TASK_ID(port) -1 -#endif -#define TASK_ID_TO_PORT(id) 0 - /* Timer selection for baseband PD communication */ #define TIM_CLOCK_PD_TX_C0 17 #define TIM_CLOCK_PD_RX_C0 1 @@ -186,29 +177,4 @@ static inline int pd_adc_read(int port, int cc) return adc_read_channel(ADC_CH_CC2_PD); } -static inline int pd_snk_is_vbus_provided(int port) -{ - /* assume the alert was programmed to detect bus voltage above 4.5V */ - return (gpio_get_level(GPIO_VBUS_ALERT_L) == 0); -} - -/* Standard-current DFP : no-connect voltage is 1.55V */ -#define PD_SRC_VNC 1550 /* mV */ - -/* UFP-side : threshold for DFP connection detection */ -#define PD_SNK_VA 200 /* mV */ - -/* start as a sink in case we have no other power supply/battery */ -#define PD_DEFAULT_STATE PD_STATE_SNK_DISCONNECTED - -/* delay necessary for the voltage transition on the power supply */ -#define PD_POWER_SUPPLY_TURN_ON_DELAY 50000 /* us */ -#define PD_POWER_SUPPLY_TURN_OFF_DELAY 50000 /* us */ - -/* Define typical operating power and max power */ -#define PD_OPERATING_POWER_MW 15000 -#define PD_MAX_POWER_MW 60000 -#define PD_MAX_CURRENT_MA 3000 -#define PD_MAX_VOLTAGE_MV 20000 - #endif /* __USB_PD_CONFIG_H */ diff --git a/board/twinkie/usb_pd_policy.c b/board/twinkie/usb_pd_policy.c index 8b19031f32..0553bdad3c 100644 --- a/board/twinkie/usb_pd_policy.c +++ b/board/twinkie/usb_pd_policy.c @@ -89,6 +89,12 @@ void pd_power_supply_reset(int port) { } +int pd_snk_is_vbus_provided(int port) +{ + /* assume the alert was programmed to detect bus voltage above 4.5V */ + return (gpio_get_level(GPIO_VBUS_ALERT_L) == 0); +} + int pd_board_checks(void) { return EC_SUCCESS; diff --git a/board/zinger/board.h b/board/zinger/board.h index 49a8064c36..1b94b30064 100644 --- a/board/zinger/board.h +++ b/board/zinger/board.h @@ -57,6 +57,7 @@ #undef CONFIG_USB_PD_INTERNAL_COMP #define CONFIG_USB_PD_LOGGING #define CONFIG_USB_PD_LOG_SIZE 256 +#define CONFIG_USB_PD_PORT_COUNT 1 #define CONFIG_USB_PD_TCPC #define CONFIG_USB_PD_TCPM_STUB #undef CONFIG_USB_PD_RX_COMP_IRQ @@ -97,6 +98,16 @@ enum adc_channel { /* captive cable : no CC2 */ #define ADC_CH_CC2_PD ADC_CH_CC1_PD +/* 3.0A Rp */ +#define PD_SRC_VNC (PD_SRC_3_0_VNC_MV * 4096 / 3300/* 12-bit ADC, 3.3V range */) + +/* we are a power supply, boot as a power source waiting for a sink */ +#define PD_DEFAULT_STATE PD_STATE_SRC_DISCONNECTED + +/* delay necessary for the voltage transition on the power supply */ +#define PD_POWER_SUPPLY_TURN_ON_DELAY 50000 /* us */ +#define PD_POWER_SUPPLY_TURN_OFF_DELAY 50000 /* us */ + /* Initialize all useful registers */ void hardware_init(void); diff --git a/board/zinger/usb_pd_config.h b/board/zinger/usb_pd_config.h index f31087fab2..7541285429 100644 --- a/board/zinger/usb_pd_config.h +++ b/board/zinger/usb_pd_config.h @@ -8,13 +8,6 @@ #ifndef __USB_PD_CONFIG_H #define __USB_PD_CONFIG_H -/* Port and task configuration */ -#define PD_PORT_COUNT 1 -/* Stub value */ -#define TASK_ID_PD 0 -#define PORT_TO_TASK_ID(port) TASK_ID_PD -#define TASK_ID_TO_PORT(id) 0 - /* Timer selection for baseband PD communication */ #define TIM_CLOCK_PD_TX_C0 14 #define TIM_CLOCK_PD_RX_C0 3 @@ -113,14 +106,4 @@ static inline int pd_adc_read(int port, int cc) return (cc == 0) ? adc_read_channel(ADC_CH_CC1_PD) : 4096; } -/* 3.0A DFP : no-connect voltage is 2.45V */ -#define PD_SRC_VNC (2450 /*mV*/ * 4096 / 3300/* 12-bit ADC with 3.3V range */) - -/* we are a power supply, boot as a power source waiting for a sink */ -#define PD_DEFAULT_STATE PD_STATE_SRC_DISCONNECTED - -/* delay necessary for the voltage transition on the power supply */ -#define PD_POWER_SUPPLY_TURN_ON_DELAY 50000 /* us */ -#define PD_POWER_SUPPLY_TURN_OFF_DELAY 50000 /* us */ - #endif /* __USB_PD_CONFIG_H */ diff --git a/chip/host/usb_pd_phy.c b/chip/host/usb_pd_phy.c index 4f2e7640f0..1a8e74b97e 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[PD_PORT_COUNT]; +} pd_phy[CONFIG_USB_PD_PORT_COUNT]; static const uint16_t enc4b5b[] = { 0x1E, 0x09, 0x14, 0x15, 0x0A, 0x0B, 0x0E, 0x0F, 0x12, 0x13, 0x16, diff --git a/chip/stm32/usb_pd_phy.c b/chip/stm32/usb_pd_phy.c index 4fd495d769..e3156e79d6 100644 --- a/chip/stm32/usb_pd_phy.c +++ b/chip/stm32/usb_pd_phy.c @@ -70,14 +70,14 @@ static struct pd_physical { /* Pointers to timer register for each port */ timer_ctlr_t *tim_tx; timer_ctlr_t *tim_rx; -} pd_phy[PD_PORT_COUNT]; +} pd_phy[CONFIG_USB_PD_PORT_COUNT]; /* keep track of RX edge timing in order to trigger receive */ -static timestamp_t rx_edge_ts[PD_PORT_COUNT][PD_RX_TRANSITION_COUNT]; -static int rx_edge_ts_idx[PD_PORT_COUNT]; +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]; /* keep track of transmit polarity for DMA interrupt */ -static int tx_dma_polarities[PD_PORT_COUNT]; +static int tx_dma_polarities[CONFIG_USB_PD_PORT_COUNT]; void pd_init_dequeue(int port) { @@ -302,7 +302,7 @@ static void tx_dma_done(void *data) pd_phy[port].tim_tx->cr1 &= ~1; #if defined(CONFIG_COMMON_RUNTIME) && defined(CONFIG_DMA_DEFAULT_HANDLERS) - task_set_event(PORT_TO_TASK_ID(port), TASK_EVENT_DMA_TC, 0); + task_set_event(PD_PORT_TO_TASK_ID(port), TASK_EVENT_DMA_TC, 0); #endif } @@ -456,7 +456,7 @@ void pd_rx_handler(void) int next_idx; pending = STM32_EXTI_PR; - for (i = 0; i < PD_PORT_COUNT; i++) { + for (i = 0; i < CONFIG_USB_PD_PORT_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 7e0600d8d9..b52f297c45 100644 --- a/common/charge_manager.c +++ b/common/charge_manager.c @@ -13,7 +13,6 @@ #include "system.h" #include "timer.h" #include "usb_pd.h" -#include "usb_pd_config.h" #include "util.h" #define CPRINTS(format, args...) cprints(CC_USBCHARGE, format, ## args) @@ -26,23 +25,23 @@ /* Keep track of available charge for each charge port. */ static struct charge_port_info available_charge[CHARGE_SUPPLIER_COUNT] - [PD_PORT_COUNT]; + [CONFIG_USB_PD_PORT_COUNT]; /* Keep track of when the supplier on each port is registered. */ -static timestamp_t registration_time[PD_PORT_COUNT]; +static timestamp_t registration_time[CONFIG_USB_PD_PORT_COUNT]; /* * Charge ceiling for ports. This can be set to temporarily limit the charge * pulled from a port, without influencing the port selection logic. */ -static int charge_ceil[PD_PORT_COUNT]; +static int charge_ceil[CONFIG_USB_PD_PORT_COUNT]; /* Dual-role capability of attached partner port */ -static enum dualrole_capabilities dualrole_capability[PD_PORT_COUNT]; +static enum dualrole_capabilities dualrole_capability[CONFIG_USB_PD_PORT_COUNT]; #ifdef CONFIG_USB_PD_LOGGING /* Mark port as dirty when making changes, for later logging */ -static int save_log[PD_PORT_COUNT]; +static int save_log[CONFIG_USB_PD_PORT_COUNT]; #endif /* Store current state of port enable / charge current. */ @@ -69,7 +68,7 @@ static void charge_manager_init(void) { int i, j; - for (i = 0; i < PD_PORT_COUNT; ++i) { + for (i = 0; i < CONFIG_USB_PD_PORT_COUNT; ++i) { for (j = 0; j < CHARGE_SUPPLIER_COUNT; ++j) { available_charge[j][i].current = CHARGE_CURRENT_UNINITIALIZED; @@ -96,7 +95,7 @@ static int charge_manager_is_seeded(void) return 1; for (i = 0; i < CHARGE_SUPPLIER_COUNT; ++i) - for (j = 0; j < PD_PORT_COUNT; ++j) + for (j = 0; j < CONFIG_USB_PD_PORT_COUNT; ++j) if (available_charge[i][j].current == CHARGE_CURRENT_UNINITIALIZED || available_charge[i][j].voltage == @@ -251,7 +250,7 @@ void charge_manager_save_log(int port) uint16_t flags = 0; struct ec_response_usb_pd_power_info pinfo; - if (port < 0 || port >= PD_PORT_COUNT) + if (port < 0 || port >= CONFIG_USB_PD_PORT_COUNT) return; save_log[port] = 0; @@ -278,7 +277,7 @@ void charge_manager_save_log(int port) */ static void charge_manager_cleanup_override_port(int port) { - if (port < 0 || port >= PD_PORT_COUNT) + if (port < 0 || port >= CONFIG_USB_PD_PORT_COUNT) return; if (dualrole_capability[port] == CAP_DUALROLE && @@ -310,7 +309,7 @@ static void charge_manager_get_best_charge_port(int *new_port, * so make no assumptions about its consistency. */ for (i = 0; i < CHARGE_SUPPLIER_COUNT; ++i) - for (j = 0; j < PD_PORT_COUNT; ++j) { + for (j = 0; j < CONFIG_USB_PD_PORT_COUNT; ++j) { /* * Skip this supplier if there is no * available charge. @@ -490,7 +489,7 @@ static void charge_manager_refresh(void) if (updated_old_port != CHARGE_PORT_NONE) save_log[updated_old_port] = 1; - for (i = 0; i < PD_PORT_COUNT; ++i) + for (i = 0; i < CONFIG_USB_PD_PORT_COUNT; ++i) if (save_log[i]) charge_manager_save_log(i); #endif @@ -601,7 +600,7 @@ void charge_manager_update_charge(int supplier, struct charge_port_info *charge) { ASSERT(supplier >= 0 && supplier < CHARGE_SUPPLIER_COUNT); - ASSERT(port >= 0 && port < PD_PORT_COUNT); + ASSERT(port >= 0 && port < CONFIG_USB_PD_PORT_COUNT); ASSERT(charge != NULL); charge_manager_make_change(CHANGE_CHARGE, supplier, port, charge); @@ -615,7 +614,7 @@ void charge_manager_update_charge(int supplier, */ void charge_manager_update_dualrole(int port, enum dualrole_capabilities cap) { - ASSERT(port >= 0 && port < PD_PORT_COUNT); + ASSERT(port >= 0 && port < CONFIG_USB_PD_PORT_COUNT); /* * We have no way of determining the charger dualrole capability in @@ -639,7 +638,7 @@ void charge_manager_update_dualrole(int port, enum dualrole_capabilities cap) */ void charge_manager_set_ceil(int port, int ceil) { - ASSERT(port >= 0 && port < PD_PORT_COUNT); + ASSERT(port >= 0 && port < CONFIG_USB_PD_PORT_COUNT); if (charge_ceil[port] != ceil) { charge_ceil[port] = ceil; @@ -661,7 +660,7 @@ int charge_manager_set_override(int port) { int retval = EC_SUCCESS; - ASSERT(port >= OVERRIDE_DONT_CHARGE && port < PD_PORT_COUNT); + ASSERT(port >= OVERRIDE_DONT_CHARGE && port < CONFIG_USB_PD_PORT_COUNT); CPRINTS("Charge Override: %d", port); @@ -748,7 +747,7 @@ static int hc_charge_port_override(struct host_cmd_handler_args *args) const int16_t override_port = p->override_port; if (override_port < OVERRIDE_DONT_CHARGE || - override_port >= PD_PORT_COUNT) + override_port >= CONFIG_USB_PD_PORT_COUNT) return EC_RES_INVALID_PARAM; return charge_manager_set_override(override_port); @@ -765,7 +764,8 @@ static int command_charge_port_override(int argc, char **argv) if (argc >= 2) { port = strtoi(argv[1], &e, 0); - if (*e || port < OVERRIDE_DONT_CHARGE || port >= PD_PORT_COUNT) + if (*e || port < OVERRIDE_DONT_CHARGE || + port >= CONFIG_USB_PD_PORT_COUNT) return EC_ERROR_PARAM1; ret = charge_manager_set_override(port); } diff --git a/common/charge_ramp.c b/common/charge_ramp.c index 059648a88b..cc71f987b6 100644 --- a/common/charge_ramp.c +++ b/common/charge_ramp.c @@ -13,7 +13,6 @@ #include "task.h" #include "timer.h" #include "usb_pd.h" -#include "usb_pd_config.h" #include "util.h" #define CPRINTS(format, args...) cprints(CC_USBCHARGE, format, ## args) @@ -59,8 +58,8 @@ struct oc_info { }; /* OCP info for each over-current */ -static struct oc_info oc_info[PD_PORT_COUNT][RAMP_COUNT]; -static int oc_info_idx[PD_PORT_COUNT]; +static struct oc_info oc_info[CONFIG_USB_PD_PORT_COUNT][RAMP_COUNT]; +static int oc_info_idx[CONFIG_USB_PD_PORT_COUNT]; #define ACTIVE_OC_INFO (oc_info[active_port][oc_info_idx[active_port]]) /* Active charging information */ @@ -160,7 +159,7 @@ void chg_ramp_task(void) int active_icl_new; /* Clear last OCP supplier to guarantee we ramp on first connect */ - for (i = 0; i < PD_PORT_COUNT; i++) + for (i = 0; i < CONFIG_USB_PD_PORT_COUNT; i++) oc_info[i][0].sup = CHARGE_SUPPLIER_NONE; while (1) { @@ -347,7 +346,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 < PD_PORT_COUNT; port++) { + for (port = 0; port < CONFIG_USB_PD_PORT_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/pd_log.c b/common/pd_log.c index 96d55f9330..333a22b7bb 100644 --- a/common/pd_log.c +++ b/common/pd_log.c @@ -10,9 +10,6 @@ #include "task.h" #include "timer.h" #include "usb_pd.h" -#ifdef HAS_TASK_HOSTCMD -#include "usb_pd_config.h" -#endif #include "util.h" /* Event log FIFO */ @@ -176,7 +173,7 @@ dequeue_retry: if (r->type == PD_EVENT_NO_ENTRY) { int i, res; incoming_logs = 0; - for (i = 0; i < PD_PORT_COUNT; ++i) { + for (i = 0; i < CONFIG_USB_PD_PORT_COUNT; ++i) { /* only accessories who knows Google logging format */ if (pd_get_identity_vid(i) != USB_VID_GOOGLE) continue; @@ -204,7 +201,7 @@ static int 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 >= PD_PORT_COUNT) + if (port > 0 && port >= CONFIG_USB_PD_PORT_COUNT) return EC_RES_INVALID_PARAM; switch (type) { diff --git a/common/usb_pd_policy.c b/common/usb_pd_policy.c index 4ab8f870a3..36ecba8fc6 100644 --- a/common/usb_pd_policy.c +++ b/common/usb_pd_policy.c @@ -2,7 +2,7 @@ * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ -#include "adc.h" + #include "atomic.h" #include "charge_manager.h" #include "common.h" @@ -20,7 +20,6 @@ #include "util.h" #include "usb_api.h" #include "usb_pd.h" -#include "usb_pd_config.h" #include "version.h" #ifdef CONFIG_COMMON_RUNTIME @@ -193,7 +192,7 @@ int pd_charge_from_device(uint16_t vid, uint16_t pid) #ifdef CONFIG_USB_PD_ALT_MODE_DFP -static struct pd_policy pe[PD_PORT_COUNT]; +static struct pd_policy pe[CONFIG_USB_PD_PORT_COUNT]; void pd_dfp_pe_init(int port) { @@ -555,7 +554,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 >= PD_PORT_COUNT) + if (*e || port >= CONFIG_USB_PD_PORT_COUNT) return EC_ERROR_PARAM2; if (!strncasecmp(argv[2], "dump", 4)) dump_pe(port); @@ -770,7 +769,7 @@ static int 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 >= PD_PORT_COUNT) + if (*port >= CONFIG_USB_PD_PORT_COUNT) return EC_RES_INVALID_PARAM; r->vid = pd_get_identity_vid(*port); @@ -792,7 +791,7 @@ static int 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 >= PD_PORT_COUNT) + if (p->port >= CONFIG_USB_PD_PORT_COUNT) return EC_RES_INVALID_PARAM; /* no more to send */ diff --git a/common/usb_pd_protocol.c b/common/usb_pd_protocol.c index 639c62e5f7..d8393f118c 100644 --- a/common/usb_pd_protocol.c +++ b/common/usb_pd_protocol.c @@ -3,7 +3,6 @@ * found in the LICENSE file. */ -#include "adc.h" #include "battery.h" #include "board.h" #include "case_closed_debug.h" @@ -21,7 +20,6 @@ #include "timer.h" #include "util.h" #include "usb_pd.h" -#include "usb_pd_config.h" #include "usb_pd_tcpm.h" #include "version.h" @@ -86,8 +84,8 @@ enum vdm_states { enum pd_dual_role_states drp_state = PD_DRP_TOGGLE_OFF; /* Last received source cap */ -static uint32_t pd_src_caps[PD_PORT_COUNT][PDO_MAX_OBJECTS]; -static int pd_src_cap_cnt[PD_PORT_COUNT]; +static uint32_t pd_src_caps[CONFIG_USB_PD_PORT_COUNT][PDO_MAX_OBJECTS]; +static int pd_src_cap_cnt[CONFIG_USB_PD_PORT_COUNT]; #endif static struct pd_protocol { @@ -144,7 +142,7 @@ static struct pd_protocol { uint16_t dev_id; uint32_t dev_rw_hash[PD_RW_HASH_SIZE/4]; enum ec_current_image current_image; -} pd[PD_PORT_COUNT]; +} pd[CONFIG_USB_PD_PORT_COUNT]; #ifdef CONFIG_COMMON_RUNTIME static const char * const pd_state_names[] = { @@ -257,11 +255,11 @@ static inline void set_state(int port, enum pd_states next_state) #ifdef CONFIG_LOW_POWER_IDLE /* If any PD port is connected, then disable deep sleep */ - for (i = 0; i < PD_PORT_COUNT; i++) { + for (i = 0; i < CONFIG_USB_PD_PORT_COUNT; i++) { if (pd_is_connected(i)) break; } - if (i == PD_PORT_COUNT) + if (i == CONFIG_USB_PD_PORT_COUNT) enable_sleep(SLEEP_MASK_USB_PD); else disable_sleep(SLEEP_MASK_USB_PD); @@ -282,7 +280,7 @@ static void pd_transmit_complete(int port, int status) inc_id(port); pd[port].tx_status = status; - task_set_event(PORT_TO_TASK_ID(port), PD_EVENT_TX, 0); + task_set_event(PD_PORT_TO_TASK_ID(port), PD_EVENT_TX, 0); } static int pd_transmit(int port, enum tcpm_transmit_type type, @@ -501,10 +499,10 @@ void pd_soft_reset(void) { int i; - for (i = 0; i < PD_PORT_COUNT; ++i) + for (i = 0; i < CONFIG_USB_PD_PORT_COUNT; ++i) if (pd_is_connected(i)) { set_state(i, PD_STATE_SOFT_RESET); - task_wake(PORT_TO_TASK_ID(i)); + task_wake(PD_PORT_TO_TASK_ID(i)); } } @@ -520,7 +518,7 @@ void pd_prepare_sysjump(void) * is complete so that the communication starts over without dropping * power. */ - for (i = 0; i < PD_PORT_COUNT; ++i) + for (i = 0; i < CONFIG_USB_PD_PORT_COUNT; ++i) if (pd_is_connected(i)) pd[i].flags |= PD_FLAGS_SFT_RST_DIS_COMM; @@ -734,7 +732,7 @@ void pd_request_power_swap(int port) set_state(port, PD_STATE_SRC_SWAP_INIT); else if (pd[port].task_state == PD_STATE_SNK_READY) set_state(port, PD_STATE_SNK_SWAP_INIT); - task_wake(PORT_TO_TASK_ID(port)); + task_wake(PD_PORT_TO_TASK_ID(port)); } #endif @@ -744,7 +742,7 @@ void pd_request_data_swap(int port) pd[port].task_state == PD_STATE_SNK_READY, pd[port].task_state == PD_STATE_SRC_READY)) set_state(port, PD_STATE_DR_SWAP); - task_wake(PORT_TO_TASK_ID(port)); + task_wake(PD_PORT_TO_TASK_ID(port)); } static void pd_set_data_role(int port, int role) @@ -989,7 +987,7 @@ void pd_send_vdm(int port, uint32_t vid, int cmd, const uint32_t *data, 1 : (PD_VDO_CMD(cmd) < CMD_ATTENTION), cmd); queue_vdm(port, pd[port].vdo_data, data, count); - task_wake(PORT_TO_TASK_ID(port)); + task_wake(PD_PORT_TO_TASK_ID(port)); } static inline int pdo_busy(int port) @@ -1137,7 +1135,7 @@ void pd_set_dual_role(enum pd_dual_role_states state) int i; drp_state = state; - for (i = 0; i < PD_PORT_COUNT; i++) { + for (i = 0; i < CONFIG_USB_PD_PORT_COUNT; i++) { /* * Change to sink if port is currently a source AND (new DRP * state is force sink OR new DRP state is toggle off and we @@ -1150,7 +1148,7 @@ void pd_set_dual_role(enum pd_dual_role_states state) pd[i].power_role = PD_ROLE_SINK; set_state(i, PD_STATE_SNK_DISCONNECTED); tcpm_set_cc(i, TYPEC_CC_RD); - task_wake(PORT_TO_TASK_ID(i)); + task_wake(PD_PORT_TO_TASK_ID(i)); } /* @@ -1162,7 +1160,7 @@ void pd_set_dual_role(enum pd_dual_role_states state) pd[i].power_role = PD_ROLE_SOURCE; set_state(i, PD_STATE_SRC_DISCONNECTED); tcpm_set_cc(i, TYPEC_CC_RP); - task_wake(PORT_TO_TASK_ID(i)); + task_wake(PD_PORT_TO_TASK_ID(i)); } } } @@ -1208,7 +1206,7 @@ void pd_comm_enable(int enable) */ if (enable) { int i; - for (i = 0; i < PD_PORT_COUNT; i++) { + for (i = 0; i < CONFIG_USB_PD_PORT_COUNT; i++) { if (pd[i].task_state == PD_STATE_SNK_DISCOVERY) set_state_timeout(i, get_time().val + @@ -1253,7 +1251,7 @@ static inline int get_typec_current_limit(int cc) void pd_set_new_power_request(int port) { pd[port].new_power_request = 1; - task_wake(PORT_TO_TASK_ID(port)); + task_wake(PD_PORT_TO_TASK_ID(port)); } #endif /* CONFIG_CHARGE_MANAGER */ @@ -1269,7 +1267,7 @@ void pd_set_new_power_request(int port) void pd_task(void) { int head; - int port = TASK_ID_TO_PORT(task_get_current()); + int port = TASK_ID_TO_PD_PORT(task_get_current()); uint32_t payload[7]; int timeout = 10*MSEC; int cc1, cc2; @@ -2350,18 +2348,18 @@ void tcpc_alert(void) int status, i; /* loop over ports and check alert status */ - for (i = 0; i < PD_PORT_COUNT; i++) { + for (i = 0; i < CONFIG_USB_PD_PORT_COUNT; i++) { tcpm_alert_status(i, TCPC_REG_ALERT1, (uint8_t *)&status); if (status & TCPC_REG_ALERT1_CC_STATUS) { /* CC status changed, wake task */ - task_set_event(PORT_TO_TASK_ID(i), PD_EVENT_CC, 0); + task_set_event(PD_PORT_TO_TASK_ID(i), PD_EVENT_CC, 0); } else if (status & TCPC_REG_ALERT1_RX_STATUS) { /* message received */ - task_set_event(PORT_TO_TASK_ID(i), PD_EVENT_RX, 0); + task_set_event(PD_PORT_TO_TASK_ID(i), PD_EVENT_RX, 0); } else if (status & TCPC_REG_ALERT1_RX_HARD_RST) { /* hard reset received */ execute_hard_reset(i); - task_wake(PORT_TO_TASK_ID(i)); + task_wake(PD_PORT_TO_TASK_ID(i)); } else if (status & TCPC_REG_ALERT1_TX_COMPLETE) { /* transmit complete */ pd_transmit_complete(i, status); @@ -2377,7 +2375,7 @@ static void dual_role_on(void) pd_set_dual_role(PD_DRP_TOGGLE_ON); CPRINTS("chipset -> S0"); - for (i = 0; i < PD_PORT_COUNT; i++) { + for (i = 0; i < CONFIG_USB_PD_PORT_COUNT; i++) { #ifdef CONFIG_CHARGE_MANAGER if (charge_manager_get_active_charge_port() != i) #endif @@ -2421,7 +2419,7 @@ void pd_set_suspend(int port, int enable) { set_state(port, enable ? PD_STATE_SUSPENDED : PD_DEFAULT_STATE); - task_wake(PORT_TO_TASK_ID(port)); + task_wake(PD_PORT_TO_TASK_ID(port)); } #if defined(CONFIG_CMD_PD) && defined(CONFIG_CMD_PD_FLASH) @@ -2452,13 +2450,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[PD_PORT_COUNT]; + static int flash_offset[CONFIG_USB_PD_PORT_COUNT]; if (argc < 4 || argc > (VDO_MAX_SIZE + 4 - 1)) return EC_ERROR_PARAM_COUNT; port = strtoi(argv[1], &e, 10); - if (*e || port >= PD_PORT_COUNT) + if (*e || port >= CONFIG_USB_PD_PORT_COUNT) return EC_ERROR_PARAM2; cnt = 0; @@ -2566,7 +2564,7 @@ void pd_request_source_voltage(int port, int mv) set_state(port, PD_STATE_SNK_DISCONNECTED); } - task_wake(PORT_TO_TASK_ID(port)); + task_wake(PD_PORT_TO_TASK_ID(port)); } #endif /* CONFIG_USB_PD_DUAL_ROLE */ @@ -2656,26 +2654,26 @@ 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 >= PD_PORT_COUNT) + if (*e || port >= CONFIG_USB_PD_PORT_COUNT) return EC_ERROR_PARAM2; #if defined(CONFIG_CMD_PD) && defined(CONFIG_USB_PD_DUAL_ROLE) if (!strcasecmp(argv[2], "tx")) { set_state(port, PD_STATE_SNK_DISCOVERY); - task_wake(PORT_TO_TASK_ID(port)); + task_wake(PD_PORT_TO_TASK_ID(port)); } else if (!strcasecmp(argv[2], "bist_rx")) { set_state(port, PD_STATE_BIST_RX); - task_wake(PORT_TO_TASK_ID(port)); + task_wake(PD_PORT_TO_TASK_ID(port)); } else if (!strcasecmp(argv[2], "bist_tx")) { if (*e) return EC_ERROR_PARAM3; set_state(port, PD_STATE_BIST_TX); - task_wake(PORT_TO_TASK_ID(port)); + task_wake(PD_PORT_TO_TASK_ID(port)); } else if (!strcasecmp(argv[2], "charger")) { pd[port].power_role = PD_ROLE_SOURCE; tcpm_set_cc(port, TYPEC_CC_RP); set_state(port, PD_STATE_SRC_DISCONNECTED); - task_wake(PORT_TO_TASK_ID(port)); + task_wake(PD_PORT_TO_TASK_ID(port)); } else if (!strncasecmp(argv[2], "dev", 3)) { int max_volt; if (argc >= 4) @@ -2687,7 +2685,7 @@ static int command_pd(int argc, char **argv) ccprintf("max req: %dmV\n", max_volt); } else if (!strncasecmp(argv[2], "hard", 4)) { set_state(port, PD_STATE_HARD_RESET_SEND); - task_wake(PORT_TO_TASK_ID(port)); + task_wake(PD_PORT_TO_TASK_ID(port)); } else if (!strncasecmp(argv[2], "info", 4)) { int i; ccprintf("Hash "); @@ -2697,7 +2695,7 @@ static int command_pd(int argc, char **argv) pd[port].current_image)); } else if (!strncasecmp(argv[2], "soft", 4)) { set_state(port, PD_STATE_SOFT_RESET); - task_wake(PORT_TO_TASK_ID(port)); + task_wake(PD_PORT_TO_TASK_ID(port)); } else if (!strncasecmp(argv[2], "swap", 4)) { if (argc < 4) return EC_ERROR_PARAM_COUNT; @@ -2709,7 +2707,7 @@ static int command_pd(int argc, char **argv) #ifdef CONFIG_USBC_VCONN_SWAP } else if (!strncasecmp(argv[3], "vconn", 5)) { set_state(port, PD_STATE_VCONN_SWAP_SEND); - task_wake(PORT_TO_TASK_ID(port)); + task_wake(PD_PORT_TO_TASK_ID(port)); #endif } else { return EC_ERROR_PARAM3; @@ -2793,14 +2791,13 @@ static int command_typec(int argc, char **argv) return EC_ERROR_PARAM_COUNT; port = strtoi(argv[1], &e, 10); - if (*e || port >= PD_PORT_COUNT) + if (*e || port >= CONFIG_USB_PD_PORT_COUNT) return EC_ERROR_PARAM1; if (argc < 3) { const char *dp_str, *usb_str; - ccprintf("Port C%d: CC1 %d mV CC2 %d mV (polarity:CC%d)\n", - port, pd_adc_read(port, 0), pd_adc_read(port, 1), - pd_get_polarity(port) + 1); + ccprintf("Port C%d: polarity:CC%d\n", + port, pd_get_polarity(port) + 1); if (board_get_usb_mux(port, &dp_str, &usb_str)) ccprintf("Superspeed %s%s%s\n", dp_str ? dp_str : "", @@ -2833,7 +2830,7 @@ DECLARE_CONSOLE_COMMAND(typec, command_typec, static int hc_pd_ports(struct host_cmd_handler_args *args) { struct ec_response_usb_pd_ports *r = args->response; - r->num_ports = PD_PORT_COUNT; + r->num_ports = CONFIG_USB_PD_PORT_COUNT; args->response_size = sizeof(*r); return EC_RES_SUCCESS; @@ -2865,7 +2862,7 @@ static int 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 >= PD_PORT_COUNT) + if (p->port >= CONFIG_USB_PD_PORT_COUNT) return EC_RES_INVALID_PARAM; if (p->role >= USB_PD_CTRL_ROLE_COUNT || @@ -2915,7 +2912,7 @@ static int hc_remote_flash(struct host_cmd_handler_args *args) int i, size, rv = EC_RES_SUCCESS; timestamp_t timeout; - if (port >= PD_PORT_COUNT) + if (port >= CONFIG_USB_PD_PORT_COUNT) return EC_RES_INVALID_PARAM; if (p->size + sizeof(*p) > args->params_size) @@ -3040,7 +3037,7 @@ static int 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 >= PD_PORT_COUNT) + if (*port >= CONFIG_USB_PD_PORT_COUNT) return EC_RES_INVALID_PARAM; r->dev_id = pd[*port].dev_id; @@ -3065,7 +3062,7 @@ static int 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 >= PD_PORT_COUNT) || (!p->svid) || (!p->opos)) + if ((p->port >= CONFIG_USB_PD_PORT_COUNT) || (!p->svid) || (!p->opos)) return EC_RES_INVALID_PARAM; switch (p->cmd) { diff --git a/common/usb_pd_tcpc.c b/common/usb_pd_tcpc.c index 272b84458c..bd99bebcec 100644 --- a/common/usb_pd_tcpc.c +++ b/common/usb_pd_tcpc.c @@ -157,8 +157,12 @@ static const uint8_t dec4b5b[] = { * Note, V(Rd) > V(Ra) */ #ifndef PD_SRC_RD_THRESHOLD -#define PD_SRC_RD_THRESHOLD 200 /* mV */ +#define PD_SRC_RD_THRESHOLD PD_SRC_DEF_RD_THRESH_MV #endif +#ifndef PD_SRC_VNC +#define PD_SRC_VNC PD_SRC_DEF_VNC_MV +#endif + #define CC_RA(cc) (cc < PD_SRC_RD_THRESHOLD) #define CC_RD(cc) ((cc >= PD_SRC_RD_THRESHOLD) && (cc < PD_SRC_VNC)) #define CC_NC(cc) (cc >= PD_SRC_VNC) @@ -173,6 +177,10 @@ static const uint8_t dec4b5b[] = { * open Rp DFP attached 2 * Rp Rp Accessory attached N/A */ +#ifndef PD_SNK_VA +#define PD_SNK_VA PD_SNK_VA_MV +#endif + #define CC_RP(cc) (cc >= PD_SNK_VA) /* @@ -218,7 +226,7 @@ static struct pd_port_controller { uint16_t tx_head; uint32_t tx_payload[7]; const uint32_t *tx_data; -} pd[PD_PORT_COUNT]; +} pd[CONFIG_USB_PD_PORT_COUNT]; static inline int encode_short(int port, int off, uint16_t val16) { @@ -788,7 +796,7 @@ int tcpc_run(int port, int evt) #ifndef CONFIG_USB_POWER_DELIVERY void pd_task(void) { - int port = TASK_ID_TO_PORT(task_get_current()); + int port = TASK_ID_TO_PD_PORT(task_get_current()); int timeout = 10*MSEC; int evt; @@ -807,7 +815,7 @@ void pd_task(void) void pd_rx_event(int port) { - task_set_event(PORT_TO_TASK_ID(port), PD_EVENT_RX, 0); + task_set_event(PD_PORT_TO_TASK_ID(port), PD_EVENT_RX, 0); } int tcpc_alert_status(int port, int alert_reg, uint8_t *alert) @@ -846,7 +854,7 @@ int tcpc_set_cc(int port, int pull) #ifdef CONFIG_USB_POWER_DELIVERY tcpc_run(port, PD_EVENT_CC); #else - task_set_event(PORT_TO_TASK_ID(port), PD_EVENT_CC, 0); + task_set_event(PD_PORT_TO_TASK_ID(port), PD_EVENT_CC, 0); #endif return EC_SUCCESS; } @@ -886,7 +894,7 @@ int tcpc_transmit(int port, enum tcpm_transmit_type type, uint16_t header, #ifdef CONFIG_USB_POWER_DELIVERY tcpc_run(port, PD_EVENT_TX); #else - task_set_event(PORT_TO_TASK_ID(port), PD_EVENT_TX, 0); + task_set_event(PD_PORT_TO_TASK_ID(port), PD_EVENT_TX, 0); #endif return EC_SUCCESS; } @@ -1077,7 +1085,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 >= PD_PORT_COUNT) + if (*e || port >= CONFIG_USB_PD_PORT_COUNT) return EC_ERROR_PARAM2; if (!strcasecmp(argv[2], "clock")) { diff --git a/include/config.h b/include/config.h index a824744896..ddea4d8d30 100644 --- a/include/config.h +++ b/include/config.h @@ -1329,6 +1329,9 @@ /* Define if USB-PD device has no way of detecting USB VBUS */ #undef CONFIG_USB_PD_NO_VBUS_DETECT +/* Number of USB PD ports */ +#undef CONFIG_USB_PD_PORT_COUNT + /* Simple DFP, such as power adapter, will not send discovery VDM on connect */ #undef CONFIG_USB_PD_SIMPLE_DFP diff --git a/include/ec_commands.h b/include/ec_commands.h index 8a05d0ab5b..c1b5637af6 100644 --- a/include/ec_commands.h +++ b/include/ec_commands.h @@ -3075,7 +3075,7 @@ struct ec_params_usb_pd_discovery_entry { enum usb_pd_override_ports { OVERRIDE_DONT_CHARGE = -2, OVERRIDE_OFF = -1, - /* [0, PD_PORT_COUNT): Port# */ + /* [0, CONFIG_USB_PD_PORT_COUNT): Port# */ }; struct ec_params_charge_port_override { diff --git a/include/usb_pd.h b/include/usb_pd.h index b5425bde21..31c3501726 100644 --- a/include/usb_pd.h +++ b/include/usb_pd.h @@ -13,6 +13,24 @@ /* PD Host command timeout */ #define PD_HOST_COMMAND_TIMEOUT_US SECOND +#ifdef CONFIG_USB_PD_PORT_COUNT +/* + * Define PD_PORT_TO_TASK_ID() and TASK_ID_TO_PD_PORT() macros to + * go between PD port number and task ID. + */ +#if CONFIG_USB_PD_PORT_COUNT == 1 +#ifdef HAS_TASK_PD +#define PD_PORT_TO_TASK_ID(port) TASK_ID_PD +#else +#define PD_PORT_TO_TASK_ID(port) -1 /* dummy task ID */ +#endif +#define TASK_ID_TO_PD_PORT(id) 0 +#elif CONFIG_USB_PD_PORT_COUNT == 2 +#define PD_PORT_TO_TASK_ID(port) ((port) ? TASK_ID_PD_C1 : TASK_ID_PD_C0) +#define TASK_ID_TO_PD_PORT(id) ((id) == TASK_ID_PD_C0 ? 0 : 1) +#endif +#endif /* CONFIG_USB_PD_PORT_COUNT */ + enum pd_rx_errors { PD_RX_ERR_INVAL = -1, /* Invalid packet */ PD_RX_ERR_HARD_RESET = -2, /* Got a Hard-Reset packet */ @@ -802,6 +820,19 @@ enum pd_data_msg_type { /* Minimum PD voltage (mV) */ #define PD_MIN_MV 5000 +/* No connect voltage threshold for sources based on Rp */ +#define PD_SRC_DEF_VNC_MV 1600 +#define PD_SRC_1_5_VNC_MV 1600 +#define PD_SRC_3_0_VNC_MV 2600 + +/* Rd voltage threshold for sources based on Rp */ +#define PD_SRC_DEF_RD_THRESH_MV 200 +#define PD_SRC_1_5_RD_THRESH_MV 400 +#define PD_SRC_3_0_RD_THRESH_MV 800 + +/* Voltage threshold to detect connection when presenting Rd */ +#define PD_SNK_VA_MV 250 + /* --- Policy layer functions --- */ /* Request types for pd_build_request() */ @@ -928,6 +959,14 @@ void typec_set_input_current_limit(int port, uint32_t max_ma, int pd_board_checks(void); /** + * Return if VBUS is detected on type-C port + * + * @param port USB-C port number + * @return VBUS is detected + */ +int pd_snk_is_vbus_provided(int port); + +/** * Check if power swap is allowed. * * @param port USB-C port number diff --git a/test/charge_manager.c b/test/charge_manager.c index d504d9daf5..a2a366750c 100644 --- a/test/charge_manager.c +++ b/test/charge_manager.c @@ -11,7 +11,6 @@ #include "test_util.h" #include "timer.h" #include "usb_pd.h" -#include "usb_pd_config.h" #include "util.h" #define CHARGE_MANAGER_SLEEP_MS 50 @@ -33,8 +32,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[PD_PORT_COUNT]; -static int power_role[PD_PORT_COUNT]; +static int new_power_request[CONFIG_USB_PD_PORT_COUNT]; +static int power_role[CONFIG_USB_PD_PORT_COUNT]; /* Callback functions called by CM on state change */ void board_set_charge_limit(int charge_ma) @@ -70,7 +69,7 @@ void pd_set_new_power_request(int port) static void clear_new_power_requests(void) { int i; - for (i = 0; i < PD_PORT_COUNT; ++i) + for (i = 0; i < CONFIG_USB_PD_PORT_COUNT; ++i) new_power_request[i] = 0; } @@ -107,7 +106,7 @@ static void initialize_charge_table(int current, int voltage, int ceil) charge.current = current; charge.voltage = voltage; - for (i = 0; i < PD_PORT_COUNT; ++i) { + for (i = 0; i < CONFIG_USB_PD_PORT_COUNT; ++i) { charge_manager_set_ceil(i, ceil); charge_manager_update_dualrole(i, CAP_DEDICATED); pd_set_role(i, PD_ROLE_SINK); @@ -132,12 +131,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 < PD_PORT_COUNT; ++j) { + for (j = 0; j < CONFIG_USB_PD_PORT_COUNT; ++j) { if (i == 0) charge_manager_update_dualrole(j, CAP_DEDICATED); if (i == CHARGE_SUPPLIER_COUNT - 1 && - j == PD_PORT_COUNT - 1) + j == CONFIG_USB_PD_PORT_COUNT - 1) break; charge_manager_update_charge(i, j, &charge); } @@ -148,7 +147,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, - PD_PORT_COUNT-1, + CONFIG_USB_PD_PORT_COUNT-1, &charge); wait_for_charge_manager_refresh(); TEST_ASSERT(active_charge_port != CHARGE_PORT_NONE); diff --git a/test/test_config.h b/test/test_config.h index 6117a6c0dc..39746787b5 100644 --- a/test/test_config.h +++ b/test/test_config.h @@ -130,6 +130,7 @@ int board_discharge_on_ac(int enabled); #define CONFIG_USB_POWER_DELIVERY #define CONFIG_USB_PD_CUSTOM_VDM #define CONFIG_USB_PD_DUAL_ROLE +#define CONFIG_USB_PD_PORT_COUNT 2 #define CONFIG_USB_PD_TCPC #define CONFIG_USB_PD_TCPM_STUB #define CONFIG_SHA256 @@ -139,10 +140,12 @@ int board_discharge_on_ac(int enabled); #ifdef TEST_CHARGE_MANAGER #define CONFIG_CHARGE_MANAGER #define CONFIG_USB_PD_DUAL_ROLE +#define CONFIG_USB_PD_PORT_COUNT 2 #endif #ifdef TEST_CHARGE_RAMP #define CONFIG_CHARGE_RAMP +#define CONFIG_USB_PD_PORT_COUNT 2 #endif #endif /* TEST_BUILD */ diff --git a/test/usb_pd.c b/test/usb_pd.c index 4fb38d1916..2a8f73a684 100644 --- a/test/usb_pd.c +++ b/test/usb_pd.c @@ -11,7 +11,6 @@ #include "test_util.h" #include "timer.h" #include "usb_pd.h" -#include "usb_pd_config.h" #include "usb_pd_test_util.h" #include "util.h" @@ -23,7 +22,7 @@ struct pd_port_t { int polarity; int partner_role; /* -1 for none */ int partner_polarity; -} pd_port[PD_PORT_COUNT]; +} pd_port[CONFIG_USB_PD_PORT_COUNT]; /* Mock functions */ @@ -86,7 +85,7 @@ static void init_ports(void) { int i; - for (i = 0; i < PD_PORT_COUNT; ++i) { + for (i = 0; i < CONFIG_USB_PD_PORT_COUNT; ++i) { pd_port[i].host_mode = 0; pd_port[i].partner_role = -1; pd_port[i].has_vbus = 0; @@ -157,7 +156,7 @@ static void unplug(int port) { pd_port[port].has_vbus = 0; pd_port[port].partner_role = -1; - task_wake(PORT_TO_TASK_ID(port)); + task_wake(PD_PORT_TO_TASK_ID(port)); usleep(30 * MSEC); } @@ -166,7 +165,7 @@ static int test_request(void) uint32_t expected_rdo = RDO_FIXED(1, 900, 900, RDO_CAP_MISMATCH); plug_in_source(0, 0); - task_wake(PORT_TO_TASK_ID(0)); + task_wake(PD_PORT_TO_TASK_ID(0)); task_wait_event(2 * PD_T_CC_DEBOUNCE + 100 * MSEC); TEST_ASSERT(pd_port[0].polarity == 0); @@ -176,7 +175,7 @@ static int test_request(void) TEST_ASSERT(verify_goodcrc(0, PD_ROLE_SINK, pd_port[0].msg_rx_id)); /* Wait for the power request */ - task_wake(PORT_TO_TASK_ID(0)); + task_wake(PD_PORT_TO_TASK_ID(0)); task_wait_event(35 * MSEC); /* tSenderResponse: 24~30 ms */ inc_rx_id(0); @@ -200,7 +199,7 @@ static int test_sink(void) int i; plug_in_sink(1, 1); - task_wake(PORT_TO_TASK_ID(1)); + task_wake(PD_PORT_TO_TASK_ID(1)); task_wait_event(250 * MSEC); /* tTypeCSinkWaitCap: 210~250 ms */ TEST_ASSERT(pd_port[1].polarity == 1); @@ -217,7 +216,7 @@ static int test_sink(void) /* Looks good. Ack the source cap. */ simulate_goodcrc(1, PD_ROLE_SINK, pd_port[1].msg_tx_id); - task_wake(PORT_TO_TASK_ID(1)); + task_wake(PD_PORT_TO_TASK_ID(1)); usleep(30 * MSEC); inc_tx_id(1); |