summaryrefslogtreecommitdiff
path: root/zephyr/test/drivers
Commit message (Collapse)AuthorAgeFilesLines
* zephyr/test: Increase timeoutJeremy Bettis2023-05-111-0/+1
| | | | | | | | | | | | | | | | | This test is timing out on gitlab, increase timeout to 6m. https://gitlab.com/zephyr-ec/ec/-/jobs/4264180403 BUG=None TEST=None Change-Id: I5a18e20091825f649d29b29950644f1121b90ed6 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4523022 Tested-by: Jeremy Bettis <jbettis@chromium.org> Auto-Submit: Jeremy Bettis <jbettis@chromium.org> Commit-Queue: Jeremy Bettis <jbettis@chromium.org> Reviewed-by: Al Semjonovs <asemjonovs@google.com> Commit-Queue: Al Semjonovs <asemjonovs@google.com>
* charger: Move charger_state_v2.h into charge_state.hSimon Glass2023-05-115-5/+3
| | | | | | | | | | | | | | | | | | | | We don't have a v1 anymore, so the name makes no sense. Move it into the existing file. Include charge_state.h instead of v2, doing this in the same change to avoid build errors. This makes no functional change. BUG=b:218332694 TEST=make buildall Change-Id: Ic3e3adc45e4d002c2cd5ba8aa65e24686e01d628 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4516191 Reviewed-by: Tim Van Patten <timvp@google.com> Commit-Queue: Simon Glass <sjg@chromium.org> Tested-by: Simon Glass <sjg@chromium.org> Reviewed-by: Yuval Peress <peress@google.com>
* zephyr: test: Avoid using charger_state as a variableSimon Glass2023-05-113-21/+21
| | | | | | | | | | | | | | | | We have enum charge_state_v2 and used to have enum charge_state. Try to avoid using charger_state in the source except as an enum. This makes no functional change. BUG=b:218332694 TEST=CQ Change-Id: I3e53843799b7a6258cf636c11df47389b8d98123 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4516190 Reviewed-by: Jeremy Bettis <jbettis@chromium.org> Commit-Queue: Simon Glass <sjg@chromium.org> Tested-by: Simon Glass <sjg@chromium.org>
* zephyr: test: Test keyboard_8042.c console commandsTristan Honscheid2023-05-115-0/+213
| | | | | | | | | | | | | | | | Add tests for the `8042` set of console commands in `keyboard_8042.c`, covers about 100 new lines. BUG=b:281691908 TEST=./twister -s drivers/drivers.keyboard_8042 Change-Id: I1e28e0258305d0e1d17571346fcdca8f19102cb9 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4520583 Commit-Queue: Peter Marheine <pmarheine@chromium.org> Tested-by: Tristan Honscheid <honscheid@google.com> Commit-Queue: Tristan Honscheid <honscheid@google.com> Auto-Submit: Tristan Honscheid <honscheid@google.com> Reviewed-by: Peter Marheine <pmarheine@chromium.org>
* zephyr: implement icm42607 testTing Shen2023-05-097-0/+565
| | | | | | | | | | | | | | | | | | | Add unittest for ICM42607 accel+gyro sensor. Note that we've already hit the hard limit of motion sensor count in zephyr/test/drivers/default/, so this one is implemented as a standalone test. Also fixed an endian bug in driver/accelgyro_icm42607.c. BUG=b:272665228 TEST=twister Change-Id: Ia52a81e671a981fc0f003d07c7f59ca3d0c24233 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4497324 Tested-by: Ting Shen <phoenixshen@chromium.org> Reviewed-by: Eric Yilun Lin <yllin@google.com> Commit-Queue: Ting Shen <phoenixshen@chromium.org>
* Zephyr test: Add HPD GPIO test to AP VDM controlDiana Z2023-05-052-0/+243
| | | | | | | | | | | | | | | Add tests ensuring we set the HPD gpio correctly for the AP when we get VDM:Attention messages in for DisplayPort, and also wake the AP when needed. BUG=b:266714542 TEST=./twister -T ./zephyr/test Change-Id: Ie9946477ae4b1a3e22b5cd92a02fe844a32ae5c4 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4218927 Tested-by: Diana Z <dzigterman@chromium.org> Reviewed-by: Jeremy Bettis <jbettis@chromium.org> Commit-Queue: Diana Z <dzigterman@chromium.org>
* sm5803: restore load-bearing ERROR_UNIMPLEMENTEDPeter Marheine2023-05-051-5/+12
| | | | | | | | | | | | | | | | | | | | | | The OCPC code seems to use ERROR_UNIMPLEMENTED as a signal that it should do some work, and SUCCESS as a signal that everything has been done. Always returning success appears to cause incorrect charging behavior: restore the unconditional ERROR_UNIMPLEMENTED that was removed in commit ae68afbb5d58ce7af0be3e04f833900b105021cd and change the test to reflect this. A note is added to the definition of this driver field to document that ERROR_UNIMPLEMENTED is an expected normal result. BUG=b:280530115 TEST=Battery once again charges on Yaviks port C1 when connected to a charger. Change-Id: I491247148c523123206fefcdbcde62a92ea8caf4 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4506012 Reviewed-by: Aseda Aboagye <aaboagye@chromium.org> Tested-by: Peter Marheine <pmarheine@chromium.org> Commit-Queue: Peter Marheine <pmarheine@chromium.org>
* drivers.body_detection: Enable CONFIG_PLATFORM_EC_GESTURE_HOST_DETECTIONTim Van Patten2023-05-042-5/+18
| | | | | | | | | | | | | | | Enable CONFIG_PLATFORM_EC_GESTURE_HOST_DETECTION for drivers.body_detection, to enable additional testing. BUG=b:259754018 TEST=./twister -v -i -p native_posix -p unit_testing Change-Id: I092e2c3e9c9b5db5a29adf15cfb338647058f514 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4484797 Reviewed-by: Aaron Massey <aaronmassey@google.com> Commit-Queue: Tim Van Patten <timvp@google.com> Reviewed-by: Tristan Honscheid <honscheid@google.com> Tested-by: Tim Van Patten <timvp@google.com>
* sm5803: implement more driver testsPeter Marheine2023-05-043-4/+368
| | | | | | | | | | | | | | | | | | | | There are two behavioral changes: * sm5803_set_otg_current_voltage is modified to ensure it never attempts to program an output voltage less than the minimum supported by the chip, because that would program unintended bits. * the SM5803 emulator is fixed to still build correctly if no interrupt GPIO is specified, because not all users of the emulator care about the interrupts (such as the newly-introduced secondary charger for this test, allowing it to exercise OCPC-specific functionality). BUG=b:242544165 TEST=./twister -ci -T zephyr/tests/drivers -s drivers.sm5803 Change-Id: I9df854d5e9666a833d209a0d98d6987c7b29e953 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4482276 Tested-by: Peter Marheine <pmarheine@chromium.org> Reviewed-by: Tristan Honscheid <honscheid@google.com> Commit-Queue: Peter Marheine <pmarheine@chromium.org>
* adc: Reduce code size of adc commandDaisuke Nojiri2023-05-031-5/+5
| | | | | | | | | | | | | | | | This CL reduces the code size of the adc console command by removing some redundancy. BUG=None TEST=twister -T zephyr/test/drivers -s drivers.default.console_cmds Change-Id: Icd08d6b73adc25d1be0cd4a2f69ff38a65ed0ddf Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4501179 Reviewed-by: Rob Barnes <robbarnes@google.com> Commit-Queue: Rob Barnes <robbarnes@google.com> Auto-Submit: Daisuke Nojiri <dnojiri@chromium.org> Commit-Queue: Daisuke Nojiri <dnojiri@chromium.org> Tested-by: Daisuke Nojiri <dnojiri@chromium.org>
* body_detection: Add body detection testsTim Van Patten2023-05-026-0/+146
| | | | | | | | | | | | | | | Add body detection tests. Test results: http://go/259754018 BRANCH=none BUG=b:259754018 TEST=./twister -v -i -p native_posix -p unit_testing Change-Id: I6a9b8ce6bce718e9231987698f4943d6c5e04dbb Signed-off-by: Tim Van Patten <timvp@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4484777 Reviewed-by: Tristan Honscheid <honscheid@google.com>
* emul_nx20p348x: use TCPC power_status as TCPC GPIO configEric Yilun Lin2023-05-021-2/+20
| | | | | | | | | | | | | | | | | | On NX20P3483, it needs 2 dedicated TCPC GPIO to reflect the VBUS sink and source control. There's no such binding now, so we checked the TCPC POWER_STATUS instead, and it should have the same functionality for the VBUS status checking. BUG=b:272664811 TEST=./twister -ci -T zephyr/test BRANCH=none Change-Id: I05e73e16a4ddb1d22b812e672dbaaa366704f984 Signed-off-by: Eric Yilun Lin <yllin@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4483239 Commit-Queue: Eric Yilun Lin <yllin@google.com> Reviewed-by: Diana Z <dzigterman@chromium.org> Tested-by: Eric Yilun Lin <yllin@google.com>
* sm5803: add tests for set_vsys_compensationPeter Marheine2023-04-271-0/+32
| | | | | | | | | | | | | | | | | | | Two bugs in the driver were exposed by this test and are fixed: * All 8 bits of IR_COMP_REG2 are used as resistance value (in addition to bits 6 and 7 of IR_COMP_REG1), but the driver incorrectly masked off bit 7 which would cause incorrect values to be programmed when resistance is greater than 212 mΩ. * sm5803_set_vsys_compensation always returned an error, which apparently goes unchecked by regular charger code. BUG=b:242544165 TEST=./twister -ci -T zephyr/test/drivers/ -s drivers.sm5803 BRANCH=none Change-Id: I761c3523d9903c3498cfe30d93ddb56b004cc4ef Signed-off-by: Peter Marheine <pmarheine@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4482275 Reviewed-by: Tristan Honscheid <honscheid@google.com>
* zephyr: Add test to 100% cover bmi_set_gyro_offsetJeremy Bettis2023-04-211-0/+52
| | | | | | | | | | | | | | | | | | | Call set_offset with extreme values to exercise the clipping code. BRANCH=None BUG=b:278607671 TEST=./twister -T zephyr/test/drivers/ --coverage -s drivers.default \ -- --test=bmi160::test_bmi_gyr_set_offset_min_max &&\ lcov --list-full-path -l twister-out/coverage.info | \ awk '/accelgyro_bmi_common.c/ {print $2, $3}' Change-Id: I3c3ca9ea638e6bb45e3d737019f34d71831a855e Signed-off-by: Jeremy Bettis <jbettis@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4454188 Auto-Submit: Jeremy Bettis <jbettis@chromium.org> Commit-Queue: Jeremy Bettis <jbettis@chromium.org> Reviewed-by: Yuval Peress <peress@google.com> Tested-by: Jeremy Bettis <jbettis@chromium.org>
* Reland "zephyr/tests: emulator and tests for sm5803"Peter Marheine2023-04-208-0/+807
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is a reland of commit fd2415cda6a261b92390aad04829f46f33ffc9e6, with sleeps in test_lpm increased from 4 to 10 seconds. This seems to fix the flakiness that was observed, verified with no failures over 8 CQ builds. Original change's description: > zephyr/tests: emulator and tests for sm5803 > > This implements an emulator and some tests for the SM5803 charger. The > current tests do not exercise the driver as comprehensively as intended, > but those will be added in a later change. > > One discovered bug in the driver is fixed, where some interrupts were > disabled immediately after being enabled. > > BUG=b:242544165 > TEST=twister -ciC -s drivers/drivers.sm5803 > BRANCH=nissa > > Change-Id: I9fc6abd26cd1b2e0cbc05b8e45cf94fc83abd08c > Signed-off-by: Peter Marheine <pmarheine@chromium.org> > Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4290087 > Reviewed-by: Tristan Honscheid <honscheid@google.com> BUG=b:242544165,b:278890420 TEST=`bb add chromeos/cq/firmware-zephyr-cov-cq -commit https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4451846` 8 times, verified success for all builds. Change-Id: Ifd0d486a45be2242023e6efba6457e7907aaedd2 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4451846 Reviewed-by: Tristan Honscheid <honscheid@google.com> Commit-Queue: Tristan Honscheid <honscheid@google.com> Reviewed-by: Aaron Massey <aaronmassey@google.com> Tested-by: Peter Marheine <pmarheine@chromium.org>
* retimer: Use common console command for all RetimersVijay Hiremath2023-04-191-9/+9
| | | | | | | | | | | | | | BUG=b:278138274 BRANCH=none TEST=Tested on ADL-RVP, retimer console command works ./twister -T zephyr/test/drivers ./twister -T zephyr/test/drivers -s drivers.default ./firmware_builder.py --metrics /tmp/tmp_pc1rc15 build Change-Id: Idaec9b41f550ad6aafa34400e95ebf00b9c11348 Signed-off-by: Vijay Hiremath <vijay.p.hiremath@intel.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4426790 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
* Revert "zephyr/tests: emulator and tests for sm5803"Aaron Massey2023-04-198-807/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This reverts commit fd2415cda6a261b92390aad04829f46f33ffc9e6. Reason for revert: http://b/278890420 - test was flakily blocking CQ Original change's description: > zephyr/tests: emulator and tests for sm5803 > > This implements an emulator and some tests for the SM5803 charger. The > current tests do not exercise the driver as comprehensively as intended, > but those will be added in a later change. > > One discovered bug in the driver is fixed, where some interrupts were > disabled immediately after being enabled. > > BUG=b:242544165 > TEST=twister -ciC -s drivers/drivers.sm5803 > BRANCH=nissa > > Change-Id: I9fc6abd26cd1b2e0cbc05b8e45cf94fc83abd08c > Signed-off-by: Peter Marheine <pmarheine@chromium.org> > Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4290087 > Reviewed-by: Tristan Honscheid <honscheid@google.com> Bug: b:242544165 Change-Id: I315d36d1e08035f13d847ea1a21756ee3790216e Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4448966 Commit-Queue: Aaron Massey <aaronmassey@google.com> Tested-by: Aaron Massey <aaronmassey@google.com> Reviewed-by: Keith Short <keithshort@chromium.org>
* zephyr/tests: emulator and tests for sm5803Peter Marheine2023-04-198-0/+807
| | | | | | | | | | | | | | | | | | This implements an emulator and some tests for the SM5803 charger. The current tests do not exercise the driver as comprehensively as intended, but those will be added in a later change. One discovered bug in the driver is fixed, where some interrupts were disabled immediately after being enabled. BUG=b:242544165 TEST=twister -ciC -s drivers/drivers.sm5803 BRANCH=nissa Change-Id: I9fc6abd26cd1b2e0cbc05b8e45cf94fc83abd08c Signed-off-by: Peter Marheine <pmarheine@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4290087 Reviewed-by: Tristan Honscheid <honscheid@google.com>
* zephyr: LED: Reformated led-pins bindingsJason Yuan2023-04-182-72/+64
| | | | | | | | | | | | | | | | | | This CL formats the led-pins devicetree to be more intuitive as part of the LED driver overhaul. led-policy and led driver logic is unmodified in this CL and will be added later. BUG=b:228868616 TEST=twister, power LED verified on Villager, Lazor, Skyrim, Xivu BRANCH=none Change-Id: Ia688e872811199447d1e0b11a5533fd8478d2935 Signed-off-by: Jason Yuan <jasonyuan@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4426805 Commit-Queue: Wai-Hong Tam <waihong@google.com> Auto-Submit: zhi cheng yuan <jasonyuan@chromium.org> Tested-by: zhi cheng yuan <jasonyuan@chromium.org> Reviewed-by: Wai-Hong Tam <waihong@google.com>
* panic: Set watchdog panic reason if old watchdog panicRob Barnes2023-04-181-0/+50
| | | | | | | | | | | | | | | | | | | | | | | | | | | | The watchdog panic info may be set in watchdog handler or during system pre init after the watchdog reset. It depends on the chip implementation. For cortex-m on Zephyr, the watchdog panic reason is not set in the watchdog handler. The current logic in system pre init only sets the watchdog panic reason when the current reason is not a watchdog. This means only the first watchdog is reported. Successive watchdogs are ignored because the panic flags are never reset. The panic flags will only be reset if a non-watchdog panic occurs or EC memory cleared (FW update or 0 battery). This change checks if the current watchdog panic is old. This is inferred by checking for the PANIC_DATA_FLAG_OLD_HOSTCMD flag, which is set when the host reads the panic info. BUG=b:273516527 BRANCH=Zephyer NPCX boards TEST=Succesive watchdogs are correctly reported in elog TEST=drivers.system unit test Change-Id: I91ec1bf75a85ea7fed978895a262ff74e6ac16c7 Signed-off-by: Rob Barnes <robbarnes@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4415329 Commit-Queue: Aaron Massey <aaronmassey@google.com> Reviewed-by: Aaron Massey <aaronmassey@google.com>
* zephyr: Fix uninitialized variableJeremy Bettis2023-04-181-1/+1
| | | | | | | | | | | | | | | | | | The test was causing inconsistent code coverage due to calling set_offset with an uninitialized variable. BRANCH=None BUG=b:278607671 TEST=Ran test several times Change-Id: I779096eb0b90deb040b50b1015bbffcf22fc0583 Signed-off-by: Jeremy Bettis <jbettis@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4437750 Auto-Submit: Jeremy Bettis <jbettis@chromium.org> Commit-Queue: Aaron Massey <aaronmassey@google.com> Tested-by: Jeremy Bettis <jbettis@chromium.org> Commit-Queue: Jeremy Bettis <jbettis@chromium.org> Reviewed-by: Aaron Massey <aaronmassey@google.com>
* accel_list2dw12: Set high perf mode for ODR >= 50zKornel Dulęba2023-04-171-3/+3
| | | | | | | | | | | | | | | | | | | Until recently we're used it only as lid accel, where no significant precision is required. However in Winterhold we want to use it for body detection. In order to reduce the noise and make it usable for that purpose we need to set it into "high performance" power mode. ODR is used to recognize the sensor purpose. For lid accel it's set to 12.5Hz, assume that if it's at least 50Hz the high performance is wanted. BUG=b:262680246 BRANCH=none TEST=Set ODR to 50Hz, verify high performance mode is on Change-Id: I8c4decc93d2f2cfcc074cf2399f5cb582eb72696 Signed-off-by: Kornel Dulęba <korneld@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4379149 Reviewed-by: Gwendal Grignou <gwendal@chromium.org>
* flash: cbi: Block the HCs from flash CBI section modificationMadhurima Paruchuri2023-04-173-9/+287
| | | | | | | | | | | BRANCH=None BUG=b:267629295 TEST=./twister -T zephyr/test -c Change-Id: Ibcf176f10860cc126b267908faba054df256c3d4 Signed-off-by: Madhurima Paruchuri <mparuchuri@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4414226 Reviewed-by: Wai-Hong Tam <waihong@google.com>
* zephyr: test drivers: Fix GPIO mismatchKeith Short2023-04-141-1/+1
| | | | | | | | | | | | | | | Make the GPIO flags match for the PPC interrupt in the named-gpios node and the ppc device node. Eventually the named-gpios node will be eliminated, but it is currently needed to configure the GPIO pin. BUG=none BRANCH=none TEST=twister Change-Id: Iea28bdf5c29386f19576ad64ed149120a08f0f74 Signed-off-by: Keith Short <keithshort@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4426792 Reviewed-by: Abe Levkoy <alevkoy@chromium.org>
* zephyr: tcpc: Add TCPC alt support for all existing TCPCMadhurima Paruchuri2023-04-143-13/+79
| | | | | | | | | | | | | | Add TCPC alt support for all TCPCs and tests to test the working of TCPC alternatives BRANCH=none BUG=b:274126703 TEST=./twister -s drivers/drivers.usbc_tcpc -c Change-Id: Icafdaf8b940b09cfc3c17ed124e1b4a0a9427d01 Signed-off-by: Madhurima Paruchuri <mparuchuri@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4375619 Reviewed-by: Keith Short <keithshort@chromium.org>
* zephyr/emul/retimer/anx7483: Add function to validate tuning settingsRobert Zieba2023-04-141-473/+188
| | | | | | | | | | | | | | | | | Board tests may want to have a basic check to ensure that tunings are getting set, while the actual full testing remains in the ANX7483 emulator tests. Add `anx7483_emul_validate_tuning` function to facilitate this. BRANCH=none BUG=b:247151116 TEST=Ran tests Change-Id: I88ce43b079db98d16aedf561a463df0046c4460b Signed-off-by: Robert Zieba <robertzieba@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4354875 Reviewed-by: Abe Levkoy <alevkoy@chromium.org> Reviewed-by: Keith Short <keithshort@chromium.org>
* zephyr/emul/anx7483: Add anx7483_emul_test_get_eq functionRobert Zieba2023-04-141-27/+33
| | | | | | | | | | | | | | Add `anx7483_emul_test_get_eq` function. This function will be useful for board tests. BRANCH=none BUG=b:247151116 TEST=Ran tests Change-Id: I88ca9ee6d73eac7db513633f2fdfe590fea8ef92 Signed-off-by: Robert Zieba <robertzieba@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4345936 Reviewed-by: Jeremy Bettis <jbettis@chromium.org>
* drivers.power_host_sleep: Add test for s0ix counterGrzegorz Bernacki2023-04-142-0/+29
| | | | | | | | | | | | | | This commits add test the verifies if s0ix counter gets incremented on change state to s0ix. BUG=b:261869264 TEST=Run with twister BRANCH=none Change-Id: Iae5aecb4a6feec84d233f296b0215e54f6c60abb Signed-off-by: Grzegorz Bernacki <bernacki@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4239446 Reviewed-by: Robert Zieba <robertzieba@google.com>
* zephyr: Add support for RNG devicesPatryk Duda2023-04-135-0/+115
| | | | | | | | | | | | | | | | | | | | | | | This patch provides implementation of trng_rand_bytes() using Zephyr's entropy API. Zephyr driver is responsible for hardware initialization, enabling and disabling, so trng_init() and trng_exit() are no-op. Add hostcmd and console command which can be used to test random number generator. Both commands have unit tests implemented. BUG=b:277029648 BRANCH=none TEST=zmake build bloonchipper TEST=Enable CONFIG_PLATFORM_EC_CONSOLE_CMD_RAND and compile firmware. Use 'rand' command to check if random values are generated. TEST=./twister -v -i -T zephyr/test/drivers/ --test drivers.random Change-Id: I3fa2c6a1aaf84dc23a8fbb06e557d9e07f5d1d32 Signed-off-by: Patryk Duda <pdk@semihalf.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4381919 Tested-by: Patryk Duda <patrykd@google.com> Commit-Queue: Patryk Duda <patrykd@google.com> Reviewed-by: Keith Short <keithshort@chromium.org>
* ISL9241: Fix ACProchot reg <-> mA conversionDaisuke Nojiri2023-04-121-2/+2
| | | | | | | | | | | | | | | | | | This CL fixes expressions used to convert ACProchot register values to/from the current. There is no functionality change because the register happens to use identical conversion. That is, 128 mA <-> 0x80, for example. BUG=b:277280318 BRANCH=None TEST=./twister --toolchain host -T zephyr/test/drivers -s drivers.isl9241 Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> Change-Id: I7c2d6c8b1819c5031306de4ea421193828359290 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4409985 Commit-Queue: Paul Fagerburg <pfagerburg@chromium.org> Reviewed-by: Paul Fagerburg <pfagerburg@chromium.org>
* retimer: Add emulator and unit tests for ANX7452 retimer driverMadhurima Paruchuri2023-04-127-0/+345
| | | | | | | | | | | BUG=b:267589042 BRANCH=none TEST=./twister -s drivers/drivers.anx7452 -c --coverage Change-Id: I7b4dcef7e667cd69ecb39f6dda7a6c8570177f40 Signed-off-by: Madhurima Paruchuri <mparuchuri@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4303379 Reviewed-by: Fabio Baltieri <fabiobaltieri@google.com>
* zephyr: Support PLATFORM_EC_CMD_POWERINDEBUG flagKnox Chiou2023-04-111-0/+1
| | | | | | | | | | | | | | | | | | | Support PLATFORM_EC_CMD_POWERINDEBUG flag for `powerindebug` on zephyr. BUG=b:272185086 BRANCH=none TEST=zmake build geralt TEST=disable flag and check powerindebug Signed-off-by: Knox Chiou <knoxchiou@google.com> Change-Id: I89af4161b6bcc351e750d2716e0cc594cfe74814 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4383291 Tested-by: Knox Chiou <knoxchiou@chromium.org> Commit-Queue: Knox Chiou <knoxchiou@chromium.org> Reviewed-by: Zhuohao Lee <zhuohao@chromium.org> Reviewed-by: Keith Short <keithshort@chromium.org> Code-Coverage: Knox Chiou <knoxchiou@chromium.org>
* zephyr: driver: add gpio test for rt1718slschyi2023-04-105-34/+198
| | | | | | | | | | | | | | | | | Add test for GPIO related driver tests. The common code used in different test suite are extracted into a new file, and extend the GPIO related functionality in RT1718S emulator for testing. BUG=b:273854897 BRANCH=none TEST=./twister -c -i -T zephyr/test/drivers -s drivers.rt1718s Change-Id: Ic32973bcee0f944be59ac6840612a3358d010b76 Signed-off-by: lschyi <lschyi@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4387396 Commit-Queue: Sung-Chi Li <lschyi@chromium.org> Tested-by: Sung-Chi Li <lschyi@chromium.org> Reviewed-by: Eric Yilun Lin <yllin@google.com>
* zephyr: Add `test_` prefix to ZTEST function namesAl Semjonovs2023-04-0738-196/+198
| | | | | | | | | | | | | | Twister parsing fails when `test_` prefix is missing from the test name. BUG=None BRANCH=NONE TEST=./twister -T zephyr/test Change-Id: Ic7148a66c761eaf45619b4e764e5aac9b869092c Signed-off-by: Al Semjonovs <asemjonovs@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4409346 Reviewed-by: Keith Short <keithshort@chromium.org>
* zephyr: test: Fix flaky keyboard_scan testTristan Honscheid2023-04-071-17/+33
| | | | | | | | | | | | | | | | Latent key presses were appearing in a subsequent test, throwing off FFF expectations. Resolved by adding a test-only helper function to `keyboard_scan.c` to wipe out the debouncing state between tests. Also broke out the failing test into two independent ones. BRANCH=None BUG=None TEST=./twister -s drivers/drivers.keyboard_scan Change-Id: I79f2a6891f36e10a7df87865573348312c5b57d5 Signed-off-by: Tristan Honscheid <honscheid@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4404706 Reviewed-by: Al Semjonovs <asemjonovs@google.com>
* Zephyr Test: Create test for NX20P3481 PPCDiana Z2023-04-073-0/+58
| | | | | | | | | | | | | | Create test cases and emulor behavior to cover the slightly-different portions of the NX20P348X code related to Vbus sourcig and sinking. BRANCH=None BUG=b:276468569 TEST=./twister -T ./zephyr/test Change-Id: Ieb30b3dbe3ad52448359ef253085058efe5b1d39 Signed-off-by: Diana Z <dzigterman@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4404285 Reviewed-by: Simon Glass <sjg@chromium.org>
* Zephyr test: Split NX20P3483 specifics into their own testDiana Z2023-04-076-22/+50
| | | | | | | | | | | | | | | | The driver code in drivers/ppc/nx20p348x.c is split between two similar PPCs, with the primary difference being their methods of enabling sourcing and sinking. Split the code for the "3" variant into its own file so it may be tested separately. BRANCH=None BUG=b:276468569 TEST=./twister -T ./zephyr/test Change-Id: I83a8f0a1b01981aa8654aac472b2fb747bcb9feb Signed-off-by: Diana Z <dzigterman@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4404283 Reviewed-by: Aaron Massey <aaronmassey@google.com>
* Zephyr test: Test NXP PPC interruptsDiana Z2023-04-074-0/+135
| | | | | | | | | | | | | Add support for testing interrupts with the NX20P384X driver. BRANCH=None BUG=b:276468569 TEST=./twister -T ./zephyr/test Change-Id: I3856063c367ec6d8ffcbd8599c3b62fa73e01b1f Signed-off-by: Diana Z <dzigterman@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4389620 Reviewed-by: Tomasz Michalec <tmichalec@google.com>
* Zephyr test: Create NX20P383X testDiana Z2023-04-036-0/+156
| | | | | | | | | | | | | | Create a test for the NX20P383X driver. This first test checks the APIs into the driver, but does not test the interrupt functionality. BRANCH=None BUG=b:276468569 TEST=./twister -T ./zephyr/test Change-Id: I9ffffda688c6d45b1448aac781bc4c070f06777b Signed-off-by: Diana Z <dzigterman@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4389618 Reviewed-by: Yuval Peress <peress@google.com>
* Zephyr test: Create NX20P383X emulatorDiana Z2023-04-031-1/+1
| | | | | | | | | | | | | | | | Create an emulator for this PPC so tests may use it as an available i2c target. BRANCH=None BUG=b:276468569 TEST=./twister -T ./zephyr/test LOW_COVERAGE_REASON=emulator edge cases not tested Change-Id: I54b8aced582e81b3f61895f25b472bce79dddc50 Signed-off-by: Diana Z <dzigterman@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4389617 Reviewed-by: Keith Short <keithshort@chromium.org> Commit-Queue: Keith Short <keithshort@chromium.org>
* zephyr: tests: Update testcase.yaml to remove extra_argsTristan Honscheid2023-04-031-228/+290
| | | | | | | | | | | | | | Update testcase.yaml files using `extra_args` to specify extra config an DT overlays to use the new dedicated YAML fields. BUG=None BRANCH=None TEST=./twister for affected test projects Change-Id: If8162b7424b22638613a60b22ab0b35b2cae4e09 Signed-off-by: Tristan Honscheid <honscheid@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4391242 Reviewed-by: Yuval Peress <peress@google.com>
* Zephyr test: Add test for ISL9241 charger chipDiana Z2023-03-316-0/+276
| | | | | | | | | | | | | | Add a test to run through the basic available functionality of the ISL9241 charger chip and validate it behaves as expected. BRANCH=None BUG=b:273722902 TEST=./twister -T ./zephyr/test Change-Id: I29beb38a1af867640c31237581dba41512c01ddd Signed-off-by: Diana Z <dzigterman@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4387137 Reviewed-by: Al Semjonovs <asemjonovs@google.com>
* Zephyr test: Conditionally compile ISL923x dependent functionsDiana Z2023-03-311-0/+2
| | | | | | | | | | | | | | | Remove the functions which require the ISL923x emulator to function from the build if that emulator isn't present. This way, tests may compile with a different charger emulator in place. BRANCH=None BUG=b:273722902 TEST=./twister -T ./zephyr/test Change-Id: Id497e8c9151a247aedff10eca1b7af3dd047a1fa Signed-off-by: Diana Z <dzigterman@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4387135 Reviewed-by: Aaron Massey <aaronmassey@google.com>
* zephyr: tests: Fix duplicate GPIOsKeith Short2023-03-301-4/+0
| | | | | | | | | | | | | | Fix duplicate GPIOs found in the unit tests. Duplicate GPIOs may cause test instability. BUG=none BRANCH=none TEST=./twister Change-Id: Ie6df5ebd0d663488673442377b09d66e07fff38e Signed-off-by: Keith Short <keithshort@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4382527 Reviewed-by: Fabio Baltieri <fabiobaltieri@google.com>
* zephyr: tcpc: add rt1718s testlschyi2023-03-307-0/+300
| | | | | | | | | | | | | | | Add test cases for testing rt1718s tcpc driver. BUG=b:273854897 BRANCH=none TEST=./twister -c -i -T zephyr/test/drivers -s drivers.rt1718s Change-Id: Ib37a41bf85200778b8488be5ff3c16d99d2d1f28 Signed-off-by: lschyi <lschyi@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4369111 Reviewed-by: Eric Yilun Lin <yllin@google.com> Tested-by: Sung-Chi Li <lschyi@chromium.org> Commit-Queue: Sung-Chi Li <lschyi@chromium.org>
* Zephyr test: Add test for AMD FP6 USB muxDiana Z2023-03-286-0/+194
| | | | | | | | | | | | | | | Add a test exercising all the basic sets, as well as timing quirks, of the AMD FP6 USB mux driver. BRANCH=None BUG=b:274159180 TEST=./twister -T ./zephyr/test, observe a satisfying 96% coverage in the AMD FP6 mux driver Change-Id: Id931126bcb6639f9004a99543e7e803b0042ec60 Signed-off-by: Diana Z <dzigterman@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4350996 Reviewed-by: Fabio Baltieri <fabiobaltieri@google.com>
* zephyr: tcpc: Add tests for TCPC alternate switch during runtimeMadhurima Paruchuri2023-03-286-0/+107
| | | | | | | | | | | | | Add tests to test the working of TCPC alternatives switch working BRANCH=none BUG=b:274151516 TEST=./twister -s drivers/drivers.usbc_tcpc -c Change-Id: Ic5f666d4efa053a888d0f045fb3075d39b9000d2 Signed-off-by: Madhurima Paruchuri <mparuchuri@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4356352 Reviewed-by: Keith Short <keithshort@chromium.org>
* mkbp_fifo: fix buffer overflow bugTing Shen2023-03-272-1/+7
| | | | | | | | | | | | | | | | | | | | | The element type we used in mkbp fifo (ec_response_get_next_event, 13 bytes) is smaller than the maximum data we put into the queue (KEYBOARD_COLS_WITH_KEYPAD, 15 bytes). Change the element type to ec_response_get_next_event_v1 to fix this bug. Also added a compile time check and updated the unittest to detect similar bugs in the future. BUG=none TEST=pass the updated drivers.mkbp test BRANCH=none Change-Id: Ifb6d89a81cbbb1bbcf9fa20164b6b133bad3d0a2 Signed-off-by: Ting Shen <phoenixshen@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4369577 Reviewed-by: Peter Marheine <pmarheine@chromium.org> Tested-by: Ting Shen <phoenixshen@chromium.org> Commit-Queue: Ting Shen <phoenixshen@chromium.org>
* zephyr: move tcpc_get_alert_status to shimJason Yuan2023-03-242-12/+16
| | | | | | | | | | | | | | | | | | | | tcpc_get_alert_status is similar between multiple different projects. They have been now merged into common code. BUG=b:254148652 TEST=twister, usbc charging on villager, lazor BRANCH=none LOW_COVERAGE_REASON=the change from hardcoding to rst-gpios in board specific code is uncovered. The common code is 100% covered. This CL increases the absolute coverage. Change-Id: I3136bd5b600dbb385547e06490dcbf8815b85b85 Signed-off-by: Jason Yuan <jasonyuan@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4257651 Commit-Queue: zhi cheng yuan <jasonyuan@chromium.org> Auto-Submit: zhi cheng yuan <jasonyuan@chromium.org> Reviewed-by: Keith Short <keithshort@chromium.org> Tested-by: zhi cheng yuan <jasonyuan@chromium.org>
* zephyr/emul/anx7483: Add support for changing reserved register masksRobert Zieba2023-03-231-0/+174
| | | | | | | | | | | | | | | | | Some of the bits marked as reserved in the ANX7483's registers are used by the manufacturer for board-specific tuning. Add an API to allow for changing reserved masks to allow for tests to fully validate their tunings. BRANCH=none BUG=b:247151116 TEST=Ran tests Change-Id: Ifca5e5dea60b0ed4d2557096be65211c0f83f459 Signed-off-by: Robert Zieba <robertzieba@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4345934 Reviewed-by: Al Semjonovs <asemjonovs@google.com> Reviewed-by: Diana Z <dzigterman@chromium.org>