summaryrefslogtreecommitdiff
path: root/test
Commit message (Collapse)AuthorAgeFilesLines
* test: Add on-device unit test for STM32 RTCTom Hughes2020-04-303-0/+62
| | | | | | | | | | | | BRANCH=none BUG=b:151105339 TEST=make BOARD=bloonchipper test-stm32f_rtc -j Flash stm32f_rtc.bin and "runtest" in the console Signed-off-by: Tom Hughes <tomhughes@chromium.org> Change-Id: I3debfd93b62cb269ad61af0e4ca7e195554b5548 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2171569 Reviewed-by: Eric Yilun Lin <yllin@chromium.org>
* tcpmv2: SNK HardReset cleanupDenis Brockus2020-04-301-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | tc_hard_reset tells tcpc we are starting a hard reset. It now disables AutoDischargeDisconnect and sets the flag to put TC in reset. When this happens, TCPC should not go to an unattached state. tc_hard_reset_complete was added to tell the TCPC we are done with the hard reset and going to an unattached state is allowed again. It enables AutoDischargeDisconnect and clears the flag that blocked the TCPC from going to an unattached state. hard reset changes the TCPCI mask register to be their default values. Alert will now detect this and will make sure the TCPC is initialized and back to what we expect it to be. BUG=b:154073581,b:154622375,b:154937258 BUG=b:154778807,b:155132904 BRANCH=none TEST=verify charger is still detected after hardreset Signed-off-by: Denis Brockus <dbrockus@google.com> Change-Id: I3e1dd04b04653b8fca5dccc9373533d5a5ff9586 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2172063 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>
* Button: Add unit tests for simulated button presspandeyan2020-04-292-0/+135
| | | | | | | | | | | | | | Added unit test cases to verify the button simulate operations. BUG=b:149659987 BRANCH=None TEST= Executed all unit tests locally make runhosttests -j Signed-off-by: pandeyan <anshuman.pandey@intel.com> Change-Id: If936766e03d574590fd90b1ea7a543102e263b0c Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2131966 Reviewed-by: Jett Rink <jettrink@chromium.org>
* tests/kb_8042: Add vivaldi keyboard testsRajat Jain2020-04-271-0/+70
| | | | | | | | | | | | | | | Add tests for the vivaldi keyboard Signed-off-by: Rajat Jain <rajatja@google.com> BUG=b:154772934 TEST=make -j buildall BRANCH=None Change-Id: I3bd36162077a7770a6af30f6783b7c70736e8c74 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2162187 Reviewed-by: Jett Rink <jettrink@chromium.org> Commit-Queue: Rajat Jain <rajatja@google.com> Tested-by: Rajat Jain <rajatja@google.com>
* common/keyboard_vivaldi: New keyboard framework for custom layoutRajat Jain2020-04-211-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Vivaldi is a new keyboard that allows individual boards to have additional or different top row keys and/or to reorder those keys. The primary agenda of vivaldi is to allow customization of the top row keys. However, as a secondary objective, it also allows coreboot to send a keymap to the kernel, for only the keys that are actually present on the keyboard. As part of enabling vivaldi, another feature that get enabled is to start sending action codes instead of function codes for the top row of the keyboard. go/vivaldi-prd go/vivaldi-design go/vivaldi-fw-design With this patch, things remain unchanged for any boards that do not provide board_set_vivaldi_keybd_config(). For boards that do provide it: * EC begins to send action scancodes instead of function scancodes for the top row when top row keys are pressed. * EC responds to an EC command from the coreboot, that asks for the layout for the keyboard. Coreboot uses this to expose corresponding keycodes to the kernel. BUG=b:146501925 TEST=Check on Jinlon the (new) expected scancodes are output from EC. BRANCH=firmware-hatch-12672.B Signed-off-by: Rajat Jain <rajatja@google.com> Change-Id: I1f45ce6eee138a984f8d4caef1ec76c9538dd30b Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2135566
* TCPMv2: Revamp pe_attempt_port_discoveryDiana Z2020-04-171-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Revamps pe_attempt_port_discovery to be called from the ready run states, try once to be DFP and Vconn source, and moves timer check and discovery calls into this function. Note that nDiscoverIdentityCount and DiscoverIdentityTimer are only applicable to cable plugs, though here the discover identity timer is also repurposed to space out requests to a BUSY partner. Long term, the policy decisions regarding our data and vconn role will be moved out into their own file in order to support allowing the AP to override EC default policies. BRANCH=None BUG=b:152417977 TEST=on kindred running TCPMv2, ensured we could complete discovery and enter mode DP mode (when applicable) with: - PD 2.0 Apple dongle, with and without external power - PD 2.0 Acer hub - PD 2.0 charger which would DR swap - PD 3.0 Cable Matters hub, with and without external power - PD 3.0 Hoo Too hub, with and without external power Ensured we did not attempt discovery with: - PD 2.0 charger which won't DR swap Signed-off-by: Diana Z <dzigterman@chromium.org> Change-Id: I9c049690a87f3fc0eca3b9d2c85128470cbb2a91 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2130478 Reviewed-by: Jett Rink <jettrink@chromium.org>
* TCPMv2: Configure PE test for alternate modesDiana Z2020-04-163-5/+10
| | | | | | | | | | | | Configures the TCPMv2 PE test to build the alternate mode code. BRANCH=None BUG=None TEST=make -j buildall Signed-off-by: Diana Z <dzigterman@chromium.org> Change-Id: I4cb5824875e2a4b4e93fbae0a4d8762195b987f5 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2137258
* TCPMv2: Add pd console commandSam Hurst2020-04-142-4/+481
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add pd console commands that enables the device to work with PD FAFT. Other pd commands such as bist, vdm and ping will be added in another CL. BUG=b:151481791 BUG=chromium:1021235 BRANCH=none TEST=make -j buildall manual: Verified that system: pd tryscr 0 - did not trysrc pd tryscr 1 - did trysrc pd tryscr 2 - normal trysrc operation pd 0 tx - started as snk pd 0 charger - started as src pd 0 dev 5 - charged at 5V pd 0 dev 12 - charged at 12V pd 0 dev 15 - charged at 15V pd 0 dev 20 - charged at 20V pd 0 disable - pd was disabled pd 0 enable - pd was enabled pd 0 soft - sent soft reset pd 0 hard - sent hard reset pd 0 dualrole off - stayed in src and switched to snk on disconnect pd 0 dualrole on - toggled from snk to src and vice versa pd 0 dualrole sink - was a sink only pd 0 dualrole source - was a source only pd 0 dualrole freeze - stayed in current power role and switched to snk on disconnect pd 0 swap power - initiated a power role swap pd 0 swap vconn - initiated a vconn swap pd 0 swap data - initiated a data role swap Change-Id: Id1542001c0e52d1d5bfbc5b9cb826b9a204e5b2e Signed-off-by: Sam Hurst <shurst@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1962506 Commit-Queue: Denis Brockus <dbrockus@chromium.org> Reviewed-by: Denis Brockus <dbrockus@chromium.org>
* test: add tc_drp testsJett Rink2020-04-031-0/+463
| | | | | | | | | | | | | | Add polarity tests Add try source tests Add no try source test BRANCH=none BUG=b:153071799 TEST=all unit tests pass Signed-off-by: Jett Rink <jettrink@chromium.org> Change-Id: Ib3d8b6afa2e8fdd80642e026deb4322e2c3e1e9b Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2132872
* tcpmv2: move function from TC layer to PEJett Rink2020-04-035-16/+34
| | | | | | | | | | | | | | | | | | | | | - Move pd_ function that belong in PE layer to PE layer. Remove the extra pe_ layer. - Remove unnecessary PE and Vconn ifdef guards in TC layer - Remove unused print_dev_info function - Move host commands in TC layer to host command file - Move RW hash stuff from TC to PE, since this only has to do with VDO (Which is a PE layer thing) - Removed dependency for tc_drp test on usbc_fake as we don't really need it anymore once we don't pull in the PRL and PE layers anymore (based on previously landed CLs) BRANCH=none BUG=b:153071799 TEST=everything still builds and passes tests Change-Id: Id1d1efa291c3525f57bc26af9fddda6ddace1b58 Signed-off-by: Jett Rink <jettrink@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2132871
* test: isolate tc_drp test cases betterJett Rink2020-04-031-14/+17
| | | | | | | | | | | | | | Ensure that state between test cases is getting fully cleared between different test cases BRANCH=none BUG=b:153071799 TEST=child CL pass when commenting various tests out without issue Signed-off-by: Jett Rink <jettrink@chromium.org> Change-Id: I7628d580c5c16bc404694a93ecc2418241d432b9 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2131050 Reviewed-by: LaMont Jones <lamontjones@chromium.org>
* mock: add callback functionality to tcpc mockstabilize-13020.87.B-masterstabilize-13020.67.B-masterstabilize-13020.55.B-masterrelease-R83-13020.B-masterJett Rink2020-04-031-3/+3
| | | | | | | | | | | | | | Also update prints functionality to make tests easier to see what is happening BRANCH=none BUG=b:153071799 TEST=use mock in child CL Change-Id: Ia9cfeeff220e3255e6fc0aa41f0795df3b1920e4 Signed-off-by: Jett Rink <jettrink@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2131049 Commit-Queue: LaMont Jones <lamontjones@chromium.org>
* TCPMv2: Restore PD state after SysjumpSam Hurst2020-04-021-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When a PD explicit contract is negotiated in RO, the contract is maintained while performing a sysjump to RW. This is done by serializing the PD Power, Data, and VCONN Roles, along with the explicit contract flag. After jumping to RW, deserialization is performed by restoring the power roles and setting the explicit contract flag. BUG=b:152350558,b:152027807,b:152967274 BRANCH=none TEST=make -j buildall Manual tests: Used total phase to verify that charging voltage was maintained across sysjump from RO to RW and that DP was reestablished when a dock was used. Tested that Kohaku booted properly without a battery and a charger connected to port 0. This test was repeated with a charger connected to port 1. Signed-off-by: Sam Hurst <shurst@google.com> Change-Id: I349c41f2279e9af9830564d44ac73ad8435f1f80 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2119131 Tested-by: Sam Hurst <shurst@google.com> Reviewed-by: Denis Brockus <dbrockus@chromium.org> Commit-Queue: Denis Brockus <dbrockus@chromium.org>
* cleanup: correct max port count on testJett Rink2020-04-011-1/+1
| | | | | | | | | | | | | | Looking at code, we only test one port, so make the test defines match the test code BRANCH=none BUG=none TEST=all tests pass Change-Id: I0b793425e20678173f3ec52fdcff4567f0b8ccb4 Signed-off-by: Jett Rink <jettrink@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2131047 Reviewed-by: Diana Z <dzigterman@chromium.org>
* config: update TCPMv2 config optionsJett Rink2020-03-274-51/+23
| | | | | | | | | | | | | | | | | | | Reorganize how the TCPMv2 options are used - Update documentation in config.h and bring TCPMv2 items close together - Make the layer defines consistent on how they include compilation units - Update tests to account for how files are included now - Remove unnecessary defines in board.h since they are default on BRANCH=none BUG=none TEST=builds Change-Id: I91fca51648912deef44db23492ecc7775b2e3062 Signed-off-by: Jett Rink <jettrink@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2120063 Reviewed-by: Denis Brockus <dbrockus@chromium.org>
* usb_pd: Move cable communication functions to common fileAyushee2020-03-271-0/+5
| | | | | | | | | | | | | BUG=b:148528713 BRANCH=none TEST=Verified on TCPMV1 and TCPMv2, able to get correct cable characteristics. Change-Id: I812b21c87661952bf4e86acaa194d4b136371594 Signed-off-by: Ayushee <ayushee.shah@intel.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2051628 Reviewed-by: Diana Z <dzigterman@chromium.org> Reviewed-by: Vijay P Hiremath <vijay.p.hiremath@intel.com>
* cleanup: drop the _TYPEC part of USB device configJett Rink2020-03-263-9/+9
| | | | | | | | | | | | | | | | | | | | | | | | | The three USB device configurations describe more than just the Type-C layer, so remove the _TYPEC part within the define. This is also in preparation to change how the usbc build.mk includes files. This was performed with the following commands: $ git grep --name-only CONFIG_USB_TYPEC_DRP_ACC_TRYSRC | xargs perl -i -ple 's/CONFIG_USB_TYPEC_DRP_ACC_TRYSRC/CONFIG_USB_DRP_ACC_TRYSRC/g' $ git grep --name-only CONFIG_USB_TYPEC_CTVPD | xargs perl -i -ple 's/CONFIG_USB_TYPEC_CTVPD/CONFIG_USB_CTVPD/g' $ git grep --name-only CONFIG_USB_TYPEC_VPD | xargs perl -i -ple 's/CONFIG_USB_TYPEC_VPD/CONFIG_USB_VPD/g' BRANCH=none BUG=none TEST=builds Signed-off-by: Jett Rink <jettrink@chromium.org> Change-Id: I4deab784b7c3479cffd3dee7fb3ea3c8a9d6081c Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2121193 Reviewed-by: Denis Brockus <dbrockus@chromium.org> Commit-Queue: Denis Brockus <dbrockus@chromium.org>
* TCPMv2: Not enable PD comm on TX Phy reset if not in a connected stateWai-Hong Tam2020-03-241-6/+9
| | | | | | | | | | | | | | | | | | | | | | | If PD is not in a connected state, the previous approach was to enable PD comm on TX Phy reset and then disable it later (the SM_RUN case in prl_run()). In this short period of time, the TCPC wil respond GoodCRC to the PD message and the PD partner will go forward to the next state that messes up its state machine and causes an unexpected hard reset. We should not enable PD comm if not in a connected state. BRANCH=None BUG=b:151159750 TEST=Tested on Trogdor, with extra patches to fix the DP discovery and separate the Tx and Rx buffers. Unplugged battery and plugged a 20V charger and verified it boot fine, no reboot loop. TEST=Built chocodile_vpdmcu image successfully. TEST=make runtests -j Change-Id: Ic819787f1ec0085abdded3bab8ecbcb813495408 Signed-off-by: Wai-Hong Tam <waihong@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2107882 Reviewed-by: Sam Hurst <shurst@google.com>
* curve25519: Move to third_partyNicolas Boichat2020-03-241-197/+1
| | | | | | | | | | | | | | | | curve25519 comes from boringssl as well, move it to that directory. See git log for which boringssl commit the implementation comes from, and changes that were applied. BRANCH=none BUG=chromium:884905 TEST=make buildall -j, which also include basic tests. Change-Id: I1dee4795009c1e2034a181f6083d1f9445c87d41 Signed-off-by: Nicolas Boichat <drinkcat@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1600946 Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
* TCPMv2: Split PD message buffers into separate TX/RX buffersSam Hurst2020-03-213-26/+27
| | | | | | | | | | | | | | | | | | | | | Use separate buffers for transmit and reception of PD messages. This prevents the potential corruption of PD messages waiting to be transmitted when an unexpected PD message is received BUG=b:150637227 BUG=b:149662829 BRANCH=none TEST=make -j buildall Manual tests: Tested hatch device and powered dock. Used total phase to verify that transmitted messages were not corrupted by unexpected message reception. Change-Id: I12df471f59fb7510e642bb92b769ccbddd79c84f Signed-off-by: Sam Hurst <shurst@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2103253 Reviewed-by: Diana Z <dzigterman@chromium.org>
* common: online_calibration: Fire MKBP event on new calibrationYuval Peress2020-03-092-5/+121
| | | | | | | | | | | | | | Implement online calibration for accelerometers and fire a new MKBP event when a new calibration value is computed. TEST=Added new unit tests BRANCH=None BUG=b:138303429,chromium:1023858 Change-Id: I31ec7164be0d8c7dac210a1ac4b94ec9ecd6a60a Signed-off-by: Yuval Peress <peress@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2012847 Reviewed-by: Jack Rosenthal <jrosenth@chromium.org>
* remove cr50 related filesNamyoon Woo2020-03-098-3057/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | BUG=b:149350081 BRANCH=none TEST=build all, and emerged ec related packages for host and octopus. $ make buildall -j $ cros_workon --host list chromeos-base/chromeos-cr50-dev chromeos-base/chromeos-ec chromeos-base/chromeos-ec-headers chromeos-base/ec-devutils chromeos-base/ec-utils chromeos-base/ec-utils-test dev-util/hdctools $ sudo emerge chromeos-cr50-dev -j $ sudo emerge chromeos-ec -j $ sudo emerge chromeos-ec-headers -j $ sudo emerge ec-devutils -j $ sudo emerge ec-utils -j $ sudo emerge ec-utils-test -j $ sudo emerge hdctools -j $ cros_workon-octopus list chromeos-base/chromeos-ec chromeos-base/chromeos-ec-headers chromeos-base/ec-devutils chromeos-base/ec-utils chromeos-base/ec-utils-test dev-util/hdctools $ sudo emerge-octopus chromeos-ec -j $ sudo emerge-octopus chromeos-ec-headers -j $ sudo emerge-octopus ec-devutils -j $ sudo emerge-octopus ec-utils -j $ sudo emerge-octopus ec-utils-test -j $ sudo emerge-octopus hdctools -j Signed-off-by: Namyoon Woo <namyoon@chromium.org> Change-Id: If751b26b0635b0021c077338e96eaa8e8dcf17a5 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2080631 Reviewed-by: Edward Hill <ecgh@chromium.org> Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
* remove board/cr50 and chip/gNamyoon Woo2020-03-0335-5752/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch removes cr50 related files from platform/ec. BUG=b:149350081 BRANCH=none TEST=$ make buildall -j $ cros_workon --host list chromeos-base/chromeos-cr50-dev chromeos-base/chromeos-ec chromeos-base/chromeos-ec-headers chromeos-base/ec-devutils chromeos-base/ec-utils chromeos-base/ec-utils-test dev-util/hdctools $ sudo emerge chromeos-cr50-dev -j $ sudo emerge chromeos-ec -j $ sudo emerge chromeos-ec-headers -j $ sudo emerge ec-devutils -j $ sudo emerge ec-utils -j $ sudo emerge ec-utils-test -j $ sudo emerge hdctools -j $ cros_workon-octopus list chromeos-base/chromeos-ec chromeos-base/chromeos-ec-headers chromeos-base/ec-devutils chromeos-base/ec-utils chromeos-base/ec-utils-test dev-util/hdctools $ sudo emerge-octopus chromeos-ec -j $ sudo emerge-octopus chromeos-ec-headers -j $ sudo emerge-octopus ec-devutils -j $ sudo emerge-octopus ec-utils -j $ sudo emerge-octopus ec-utils-test -j $ sudo emerge-octopus hdctools -j Signed-off-by: Namyoon Woo <namyoon@chromium.org> Change-Id: Ifa3a037fff17177204ce1a9b88474490fb9be3ed Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2083659 Reviewed-by: Vadim Bendebury <vbendeb@chromium.org> Reviewed-by: Denis Brockus <dbrockus@chromium.org>
* usb_mux: retimer: mux as chained mux and retimerDenis Brockus2020-02-282-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This makes retimers appear as generic muxes. By allowing a chain of muxes they can be stacked up to the new configurations that zork requires and will continue to work as they did before on configurations that only have a single mux. The code used to have two different arrays, 1) muxes and 2) retimers. On one of the zork configurations the processor MUX stopped being the primary mux and the retimer took its place. In a different configuration of that same platform it left the primary and secondary alone but the mux_set FLIP operation had to be ignored. Since the same interfaces needed to be available for both it stopped making sense to have two different structures and two different methods of handling them. This consolodates the two into one. The platforms that do not have retimers, this change will not make any difference. For platforms like zork, it will remove the retimers and make them chained muxes. So testing on trembyle makes sense to verify, BUG=b:147593660 BRANCH=none TEST=verify USB still works on trembyle Change-Id: I286cf1e302f9bd3dd7e81098ec08514a2a009fe3 Signed-off-by: Denis Brockus <dbrockus@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2066794 Commit-Queue: Jett Rink <jettrink@chromium.org> Reviewed-by: Edward Hill <ecgh@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org>
* common/system: Unify ec_current_image and system_image_copy_tTom Hughes2020-02-283-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | "enum ec_current_image" is exposed in ec_commands.h (and used by non-EC code, such as biod). We also have an "enum system_image_copy_t" that is the exact same thing (though has a few more definitions). A followup CL (I714b6bd8c0d7192386404c25a831e38438fa5238) adds the "sysinfo" host command, so we want to be able to expose all the potential image variants. Rather than maintain two enums that can potentially get out of sync, unify the code to use a single enum. We choose to keep the "enum ec_current_image", since external code depends on it. To verify that this change results in no changes to the generated binaries: ./util/compare_build.sh --board all BRANCH=none BUG=b:146447208 TEST=./util/compare_build.sh --board=all Change-Id: I13776bc3fd6e6ad635980476a35571c52b1767ac Signed-off-by: Tom Hughes <tomhughes@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2036599 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-by: Namyoon Woo <namyoon@chromium.org>
* TCPMV1/2: Make the PD Config Flags more consistentSam Hurst2020-02-221-8/+11
| | | | | | | | | | | | | | | | | | | | The current use of the PD Config Flags are a bit confusing and has been changed to the following: The CONFIG_USB_POWER_DELIVERY flag is used to enable and disable the TCPMv1 and TCPMv2 stacks. And when CONFIG_USB_POWER_DELIVERY is enabled, one of the following must be enabled: CONFIG_USB_PD_TCPMV1 - legacy power delivery state machine CONFIG_USB_PD_TCPMV2 - current power delivery state machine BUG=b:149993808 BRANCH=none TEST=make -j buildall Change-Id: Ie3f8615a75b15b4f1c703f57f3db9e152a471238 Signed-off-by: Sam Hurst <shurst@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2068519 Reviewed-by: Diana Z <dzigterman@chromium.org>
* common: motion_sense_fifo: fix iteration bugYuval Peress2020-02-141-0/+30
| | | | | | | | | | | | | | | Fix potential bug when iterating over FIFO entries for commit. This bug can manifest when non-timestamp/non-data entries are inserted into the FIFO. TEST=Added unit tests BRANCH=None BUG=b:138303429,chromium:1023858 Change-Id: I64855db2141f7ad6aafb3f3a84632a1dabef11f4 Signed-off-by: Yuval Peress <peress@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2012846 Reviewed-by: Gwendal Grignou <gwendal@chromium.org>
* common: Migrate online calibration to own moduleYuval Peress2020-02-135-100/+166
| | | | | | | | | | | | | | | This change moves the code that handles caching the temperature (which is the first step in online calibration) into a new compilational unit. TEST=None BRANCH=None BUG=b:138303429,chromium:1023858 Change-Id: Ib1fe3d2234dc2436e2bbfd4febd22196e5cdafef Signed-off-by: Yuval Peress <peress@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1906340 Reviewed-by: Jack Rosenthal <jrosenth@chromium.org>
* TCPMv1/v2: Move pd_process_source_cap() to common fileVijay Hiremath2020-02-121-0/+14
| | | | | | | | | | | BUG=b:148528713 BRANCH=none TEST=make buildall -j Change-Id: I6bd6b5875a322ca4ba6d77a4cfc96a72630e5f5c Signed-off-by: Vijay Hiremath <vijay.p.hiremath@intel.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2051220 Reviewed-by: Keith Short <keithshort@chromium.org>
* TCPMv1/v2: Move pd_set_vbus_discharge() to common fileVijay Hiremath2020-02-121-0/+5
| | | | | | | | | | | BUG=b:148528713 BRANCH=none TEST=make buildall -j Change-Id: Id7b0d10396300c4bd5b8253b7ce77c1fe59c9bc8 Signed-off-by: Vijay Hiremath <vijay.p.hiremath@intel.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2051216 Reviewed-by: Keith Short <keithshort@chromium.org>
* fuzz: remove cr50 or TPM2 library related tests from fuzz and testNamyoon Woo2020-02-124-1964/+0
| | | | | | | | | | | | | | | | | | This patch removes cr50 or TPM2 related test cases from fuzz and test directory, so that buildall or chromeos-ec package won't check them. Those test cases are already moved to cr50_stab branch. BUG=b:149243259 BRANCH=none TEST=ran 'make buildall -j' and 'sudo 'FEATURES=test' 'PKGDIR=/build/eve/test-packages' \ -- /mnt/host/source/chromite/bin/parallel_emerge \ '--sysroot=/build/eve' '--jobs=10' chromeos-ec Change-Id: Ie6f7c8622fe3e488758a814dc99ddf4587ffd973 Signed-off-by: Namyoon Woo <namyoon@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2047935 Reviewed-by: Allen Webb <allenwebb@google.com>
* cleanup: add comments for MT flag useJett Rink2020-02-111-0/+1
| | | | | | | | | | | | | Document why we need the MT flag as a compiler option BRANCH=none BUG=none TEST=builds Change-Id: Id6bceacc3b0af110f79d9f727ded595950fa2afb Signed-off-by: Jett Rink <jettrink@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2044358 Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
* common: Implement accelerometer calibrationYuval Peress2020-02-084-1/+159
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | This change implements the hybrid accelerometer calibration algorithm described in https://drive.google.com/corp/drive/u/0/folders/13k8AWvVkCg8KUr1HhD2qv6_ob1ixgCbE 1. Waits until the device is still 2. Adds a still sample to an orientation accumulator - If the new sample is close to an existing one, they're merged. - If the new sample is unique, it is added to the list of orientations in a FIFO manner (may be evicting an older sample). - Once enough orientations have been gathered, run the kasa algorithm. - The kasa algorithm should yield a radius that's near 1g, since all the samples were added when still. If this isn't the case, we fall back on newton's method (which takes longer). BUG=b:138303429,chromium:1023858 BRANCH=None TEST=buildall with new unit tests Change-Id: I98bb0d365017d8a916b008c7c0c263345a9cddac Signed-off-by: Yuval Peress <peress@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1879716 Reviewed-by: Gwendal Grignou <gwendal@chromium.org>
* fpsensor: Refactor fpsensor tests into separate binariesTom Hughes2020-02-0710-807/+836
| | | | | | | | | | | | | | | | | | | | | | | Using separate test binaries helps to prevent state from one set of tests accidentally leaking into other tests. Ideally all unit tests should be completely independent. Since there's a lot of global state in the fpsensor code the separate test binaries should help prevent the state from leaking across tests as we continue to add more. Also, by having a 1:1 correspondence between test binaries and test files, it's clearer what file (and functionality) each set of tests is targeting. BRANCH=none BUG=none TEST=make buildall -j Change-Id: I937a5ffebfe61aa711efbbc2467d15d514fcfbae Signed-off-by: Tom Hughes <tomhughes@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1832748 Commit-Queue: Yicheng Li <yichengli@chromium.org> Tested-by: Yicheng Li <yichengli@chromium.org> Reviewed-by: Yicheng Li <yichengli@chromium.org>
* Makefile: enforce target name in generated dependenciesVadim Bendebury2020-02-071-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | There seems to be some odd interaction between ccache version 3.7.6 and the set of command line options passed to gcc by the EC makefile, as a result the generated dependency files are wrong, the target file name is missing the path. The -MT command line option makes sure that the correct target file name is generated. Had to make similar changes in ../../third_party/{cryptoc,tpm2} Makefiles. No need to change extra/usb_updater/Makefile as it puts .o files in the same directory where .c files are. BRANCH=all BUG=b:148943341 TEST=verified that relevant object files are rebuilt when an .h file is touched. Also, with companion changes in cryptoc and tpm2 trees verified that all generated my 'make buildall' .d files have proper target values (including path), apart froom files in extra/usb_udater, which place .o files in the same directory with .c files. Change-Id: I22dfad94c112582230a2b6b60289e029a382d822 Signed-off-by: Vadim Bendebury <vbendeb@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2039988 Reviewed-by: Paul Fagerburg <pfagerburg@chromium.org> Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
* common: Implement newton sphere fitYuval Peress2020-02-064-0/+156
| | | | | | | | | | | | | Add implementation of Newton's method for sphere fitting. BUG=b:137758297,chromium:1023858 TEST=Added new unit tests BRANCH=None Change-Id: Ic78ec4f8a8c2f57ddfa1d5220861bf5c06981ad8 Signed-off-by: Yuval Peress <peress@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1869730 Reviewed-by: Jack Rosenthal <jrosenth@chromium.org>
* common: queue: Add ability to iterate over queueYuval Peress2020-02-051-20/+97
| | | | | | | | | | | | | | | | | | This is done via: * queue_begin(q) gets an iterator to the start of the list * queue_next(q, &it) updates the iterator to the next element ** Once the iterator reaches the end, ptr will be NULL. ** If the queue was modified between the _begin and _next calls queue_next will terminate the iterator (set the ptr to NULL). BUG=None TEST=New unit tests BRANCH=None Change-Id: I643f544ed91bafac8e8b4c85545d4070f2d82610 Signed-off-by: Yuval Peress <peress@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1879715 Reviewed-by: Jack Rosenthal <jrosenth@chromium.org>
* common: mag_cal: Re-add bias inversionGwendal Grignou2020-02-041-6/+6
| | | | | | | | | | | | | | | | | | | Sensors add offset to raw value. kaza_compute calculate the bias (the hard iron) and it has to be remove from the raw value. Invert the vector in magnetometer calibration code. Fixes: 994af4a65fa7e ("common: mag_cal: update magnetometer to leverage kasa") BUG=b:144027014 BRANCH=none TEST=Check that after successful online calibration, value reported to the host are closer to 0 than before calibration. Change-Id: I6cfd711c82287b1c877912e85d84d2725b063cb2 Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2034675 Reviewed-by: Yuval Peress <peress@chromium.org>
* test: add repeating deferred testJett Rink2020-01-311-0/+26
| | | | | | | | | | | | | | | Adding simple unit test that ensures that a deferred call can call itself and won't repeat forever. I thought this might be a problem, but it wasn't. We might as well add this code as a unit test. BRANCH=none BUG=none TEST=test passes Change-Id: Ie9791606e4a401821594df122481f22d87eadbbd Signed-off-by: Jett Rink <jettrink@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2025073 Reviewed-by: Diana Z <dzigterman@chromium.org>
* TCPMv1/v2: Move EC_CMD_USB_PD_CONTROL host command to common fileVijay Hiremath2020-01-301-0/+66
| | | | | | | | | | | BUG=b:142911453 BRANCH=none TEST=make buildall -j Change-Id: Iadb75b9b187a0444c445c2641ec71d592cf4ac92 Signed-off-by: Vijay Hiremath <vijay.p.hiremath@intel.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2013228 Reviewed-by: Keith Short <keithshort@chromium.org>
* common: mag_cal: update magnetometer to leverage kasaYuval Peress2020-01-284-0/+107
| | | | | | | | | | | | | | | Update magnetometer calibration algorithm to leverage the new kasa standalone code. BUG=b:138303429,chromium:1023858 TEST=added unit test BRANCH=None Change-Id: I5c0403b66d9fe7c2925b2ec6244cf9e32ad5ea5f Signed-off-by: Yuval Peress <peress@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1931464 Reviewed-by: Jack Rosenthal <jrosenth@chromium.org> Reviewed-by: Gwendal Grignou <gwendal@chromium.org>
* usb_mux: cleanup: Replace mux state enums with ec_command bit flagVijay Hiremath2020-01-282-4/+11
| | | | | | | | | | | BUG=b:145796172 BRANCH=none TEST=make buildall -j Change-Id: Ie4ffaf208745764262931501f0dff77b525a4e59 Signed-off-by: Vijay Hiremath <vijay.p.hiremath@intel.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2017569 Reviewed-by: Jett Rink <jettrink@chromium.org>
* TCPMv1/v2: Move EC_CMD_USB_PD_DEV_INFO host command to common fileVijay Hiremath2020-01-241-0/+5
| | | | | | | | | | | BUG=b:142911453 BRANCH=none TEST=make buildall -j Change-Id: If9d902ef77da7d56a123c0c78b1ebbcd0d95bc3b Signed-off-by: Vijay Hiremath <vijay.p.hiremath@intel.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2008301 Reviewed-by: Keith Short <keithshort@chromium.org>
* TCPMv1/v2: Move EC_CMD_PD_CHIP_INFO host command to common fileVijay Hiremath2020-01-241-0/+2
| | | | | | | | | | | BUG=b:142911453 BRANCH=none TEST=make buildall -j Change-Id: Ia858db061811c58a14b2525d17d6abdc35ea6fa7 Signed-off-by: Vijay Hiremath <vijay.p.hiremath@intel.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2008299 Reviewed-by: Keith Short <keithshort@chromium.org>
* common: Implement kasa sphere fit algorithmYuval Peress2020-01-214-0/+90
| | | | | | | | | | | | | | Add an implementation of the kasa sphere fit algorithm adapted from AOSP. BUG=b:138303429,chromium:1023858 TEST=Added unit tests BRANCH=None Change-Id: I8194bfaddbb7c57a2b20a1917c91f7c78707e685 Signed-off-by: Yuval Peress <peress@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1867226 Reviewed-by: Jack Rosenthal <jrosenth@chromium.org>
* aes: Enforce alignment of static arrayYicheng Li2020-01-171-2/+2
| | | | | | | | | | | | | | | | | | | | When building on-device unit test binaries, the static array in test/aes.c were not address-aligned after being linked into the final binary. This causes "runtest" to emit an exception on device as the MCU tries to load from the address of the static array which is unaligned address. Enforce alignment to avoid the error. BRANCH=nocturne BUG=b:146059307 TEST=make BOARD=nucleo-h743zi tests -j # Flash build/nucleo-h743zi/test-aes.bin # Connect to UARD console runtest Change-Id: I91e8523fa0f13bf89baa609cded36e111e466972 Signed-off-by: Yicheng Li <yichengli@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2006708 Reviewed-by: Nicolas Boichat <drinkcat@chromium.org>
* TCPMv1 & TCPMv2: Move common functions to common codeVijay Hiremath2020-01-141-0/+5
| | | | | | | | | | | BUG=b:147249926, b:146623068 BRANCH=none TEST=make buildall -j Change-Id: Ibb24bdad4e9ec24b02106c05ca5fe51269efcb1c Signed-off-by: Vijay Hiremath <vijay.p.hiremath@intel.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1990425 Reviewed-by: Denis Brockus <dbrockus@chromium.org>
* common: motion_sense_fifo: Read temperature on stageYuval Peress2020-01-112-40/+120
| | | | | | | | | | | | | | | | Assuming online calibration is enabled, and the driver implements the get_temp function. When a driver stages data, if this is the first staged sample, read the current internal sensor temperature and cache it (will later be used in commit_data()). BUG=b:138303429,chromium:1023858 BRANCH=None TEST=buildall Change-Id: I8e5404e628d3e8ded7c2d75b1b5cbac8166e97aa Signed-off-by: Yuval Peress <peress@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1867225 Reviewed-by: Jack Rosenthal <jrosenth@chromium.org>
* pd: use pd_get_[power/data]_role instead of the tc versionDenis Brockus2020-01-102-9/+4
| | | | | | | | | | | | | | the tc versions were doing the same thing as the pd version so removed the duplication BUG=b:147290482,b:147314832 BRANCH=none TEST=make buildall -j Signed-off-by: Denis Brockus <dbrockus@chromium.org> Change-Id: Iaa48dcd65e3a6c325b0ae2cca33e629fec6e33c9 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1993861 Reviewed-by: Edward Hill <ecgh@chromium.org>
* pd: cleanup pd_get_roleDenis Brockus2020-01-092-17/+17
| | | | | | | | | | | | | | | | | | pd_get_role in the TCPMv1 stack meant pd_get_power_role. pd_get_role in the TCPMv2 stack meant pd_get_data_role. This CL will clean that up and make them the correct naming. pd_get_power_role will also return an enum pd_power_role type instead of an int. BUG=b:147290482 BRANCH=none TEST=make buildall -j Change-Id: I73ee465401ccd050c2bd151f2fc043a59d95e079 Signed-off-by: Denis Brockus <dbrockus@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1991844 Reviewed-by: Jett Rink <jettrink@chromium.org>