diff options
Diffstat (limited to 'board')
41 files changed, 289 insertions, 386 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 */ |