summaryrefslogtreecommitdiff
path: root/zephyr/emul
Commit message (Collapse)AuthorAgeFilesLines
* zephyr: emul: update EMUL_DT_INST_DEFINE API usageFabio Baltieri2023-01-2718-18/+20
| | | | | | | | | | | | | | | | | Update various instances of the EMUL_DT_INST_DEFINE to set the extra argument introduced in: 6062914cf2 emul: Add support for backend APIs BRANCH=none BUG=none TEST=./twister Cq-Depend: chromium:4200298 Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com> Change-Id: I2bcec5786e78840fd552dcbde1b50f6941a23f05 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4188744 Reviewed-by: Keith Short <keithshort@chromium.org>
* zephyr: make the test emulator's PD revision configurableJameson Thies2023-01-132-6/+9
| | | | | | | | | | | | | | | | This CL updates the tcpci partner emulator to have an internal variable define how it responds to Get_Revision, instead of hardcoding it's RMDO to 0x31000000 (USBPD 3.1). BUG=b:236868370 BRANCH=None TEST=./twister -p native_posix -p unit_testing Signed-off-by: Jameson Thies <jthies@google.com> Change-Id: Ib212383ce2a29c87f7284a971b2ad96cce6b68c6 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4159990 Reviewed-by: Abe Levkoy <alevkoy@chromium.org> Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com>
* zephyr: Test all ports for correct pd informationJason Yuan2023-01-131-0/+1
| | | | | | | | | | | | | | | | | pd_chip_info is tested for all ports instead of just port 0. BUG=b:261874683 TEST=twister BRANCH=none Change-Id: I338af9781539cd1fe325410d085593832f776120 Signed-off-by: Jason Yuan <jasonyuan@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4159971 Auto-Submit: zhi cheng yuan <jasonyuan@chromium.org> Tested-by: zhi cheng yuan <jasonyuan@chromium.org> Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com> Commit-Queue: Wai-Hong Tam <waihong@google.com> Reviewed-by: Wai-Hong Tam <waihong@google.com>
* zephyr: emul: add a voltage comparator mock driverFabio Baltieri2022-12-194-0/+149
| | | | | | | | | | | | | | | | Add a voltage comparator mock driver, this is meant to initially be used to test the adc power sequencing code. BRANCH=none BUG=none TEST=cq dry run TEST=./twister Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com> Change-Id: I3e9d9099d265b265486d1c9b9d60e618bb44ff31 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4111306 Reviewed-by: Al Semjonovs <asemjonovs@google.com> Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com>
* zephyr: mock: always include the include directoryFabio Baltieri2022-12-192-17/+17
| | | | | | | | | | | | | | | | | | | | | | | There's multiple emul drivers relying on include files, change the CMake include directive to always add that to the include search path. Fixes a build fail when PWM_MOCK is used but not EMUL_CROS_FLASH. Now though this ends up causing a collision since there's multiple flash_chip.h files in the system, one for every supported chip. Fix that by using a different name when running in NATIVE_POSIX, so that there's no ambiguity. Sort the build list while we are at it. BRANCH=none BUG=none TEST=cq dry run Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com> Change-Id: I9858ab3ccea2631ff7b3a22ef2d1c79b4dc73b25 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4111305 Reviewed-by: Abe Levkoy <alevkoy@chromium.org> Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com>
* zephyr: Sort remaining includesJeremy Bettis2022-11-291-3/+3
| | | | | | | | | | | | | | | | | | | | | | This is the last of the files in platform/ec. Sort all includes with the clang-format rules used by the zephyr project. BRANCH=None BUG=b:247100970 TEST=zmake build -a TEST=./twister --clobber -v -i TEST=make -j72 buildall_only runtests TEST=zmake compare-builds Signed-off-by: Jeremy Bettis <jbettis@google.com> Change-Id: I95e37e74d860cbb7c74ec478b543aef0b0e967e9 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4062620 Commit-Queue: Jeremy Bettis <jbettis@chromium.org> Reviewed-by: Sam Hurst <shurst@google.com> Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com> Tested-by: Jeremy Bettis <jbettis@chromium.org>
* zephyr: emul: select few more emulator config automaticallyFabio Baltieri2022-11-291-0/+4
| | | | | | | | | | | | | | | Select EMUL_BB_RETIMER and EMUL_PCT2075 when unit testing, drop the now unnecessary explicit settings. BRANCH=none BUG=none TEST=cq dry run Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com> Change-Id: Idda7529476de7bc1e5e2b7dade47c8322628f16d Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4055682 Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com> Reviewed-by: Al Semjonovs <asemjonovs@google.com>
* zephyr: emul: rename the binding to be consistentFabio Baltieri2022-11-299-12/+12
| | | | | | | | | | | | | | | | Zephyr uses a -emul suffix on all emulation bindings. Rename some of the EC emul bindings so that they are consistent with upstream and the other ones we already have. BRANCH=none BUG=none TEST=cq dry run Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com> Change-Id: I666b74bb243da10a79dd1d0da56028c2b142d360 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4047463 Reviewed-by: Yuval Peress <peress@google.com> Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com>
* zephyr: test: Add tests for USB_Enter/DATA_RESET messagesScott Collyer2022-11-291-0/+36
| | | | | | | | | | | | | | | | | | | | This CL adds support for USB_Enter and DATA_RESET messages to the tcpc emmulator. In addition it adds a test suite for USB4 mode. The usbc_tbt_mode test suite was used as a starting reference. BUG=b:260095516 BRANCH=none TEST=manual twister -c -v -i -s <path>/drivers/drivers.usbc_usb4_mode and verify that the tests pass. Signed-off-by: Scott Collyer <scollyer@google.com> Change-Id: I34e104a1e53b1540b20451fbd0631bbd9d42559b Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4029517 Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com> Commit-Queue: Scott Collyer <scollyer@chromium.org> Tested-by: Scott Collyer <scollyer@chromium.org> Reviewed-by: Abe Levkoy <alevkoy@chromium.org>
* zephyr: usb: enable pi3usb9201 driver and emulator automaticallyFabio Baltieri2022-11-231-0/+2
| | | | | | | | | | | | | | | | | Enable the PLATFORM_EC_BC12_DETECT_PI3USB9201 and EMUL_BC12_DETECT_PI3USB9201 based on the devicetree configuration. The two drivers use the same compatible so the emulator one is set so it can only be enabled in testing. BRANCH=none BUG=none TEST=cq dry run Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com> Change-Id: Id4438d2af72c46ecf5c47c2d347dfb8bb74a0a57 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4051187 Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com> Reviewed-by: Keith Short <keithshort@chromium.org>
* zephyr: tests, emul: add a bunch of automatic configsFabio Baltieri2022-11-232-0/+28
| | | | | | | | | | | | | | | | Rework various emul drivers to use an automatic Kconfig and drop few explicitly prj.conf entries, plus some that were already redundant from upstream. BRANCH=none BUG=none TEST=cq dry run Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com> Change-Id: I1e81e310248070dc619012f69663d044f329f249 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4047461 Reviewed-by: Keith Short <keithshort@chromium.org> Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com>
* zephyr emul: Add VPD partner extensionAbe Levkoy2022-11-233-0/+136
| | | | | | | | | | | | | | | | Add a USB PD partner emulator extension with the behavior of a VCONN-powered device. BUG=b:257341564 TEST=twister -s zephyr/test/drivers/drivers.default BRANCH=none Signed-off-by: Abe Levkoy <alevkoy@chromium.org> Change-Id: I9bce8bcecab238173cd55f202ba0debbfb9564c6 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4025833 Reviewed-by: Tomasz Michalec <tmichalec@google.com> Commit-Queue: Tomasz Michalec <tmichalec@google.com> Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com>
* zephyr emul: TCPC partner: Expose CC to extensionsAbe Levkoy2022-11-221-1/+28
| | | | | | | | | | | | | | | | | | | | | | Implement a callback in the TCPC partner common code for changes to control registers in the TCPCI TCPC emulator. Specifically, when the TCPC changes ROLE_CONTROL, record the new CC "voltages" exposed by the TCPC emulator in the partner emulator. Then call any partner extension callbacks for control changes. This change does not cause the partner to react to other changes to TCPCI control registers. BUG=b:257341564 TEST=twister -s zephyr/test/drivers/drivers.usbc_ctvpd BRANCH=none LOW_COVERAGE_REASON=This is an emulator. Later tests will use it. Signed-off-by: Abe Levkoy <alevkoy@chromium.org> Change-Id: Id27a156ed5db6d805c439a33a157ae13706d541a Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4043735 Reviewed-by: Tomasz Michalec <tmichalec@google.com> Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com>
* zephyr emul: TCPC partner: Support sending VCSAbe Levkoy2022-11-221-4/+54
| | | | | | | | | | | | | | | | Support sending VCONN Swap from the partner emulator. Respond to Accept with PS_RDY and enabled VCONN if it was disabled. BUG=b:257341564 TEST=twister -s zephyr/test/drivers/drivers.usbc_vconn_swap BRANCH=none LOW_COVERAGE_REASON=This is an emulator. Later CLs will use it. Signed-off-by: Abe Levkoy <alevkoy@chromium.org> Change-Id: I011a391a2d378a637f7d8cc624addd46c4b54736 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4025832 Reviewed-by: Tomasz Michalec <tmichalec@google.com> Code-Coverage: Jeremy Bettis <jbettis@chromium.org>
* test: emul_common_i2c: fix access fail logicKeith Short2022-11-221-20/+24
| | | | | | | | | | | | | | | | | | Calling i2c_common_emul_set_read_fail_reg() or i2c_common_emul_set_write_fail_reg() with an emulator that registers custom read/write routines doesn't' actually fail the transfer. Move the register checks before the custom user handler is invoked. BUG=none BRANCH=none TEST=twister Signed-off-by: Keith Short <keithshort@chromium.org> Change-Id: I7097e3204bc5e7e466fa1ca52f32516c4910158a Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4045149 Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com> Reviewed-by: Simon Glass <sjg@chromium.org>
* zephyr: Sort header filesJeremy Bettis2022-11-218-15/+8
| | | | | | | | | | | | | | | | | | | | Sort all headers in zephyr with the clang-format rules used by the zephyr project. BRANCH=None BUG=b:247100970 TEST=zmake build -a TEST=./twister --clobber -v -i TEST=make -j$(nproc) buildall_only runtests TEST=zmake compare-builds Signed-off-by: Jeremy Bettis <jbettis@google.com> Change-Id: Ic4431f9354cfb87b8357e6288f651aaef8a50f7f Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4043353 Reviewed-by: Simon Glass <sjg@chromium.org> Commit-Queue: Jeremy Bettis <jbettis@chromium.org> Tested-by: Jeremy Bettis <jbettis@chromium.org> Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com>
* zephyr: Manually reorder includesJeremy Bettis2022-11-219-18/+24
| | | | | | | | | | | | | | | | | | | Embedded comments or preprocessor directives confuse clang format, and it can't reorder the includes. Manually fix these files to put the headers in order. BRANCH=None BUG=b:247100970 TEST=CQ Signed-off-by: Jeremy Bettis <jbettis@google.com> Change-Id: Ie5e0ec55712aab6cbc5446b0f81c7b653846084a Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4032915 Tested-by: Jeremy Bettis <jbettis@chromium.org> Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com> Reviewed-by: Aaron Massey <aaronmassey@google.com> Commit-Queue: Jeremy Bettis <jbettis@chromium.org>
* zephyr/emul: Sort header filesJeremy Bettis2022-11-2132-205/+200
| | | | | | | | | | | | | | | | | | | | | Sort all headers in zephyr/test with the clang-format rules used by the zephyr project. BRANCH=None BUG=b:247100970 TEST=zmake build -a TEST=./twister --clobber -v -i TEST=make -j$(nproc) buildall_only runtests TEST=zmake compare-builds Signed-off-by: Jeremy Bettis <jbettis@google.com> Change-Id: I6d9671149004496a12937a4176e177e12b29dd68 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4024016 Auto-Submit: Jeremy Bettis <jbettis@chromium.org> Commit-Queue: Jeremy Bettis <jbettis@chromium.org> Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com> Tested-by: Jeremy Bettis <jbettis@chromium.org> Reviewed-by: Abe Levkoy <alevkoy@chromium.org>
* test: add tests for battery_fuel_gaugeYuval Peress2022-11-161-2/+4
| | | | | | | | | | | | | | | | | | | | - Add error handling tests for fuel gauge. - Add cutoff handling tests for fuel gauge. - Add tests for default implementation of the get_default_battery_type - Add tests for battery_sleep_fuel_gauge - Add tests for battery_is_charge_fet_disabled - Add tests for battery_get_disconnect_state BRANCH=none BUG=none TEST=twister Signed-off-by: Yuval Peress <peress@google.com> Change-Id: I87552b936184c6152c4be4a64bd42278ce5b5ca2 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4026562 Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com> Reviewed-by: Aaron Massey <aaronmassey@google.com>
* zephyr: tests: add pct2075 emulatorDawid Niedzwiecki2022-11-143-0/+115
| | | | | | | | | | | | | | | | | | | | Add PCT2075 temperature sensor emulator. The PCT2075 doesn't support the OS pin. The emulator helps with testing code that is touched only by i2c temperature sensors. BUG=b:244474857 BRANCH=main TEST=twister -T zephyr/test/drivers Signed-off-by: Dawid Niedzwiecki <dn@semihalf.com> Change-Id: Iaefed4ffd50b17b59da89361abeded28456751ec Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4020414 Commit-Queue: Keith Short <keithshort@chromium.org> Tested-by: Dawid Niedzwiecki <dawidn@google.com> Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com> Reviewed-by: Keith Short <keithshort@chromium.org>
* emul_pi3usb9201: Rename compatible stringKeith Short2022-11-111-1/+1
| | | | | | | | | | | | | | | | Rename the compatible string for the PI3USB9201 emulator to match the real driver. Also move all bc12 setup into the devicetree for tests. BUG=b:218331557 BRANCH=none TEST=twister Signed-off-by: Keith Short <keithshort@chromium.org> Change-Id: Iaf15fadf20b070033a474d395ae330b4f84e4f18 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4023768 Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com> Reviewed-by: Yuval Peress <peress@google.com> Reviewed-by: Abe Levkoy <alevkoy@chromium.org>
* emul_bb_retimer: Rename compatible stringKeith Short2022-11-111-5/+4
| | | | | | | | | | | | | | | | | Rename the compatible string for the BB retimer emulator to match the real driver. Also removed unneeded devicetree properties from the emulator devicetree node. BUG=b:239457738 BRANCH=none TEST=twister Signed-off-by: Keith Short <keithshort@chromium.org> Change-Id: I312129f5ffab9ba39394a3a2655d7ce3def5f9f0 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4023765 Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com> Reviewed-by: Yuval Peress <peress@google.com> Reviewed-by: Abe Levkoy <alevkoy@chromium.org>
* zephyr: fix misspelling of the analogix companyMichał Barnaś2022-10-281-1/+1
| | | | | | | | | | | | | | | The compatible string for driver and emulator were using the company name as anologix instead of analogix. BUG=b:251812799 BRANCH=main TEST=compile and check that proper compatible string is generated for the DT_HAS_ macro Change-Id: I9150243fb7451f0f721e169b1513aa5adad310e9 Signed-off-by: Michał Barnaś <mb@semihalf.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3982642 Reviewed-by: Jeremy Bettis <jbettis@chromium.org>
* zephyr/test: add tusb1064 usb mux emulatorlschyi2022-10-203-0/+116
| | | | | | | | | | | | | | | | | Implemented tusb1064 usb mux emulator with basic i2c read/write, and export peek reg functions. BUG=b:229340646 TEST=none BRANCH=none Signed-off-by: lschyi <lschyi@google.com> Change-Id: Ie91c216a6d1fb9ffc1decbb07c2b082b02bf8cda Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3965888 Reviewed-by: Ting Shen <phoenixshen@chromium.org> Tested-by: Sung-Chi Li <lschyi@chromium.org> Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com> Commit-Queue: Sung-Chi Li <lschyi@chromium.org>
* tree: Enable warning for fallthrough in switch statementsTom Hughes2022-10-194-12/+19
| | | | | | | | | | | | | | | | | | | | | | | The EC code has generally been good about adding comments about intentional fallthrough in switch statements, but there were a few cases without comments (e.g., https://crrev.com/c/3949622). Enabling -Wimplicit-fallthrough generates a compiler warning if the fallthrough is not annotated with __attribute__((fallthrough)). For convenience, we add a "__fallthrough" macro for this attribute. See https://clang.llvm.org/docs/AttributeReference.html#fallthrough and https://gcc.gnu.org/onlinedocs/gcc/Statement-Attributes.html. BRANCH=none BUG=b:253644823 TEST=make buildall LOW_COVERAGE_REASON=legacy code Signed-off-by: Tom Hughes <tomhughes@chromium.org> Change-Id: I9f4d6049f4507a25ce706675d159b70e28b4b825 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3957420 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org> Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com>
* zephyr: emul: ps8xxx: Add REG_ID registerSam Hurst2022-10-141-0/+20
| | | | | | | | | | | | | | | | | Add REG_ID Register used to distinguish between the PS8745 and PS8815 chips BUG=None TEST=./twister -T zephyr/test/drivers BRANCH=None Signed-off-by: Sam Hurst <shurst@google.com> Change-Id: Ib7ed8f7d5c3dc4d978342fabfb1046b1e531d82e Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3950209 Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com> Commit-Queue: Keith Short <keithshort@chromium.org> Reviewed-by: Keith Short <keithshort@chromium.org> Code-Coverage: Keith Short <keithshort@chromium.org>
* PD partner emul: Optional VCONN supportAbe Levkoy2022-10-141-0/+13
| | | | | | | | | | | | | | | | In the PD partner emulator, allow users to disable support for sourcing VCONN. Support the VCONN_Swap -> Not_Supported message flow when VCONN is not supported. BUG=b:251485312 TEST=./twister -T test/zephyr BRANCH=none Signed-off-by: Abe Levkoy <alevkoy@chromium.org> Change-Id: I833fb3927fd999bf81dcc0cd0aea3697db1346c0 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3949578 Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com> Reviewed-by: Tomasz Michalec <tmichalec@google.com>
* zephyr test: Initialize partner VCONN roleAbe Levkoy2022-10-141-1/+2
| | | | | | | | | | | | | | | After a Hard Reset and when initializing a PD partner emulator structure, set the VCONN role to be consistent with the power role. BUG=none TEST=twister -T zephyr/test BRANCH=none Signed-off-by: Abe Levkoy <alevkoy@chromium.org> Change-Id: I6545d5febbbf6cd66fc8b9f17b5a3310f31772c7 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3949572 Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com> Reviewed-by: Tomasz Michalec <tmichalec@google.com>
* test: shim rtc EC_CMD_RTC_SET_ALARM hostcmdAaron Massey2022-10-101-0/+4
| | | | | | | | | | | | | | | Add test that verifies setting an rtc alarm when fired will invoke the initialized rtc callback function and accompanying host_event. BRANCH=none BUG=b:236160570 TEST=twister --clobber -i -s zephyr/test/drivers/drivers.shim_rtc Signed-off-by: Aaron Massey <aaronmassey@google.com> Change-Id: I2a4aa421418a16944ffa8e452f8a297c000b7367 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3939609 Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com> Reviewed-by: Keith Short <keithshort@chromium.org>
* test: shim rtc RTC_GET/SET_VALUE host commandsAaron Massey2022-10-061-0/+2
| | | | | | | | | | | | | | | | | | | | Verify the EC_CMD_RTC_GET/SET_VALUE host commands by setting the value to two different arbitrary values via the SET host command and subsequently retrieving these values via the GET host command. Also adds a new test-binary under the drivers tests for shim rtc code. BRANCH=none BUG=b:236161110 BUG=b:236160901 TEST=twister --clobber -i -s zephyr/test/drivers/drivers.shim_rtc Signed-off-by: Aaron Massey <aaronmassey@google.com> Change-Id: I8b843c15d7f73e6905caccfec5a3ee5046bbfff8 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3938407 Reviewed-by: Wai-Hong Tam <waihong@google.com> Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com> Commit-Queue: Wai-Hong Tam <waihong@google.com>
* zephyr: add anx7447 emulatorlschyi2022-10-053-0/+175
| | | | | | | | | | | | | | | | | Add basic ANX7447 TCPC emulator, along with KConfig option, dts binding, and can be found in the TCPC shim code. BUG=b:244232583 TEST=none BRANCH=none Signed-off-by: lschyi <lschyi@google.com> Change-Id: Idac771d92de526abf0796015fab6d473dae5502e Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3905448 Reviewed-by: Jeremy Bettis <jbettis@chromium.org> Commit-Queue: Sung-Chi Li <lschyi@chromium.org> Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com> Tested-by: Sung-Chi Li <lschyi@chromium.org>
* zephyr: test: add rt9490 charger testTing Shen2022-09-221-0/+15
| | | | | | | | | | | | | | BUG=b:244233556 TEST=./twister -T zephyr/test/drivers/ BRANCH=none Signed-off-by: Ting Shen <phoenixshen@google.com> Change-Id: I867929b5cde1ce65311d15af851dc4815d1c248e Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3895196 Reviewed-by: Jeremy Bettis <jbettis@chromium.org> Commit-Queue: Ting Shen <phoenixshen@chromium.org> Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com> Tested-by: Ting Shen <phoenixshen@chromium.org>
* emul_smart_battery: Validate string property sizesAaron Massey2022-09-211-0/+8
| | | | | | | | | | | | | | | | | Add BUILD_ASSERTs to enforce that strings of sizes larger than MAX_BLOCK_SIZE cannot be properties of the DT node that the emul_smart_battery is emulating. BRANCH=none BUG=b:246652125 TEST=./twister --clobber -i -s zephyr/test/drivers/drivers.default -b TEST=Above TEST with failing string property Signed-off-by: Aaron Massey <aaronmassey@google.com> Change-Id: I5c44be1bfd1ff183a5357ea947285662d467fffc Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3910903 Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com> Reviewed-by: Keith Short <keithshort@chromium.org>
* test: virtual_battery: Manufacture Info SB ext cmdAaron Massey2022-09-211-0/+7
| | | | | | | | | | | | | | | Verify the virtual_battery code appropriately responds to a manufacture info extended smart battery spec command. BRANCH=none BUG=b:246652125 TEST=./twister --clobber -i -s zephyr/test/drivers/drivers.default Signed-off-by: Aaron Massey <aaronmassey@google.com> Change-Id: Ibc316a052b26364110b7b8a3712af1ce466cc8f4 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3905884 Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com> Reviewed-by: Keith Short <keithshort@chromium.org>
* test: Rest of standard SBS virtual_battery cmdsAaron Massey2022-09-201-0/+2
| | | | | | | | | | | | | | | | | | | | | Some of the SBS read commands had not been tested via the virtual battery interface. Verify read commands for: Battery Status Design Voltage Manufacturer Data BRANCH=none BUG=b:246652125 TEST=./twister --clobber -i -s zephyr/test/drivers/drivers.default Signed-off-by: Aaron Massey <aaronmassey@google.com> Change-Id: Iaeecf912dc965ee2479e42fd7a2650f011af2dc6 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3902457 Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com> Reviewed-by: Wai-Hong Tam <waihong@google.com>
* zephyr: emul_rt9490: fix incorrect multibyte IO implementationTing Shen2022-09-201-4/+6
| | | | | | | | | | | | | | | | | | | | When performing multibyte IO, the `reg` parameter means the first byte of this IO operation, it won't increase during consecutive read/write operations. The actual byte to access is offsetted by the `bytes` parameter. BUG=none TEST=pass all tests BRANCH=none Signed-off-by: Ting Shen <phoenixshen@google.com> Change-Id: I15c046fcfb8dbcc05f260bd929da32b7d86a3c90 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3896554 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: Eric Yilun Lin <yllin@google.com>
* zephyr: pwm_mock: Add support for PWM flags to mock PWM driverTristan Honscheid2022-09-162-0/+23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The upstream Zephyr PWM API supports passing extra flags to control PWM polarity and this feature is used in our keyboard backlight PWM driver. However, our internal PWM mock/emul doesn't support specifying flags in the device tree. This CL adds support for this. * Add a "flags" cell to cros,pwm-mock * Update references in the device tree to pass the default flag of PWM_POLARITY_NORMAL. Since this only affects the PWM mock, this was limited in scope to our test code, specifically `zephyr/test/drivers/boards/native_posix.overlay` * Update the PWM mock to store the passed flags in its state struct and add a getter function. To make use of the updated PWM mock for an upcoming test suite covering `common/keyboard_backlight.c`, I also: * Add a keyboard backlight driver to the device tree * Enable CONFIG_PWM_MOCK for all driver tests, as required by the above backlight driver. BRANCH=None BUG=None TEST=./twister LOW_COVERAGE_REASON=Minor upgrade (~6 SLOC) to an emulator Signed-off-by: Tristan Honscheid <honscheid@google.com> Change-Id: I6abb6aba8b7ab4f2185c2ef28868767f95f79af2 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3893395 Reviewed-by: Keith Short <keithshort@chromium.org> Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com> Code-Coverage: Jeremy Bettis <jbettis@chromium.org>
* Update license boilerplate text in source code filesMike Frysinger2022-09-1241-41/+41
| | | | | | | | | | | | | | | Normally we don't do this, but enough changes have accumulated that we're doing a tree-wide one-off update of the name & style. BRANCH=none BUG=chromium:1098010 TEST=`repo upload` works Change-Id: Icd3a1723c20595356af83d190b2c6a9078b3013b Signed-off-by: Mike Frysinger <vapier@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3891203 Reviewed-by: Jeremy Bettis <jbettis@chromium.org> Reviewed-by: Jack Rosenthal <jrosenth@chromium.org>
* zephyr: Move the fake system functions into their own fileSimon Glass2022-09-102-25/+1
| | | | | | | | | | | | | | | | | | Move this out of the flash emulator so we can add to it and use it from other tests. Put it in a new 'fake' subdirectory, since we don't seem to have of this sort of thing yet. BUG=b:243982872 BRANCH=none TEST=./twister -c -T zephyr/test/drivers/ Signed-off-by: Simon Glass <sjg@chromium.org> Change-Id: Ia4cd3b10e2f38dbacadf0d20198be8f9bbc026e3 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3883773 Reviewed-by: Aaron Massey <aaronmassey@google.com> Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com>
* zephyr: Create RTC emulatorAl Semjonovs2022-09-083-0/+145
| | | | | | | | | | | | | | Emulate RTC driver BUG=b:236074639 BRANCH=NONE TEST=./twister -T zephyr/test Signed-off-by: Al Semjonovs <asemjonovs@google.com> Change-Id: Ib1073c0e30c0c39d8e778c228a89cc9b6638c887 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3880865 Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com> Reviewed-by: Tomasz Michalec <tmichalec@google.com>
* zephyr: Replace deprecated zephyr.h with kernel.hAaron Massey2022-09-085-5/+5
| | | | | | | | | | | | | | | | | | The zephyr.h header has been formally deprecated upstream thus causing a build failure when downstreaming. Replace zephyr.h with kernel.h BRANCH=none BUG=none TEST=zmake build -a Signed-off-by: Aaron Massey <aaronmassey@google.com> Change-Id: I0e6095160ab7248edde00f5c8336bc8d01c6b937 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3885035 Reviewed-by: Keith Short <keithshort@chromium.org> Reviewed-by: Al Semjonovs <asemjonovs@google.com> Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com>
* zephyr/test: add rt9490 charger emulatorTing Shen2022-09-063-0/+113
| | | | | | | | | | | | | | | | Implemented a rt9490 charger emulator with basic i2c read/write, and extra peek/reset reg functions BUG=b:244233556,b:243841599 TEST=tested with CL:3873241 BRANCH=none Signed-off-by: Ting Shen <phoenixshen@google.com> Change-Id: I87b77cf2b0bc0a0d89f2f76353e16b9296dc5596 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3873240 Tested-by: Ting Shen <phoenixshen@chromium.org> Commit-Queue: Ting Shen <phoenixshen@chromium.org> Reviewed-by: Jeremy Bettis <jbettis@chromium.org>
* zephyr: Add new test for vboot efs2Jeremy Bettis2022-08-291-1/+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 emul: Generalize ExitModeDiana Z2022-08-271-12/+23
| | | | | | | | | | | | | | | | Allow ExitMode to take place with any SVID sent if we've ACK'd an EnterMode of that SVID. BRANCH=None BUG=b:243151272 TEST=./twister -T ./zephyr/test Signed-off-by: Diana Z <dzigterman@chromium.org> Change-Id: Iec3dec1900dba54d13d7a4bbe50078b547d4a1f8 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3859564 Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com> Commit-Queue: Abe Levkoy <alevkoy@chromium.org> Reviewed-by: Abe Levkoy <alevkoy@chromium.org>
* Zephyr emul: Generalize mode entry responseDiana Z2022-08-271-9/+9
| | | | | | | | | | | | | | | | | Generalize the fields for mode entry so they can be used for modes besides DP as well. BRANCH=None BUG=b:243151272 TEST=./twister -T ./zephyr/test Signed-off-by: Diana Z <dzigterman@chromium.org> Change-Id: Idf2ce813cbcfcf730042a1d55b1de63425fbc824 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3859561 Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com> Reviewed-by: Keith Short <keithshort@chromium.org> Commit-Queue: Abe Levkoy <alevkoy@chromium.org> Reviewed-by: Abe Levkoy <alevkoy@chromium.org>
* Zephyr emul: Add cable supportDiana Z2022-08-272-21/+140
| | | | | | | | | | | | | | | | | Add support for the cable replying to messages for unit testing. For the first level of support, only reply to DiscoverIdentity (response for a cable with no alternate mode support). BRANCH=None BUG=b:243151272 TEST=./twister -T ./zephyr/test Signed-off-by: Diana Z <dzigterman@chromium.org> Change-Id: I731e0aad35a1d4bc07be75378df1f272d0eef525 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3859560 Commit-Queue: Abe Levkoy <alevkoy@chromium.org> Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com> Reviewed-by: Abe Levkoy <alevkoy@chromium.org>
* Zephyr emul: Clarify TCPCI message typeDiana Z2022-08-262-9/+9
| | | | | | | | | | | | | | | | | Both the TCPCI emulator and the partner emulator have message structures with a member named "type". Re-name the TCPCI "type" to reduce confusion when the code references msg->type in both files. BRANCH=None BUG=b:243151272 TEST=./twister -T ./zephyr/test Signed-off-by: Diana Z <dzigterman@chromium.org> Change-Id: I600e8b046a701f53f21157a15d5073a127209076 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3859559 Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com> Commit-Queue: Keith Short <keithshort@chromium.org> Reviewed-by: Keith Short <keithshort@chromium.org>
* zephyr: remove label usage from i2c_mock emulatorKeith Short2022-08-261-1/+1
| | | | | | | | | | | | | | Remove all devicetree label usage from the i2c_mock emulator. BUG=b:239165779 BRANCH=none TEST=./twister --clobber Signed-off-by: Keith Short <keithshort@chromium.org> Change-Id: Iece16f5aa8ff48e280db4487f38b776554556174 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3855428 Reviewed-by: Aaron Massey <aaronmassey@google.com> Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com>
* zephyr: remove label usage from sn5s330 emulatorKeith Short2022-08-261-1/+1
| | | | | | | | | | | | | | Remove all devicetree label usage from the sn5s330 emulator. BUG=b:239165779 BRANCH=none TEST=./twister --clobber Signed-off-by: Keith Short <keithshort@chromium.org> Change-Id: I9f30cb5ba28b85d1cef1a838327a4ff599e28506 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3855427 Reviewed-by: Tristan Honscheid <honscheid@google.com> Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com>
* zephyr: remove label usage from lis2dw12 emulatorKeith Short2022-08-261-1/+1
| | | | | | | | | | | | | | Remove all devicetree label usage from the lis2dw12 emulator. BUG=b:239165779 BRANCH=none TEST=./twister --clobber Signed-off-by: Keith Short <keithshort@chromium.org> Change-Id: Ice425e988f1d39e1eb3293c1ac1e9ff97de174d6 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3855426 Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com> Reviewed-by: Jeremy Bettis <jbettis@chromium.org>