chrome-ec/common
Edward Hill bf4aea7fb4 pd: Check for dual-role partner when TOGGLE_OFF/FORCE_SINK
Charging via hub with the ANX3429 TCPC sometimes fails when the system
is in S5/G3. Both the hub and the ANX3429 are auto-toggling, so source
and sink roles depend on the timing of the connection. Charging will
fail when the hub expects the ANX3429 to be a source, but the
drp_state in S5/G3 is TOGGLE_OFF/FORCE_SINK.

Ideally we wouldn't use auto-toggle when drp_state is
TOGGLE_OFF/FORCE_SINK, but with the ANX3429 TCPC, auto-toggle can't be
prevented in low power mode.

To fix this, try being a sink in case the connected device is dual-role.
100 ms is enough time for a dual-role partner to switch from sink to
source. If the connected device is sink-only, then we will attempt
SNK_DISCONNECTED twice (due to debounce time), then return to low power
mode (and stay there). After 200 ms, reset ready for a new connection.

Move the next_state selection out into a function since things were
getting very narrow inside PD_STATE_DRP_AUTO_TOGGLE.

BRANCH=none
BUG=b:72007056
TEST=sink device + ANX3429: low power mode
TEST=sink device + PS8751: low power mode
TEST=charger via hub + ANX3429: starts charging (20/20 tries)
TEST=charger via hub + PS8751: starts charging
(all tests with Grunt in G3)

