summaryrefslogtreecommitdiff
path: root/include/usb_pd_tcpm.h
Commit message (Collapse)AuthorAgeFilesLines
* zephyr: move usbc interrupt handler to shimJason Yuan2023-02-091-0/+4
| | | | | | | | | | | | | | | | | | | TCPC interrupt no longer uses gpio-int. Instead the shim tcpc completely handles its own interrupt. An optional config is added to allow projects to use the legacy tcpc interrupt. The program intelrvp is excluded from this CL. BUG=b:254148652 TEST=twister, usbc charging on villager, lazor, and xivu BRANCH=none Change-Id: Ieeb4fb61ca6cf8f44df212a6cf520d265cff5147 Signed-off-by: Jason Yuan <jasonyuan@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4108942 Commit-Queue: zhi cheng yuan <jasonyuan@chromium.org> Reviewed-by: Keith Short <keithshort@chromium.org> Tested-by: Diana Z <dzigterman@chromium.org>
* ec: Add #line directive to fix coverageJeremy Bettis2023-01-111-0/+7
| | | | | | | | | | | | | | | | | | Once again, gcc is buggy when importing common.h. Add #line to usb_pd_tcpm.h where the problem is showing up today. BRANCH=None BUG=b:265061949 TEST=See bug Change-Id: I08ed9f5574e026dbc371c7634d0bf046df9c95ac Signed-off-by: Jeremy Bettis <jbettis@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4157000 Tested-by: Jeremy Bettis <jbettis@chromium.org> Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com> Auto-Submit: Jeremy Bettis <jbettis@chromium.org> Reviewed-by: Al Semjonovs <asemjonovs@google.com> Commit-Queue: Jeremy Bettis <jbettis@chromium.org>
* include: Sort header filesJeremy Bettis2022-11-291-1/+2
| | | | | | | | | | | | | | | | | | | | Sort all includes in include with the clang-format rules used by the zephyr project. BRANCH=None BUG=b:247100970 TEST=zmake build -a TEST=./twister --clobber -v -i TEST=make -j72 buildall_only runtests TEST=zmake compare-builds -a Signed-off-by: Jeremy Bettis <jbettis@google.com> Change-Id: Ic23f440ebd93519e4341423cf6cb7a298620cbfe Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4049883 Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com> Commit-Queue: Jeremy Bettis <jbettis@chromium.org> Tested-by: Jeremy Bettis <jbettis@chromium.org> Reviewed-by: Tristan Honscheid <honscheid@google.com>
* tcpc: modify nct38xx and fusb302 get vbus voltage functionMatt Wang2022-10-191-9/+0
| | | | | | | | | | | | | | | | | | Modify nct38xx and fusb3802 get vbus voltage function to use the tcpm_drv API. BUG=b:252974232 BRANCH=none TEST=zmake build skyrim winterhold adlrvp_npcx ass TEST=Winterhold with this function ectool usbpdpower can get the voltage LOW_COVERAGE_REASON=we don't have an NCT emulator yet Signed-off-by: Matt Wang <matt_wang@compal.corp-partner.google.com> Change-Id: Iedd7165aad0c471c60f750cc4b207eef609d2eed Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3951752 Reviewed-by: Diana Z <dzigterman@chromium.org> Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com> Reviewed-by: Elthan Huang <elthan_huang@compal.corp-partner.google.com>
* Update license boilerplate text in source code filesMike Frysinger2022-09-121-1/+1
| | | | | | | | | | | | | | | Normally we don't do this, but enough changes have accumulated that we're doing a tree-wide one-off update of the name & style. BRANCH=none BUG=chromium:1098010 TEST=`repo upload` works Change-Id: Icd3a1723c20595356af83d190b2c6a9078b3013b Signed-off-by: Mike Frysinger <vapier@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3891203 Reviewed-by: Jeremy Bettis <jbettis@chromium.org> Reviewed-by: Jack Rosenthal <jrosenth@chromium.org>
* tcpm: add tcpc_get_bist_test_modeEric Yilun Lin2022-08-221-0/+10
| | | | | | | | | | | | | | | | Add tcpc_get_bist_test_mode which returns the BIST mode control status. BUG=b:229812911 TEST=ensure the BIST status is reported correctly BRANCH=none Change-Id: Idbec04e449c962ee1b3185aa91a324c1a5215960 Signed-off-by: Eric Yilun Lin <yllin@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3787827 Commit-Queue: Eric Yilun Lin <yllin@google.com> Reviewed-by: Abe Levkoy <alevkoy@chromium.org> Tested-by: Eric Yilun Lin <yllin@google.com>
* TCPCI: nct38xx: Only restore mask registers during hard resetDevin Lu2022-07-141-0/+13
| | | | | | | | | | | | | | | | | | | | Currently the mask registers will be reseted after hard reset received. TCPM did full initialization and restore the mask registers as well. However, full initialization will cause tPSHardReset time to worse. To improve tPSHardReset time during hard reset, so only restore the mask registers during hard reset. BUG=b:232326002 BRANCH=none TEST=On Vell. Check tPSHardReset time. Signed-off-by: Devin Lu <Devin.Lu@quantatw.com> Change-Id: I2ae250af7cb06fe5102c8ba4dce98e5d467a2d93 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3702883 Tested-by: Devin Lu <devin.lu@quantatw.com> Reviewed-by: Abe Levkoy <alevkoy@chromium.org> Reviewed-by: Diana Z <dzigterman@chromium.org> Commit-Queue: Diana Z <dzigterman@chromium.org>
* include/usb_pd_tcpm.h: Format with clang-formatJack Rosenthal2022-06-281-41/+41
| | | | | | | | | | | BUG=b:236386294 BRANCH=none TEST=none Change-Id: I12f359fbc1ee16f07a36536a2279ae171c6c6eec Signed-off-by: Jack Rosenthal <jrosenth@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3730444 Reviewed-by: Jeremy Bettis <jbettis@chromium.org>
* tcpm: Support PD chips with SBU protectionVijay Hiremath2022-05-261-0/+19
| | | | | | | | | | | | | | | | | | | | | Some PD chips have integrated port protection for SBU lines and the switches to enable the SBU lines coming out of the PD chip are controlled by vendor specific registers. Hence, added the code in TCPM & driver skeleton in TCPCI to support those chips. By checking if the SBU enable function exists in TCPM driver before trying to enable the SBU from discrete PPC, this code supports co-existence of both PD based SBU protection and discrete PPC chip SBU protection in a same platform. BUG=none BRANCH=none TEST=make buildall -j, zmake testall Change-Id: I3d3a5eec9077df95c0eb91cf1a709cb79f36ca60 Signed-off-by: Vijay Hiremath <vijay.p.hiremath@intel.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3227374 Reviewed-by: Abe Levkoy <alevkoy@chromium.org>
* zephyr: tcpm: Add flags property to TCPC yamlAl Semjonovs2022-05-161-0/+8
| | | | | | | | | | | | | Updated ps8xxx device to include TCPC config flags BUG=b:231291434 BRANCH=NONE TEST=Attach USBC to DUT and make sure device is detected. Signed-off-by: Al Semjonovs <asemjonovs@google.com> Change-Id: I9d38ad8ed988bb6d2c57976261dde65cdfe0075b Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3645317 Reviewed-by: Abe Levkoy <alevkoy@chromium.org>
* TCPCI: Allow TCPM to use sink/source control without PPCs presenceDevin Lu2022-05-101-2/+0
| | | | | | | | | | | | | | | This patch removes define CONFIG_USBC_PPC to allow TCPM to use sink and source control without PPCs presence. since they exist generally in TCPCI specification independently of PPCs. BUG=b:211791444 BRANCH=none TEST=make buildall Signed-off-by: Devin Lu <Devin.Lu@quantatw.com> Change-Id: Ia4be8bf872f981c23908944381b156778f63064b Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3597314 Reviewed-by: Diana Z <dzigterman@chromium.org>
* tcpci: support tcpci_get_vbus_voltageEric Yilun Lin2022-03-041-0/+12
| | | | | | | | | | | | | | | | Implement the common interface tcpic_get_vbus_voltage BUG=b:214893572 TEST=on kinger, the VBUS ADC reading is correct BRANCH=none Change-Id: I5f31533e8b290b4019e74870053e009b0da6ddcf Signed-off-by: Eric Yilun Lin <yllin@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3400768 Auto-Submit: Eric Yilun Lin <yllin@google.com> Tested-by: Eric Yilun Lin <yllin@google.com> Reviewed-by: Diana Z <dzigterman@chromium.org> Commit-Queue: Diana Z <dzigterman@chromium.org>
* tcpm: allow TCPC FRS without CONFIG_USB_PD_FRS_TCPCCaveh Jalali2022-02-031-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | This introduces a new TCPC port flag (TCPC_FLAGS_CONTROL_FRS) that allows it to be configured for TCPC based FRS independently of other ports. Traditionally, we would enable CONFIG_USB_PD_FRS_TCPC, but that config option applies to all ports which is not appropriate in some devices. Brya's ps8815 daughterboard needs FRS_TCPC while the other ports need FRS_PPC. To enable this feature, CONFIG_USB_PD_FRS must be enabled for basic FRS support. Then, any TCPC port with TCPC_FLAGS_CONTROL_FRS set will be treated like CONFIG_USB_PD_FRS_TCPC was enabled. The new API tcpm_tcpc_has_frs_control(port) is used instead of IS_ENABLED(CONFIG_USB_PD_FRS_TCPC). BRANCH=none BUG=b:216411401 TEST=buildall passes Cq-Depend: chromium:3432915 Change-Id: I9c3c35c5921b6afb8241e1d9e1205fe7064d40cf Signed-off-by: Caveh Jalali <caveh@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3417012 Reviewed-by: Keith Short <keithshort@chromium.org>
* TCPCI: Add an interface for I2C wakeDiana Z2021-11-111-0/+10
| | | | | | | | | | | | | | | | | | When we wake a TCPC from I2C idle, there is a procedure in the TCPCI specificaiton to follow. Implementing the full procedure will take some refactoring, but for now at least send the i2c wake to the chip when we plan to wake it. Otherwise, we don't actually wake the chip until the LPM exit debounce finishes, which isn't in the intended use of the LPM exit debounce. BRANCH=None BUG=b:195393479 TEST=make -j buildall Signed-off-by: Diana Z <dzigterman@chromium.org> Change-Id: I6d5a6d27cce653ab02b59ab0e09d06657f640c39 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3262585 Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
* tcpm: Add port flag indicating if the TCPC controls VCONNCaveh Jalali2021-10-291-0/+2
| | | | | | | | | | | | | | | | | | This adds a port flag to indicate that its TCPC needs to control VCONN. We have a global compile time flag (CONFIG_USB_PD_TCPC_VCONN) to enable TCPC control of VCONN. However, on some device architectures, such a global setting is not suitable for all ports in the system. So, add a port flag to enable VCONN control where it would otherwise be disabled. BRANCH=none BUG=b:204102039 TEST=with reset of patch stack, external monitor links up using active TBT4 cable Change-Id: I9028f65a8b10b2f8eb5b614a256d90e05064b4c3 Signed-off-by: Caveh Jalali <caveh@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3252410 Reviewed-by: Boris Mittelberg <bmbm@google.com>
* board/metaknight: Fix compilation error when using clangTom Hughes2021-10-271-0/+1
| | | | | | | | | | | | | | | | | | | | | clang warns: board/metaknight/board.c:787:10: error: array index 1 is past the end of the array (which contains 1 element) [-Werror,-Warray-bounds] if (!(tcpc_config[1].flags & TCPC_FLAGS_TCPCI_REV2_0)) ^ ~ board/metaknight/board.c:741:1: note: array 'tcpc_config' declared here const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_MAX_COUNT] = { ^ BRANCH=none BUG=b:172020503 TEST=CC=clang make BOARD=metaknight Signed-off-by: Tom Hughes <tomhughes@chromium.org> Change-Id: I510d6ec4343f258d734834f2d1e3b6760fca7761 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3238248 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
* TCPM: Rename enum tcpm_sop_type and its constantsAbe Levkoy2021-08-311-13/+14
| | | | | | | | | | | | | | | As a followup to CL:3104290, give the TCPCI TRANSMIT and RX_BUF_FRAME_TYPE types more consistent names. Most of them can be used for receiving, not just transmitting. Fix lint errors thus revealed. BUG=b:155476419 TEST=make buildall BRANCH=none Signed-off-by: Abe Levkoy <alevkoy@chromium.org> Change-Id: I399ec479eacc18622fc4d3f55f8bdabf4560fcff Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3125995 Reviewed-by: Keith Short <keithshort@chromium.org>
* TCPM: Rename enum tcpm_transmit_typeAbe Levkoy2021-08-181-2/+9
| | | | | | | | | | | | | | | Rename tcpm_transmit_type to tcpm_sop_type to reflect that it can be used for Rx as well. Describe it in comments. This prepares to consolidate enum pd_msg_type into this enum. BUG=b:155476419 TEST=make buildall BRANCH=none Signed-off-by: Abe Levkoy <alevkoy@chromium.org> Change-Id: Ife97d4ad51c48f2e832b94e007954919e236a309 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3104290 Reviewed-by: Keith Short <keithshort@chromium.org>
* TCPC: add flag to disable debug accessory controlBoris Mittelberg2021-07-131-0/+2
| | | | | | | | | | | | | | | | | The NCT38xx TCPC takes over the GPIO we otherwise use to control the Burnside Bridge on Brya P1 devices. To get the BB out of reset we add the flag to tcpc_config structure to take the control back to TCPM. BRANCH=none BUG=b:191516281 TEST=running deployment in the lab; running FAFT PD test Signed-off-by: Boris Mittelberg <bmbm@google.com> Change-Id: I73ddf26964cc6363640ddd80fbcbf353704d3198 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3016406 Reviewed-by: caveh jalali <caveh@chromium.org> Reviewed-by: Aseda Aboagye <aaboagye@chromium.org> Reviewed-by: Diana Z <dzigterman@chromium.org>
* Specify type for forward-declared enumsTom Hughes2021-05-061-1/+2
| | | | | | | | | | | | | C++ does not allow enums to be forward declared unless they have a type. BRANCH=none BUG=b:144959033 TEST=make buildall Signed-off-by: Tom Hughes <tomhughes@chromium.org> Change-Id: I6fcdedc81f2b60a44b750554939e60552a4c6a77 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2740567 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
* util: Add explicit castsTom Hughes2021-05-061-1/+1
| | | | | | | | | | | | | | When compiling with C++, the implicit casting that is performed in C is disallowed. Add casts in preparation for C++ compatibility. BRANCH=none BUG=b:144959033 TEST=make buildall Signed-off-by: Tom Hughes <tomhughes@chromium.org> Change-Id: I5c25440819428db65225c772c1c5115a735db58a Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2864519 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
* TCPC: Cleanup: Get Sink & SRC state from PD or PPCVijay Hiremath2021-04-211-6/+4
| | | | | | | | | | | | | | Added option to get the Sinking or Sourcing state from either PD or PPC. BUG=none BRANCH=none TEST=make buildall -j Change-Id: Ibb21ef69b5825ea5722ceacd5d7ef6f535aad17c Signed-off-by: Vijay Hiremath <vijay.p.hiremath@intel.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2838127 Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
* TCPC: Cleanup: Enable PPC from PD or Power MUXVijay Hiremath2021-04-201-1/+1
| | | | | | | | | | | | | | | Some PD chips have integrated SRC FET and control the SRC/SINK FET from GPIOs hence cleaned up the code to enable Power Path Control from either from PD or from Power MUX. BUG=none BRANCH=none TEST=make buildall -j Change-Id: I77f96b681fd2e5fca35bce425e4bd5ec87d5ccfd Signed-off-by: Vijay Hiremath <vijay.p.hiremath@intel.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2828980 Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
* TCPMv2: PRL: Enahnce support for the tx message discard pathScott Collyer2021-03-311-3/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This CL modifies the tx message discard path in the PRL. The states that should have triggered tx message discard events, would only act on messages pending from PE, but not passed yet to the phy. This behavior was required to account for the serial nature of the different PRL state machines and inherent delay in sending/receiving messages to/from off chip TCPCs via the I2C bus. This CL adds a new WAIT value to the xmit_status enum so that a message being sent to the phy but not reponse yet can be known. In addition, xmit_status == DISCARDED is no longer treated automatically as a protocol error. BUG=b:181179550,b:173028144 BRANCH=None TEST=Running VDMU.E16 compliance test. Validated that the SVDM command sequence is properly interrupted in most all cases. This test only fails if collision events are present which is a happening on honybuns for 2 reasons: 1) GRL test waits too long to interrupt the VDM command (~1 msec) 2) honeybuns ucpd is faster since it doesn't have i2c delays. Signed-off-by: Scott Collyer <scollyer@google.com> Change-Id: I2bec09b96d7f6ea6122fcb369246717950987ca8 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2752251 Tested-by: Scott Collyer <scollyer@chromium.org> Reviewed-by: Diana Z <dzigterman@chromium.org> Commit-Queue: Scott Collyer <scollyer@chromium.org>
* TCPMv2: Add support for disabling type-2 BIST modeScott Collyer2021-03-121-0/+2
| | | | | | | | | | | | | | | | | | | | | | This CL adds a TCPCI method to disable BIST mode for the case where the TCPC does not handle the duration automatically. This is required for the ucpd driver as once type-2 BIST mode is started, the ucpd peripheral needs to be reset to stop. This CL also reduces the timer value from 60 msec to 55 msec to ensure that there is enough time for BIST to be stopped and still be in spec. BUG=b:182436876 BRANCH=None TEST=verifed on Quiche that when type-2 BIST is started then it stops when the timer in PE expires. This fixes TDA.2.1.1.1: BMC-PHY-TX-EYE Signed-off-by: Scott Collyer <scollyer@google.com> Change-Id: I59ee7ac0dead09ac3a1b5783cfa3fe9db238eb7e Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2660803 Tested-by: Scott Collyer <scollyer@chromium.org> Reviewed-by: Diana Z <dzigterman@chromium.org> Commit-Queue: Scott Collyer <scollyer@chromium.org>
* TCPMv2: Support BIST Test ModeAbe Levkoy2021-01-221-0/+12
| | | | | | | | | | | | | | | | | | After the first BIST Test Data packet, enable BIST Test Mode if the TCPC supports it (currently just TCPCI). While in BIST Test Mode, mask ALERT.ReceivedSOP*MessageStatus. Unmask it when the test ends, due to Hard Reset or to detach. BUG=b:173023378,b:169385081,b:172709198,b:173028832,b:173028791 BUG=b:173141941,b:173142113 TEST=Complete TDA.2.1.2.2 BMC PHY RX INT REJ on volteer without running out of Rx buffer space or watchdog timeout (still fail though) BRANCH=firmware-volteer-13521.B-master Signed-off-by: Abe Levkoy <alevkoy@chromium.org> Change-Id: I03bbc4cfacceebd0334aa814e11a16e09177a322 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2545667 Reviewed-by: Diana Z <dzigterman@chromium.org>
* TCPC: Change SOP' disable interfaceDiana Z2020-11-181-3/+5
| | | | | | | | | | | | | | | Add the ability to enable or disable SOP' traffic through a new parameter. Name the function for "enable" to match other EC conventions. BRANCH=None BUG=b:168560801 TEST=make -j buildall Signed-off-by: Diana Z <dzigterman@chromium.org> Change-Id: Ife52e7d7d098825ab2163c70a4c59510da958876 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2542864 Reviewed-by: Keith Short <keithshort@chromium.org>
* tcpc: Cleanup usage of tcpci_set_role_ctrl()Keith Short2020-11-181-0/+6
| | | | | | | | | | | | | | Cleanup arguments for tcpci_set_role_ctrl(). BUG=b:171430855 BRANCH=firmware-volteer-13521.B-master TEST=make buildall Signed-off-by: Keith Short <keithshort@chromium.org> Change-Id: Ib58defb5f9bcd3c3fe3d7de4239aa19e5545b778 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2544802 Reviewed-by: Denis Brockus <dbrockus@chromium.org> Reviewed-by: Abe Levkoy <alevkoy@chromium.org>
* Revert "topology: Add USB2 & USB3 connectivity info to tcpc_config_t"caveh jalali2020-11-061-7/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This reverts commit f5121aa5b762a68e9e2bca3c4c132cb2ffc9cfdb. Reason for revert: feature no longer used BRANCH=none BUG=b:153941950 TEST=buildall passes Original change's description: > topology: Add USB2 & USB3 connectivity info to tcpc_config_t > > Intel SoC needs which USB2/3 ports are assigned to which Type-C ports. > This patch adds USB2 and USB3 port numbers to tcpc_config_t so that > EC_CMD_LOCATE_CHIP can return it to the host. > > Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> > > BUG=b/134614710 > BRANCH=none > TEST=TBD > > Change-Id: I10206dde4d71ac6e40a71c65333db4edd3c81e7a > Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1669880 > Reviewed-by: Vijay P Hiremath <vijay.p.hiremath@intel.com> > Reviewed-by: Aseda Aboagye <aaboagye@chromium.org> > Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org> > Tested-by: Daisuke Nojiri <dnojiri@chromium.org> > Auto-Submit: Daisuke Nojiri <dnojiri@chromium.org> > Commit-Queue: Daisuke Nojiri <dnojiri@chromium.org> Bug: b/134614710 Change-Id: Ibd60e7e3d59e11734a3a08917be3daaae7fb569d Signed-off-by: Caveh Jalali <caveh@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2427440 Reviewed-by: Vijay P Hiremath <vijay.p.hiremath@intel.com> Reviewed-by: Keith Short <keithshort@chromium.org> Commit-Queue: Keith Short <keithshort@chromium.org>
* TCPMv2: Add debug detach interfaceDiana Z2020-10-191-0/+8
| | | | | | | | | | | | | | Some TCPCs may require special commands to be run after a debug accessory leaves the Attached.SNK/SRC states. Add an interface to support this, and call it from the TC when needed. BRANCH=None BUG=b:159495742,b:170259606 TEST=make -j buildall Signed-off-by: Diana Z <dzigterman@chromium.org> Change-Id: I79c7ebc308958c598cfa228598362c97b9b00e86 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2481941
* TCPMv2: Add TYPEC_STATUS commandDiana Z2020-10-051-25/+0
| | | | | | | | | | | | | | | | | | | | | | | The TYPEC_STATUS command will be deprecating the informational return from the USB_PD_CONTROL host command. It brings over the enablement, role, and connection information from the older command. Cable specifics are excluded as they are redundant with the discovery return. Information about the mux state is also added for convenience. Additionally, this moves enums and defines which are a part of our overall pd_* API to the ec_commands.h file to ensure consumers have the same field values available for interpretation as the EC. BRANCH=None BUG=b:167700356 TEST=on waddledoo, plug in chargers and dongles and ensure outputs from "ectool typecstatus <port>" match "ectool usbpd <port>" and "ectool usbpdmuxinfo" Signed-off-by: Diana Z <dzigterman@chromium.org> Change-Id: Ic7afc0b282b88fdb34cb9a6feef22ad913bb4aae Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2432452 Reviewed-by: Abe Levkoy <alevkoy@chromium.org>
* TCPMv2: Add VBUS_REMOVED levelDiana Z2020-10-011-3/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | For boards which use Vbus ADCs, add a VBUS_REMOVED check level. The level for VBUS_PRESENT should be used in any locations looking for "Vbus is present" on transition, but in order to correctly detect disconnection with a load on Vbus, VBUS_REMOVED (vSinkDisconnect) is required. TODO statements have been added for places where work will be needed to support vSinkDisconnectPD in the future. For boards detecting Vbus through an external chip, the levels will likely be indistinguishable due to the chips setting a lower threshold for disconnect than for connection. Unit test code has also been added to encourage new Vbus levels to be added to the mock, and remind developers to update all locations using the vbus_level enum. BRANCH=None BUG=b:168831161 TEST=make -j buildall Signed-off-by: Diana Z <dzigterman@chromium.org> Change-Id: I04014ce54ec162dd9c62f545126d921c6d880741 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2436580 Reviewed-by: Denis Brockus <dbrockus@chromium.org>
* tcpmv2: disable receive of SOP' during VCONN swapKeith Short2020-09-021-0/+13
| | | | | | | | | | | | | | | | | | | 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>
* tcpmc2: fix TD.PD.LL3.E2 Retransmission testJett Rink2020-08-061-3/+0
| | | | | | | | | | | | | | | | | | | | | | | We are retrying in both the TCPC hardware (4 total) and in the Protocol layer (3 total) when we do not get a GoodCRC back from the port partner. We are only suppose to retry up to nRetryCount times which is 2. This means we should be sending 3 total replies. Also correct a misinterpretation of the spec around SOP' and SOP" retries. We were not retrying those packets, but we should be retry them as the SOP. The SOP' device will not retry, but we (as the SOP) should retry packet that we are sending to them. The TCPM is not fast enough to meet the timing for tRetry (195 usec), so we need to perform the retries in the TCPC hardware layer. BRANCH=none BUG=b:150617035 TEST=Verify passing compliance test with GRL-C2 on Trembyle Change-Id: I55c4ab2f5ce8f64acf21af943862d96d9088622d Signed-off-by: Jett Rink <jettrink@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2248960
* AOZ1380: initialize srcing/snking flags to reflect hardwareDenis Brockus2020-07-281-0/+22
| | | | | | | | | | | | | | | | | | | The AOZ1380 always started off with not sinking and not sourcing. In a batteryless or dead battery condition this is not true. So making sure we start with an accurate state. BUG=b:162016100 BRANCH=none TEST=trembyle cold boot with only AC power Signed-off-by: Denis Brockus <dbrockus@google.com> Change-Id: Ic542e52b3b8d715b7526e7e393ae4f4c40c721ac Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2321132 Tested-by: Denis Brockus <dbrockus@chromium.org> Reviewed-by: Edward Hill <ecgh@chromium.org> Commit-Queue: Denis Brockus <dbrockus@chromium.org> Auto-Submit: Denis Brockus <dbrockus@chromium.org>
* Revert "TCPMv2: make sure Vbus is not sourced in AttachWait.SRC"Denis Brockus2020-07-081-3/+0
| | | | | | | | | | | | | | | | | | | | | | | | Commit sha 57b95363c05bdab7b7e57d553a9514128393247d Reverting a CL that was a temporary fix while a real solution was found. This will now be implemented with the following CLs https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2282691 https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2282699 https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2283697 BUG=none BRANCH=none TEST=make buildall Signed-off-by: Denis Brockus <dbrockus@google.com> Change-Id: I76b92388f5ee5bae4bdb945a82f18eb3df3ab1fd Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2284728 Tested-by: Denis Brockus <dbrockus@chromium.org> Auto-Submit: Denis Brockus <dbrockus@chromium.org> Reviewed-by: Edward Hill <ecgh@chromium.org> Commit-Queue: Edward Hill <ecgh@chromium.org>
* TCPMv2: manual control to DBG_ACC in TCPCDenis Brockus2020-07-081-0/+8
| | | | | | | | | | | | | | | | | | | | With TCPCI being changed to allow TCPM to control the DBG_ACC enable instead of the TCPC, it is probably a good idea to actually toggle the bit for any TCPC that uses this signal for internal logic. BUG=b:160253746 BRANCH=none TEST=verify DBG and nonDBG attaches Signed-off-by: Denis Brockus <dbrockus@google.com> Change-Id: Ifb91afa0127689e0ca371e64495d80f30bf93c26 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2283697 Tested-by: Denis Brockus <dbrockus@chromium.org> Auto-Submit: Denis Brockus <dbrockus@chromium.org> Commit-Queue: Edward Hill <ecgh@chromium.org> Reviewed-by: Edward Hill <ecgh@chromium.org>
* usbc: only try to use ppc_set_frs_enable if it existsPeter Marheine2020-07-061-0/+2
| | | | | | | | | | | | | | | | The driver function to set FRS enable only exists if CONFIG_USB_PD_FRS_PPC is enabled, so we must also make its callers conditional in the same way. For consistency, also revise the TCPC FRS code paths to be conditional. BUG=b:146393213 BRANCH=None TEST=make buildall Signed-off-by: Peter Marheine <pmarheine@chromium.org> Change-Id: I3fb14c711dd2abdf6ef77d469b2103f37daac182 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2276125 Reviewed-by: Denis Brockus <dbrockus@chromium.org>
* TCPMv2: make sure Vbus is not sourced in AttachWait.SRCDenis Brockus2020-07-011-0/+3
| | | | | | | | | | | | | | | | | | | | | | | The TCPC on zork appears to enable Vbus sourcing some of the time when we come out of auto-toggle. It looks like about a 60ms delay before it is enabled. We then go to AttachWait.SRC and since the exit condition to get to Attached.SRC is a debounced/valid Attached.SRC CC and Safe0V, it has to be disabled manually in order to move to Attached.SRC BUG=b:160227699,b:160253746 BRANCH=none TEST=dut-control servo_v4_role:snk should attach Signed-off-by: Denis Brockus <dbrockus@google.com> Change-Id: I1dfc5d2536aaa4d7a5ffc7bbb52c647b15764196 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2276463 Tested-by: Denis Brockus <dbrockus@chromium.org> Reviewed-by: Diana Z <dzigterman@chromium.org> Reviewed-by: Keith Short <keithshort@chromium.org> Commit-Queue: Denis Brockus <dbrockus@chromium.org> Auto-Submit: Denis Brockus <dbrockus@chromium.org>
* tcpm: allow returning a status from set_frs_enablePeter Marheine2020-07-011-1/+3
| | | | | | | | | | | | | | | | | | | | | The old declaration with void is incompatible with the use of tcpci_tcpc_fast_role_swap_enable in the one driver that currently implements that function, causing build failure when CONFIG_USB_PC_FRS_TCPC is enabled and using the nct38xx TCPC driver. Because the underlying function may fail, walk up the stack and make all users capable of failure as well (however the top level user currently ignores the result). BUG=b:146393213 BRANCH=None TEST=make buildall Change-Id: Ib8cabf4a435731ed804a3cc4696dfea97eef3c98 Signed-off-by: Peter Marheine <pmarheine@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2276124 Commit-Queue: Denis Brockus <dbrockus@chromium.org> Reviewed-by: Denis Brockus <dbrockus@chromium.org>
* tcpm: Change the get_chip_info() to prevent race conditionsWai-Hong Tam2020-06-251-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The original get_chip_info() returns a point of point to the chip_info. This way helps to cache the chip_info to a static variable and the function just returns the pointer to the static variable. This static variable has a race condition on the PS8805 chip. The PS8805 chip returns a different PID when the firmware is corrupted, i.e. 0x8803 instead of 0x8805. The !live case fixes the PID, by modifying the static variable directly. When another task calls the same function for the live case, the static variable is modified and has a race condition. This change fixes the issue by changing the get_chip_info() parameter to a point of the chip_info. The caller has to allocate a buffer in the stack and pass the address to the function. For the !live case, the function copies the cache value from the static variable to the buffer. So the static variable doesn't have a race condition. BRANCH=None BUG=b:159588335 TEST=Used ectool to check the PD chip PID 0x8805 (was 0x8803). localhost ~ # ectool pdchipinfo 1 vendor_id: 0x1da0 product_id: 0x8805 device_id: 0x1 fw_version: 0x0 min_req_fw_version: 0x0 Change-Id: Ic24615af77ea58016d286480572d2a282c4fa09a Signed-off-by: Wai-Hong Tam <waihong@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2264477 Reviewed-by: Julius Werner <jwerner@chromium.org>
* tcpmv2: only enable AutoDischargeDisconnect when attachedDenis Brockus2020-06-241-20/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | Connecting a non-PD charger the DUT performs a TRY switch to become SRC. During this TRY path the AutoDischargeDisconnect had been enabled and the fact the non-PD charger will never allow Vbus to drop to Safe0V causes the fault. AutoDischargeDisconnect should only be enabled when there is a known stable attach and when this stops being the case the feature should return back to disabled. Verified on Trembyle NCT3807 platform BUG=b:158751942 BRANCH=none TEST=verify try does not fault on 5V charger Signed-off-by: Denis Brockus <dbrockus@google.com> Change-Id: I9ab507a1bbc5b84948620b6174f946f07befde90 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2250092 Tested-by: Denis Brockus <dbrockus@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org> Commit-Queue: Denis Brockus <dbrockus@chromium.org>
* tcpci: Add workaround for devices with broken vSafe0VKeith Short2020-06-131-0/+3
| | | | | | | | | | | | | | | | Add a flag to override checking the vSafe0V bit directly if this capability is not functional on a TCPC revision 2.0 device. BUG=b:158520242 BRANCH=none TEST=make buildall TEST=Volteer, confirm that SNK devices can be detected with TCPMv2 stack. Signed-off-by: Keith Short <keithshort@chromium.org> Change-Id: Ia6f3a28970f240fb022cbef9d286761266224f6f Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2244017 Reviewed-by: Denis Brockus <dbrockus@chromium.org>
* Extend the tcpci register dump.Andrew McRae2020-05-271-0/+35
| | | | | | | | | | | | | | | | | Extend the tcpci register dump command to allow chip specific register dumps to be displayed. BUG=b:157206143 TEST=Display ANX3447 registers on Puff. BRANCH=none Change-Id: Ib2bf1adcbe3bce75ff54c36c4306b17356eae96f Signed-off-by: Andrew McRae <amcrae@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2208344 Tested-by: Andrew McRae <amcrae@chromium.org> Auto-Submit: Andrew McRae <amcrae@chromium.org> Reviewed-by: Peter Marheine <pmarheine@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org> Commit-Queue: Andrew McRae <amcrae@chromium.org>
* tcpc: AutoDischarge can be enabled on any connection wakeDenis Brockus2020-05-191-3/+1
| | | | | | | | | | | | | | | | | | | I thought AutoDischarge could only be enabled when waking if DRP was enabled. This is not the case and I am removing the unnecessary portions of code dealing with this distinction. BUG=none BRANCH=none TEST=verify connections continue to work Signed-off-by: Denis Brockus <dbrockus@google.com> Change-Id: Iddea93a0749842f366b046594f9abb936b1ec523 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2202564 Tested-by: Denis Brockus <dbrockus@chromium.org> Reviewed-by: Edward Hill <ecgh@chromium.org> Commit-Queue: Denis Brockus <dbrockus@chromium.org> Auto-Submit: Denis Brockus <dbrockus@chromium.org>
* tcpc: change name of get_vbus_level to check_vbus_levelDenis Brockus2020-05-151-3/+11
| | | | | | | | | | | | | | | | | | | | this is to add near future functionality to allow not only the current PRESENT range check but to add Save0V range checking as well, for platforms that allow for this. This just lays the framework and is functionally equivalent. BUG=none BRANCH=none TEST=verify basic USB functionality Signed-off-by: Denis Brockus <dbrockus@google.com> Change-Id: I1eb3411bc3aa9b792c9b97799e1721e5cb229f64 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2199036 Tested-by: Denis Brockus <dbrockus@chromium.org> Reviewed-by: Diana Z <dzigterman@chromium.org> Commit-Queue: Denis Brockus <dbrockus@chromium.org> Auto-Submit: Denis Brockus <dbrockus@chromium.org>
* tcpmv2: get USB CCD working on servo_v4 with trembyleDenis Brockus2020-05-081-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | Change AutoDischargeDisconnects to handle Debug Accessory CCD devices. Repair Try.SRC on an initial SNK connection path. Repair power swap path. Auto Discharge was still in the wrong places and faults pointed that there was a problem but finding the correct location is not quite as simple. This at least is working better than before. BUG=b:154590730 BRANCH=none TEST=servo_v4 charge through TEST=servo_v4 connected to USB stick when SNK and SRC Signed-off-by: Denis Brockus <dbrockus@google.com> Change-Id: I9638b873a7243028a230d6d997c060d0bf2616e3 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2185871 Tested-by: Denis Brockus <dbrockus@chromium.org> Tested-by: Edward Hill <ecgh@chromium.org> Reviewed-by: Edward Hill <ecgh@chromium.org> Commit-Queue: Edward Hill <ecgh@chromium.org> Commit-Queue: Denis Brockus <dbrockus@chromium.org> Auto-Submit: Denis Brockus <dbrockus@chromium.org>
* TCPMv2: Store Tx type in PE stateAbe Levkoy2020-05-021-1/+2
| | | | | | | | | | | | | | | | | This will be used for VDM request state for discovery. Also change names of identity discovery timer and counter fields to comport with PD spec. This is substantially based on https://crrev.com/c/2148427. BUG=none TEST=make buildall BRANCH=none Change-Id: Iabda5c4cd169944a6c84bc72f551de7eb82ab424 Signed-off-by: Abe Levkoy <alevkoy@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2174463 Reviewed-by: Diana Z <dzigterman@chromium.org>
* nct38xx: handle TCPCI faultsDenis Brockus2020-04-161-0/+10
| | | | | | | | | | | | | | | | | | Add chip specific fault handling. This includes the all registers reset to default fault as well as the Vbus OVP fault. BUG=b:152841243 BRANCH=none TEST=switch normal to dev-mode with AC attached Signed-off-by: Denis Brockus <dbrockus@google.com> Change-Id: Id5233823d873833c21da885a5a13fffe794899f7 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2149385 Tested-by: Denis Brockus <dbrockus@chromium.org> Reviewed-by: Denis Brockus <dbrockus@chromium.org> Commit-Queue: Denis Brockus <dbrockus@chromium.org> Auto-Submit: Denis Brockus <dbrockus@chromium.org>
* tcpmv2: reduce zork specific auto discharge disconnect codeDenis Brockus2020-03-281-19/+0
| | | | | | | | | | | | | | | | | | | Removing the conditional code to find the specifics that broke waddledoo and then fix that. BUG=b:152616398 b:152444591 b:150110431 b:150913968 b:151152817 BRANCH=none TEST=verify trembyle and waddledoo Signed-off-by: Denis Brockus <dbrockus@google.com> Change-Id: Ieb88540b2298c3b999ab27ea78285f7f1c34bff6 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2121633 Reviewed-by: Denis Brockus <dbrockus@chromium.org> Reviewed-by: Diana Z <dzigterman@chromium.org> Commit-Queue: Denis Brockus <dbrockus@chromium.org> Commit-Queue: Diana Z <dzigterman@chromium.org> Tested-by: Denis Brockus <dbrockus@chromium.org> Auto-Submit: Denis Brockus <dbrockus@chromium.org>