diff options
-rw-r--r-- | board/chell/board.h | 3 | ||||
-rw-r--r-- | board/dingdong/board.h | 3 | ||||
-rw-r--r-- | board/elm/board.h | 3 | ||||
-rw-r--r-- | board/eve/board.h | 3 | ||||
-rw-r--r-- | board/glados/board.h | 3 | ||||
-rw-r--r-- | board/hoho/board.h | 3 | ||||
-rw-r--r-- | board/honeybuns/board.h | 3 | ||||
-rw-r--r-- | board/host/board.h | 3 | ||||
-rw-r--r-- | board/it83xx_evb/board.h | 2 | ||||
-rw-r--r-- | board/kevin/board.h | 3 | ||||
-rw-r--r-- | board/lucid/board.h | 2 | ||||
-rw-r--r-- | board/oak/board.h | 3 | ||||
-rw-r--r-- | board/pdeval-stm32f072/board.h | 3 | ||||
-rw-r--r-- | board/plankton/board.h | 3 | ||||
-rw-r--r-- | board/poppy/board.h | 3 | ||||
-rw-r--r-- | board/pyro/board.h | 3 | ||||
-rw-r--r-- | board/reef/board.h | 3 | ||||
-rw-r--r-- | board/ryu/board.h | 3 | ||||
-rw-r--r-- | board/samus_pd/board.h | 3 | ||||
-rw-r--r-- | board/servo_v4/board.h | 3 | ||||
-rw-r--r-- | board/snappy/board.h | 3 | ||||
-rw-r--r-- | board/strago/board.h | 3 | ||||
-rw-r--r-- | board/twinkie/board.h | 3 | ||||
-rw-r--r-- | board/wheatley/board.h | 3 | ||||
-rw-r--r-- | board/zinger/board.h | 3 | ||||
-rw-r--r-- | common/usb_pd_protocol.c | 7 | ||||
-rw-r--r-- | include/usb_pd.h | 9 |
27 files changed, 13 insertions, 76 deletions
diff --git a/board/chell/board.h b/board/chell/board.h index cbefb76929..42f56b8d64 100644 --- a/board/chell/board.h +++ b/board/chell/board.h @@ -185,9 +185,6 @@ enum temp_sensor_id { TEMP_SENSOR_COUNT }; -/* start as a sink in case we have no other power supply/battery */ -#define PD_DEFAULT_STATE PD_STATE_SNK_DISCONNECTED - /* TODO: determine the following board specific type-C power constants */ /* * delay to turn on the power supply max is ~16ms. diff --git a/board/dingdong/board.h b/board/dingdong/board.h index 91a8c8b2ea..4c33b4ba45 100644 --- a/board/dingdong/board.h +++ b/board/dingdong/board.h @@ -78,9 +78,6 @@ 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 */ diff --git a/board/elm/board.h b/board/elm/board.h index 779728b988..f143dc614a 100644 --- a/board/elm/board.h +++ b/board/elm/board.h @@ -194,9 +194,6 @@ enum temp_sensor_id { TEMP_SENSOR_COUNT }; -/* start as a sink in case we have no other power supply/battery */ -#define PD_DEFAULT_STATE PD_STATE_SNK_DISCONNECTED - /* TODO: determine the following board specific type-C power constants */ /* * delay to turn on the power supply max is ~16ms. diff --git a/board/eve/board.h b/board/eve/board.h index 87b527333e..521fe1631f 100644 --- a/board/eve/board.h +++ b/board/eve/board.h @@ -230,9 +230,6 @@ enum adc_channel { ADC_CH_COUNT }; -/* 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. diff --git a/board/glados/board.h b/board/glados/board.h index 58d6fcbd8c..9ce659c216 100644 --- a/board/glados/board.h +++ b/board/glados/board.h @@ -190,9 +190,6 @@ enum als_id { ALS_COUNT }; -/* start as a sink in case we have no other power supply/battery */ -#define PD_DEFAULT_STATE PD_STATE_SNK_DISCONNECTED - /* TODO: determine the following board specific type-C power constants */ /* * delay to turn on the power supply max is ~16ms. diff --git a/board/hoho/board.h b/board/hoho/board.h index 2e02744cf3..d0c72f18b9 100644 --- a/board/hoho/board.h +++ b/board/hoho/board.h @@ -88,9 +88,6 @@ 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 */ diff --git a/board/honeybuns/board.h b/board/honeybuns/board.h index 3903623a70..ad60fdb680 100644 --- a/board/honeybuns/board.h +++ b/board/honeybuns/board.h @@ -92,9 +92,6 @@ enum usb_strings { #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. diff --git a/board/host/board.h b/board/host/board.h index 592ecb620a..a5b6a5dc20 100644 --- a/board/host/board.h +++ b/board/host/board.h @@ -59,9 +59,6 @@ extern const int supplier_priority[]; #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 */ diff --git a/board/it83xx_evb/board.h b/board/it83xx_evb/board.h index e19e1bd105..9abc9d8053 100644 --- a/board/it83xx_evb/board.h +++ b/board/it83xx_evb/board.h @@ -131,8 +131,6 @@ enum ec2i_setting { #define PD_MAX_CURRENT_MA 3000 /* Try to negotiate to 20V since i2c noise problems should be fixed. */ #define PD_MAX_VOLTAGE_MV 20000 -/* start as a sink in case we have no other power supply/battery */ -#define PD_DEFAULT_STATE PD_STATE_SNK_DISCONNECTED /* TODO: determine the following board specific type-C power constants */ /* * delay to turn on the power supply max is ~16ms. diff --git a/board/kevin/board.h b/board/kevin/board.h index bc7fc5b0ef..304de3da1e 100644 --- a/board/kevin/board.h +++ b/board/kevin/board.h @@ -152,9 +152,6 @@ #define PD_POWER_SUPPLY_TURN_OFF_DELAY 50000 /* us */ #define PD_VCONN_SWAP_DELAY 5000 /* us */ -/* start as a sink in case we have no other power supply/battery */ -#define PD_DEFAULT_STATE PD_STATE_SNK_DISCONNECTED - /* Optional features for test commands */ #define CONFIG_CMD_CHARGER_PSYS diff --git a/board/lucid/board.h b/board/lucid/board.h index fba5e73dd8..bba13f973c 100644 --- a/board/lucid/board.h +++ b/board/lucid/board.h @@ -113,8 +113,6 @@ enum temp_sensor_id { TEMP_SENSOR_COUNT }; -#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 */ diff --git a/board/oak/board.h b/board/oak/board.h index bc4c03ee52..6567b6dea5 100644 --- a/board/oak/board.h +++ b/board/oak/board.h @@ -217,9 +217,6 @@ enum als_id { ALS_COUNT }; -/* start as a sink in case we have no other power supply/battery */ -#define PD_DEFAULT_STATE PD_STATE_SNK_DISCONNECTED - /* TODO: determine the following board specific type-C power constants */ /* * delay to turn on the power supply max is ~16ms. diff --git a/board/pdeval-stm32f072/board.h b/board/pdeval-stm32f072/board.h index 2d2b4edc29..df32ec2683 100644 --- a/board/pdeval-stm32f072/board.h +++ b/board/pdeval-stm32f072/board.h @@ -29,9 +29,6 @@ #define CONFIG_USB_PD_PORT_COUNT 2 #define CONFIG_USB_PD_TCPM_TCPCI -/* start as a sink */ -#define PD_DEFAULT_STATE PD_STATE_SNK_DISCONNECTED - /* fake board specific type-C power constants */ #define PD_POWER_SUPPLY_TURN_ON_DELAY 30000 /* us */ #define PD_POWER_SUPPLY_TURN_OFF_DELAY 250000 /* us */ diff --git a/board/plankton/board.h b/board/plankton/board.h index 749a3e8cd6..994fb98c76 100644 --- a/board/plankton/board.h +++ b/board/plankton/board.h @@ -79,9 +79,6 @@ enum board_src_cap { #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 */ diff --git a/board/poppy/board.h b/board/poppy/board.h index abb538b49d..2c7163a6b8 100644 --- a/board/poppy/board.h +++ b/board/poppy/board.h @@ -222,9 +222,6 @@ enum button { BUTTON_COUNT }; -/* start as a sink in case we have no other power supply/battery */ -#define PD_DEFAULT_STATE PD_STATE_SNK_DISCONNECTED - /* TODO(crosbug.com/p/61098): Verify the numbers below. */ /* * delay to turn on the power supply max is ~16ms. diff --git a/board/pyro/board.h b/board/pyro/board.h index 035a4e623b..eb656abc68 100644 --- a/board/pyro/board.h +++ b/board/pyro/board.h @@ -292,9 +292,6 @@ enum pyro_board_version { BOARD_VERSION_COUNT, }; -/* start as a sink in case we have no other power supply/battery */ -#define PD_DEFAULT_STATE PD_STATE_SNK_DISCONNECTED - /* TODO: determine the following board specific type-C power constants */ /* FIXME(dhendrix): verify all of the below PD_* numbers */ /* diff --git a/board/reef/board.h b/board/reef/board.h index af68d69eb4..86c288a04c 100644 --- a/board/reef/board.h +++ b/board/reef/board.h @@ -282,9 +282,6 @@ enum reef_board_version { BOARD_VERSION_COUNT, }; -/* start as a sink in case we have no other power supply/battery */ -#define PD_DEFAULT_STATE PD_STATE_SNK_DISCONNECTED - /* TODO: determine the following board specific type-C power constants */ /* FIXME(dhendrix): verify all of the below PD_* numbers */ /* diff --git a/board/ryu/board.h b/board/ryu/board.h index 1658a98c1e..7f04028a82 100644 --- a/board/ryu/board.h +++ b/board/ryu/board.h @@ -257,9 +257,6 @@ enum usb_strings { #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 */ diff --git a/board/samus_pd/board.h b/board/samus_pd/board.h index 51963fa5de..bb60b08e62 100644 --- a/board/samus_pd/board.h +++ b/board/samus_pd/board.h @@ -119,9 +119,6 @@ enum pwm_channel { #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. diff --git a/board/servo_v4/board.h b/board/servo_v4/board.h index 38c7249375..94fc4bf69e 100644 --- a/board/servo_v4/board.h +++ b/board/servo_v4/board.h @@ -88,9 +88,6 @@ #define PD_SRC_VNC PD_SRC_DEF_VNC_MV #define PD_SRC_RD_THRESHOLD PD_SRC_DEF_RD_THRESH_MV -/* Start as a sink for both CHG/DUT ports */ -#define PD_DEFAULT_STATE PD_STATE_SNK_DISCONNECTED - /* * TODO(crosbug.com/p/60792): The delay values are currently just place holders * and the delay will need to be relative to the circuitry that allows VBUS to diff --git a/board/snappy/board.h b/board/snappy/board.h index 9e454afe3a..12014201d4 100644 --- a/board/snappy/board.h +++ b/board/snappy/board.h @@ -282,9 +282,6 @@ enum snappy_board_version { BOARD_VERSION_COUNT, }; -/* start as a sink in case we have no other power supply/battery */ -#define PD_DEFAULT_STATE PD_STATE_SNK_DISCONNECTED - /* TODO: determine the following board specific type-C power constants */ /* FIXME(dhendrix): verify all of the below PD_* numbers */ /* diff --git a/board/strago/board.h b/board/strago/board.h index 158329c4ad..24a736e585 100644 --- a/board/strago/board.h +++ b/board/strago/board.h @@ -174,9 +174,6 @@ enum als_id { ALS_COUNT, }; -/* start as a sink in case we have no other power supply/battery */ -#define PD_DEFAULT_STATE PD_STATE_SNK_DISCONNECTED - /* TODO: determine the following board specific type-C power constants */ /* * delay to turn on the power supply max is ~16ms. diff --git a/board/twinkie/board.h b/board/twinkie/board.h index 676e9a337f..0419ae5a3f 100644 --- a/board/twinkie/board.h +++ b/board/twinkie/board.h @@ -110,9 +110,6 @@ enum usb_strings { #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 */ diff --git a/board/wheatley/board.h b/board/wheatley/board.h index 3a2abae07b..aea3a287ea 100644 --- a/board/wheatley/board.h +++ b/board/wheatley/board.h @@ -210,9 +210,6 @@ enum sensor_id { BASE_GYRO, }; -/* start as a sink in case we have no other power supply/battery */ -#define PD_DEFAULT_STATE PD_STATE_SNK_DISCONNECTED - /* TODO: determine the following board specific type-C power constants */ /* * delay to turn on the power supply max is ~16ms. diff --git a/board/zinger/board.h b/board/zinger/board.h index 5945d6c639..9a2a40afe8 100644 --- a/board/zinger/board.h +++ b/board/zinger/board.h @@ -104,9 +104,6 @@ enum adc_channel { /* 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 */ diff --git a/common/usb_pd_protocol.c b/common/usb_pd_protocol.c index 0378d817f4..28f7796240 100644 --- a/common/usb_pd_protocol.c +++ b/common/usb_pd_protocol.c @@ -1599,7 +1599,7 @@ void pd_task(void) /* Initialize TCPM driver and wait for TCPC to be ready */ res = tcpm_init(port); CPRINTS("TCPC p%d init %s", port, res ? "failed" : "ready"); - this_state = res ? PD_STATE_SUSPENDED : PD_DEFAULT_STATE; + this_state = res ? PD_STATE_SUSPENDED : PD_DEFAULT_STATE(port); #ifdef CONFIG_USB_PD_DUAL_ROLE /* @@ -1705,7 +1705,7 @@ void pd_task(void) /* Ensure state variables are at default */ pd[port].power_role = PD_ROLE_DEFAULT; pd[port].vdm_state = VDM_STATE_DONE; - set_state(port, PD_DEFAULT_STATE); + set_state(port, PD_DEFAULT_STATE(port)); } } #endif @@ -2989,7 +2989,8 @@ void pd_set_suspend(int port, int enable) int tries = 3; do { - set_state(port, enable ? PD_STATE_SUSPENDED : PD_DEFAULT_STATE); + set_state(port, enable ? PD_STATE_SUSPENDED : + PD_DEFAULT_STATE(port)); task_wake(PD_PORT_TO_TASK_ID(port)); } while (enable && pd[port].task_state != PD_STATE_SUSPENDED && --tries); diff --git a/include/usb_pd.h b/include/usb_pd.h index 4eef319ae2..08eef75822 100644 --- a/include/usb_pd.h +++ b/include/usb_pd.h @@ -818,6 +818,15 @@ enum pd_data_msg_type { #define PD_ROLE_DEFAULT PD_ROLE_SOURCE #endif +/* Port default state at startup */ +#ifdef CONFIG_USB_PD_DUAL_ROLE +#define PD_DEFAULT_STATE(port) ((PD_ROLE_DEFAULT == PD_ROLE_SOURCE) ? \ + PD_STATE_SRC_DISCONNECTED : \ + PD_STATE_SNK_DISCONNECTED) +#else +#define PD_DEFAULT_STATE(port) PD_STATE_SRC_DISCONNECTED +#endif + /* build message header */ #define PD_HEADER(type, prole, drole, id, cnt) \ ((type) | (PD_REV20 << 6) | \ |