summaryrefslogtreecommitdiff
Commit message (Collapse)AuthorAgeFilesLines
* servo_v4: add "cc dtsoff" and "cc dtson" commandsfirmware-servo-12768.B-masterMatthew Blecker2022-09-121-1/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | BRANCH=none BUG=none TEST=Built servo_v4 firmware with this change cherry-picked onto d771c18ba9989eed5eca134d27e1973a63bded74 from cros/firmware-servo-12768.B-master branch (current top-of-branch) and flashed it to a Servo v4 with Type-C CCD DUT cable. Repeated the following steps with and without a DUT charge plugged into Servo v4: 1) Power on the Servo v4 while connected to a known-good CCD capable DUT. Verify presence of CR50 CCD USB device on servo host machine. 2) Run "cc" to log its output. 3) Run "cc dtsoff" and compare the output. Only change is "dts mode: on" changing to "dts mode: off" . Verify absence of CR50 CCD USB device on servo host machine. 4) Run "cc dtson" and compare the output. Only change is going back to "dts mode: on" . Verify presence of CR50 CCD USB device on servo host machine. Change-Id: I780073165609f2278d3323f42ff8cf6a1ea71999 Signed-off-by: Matthew Blecker <matthewb@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3888998 Reviewed-by: Brian Nemec <bnemec@google.com> Reviewed-by: Wai-Hong Tam <waihong@google.com> (cherry picked from commit 1e1cc37b4078e241f9b97fd50b5ebbcd3079ab33) Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3888999
* c2d2: increase the usart1_to_usb sizeMary Ruthven2022-08-031-1/+1
| | | | | | | | | | | | | | | | Set the usart1_to_usb size to 1024 to match the other consoles. BUG=b:240718978 BRANCH=servo TEST=none Change-Id: I0b57677365eca98684a883482562d5e9ad2f2ced Signed-off-by: Mary Ruthven <mruthven@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3805279 Commit-Queue: Ziting Shen <zitingshen@google.com> Reviewed-by: Ziting Shen <zitingshen@google.com> (cherry picked from commit e55cc58e28694bb4c01189466355b79c0744e434) Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3807128
* servo_micro: increase the usart4_to_usb buf sizeMary Ruthven2022-08-031-1/+1
| | | | | | | | | | | | | | | | | | | | | | | The Cr50 console drops a lot of characters on servo micro. Increase the uart4 buf size to match the EC and AP uart sizes. BUG=b:240718978 BRANCH=servo release branch TEST=basic check run `ccd` a bunch of times. Make sure characters aren't dropped. # full test add chargen to cr50 run firmware_Cr50CCDUartStress through servo micro cr50 console. Change-Id: I0c857310f88886dcffa29712c512c37dbe557f13 Signed-off-by: Mary Ruthven <mruthven@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3790822 Reviewed-by: Ziting Shen <zitingshen@google.com> Reviewed-by: Brian Nemec <bnemec@google.com> (cherry picked from commit 712d9ae17713f7b0cb267ce36d83b91b51e9c7f5) Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3807127 Commit-Queue: Ziting Shen <zitingshen@google.com>
* Clear OWNERS for factory/firmware branchBrian Norris2021-09-109-32/+0
| | | | | | | | | | | | BUG=none TEST=none Change-Id: I0f03f432ada1064ffba9595be78ca7ab4d25ecd1 Signed-off-by: Brian Norris <briannorris@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3155243 Reviewed-by: Jack Rosenthal <jrosenth@chromium.org> Owners-Override: Jora Jacobi <jora@google.com> Tested-by: Jack Rosenthal <jrosenth@chromium.org>
* i2c_master: Check if get_i2c_port returns NULLLukasz Hajec2021-08-261-0/+3
| | | | | | | | | | | | | | | | | | | | This patch fixes an issue, when nonexistent port number parameter is passed to i2cxfer and causes panic due to using null pointer. Add check if get_i2c_port returns NULL and return EC_ERROR_INVAL. BUG=b:186873536 BRANCH=none TEST=Run i2cxfer command with different parameters on servo_v4, nocturne and grunt - do not observe panic. Signed-off-by: Lukasz Hajec <lha@semihalf.com> Change-Id: I8bd90d898e1097b59ca6c9a1eff850bc2dc808e4 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3074620 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-by: Ruben Rodriguez Buchillon <coconutruben@chromium.org> (cherry picked from commit faa5ff511aa464f5fee621eef7b8bf4cdeb26ad5) Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3113967 Commit-Queue: Daisuke Nojiri <dnojiri@chromium.org>
* servo_v4p1: Enable 5A and 20V chargingBrian J. Nemec2021-08-241-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Enables 5A and 20V charging on all Servo_v4p1's. There is a small population of servo_v4p1 devices with 3A cables but these represent about 100 total units between the early builds. The setting was not set as a board id configuration as stress tests show this process will still be safe and the Servo_v4p1's that are current limited are easy to keep within the 3A current limits. The 5A cables are visually distinctive and most chargers and DUTs are limited to 3A. BUG=b:176110980 BRANCH=servo TEST=Validated the Servo_v4p1 can deliver power at 4.5A and 20V using a 90W charger and a resistive load. Verified current using meters and verified Servo_v4p1 does not heat excessively significantly after over 2 hours at the cable or PCB. TEST=Repeated the same test on older Servo_v4p1 devices with the smaller shunt resistors and 3A compliant cable and verified components remain at reasonable temperatures. Signed-off-by: Brian Nemec <bnemec@chromium.org> Change-Id: If9e67081fe4441ca0fe1039c3189e0673eb8f13a Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2714031 Reviewed-by: Jan DÄ…broÅ› <jsd@semihalf.com> Reviewed-by: Matthew Blecker <matthewb@chromium.org> Reviewed-by: Vincent Palatin <vpalatin@chromium.org> (cherry picked from commit 118fa0ff5a6361066b213522798697ab399c1e84) Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3078770 Reviewed-by: Ruben Rodriguez Buchillon <coconutruben@chromium.org> Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
* ec: Filter non-FIXED PDOs in servo_v4{p1}Jeremy Bettis2021-05-1910-4/+84
| | | | | | | | | | | | | | | | | | | | | | | | Add a new config CONFIG_USB_PD_ONLY_FIXED_PDOS. If that config is enabled, ignore non-FIXED PDOs in both the console command `ada_srccaps` and also when selecting the preferred PDO for a voltage. Enable CONFIG_USB_PD_ONLY_FIXED_PDOS for servo_v4 and servo_v4p1, since they don't expose non-fixed PDO in their srccaps. Without this change, there is a risk that the "best" PDO for a given voltage will be non-FIXED and then that voltage just won't be supported at all. BRANCH=servo BUG=b:178484932 TEST=added Signed-off-by: Jeremy Bettis <jbettis@google.com> Change-Id: Ica3c521abe58a79b3c1f8e932814fed99e31ff50 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2827326 Tested-by: Jeremy Bettis <jbettis@chromium.org> Auto-Submit: Jeremy Bettis <jbettis@chromium.org> Reviewed-by: Brian Nemec <bnemec@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org> Commit-Queue: Jeremy Bettis <jbettis@chromium.org>
* ec: Parse battery and augmented PDOs correctly.Jeremy Bettis2021-05-053-18/+155
| | | | | | | | | | | | | | | | Fixes pd_extract_pdo_power() to output the correct voltage and current for non-fixed PDOs. Add unit test. BRANCH=servo BUG=b:178484932 TEST=added Signed-off-by: Jeremy Bettis <jbettis@google.com> Change-Id: I791de41f00d75306a377e1ab9fb54409d5f537e7 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2827325 Commit-Queue: Jeremy Bettis <jbettis@chromium.org> Tested-by: Jeremy Bettis <jbettis@chromium.org> Reviewed-by: Brian Nemec <bnemec@chromium.org>
* Servo_v4/v4p1: Only read CC if a pull is appliedEric Herrmann2021-05-052-4/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | CC readings aren't valid if we aren't applying a pull to CC. This causes some issues on platforms which use voltage clamp Rd implementations. There is currently the intention to fake CC readings if we aren't applying a pull, but it uses the CC_DETACH flag which doesn't directly mirror the CC status, and we could be applying no CC pull even if CC_DETACH isn't set. Check more directly if we're applying CC pulls when getting the CC status. BUG=b:182173370 TEST=firmware_PDTrySrc on Voxel with servoV4 TEST=check that fakedisconnect as src and snk works on servoV4p1 BRANCH=None Signed-off-by: Eric Herrmann <eherrmann@chromium.org> Change-Id: Ie67c5c7a05add81aca1336caa7951d31f88c35fc Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2745222 Reviewed-by: Nathan Kolluru <nkolluru@google.com> Reviewed-by: Wai-Hong Tam <waihong@google.com> (cherry picked from commit 304ac382935378e95ba1f37b98230d8219b18ac0) Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2873629 Commit-Queue: Zhuohao Lee <zhuohao@chromium.org> Tested-by: Zhuohao Lee <zhuohao@chromium.org>
* extra/util: replace deprecated sys_siglist with strsignalAdrian Ratiu2021-05-043-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | Starting with Glibc 2.32: * The deprecated arrays sys_siglist, _sys_siglist, and sys_sigabbrev are no longer available to newly linked binaries, and their declarations have been removed from <string.h>. They are exported solely as compatibility symbols to support old binaries. All programs should use strsignal instead. https://sourceware.org/pipermail/libc-announce/2020/000029.html BUG=chromium:1171287 BRANCH=none TEST=Local builds on x86_64 / eve and arm / kevin. Sent SIGINT to iteflash and verified output. Signed-off-by: Jeremy Bettis <jbettis@google.com> Change-Id: Ia977cfe24e4ce4e78c3b82a2f98613be1f2f6ca3 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2857787 Tested-by: Jeremy Bettis <jbettis@chromium.org> Auto-Submit: Jeremy Bettis <jbettis@chromium.org> Commit-Queue: Jett Rink <jettrink@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org>
* servo: Remove define PROTOBUF_MIN_PROTOC_VERSIONJeremy Bettis2021-04-291-1/+0
| | | | | | | | | | | | | | | Something changed in the chroot, and this is causing problems now. BRANCH=servo BUG=b:178484932 TEST=make -j buildall runhosttests Signed-off-by: Jeremy Bettis <jbettis@google.com> Change-Id: Ie00e5120bc8dbe411b447a0b68d76a8f7151f815 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2827327 Tested-by: Jeremy Bettis <jbettis@chromium.org> Commit-Queue: Jeremy Bettis <jbettis@chromium.org> Reviewed-by: Brian Nemec <bnemec@chromium.org>
* TCPMv2: Report source capabilities in TYPEC_STATUSDiana Z2021-04-282-11/+79
| | | | | | | | | | | | | | | | | Report the source capabilities for a port to the TYPEC_STATUS host command, and add decoding for the interesting fields here to ectool. BRANCH=servo BUG=b:167700356 TEST=on waddledoo, confirm source capability decoding from ectool matches that from TotalPhase for servo_v4 and a charger Signed-off-by: Jeremy Bettis <jbettis@google.com> Change-Id: I61f03d4646d31379d5d2b834a3ec5b1eac9042c2 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2827324 Tested-by: Jeremy Bettis <jbettis@chromium.org> Reviewed-by: Brian Nemec <bnemec@chromium.org> Commit-Queue: Jeremy Bettis <jbettis@chromium.org>
* usb_common: support parse Augmented PDOEric Yilun Lin2021-04-156-28/+41
| | | | | | | | | | | | | | | | | | | | Change the function signature to void pd_extract_pdo_power(uint32_t pdo, uint32_t *ma, uint32_t *max_mv, uint32_t *min_mv); Replace the original caller with an extra unused parameter, no functional changes. BUG=none TEST=`pd 0 srccaps` prints the correct PDO info BRANCH=servo Signed-off-by: Jeremy Bettis <jbettis@google.com> Change-Id: I0ea9c3a00ffbb465aaea34f77101ab27188ca34e Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2827323 Reviewed-by: Brian Nemec <bnemec@chromium.org> Tested-by: Jeremy Bettis <jbettis@chromium.org> Commit-Queue: Jeremy Bettis <jbettis@chromium.org>
* Fix use of int const in size of array.Luis Lozano2021-04-151-1/+1
| | | | | | | | | | | | | | | | Compiler complains about this use of a GNU extension now. Replace by a #define. BUG=chromium:1151317 BRANCH=servo TEST=to be done Signed-off-by: Jeremy Bettis <jbettis@google.com> Change-Id: If11fe0dcbc14f91564a6b3f09a6b0e109b7843fd Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2827322 Reviewed-by: Luis Lozano <llozano@chromium.org> Commit-Queue: Jeremy Bettis <jbettis@chromium.org> Tested-by: Jeremy Bettis <jbettis@chromium.org>
* ectool_keyscan: add missing null terminator to kbd_plain_xlateFabio Baltieri2021-04-151-1/+1
| | | | | | | | | | | | | | | | | | | | | strchr relies on the source string to be null terminated. This fixes a compiler warning when building outside of the chroot: util/ectool_keyscan.c: In function ‘cmd_keyscan’: util/ectool_keyscan.c:208:9: error: ‘strchr’ argument missing terminating nul [-Werror=stringop-overflow=] 208 | pos = strchr(kbd_plain_xlate, key); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~ BUG=none TEST=build only, warning is gone BRANCH=servo Signed-off-by: Jeremy Bettis <jbettis@google.com> Change-Id: I068779820876167a31076c69dfedb24f0f5e7ed6 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2827321 Reviewed-by: Brian Nemec <bnemec@chromium.org> Commit-Queue: Jeremy Bettis <jbettis@chromium.org> Tested-by: Jeremy Bettis <jbettis@chromium.org>
* servo_v4,servo_v4p1: filter Augmented PDO for pass-throughEric Yilun Lin2021-03-112-0/+9
| | | | | | | | | | | | This is currently unsupported since servo-v4 uses PD2.0 (TCPMv1) stack. BUG=b:182219864 TEST=Ensure APDOs don't show in ada_srccaps cmd BRANCH=servo Change-Id: I4d10ac6a44d649281c5ae2fff665cc1fd0c590c9 Signed-off-by: Eric Yilun Lin <yllin@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2751303
* EC: After SRC_HARD_RESET_RECOVER set CHECK_XX_ROLEJeremy Bettis2021-03-011-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | Just before moving from state PD_STATE_SRC_DISCONNECTED_DEBOUNCE to PD_STATE_SRC_STARTUP we set the PD_FLAGS_CHECK_PR_ROLE and PD_FLAGS_CHECK_DR_ROLE. However when we move from PD_STATE_SRC_HARD_RESET_RECOVER to PD_STATE_SRC_STARTUP we do not set those flags. This cl corrects that and sets the flags in both cases. This will allow the servo to get back into the correct dr_role after a hard reset. BUG=b:179532434, b:178417455, b:180051107 TEST=Flashed servo, cc srcdts, pd 1 hard BRANCH=None Signed-off-by: Jeremy Bettis <jbettis@google.com> Change-Id: I42d5807ab87d3bc001f80ca709a2e72d9e89fe63 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2716862 Tested-by: Jeremy Bettis <jbettis@chromium.org> Reviewed-by: Wai-Hong Tam <waihong@google.com> Reviewed-by: Diana Z <dzigterman@chromium.org> Commit-Queue: Jeremy Bettis <jbettis@chromium.org> (cherry picked from commit 7ac66e54e8e73018189b0b3dc4e1bae9bfa5bec3) Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2718984 Auto-Submit: Jeremy Bettis <jbettis@chromium.org> Commit-Queue: Brian Nemec <bnemec@chromium.org> Reviewed-by: Brian Nemec <bnemec@chromium.org>
* servo_v4/usb_pd_policy: Disable VBUS instead of power supply resetPatryk Duda2020-12-031-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When running 'fakedisconnect' command on ServoV4, CC_DETACH bit is going to be set. Detach is done by calling pd_power_supply_reset() which disables VBUS (set DUT_CHG_EN to 0) and requests 5 volts from charger. Next step is disable PD communication by calling pd_comm_enable() and set RP to RP_RESERVED value (pd_set_rp_rd() function). Setting RP to RP_RESERVED (just disconnect all resistors on CC1 and CC2) actually is a trick to make PD_C1 task think that DUT is disconnected. TCPM stack checks voltage on CC lines and when voltage on active CC line indicates that we are open it changes state to SRC_DISCONNECTED. Changing state to SRC_DISCONNECTED triggers pd_power_supply_reset() which was already run in do_cc() function as a result of 'fakedisconnect' command. Calling this once again causes weird behaviour - communication issues and finally Hard Reset, eg: > fakedisconnect 100 1000 Fake disconnect for 1000 ms starting in 100 ms. C0 Req [1] 5000mV 3000mA [210.470350 CL: p0 s0 i500 v15000] [210.472703 PD TMOUT RX 1/1] RXERR1 Preamble C1 srcCAP>-1 C1 srcCAP>-1 C1 st14 SRC_DISCONNECTED [210.473835 PD TMOUT RX 467/1] RXERR0 Preamble C0 REQ>1 C0 st6 SNK_REQUESTED C0 st34 HARD_RESET_SEND C0 st35 HARD_RESET_EXECUTE C0 HARD RST TX Hard Reset in PD_C0 task can cause additional delay when C1 gets connected and DUT requests higher voltage. As a result DUT sends Hard Reset due to timeout. Hard Reset on port 1 causes PDTrySrc to fail because of timeout waiting for 'fakedisconnect' command. This was fixed by removing one voltage change request. In other words in do_cc() function we are not calling pd_power_supply_reset(), but disabling VBUS only. Eventually pd_power_supply_reset() will be called during transition to SRC_DISCONNECT state. BUG=b:162254118 BRANCH=none TEST=Run FAFT_PD test suite. All tests should pass except PDVbusRequest (depends on charger connected to ServoV4). TEST=Call 'fakedisconnect' command on ServoV4 console and check if there is no Hard Reset on port 0. Signed-off-by: Patryk Duda <pdk@semihalf.com> Change-Id: I657dd1ce2dc3a2f4914e975387eeebb037e1ada5 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2569652 Reviewed-by: Jett Rink <jettrink@chromium.org> Reviewed-by: Diana Z <dzigterman@chromium.org> (cherry picked from commit f10da1149896c54bd95163d654e5f2bc4f3bd1f4) Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2566823 Reviewed-by: Dossym Nurmukhanov <dossym@chromium.org> Commit-Queue: Dossym Nurmukhanov <dossym@chromium.org>
* servo_v4/usb_pd_policy: Reject SNK->SRC power swap if CC_ALLOW_SRC not setPatryk Duda2020-12-011-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When ServoV4 acts as sink ('cc snk' issued), and we issue 'cc pdsnk' there are following state transitions (starting from C1 SNK_READY): C1 st8 SNK_READY <--- From this point DUT acts as source DUT's PE is in PE_SRC_Ready state C1 RECV 196f/1 [0]ff008001 C1 RECV 0b67/0 <--- DUT asks for source capabilities C1 srcCAP>1 <--- ServoV4 sends its capabilities C1 RECV 0d6a/0 <--- DUT requests power swap C1 CTRL[3]>1 <--- ServoV4 accepts C1 st10 SNK_SWAP_SNK_DISABLE C1 st11 SNK_SWAP_SRC_DISABLE C1 RECV 0e66/0 <--- DUT sends PS_RDY to inform that it disabled power C1 st12 SNK_SWAP_STANDBY <--- ServoV4 enables power supply and waits PD_POWER_SUPPLY_TURN_ON_DELAY to ensure that it is turned on, before switching to SNK_SWAP_COMPLETE C1 st13 SNK_SWAP_COMPLETE <--- Power swap completed successfully C1 CTRL[6]>1 <--- ServoV4 sends PS_RDY to inform that power was enabled. C1 st18 SRC_DISCOVERY C1 srcCAP>1 <--- ServoV4 sends its capabilities C1 st19 SRC_NEGOCIATE C1 RECV 1062/1 [0]4304b12c Requested 15000 mV 3000 mA (for 3000/3000 mA) C1 CTRL[3]>1 <--- ServoV4 accepts C1 st20 SRC_ACCEPTED C1 st21 SRC_POWERED <--- Switching to requested voltage. This calls pd_transition_voltage() from servo_v4/usb_pd_policy which requests charger to change its voltage. [570.815776 Waiting for CHG port transition] <--- Here we are changing active task to PD_C0. This task changes dual role for C1 (DUT port), because CC_ALLOW_SRC is not set. Appropriate event is set too C0 Req [4] 15000mV 3000mA C0 REQ>1 C0 st6 SNK_REQUESTED [570.822679 CL: p0 s0 i500 v5000] C0 RECV 0763/0 C0 st7 SNK_TRANSITION C0 RECV 0966/0 C0 st8 SNK_READY <--- Charger voltage changed successfully [570.991969 CL: p0 s0 i3000 v15000] <--- Context switch to PD_C1 task [571.001981 CHG transitioned] <--- Check event and call update_dual_role_config() which changes state to SNK_DISCONNECTED C1 st2 SNK_DISCONNECTED Port 1 switches to SNK_DISCONNECTED state because PD_C0 task calls pd_send_request_msg() (reaction for voltage change request), which limits maximum current by calling charge_manager_force_ceil(). Charge manager calls board_set_charge_limit() to limit current, which calls update_ports() which calls board_manage_dut_port() unconditionally. This function checks if charge through is allowed. It turns out that it is not allowed, because CC_ALLOW_SRC bit is not set in cc_config (see is_charge_through_allowed()), then board_manage_dut_port() changes dual role of port 1 to force sink. Fix for this issue is simple. Function is_charge_through_allowed() actually tells us that we are not able to source power when 'cc snk' or 'cc pdsnk' was issued. So fix is just to reject power swap when our power role is sink, and CC_ALLOW_SRC is not set. BUG=b:162254118 BRANCH=none TEST=Issue 'cc snk' from ServoV4 console and wait until state gets stable. Issue 'cc pdsnk' from ServoV4 console and check if port 1 reaches SNK_READY state. Signed-off-by: Patryk Duda <pdk@semihalf.com> Change-Id: Idf89c0f79a60275345d23aca4705811b1acba98a Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2563682 Reviewed-by: Jett Rink <jettrink@chromium.org> Reviewed-by: Sam Hurst <shurst@google.com> Reviewed-by: Diana Z <dzigterman@chromium.org> (cherry picked from commit a2390f3c505a4684535c08da27736099a63850fe) Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2566813 Commit-Queue: Jett Rink <jettrink@chromium.org>
* TCPMv1: Do not update dual role config during power swapPatryk Duda2020-12-011-14/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When ServoV4 acts as sink ('cc snk' issued), and we issue 'cc pdsnk' there are following state transitions: > cc pdsnk C1 st2 SNK_DISCONNECTED C1 st3 SNK_DISCONNECTED_DEBOUNCE C1 st5 SNK_DISCOVERY C1 RECV 1361/1 [0]2601912c C1 Req [1] 5000mV 3000mA C1 REQ>1 C1 st6 SNK_REQUESTED C1 RECV 0563/0 C1 st7 SNK_TRANSITION C1 RECV 0766/0 C1 st8 SNK_READY <--- From this point DUT acts as source DUT's PE is in PE_SRC_Ready state C1 RECV 196f/1 [0]ff008001 C1 RECV 0b67/0 <--- DUT asks for source capabilities C1 srcCAP>1 <--- ServoV4 sends its capabilities C1 RECV 0d6a/0 <--- DUT requests power swap C1 CTRL[3]>1 <--- ServoV4 accepts C1 st10 SNK_SWAP_SNK_DISABLE C1 st11 SNK_SWAP_SRC_DISABLE C1 RECV 0e66/0 <--- DUT sends PS_RDY to inform that it disabled power C1 st12 SNK_SWAP_STANDBY <--- ServoV4 enables power supply and waits PD_POWER_SUPPLY_TURN_ON_DELAY to ensure that it is turned on, before switching to SNK_SWAP_COMPLETE C1 st14 SRC_DISCONNECTED <--- This is not expected state, DUT is still waiting for PS_RDY from ServoV4 C1 st15 SRC_DISCONNECTED_DEBOUNCE C1 st17 SRC_STARTUP C1 st18 SRC_DISCOVERY C1 srcCAP>1 <--- ServoV4 tries to negotiate, but DUT is still waiting for PS_RDY C1 st19 SRC_NEGOCIATE C1 st34 HARD_RESET_SEND <--- Negotiation timeout C1 st35 HARD_RESET_EXECUTE DUT requests power swap which is interrupted by wrong state transition. SNK_SWAP_STANDBY state should be switched to SNK_SWAP_COMPLETE, but instead of it switched to SRC_DISCONNECTED, this is caused by changing DRP state to force source in pd_set_power_supply_ready() called in SNK_SWAP_STANDBY state. Changing DRP state also sets PD_EVENT_UPDATE_DUAL_ROLE, which causes state transition (performed in pd_update_dual_role_config() function), because power role is still PD_ROLE_SINK, but DRP is now force source. This was fixed by adding requirement that we should not perform power swap, because we are going to change our power role in SNK_SWAP_COMPLETE actually. BUG=none BRANCH=none TEST=Issue 'cc snk' on ServoV4 console, wait until it reaches stable state. Issue 'cc pdsnk' and check if SNK_SWAP_COMPLETE state comes after SNK_SWAP_STANDBY Signed-off-by: Patryk Duda <pdk@semihalf.com> Change-Id: I0ffd6ef79d59ca7fcb0dd1357dd491fe852b7461 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2563681 Reviewed-by: Jett Rink <jettrink@chromium.org> Reviewed-by: Diana Z <dzigterman@chromium.org> (cherry picked from commit 8150f11ccf19e77b0e17f11dcee8811a924fcce1) Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2566812 Commit-Queue: Jett Rink <jettrink@chromium.org>
* servo_v4,servo_v4p1: control acceptance of power and data swapEric Yilun Lin2020-10-142-6/+56
| | | | | | | | | | | | | | | | enable this command for more FAFT test coverage BUG=b:139065787 TEST=on servo_v4, test that usbc_action prswap|drswap works as expected BRANCH=servo Change-Id: I1b88d5c0ed00997e78d129633faf435e3cee61ac Signed-off-by: Eric Yilun Lin <yllin@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2467599 Reviewed-by: Wai-Hong Tam <waihong@google.com> (cherry picked from commit 11053f40043229b98ab7cb6be0325ab483a5d9e5) Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2470223
* Revert "ServoV4/V4p1: Change CCD detection flow"Brian Nemec2020-10-063-52/+52
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This reverts commit 7bd7acb85ff66f57b47bd294bf53acab3fa30815. Reason for revert: b:167734179 CCD detection is failing on many devices. Tests on reverted devices show this is primary cause. Original change's description: > ServoV4/V4p1: Change CCD detection flow > > Currently, servoV4 and servoV4p1 don't apply terminations to SBU when > searching for a DUT. This means SBU can float which can break the SBU > voltage detection. Technically, the DUT should only need to pull up D+ > and can float D- since it is a FS USB2 device when in CCD mode. > > Change the detection to connect SBU to the USB2 hub on servoV4/4p1. The > USB2 hub will apply 15k pulldowns to the USB lines, which will pull SBU > down and fix detection in the case where the DUT floats SBU. > > BUG=b:161762948, b:150886157, b:151487379 > TEST=make BOARD=servo_v4; make BOARD=servo_v4p1 > TEST=check that CCD works on DUT without pulldown resistors on SBU > BRANCH=none > > Change-Id: I9b6f620617fb0e270e35804704111afd3c606a3b > Signed-off-by: Eric Herrmann <eherrmann@chromium.org> > Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2352439 > Reviewed-by: Wai-Hong Tam <waihong@google.com> > (cherry picked from commit 1a09ade7b846cc048fb2f177adcacd5f836b8887) > Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2389080 > Reviewed-by: Brian Nemec <bnemec@chromium.org> > Commit-Queue: Brian Nemec <bnemec@chromium.org> > Tested-by: Brian Nemec <bnemec@chromium.org> BUG=b:167734179, b:168546666, b:168548776 TEST=Measured SBU voltages with the prior CL included, observed low voltages and no-voltage on some platforms including variations of dedede under the flipped orientation. TEST=Reverted the CL and CCD detection worked reliably, devices with CCD not driving SBU rails started working, and labstation release was more reliable on prior versions. Change-Id: Ibf120ad18f25daaaa584b20dc49c12c453049979 Signed-off-by: Brian Nemec <bnemec@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2429495
* ServoV4/V4p1: Change CCD detection flowEric Herrmann2020-09-033-52/+52
| | | | | | | | | | | | | | | | | | | | | | | | | | Currently, servoV4 and servoV4p1 don't apply terminations to SBU when searching for a DUT. This means SBU can float which can break the SBU voltage detection. Technically, the DUT should only need to pull up D+ and can float D- since it is a FS USB2 device when in CCD mode. Change the detection to connect SBU to the USB2 hub on servoV4/4p1. The USB2 hub will apply 15k pulldowns to the USB lines, which will pull SBU down and fix detection in the case where the DUT floats SBU. BUG=b:161762948, b:150886157, b:151487379 TEST=make BOARD=servo_v4; make BOARD=servo_v4p1 TEST=check that CCD works on DUT without pulldown resistors on SBU BRANCH=none Change-Id: I9b6f620617fb0e270e35804704111afd3c606a3b Signed-off-by: Eric Herrmann <eherrmann@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2352439 Reviewed-by: Wai-Hong Tam <waihong@google.com> (cherry picked from commit 1a09ade7b846cc048fb2f177adcacd5f836b8887) Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2389080 Reviewed-by: Brian Nemec <bnemec@chromium.org> Commit-Queue: Brian Nemec <bnemec@chromium.org> Tested-by: Brian Nemec <bnemec@chromium.org>
* servo_v4: optimize USB PD TX switchingVincent Palatin2020-08-192-110/+88
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Optimize the duration when switching the USB PD path to TX, in order to meet the PD spec tStartDive timing between when we start driving the line and the start of the preamble waveform. Try to decrease the number of operations on the GPIO registers which might be clocked slowly in order to achieve this, this includes abandoning the high level GPIO functions and writing directly the useful GPIO registers and knowing in advance between which modes we are switching. A few constant values in the GPIO registers for the TX path are now written in the pd_tx_init function. The current version uses the regular GPIO functions *but* it will glitch these GPIOs, we might want to switch to a lower level implementation and avoid the glitch. Signed-off-by: Vincent Palatin <vpalatin@chromium.org> BUG=b:155202697 BRANCH=none TEST=make BOARD=servo_v4p1 TEST=probe TX_DATA on the scope and measure the duration before the preamble Change-Id: I84c8321ed9be045087e228a74f6e0ddb3f677d76 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2346804 Reviewed-by: Nitin Kolluru <nkolluru@google.com> Reviewed-by: Wai-Hong Tam <waihong@google.com> Tested-by: Nitin Kolluru <nkolluru@google.com> (cherry picked from commit ca827c348942c8bb9a4f71dbf4e593d6d46510dc) Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2363290 Reviewed-by: Vincent Palatin <vpalatin@chromium.org> Reviewed-by: Brian Nemec <bnemec@chromium.org> Tested-by: Brian Nemec <bnemec@chromium.org> Auto-Submit: Brian Nemec <bnemec@chromium.org> Commit-Queue: Brian Nemec <bnemec@chromium.org>
* servo: Increased stack sizes for servo_v4p1Brian J. Nemec2020-08-121-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | Increased the stack sizes in servo_V4p1's power delivery tasks. The report from stack analysis: make BOARD=servo_v4p1 SECTION=RO analyzestack | grep Max Task: HOOKS, Max size: 336 (112 + 224), Allocated size: 768 Task: CONSOLE, Max size: 512 (288 + 224), Allocated size: 768 Task: PD_C0, Max size: 976 (752 + 224), Allocated size: 1056 Task: PD_C1, Max size: 976 (752 + 224), Allocated size: 1056 Task: PD_C2, Max size: 696 (472 + 224), Allocated size: 768 BUG=b:163546782 BRANCH=servo TEST=make -j BOARD=servo_v4p1 TESt=make BOARD=servo_v4p1 SECTION=RO analyzestack Signed-off-by: Brian Nemec <bnemec@chromium.org> Change-Id: Iccf7ebdf2a19afce9c02c43df6f72940c950d35e Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2350300 Reviewed-by: Sam Hurst <shurst@google.com> (cherry picked from commit dbcab40b7b8696d56b4708f37f84883ae3e0c8bf) Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2351361
* servo_v4p1: Add support for alternate charger portSam Hurst2020-07-317-3/+955
| | | | | | | | | | | | | | | | A TypeC charger can be attached to the alternate charger port to supply up to 15W to the servoV4.1. BRANCH=none BUG=b:146793000 TEST=make -j buildall Signed-off-by: Sam Hurst <shurst@google.com> Change-Id: Ia88c783d23d09bfc12b34d416af98445db2d75c2 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2270696 Reviewed-by: Brian Nemec <bnemec@chromium.org> (cherry picked from commit 31146a9a0acdf42ef5148a473242f77886fcbd2e) Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2332250
* servo_v4p1: Add BC1.2 functionalitySam Hurst2020-07-314-0/+96
| | | | | | | | | | | | | | | This functionality is available in both RO and RW. BRANCH=none BUG=b:146793000 TEST=make -j buildall Signed-off-by: Sam Hurst <shurst@google.com> Change-Id: Ia442010e7721553a7e155442e32f24ffbf5c4d70 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2216405 Reviewed-by: Brian Nemec <bnemec@chromium.org> (cherry picked from commit 484f7178604701655ef1a144aaa7465016ad4fc1) Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2332249
* servo_v4p1: Handle ioexpanders irq in a deferred function callSam Hurst2020-07-313-30/+49
| | | | | | | | | | | | | | | | | Performing i2c transfers from interrupt context seems to reset the device. Handling the interrupt in a deferred function gets around the problem. BRANCH=none BUG=b:146793000 TEST=make -j buildall Signed-off-by: Sam Hurst <shurst@google.com> Change-Id: I7d4609670f5d9826de12f87f5543f231de875df5 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2270695 Reviewed-by: Wai-Hong Tam <waihong@google.com> (cherry picked from commit b93f139e47f8ced7ebe2414737296f9a6ba49cbc) Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2332248
* servo_v4p1: Add DP functionalitySam Hurst2020-07-313-60/+289
| | | | | | | | | | | | | | Add DP functionality BRANCH=none BUG=b:146793000 TEST=make -j buildall Signed-off-by: Sam Hurst <shurst@google.com> Change-Id: I041628a2fe01123e168e78f01a5fba9b72e80dca Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2238676 (cherry picked from commit 3e083f33a6739b00ea69ba1387dedfc4af8821a6) Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2332247
* servo_v4p1: Add TUSB1064 functionalitySam Hurst2020-07-314-0/+96
| | | | | | | | | | | | | | | This functionality is available in both RO and RW. BRANCH=none BUG=b:146793000 TEST=make -j buildall Signed-off-by: Sam Hurst <shurst@google.com> Change-Id: I2161e5326a1869e092d0c6dd15ad45523f13ca05 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2298268 Reviewed-by: Wai-Hong Tam <waihong@google.com> (cherry picked from commit c556adf8d3689299d4da24bdfa36d09e23f73843) Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2332246
* servo_v4p1: Add USB PD functionalitySam Hurst2020-07-316-3/+1667
| | | | | | | | | | | | | | | This functionality is only available in RO BRANCH=none BUG=b:146793000 TEST=make -j buildall Signed-off-by: Sam Hurst <shurst@google.com> Change-Id: I3a81284a05c013169d1b401cd2b2056724a06465 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2216408 Reviewed-by: Wai-Hong Tam <waihong@google.com> (cherry picked from commit 3f0e64c37faff5c857289ea95de78b34e3940d39) Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2332245
* servo_v4p1: Add CC DAC functionalitySam Hurst2020-07-314-0/+178
| | | | | | | | | | | | | | | This functionality is available in both RO and RW. BRANCH=none BUG=b:146793000 TEST=make -j buildall Signed-off-by: Sam Hurst <shurst@google.com> Change-Id: Iace11bd64fe9db2fd7ff14827cb412dae1abcbca Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2216407 Reviewed-by: Wai-Hong Tam <waihong@google.com> (cherry picked from commit c2981839b8879c43896ac8ba726564ce9fe7cf36) Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2332244
* servo_v4p1: Add INA231S functionalitySam Hurst2020-07-315-0/+132
| | | | | | | | | | | | | | | This functionality is only available in RO BRANCH=none BUG=b:146793000 TEST=make -j buildall Signed-off-by: Sam Hurst <shurst@google.com> Change-Id: I37f97e8e882a8a5948aeeb669ca39cc930e32d31 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2216406 Reviewed-by: Wai-Hong Tam <waihong@google.com> (cherry picked from commit 5e62b34f19a0d8a93d82990e7327491ca4ee6a1d) Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2332243
* servo_v4p1: Add DUT Charge Through functionalitySam Hurst2020-07-314-0/+125
| | | | | | | | | | | | | | | | This functionality is only available in RO and enables the servo V4.1 to charge the DUT. BRANCH=none BUG=b:146793000 TEST=make -j buildall Signed-off-by: Sam Hurst <shurst@google.com> Change-Id: I317d02081b935d69af712c6189634496f56110f0 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2216404 Reviewed-by: Wai-Hong Tam <waihong@google.com> (cherry picked from commit 48a55c8b351bc10e5637e90814293a4b7869ac84) Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2332242
* servo_v4p1: Add USB3 routing to DUT or HOST functionalitySam Hurst2020-07-314-0/+106
| | | | | | | | | | | | | | | | This functionality is only available in RO and enables the USB3 ports A0 and A1 to be routed to the DUT or HOST. BRANCH=none BUG=b:146793000 TEST=make -j buildall Signed-off-by: Sam Hurst <shurst@google.com> Change-Id: I1fb11fcf918d3351094fd3e2f0553a3aa551f945 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2216403 Reviewed-by: Wai-Hong Tam <waihong@google.com> (cherry picked from commit 6129bccba9c893334a28fda6c233a9854dcabc42) Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2332241
* servo_v4p1: Add CCD measurement functionalitySam Hurst2020-07-315-8/+157
| | | | | | | | | | | | | | | | The CCD measurement functionality is only available in RO. BRANCH=none BUG=b:146793000 TEST=make -j buildall Signed-off-by: Sam Hurst <shurst@google.com> Change-Id: I4bf9885a8a76c8d9dbb688a72673726fb0a7efa5 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2216402 Reviewed-by: Wai-Hong Tam <waihong@google.com> (cherry picked from commit 7745df7b323104633933d9b56faa906e099017d4) Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2332239
* servo_v4p1: Add IO Expander functionality and board setup codeSam Hurst2020-07-316-1/+753
| | | | | | | | | | | | | | | | The IO Expander and board setup functionality are available in RW and RO BRANCH=none BUG=b:146793000 TEST=make -j buildall Signed-off-by: Sam Hurst <shurst@google.com> Change-Id: Ic740169607bd1f97be5145caef08715050ece1ad Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2219119 Reviewed-by: Wai-Hong Tam <waihong@google.com> (cherry picked from commit 8a834c60790e232db196032eec905f56032c5515) Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2332238
* servo_v4p1: Add TCA6416A and TCA6424A driversSam Hurst2020-07-315-1/+262
| | | | | | | | | | | | | | | Add TCA6416A and TCA6424A IO Expander driver. BRANCH=none BUG=b:146793000 TEST=make -j buildall Signed-off-by: Sam Hurst <shurst@google.com> Change-Id: I498496bab9f1b874b502c2a1f704d1693a7c1cf5 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2223822 Reviewed-by: Wai-Hong Tam <waihong@google.com> (cherry picked from commit a5b8745370a725243dafdf315476c6726fdac403) Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2332237
* servo_v4p1: Initial checkin of firmwareSam Hurst2020-07-315-0/+586
| | | | | | | | | | | | | | | | | | | | | | | | | The flash is partitioned as follows: 96K for RO 40K for RW The bulk of the code is placed in RO and RW is used for software updates. This initial checkin implements the following functionality: 1) Software updates over servo_updater BRANCH=none BUG=b:146793000 BUG=b:141180763 TEST=make -j buildall Change-Id: I68f94c5110210c134e7ff7212d6ccc0854413457 Signed-off-by: Sam Hurst <shurst@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2107729 Reviewed-by: Wai-Hong Tam <waihong@google.com> (cherry picked from commit 8253f94d1fc6432b26bbca515628f16ea4dbd658) Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2332236
* servo: Adds USB SPI protocol V2 commands and responsesBrian J. Nemec2020-07-244-104/+630
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Adds the USB SPI protocol V2, this protocol supports larger SPI transfers that are delivered in multiple USB packets. This enables us to perform 2 optimizations on the USB SPI transfer speed for large USB packets: * USB packets can be grouped together reducing the total number of packets exchanged. The host can write multiple data sections sequentially without the device responding with a packet for each one. Going the other direction, the host can continue to poll the device for data until the transmission is complete. * Only a single SPI transaction is required, this eliminates overhead in setting up and getting data from SPI transactions. Benchmark results show a typical 35% improvement in performance on Servo Micro platforms with these changes on operations which involve large SPI transfers reading or writing from the flash. Signed-off-by: Brian Nemec <bnemec@chromium.org> Blocked on upstream changes to flashrom: Depends-On:https://review.coreboot.org/c/flashrom/+/41533 BUG=b:139058552 BRANCH=servo TEST=Tested with Servo Micro with the reading, erase, write, and verify operations with updated copies of flashrom. Change-Id: I04b6cf8449e32cc1b75d3501939958887eb57f5b Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2224765 Reviewed-by: Jett Rink <jettrink@chromium.org> Reviewed-by: Vadim Bendebury <vbendeb@chromium.org> Commit-Queue: Brian Nemec <bnemec@chromium.org> Tested-by: Brian Nemec <bnemec@chromium.org> (cherry picked from commit 7d4f4bf3ea9b002f5935ba0b98698999cd9d94e7) Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2317056 Reviewed-by: Brian Nemec <bnemec@chromium.org>
* servo: Add USB SPI helper functions and context statesBrian J. Nemec2020-07-242-86/+325
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Adds context states to USB SPI for handling receiving and transmitting data. These context states allow us to keep track of data buffers that can not fit within a single USB packet. A context state has been added to describe the USB packets accepted by the USB SPI protocol. This structure includes union fields for easily addressing the different packet's fields and to describe the basic attributes for a USB packet including its size and how many bytes are allocated to the header. Helper functions process the USB packets and aid in the transfer of data between them and receive and transmission buffers. BUG=b:139058552 BRANCH=servo TEST=Tested with Servo Micro reading and verifying flash writes are successful in a loop. Signed-off-by: Brian Nemec <bnemec@chromium.org> Change-Id: I3e0b31f33f442719123b9e897495cad25e9e6ed4 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2224764 Reviewed-by: Vadim Bendebury <vbendeb@chromium.org> Tested-by: Brian Nemec <bnemec@chromium.org> Commit-Queue: Brian Nemec <bnemec@chromium.org> (cherry picked from commit 30e6d281549b34a22877eb6bb45da1e9d0d210b9) Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2317054 Reviewed-by: Brian Nemec <bnemec@chromium.org>
* ec: Minor cleanup of magic number commonly used in STM32 USBBrian J. Nemec2020-07-245-4/+8
| | | | | | | | | | | | | | | | | | | | Minor cleanup of a commonly used magic number in the STM32 USB interface. BUG=none BRANCH=none TEST=Builds Signed-off-by: Brian Nemec <bnemec@chromium.org> Change-Id: I2c0b7947810aae651e452db42ac27221ab19b99b Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2224763 Tested-by: Brian Nemec <bnemec@chromium.org> Reviewed-by: Vadim Bendebury <vbendeb@chromium.org> Commit-Queue: Brian Nemec <bnemec@chromium.org> (cherry picked from commit 11b912091e133568483e92b5aa7fadbf882e5e92) Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2317055 Reviewed-by: Brian Nemec <bnemec@chromium.org>
* servo: Increased stack sizes for servo_v4Brian J. Nemec2020-07-171-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | Increased the stack sizes in servo_V4's console and power delivery tasks. The report from stack analysis: make BOARD=servo_v4 SECTION=RW analyzestack Task: HOOKS, Max size: 336 (112 + 224), Allocated size: 768 Task: CONSOLE, Max size: 664 (440 + 224), Allocated size: 768 Task: PD_C0, Max size: 1136 (912 + 224), Allocated size: 1184 Task: PD_C1, Max size: 1136 (912 + 224), Allocated size: 1184 BUG=b:156476618 BRANCH=servo TEST=make -j BOARD=servo_v4 TESt=make BOARD=servo_v4 SECTION=RW analyzestack Signed-off-by: Brian Nemec <bnemec@chromium.org> Change-Id: Id313b02616441e4cc438e76ec01bf84c598bd4e6 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2271011 Reviewed-by: Ruben Rodriguez Buchillon <coconutruben@chromium.org> (cherry picked from commit 065b286ebea6442d277543f8c4b6af6100bdbd4c) Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2303283
* EC: Add additional stack sizesSam Hurst2020-07-174-0/+62
| | | | | | | | | | | | | | | | | | | | | | Add two additional stack sizes for tasks that need more stack space. BRANCH=none BUG=b:155813111 TEST=make -j buildall Manual: Changed waddledee's TypeC ports0 and 1 to ULTRA_STACK_SIZE and TRENTA_STACK_SIZE and make -j buildall without errors. Signed-off-by: Sam Hurst <shurst@google.com> Change-Id: I927d5b978c705f49d1b3a85a09c4020d7fd9ee84 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2280486 Reviewed-by: Aseda Aboagye <aaboagye@chromium.org> (cherry picked from commit 221510d14a9b9dfeda7e3ede032273f1b5186a72) Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2303282 Reviewed-by: Brian Nemec <bnemec@chromium.org> Commit-Queue: Brian Nemec <bnemec@chromium.org> Tested-by: Brian Nemec <bnemec@chromium.org>
* usb_pd: expose pd_set_src_caps and pd_is_disconnected.Eric Yilun Lin2020-06-183-5/+30
| | | | | | | | | | | | | | Manually merge changes CL:2051220 and CL:1990425. BRANCH=servo BUG=b:159229399 TEST=build pass, and ensure ada_srccaps reports correctly. Change-Id: I3b8b8c479e180911b24b428bd0c2f7e470aecaeb Signed-off-by: Eric Yilun Lin <yllin@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2251123 Reviewed-by: Brian Nemec <bnemec@chromium.org> Commit-Queue: Brian Nemec <bnemec@chromium.org>
* usb_pd_protocol: Invalidate last message id in SRC_SWAP_STANDBY statePatryk Duda2020-06-101-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In SRC_SWAP_STANDBY state when PD_CTRL_PS_RDY message is received, message id counter is cleared, but last message id remain the same. Situation where last message before power swap had message id equal to 0, and first message after power swap had message id equal to 0, was reported as message duplication and as result hard reset was triggered. From ServoV4 perspective: C1 RECV 0e6a/0 <-- Received PR_SWAP with msg_id 7 C1 CTRL[3]>1 <-- Accept it C1 st27 SRC_SWAP_SNK_DISABLE C1 st28 SRC_SWAP_SRC_DISABLE C1 st29 SRC_SWAP_STANDBY C1 CTRL[6]>1 <-- Send PS_RDY C1 RECV 0166/0 <-- Received PS_RDY with msg_id 0 due to msg_id overflow C1 st5 SNK_DISCOVERY C1 Repeat msg_id 0 <-- DUT sent capabilities with msg_id 0 C1 HARD RST RX <-- DUT sent hard reset due to timeout BUG=none BRANCH=none TEST=Flash nocturne with EC compiled with TCPMv2/PD3.0 support. Flash ServoV4 with this fix. Run firmware_PDConnect, test should pass. During test check if ServoV4 is not receiving hard reset requests. TEST=Flash nocturne with EC compiled with TCPMv2/PD3.0 support. Flash ServoV4 with this fix. Run 'fakedisconnect 100 10000' in ServoV4 console. Run 'pd 0 swap power' in DUT console. During power swap no hard reset states should be entered. Change-Id: I902d153a4f427c6a7239f8ff8b70efc9418da31a Signed-off-by: Patryk Duda <pdk@semihalf.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2231365 Reviewed-by: Eric Yilun Lin <yllin@chromium.org> Reviewed-by: Aseda Aboagye <aaboagye@chromium.org> (cherry picked from commit 9f95ab8d1655d141dcceec18d6730c9d6451e4a9) Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2238287 Commit-Queue: Aseda Aboagye <aaboagye@chromium.org>
* servo_v4: clear SrcCap on CHG port disconnectedEric Yilun Lin2020-06-051-0/+8
| | | | | | | | | | | | | | | | | | | | | | | | | Currently, when CHG port's PD disconnected from the servo-v4, it still holds the SourceCap information. This CL clears the SourceCap when the PD disconnection event is found. BUG=b:157261654 TEST=plug charger: > ada_srccaps 0: 5000mV/3000mA 1: 9000mV/3000mA 2: 15000mV/3000mA 3: 20000mV/2250mA unplug charger: > ada_srccaps # print nothing. BRANCH=servo_v4 Change-Id: Ia91c97d6baa5e796c909893dac9abe0e6bc7ebad Signed-off-by: Eric Yilun Lin <yllin@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2215393 Reviewed-by: Wai-Hong Tam <waihong@google.com> Commit-Queue: Wai-Hong Tam <waihong@google.com> (cherry picked from commit 5e251579f921b6a3704d5c5218de22701340614f) Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2230947
* servo_v4: use PD_PREFER_HIGH_VOLTAGE for PDO selection logicEric Yilun Lin2020-06-051-0/+9
| | | | | | | | | | | | | | | | | | | | | | Define PDO selection logic for SourceCap PDO collection. On a 45W PD charger, it might provide PDOs with 15V/3A and 20V/2.25A. In this case, pd_find_pdo_index() would always prefer 15V/3A rather than 20V/2.25A and such that the 20V PDO will be disappeared when servo-v4 advertise the SrcCap. We define PD_PREFER_HIGH_VOLTAGE so that all the PDOs could be advertised by servo-v4. BUG=b:147021699 TEST=plug treeya 45W charger, and see servo-v4 advertise 20V/2.25A PDO BRANCH=servo-v4 Change-Id: I3bd071161679bae98be17fd6b53a24e258d9c15c Signed-off-by: Eric Yilun Lin <yllin@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2215391 Reviewed-by: Wai-Hong Tam <waihong@google.com> Commit-Queue: Wai-Hong Tam <waihong@google.com> (cherry picked from commit d7fbb75271a8ec4ca6d84e08bbac37e2ed6cc4e9) Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2230946
* servo_micro: Increase USART2 queue sizeTom Hughes2020-06-041-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | When servo_micro is forwarded to a remote machine with usbip (go/chromeos-wfh-tools#usbip) and the FPMCU console is on USART2, I see dropped characters: > help Known commands: chan flashwrite gpioset reboot sysinfo crash fpcapture hc history rw taskinfo flashinfo e info; HELP CMD = help on CMD. This doesn't happen when using the same setup with servo_micro's USART3, which has a larger queue size of 1024, so increase USART2 queue size to match. BRANCH=none BUG=b:147849609 TEST=make buildall -j Signed-off-by: Tom Hughes <tomhughes@chromium.org> Change-Id: I5badc239dad866eba0571b3626961b1008979273 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2230336 Commit-Queue: Jett Rink <jettrink@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org>
* usb_pd_protocol: Don't reset msg_id on ACCEPT when in SOFT_RESET statePatryk Duda2020-06-031-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | DUT is running new TCPMv2 stack. PD3.0 enabled When ServoV4 sends PD_CTRL_SOFT_RESET message to DUT it assigns 0 to msg_id because PD_CTRL_SOFT_RESET always has msg_id equal to 0. DUT performs soft reset and responds with PD_CTRL_ACCEPT message. ServoV4 receives PD_CTRL_ACCEPT and calls execute_soft_reset() which again resets msg_id to 0. Next message sent by ServoV4 is dropped by DUT due to msg_id duplication. This issue was found by running firmware_PDResetSoft test against nocturne with TCPMv2/PD3.0 stack. Test was failing after power swap (DUT as SRC) when soft reset was initiated by ServoV4. When DUT was SNK soft reset from ServoV4 was passing, however debugging showed that it was going to hard reset due to negotiation failure, eg. pd 1 soft C1 st33 SOFT_RESET C1 CTRL[13]>1 C1 RECV 0063/0 C1 st18 SRC_DISCOVERY C1 Soft Rst C1 srcCAP>1 C1 st19 SRC_NEGOCIATE C1 st34 HARD_RESET_SEND C1 st35 HARD_RESET_EXECUTE C1 HARD RST TX C1 st16 SRC_HARD_RESET_RECOVER BRANCH=none BUG=b/157600843 TEST=Flash nocturne with EC compiled with TCPMv2/PD3.0 support. Flash ServoV4 with this fix. Run firmware_PDResetSoft, test should pass. Check if ServoV4 is not entering hard reset states Change-Id: Ifb7c031969eb48f740e16117de72ba8bdd36fc0b Signed-off-by: Patryk Duda <pdk@semihalf.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2224804 Reviewed-by: Aseda Aboagye <aaboagye@chromium.org> (cherry picked from commit 99e40128ac0700c919834aaae1e085716b5d76fb) Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2228512 Commit-Queue: Aseda Aboagye <aaboagye@chromium.org>