summaryrefslogtreecommitdiff
path: root/test
Commit message (Collapse)AuthorAgeFilesLines
* common: include config.h from console.hJack Rosenthal2020-09-291-0/+4
| | | | | | | | | | | | | | | | | | | | | console.h currently relies on many config options to selectively define macros. It does not currently include config.h, which means these config options are not guaranteed to be defined by this point. We will need this for Zephyr as well. There were a few configuration header files which implicitly relied on the ording of including console.h to bring in stdint.h at some point. We explicitly include what we use here to fix that. BUG=b:167590251 BRANCH=none TEST=build passes Signed-off-by: Jack Rosenthal <jrosenth@chromium.org> Change-Id: Ia005577a2579962ee8b14c61930f37fe28bc8f5c Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2427088 Reviewed-by: Yuval Peress <peress@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org>
* tree: rename atomic_* functions to deprecated_atomic_*Jack Rosenthal2020-09-291-2/+2
| | | | | | | | | | | | | | | | We will move to an API compatible with Zephyr's API. See the bug for complete rationale and plan. BUG=b:169151160 BRANCH=none TEST=buildall Signed-off-by: Jack Rosenthal <jrosenth@chromium.org> Change-Id: Id611f663446abf00b24298a669f2ae47fef7f632 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2427507 Tested-by: Dawid Niedźwiecki <dn@semihalf.com> Reviewed-by: Tom Hughes <tomhughes@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org>
* fpsensor: Fix buffer check to account for overflowTom Hughes2020-09-251-1/+23
| | | | | | | | | | | BRANCH=none BUG=b:144957935 TEST=make buildall Signed-off-by: Tom Hughes <tomhughes@chromium.org> Change-Id: I1b4fa0a715869ccc37e48d75316ef52c367aa64a Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2417529 Reviewed-by: Craig Hesling <hesling@chromium.org>
* test/utils: Add unit tests for safe_memcmpTom Hughes2020-09-241-0/+15
| | | | | | | | | | | | BRANCH=none BUG=b:169156874 TEST=make buildall Signed-off-by: Tom Hughes <tomhughes@chromium.org> Change-Id: I0bf4bdd654e6ba64b718c0d18650d561294744bc Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2424067 Reviewed-by: Diana Z <dzigterman@chromium.org> Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
* test: Add test_send_caps_error to usb_pe_drpEdward Hill2020-09-222-11/+102
| | | | | | | | | | | | | | | | | As requested in CL:2321869 review, make a new version of test_send_caps_error that uses the external interface of the PE layer. BUG=b:161835483 BRANCH=none TEST=make run-usb_pe_drp Signed-off-by: Edward Hill <ecgh@chromium.org> Change-Id: I983b145cd1e731e844363955896898a2374a0a30 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2419834 Reviewed-by: Paul Fagerburg <pfagerburg@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org> Commit-Queue: Paul Fagerburg <pfagerburg@chromium.org>
* TCPMv2: Move DPM requests to public APIAbe Levkoy2020-09-212-3/+3
| | | | | | | | | | | | | | | | It is safe (atomic bit ops) and will soon be necessary (new host commands) to send DPM requests from outside the PD tasks. Rename pe_dpm_request to pd_dpm_request and move the declarations into usb_pd.h to reflect this. BUG=b:168030639 TEST=make buildall BRANCH=none Signed-off-by: Abe Levkoy <alevkoy@chromium.org> Change-Id: Ied43e9f6973a3172b98090cc068a607257dce21b Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2415068 Reviewed-by: Jett Rink <jettrink@chromium.org>
* run_device_tests.py: Add type informationTom Hughes2020-09-101-15/+20
| | | | | | | | | | | | BRANCH=none BUG=b:162009542 TEST=mypy ./test/run_device_tests.py TEST=./test/run_device_tests.py Signed-off-by: Tom Hughes <tomhughes@chromium.org> Change-Id: I46d83c15eeaba03abd3477b516be22278a3dcf2b Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2316522 Reviewed-by: Craig Hesling <hesling@chromium.org>
* test: body_detection: add unittest for algorithmChing-Kang Yen2020-09-037-3/+6397
| | | | | | | | | | | | | | | | | | Add test to check if the algorithm of body detection is correct. There are three testcases: OnBody: always in on-body state, should not change to off-body Off to On: change state from off-body to on-body On to Off: change state from on-body to off-body BRANCH=None BUG=b:123434029 TEST=make buildall Signed-off-by: Ching-Kang Yen <chingkang@chromium.org> Change-Id: Ib027fa3ed659f0d2efd7416888a9ee4ad519edd6 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2329113 Reviewed-by: Heng-ruey Hsu <henryhsu@chromium.org>
* tcpmv2: allow early connection when waiting to allow LPMDenis Brockus2020-09-021-0/+38
| | | | | | | | | | | | | | | | | | While waiting to go into Low Power Mode the TCPC can detect a connection and we should honor that instead of waiting for the timeout and going into Auto Toggle. BUG=b:157718272 BRANCH=none TEST=FAFT_PD "dut-control usbc_pr:src20v" Signed-off-by: Denis Brockus <dbrockus@google.com> Change-Id: Ib3a3233ebf9b05b83446d7c1163e30fdcaf42aec Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2390848 Tested-by: Denis Brockus <dbrockus@chromium.org> Auto-Submit: Denis Brockus <dbrockus@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org> Commit-Queue: Jett Rink <jettrink@chromium.org>
* TCPMv2: Add DPM_REQUEST_GET_SRC_CAPDenis Brockus2020-09-022-4/+28
| | | | | | | | | | | | | | | | | | | | | As a SRC that runs on battery it can be handy to determine if the connected partner has unconstrained power available so we can try to PR_Swap to let them power us. This only requests the information, if it is not already available, and leaves it to other code to determine if the swap is a good idea. BUG=b:166446426 BRANCH=none TEST=connect a sink device and determine it performed the action Signed-off-by: Denis Brockus <dbrockus@google.com> Change-Id: If45801a33df8b75e541989d7ee8f36ed316ffcc6 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2381408 Tested-by: Denis Brockus <dbrockus@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org> Commit-Queue: Jett Rink <jettrink@chromium.org> Auto-Submit: Denis Brockus <dbrockus@chromium.org>
* TCPMv2: use sender_response message frameworkDenis Brockus2020-09-022-1/+1
| | | | | | | | | | | | | | | | | | Building up the framework to handle discarded DPM requests and using it on all of the sender_response messages BUG=b:165822172 BRANCH=none TEST=DUT-DUT PR_Swap Signed-off-by: Denis Brockus <dbrockus@google.com> Change-Id: I542d4cba89a923fb16588cc675d2ea4ab7954e0a Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2376386 Tested-by: Denis Brockus <dbrockus@chromium.org> Commit-Queue: Jett Rink <jettrink@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org> Auto-Submit: Denis Brockus <dbrockus@chromium.org>
* usb_pe_drp: new unit test with mocksPaul Fagerburg2020-08-3111-84/+192
| | | | | | | | | | | | | | | | | | | Add a new unit test for usb_pe_drp with mocks for the various subsystems that it will use. The fake_prl module is already essentially a mock for the PRL layer, so just move it into the mocks directory and make it available as mock to other tests. BUG=b:163421994 BRANCH=None TEST=`make runhosttests` succeeds Signed-off-by: Paul Fagerburg <pfagerburg@google.com> Change-Id: I2aea3fa0694e8d9e6bae1f47516cb4d5d2a1e714 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2364050 Tested-by: Paul Fagerburg <pfagerburg@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org> Commit-Queue: Paul Fagerburg <pfagerburg@chromium.org>
* fpsensor: Run maintenance when in maintenance modeTom Hughes2020-08-311-0/+18
| | | | | | | | | | | | BRANCH=none BUG=b:76037094 TEST=make buildall -j Signed-off-by: Tom Hughes <tomhughes@chromium.org> Change-Id: Ibe8649c3cf77ef4542b5fc46d7df5eee03293b56 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2364755 Commit-Queue: Craig Hesling <hesling@chromium.org> Reviewed-by: Craig Hesling <hesling@chromium.org>
* TCPMv2: Don't interrupt RX/TX Extended Chunked Msg sequenceSam Hurst2020-08-221-1/+61
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Delay sending a new message during the reception or transmitting of Chunked messages. BRANCH=none BUG=b:161836223 TEST=make -j buildall manual: Transmitted an extended message and verified that the sequence was not interrupted by attempting to send a VDM message. Without patch Chunked message request that was interrupted. 20-08-14 10:46:13.473 C1: RECV 9a9f/1 [0]00008c00 20-08-14 10:46:13.494 C1: RECV 9c9f/1 [0]00009400 20-08-14 10:46:13.516 C1: RECV 9e9f/1 [0]00009c00 20-08-14 10:46:13.535 C1: RECV 909f/1 [0]0000a400 Try to send VDM. MSG_TYPE is corrupted, was 0x1f, now 0x0f 20-08-14 10:46:13.563 C1: RECV 928f/1 [0]0000ac00 20-08-14 10:46:13.591 C1: RECV 948f/1 [0]0000b400 20-08-14 10:46:13.618 C1: RECV 968f/1 [0]0000bc00 20-08-14 10:46:13.645 C1: RECV 988f/1 [0]0000c400 20-08-14 10:46:13.674 C1: RECV 9a8f/1 [0]0000cc00 With patch. Chunked message request was not interrupted. 20-08-14 10:50:56.052 C1: RECV 9a9f/1 [0]00008c00 20-08-14 10:50:56.075 C1: RECV 9c9f/1 [0]00009400 20-08-14 10:50:56.093 C1: RECV 9e9f/1 [0]00009c00 20-08-14 10:50:56.114 C1: RECV 909f/1 [0]0000a400 Try to send VDM. Message delayed 20-08-14 10:50:56.134 C1: RECV 929f/1 [0]0000ac00 20-08-14 10:50:56.155 C1: RECV 949f/1 [0]0000b400 20-08-14 10:50:56.175 C1: RECV 969f/1 [0]0000bc00 20-08-14 10:50:56.195 C1: RECV 989f/1 [0]0000c400 20-08-14 10:50:56.216 C1: RECV 9a9f/1 [0]0000cc00 20-08-14 10:50:56.242 C1: RECV 0c90/0 Try to send VDM. Signed-off-by: Sam Hurst <shurst@google.com>wq Change-Id: I5475792ee9f272fe4964e27839e55e3409a6a799 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2357414
* usbc: wake task on every state transitionJett Rink2020-08-192-19/+11
| | | | | | | | | | | | | | | | | | Whenever we change state, we should continue to wake the USB statemachine task up until is settles into a steady state were it is waiting/polling on a timer or event. BRANCH=none BUG=b:163152687 TEST=Ran GRL PD3.0 test on Trembyle and did not see any regressions. It did make a few tests pass that were failing before due to timing issues. Signed-off-by: Jett Rink <jettrink@chromium.org> Change-Id: Idc3c1ae8d92a0f6a5cd4b82f9db6d7138d143f77 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2356954 Reviewed-by: Edward Hill <ecgh@chromium.org> Reviewed-by: Diana Z <dzigterman@chromium.org> Commit-Queue: Diana Z <dzigterman@chromium.org>
* common: gyro_cal: Implement gyroscope calibrationYuval Peress2020-08-184-0/+631
| | | | | | | | | | | | | | Implement the calibration code for the gyroscope which is ported over from AOSP's https://android.googlesource.com/device/google/contexthub/+/refs/heads/master/firmware/os/algos/calibration/gyroscope/ BUG=b:138303429,b:137204366,chromium:1023858 TEST=Added unit tests BRANCH=None Signed-off-by: Yuval Peress <peress@chromium.org> Change-Id: Ic1ab2efb66565cda0a96c9c06722136fb184df77 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2244934 Reviewed-by: Jack Rosenthal <jrosenth@chromium.org>
* test: rename usb_pe_drp to usb_pe_drp_oldPaul Fagerburg2020-08-178-8/+377
| | | | | | | | | | | | | | | | | Rename the current usb_pe_drp test to usb_pe_drp_old. There will be a new usb_pe_drp test that uses mocks and we will move the tests over in a controlled fashion. BUG=b:163421994 BRANCH=None TEST=`TEST_LIST_HOST=usb_pe_drp_old make runhosttests` works. Signed-off-by: Paul Fagerburg <pfagerburg@google.com> Change-Id: I2e0f79eb793d888109d00a96567042356c770502 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2357519 Tested-by: Paul Fagerburg <pfagerburg@chromium.org> Reviewed-by: Diana Z <dzigterman@chromium.org> Commit-Queue: Paul Fagerburg <pfagerburg@chromium.org>
* CBI: Make test fail if a tag is missing from unit testDaisuke Nojiri2020-08-141-0/+35
| | | | | | | | | | | | | | This patch adds a check in the unit test which fails if there is a tag missing from test_all_tags. This will force developers to pay attension to the unit test when adding a new tag. BUG=none BRANCH=none TEST=buildall Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> Change-Id: I34d054493e16454c3662b289eaa6d4de362a26f4 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2354200
* cleanup/usbc: organize all super states togetherJett Rink2020-08-131-7/+5
| | | | | | | | | | | | | | Like other state machine declarations, put all of the super states together to make it more clear when reading states. BRANCH=none BUG=none TEST=build and unit tests Signed-off-by: Jett Rink <jettrink@chromium.org> Change-Id: I1bb776434911d3acdb34abc64e7e8fa5f87154de Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2354193 Reviewed-by: Edward Hill <ecgh@chromium.org>
* usbc: add GEN_NOT_SUPPORTED macro for unsupported statesJett Rink2020-08-131-5/+3
| | | | | | | | | | | | | | | | | | | To enabled use of the IS_ENABLE macro we need to define some of the usb state machine states as extern variables that will never be linked. This allows the compiler to know about a state but will still fail the linking phase if the config option is not defined properly. This is just adding a convenience macro for this paradigm, not creating the paradigm itself. BRANCH=none BUG=none TEST=builds Signed-off-by: Jett Rink <jettrink@chromium.org> Change-Id: Ia19b5babd43d536f043745314481475cf25f6e01 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2353369 Reviewed-by: Edward Hill <ecgh@chromium.org>
* test: remove no_empty_state testsJett Rink2020-08-137-73/+0
| | | | | | | | | | | | | | | | When we use IS_ENABLED style code we may have empty state machine states that are unused. The linker ensures that we never try to reference these states. This does mean that extra states do cost ~20 bytes each. This cost does seem worth it to keep the value of usb states stable. BRANCH=none BUG=none TEST=buildall Signed-off-by: Jett Rink <jettrink@chromium.org> Change-Id: I44c1454bed91c9e28d89ebd6b75e9df684c41844 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2354192 Reviewed-by: Edward Hill <ecgh@chromium.org>
* tcpmv2: wait before enabling HW auto toggleJett Rink2020-08-132-0/+27
| | | | | | | | | | | | | | | We need to ensure that the previous Rd or Rp has been held long enough before we transition into hardware auto toggle otherwise the first toggle might be too short and violate the DRP timing spec BRANCH=none BUG=b:163095971 TEST=Verify on scope Signed-off-by: Jett Rink <jettrink@chromium.org> Change-Id: I92e9f5ca7dbca2b347e438d774551cc11476195b Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2343176 Reviewed-by: Edward Hill <ecgh@chromium.org>
* cbi: add Second Source Factory Cache (SSFC) CBI fieldMarco Chen2020-08-131-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | SSFC field will be leveraged to record what second source is used in the DUT by probing components in the factory or RMA. Firmware code should refer to this field to judge what driver should be configured for a specific component. For example, the board code can arrange what sensor driver should be set into motion_sensors array if there are multiple sources of base or lid sensor. As the definition of FW_CONFIG, it describe which "features" the firmware code should enable or disable. For example, whether lid / base sensors should be enabled or not but not care about what second source is in this DUT. BRANCH=none BUG=b:163285687 TEST=call `cbi-util` to create the cbi image with SSFC and show created content. TEST=`make buildall -j` TEST=`make runhosttests -j` Change-Id: Icb4aa00ae47ab025198e7fd5edd6aab96a4bf53e Signed-off-by: Marco Chen <marcochen@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2344268 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org> Commit-Queue: Jett Rink <jettrink@chromium.org>
* flash: allow programming larger EC imagesKeith Short2020-08-131-3/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | For some ECs, the EC image size is limited by the amount of code RAM instead of 1/2 the total flash size. In this instance, there is unused flash that can be used for single use data objects. To support linking data objects into the unused flash area, increase the region size that can be programmed for RW images. Analysis of chips that are impacted by this change: Chip EC image limit New RW size limit mec1701h 188 KiB 256 KiB mec17xx_2E00 188 KiB 256 KiB npcx5m5g 96 KiB 128 KiB npcx5m6g 224 KiB 256 KiB npcx7m6f 192 KiB 256 KiB npcx7m6fb 192 KiB 256 KiB npcx7m6fc 192 KiB 256 KiB npcx7m6g 192 KiB 256 KiB npcx7m7wb 256 KiB 512 KiB npcx7m7wc 252 KiB 256 KiB Boards using other chips verified that CONFIG_RW_SIZE is the same as CONFIG_EC_WRITABLE_STORAGE_SIZE. EC_FLASH_REGION_RO isn't used by depthcharge, only EC_FLASH_REGION_WP_RO which is already set to the correct size. BUG=b:160330682 BRANCH=none TEST=make buildall Signed-off-by: Keith Short <keithshort@chromium.org> Change-Id: I84b9dc84568273e1ab1473e301d27ffd2b07ba7f Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2325764 Reviewed-by: Abe Levkoy <alevkoy@chromium.org> Reviewed-by: caveh jalali <caveh@chromium.org> Commit-Queue: caveh jalali <caveh@chromium.org>
* mock/usb_pd_mock: remove tc functionsPaul Fagerburg2020-08-121-2/+1
| | | | | | | | | | | | | Remove tc_set_data_role and tc_set_power_role from usb_pd_mock. BUG=b:163421165 BRANCH=None TEST=`make runhosttests`, all unit tests pass Signed-off-by: Paul Fagerburg <pfagerburg@chromium.org> Change-Id: Ib380d2f04f833b58e23a16d0c6421316b72329fe Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2349282 Reviewed-by: Jett Rink <jettrink@chromium.org>
* test/usb_pe_drp: remove fake_batteryPaul Fagerburg2020-08-121-1/+1
| | | | | | | | | | | | | | | | The test/usb_pe_drp build includes fake_battery.o, which is not used in the unit test, so remove it from the build. BUG=b:163421994 BRANCH=None TEST=`make runhosttests`, all unit tests pass Signed-off-by: Paul Fagerburg <pfagerburg@google.com> Change-Id: Ie3167345415073de073386d1f4d82310563e9d27 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2349281 Tested-by: Paul Fagerburg <pfagerburg@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org> Commit-Queue: Paul Fagerburg <pfagerburg@chromium.org>
* test: Soft_Reset sent regardless of Rp valueEdward Hill2020-08-122-3/+45
| | | | | | | | | | | | | | | Add test for TD.PD.SRC3.E26.Soft_Reset sent regardless of Rp value. BUG=b:161835483 BRANCH=none TEST=make -j run-usb_tcpmv2_tcpci Signed-off-by: Edward Hill <ecgh@chromium.org> Change-Id: I972bffcb1c7a330aef4ebdff98fcd33af9a667be Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2340486 Reviewed-by: Denis Brockus <dbrockus@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org> Commit-Queue: Denis Brockus <dbrockus@chromium.org>
* CBI: Add unit testDaisuke Nojiri2020-08-073-0/+206
| | | | | | | | | | | | This patch adds unit tests for Cros Board Info APIs. BUG=b:163038871 BRANCH=none TEST=buildall Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> Change-Id: I7b2fdb2c4f13da12f8c0dc2ab526332cbd46d849 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2339393
* usbc: correctly handle Get_Source_Cap as a sinkPeter Marheine2020-08-063-4/+45
| | | | | | | | | | | | | | | | | | | | | | | | | | USB Power Delivery Specification Revision 3.0, version 2.0 section 6.3.7 states that a dual-role port shall respond to Get_Source_Cap with its source capabilities, but this was incorrectly handled by responding with a request for source capabilities. Per section 8.3.3.18.10, implement the PE_DR_SNK_Give_Source_Cap state to handle this correctly. To support the new test, some helper functions for the fake PE are added and the test code's copy of the PE state enum is updated to be in sync with the real one. BUG=b:161400825,b:161331630 TEST=New host test for this state, and verified on Dalboz that requesting a PRS via the EC console (`pd 1 swap power`) now sends source capabilities when the partner requests them. BRANCH=None Signed-off-by: Peter Marheine <pmarheine@chromium.org> Change-Id: I87c27d406e0a3f57cf2c25fa583bee51155b6b12 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2336233 Reviewed-by: Jett Rink <jettrink@chromium.org> Reviewed-by: Diana Z <dzigterman@chromium.org>
* tcpmc2: fix TD.PD.LL3.E2 Retransmission testJett Rink2020-08-062-143/+84
| | | | | | | | | | | | | | | | | | | | | | | 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
* ec: change usage of dummySam Hurst2020-08-054-11/+11
| | | | | | | | | | | | | | | | | | Google is working to change its source code to use more inclusive language. To that end, replace the term "dummy" with inclusive alternatives. BUG=b:162781382 BRANCH=None TEST=make -j buildall `grep -ir dummy *` The only results are in "private/nordic_keyboard/sdk8.0.0" which is not our code. Signed-off-by: Sam Hurst <shurst@google.com> Change-Id: I6a42183d998e4db4bb61625f962867fda10722e2 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2335737 Reviewed-by: Tom Hughes <tomhughes@chromium.org>
* test: Add PD TX and RX to usb_tcpmv2_tcpciEdward Hill2020-08-052-2/+102
| | | | | | | | | | | | | BUG=b:162369240 BRANCH=none TEST=make -j run-usb_tcpmv2_tcpci Signed-off-by: Edward Hill <ecgh@chromium.org> Change-Id: I61a9f99a10c3432135a91699ac04ff65690388e7 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2335455 Commit-Queue: Jett Rink <jettrink@chromium.org> Reviewed-by: Denis Brockus <dbrockus@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org>
* TCPMv2: Soft reset on failure to send source capsEdward Hill2020-08-012-1/+37
| | | | | | | | | | | | | | | | | | | | pe_report_error() defers to PE_SRC_SEND_CAPABILITIES for custom error handling (via PE_FLAGS_PROTOCOL_ERROR). pe_src_send_capabilities_run() was correctly going to PE_SRC_DISCOVERY when we are not connected (PD 3.0 8.3.3.2.3), but it was failing to send soft reset when we are already connected (PD 3.0 8.3.3.4.1.1). BUG=b:161835483 BRANCH=none TEST=make run-usb_pe_drp PD 3.0 compliance test TD.PD.SRC3.E26 (Soft_Reset sent regardless of Rp value) Signed-off-by: Edward Hill <ecgh@chromium.org> Change-Id: Id71e38a69006e95b7ff4f7145e86bd5ac64c7577 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2321869 Reviewed-by: Jett Rink <jettrink@chromium.org>
* TCPMv2: Use named constants for extended messagesAbe Levkoy2020-07-292-14/+14
| | | | | | | | | | | | | | These correspond to MaxExtendedMsgLen and MaxExtendedMsgChunkLen (PD 3.0, rev 2.0, ss 6.13). BUG=b:160374787 TEST=make buildall BRANCH=none Signed-off-by: Abe Levkoy <alevkoy@chromium.org> Change-Id: I3640df18724c3c04e9f644ca59a6542563d723f0 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2316135 Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
* TCPMv2: Optionally build extended message supportAbe Levkoy2020-07-2910-18/+212
| | | | | | | | | | | | | | | | | | If CONFIG_USB_PD_EXTENDED_MESSAGES is defined, support sending and receiving extended messages. If it is not, remove the chunking state machines from the PRL and modify the PE to respond with Not Supported as appropriate. BUG=b:160374787,b:158572770 TEST=Attach various devices; observe PD traffic TEST=make run-usb_prl_noextended; make run-usb_pe_drp_noextended BRANCH=none Signed-off-by: Abe Levkoy <alevkoy@chromium.org> Change-Id: I862020155927b5613d599274708e60678c49c43c Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2304263 Commit-Queue: Jett Rink <jettrink@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org>
* Make wait_for_ready available for allDaisuke Nojiri2020-07-281-0/+18
| | | | | | | | | | | | | | | | | | | wait_for_ready is a generic function which loops until bits in a register are set. This patch move it to util.c to make it available for all. There are more places where the function is applicable but this CL keeps the scope under chip/stm32/clock-stm32. There is no functionality change. BUG=none BRANCH=none TEST=buildall Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> Change-Id: I796599344c1d86ab7144d1d6b434ec54cf1cc55d Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2317887 Reviewed-by: Scott Collyer <scollyer@chromium.org>
* run_device_tests.py: Explicitly set hardware write protectTom Hughes2020-07-241-2/+21
| | | | | | | | | | | | | | | | Hardware write protect is something that can affect a test. We now explicitly set the state for each test. Currently only the flash_write_protect test has it enabled. BRANCH=none BUG=b:151105339 TEST=./run_device_tests.py Signed-off-by: Tom Hughes <tomhughes@chromium.org> Change-Id: I956e00b75bdf5fe416386f0ac9090f864e3733dc Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2316161 Commit-Queue: Craig Hesling <hesling@chromium.org> Reviewed-by: Craig Hesling <hesling@chromium.org>
* run_device_tests.py: Specify python3Tom Hughes2020-07-241-1/+1
| | | | | | | | | | | | BRANCH=none BUG=b:151105339 TEST=./test/run_device_tests.py Signed-off-by: Tom Hughes <tomhughes@chromium.org> Change-Id: I5405817dd67eac63f9005954f1f18d44a4168731 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2316160 Commit-Queue: Craig Hesling <hesling@chromium.org> Reviewed-by: Craig Hesling <hesling@chromium.org>
* ec: change usage of "sane" per inclusive languagePaul Fagerburg2020-07-227-7/+7
| | | | | | | | | | | | | | | | Google is working to change its source code to use more inclusive language. To that end, replace the terms "sane", "sanity check", and similar with inclusive/non-stigmatizing alternatives. BUG=b:161832469 BRANCH=None TEST=`make buildall -j` succeeds. `grep -Eir "sane|sanity" .` shows results only in third-party code or documentation. Signed-off-by: Paul Fagerburg <pfagerburg@chromium.org> Change-Id: I29e78ab27f84f17b1ded75cfa10868fa4e5ae88c Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2311169 Reviewed-by: Jett Rink <jettrink@chromium.org>
* test: Use pd_task for pe testJett Rink2020-07-213-34/+19
| | | | | | | | | | | | | | | | Instead of calling pe function direction in unit test, use the existing state machine task for unit tests. This allows the real code to call into a task_set_event on the PD tasks. See CL:1786462 where this is needed. BRANCH=none BUG=none TEST=run test passes with and without CL:1786462 Signed-off-by: Jett Rink <jettrink@chromium.org> Change-Id: If31f946e2253c724dd314b2b22e2265cf46197f4 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2307713 Reviewed-by: Diana Z <dzigterman@chromium.org>
* TCPMv2: add unit tests for packet discard logicPaul Fagerburg2020-07-201-1/+126
| | | | | | | | | | | | | | Add unit tests for the packet discard logic for packets while going into SinkTxNG. BUG=b:160622527, b:161174072 BRANCH=None TEST=`TEST_LIST_HOST=usb_prl make runhosttests` Signed-off-by: Paul Fagerburg <pfagerburg@chromium.org> Change-Id: Ied7689d2fe40da93069e58b53ea32e053ab887b8 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2300690 Reviewed-by: Jett Rink <jettrink@chromium.org>
* TCPMv2: Add common function for DPM entry and exit modeAyushee2020-07-171-5/+1
| | | | | | | | | | | | | | | | Added a common entry point into DPM for entering or exiting modes. BUG=b:155890173 BRANCH=None TEST=Tested on volteer, able to enter and exit 1. DisplayPort mode with type-C dock 2. Thunderbolt mode with a Thunderbolt dock Signed-off-by: Ayushee <ayushee.shah@intel.com> Change-Id: I3bb996d96d0fff543ad7a2e1dc8e09d0b17d0171 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2299840 Reviewed-by: Abe Levkoy <alevkoy@chromium.org> Commit-Queue: Abe Levkoy <alevkoy@chromium.org>
* TCPMv2: Add common exit mode for all the alternate modesAyushee2020-07-171-0/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | When chipset is transitioning to a new state or on sysjump, the SOC re-negotiates to enter an alternate mode on booting up. This commit: 1. Adds a common DPM function to check for all the active alternate modes one at a time, construct the VDM and send the DPM request to exit the mode. 2. Marks thunderbolt mode as inactive in DFP's thunderbolt mode exit function. BUG=b:152235216 BRANCH=None TEST=Tested on volteer: 1. On connecting a DP dongle, able to enter into DP alternate mode on reboot 2. On connecting a Thunderbolt dock, able to enter into Thunderbolt mode on reboot Change-Id: I7da6a4b08cab9abb3446c0dafdc7c9e9378ef00e Signed-off-by: Ayushee <ayushee.shah@intel.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2270877 Tested-by: Abe Levkoy <alevkoy@chromium.org> Reviewed-by: Abe Levkoy <alevkoy@chromium.org> Commit-Queue: Abe Levkoy <alevkoy@chromium.org>
* tcpmv2: Add usb_tcpmv2_tcpci testEdward Hill2020-07-155-0/+201
| | | | | | | | | | | | | | | | | | | | Add a new test that runs a full set of TCPMv2 layers and state machines, talking to a simulated TCPC via I2C. Initial test cases: 1) Plug in a non-PD power supply -> we connect as sink. 2) AP S5 > S3 > S0 -> auto-toggle + low power. BUG=b:161167893 BRANCH=none TEST=make -j run-usb_tcpmv2_tcpci Signed-off-by: Edward Hill <ecgh@chromium.org> Change-Id: If8b8eb2cca722ed01cbe1d6000fb3e4f4b70149c Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2283911 Reviewed-by: Paul Fagerburg <pfagerburg@chromium.org> Reviewed-by: Denis Brockus <dbrockus@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org>
* host: Fix task_wait_event() to return TASK_EVENT_TIMEREdward Hill2020-07-131-5/+2
| | | | | | | | | | | | BUG=none BRANCH=none TEST=make -j runhosttests Signed-off-by: Edward Hill <ecgh@chromium.org> Change-Id: Ibd753b2eec5d81438dc0884b1a0c12c4c319afe2 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2294164 Reviewed-by: Denis Brockus <dbrockus@chromium.org> Commit-Queue: Denis Brockus <dbrockus@chromium.org>
* ppc: Fix return values of ppc_is_* to be booleanEdward Hill2020-07-111-4/+4
| | | | | | | | | | | | | | | The return values for ppc_is_sourcing_vbus(), ppc_is_port_latched_off(), ppc_is_vbus_present() are boolean, so EC_ERROR_UNIMPLEMENTED and EC_ERROR_INVAL cannot be returned. BUG=none BRANCH=none TEST=none Signed-off-by: Edward Hill <ecgh@chromium.org> Change-Id: Ic56fd5ac75e5f0ad6e21c803feb929983f08aaf3 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2290664 Reviewed-by: Denis Brockus <dbrockus@chromium.org>
* tcpmv2: perform partner reset on startup, remove BBRAMJett Rink2020-07-101-0/+63
| | | | | | | | | | | | | | | | | | | | | | | - Reset the port partner by applying CC Open on both CC lines - Reuse the existing error recovery state to apply CC values - Extend error recovery timer to 240 msec to account for us being able to source Vconn - Since we always reset on startup, we don't need to store previous contracts in BBRAM. BRANCH=none BUG=b:159495742,b:158802939 TEST=see that we apply CC Open upon reset TEST=see that we do not get a fault on Trembyle went setting CC open TEST=apple 3-1 dongle with display port and power on Puff will come back with power and display after a `reboot` EC command (which will trigger the ErrorRecovery brownout path) Signed-off-by: Jett Rink <jettrink@chromium.org> Change-Id: Iaac09d62e4a31557492cebb354d3a34371c1e9bb Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2271002 Reviewed-by: Denis Brockus <dbrockus@chromium.org> Reviewed-by: Diana Z <dzigterman@chromium.org>
* tests: reset the PD task before every test caseJett Rink2020-07-101-4/+8
| | | | | | | | | | | | | | | | | In order to isolate each test and make each test run from a clean state, reuse the TASK_RESET_DONE event to signal to the test code that we should just jump back to the beginning of the PD task BRANCH=none BUG=none TEST=see that tests are reset in child CLs Signed-off-by: Jett Rink <jettrink@chromium.org> Change-Id: I3c0408ab0dbc3ad3a26f17aadbda1577ffc7d32f Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2290650 Reviewed-by: Paul Fagerburg <pfagerburg@chromium.org> Reviewed-by: Denis Brockus <dbrockus@chromium.org>
* usbc: ensure we are suspending USB-C ports on shutdownJett Rink2020-07-094-0/+18
| | | | | | | | | | | | | | | | | | | | | | After CL:2208221, the check for the PD_CMD task no longer trigger, so we end up not calling suspend on our TCPC ports. We want to continue to suspend, which will apply CC open in TCPMv2 for a cooperative shutdown Also, correct override keyword usage for board_get_usb_pd_port_count since I had to touch those definitions to make IS_ENABLE work BRANCH=none BUG=b:160243292 TEST=See that software sync reboot, applies CC open (and browns out system) Change-Id: I00bf08c7d347441d77834e2c5122a09ca2316280 Signed-off-by: Jett Rink <jettrink@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2276318 Reviewed-by: Diana Z <dzigterman@chromium.org> Reviewed-by: Denis Brockus <dbrockus@chromium.org> Commit-Queue: Denis Brockus <dbrockus@chromium.org>
* tcpmv2: remove tc_restart indirection layerJett Rink2020-07-071-2/+0
| | | | | | | | | | | | BRANCH=none BUG=none TEST=builds Signed-off-by: Jett Rink <jettrink@chromium.org> Change-Id: I2beaa8b74b313d225b9166f324d2b44cb0aa59ce Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2276317 Reviewed-by: Aseda Aboagye <aaboagye@chromium.org> Reviewed-by: Denis Brockus <dbrockus@chromium.org>