Change-Id: I097dcace96bc6e6e9cfab279bcbded50ef9951e3
Signed-off-by: Edward Hill <ecgh@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/1194678
Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com>
Reviewed-by: Jett Rink <jettrink@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/1231363
Reviewed-by: Martin Roth <martinroth@chromium.org>
Commit-Queue: Martin Roth <martinroth@chromium.org>
Tested-by: Martin Roth <martinroth@chromium.org>
2018-09-18 17:19:57 +00:00
..
vboot shared_mem: Assert that shared memory size is large enough 2018-05-07 20:45:54 -07:00
acpi.c acpi: Return 0 for tablet mode if EC has no device orientation 2018-07-11 12:13:07 -07:00
adc.c adc: Add ectool command for reading ADC channels. 2018-08-17 20:39:05 -07:00
als.c ec_als: ALS now uses CPRINT macros 2017-12-28 14:50:29 -08:00
ap_hang_detect.c reset: Log the reason for AP resets. 2018-07-26 04:07:41 -07:00
backlight_lid.c backlight: Adding support for active low GPIO signal 2018-01-18 05:09:37 -08:00
base32.c common: Substitute modified CRC8 with CRC-5-USB 2017-09-12 16:17:03 -07:00
base_state.c common: add API to expose detachable "base" state 2018-08-22 00:10:42 -07:00
battery.c battery: treat error codes properly 2018-04-10 19:13:11 -07:00
battery_fuel_gauge.c battery: Optionally prevent boot at low SOC with cell imbalance. 2018-08-08 04:29:20 -07:00
bluetooth_le.c btle: Cleanup: Moved constants, renamed functions 2016-08-11 14:46:33 -07:00
btle_hci_controller.c cleanup: DECLARE_CONSOLE_COMMAND only needs 4 args 2016-08-24 16:30:10 +00:00
btle_ll.c btle_ll.c: Initialize variables to fix GCC warnings 2016-11-16 19:04:31 -08:00
build.mk CEC: Make buffer handling code unit testable 2018-08-22 08:16:01 -07:00
button.c reset: Log the reason for AP resets. 2018-07-26 04:07:41 -07:00
capsense.c i2c: Split i2c_xfer into locked/unlocked versions. 2018-08-16 13:14:49 -07:00
cbi.c cbi: fail set command early if WP is asserted 2018-09-18 15:38:05 +00:00
ccd_config.c cr50: add more ccd open capabilities 2018-08-29 04:20:29 +00:00
cec.c CEC: Cleanup the API for the CEC buffer handlers 2018-08-22 08:16:02 -07:00
charge_manager.c chgstv2: Always check batt disconnect state. 2018-07-31 16:37:10 -07:00
charge_ramp.c charge_ramp: Ramp USB-C DTS sources 2017-10-19 12:56:42 -07:00
charge_ramp_sw.c chg_ramp: Add charge_is_consuming_full_input_current(). 2017-11-01 16:47:21 -07:00
charge_state_v2.c docs: Document low-battery compatibility config. 2018-08-31 05:23:10 -07:00
charger.c chgstv2: Fix manual control via EC console. 2018-06-01 17:44:41 -07:00
charger_profile_override.c charger_profile: support multiple battery voltage range thresholds 2017-02-10 19:02:55 -08:00
chipset.c reset: Log the reason for AP resets. 2018-07-26 04:07:41 -07:00
clz.c Add option to enable GCC LTO 2015-05-19 02:46:27 +00:00
console.c console: Do not flush the console in console_init 2018-05-31 03:50:20 -07:00
console_output.c console_output: make chan a safe command 2018-05-31 00:19:29 -07:00
crc.c ec: add crc32_ctx..() to take context parameter. 2018-02-23 23:13:01 -08:00
crc8.c crc8: Support crc calculation across non-contiguous data 2016-03-18 22:16:53 -07:00
ctz.c common: Add software CTZ implementation when needeed 2017-11-16 23:32:11 -08:00
curve25519-generic.c core/cortex-m0/curve25519: Integrate fast curve25519 implementation 2017-07-03 21:44:34 -07:00
curve25519.c core/cortex-m0/curve25519: Integrate fast curve25519 implementation 2017-07-03 21:44:34 -07:00
device_event.c Add support for reporting device events 2017-06-30 03:08:42 -07:00
device_state.c cr50: Clean up device state code 2017-08-08 17:34:09 -07:00
dptf.c eve: Move DPTF tablet mode support to common code 2017-02-14 14:50:36 -08:00
ec.libsharedobjs.ld build-infr: Add support for shared RO library. 2015-07-17 03:17:50 +00:00
ec_ec_comm_master.c common/ec_ec_comm_master/slave: Add support for EC hibernate 2018-03-28 23:23:31 -07:00
ec_ec_comm_slave.c common/ec_ec_comm_slave: initialize seq 2018-08-01 19:35:14 -07:00
ec_features.c sensor: Add flag for tight timestamping 2018-07-03 22:31:05 -07:00
espi.c espi: Add API to test if signal is eSPI virtual wire 2018-01-02 15:48:20 -08:00
event_log.c pd_log: Make PD logging more generic for general purpose logging 2017-08-02 15:02:34 -07:00
extension.c cr50: Disabling TPM or enabling TPM. 2018-06-21 01:05:47 -07:00
extpower_gpio.c extpower: Allow board to override signal debounce time 2016-09-02 07:11:33 -07:00
factory_mode.c cr50: refactor rma mode into factory mode 2018-05-30 20:38:53 -07:00
fan.c Fan: Restore thermal control after sysjump 2018-08-10 22:43:55 -07:00
firmware_image.S npcx: Build RW_B and support sysjump to it 2017-07-13 19:45:57 -07:00
firmware_image.lds.S npcx: Build RW_B and support sysjump to it 2017-07-13 19:45:57 -07:00
flash.c common/flash: Abort rwsig when RW is erased/written to 2018-07-25 00:14:49 -07:00
fmap.c EFS: Add SIG_RW_B in fmap 2018-01-10 12:58:55 -08:00
fpsensor.c fingerprint: Flush SPI transaction before increasing CPU clock 2018-08-29 06:27:18 -07:00
gesture.c Fix various misspellings in comments 2016-11-15 17:41:53 -08:00
gpio.c gpio: extend flags size to accommodate GPIO_ flags 2018-06-11 17:29:48 -07:00
gpio_commands.c Cr50: Mark several console commands as safe 2016-08-31 17:20:26 +00:00
hooks.c common: add BASE_CHANGE hook 2018-08-21 19:27:46 -07:00
host_command.c host_command: fix the memmap fix 2018-06-29 14:16:33 -07:00
host_command_master.c i2c: Split i2c_xfer into locked/unlocked versions. 2018-08-16 13:14:49 -07:00
host_command_pd.c Fix inconsistent task function declarations 2017-08-08 14:56:13 -07:00
host_event_commands.c lpc/espi: convert remaning CONFIG_LPC to CONFIG_HOSTCMD_X86 2018-05-22 21:56:40 -07:00
i2c_master.c i2c: Don't try to unwedge unpowered busses. 2018-08-22 00:10:38 -07:00
i2c_slave.c i2c: separate slave and master code 2017-04-26 13:37:04 -07:00
i2c_wedge.c cleanup: DECLARE_CONSOLE_COMMAND only needs 4 args 2016-08-24 16:30:10 +00:00
i2cs_tpm.c tpm: provide means of shutting down comms layer while in reset 2017-11-07 17:52:15 -08:00
inductive_charging.c Deferred: Use deferred_data instead of function pointer 2016-04-18 17:32:40 -07:00
keyboard_8042.c keyboard: Move keyboard_special (lightbar demo) to samus/board.c 2018-08-20 03:27:39 -07:00
keyboard_8042_sharedlib.c keyboard: Change scan code magic values to enum. 2018-08-16 13:14:46 -07:00
keyboard_backlight.c kblight: fix bounds checks on backlight intensity 2018-08-15 12:54:51 -07:00
keyboard_mkbp.c common: add API to expose detachable "base" state 2018-08-22 00:10:42 -07:00
keyboard_scan.c keyboard: Ignore refresh button at boot 2018-09-18 15:38:08 +00:00
keyboard_test.c Move keyboard dimension and key constants to keyboard_config.h 2013-03-22 11:24:29 -07:00
lb_common.c i2c: Split i2c_xfer into locked/unlocked versions. 2018-08-16 13:14:49 -07:00
led_common.c led: Only report auto control for supported LEDs. 2018-01-31 18:01:04 -08:00
led_policy_std.c chipset: Introduce CHIPSET_STATE_ANY_SUSPEND 2017-11-28 15:44:19 -08:00
led_pwm.c led_pwm: Turn off LEDs when not pulsing. 2018-07-31 16:37:15 -07:00
lid_angle.c oak: enable lid angle update 2016-03-02 13:39:47 -08:00
lid_switch.c whiskers: Disable keyboard/USB interface when magnet sensor active 2018-02-08 06:57:51 -08:00
lightbar.c ec: Make it possible to build tests using clang 2018-06-28 07:06:46 -07:00
mag_cal.c type: Rename mat44_t to mat44_float_t. 2018-09-18 15:38:14 +00:00
main.c lpc/espi: convert remaning CONFIG_LPC to CONFIG_HOSTCMD_X86 2018-05-22 21:56:40 -07:00
mat33.c type: Rename mat33_t to mat33_float_t 2018-09-18 15:38:14 +00:00
mat44.c type: Rename mat44_t to mat44_float_t. 2018-09-18 15:38:14 +00:00
math_util.c type: Rename matrix_3x3_t to mat33_fp_t 2018-09-18 15:38:15 +00:00
memory_commands.c Add more CONFIG_CMD_* options for console commands 2016-10-01 00:02:01 -07:00
mkbp_event.c ec: Make it possible to build tests using clang 2018-06-28 07:06:46 -07:00
motion_lid.c type: Rename vector_3_t to intv3_t. 2018-09-18 15:38:10 +00:00
motion_sense.c type: Rename vector_3_t to intv3_t. 2018-09-18 15:38:10 +00:00
nvcounter.c Add non-volatile flash counter 2017-06-02 10:38:57 -07:00
nvmem.c cr50: Make sure TPM wipe only clears TPM data. 2017-02-23 01:19:07 -08:00
nvmem_vars.c nvmem_vars: Make sure tuple structure is within bounds 2018-06-22 08:21:26 -07:00
onewire.c Move onewire bus support from chip/lm4 to common 2013-08-02 18:22:57 -07:00
panic_output.c panic_output: undefined behaviour elicits abort() calls 2018-07-17 09:08:11 -07:00
pd_log.c pd_log: Make PD logging more generic for general purpose logging 2017-08-02 15:02:34 -07:00
physical_presence.c pp: add API to show when press is expected 2018-01-12 03:27:08 -08:00
pinweaver.c Cr50: Add logging functionality to PinWeaver. 2018-04-27 12:22:26 -07:00
port80.c port80: Clean up macros 2017-10-31 13:04:59 -07:00
power_button.c cleanup: DECLARE_CONSOLE_COMMAND only needs 4 args 2016-08-24 16:30:10 +00:00
power_button_x86.c Nami: Delay and repeat gas gauge detection 2018-08-03 13:37:28 -07:00
printf.c common/printf: snprintf: Return number of bytes on success 2018-06-28 07:06:45 -07:00
pstore_commands.c pstore: Fix issue with block calculation for pstore blocks 2017-01-03 15:13:58 -08:00
pwm.c pwm: PWM is disabled when duty is set to max value 2016-09-08 17:57:51 -07:00
pwm_kblight.c kblight: Add keyboard backlight control module 2018-05-11 12:10:44 -07:00
queue.c Queue: Add ability to modify contiguous units inplace 2015-07-15 21:57:36 +00:00
queue_policies.c consumer: Remove flush operation 2017-12-18 20:32:58 -08:00
rma_auth.c cr50: refactor rma mode into factory mode 2018-05-30 20:38:53 -07:00
rollback.c rollback: Prevent rollback region readback using MPU 2018-08-15 08:46:51 -07:00
rsa.c rsa: Further optimization of multiplications for Cortex-M0 2018-05-29 06:02:19 -07:00
rtc.c rtc: Add functions and tests for time conversion 2017-09-26 18:24:07 -07:00
rwsig.c common/flash: Abort rwsig when RW is erased/written to 2018-07-25 00:14:49 -07:00
sha1.c Add SHA-1 hash 2014-05-17 20:14:17 +00:00
sha256.c common/sha256: agressive SHA-256 unrolling as an option 2017-09-11 04:42:59 -07:00
shared_mem.c Cr50: Mark several console commands as safe 2016-08-31 17:20:26 +00:00
shmalloc.c fix shmem console command 2018-03-01 12:39:05 -08:00
smbus.c i2c: Split i2c_xfer into locked/unlocked versions. 2018-08-16 13:14:49 -07:00
spi_commands.c cleanup: DECLARE_CONSOLE_COMMAND only needs 4 args 2016-08-24 16:30:10 +00:00
spi_flash.c common/spi_flash: don't mix up unsigned and signed types 2018-08-01 19:35:13 -07:00
spi_flash_reg.c careena: Correct baseboard IMU orientation. 2018-07-31 16:37:04 -07:00
spi_nor.c common/spi_nor: Differential erase support 2017-02-09 05:04:56 +00:00
switch.c Allow lid-less configuration 2017-05-09 23:20:07 -07:00
system.c system: Make hibernate console command invoke chipset task if chipset is on 2018-08-29 06:27:14 -07:00
tablet_mode.c tablet-mode: add disable function 2018-09-18 15:38:04 +00:00
temp_sensor.c cleanup: DECLARE_CONSOLE_COMMAND only needs 4 args 2016-08-24 16:30:10 +00:00
test_util.c cleanup: DECLARE_CONSOLE_COMMAND only needs 4 args 2016-08-24 16:30:10 +00:00
thermal.c reset: Log the reason for AP resets. 2018-07-26 04:07:41 -07:00
throttle_ap.c console_channel.inc: Add more ifdef to reduce number of channels 2018-05-26 00:21:42 -07:00
timer.c timer: Allow disabling gettime console command 2018-05-24 04:10:04 -07:00
tpm_log.c tpm: Add optional event logging 2017-08-10 22:47:24 -07:00
tpm_registers.c cr50: Disabling TPM or enabling TPM. 2018-06-21 01:05:47 -07:00
u2f.c u2f: accept short APDU 2018-04-11 04:39:07 -07:00
uart_buffering.c uart_buffering: expose interface to support non-host command 2018-08-20 21:43:06 -07:00
update_fw.c update_fw: Store complete touchpad FW hash 2017-09-15 10:50:27 -07:00
usb_charger.c usb_charger: Always update VBUS charge supplier 2018-06-07 08:35:52 -07:00
usb_i2c.c i2c: Split i2c_xfer into locked/unlocked versions. 2018-08-16 13:14:49 -07:00
usb_pd_policy.c ec: Make it possible to build tests using clang 2018-06-28 07:06:46 -07:00
usb_pd_protocol.c pd: Check for dual-role partner when TOGGLE_OFF/FORCE_SINK 2018-09-18 17:19:57 +00:00
usb_pd_tcpc.c tcpm: add TCPC RX circular buffer in EC 2018-09-10 15:26:45 +00:00
usb_port_power_dumb.c usb_port_power: Use same name for mode set function 2018-05-29 06:02:18 -07:00
usb_port_power_smart.c usb_port_power_smart: Add CDP/SDP only option. 2017-08-28 15:24:10 -07:00
usb_update.c consumer: Remove flush operation 2017-12-18 20:32:58 -08:00
usbc_ppc.c sn5s330: add low power mode 2018-08-23 17:42:49 -07:00
util.c host_events: Bump up host events and masks to 64-bit 2017-11-21 18:53:35 -08:00
vboot_hash.c shared_mem: Assert that shared memory size is large enough 2018-05-07 20:45:54 -07:00
vec3.c type: Rename vec3_t to floatv3_t. 2018-09-18 15:38:11 +00:00
version.c util: do not generate redundant CROS_EC_VERSION 2018-05-22 21:57:12 -07:00
virtual_battery.c virtual_battery: Avoid unexpected batt_mode_cache refreshing 2017-09-25 21:06:52 -07:00
vstore.c ec: Add temporary secure storage for the host during boot 2016-01-25 21:46:48 -08:00
webusb_desc.c Add WebUSB descriptor support 2017-09-22 10:18:50 -07:00
wireless.c cleanup: DECLARE_CONSOLE_COMMAND only needs 4 args 2016-08-24 16:30:10 +00:00