summaryrefslogtreecommitdiff
path: root/common
Commit message (Collapse)AuthorAgeFilesLines
* fpsensor: Build fpsensor source file with C++Tom Hughes2022-09-081-9/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This change removes abs() since this change also makes the fingerprint firmware link against the toolchain's C standard library, which already provides an implementation. Note that abs() is not actually used by the FPC matching algorithm even though it links against it. BRANCH=none BUG=b:236025198, b:234181908 TEST=On dragonclaw v0.2 with servo_micro and J-Trace attached: ./util/flash_jlink.py -b bloonchipper -i ./build/bloonchipper/ec.bin > fpenroll > fpmatch TEST=On dragonclaw v0.2 with servo_micro and J-Trace attached: ./test/run_device_tests.py --board bloonchipper Test "aes": PASSED Test "cec": PASSED Test "cortexm_fpu": PASSED Test "crc": PASSED Test "flash_physical": PASSED Test "flash_write_protect": PASSED Test "fpsensor_hw": PASSED Test "fpsensor_spi_ro": PASSED Test "fpsensor_spi_rw": PASSED Test "fpsensor_uart_ro": PASSED Test "fpsensor_uart_rw": PASSED Test "mpu_ro": PASSED Test "mpu_rw": PASSED Test "mutex": PASSED Test "pingpong": PASSED Test "printf": PASSED Test "queue": PASSED Test "rollback_region0": PASSED Test "rollback_region1": PASSED Test "rollback_entropy": PASSED Test "rtc": PASSED Test "sha256": PASSED Test "sha256_unrolled": PASSED Test "static_if": PASSED Test "stdlib": PASSED Test "system_is_locked_wp_on": PASSED Test "system_is_locked_wp_off": PASSED Test "timer_dos": PASSED Test "utils": PASSED Test "utils_str": PASSED Test "stm32f_rtc": PASSED Test "panic_data_bloonchipper_v2.0.4277": PASSED Test "panic_data_bloonchipper_v2.0.5938": PASSED TEST=On icetower v0.1 with servo_micro and J-Trace attached: ./util/flash_jlink.py -b dartmonkey -i ./build/dartmonkey/ec.bin > fpenroll > fpmatch TEST=On icetower v0.1 with servo_micro and J-Trace attached: ./test/run_device_tests.py --board dartmonkey Test "aes": PASSED Test "cec": PASSED Test "cortexm_fpu": PASSED Test "crc": PASSED Test "flash_physical": PASSED Test "flash_write_protect": PASSED Test "fpsensor_hw": PASSED Test "fpsensor_spi_ro": PASSED Test "fpsensor_spi_rw": PASSED Test "fpsensor_uart_ro": PASSED Test "fpsensor_uart_rw": PASSED Test "mpu_ro": PASSED Test "mpu_rw": PASSED Test "mutex": PASSED Test "pingpong": PASSED Test "printf": PASSED Test "queue": PASSED Test "rollback_region0": PASSED Test "rollback_region1": PASSED Test "rollback_entropy": PASSED Test "rtc": PASSED Test "sha256": PASSED Test "sha256_unrolled": PASSED Test "static_if": PASSED Test "stdlib": PASSED Test "system_is_locked_wp_on": PASSED Test "system_is_locked_wp_off": PASSED Test "timer_dos": PASSED Test "utils": PASSED Test "utils_str": PASSED Test "panic_data_dartmonkey_v2.0.2887": PASSED Test "panic_data_nocturne_fp_v2.2.64": PASSED Test "panic_data_nami_fp_v2.2.144": PASSED Signed-off-by: Tom Hughes <tomhughes@chromium.org> Change-Id: Iab0de3355cbe928c7b7132263ea6d32c1e9f3a6e Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3551682 Reviewed-by: Bobby Casey <bobbycasey@google.com> Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com> Reviewed-by: Andrea Grandi <agrandi@google.com>
* fpsensor: Fix g++ compiler errorTom Hughes2022-09-081-1/+5
| | | | | | | | | | | | | | | | | | | | | | When compiling the host tests, g++ warns about the following: common/fpsensor/fpsensor.cc:491:25: error: comparison of integer expressions of different signedness: 'uint32_t' {aka 'unsigned int'} and 'int8_t' {aka 'signed char'} [-Werror=sign-compare] 491 | if (fgr == template_newly_enrolled) { | ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~ BRANCH=none BUG=b:234181908, b:244781166 TEST=make host-fpsensor_crypto TEST=./util/compare_build.sh -b fp -j 120 => MATCH Signed-off-by: Tom Hughes <tomhughes@chromium.org> Change-Id: Ida17f6c123f6d73589774dd16ba60d0d54a8ee17 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3689786 Reviewed-by: Bobby Casey <bobbycasey@google.com> Reviewed-by: Andrea Grandi <agrandi@google.com>
* zephyr: tests: Test command `ksstate` in `common/keyboard_scan.c`Tristan Honscheid2022-09-081-1/+13
| | | | | | | | | | | | | | | Add coverage for the `ksstate` console command BRANCH=None BUG=b:244606945 TEST=./twister Signed-off-by: Tristan Honscheid <honscheid@google.com> Change-Id: I1dbb754d1a357d162baee1bb909b37b7321b5c4c Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3872725 Reviewed-by: Simon Glass <sjg@chromium.org> Commit-Queue: Simon Glass <sjg@chromium.org> Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com>
* test: Verify sysinfo console_cmdAaron Massey2022-09-081-0/+1
| | | | | | | | | | | | | | | Verify the sysinfo console command may be invocated and that it prints system information, especially whether the system is locked or not. BRANCH=none BUG=b:245605079 TEST=twister -s zephyr/test/drivers/drivers.default Signed-off-by: Aaron Massey <aaronmassey@google.com> Change-Id: I0b32248c0f23906e7ef75d513a8b77663746ef6f Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3880669 Reviewed-by: Tristan Honscheid <honscheid@google.com> Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com>
* ec: Suppress new recursion warning in gcc 12Jeremy Bettis2022-09-081-0/+7
| | | | | | | | | | | | | | | | | | GCC 12 implemented -Winfinite-recursion so suppress that just like in clang. BRANCH=None BUG=None TEST=Not yet Signed-off-by: Jeremy Bettis <jbettis@google.com> Change-Id: I460a78043069f8a1e0d29cf5037559c95bd84c40 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3880534 Auto-Submit: Jeremy Bettis <jbettis@chromium.org> Commit-Queue: Jeremy Bettis <jbettis@chromium.org> Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com> Reviewed-by: Jack Rosenthal <jrosenth@chromium.org> Tested-by: Jeremy Bettis <jbettis@chromium.org>
* charger: support the charger without batteryZhuohao Lee2022-09-082-3/+8
| | | | | | | | | | | | | | | | | | | | | | In order to support the HW design with charger but doesn't include the a battery, we exclude the charge_state_v2.c if we define the CONFIG_CHARGER but not define the CONFIG_BATTERY. Besides, we also implement some default functions to avoid the link error. Note: remove the charge_prevent_power_on from the board.c of rainier/mchpevb1 and use the default function. BUG=b:242949656 BRANCH=none TEST=build pass with 1. CONFIG_CHARGER + CONFIG_BATTERY 2. CONFIG_CHARGER + no CONFIG_BATTERY 3. make buildall Change-Id: I32c9b03aaf87b641af2b337db1f3bae838464a41 Signed-off-by: Zhuohao Lee <zhuohao@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3865186 Reviewed-by: Diana Z <dzigterman@chromium.org> Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com>
* lid: Only change the lid state when forcing openAndrew McRae2022-09-071-1/+3
| | | | | | | | | | | | | | | | | | | Force the lid state only when it is being changed. When the system starts, it always sends a message to disable the forced lid open. However if the EC command lidclose has been run, disabling the forced lid open will read the actual lid status from the GPIO, possibly overriding the state set by lidclose. BUG=b:244082750 TEST=Pass firmware.ECLidSwitch.close_lid_to_shutdown BRANCH=none Signed-off-by: Andrew McRae <amcrae@google.com> Change-Id: I10595e45e5055422c1c8ce66d8271c96749848ea Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3877883 Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com> Reviewed-by: Peter Marheine <pmarheine@chromium.org>
* zephyr: test keyboard_mkbp host commandsAl Semjonovs2022-09-061-1/+1
| | | | | | | | | | | | | | Add host command tests for keyboard_mkbp.c BUG=b:244438600, b:244438560 BRANCH=NONE TEST=./twister -T zephyr/test Signed-off-by: Al Semjonovs <asemjonovs@google.com> Change-Id: I45ea83a28e58798ecc14b86e8725ee9a8a2297c4 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3868519 Reviewed-by: Yuval Peress <peress@google.com> Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com>
* fpsensor: Fix fp_set_sensor_mode return typeTom Hughes2022-09-061-2/+2
| | | | | | | | | | | | | The function returns "enum ec_status". BRANCH=none BUG=b:234181908 TEST=make buildall Signed-off-by: Tom Hughes <tomhughes@chromium.org> Change-Id: Ieca34f7209d770692382baefed7131a2d43922d0 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3872807 Reviewed-by: Bobby Casey <bobbycasey@google.com>
* fpsensor: Remove nested designators for C++ compatibilityTom Hughes2022-09-061-5/+6
| | | | | | | | | | | | | | | | | | When compiling these files as C++, a warning is emitted: nested designators are a C99 extension [-Werror,-Wc99-designator] .deadline.val = 0, ^~~~~~~~~~~~~ BRANCH=none BUG=b:234181908 TEST=./util/compare_build.sh -b fp => MATCH Signed-off-by: Tom Hughes <tomhughes@chromium.org> Change-Id: I68945ee33290d4416cf1b948cdb6e5e90c7da34b Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3872808 Reviewed-by: Bobby Casey <bobbycasey@google.com>
* test: Add tests for the powerbtn commandfirmware-ti50-mp-15090.B-mainNehemiah Dureus2022-09-021-2/+2
| | | | | | | | | | | | | | | | | As part of ensuring the test passes, the powerbtn command now errors on negative millisecond inputs. BRANCH=none BUG=b:236074627 TEST=zmake test test-drivers Signed-off-by: Nehemiah Dureus <ndureus@chromium.org> Change-Id: Ib257b101a2c909064b350a905006b25d2c85e0f0 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3860409 Reviewed-by: Yuval Peress <peress@google.com> Reviewed-by: Aseda Aboagye <aaboagye@chromium.org> Reviewed-by: Tomasz Michalec <tmichalec@google.com> Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com>
* tree-wide: const-ify argv for console commandsCaveh Jalali2022-09-0182-167/+168
| | | | | | | | | | | | | | | | | | | | | | | This updates the API for console commands from "int cmd(int argc, char **argv)" to "int cmd(int argc, const char **argv)" which is more accurate and in line with common convention. BRANCH=none BUG=b:244387210 TEST="make buildall" passes TEST="zmake build -a" passes TEST="util/compare_build.sh -b all" passes TEST="./twister -v -T zephyr/test" passes Cq-Depend: chrome-internal:4960125 Cq-Depend: chrome-internal:4959932 Change-Id: I57de9f35b85b8f3c7119df36aefb2abf25d2625f Signed-off-by: Caveh Jalali <caveh@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3863941 Reviewed-by: Aseda Aboagye <aaboagye@chromium.org> Reviewed-by: Tom Hughes <tomhughes@chromium.org> Reviewed-by: Keith Short <keithshort@chromium.org>
* zephyr: test: Test `dps` console command in `common/dps.c`Tristan Honscheid2022-09-011-0/+19
| | | | | | | | | | | | | Test the `dps` console command BRANCH=None BUG=None TEST=./twister Signed-off-by: Tristan Honscheid <honscheid@google.com> Change-Id: I89cbbf8658a6fbb25782e37048a3fa75d77e4fee Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3867045 Reviewed-by: Al Semjonovs <asemjonovs@google.com>
* battery: print gauge C-FET statusEric Yilun Lin2022-09-011-0/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | BUG=b:240883830 TEST=ec:~$ battery Status: 0x00e0 FULL DCHG INIT Param flags:00000002 Temp: 0x0bac = 298.8 K (25.7 C) V: 0x32e7 = 13031 mV V-desired: 0x0000 = 0 mV I: 0x0000 = 0 mA I-desired: 0x0000 = 0 mA Charging: Not Allowed Charge: 100 % Display: 100.0 % Manuf: COSMX Device: L22X3PG0 Chem: LiP Serial: 0x00bc V-design: 0x2c2e = 11310 mV Mode: 0x6020 Abs charge:100 % Remaining: 4152 mAh Cap-full: 4156 mAh Design: 4156 mAh Time-full: 0h:0 Empty: 0h:0 full_factor:0.97 shutdown_soc:4 % C-FET: 0 BRANCH=none Change-Id: Icbd8b357b608bf014f8670614fd3755a47b6d535 Signed-off-by: Eric Yilun Lin <yllin@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3855650 Tested-by: Eric Yilun Lin <yllin@google.com> Commit-Queue: Eric Yilun Lin <yllin@google.com> Reviewed-by: Ting Shen <phoenixshen@chromium.org> Auto-Submit: Eric Yilun Lin <yllin@google.com>
* common: Not sleep 500ms when already left safe modeDavid Huang2022-09-012-15/+15
| | | | | | | | | | | | | | | | | Don not sleep 500ms when ec already left safe mode. BUG=b:226259582 BRANCH=main TEST=Check get battery info don't have 500ms delay in console. Signed-off-by: David Huang <david.huang@quanta.corp-partner.google.com> Change-Id: I740b49e654047800936086a9de33a87c7c46a300 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3853307 Commit-Queue: David Huang <david.huang@quanta.corp-partner.google.com> Tested-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-by: Aseda Aboagye <aaboagye@chromium.org> Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com>
* usb_common: Move HPD Wake MKBP Source to TCPMv1/TCPMv2 common fileJameson Thies2022-09-012-9/+9
| | | | | | | | | | | | | | | | | | | | MKBP sources are declared using DECLARE_EVENT_SOURCE. For the EC_MKBP_EVENT_DP_ALT_MODE_ENTERED MKBP event, the source is only declared in usb_pd_policy.c, which is a TCPMv1 file. For boards using TCPMv2, the source is never declared causing mkbp_get_next_event in mkbp_event.c to return EC_RES_ERROR (0x2). This CL will move the EC_MKBP_EVENT_DP_ALT_MODE_ENTERED MKBP event source declaration to usb_common.c so that it exists in both TCPMv1 and TCPMv2. BUG=b:220875780 TEST=make try_builds_boards. make runhosttests. Triggered HPD wake event on a TCPMv2 device and received no "HC 0x0067 err 2" message. BRANCH=None Signed-off-by: Jameson Thies <jthies@google.com> Change-Id: Ib873b0b68fcf3bd1a191583d694bd6209d7205f2 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3866153 Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
* test: Add basic tests exercising the panic output APIYuval Peress2022-08-311-1/+1
| | | | | | | | | | | | | | | | | Exercise some of the panic output API. Some of the basic printing API cannot yet be fully tested. But a fix upstream is coming to allow us to use the 'console' harness features to parse the output log and pass/fail the test based on output. BRANCH=none BUG=none TEST=twister -s zephyr/test/drivers/drivers.default Signed-off-by: Yuval Peress <peress@google.com> Change-Id: I8e56e8bcdaa0e095891c38a26e56ced8f3a8d4d0 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3855593 Reviewed-by: Simon Glass <sjg@chromium.org> Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com>
* test: Add test for get ikm failure when seed not setFiras Sammoura2022-08-301-1/+1
| | | | | | | | | | | | | | | | | | Add a test for get_ikm when the fp tpm seed is not set. Change the declaration of get_ikm function inside fpsensor_crypto.c to test_export_static such that it can be visible in the test library. Declare get_ikm as an extern function inside the test/fpsensor_crypto.c file. BRANCH=None BUG=b:242720240 TEST=make run-fpsensor_crypto TEST=make runhosttests Signed-off-by: Firas Sammoura <fsammoura@google.com> Change-Id: Ibd4993bbeb6e8d166b3d0307fd1b3c90c55cc264 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3862148 Reviewed-by: Bobby Casey <bobbycasey@google.com>
* test: Add test for fpsensor trivial key failureBobby Casey2022-08-303-2/+68
| | | | | | | | | | | | | | | | | | | Add a test for derive_positive_match_secret when compute_hmac_sha256 returns a trivial key (either 0x00 or 0xFF). This required mocking compute_hmac_sha256 to get the proper test behavior. Since other tests depend upon a proper SHA256 hash to be generated, either all key/message combinations would need to be mocked or some calls to compute_hmac_sha256 need to be passed through to hmac_SHA256. The latter option was chosen for the best flexibility moving forward. BRANCH=none BUG=b:242720910 TEST=make runhosttests Signed-off-by: Bobby Casey <bobbycasey@google.com> Change-Id: I959e23cfadb5460e62af90ffba74a0cd3b9d9a7f Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3838935 Reviewed-by: Tom Hughes <tomhughes@chromium.org>
* fpsensor_crypto: Abstract calls to hmac_SHA256Bobby Casey2022-08-301-4/+10
| | | | | | | | | | | | | | | For testing purposes it is desirable to have a single location where all calls to hmac_SHA256 are called. Doing so makes mocking or replacing calls much easier. BRANCH=none BUG=b:242720910 TEST=make run-fpsensor_crypto Signed-off-by: Bobby Casey <bobbycasey@google.com> Change-Id: Icc158b3e895da11d072c65a19a36f3e1b29bca14 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3838934 Reviewed-by: Tom Hughes <tomhughes@chromium.org>
* usbc: Set VDM_SETUP_DONE on DR Swap fail due to PD 2.0B R, Harsha2022-08-301-0/+1
| | | | | | | | | | | | | | | | | | In USB PD 2.0, set VDM_SETUP_DONE flag after marking identity discovery as fail and notify kernel to avoid repeated host event generation which blocks system from entering s0ix. BUG=b:243906438 TEST=Hotplug PD 2.0 charger to DUT and check if kernel receives the corresponding notification. Check if system enters s0ix. BRANCH=none Signed-off-by: B R, Harsha <harsha.b.r@intel.com> Change-Id: I8cdd814e2c6bad4e63141bd77e2a8cd224cc688f Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3858970 Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com> Reviewed-by: Abe Levkoy <alevkoy@chromium.org> Reviewed-by: Deepti Deshatty <deepti.deshatty@intel.corp-partner.google.com>
* TCPMv2: Release TCPC driver on port suspend requestCaveh Jalali2022-08-291-0/+1
| | | | | | | | | | | | | | | | | | | | | We need to release the TCPC driver from the TCPC when we want to suspend all operations on the TCPC. In practice, this means we disable ALERTs on the TCPC so the driver is not invoked. We introduced this functionality in TCPMv1 but it never made it to TCPMv2, so add it to TCPMv2. BUG=b:240458902 BRANCH=none TEST="pd 2 suspend ; pd 2 resume" no longer stops port 0 due to interrupt storm. /sys/class/typec shows devices are enumerated on resume. Change-Id: If6cc99a7a3392fd1ddfdf795074bc9f406b2555e Signed-off-by: Caveh Jalali <caveh@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3859101 Reviewed-by: Poornima Tom <poornima.tom@intel.corp-partner.google.com> Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com> Reviewed-by: Diana Z <dzigterman@chromium.org> Reviewed-by: Boris Mittelberg <bmbm@google.com>
* zephyr: Add new test for vboot efs2Jeremy Bettis2022-08-291-0/+7
| | | | | | | | | | | | | | | | | | | | This covers the cases in vboot_main. Next is to move the next level down and emulate the communication with the cr50 as well. Add new test hooks to vboot/efs2.c, and the flash emul. BRANCH=None BUG=None TEST=./twister Signed-off-by: Jeremy Bettis <jbettis@google.com> Change-Id: Icca8dde3731a91645eabbf2bc547c84a51cb1474 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3858041 Tested-by: Jeremy Bettis <jbettis@chromium.org> Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com> Auto-Submit: Jeremy Bettis <jbettis@chromium.org> Commit-Queue: Jeremy Bettis <jbettis@chromium.org> Reviewed-by: Simon Glass <sjg@chromium.org>
* zephyr: test: Add tests for the hcdebug console commandMadhurima Paruchuri2022-08-291-0/+2
| | | | | | | | | | | | BUG=b:236074352 BRANCH=none TEST=./twister -s zephyr/test/drivers/drivers.default -c Signed-off-by: Madhurima Paruchuri <mparuchuri@google.com> Change-Id: I74701533b62e55bf72169c807c8cf55ff477263e Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3856575 Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com> Reviewed-by: Abe Levkoy <alevkoy@chromium.org>
* zephyr: vstore: Add tests for vstore host commandSimon Glass2022-08-261-1/+1
| | | | | | | | | | | | | | | | Add coverage for the three host commands. This does not cover the init and sysjump behaviour. Update to use two slots so we can test non-trivial behaviour. BUG=b:236075794,b:236160558,b:236160563 BRANCH=none TEST=./twister -T zephyr/test/drivers/ -s drivers.default Signed-off-by: Simon Glass <sjg@chromium.org> Change-Id: I3aa9146b459033f32fb12d0d86ec44c214f0db63 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3858390 Reviewed-by: Jeremy Bettis <jbettis@chromium.org> Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com>
* zephyr: test: add dps test casesEric Yilun Lin2022-08-251-9/+25
| | | | | | | | | | | | | | | | | Setup DPS test environment and add test cases for config and enablement. BUG=b:243105887 TEST=./twister -T zephyr/test/drivers/ --sub-test drivers.dps BRANCH=none Change-Id: I33d5a0c11ff58296c0faa953775220034fb13d92 Signed-off-by: Eric Yilun Lin <yllin@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3841536 Commit-Queue: Eric Yilun Lin <yllin@google.com> Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com> Tested-by: Eric Yilun Lin <yllin@google.com> Reviewed-by: Yuval Peress <peress@google.com> Reviewed-by: Jeremy Bettis <jbettis@chromium.org>
* port80: Add a config to avoid logging port80 codesAndrew McRae2022-08-251-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | Add a config item to disable logging all of the port80 history buffer as each code is received. Individual codes can still be logged as they are received when enabled via the console command 'port80 intprint' or using the CONFIG_PORT80_PRINT_IN_INT config item. This reduces the overhead at AP startup on the logging. It has been observed on the ITE81302 that logging the port80 codes causes significant overhead that may lead to watchdog timeouts. The port80 code history is still available via the 'port80' EC console command. BUG=b:243607643 TEST=zmake build nereid; flash & run BRANCH=none Signed-off-by: Andrew McRae <amcrae@google.com> Change-Id: I543b0391bcf474c9d040baa98ff75f6e2b9fd5a9 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3853308 Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com> Reviewed-by: Peter Marheine <pmarheine@chromium.org>
* Test: Add test hooks for PD_CONTROLDiana Z2022-08-241-1/+10
| | | | | | | | | | | | | | | | | One of the PD_CONTROL sub-commands irreversibly blocks future commands from running on a system. For the purposes of unit test stability, create a test hook which can be used to clear this state. Otherwise, a test execution order dependency would be created. BRANCH=None BUG=b:243188273 TEST=./twister -T ./zephyr/test Signed-off-by: Diana Z <dzigterman@chromium.org> Change-Id: Ic0aacec6717e4f54dcb7f11d55fa36505fe208a7 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3852562 Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com> Reviewed-by: Aaron Massey <aaronmassey@google.com>
* zephyr: test: test tabletmode and tablet_set_modeFabio Baltieri2022-08-241-0/+7
| | | | | | | | | | | | | | | Add few tests for the tabletmode console command and the internal tablet_set_mode() and other functions. BRANCH=none BUG=b:236074811 TEST=./twister -v -s zephyr/test/drivers/drivers.default -c Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com> Change-Id: I346e31974895281ffd73e790f28f2f433f9ee481 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3850297 Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com> Reviewed-by: Tristan Honscheid <honscheid@google.com>
* dps: header cleanupEric Yilun Lin2022-08-231-3/+0
| | | | | | | | | | | | | | | | | Drop unneeded headers. BUG=none TEST=zmake build -a BRANCH=none Change-Id: I180d319f8ea86e8d2a6fc53eeeecf3d30950bfb3 Signed-off-by: Eric Yilun Lin <yllin@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3841537 Tested-by: Eric Yilun Lin <yllin@google.com> Auto-Submit: Eric Yilun Lin <yllin@google.com> Commit-Queue: Ting Shen <phoenixshen@chromium.org> Reviewed-by: Ting Shen <phoenixshen@chromium.org> Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com>
* TCPMV2: Reset ps_reset_state on disconnectTomasz Michalec2022-08-231-8/+10
| | | | | | | | | | | | | | | | | | | It is possible that partner is disconnected during hard reset handling and ps_reset_state is left in state different than PS_STATE0. To prevent starting from wrong state in tc_perform_src/snk_hard_reset, ps_reset_state is set to PS_STATE0 after each partner disconnect. BUG=b:241107451 TEST=./twister -T zephyr/test/drivers BRANCH=None Signed-off-by: Tomasz Michalec <tm@semihalf.com> Change-Id: Ie6a47ee4afff7e776216ec4981e42c9fb2328f64 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3823511 Reviewed-by: Diana Z <dzigterman@chromium.org> Commit-Queue: Tomasz Michalec <tmichalec@google.com> Tested-by: Tomasz Michalec <tmichalec@google.com> Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com>
* zephyr: test: add tests for reboot host commandFabio Baltieri2022-08-221-0/+9
| | | | | | | | | | | | | | | | | | Test various combinations of the EC_CMD_REBOOT_EC host command. This is only missing EC_REBOOT_JUMP_RO and EC_REBOOT_JUMP_RW, which needs more work, to be made testable, but this seems like a good point to cut a commit. BRANCH=none BUG=b:236074981 TEST=./twister -v -T zephyr/test/system_common Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com> Change-Id: Ie2b53a0799bb64322646728608d3c3bfd6d3fce4 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3838932 Reviewed-by: Yuval Peress <peress@google.com> Reviewed-by: Simon Glass <sjg@chromium.org> Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com>
* zephyr: test: Add I2C passthru protect host command test casesWai-Hong Tam2022-08-191-0/+5
| | | | | | | | | | | | | | | Add the test cases for I2C passthru protect. They cover the subcommands: status, enable, and enable_tcpc. They covers the error cases. BRANCH=None BUG=b:236131905 TEST=./twister -s zephyr/test/drivers/drivers.default Change-Id: I16fe91880265204376477aac60ca8b2ed456c7bf Signed-off-by: Wai-Hong Tam <waihong@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3840659 Reviewed-by: Yuval Peress <peress@google.com> Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com>
* TCPMv2: Reset cable message IDs after Data ResetAbe Levkoy2022-08-191-0/+6
| | | | | | | | | | | | | | | | Data Reset involves power cycling the cable, which should reset the cable message IDs. To correctly anticipate this, reset the expected SOP' and SOP'' message IDs after Data Reset. BUG=b:243071481 TEST=Observe USB4 entry, exit, and re-entry with TBT active cable BRANCH=none Signed-off-by: Abe Levkoy <alevkoy@chromium.org> Change-Id: I27c421f699e8ce721a749ccb09111976d209ea25 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3840664 Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com> Reviewed-by: Diana Z <dzigterman@chromium.org>
* TCPMv2: Expose function to reset message IDsAbe Levkoy2022-08-191-15/+14
| | | | | | | | | | | | | | | Expose prl_reset_msg_ids as a function and use it in the PRL where appropriate. BUG=b:243071481 TEST=make buildall BRANCH=none Signed-off-by: Abe Levkoy <alevkoy@chromium.org> Change-Id: I18d41d1e2cebf1c4c77470f7b301af23f8d73844 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3840663 Reviewed-by: Diana Z <dzigterman@chromium.org> Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com>
* common/timer: Make passing negative values to `waitms` an errorRobert Zieba2022-08-181-0/+3
| | | | | | | | | | | | | | | | This commit updates the `waitms` command so that passing a negative value will result in an error. BRANCH=none BUG=b:236074108 TEST=Built, ran subsequent zephyr test Change-Id: Ib1e9a05a5dc865b2bce71a2449016aa6863b289c Signed-off-by: Robert Zieba <robertzieba@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3840650 Reviewed-by: Tristan Honscheid <honscheid@google.com> Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com> Commit-Queue: Tristan Honscheid <honscheid@google.com>
* 8042: Rename I8042_RET to ATKBD_RETRaul E Rangel2022-08-181-18/+18
| | | | | | | | | | | | | | | | | | This change moves and renames some of the I8042_RET definitions into the AT Keyboard protocol header. This way we can make sure we are not intermixing 8042 return codes and AT keyboard return codes. I pulled the AT turn codes from the spec. BUG=b:242886255 BRANCH=none TEST=build guybrush Signed-off-by: Raul E Rangel <rrangel@chromium.org> Change-Id: I677d052202419e9678d0a3c96aa35bf424ae7bc2 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3835510 Reviewed-by: Yuval Peress <peress@google.com> Code-Coverage: Jeremy Bettis <jbettis@chromium.org> Reviewed-by: Jeremy Bettis <jbettis@chromium.org>
* 8042: Prefix data_port_state enum valuesRaul E Rangel2022-08-181-51/+53
| | | | | | | | | | | | | | | | | | | | | The 8042 keyboard code actually has two state machines embedded into one, the AT Keyboard, and the 8042 controller. This change makes it clear which state belongs to which device. Ideally the two state machines would be split at a later point. STATE_NORMAL was renamed to STATE_ATKBD_CMD since the 8042 controller is directly passing the data byte to the keyboard. BUG=b:242886255 BRANCH=none TEST=build guybrush Signed-off-by: Raul E Rangel <rrangel@chromium.org> Change-Id: Ib3d8ca36d933a457ea8353d44862e6e27da72a2f Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3835509 Reviewed-by: Jeremy Bettis <jbettis@chromium.org> Reviewed-by: Yuval Peress <peress@google.com> Code-Coverage: Jeremy Bettis <jbettis@chromium.org>
* 8042: Rename I8042_CMD to ATKBD_CMD and move to a different fileRaul E Rangel2022-08-181-16/+17
| | | | | | | | | | | | | | | | | | | These are actually AT Keyboard commands, and not specific to the i8042 controller. Using the correct prefix will make it easier to understand which device we are interacting with. I also moved the definitions into a different file to make it clear that there is a separation between the two protocols. BUG=b:242886255 BRANCH=none TEST=build guybrush Signed-off-by: Raul E Rangel <rrangel@chromium.org> Change-Id: I160f1d71edbce80606d8bcb01dbeb0d2192cfa93 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3835508 Code-Coverage: Jeremy Bettis <jbettis@chromium.org> Reviewed-by: Yuval Peress <peress@google.com> Reviewed-by: Jeremy Bettis <jbettis@chromium.org>
* charge_state: Add PWR_STATE_FORCED_IDLE stateParth Malkan2022-08-183-11/+24
| | | | | | | | | | | | | | | | | | Add PWR_STATE_FORCED_IDLE state which indicates PWR_STATE_IDLE state is forced when charge control is not normal. Also update led.c files for boards to replace chflag use with new PWR_STATE_FORCED_IDLE. BUG=b:241167493 TEST=make buildall, zmake build --all, make runhosttests -j BRANCH=None Signed-off-by: Parth Malkan <parthmalkan@google.com> Cq-Depend: chromium:3807136 Change-Id: Ib00ed3df977482a4430b0c3d16a2a0e305bbd47f Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3807134 Reviewed-by: Wai-Hong Tam <waihong@google.com>
* keyboard_8042: fix typematic scan code will be inserted issuearthur.lin2022-08-171-15/+21
| | | | | | | | | | | | | | | When race condition happened between send typematic scan code and release scan code, ignore send typematic scan code to queue because there is no key pressed at this moment. BUG=b:240309969 BRANCH=none TEST=make buildall -j Signed-off-by: arthur.lin <arthur.lin@lcfc.corp-partner.google.com> Change-Id: Iee4fab87e6769d8ff0503f140505090a6fb87d7d Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3823778 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
* TCMPV2: Add USB PD power button support in S0/S0ix/S3 statesJameson Thies2022-08-163-33/+82
| | | | | | | | | | | | | | | | | | | | | Currently a USB PD power button can only be used wake a device which is shutdown. To account for devices which use a USB PD power button and cannot enable a HID interface, this CL adds USB PD power button support to Suspend and On power states. When a device is either suspended or on, a short USB PD power button press will simulate a 500ms power button press and a long USB PD power button press will shutdown the device. BUG=b:236022894 TEST=make try_build_boards, make runhosttests and zmake test test-drivers. Also working interactively with a dock that supports sending alerts on button presses. BRANCH=None Signed-off-by: Jameson Thies <jthies@google.com> Change-Id: I3a8adaa01dbf07a03b0e1451d3a5af5d5f39c442 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3794615 Reviewed-by: Abe Levkoy <alevkoy@chromium.org> Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com>
* usbc: Add an edge case of DR Swap fail due to PD 2.0Won Chung2022-08-151-0/+15
| | | | | | | | | | | | | | | | | | In USB PD 2.0, Discover Identity can only be initiated by the DFP. When a charger that uses USB PD 2.0 is hotplugged, USB-C port's attempt to swap from UFP to DFP may be rejected. Handle such edge case to mark identity discovery as failed and send SOP_DISC_DONE event. BUG=b:238340215 TEST=Hotplug PD 2.0 charger to DUT and check if kernel receives SOP_DISC_DONE. BRANCH=none Signed-off-by: Won Chung <wonchung@google.com> Change-Id: I96dba6654d63ff52daa69510e981ebb3b84f1d6c Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3821049 Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com> Reviewed-by: Abe Levkoy <alevkoy@chromium.org>
* power: Don't set the AP_IDLE flag if a power failure occurredPablo Ceballos2022-08-152-0/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | The AP_IDLE flag prevents the AP from automatically starting up. This is normally applied when the device has shut down cleanly. If the device has experienced power loss and has not shut down cleanly, the AP power state should be restored when power is restored. With some power supplies, the voltage drops slowly when the AC power is disconnected. This can cause the EC to detect that there is a power failure on some higher voltage rails while it continues to be powered for a short while from a lower voltage rail. In such a scenario, the EC can actually have enough time to complete all of the S0->S3->S5 power state transitions and trigger the chipset_shutdown hook that sets the AP_IDLE flag. BUG=b:239979405 TEST=Manually tested AC hotplug behavior on moonbuggy board BRANCH=none Change-Id: I82ec3c481fc62c79b5798b4d52f025a2825546f4 Signed-off-by: Pablo Ceballos <pceballos@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3824922 Reviewed-by: Jack Rosenthal <jrosenth@chromium.org> Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org> Tested-by: Pablo Ceballos <pceballos@chromium.org> Commit-Queue: Pablo Ceballos <pceballos@chromium.org>
* battery: Set battery cutoff flagTim Van Patten2022-08-151-0/+3
| | | | | | | | | | | | | | | | | | | When the command `ectool batterycutoff` is issued, set a flag in the ACPI memory mapped area so ACPI code can respond appriopriately (for example, throttling the SOC). This allows us to test that a device can boot without a battery connected. BUG=b:217911928 TEST=ectool batterycutoff BRANCH=none Change-Id: Ie73ee9bd930d78b4d84040cc0e31c42a89f8259e Signed-off-by: Tim Van Patten <timvp@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3704470 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-by: Rob Barnes <robbarnes@google.com>
* keyboard_scan: skip ghost key detection at bootTing Shen2022-08-151-21/+31
| | | | | | | | | | | | | | | | | | | | | | | | | This CL fixed a bug that EC can't detect the boot key correctly if GSC asserts KSI2/3. When all columns have row2 or 3 asserted, read_matrix() tries to "fix" this by adding more keys to the state array. This causes the check_boot_key() function rejects the adjusted state. To fix this, add another workaround step before the ghost key detection to remove the rows affected by GSC. BUG=b:239674288,b:236580049 TEST=with gsc firmware from b/239674288$comment9, verify tentacruel able to enter recovery mode BRANCH=none Signed-off-by: Ting Shen <phoenixshen@google.com> Change-Id: I3df2e56e0537446954e2b5de24bf849c2189d211 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3795747 Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com> Commit-Queue: Ting Shen <phoenixshen@chromium.org> Tested-by: Ting Shen <phoenixshen@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org>
* ec: Remove calls to __gcov_flushJeremy Bettis2022-08-091-2/+4
| | | | | | | | | | | | | | | | | | | | | | | | | __gcov_flush was removed in GCC 11, and apparently it is the same as calling dump and then reset, so switch to that. BRANCH=None BUG=None TEST=make TEST_FLAG=TEST_COVERAGE=y \ build/coverage/usb_pe_drp_noextended.info TEST=make TEST_FLAG=TEST_COVERAGE=y CC=clang \ build/coverage/usb_pe_drp_noextended.info TEST=(in docker) make -j8 CRYPTOC_DIR="${MODULES_DIR}/cryptoc" \ HOSTGCOV='gcov' \ CROSS_COMPILE_arm=/opt/zephyr-sdk/arm-zephyr-eabi/bin/arm-zephyr-eabi- \ TEST_FLAG=TEST_COVERAGE=y build/coverage/usb_pe_drp_noextended.info Signed-off-by: Jeremy Bettis <jbettis@google.com> Change-Id: I9f0c8732126104c056b6adb82e4c0a1b78ac1d3e Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3818124 Tested-by: Jeremy Bettis <jbettis@chromium.org> Commit-Queue: Tristan Honscheid <honscheid@google.com> Reviewed-by: Tristan Honscheid <honscheid@google.com> Code-Coverage: Jeremy Bettis <jbettis@chromium.org> Auto-Submit: Jeremy Bettis <jbettis@chromium.org>
* usbhc: Initialize usbhc state variable to READY_TO_RXParth Malkan2022-08-051-5/+2
| | | | | | | | | | | | | | | usbhc state gets initialized to Disabled, it should be initialized to READY_TO_RX, this patch fixes that. BUG=b:239103306 TEST=Tested manually on Vell with RGB and KB BL host commands after device wakes up from suspend BRANCH=None Signed-off-by: Parth Malkan <parthmalkan@google.com> Change-Id: I154667a4300bf513f320742cec881ae59985828e Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3812504 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
* util: remove unused includesYuval Peress2022-08-0541-3/+44
| | | | | | | | | | | | | | | | Remove these includes as they're not needed in this header. Instead, the includes should go where they're actually being used. BRANCH=none BUG=b:240574048 TEST=make buildall -j TEST=zmake build -a Signed-off-by: Yuval Peress <peress@google.com> Change-Id: I64b10af3216654b2a20caa1cabd267661a0bca39 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3791980 Reviewed-by: Tristan Honscheid <honscheid@google.com> Commit-Queue: Tristan Honscheid <honscheid@google.com>
* ec: Fix stack smashing in motion_sense_fifoJeremy Bettis2022-08-041-2/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | The struct ec_response_motion_sense_fifo_info contains one of those annoying [0] arrays, therefore you need to actually allocate extra space for the data after the end of the struct. Change all allocations of struct ec_response_motion_sense_fifo_info to actually use a uint8_t[] instead that is sizeof(struct ec_response_motion_sense_fifo_info) + sizeof(uint16_t) * MAX_MOTION_SENSORS. Added comment to motion_sense_fifo_get_info() to warn people about the pointer they pass into the function. BRANCH=None BUG=b:237305991 TEST=make run-coverage-motion_sense_fifo in chroot, and gitlab docker Change-Id: I23bc3168c43ce1e4cb20584e6a455773a789ff02 Signed-off-by: Jeremy Bettis <jbettis@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3812496 Auto-Submit: Jeremy Bettis <jbettis@chromium.org> Commit-Queue: Jeremy Bettis <jbettis@chromium.org> Tested-by: Jeremy Bettis <jbettis@chromium.org> Reviewed-by: Aaron Massey <aaronmassey@google.com>