summaryrefslogtreecommitdiff
path: root/common/usb_pd_dual_role.c
Commit message (Collapse)AuthorAgeFilesLines
* TCPMv1: Replace charging allow listTing Shen2021-01-121-45/+0
| | | | | | | | | | | | | | | | This CL backports CL:2535217 to TCPMv1, and completely removes charging allow list. BRANCH=kukui BUG=b:175364716 TEST=on Burnet, verify DUT can charge from power bank. Signed-off-by: Ting Shen <phoenixshen@google.com> Change-Id: I89476c89fd4ab6d46acf880f7573b5deb8b2c0f4 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2603614 Reviewed-by: Diana Z <dzigterman@chromium.org> Tested-by: Ting Shen <phoenixshen@chromium.org> Commit-Queue: Ting Shen <phoenixshen@chromium.org>
* usb_pd_dual_role: Respect max voltage limit when processing capabilitiesPatryk Duda2020-12-151-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | To process source capabilities received from charger we just find the most appropriate PDO and inform charge manager about our choice (pd_process_source_cap() function). This function doesn't respect any voltage limits, so even when such a limit exists charge manager will be informed about higher voltage. Of course PD stack will request correct voltage from charger and charge manager will be notified about that fact, but providing wrong information about voltage can cause unnecessary new power requests. This issue was found during debugging EC hibernate issue on casta. BUG=b:161775827 BRANCH=none TEST=Flash EC ToT on casta. Set voltage limit to 5V. Observe if charge manager reports voltage changes from 5V to 15V (in my case) when received capabilities from ServoV4. NOTE: ServoV4 will send capabilities to DUT as a result of voltage transition (requested by ServoV4). Signed-off-by: Patryk Duda <pdk@semihalf.com> Change-Id: I5fe30f7a1b86fb1d934a29429147d9d7c9a84337 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2592496 Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
* TCPMv2: Print VID/PID only when presentDiana Z2020-11-121-1/+4
| | | | | | | | | | | | | | | | Not all partners will reply to DiscoverIdentity, so only print out their VID/PID combination when the VID is non-zero. BRANCH=None BUG=None TEST=on drawcia, plug in a charger which does not reply to DiscoverIdentity and verify it doesn't print Signed-off-by: Diana Z <dzigterman@chromium.org> Change-Id: I1ea114794ada20b68cb6f902b085a2fd02650912 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2535216 Reviewed-by: Denis Brockus <dbrockus@chromium.org> Commit-Queue: Denis Brockus <dbrockus@chromium.org>
* tcpmv2: Move "Allow_List" print to USBPD channelKeith Short2020-11-041-1/+3
| | | | | | | | | | | | | | | | | Move the allow_list not found message from the CONSOLE to the USBPD channel. This allows the message to be disabled during tests. BUG=none BRANCH=none TEST=make buildall TEST=Run "chan 0" and connect a charger that isn't in the allow list to volteer. Signed-off-by: Keith Short <keithshort@chromium.org> Change-Id: I395a701ee955200ad183dcb7da64d662d3611a4b Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2518730 Reviewed-by: Denis Brockus <dbrockus@chromium.org> Commit-Queue: Denis Brockus <dbrockus@chromium.org>
* TCPMv2: Add allow_list for partners that didn't set UP but should haveDenis Brockus2020-10-301-3/+6
| | | | | | | | | | | | | | | | | | Added three additional monitors and renamed the defines to tell what the PID is. BUG=b:171013724 BRANCH=zork TEST=connect new devices and make sure they source us Signed-off-by: Denis Brockus <dbrockus@google.com> Change-Id: Iaf18d6aaad40ff5ac8d8bb57bc2568a9256712bb Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2509974 Commit-Queue: Denis Brockus <dbrockus@chromium.org> Commit-Queue: Edward Hill <ecgh@chromium.org> Tested-by: Denis Brockus <dbrockus@chromium.org> Auto-Submit: Denis Brockus <dbrockus@chromium.org> Reviewed-by: Edward Hill <ecgh@chromium.org>
* TCPMv2: Create charge allow_list and add devicesDenis Brockus2020-10-221-6/+33
| | | | | | | | | | | | | | | | | | | | | | | | | | | | The charge allow_list is for partner devices that do not advertise Unconstrained Power in their SRC_Caps but we should still charge from them if they are the SRC. The allow_list should be constrained to partners that perform dual role and do not present Unconstrained Power in their SRC_Caps. It is preferred for the partner to send this correctly but for products that are already out in the wild, it may be a really bad user experience for this to fail. BUG=b:170644500,b:170848849,b:170970249 BRANCH=zork TEST=connect E24d monitor and verify it charges DUT Signed-off-by: Denis Brockus <dbrockus@google.com> Change-Id: Ib4f2c62af3bb2c1ed066ea4353ec26cd536a4c26 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2490729 Tested-by: Denis Brockus <dbrockus@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org> Reviewed-by: Diana Z <dzigterman@chromium.org> Commit-Queue: Denis Brockus <dbrockus@chromium.org> Auto-Submit: Denis Brockus <dbrockus@chromium.org>
* TCPMv2: Use a common function to check if the battery is capableWai-Hong Tam2020-10-171-20/+30
| | | | | | | | | | | | | | | | | Move the battery checks to a common function, which is used to enable Try.SRC and enable PD comm for CONFIG_SYSTEM_LOCKED. BRANCH=None BUG=b:169453974 TEST=On a board with battery which takes longer time to enable its discharge FET, cut off the battery and booted the board. Checked on startup the Try.SRC was disabled and the PD comm was disabled. When the battery discharge FET became active, PD comm was enabled. Change-Id: I236d5f8a462ece056b4adedd0b6e6ef1e402966c Signed-off-by: Wai-Hong Tam <waihong@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2461942 Reviewed-by: Aseda Aboagye <aaboagye@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>
* charge_manager: two charger DUT does not choose correct portDenis Brockus2020-09-081-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | 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>
* config: Require battery >5% to enable PD Try.SRCWai-Hong Tam2020-08-181-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Align the CONFIG_USB_PD_TRY_SRC_MIN_BATT_SOC to the value of BATTERY_LEVEL_CRITICAL, which is 5%. The BATTERY_LEVEL_CRITICAL is 5% that means EC will send battery- critical host event when the battery level <= 5%. CrOS PD policies state that the system doesn't source power to any external USB devices when AP is shutdown. So the current CONFIG_USB_PD_TRY_SRC_MIN_BATT_SOC 1% default has no point. When the battery level is <= 5%, AP should be shutdown soon and the system should not be a source, so should not enable Try.SRC. Also change the comparison from soc >= CONFIG_USB_PD_TRY_SRC_MIN_BATT_SOC to soc > CONFIG_USB_PD_TRY_SRC_MIN_BATT_SOC as the battery critical check is soc <= BATTERY_LEVEL_CRITICAL. BRANCH=None BUG=b:165057418 TEST=Plugging a PD charger to a board with the battery level very low, the system boots up (was failed), Change-Id: If6b11feacd62fd003e13b1756eb5c33d2f9bbce4 Signed-off-by: Wai-Hong Tam <waihong@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2360543 Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
* ec: change usage of whitelist/blacklistPaul Fagerburg2020-07-281-1/+1
| | | | | | | | | | | | | | | | | | | Google is working to change its source code to use more inclusive language. To that end, replace the terms "whitelist", "blacklist", and similar with inclusive alternatives. BUG=b:162262297 BRANCH=None TEST=`grep -Eirl "(white|black)[ _\-]*list" .` The only results are in "private/nordic_keyboard/sdk8.0.0" which is not our code. Signed-off-by: Paul Fagerburg <pfagerburg@google.com> Change-Id: Ie5210b98e1096c22d0e9284c101a42820bd3d79d Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2321549 Tested-by: Paul Fagerburg <pfagerburg@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org> Commit-Queue: Paul Fagerburg <pfagerburg@chromium.org>
* USB PD: Check supplier instead of port.Andrew McRae2020-05-011-3/+3
| | | | | | | | | | | | | | | | When in dual role, check the charger supplier rather than the port number to verify it is a dedicated charger. BUG=b:155368947 TEST=Build and verify on puff that dual role is selected. BRANCH=none Signed-off-by: Andrew McRae <amcrae@google.com> Change-Id: If23594a4321da2370bd8f2f787a6091041073189 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2173930 Reviewed-by: Andrew McRae <amcrae@chromium.org> Commit-Queue: Andrew McRae <amcrae@chromium.org> Tested-by: Andrew McRae <amcrae@chromium.org>
* TCPMv2: Restore PD state after SysjumpSam Hurst2020-04-021-0/+45
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When a PD explicit contract is negotiated in RO, the contract is maintained while performing a sysjump to RW. This is done by serializing the PD Power, Data, and VCONN Roles, along with the explicit contract flag. After jumping to RW, deserialization is performed by restoring the power roles and setting the explicit contract flag. BUG=b:152350558,b:152027807,b:152967274 BRANCH=none TEST=make -j buildall Manual tests: Used total phase to verify that charging voltage was maintained across sysjump from RO to RW and that DP was reestablished when a dock was used. Tested that Kohaku booted properly without a battery and a charger connected to port 0. This test was repeated with a charger connected to port 1. Signed-off-by: Sam Hurst <shurst@google.com> Change-Id: I349c41f2279e9af9830564d44ac73ad8435f1f80 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2119131 Tested-by: Sam Hurst <shurst@google.com> Reviewed-by: Denis Brockus <dbrockus@chromium.org> Commit-Queue: Denis Brockus <dbrockus@chromium.org>
* TCPMv1/v2: Move pd_is_try_source_capable() to common fileVijay Hiremath2020-02-191-0/+48
| | | | | | | | | | | | BUG=b:148528713 BRANCH=none TEST=make buildall -j Change-Id: I79f75d23f6091a264c11b4da6cf0cea26205df60 Signed-off-by: Vijay Hiremath <vijay.p.hiremath@intel.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2052648 Reviewed-by: Denis Brockus <dbrockus@chromium.org> Reviewed-by: Diana Z <dzigterman@chromium.org>
* TCPMv1/v2: Reduce number of arguments of pd_build_request()Vijay Hiremath2020-02-141-8/+37
| | | | | | | | | | | | | | | | BUG=b:148528713 BRANCH=none TEST=Manually tested on Volteer 1. When only one charger connected: Able to negotiate to PD max. 2. When two chargers are connected (one on each port): Non charging port is rejected Swaps the charging port based on charger's priority Change-Id: Ib7fdc5d31bf36189a85f8cd3217bec78f83a9efe Signed-off-by: Vijay Hiremath <vijay.p.hiremath@intel.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2051318 Reviewed-by: Keith Short <keithshort@chromium.org>
* TCPMv1/v2: Move pd_process_source_cap() to common fileVijay Hiremath2020-02-121-0/+20
| | | | | | | | | | | BUG=b:148528713 BRANCH=none TEST=make buildall -j Change-Id: I6bd6b5875a322ca4ba6d77a4cfc96a72630e5f5c Signed-off-by: Vijay Hiremath <vijay.p.hiremath@intel.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2051220 Reviewed-by: Keith Short <keithshort@chromium.org>
* TCPMv1/v2: Move PDO functions to PD dual role module fileVijay Hiremath2020-02-121-0/+258
| | | | | | | | | | | BUG=b:148528713 BRANCH=none TEST=make buildall -j Change-Id: Ib43a83084b087905a8322bfd2bea2fe70ec33c1d Signed-off-by: Vijay Hiremath <vijay.p.hiremath@intel.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2051219 Reviewed-by: Keith Short <keithshort@chromium.org>
* TCPMv1/v2: Move pd_get/set_max_voltage() to common fileVijay Hiremath2020-02-121-0/+18
| | | | | | | | | | | BUG=b:148528713 BRANCH=none TEST=make buildall -j Change-Id: I6fd4c870b8821a2393c67fda7003583b91ef7f5c Signed-off-by: Vijay Hiremath <vijay.p.hiremath@intel.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2051218 Reviewed-by: Keith Short <keithshort@chromium.org>
* TCPMv1/v2: Move pd_charge_from_device() to common fileVijay Hiremath2020-02-121-0/+20
BUG=b:148528713 BRANCH=none TEST=make buildall -j Change-Id: I2327ceaf6be76a0428981106aaeb3ffbb2018049 Signed-off-by: Vijay Hiremath <vijay.p.hiremath@intel.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2051217 Reviewed-by: Keith Short <keithshort@chromium.org>