summaryrefslogtreecommitdiff
path: root/common
Commit message (Collapse)AuthorAgeFilesLines
* tcpmv2: Enable AutoDischarge on SRC->SNK PrSwap only if VbusDenis Brockus2020-09-111-1/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | AutoDischargeDisconnect should not be re-enabled during SRC->SNK PR_Swap if Vbus is not present. This would happen only as an error condition with the connected partner becoming unattached during the swap. Also, when we are SNK, we should disable/re-enable AutoDischargeDisconnect when we hard reset because we are shutting off sinking and Vbus will drop to Safe0V BUG=b:168128121 BRANCH=none TEST=PR_Swaps with bug mentioned dock Signed-off-by: Denis Brockus <dbrockus@google.com> Change-Id: I891857967559ecea0a7990626ef8fc3c6835797a Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2402338 Tested-by: Denis Brockus <dbrockus@chromium.org> Reviewed-by: Abe Levkoy <alevkoy@chromium.org> Reviewed-by: Diana Z <dzigterman@chromium.org> Reviewed-by: Keith Short <keithshort@chromium.org> Commit-Queue: Diana Z <dzigterman@chromium.org> Commit-Queue: Keith Short <keithshort@chromium.org> Auto-Submit: Denis Brockus <dbrockus@chromium.org>
* TCPMv2: Set mux state on updating partner's USB comm capabilityAyushee2020-09-111-0/+6
| | | | | | | | | | | | | | | | | On updating the port partner's USB communication capability, the mux should also be configured into USB/disconnect mode accordingly. Hence, this CL sets the mux setting according to the partner's USB capability. BUG=b:157163664 BRANCH=None TEST=Able to update the mux state on updating the port part USB comm capability. Signed-off-by: Ayushee <ayushee.shah@intel.com> Change-Id: Ic2d27e2a0af6dad54a875a589b85f8a5d583b5b4 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2388972 Reviewed-by: Vijay P Hiremath <vijay.p.hiremath@intel.com> Reviewed-by: Keith Short <keithshort@chromium.org>
* TCPMv2: Change the comparison of battery socWai-Hong Tam2020-09-111-1/+1
| | | | | | | | | | | | | | | | Change the comparison from soc > CONFIG_USB_PD_TRY_SRC_MIN_BATT_SOC to soc >= CONFIG_USB_PD_TRY_SRC_MIN_BATT_SOC. It accepts the case of configuring CONFIG_USB_PD_TRY_SRC_MIN_BATT_SOC to 0, meaning it skips the check. BRANCH=None BUG=None TEST=Trivial change; built an image without error. Change-Id: I1781f168aedfa9b061c6effe468b141f04d82687 Signed-off-by: Wai-Hong Tam <waihong@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2404477 Reviewed-by: Jett Rink <jettrink@chromium.org>
* TCPMv2: Block enabling PD in RO for non-EFS2 and dead-batteryWai-Hong Tam2020-09-111-2/+17
| | | | | | | | | | | | | | | | | If enable PD in RO on a non-EFS2 device, a hard reset will be issued when sysjump to RW that makes the device brownout on the dead-battery case. For this special case, disable PD in RO as a workaround. BRANCH=None BUG=b:166307654,b:168134171 TEST=Tested on Pompom, without battery attached. EC warm reset and sysjump to RW won't cause the board power-lost. EC warm reset may be brownout but the next boot is fine. Change-Id: Ie6e7687aa8e160012f9bbd725e0fbcbacae94cf2 Signed-off-by: Wai-Hong Tam <waihong@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2402150 Reviewed-by: Jett Rink <jettrink@chromium.org>
* TCPMv2:Correct get_usb4_cable_speed() functionAyushee2020-09-111-2/+2
| | | | | | | | | | | | | | | | | | | | | If a passive USB3gen2 cable NAKs to the discover SVID/mode query, we need to enter USB4 with USB3gen2 passive cable. When a cable NAKs to discover query, the port limits it's Thunderbolt speed to Passive Gen 2 cable speed. So, this CL modifies the get_usb4_cable_speed() function, to obtain the thunderbolt speed from get_tbt_cable_speed() instead of board_get_max_tbt_speed() function BUG=b:168060760 BRANCH=None TEST=Checked on volteer, able to enumerate the USB3Gen2 cables that NAKs to discover SVID query. Signed-off-by: Ayushee <ayushee.shah@intel.com> Change-Id: Id38ca12bb695ed256098d66b098aafa1bc75aed9 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2404604 Reviewed-by: Vijay P Hiremath <vijay.p.hiremath@intel.com> Reviewed-by: Abe Levkoy <alevkoy@chromium.org>
* TCPMv2: Obtain correct dual role state when going suspendPatryk Duda2020-09-112-3/+9
| | | | | | | | | | | | | | | | | | | | | Some boards (eg. eve) don't source VBUS in S3 state. In this case DRP state should be set to force sink instead of toggle off. This CL introduces pd_get_drp_state_in_suspend() function and uses it to obtain correct DRP state when entering suspend. Default implementation of pd_get_drp_state_in_suspend() returns PD_DRP_TOGGLE_OFF, so this commit introduces no functional changes. BUG=b:162254118 BRANCH=none TEST=No functional changes in this CL make -j buildall Signed-off-by: Patryk Duda <pdk@semihalf.com> Change-Id: Iacf8fcdbad027563015f593653d3ed8a49752131 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2395558 Reviewed-by: Jett Rink <jettrink@chromium.org>
* chgstv2: ocpc: Log both Rbatt & Rsys if possibleAseda Aboagye2020-09-101-1/+7
| | | | | | | | | | | | | | | | | | | | | | | It can useful to view the separated out Rsys and Rbatt without having to enable OCPC debug mode. This commit adds those parameters to the `chgstate` console command output. If the system cannot separate out Rsys from Rbatt, only the combined number will be logged. Furthermore, Isys will not be logged. BUG=b:168054855 BRANCH=None TEST=Build and flash waddledee, verify that only the combined resistance is printed when `chgstate` is run. TEST=Build and flash waddledoo, verify that Rsys and Rbatt are printed when `chgstate` is run. Signed-off-by: Aseda Aboagye <aaboagye@google.com> Change-Id: I2bee1afb545ed6e29b14e0b1ca779a0250460970 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2399657 Reviewed-by: David Schneider <dnschneid@chromium.org> Reviewed-by: Diana Z <dzigterman@chromium.org> Commit-Queue: Aseda Aboagye <aaboagye@chromium.org> Tested-by: Aseda Aboagye <aaboagye@chromium.org>
* tcpmv2: Increase SOP' Discovery Identity timeoutKeith Short2020-09-091-8/+28
| | | | | | | | | | | | | | | | | | | | Increase the tDiscoveryIdentity timer outside of an explicit contract so that SOP' Discover Identity commands are only sent at the same rate as Source Cap messages. This allows operation with captive cable devices that power the SOP' responder from VBUS instead of VCONN. BUG=b:166650426 BRANCH=none TEST=make buildall TEST=Verify TBT entry with the TBT loopback device. Signed-off-by: Keith Short <keithshort@chromium.org> Change-Id: I862a0284f36fe8aa2fb78eeaa3ac9db2764da32f Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2399036 Reviewed-by: Diana Z <dzigterman@chromium.org> Reviewed-by: Abe Levkoy <alevkoy@chromium.org>
* TCPMv2: Add board_tcpc_init() call during initializationPatryk Duda2020-09-091-0/+5
| | | | | | | | | | | | | | | | | | | | Some platforms (eg. eve) need to call board_tcpc_init() from PD task. This patch makes board_tcpc_init() to be called if CONFIG_USB_PD_TCPC_BOARD_INIT is defined. For more information please refer to commit: bd018841f6f2856c949dcf9b6dd462872cd18d7f BUG=b:162254118, b:63957122 BRANCH=none TEST=Compile firmware with TCPMv2 support, flash on eve, check if charging works. Signed-off-by: Patryk Duda <pdk@semihalf.com> Change-Id: Ib680cddc6c693bd02031100d38bb5edfebad57fc Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2395560 Commit-Queue: Aseda Aboagye <aaboagye@chromium.org> Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
* cleanup: Move High-priority interrupt task to a separate fileVijay Hiremath2020-09-094-193/+109
| | | | | | | | | | | | BUG=none BRANCH=none TEST=make buildall -j Change-Id: I63a964721a5471d6a00894cb0cb94e9656c10893 Signed-off-by: Vijay Hiremath <vijay.p.hiremath@intel.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2389325 Reviewed-by: Poornima Tom <poornima.tom@intel.com> Reviewed-by: Keith Short <keithshort@chromium.org>
* Introduce functions that provide safe pointer to panic dataPatryk Duda2020-09-091-1/+111
| | | | | | | | | | | | | | | | | | | | | | panic_get_data() function should always return pointer to panic_data structure that can be safely interpreted. When structure layout left by previous EC is different than ours then panic_get_data() should return NULL. Difference in layout can occur when we are jumping from old RO, this happens in eve. Introduce two new functions: get_panic_data_start() - It can be used to obtain beginning of panic data, eg. when copying raw data or when determining where jump data is. get_panic_data_write() - It can be used to obtain pointer to panic_data structure that can be safely written. This function moves jump data and jump tags if necessary. Signed-off-by: Patryk Duda <pdk@semihalf.com> Change-Id: If5f73c86e2176a0169b0be4b890e399c2c259740 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2379845 Reviewed-by: Jett Rink <jettrink@chromium.org>
* charge_manager: two charger DUT does not choose correct portDenis Brockus2020-09-082-1/+9
| | | | | | | | | | | | | | | | | | | | | | | | | The active charge_port is selected in a delayed call to charge_manager_refresh. This leaves a big window allowing a better charger to be detected but not acted upon as the soon to be active charge_port. This leads to the PD Policy Engine deciding this better port is not the current active charge_port and down grading the current limit for the port to no longer be the best choice. So when the charge_manager_refresh is called, it starts changing ports and then later checks for the best port and then swaps back to a lesser charger. BUG=b:166228326 BRANCH=none TEST=USB-C0 45W then attach USB-C1 65W charger Signed-off-by: Denis Brockus <dbrockus@google.com> Change-Id: I23dad1e4690285b3867bd046d9416db9522002e8 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2393863 Commit-Queue: Denis Brockus <dbrockus@chromium.org> Commit-Queue: Edward Hill <ecgh@chromium.org> Tested-by: Denis Brockus <dbrockus@chromium.org> Reviewed-by: Edward Hill <ecgh@chromium.org>
* cleanup:Consolidate multi PD INTR task config to single configPoornima Tom2020-09-043-9/+5
| | | | | | | | | | | | | | | | | | | For a multi Type-C board DUTs, use a common config CONFIG_HAS_TASK_PD_INT for all the PD_INT tasks defined. Also,it must be ensured that PDCMD task and PD_INT tasks are not used togethor. BUG=none BRANCH=none TEST=make buildall -j Also, adding PDCMD and PD_INT tasks in ec.tasklists successfully threw error message:"Should not use PDCMD task with PD INT tasks" Signed-off-by: Poornima Tom <poornima.tom@intel.com> Change-Id: I1c5f3dd6b46bc355bca8b93f8f1d356db54c0faa Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2387686 Reviewed-by: Vijay P Hiremath <vijay.p.hiremath@intel.com> Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
* ocpc: Only print CFET message if battery presentAseda Aboagye2020-09-041-1/+3
| | | | | | | | | | | | | | | | | | | | | | The OCPC algorithm will check to make sure that the battery CFET is enabled before adjusting VSYS. If it's not, it prints out an error log message. However, if the battery isn't present, the CFET can't be enabled therefore this would lead to spammy output. This commit just changes the log print to be emitted when the battery is present AND the CFET is disabled. BUG=none BRANCH=none TEST=`make -j buildall` Signed-off-by: Aseda Aboagye <aaboagye@google.com> Change-Id: Ib0dcacd7736ca5f73c114c7cfa4446378086c58e Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2393221 Tested-by: Aseda Aboagye <aaboagye@chromium.org> Auto-Submit: Aseda Aboagye <aaboagye@chromium.org> Reviewed-by: Diana Z <dzigterman@chromium.org> Commit-Queue: Diana Z <dzigterman@chromium.org>
* tcpmv2: Fix SOP' DiscoverIdent retries.Keith Short2020-09-031-1/+1
| | | | | | | | | | | | | | | | | | | | The PE DRP state machine was sending retries of SOP' DiscoverIdent without any delay. This sets the delay between SOP' DiscoverIdent to tDiscoverIdentity (45 ms). The EC uses this delay regardless of the explicitly contract state. BUG=b:166650426 BRANCH=none TEST=make buildall TEST=Connect SNK device without emarker cable. Observe retries are spaced by at least 45ms. TEST=Connect emarker cable and verify cable identity is discovered. Signed-off-by: Keith Short <keithshort@chromium.org> Change-Id: I05134052fe3576e1dd94d8aa0963a67dce080027 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2391822 Reviewed-by: Diana Z <dzigterman@chromium.org> Commit-Queue: Diana Z <dzigterman@chromium.org>
* common: implement body_detection state machineChing-Kang Yen2020-09-034-12/+293
| | | | | | | | | | | | | | | | | | | | | Implement body_detection state machine. Detect whether the user is close to the devices or not. Use the variance of acceleration from accelerometer to compute the motion confidence. If motion confidence is high enough, set the motion state to ON_BODY. If low enough, set it to OFF_BODY. Also, make gesture_cal() be called only when the gesture sensor data is updated. BRANCH=None BUG=b:123434029 TEST=make buildall, flash the ec, watch the ec console log Change-Id: If886b7f9fc505ef4db4d7abb08194b8f866121bb Signed-off-by: Ching-Kang Yen <chingkang@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2230938 Reviewed-by: Gwendal Grignou <gwendal@chromium.org>
* common: motion_sense_fifo: modify SENSOR_COUNTChing-Kang Yen2020-09-031-6/+6
| | | | | | | | | | | | | | | | | | | | When the CONFIG_GESTURE_HOST_DETECTION is defined, there will be an extra activity sensor. However, the motion_sense_fifo only use SENSOR_NUM for the number of sensors. This might cause overflow issues. Introduce a new variable MAX_MOTION_SENSORS that represents the SENSOR_COUNT (+ 1 when activity sensor is available). Replace all SENSOR_COUNT in motion_sensor_fifo.c to MAX_MOTION_SENSORS. BRANCH=None BUG=b:123434029 TEST=make buildall Signed-off-by: Ching-Kang Yen <chingkang@chromium.org> Change-Id: I39fc9d77c0aa9a23f9931d4b27905b678081d3bd Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2329110 Reviewed-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-by: Heng-ruey Hsu <henryhsu@chromium.org>
* TCPMv2: Add EC_CMD_TYPEC_DISCOVERYDiana Z2020-09-033-0/+118
| | | | | | | | | | | | | | | | | | | | | | | | | | | | This host command will return all discovery information for the given port and transmit type (SOP, SOP'). Each piece of information includes a count of the number of valid fields filled in to the arrays. To keep the command consolidated and easy to parse, this means there will be some number of bytes in each response which do not contain useful information. With this method, we may fit 7 SVID entries with mode information, which is less than the 16 which the EC can store, but more than most port partners present. BRANCH=None BUG=b:165264379 TEST=on waddledoo, confirm ectool shows: -no discovery information with nothing plugged in -no discovery information with a charger which doesn't reply to VDMs -SOP identity but no SVIDs with Moshi, which NAKs DiscoverSVIDs -SOP identity and all SVIDs with Apple 3-in-1 -SOP and SOP' identity and all SVIDs with TBT dock Signed-off-by: Diana Z <dzigterman@chromium.org> Change-Id: Idf21b23ebe4cda62781762188601b2cc35ede65d Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2363417 Reviewed-by: Jett Rink <jettrink@chromium.org> Commit-Queue: Jett Rink <jettrink@chromium.org>
* tcpmv2: allow early connection when waiting to allow LPMDenis Brockus2020-09-021-5/+8
| | | | | | | | | | | | | | | | | | While waiting to go into Low Power Mode the TCPC can detect a connection and we should honor that instead of waiting for the timeout and going into Auto Toggle. BUG=b:157718272 BRANCH=none TEST=FAFT_PD "dut-control usbc_pr:src20v" Signed-off-by: Denis Brockus <dbrockus@google.com> Change-Id: Ib3a3233ebf9b05b83446d7c1163e30fdcaf42aec Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2390848 Tested-by: Denis Brockus <dbrockus@chromium.org> Auto-Submit: Denis Brockus <dbrockus@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org> Commit-Queue: Jett Rink <jettrink@chromium.org>
* TCPMv2: Add DPM_REQUEST_GET_SRC_CAPDenis Brockus2020-09-022-5/+101
| | | | | | | | | | | | | | | | | | | | | As a SRC that runs on battery it can be handy to determine if the connected partner has unconstrained power available so we can try to PR_Swap to let them power us. This only requests the information, if it is not already available, and leaves it to other code to determine if the swap is a good idea. BUG=b:166446426 BRANCH=none TEST=connect a sink device and determine it performed the action Signed-off-by: Denis Brockus <dbrockus@google.com> Change-Id: If45801a33df8b75e541989d7ee8f36ed316ffcc6 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2381408 Tested-by: Denis Brockus <dbrockus@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org> Commit-Queue: Jett Rink <jettrink@chromium.org> Auto-Submit: Denis Brockus <dbrockus@chromium.org>
* TCPMv2: Disabling DPM_REQUEST for SnkGetSnkCaps if FRS disabledDenis Brockus2020-09-021-4/+18
| | | | | | | | | | | | | | | | | | | Leaving this code in when we don't care about the single thing we are getting from it, whether the partner can do FRS, does not make a lot of sense and wastes flash space if we do not have FRS configured to be enabled in the current build. BUG=none BRANCH=none TEST=make buildall Signed-off-by: Denis Brockus <dbrockus@google.com> Change-Id: I73568f04af5bf1df7a03b53983b8e1f443dbdae7 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2381407 Tested-by: Denis Brockus <dbrockus@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org> Commit-Queue: Denis Brockus <dbrockus@chromium.org> Auto-Submit: Denis Brockus <dbrockus@chromium.org>
* TCPMv2: allow TxSinkNG/OK to cross power roles on pr_swapsDenis Brockus2020-09-021-24/+12
| | | | | | | | | | | | | | BUG=b:165822172 BRANCH=none TEST=DUT-DUT PR_Swap Signed-off-by: Denis Brockus <dbrockus@google.com> Change-Id: I056b61cc0e6b7a56f1673728f52783c9d0cf196c Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2370746 Tested-by: Denis Brockus <dbrockus@chromium.org> Commit-Queue: Jett Rink <jettrink@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org> Auto-Submit: Denis Brockus <dbrockus@chromium.org>
* TCPMv2: clear Modal and VDMSetupDone in dfp_discovery_initDenis Brockus2020-09-021-4/+6
| | | | | | | | | | | | | | | | | | Clear MODAL_OPERATIONS and VDM_SETUP_DONE flags in pd_dfp_discovery_init to to make sure we do a full discovery BUG=b:165983983 BRANCH=none TEST=dock specified in bug should be able to PR_Swap Signed-off-by: Denis Brockus <dbrockus@google.com> Change-Id: Idcccf131e7a0dce25d11b740e947e53be8d69dc5 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2378200 Tested-by: Denis Brockus <dbrockus@chromium.org> Commit-Queue: Jett Rink <jettrink@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org> Auto-Submit: Denis Brockus <dbrockus@chromium.org>
* TCPMv2: use sender_response message frameworkDenis Brockus2020-09-021-128/+234
| | | | | | | | | | | | | | | | | | Building up the framework to handle discarded DPM requests and using it on all of the sender_response messages BUG=b:165822172 BRANCH=none TEST=DUT-DUT PR_Swap Signed-off-by: Denis Brockus <dbrockus@google.com> Change-Id: I542d4cba89a923fb16588cc675d2ea4ab7954e0a Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2376386 Tested-by: Denis Brockus <dbrockus@chromium.org> Commit-Queue: Jett Rink <jettrink@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org> Auto-Submit: Denis Brockus <dbrockus@chromium.org>
* motion_sense: use clamp functions in sending 32bit sensor valuesIkjoon Jang2020-09-021-13/+15
| | | | | | | | | | | | | | | | | | | Apply 32bit clamp functions in sending 32bit sensor values to host. Clamp functions explicitly clamp values into 16bit ec protocol regarding its sensor type. Clamp functions take its sensor type as an argument and clamp 32bit value into 0~65535 for light sensors and -32768 ~ 32767 for all other motion sensors. BUG=b:144002158 TEST=Reading illuminance values in kukui kernel BRANCH=none Signed-off-by: Ikjoon Jang <ikjn@chromium.org> Change-Id: I977114e26f28e7806c11b0a97c9edec7a84ea0dc Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2328951 Reviewed-by: Gwendal Grignou <gwendal@chromium.org>
* tcpmv2: clear oc counter when unattched.SNKZick Wei2020-09-021-0/+8
| | | | | | | | | | | | | | | | This CL clear oc_event_cnt_tbl for both USB-C0, USB-C1 port when in unattached.SNK state. BUG=b:166536767, b:165946265 BRANCH=zork TEST=verify that oc event counter will be clear when in unattached.SNK Signed-off-by: Zick Wei <zick.wei@quanta.corp-partner.google.com> Change-Id: If1d6f56d32ad62e8195456ad4fa5e1286a7bac81 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2387680 Reviewed-by: Denis Brockus <dbrockus@chromium.org> Commit-Queue: Denis Brockus <dbrockus@chromium.org>
* tcpmv2: disable receive of SOP' during VCONN swapKeith Short2020-09-021-2/+25
| | | | | | | | | | | | | | | | | | | The USB PD specification indicates that the initial VCONN source shall cease source VCONN within tVCONNSourceOff (25 ms) after receiving PS_RDY. Not all partners wait after sending PS_RDY before trying to communicate with the cable. BUG=b:163478172, b:163143427 BRANCH=none TEST=make buildall TEST=Connect 2 Volteers together and force VCONN swaps confirming the sequence completes normally. Signed-off-by: Keith Short <keithshort@chromium.org> Change-Id: I14720f033c5f6e9caed9c4fe3bfa11e5c046116e Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2381030 Reviewed-by: Denis Brockus <dbrockus@chromium.org> Commit-Queue: Denis Brockus <dbrockus@chromium.org>
* charge: CONFIG_CHARGE_RAMP_SW allows for TypeC/PD currentDenis Brockus2020-09-021-4/+0
| | | | | | | | | | | | | | | | | chg_ramp_max limited CONFIG_CHARGE_RAMP_SW to BC1.2 current. Allow this to be PD and TypeC as well. BUG=b:163864475,b:167257846 BRANCH=none TEST=ramp up to 1.5A from legacy charger Signed-off-by: Denis Brockus <dbrockus@google.com> Change-Id: I0aee9ecad2ccc9de1d7419c1a33507ccfda05fb5 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2388080 Tested-by: Denis Brockus <dbrockus@chromium.org> Auto-Submit: Denis Brockus <dbrockus@chromium.org> Reviewed-by: Edward Hill <ecgh@chromium.org> Commit-Queue: Denis Brockus <dbrockus@chromium.org>
* usb_port_power_dumb: Turn on USB ports on chipset startupWai-Hong Tam2020-09-011-3/+3
| | | | | | | | | | | | | | | It turns off USB ports on the HOOK_CHIPSET_SHUTDOWN hook. In order to pair with it, should turn on USB ports on the HOOK_CHIPSET_STARTUP hook, instead of HOOK_CHIPSET_RESUME hook. BRANCH=None BUG=b:167155164 TEST=Built a Trogdor image and tested USB-A working on the first bootup. Change-Id: I7f45a5e56bc38388fa906b430cd7dba6835ac17e Signed-off-by: Wai-Hong Tam <waihong@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2386495 Reviewed-by: Stephen Boyd <swboyd@chromium.org>
* usb_pe_drp: new unit test with mocksPaul Fagerburg2020-08-316-8/+288
| | | | | | | | | | | | | | | | | | | Add a new unit test for usb_pe_drp with mocks for the various subsystems that it will use. The fake_prl module is already essentially a mock for the PRL layer, so just move it into the mocks directory and make it available as mock to other tests. BUG=b:163421994 BRANCH=None TEST=`make runhosttests` succeeds Signed-off-by: Paul Fagerburg <pfagerburg@google.com> Change-Id: I2aea3fa0694e8d9e6bae1f47516cb4d5d2a1e714 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2364050 Tested-by: Paul Fagerburg <pfagerburg@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org> Commit-Queue: Paul Fagerburg <pfagerburg@chromium.org>
* eve: Move board level TCPC init to happen in pd_task initDuncan Laurie2020-08-311-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When the board level TCPC run as an init hook it will frequently lead to an EC reset when we are trying to recovery a disconnected battery, potentially even a reboot loop with the most unlucky timing. If we instead call it from the pd_task before tcpc_init is called then the board init hook can stall the pd_task init until the battery is out of disconnect mode, or giving up after 2 seconds in case the battery never seems to recover. This accomplishes two goals: ensure the PD chips are not reset until the battery is out of disconnect and delay start of the pd_task (and PD negotiation) until the battery is out of disconnect state. With this change I never see an EC reset when recovering from a disconnected battery state. BUG=b:63957122 BRANCH=eve TEST=manual testing on Eve with 50+ battery disconnect and battery cutoff cycles to ensure it never triggers an unexpected EC reset. Change-Id: Ie1604e82916ea203a32cbdde98f6697e344bba4c Signed-off-by: Duncan Laurie <dlaurie@google.com> Reviewed-on: https://chromium-review.googlesource.com/592716 Reviewed-by: Furquan Shaikh <furquan@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2320248 Commit-Queue: Patryk Duda <pdk@semihalf.com> Tested-by: Patryk Duda <pdk@semihalf.com> Reviewed-by: Jett Rink <jettrink@chromium.org>
* fpsensor: Run maintenance when in maintenance modeTom Hughes2020-08-312-0/+8
| | | | | | | | | | | | BRANCH=none BUG=b:76037094 TEST=make buildall -j Signed-off-by: Tom Hughes <tomhughes@chromium.org> Change-Id: Ibe8649c3cf77ef4542b5fc46d7df5eee03293b56 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2364755 Commit-Queue: Craig Hesling <hesling@chromium.org> Reviewed-by: Craig Hesling <hesling@chromium.org>
* power_button: Add CONFIG_POWER_BUTTON_TO_PCH_CUSTOMEdward Hill2020-08-291-1/+4
| | | | | | | | | | | | | | | Allow board to provide board_pwrbtn_to_pch function to override the default behavior of gpio_set_level(GPIO_PCH_PWRBTN_L, level) as the means for asserting power button signal to PCH. BUG=b:164921478 BRANCH=zork TEST=power button timing Signed-off-by: Edward Hill <ecgh@chromium.org> Change-Id: I8f5ffb2759318fdc941155b60be8bf4aa7dd4771 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2378557 Reviewed-by: Furquan Shaikh <furquan@chromium.org>
* driver: add ICM-426xx driver supportJean-Baptiste Maneyrol2020-08-291-0/+1
| | | | | | | | | | | | | | | Add ICM-426xx accel/gyro driver code. BUG=chromium:1117541 BRANCH=None TEST=ectool motionsense fifo_read && tast run hardware.SensorRing Signed-off-by: Jean-Baptiste Maneyrol <jmaneyrol@invensense.com> Change-Id: I83fe48abc6aa9cde86576a777ac4272d90fac597 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2317888 Reviewed-by: Gwendal Grignou <gwendal@chromium.org> Commit-Queue: Gwendal Grignou <gwendal@chromium.org> Tested-by: Gwendal Grignou <gwendal@chromium.org>
* TCPMv2: Send SOP'/SOP'' VDM only when the port is VCONN srcAyushee2020-08-282-1/+77
| | | | | | | | | | | | | | | | | | | | | | According to USB PD spec, section 2.5.4, only VCONN source can communicate with the cable plug. This CL checks if the port is the VCONN before sending SOP'/SOP'' messages. If there is a VCONN source failure, port retries swapping the VCONN times before marking the VDM as failed/naked. The CL also enables falling back to DP mode in case enter mode thunderbolt fails. BUG=b:148528713 BRANCH=None TEST=Tested on volteer, the port sends SOP'/SOP'' VDMs to the cable only if it's the VCONN source Signed-off-by: Ayushee <ayushee.shah@intel.com> Change-Id: I5880104a7a42b3e7de9e472affd41e937d36f9a5 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2368066 Reviewed-by: Abe Levkoy <alevkoy@chromium.org>
* TCPMv2: set VDM response buffer and lengthli feng2020-08-281-13/+30
| | | | | | | | | | | | | | | | | | | Pass tx_emsg[port].buf to VDM response implementation functions Convert data objects count to bytes VDM header in VDM response message should not use USB_VID_GOOGLE as SVID to respond to all requests. Save SVID from received request and compose response VDM header with this SVID. BUG=b:148528713,b:157163664 BRANCH=none TEST=Connect volteer to Gatkex DFP port, with CL:2370045, check VDM response messages from Volteer have correct contents. Signed-off-by: li feng <li1.feng@intel.com> Change-Id: I7403af1449abfa4ebf6b43ded457e3654396aadb Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2368067 Reviewed-by: Abe Levkoy <alevkoy@chromium.org>
* TCPMv2: handle un- and supported auto toggle TCPCRuibin Chang2020-08-281-0/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | This CL changes for both unsupported and supported auto toggle TCPC on a board: 1.board level enable CONFIG_USB_PD_TCPC_LOW_POWER: Exit LPM state for unsupported auto toggle TCPC port, when drp state is TOGGLE_ON in S0. 2.board level enable CONFIG_USB_PD_DUAL_ROLE_AUTO_TOGGLE: Don't transit to TC_DRP_AUTO_TOGGLE state for unsupported auto toggle TCPC port. BUG=none BRANCH=none TEST=on board drawcia, check unsupported auto toggle TCPC port: 1.connect with adapter/dongle, pd state to SNK/SRC_Ready during G3 -> S0. 2.shut down to G3, connect with adapter and pd state to SNK_Ready. Signed-off-by: Ruibin Chang <ruibin.chang@ite.com.tw> Change-Id: Ic6afc84df1564b2cb19a9032bba0752091cbf7a0 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2362371 Tested-by: Ruibin Chang <Ruibin.Chang@ite.com.tw> Reviewed-by: Diana Z <dzigterman@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org> Commit-Queue: Ruibin Chang <Ruibin.Chang@ite.com.tw>
* Charger: Add chgnum parameter to OTG set functionsDiana Z2020-08-273-11/+11
| | | | | | | | | | | | | | | | Add the charger number as an input for setting OTG output current and enabling it, both in the charger driver and in charge_set_output_current_limit(). Also add a clarifying note about the intent of CHARGER_SOLO. BRANCH=None BUG=b:147440290 TEST=make -j buildall Signed-off-by: Diana Z <dzigterman@chromium.org> Change-Id: I7656c19a87d8216f5efc72dcffa6d638064d3e2f Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2376469 Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
* OCPC: Assume port == chgnum when checking OTGDiana Z2020-08-271-0/+3
| | | | | | | | | | | | | | | Since OCPC has one charger chip per port, it can be assumed in the charger_is_sourcing_otg_power() function that the port will be the same as the charger number with this config enabled. BRANCH=None BUG=b:147440290 TEST=make -j buildall Signed-off-by: Diana Z <dzigterman@chromium.org> Change-Id: Iff5130e9ac7c268d38fe75eb3eb1c9ea5864abd4 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2376468 Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
* system_is_locked: Use static variable to track stateDuncan Laurie2020-08-271-1/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | When CONFIG_SYSTEM_UNLOCKED is not defined the function to check if flash is write protected (flash_get_protect()) can take up to 7ms to execute, and this function is called up to 18 times when booting from RO. Use a static variable to track the status so we do not spend so long executing this one function. Without this change I would regularly see a PD hard reset when booting without a battery and the system would fail to boot. BUG=b:63957122 BRANCH=eve TEST=manual testing to reliably boot without a battery on Eve Change-Id: I806a215b5745b41ce0d99aeb6853ebfecb0cb7d1 Signed-off-by: Duncan Laurie <dlaurie@google.com> Reviewed-on: https://chromium-review.googlesource.com/582542 Reviewed-by: Scott Collyer <scollyer@chromium.org> Reviewed-by: Furquan Shaikh <furquan@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2320002 Tested-by: Patryk Duda <pdk@semihalf.com> Reviewed-by: Jett Rink <jettrink@chromium.org> Commit-Queue: Patryk Duda <pdk@semihalf.com>
* hack: temporarily work around TX_COMPLETE failureJett Rink2020-08-271-2/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | After we removed the retry logic in the PRL layer, we uncovered an issue that was being masked. On Delbin, the state machine is not receiving that the PD messages (namely Request) is being sent successfully. We get neither success or failure within 100ms. We still need to figure out and fix this the root cause. This change just assumes that any sent PD traffic is successful after 100ms (instead of a failure) for Delbin boards only. There is an upcoming build for Delbin that we will have power on issues if we don't add some kind of power work around. This patch will not allow the USB PD stack on Delbin to work properly in all scenarios; this patch only aims to ensure that we can get power to the device to test other non-PD functionality. This CL should be reverted within a two week time frame. BRANCH=none BUG=b:164154200 TEST=Delbin can power on Signed-off-by: Jett Rink <jettrink@chromium.org> Change-Id: If6dce35dfd78ee3a70e6216a7b6bf62d3ded5646 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2376477 Reviewed-by: Keith Short <keithshort@chromium.org> Commit-Queue: Anson Tseng <ansontseng@google.com> Tested-by: Michael5 Chen <michael5_chen1@pegatron.corp-partner.google.com>
* CBI: Validate data size of input from hostDaisuke Nojiri2020-08-271-0/+4
| | | | | | | | | | | | | | | | | | | | Currently, the size of input data is not verified. This can cause read overflow in cbi_set_data. This patch makes the host command handler validate the input data size. BUG=chromium:1114458 BRANCH=none TEST=cros_fuzz --board=amd64-generic reproduce \ --fuzzer ec_host_command_fuzzer \ --testcase ...ec_host_command_fuzzer-5111452783935488 \ --package chromeos-ec --build-type asan Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> Change-Id: Ia3e03cd6bb857e0fa594de9d8cc66d8788d6dcd8 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2378203 Reviewed-by: Jett Rink <jettrink@chromium.org>
* Charger: Call discharge on AC for all chargersDiana Z2020-08-271-7/+9
| | | | | | | | | | | | | | | This change adds a loop to the common charger driver to set discharge on AC for all chargers, since it's unlikely a caller of this API would only want this feature enabled for a single port. BRANCH=None BUG=b:164256610 TEST=make -j buildall Signed-off-by: Diana Z <dzigterman@chromium.org> Change-Id: Ib23a93259a630016cb0f1384a6fc2b19b2baafb1 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2375725 Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
* TCPMv2: re-enable GetSnkCap call for allDenis Brockus2020-08-271-67/+99
| | | | | | | | | | | | | | | | | | | | | | | | | | The problem was a discarded SendSrcCap message that happened around the same time as the GetSnkCap. GetSnkCap timedout and did what it was supposed to do but the SendSrcCap locked up waiting for the message to transfer before it started the timer to allow it to time out. Never would happen. Built in a framework to track the current DPM request to make discard redirections easier to determine. Also good for re-queuing DPM requests that are discarded. BUG=b:165822172 BRANCH=none TEST=DUT-DUT PR_Swap Signed-off-by: Denis Brockus <dbrockus@google.com> Change-Id: I8854ac745d4489125c84b7e617d5fa1a94e70e51 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2370747 Tested-by: Denis Brockus <dbrockus@chromium.org> Auto-Submit: Denis Brockus <dbrockus@chromium.org> Commit-Queue: Jett Rink <jettrink@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org>
* TCPMv2: Modal Operations should clear in dfp_discovery_initDenis Brockus2020-08-261-0/+2
| | | | | | | | | | | | | BUG=b:165983983 BRANCH=none TEST=dock specified in bug should be able to PR_Swap Signed-off-by: Denis Brockus <dbrockus@google.com> Change-Id: Ifaccba2d741ed066e6bafc95c7e604b8f8dcfb17 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2373322 Tested-by: Denis Brockus <dbrockus@chromium.org> Reviewed-by: Diana Z <dzigterman@chromium.org> Commit-Queue: Denis Brockus <dbrockus@chromium.org>
* ocpc: Check CFET status before changing VSYSAseda Aboagye2020-08-261-0/+29
| | | | | | | | | | | | | | | | | | | | | | | | If the CFET is disabled, then the charging feedback loop is broken and any further adjustments of VSYS will have no effect on the charging current. Therefore, the system should not try to make any VSYS adjustments while this is occurring. This commit causes the the OCPC loop to check if the CFET is disabled before deciding to adjust VSYS or not. BUG=b:160918663 BRANCH=None TEST=Build and flash waddledee, charge DUT thru sub board until battery toggles the CFET, wait until the toggling ceases, verify that VSYS was not changed during that time. Signed-off-by: Aseda Aboagye <aaboagye@google.com> Change-Id: I7c0e5dce277118600b8f3120a6637938645db6ec Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2370044 Commit-Queue: Aseda Aboagye <aaboagye@chromium.org> Tested-by: Aseda Aboagye <aaboagye@chromium.org> Auto-Submit: Aseda Aboagye <aaboagye@chromium.org> Reviewed-by: Diana Z <dzigterman@chromium.org>
* battery_fuel_gauge: Add check for CFET statusAseda Aboagye2020-08-261-14/+54
| | | | | | | | | | | | | | | | | | | This commit adds a function that allows the system to check the if the charge FET (CFET) is disabled or not. BUG=b:160918663 BRANCH=None TEST=Build and flash waddledee; cutoff battery, revive system, verify that "found batt in disconnect" statements are still found. TEST=Add other code, verify that CFET status is able to be retrieved. Signed-off-by: Aseda Aboagye <aaboagye@google.com> Change-Id: I899070e50a38499708a367bba6b5f502b0232672 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2368071 Reviewed-by: Diana Z <dzigterman@chromium.org> Commit-Queue: Aseda Aboagye <aaboagye@chromium.org> Tested-by: Aseda Aboagye <aaboagye@chromium.org> Auto-Submit: Aseda Aboagye <aaboagye@chromium.org>
* usb_mux: move usb_mux_set_safe_mode()Keith Short2020-08-243-19/+15
| | | | | | | | | | | | | | Move usb_mux_set_safe_mode() definition into usb_common.c so it's available to the test framework. BUG=none BRANCH=none TEST=make buildall Signed-off-by: Keith Short <keithshort@chromium.org> Change-Id: I789a470468ae441e366afbf94ce3c29db526dfd8 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2370409 Reviewed-by: Denis Brockus <dbrockus@chromium.org>
* TCPMv2: Don't interrupt RX/TX Extended Chunked Msg sequenceSam Hurst2020-08-222-2/+32
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Delay sending a new message during the reception or transmitting of Chunked messages. BRANCH=none BUG=b:161836223 TEST=make -j buildall manual: Transmitted an extended message and verified that the sequence was not interrupted by attempting to send a VDM message. Without patch Chunked message request that was interrupted. 20-08-14 10:46:13.473 C1: RECV 9a9f/1 [0]00008c00 20-08-14 10:46:13.494 C1: RECV 9c9f/1 [0]00009400 20-08-14 10:46:13.516 C1: RECV 9e9f/1 [0]00009c00 20-08-14 10:46:13.535 C1: RECV 909f/1 [0]0000a400 Try to send VDM. MSG_TYPE is corrupted, was 0x1f, now 0x0f 20-08-14 10:46:13.563 C1: RECV 928f/1 [0]0000ac00 20-08-14 10:46:13.591 C1: RECV 948f/1 [0]0000b400 20-08-14 10:46:13.618 C1: RECV 968f/1 [0]0000bc00 20-08-14 10:46:13.645 C1: RECV 988f/1 [0]0000c400 20-08-14 10:46:13.674 C1: RECV 9a8f/1 [0]0000cc00 With patch. Chunked message request was not interrupted. 20-08-14 10:50:56.052 C1: RECV 9a9f/1 [0]00008c00 20-08-14 10:50:56.075 C1: RECV 9c9f/1 [0]00009400 20-08-14 10:50:56.093 C1: RECV 9e9f/1 [0]00009c00 20-08-14 10:50:56.114 C1: RECV 909f/1 [0]0000a400 Try to send VDM. Message delayed 20-08-14 10:50:56.134 C1: RECV 929f/1 [0]0000ac00 20-08-14 10:50:56.155 C1: RECV 949f/1 [0]0000b400 20-08-14 10:50:56.175 C1: RECV 969f/1 [0]0000bc00 20-08-14 10:50:56.195 C1: RECV 989f/1 [0]0000c400 20-08-14 10:50:56.216 C1: RECV 9a9f/1 [0]0000cc00 20-08-14 10:50:56.242 C1: RECV 0c90/0 Try to send VDM. Signed-off-by: Sam Hurst <shurst@google.com>wq Change-Id: I5475792ee9f272fe4964e27839e55e3409a6a799 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2357414
* usbc: remove PD_EVENT_SM in favor of task_wakeJett Rink2020-08-213-14/+13
| | | | | | | | | | | | | | | | We have used both methods of waking up the PD tasks to process the next state: PD_EVENT_SM and TASK_EVENT_WAKE. They effectively do the same thing and it is more straightforward to only have one way to wake the task up with the sole purpose of re-evaluating the current state. BRANCH=none BUG=none TEST=No regressions on GRL testing. Signed-off-by: Jett Rink <jettrink@chromium.org> Change-Id: I0fa79b82223e6b97eede4130480156949d79f365 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2363466 Reviewed-by: Edward Hill <ecgh@chromium.org>