summaryrefslogtreecommitdiff
path: root/zephyr/shim/src
Commit message (Collapse)AuthorAgeFilesLines
* console: Optionally drop output from ISRsstabilize-15317.B-mainAndrew McRae2023-01-171-3/+9
| | | | | | | | | | | | | | | | Optionally drop console output originating from interrupt level, to avoid printk locking up the EC for any length of time. BUG=b:265594963 TEST=Verify that logs from ISRs are not printed. BRANCH=none Change-Id: Ib6241d66bb3ec518439b46860804d928fd3fcfdf Signed-off-by: Andrew McRae <amcrae@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4165986 Reviewed-by: Peter Marheine <pmarheine@chromium.org> Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com>
* flash: allow zero num_banks_desc in flash_info requestTing Shen2023-01-161-3/+0
| | | | | | | | | | | | | | | | | | | | | | | Some external tools (e.g. flashrom) sends EC_CMD_FLASH_INFO with num_banks_desc=0 to get the total number of banks. EC should allow this type of request. Also add a test to cover this use case. BUG=b:265472751 TEST=1) `flashrom -p ec -w <ec.bin>` on tentacruel 2) ./twister -T zephyr/test/drivers/ \ --sub-test drivers.flash.page_layout 3) ./twister -T zephyr/test/drivers/ --sub-test drivers.flash BRANCH=none Change-Id: Iab97ac754bac87067f949cf9435156be91b07ebc Signed-off-by: Ting Shen <phoenixshen@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4167539 Tested-by: Chen-Tsung Hsieh <chentsung@chromium.org> Reviewed-by: Patryk Duda <patrykd@google.com> Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com> Commit-Queue: Patryk Duda <patrykd@google.com>
* shim/bc12_rt9490: fix compatibleDino Li2023-01-121-2/+2
| | | | | | | | | | | | | | | Correct shim code since both yaml and dtsi compatibility are "richtek,rt9490". BRANCH=none BUG=none TEST=The rt9490_interrupt isr is registered correctly. Change-Id: Idb1e3d19060852514ba98a513f2f5f34cbda5bc3 Signed-off-by: Dino Li <Dino.Li@ite.com.tw> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4154450 Reviewed-by: Ting Shen <phoenixshen@chromium.org> Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com>
* shim/src/flash: Add functions for providing flash sectors infoPatryk Duda2023-01-111-0/+182
| | | | | | | | | | | | | | | | | | | | | Introduce Zephyr counterparts of functions that provide information about flash sectors, total number of sectors, size of array to describe sector types, etc. These functions use Zephyr flash pages API. To use functions, enable PLATFORM_EC_USE_ZEPHYR_FLASH_PAGE_LAYOUT config. BUG=b:239712345 BRANCH=none TEST=zmake build -a --clobber Signed-off-by: Patryk Duda <pdk@semihalf.com> Change-Id: I9ee9a8f36401e4643adfa150c745ba502b72c36a Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4030378 Tested-by: Patryk Duda <patrykd@google.com> Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com> Reviewed-by: Keith Short <keithshort@chromium.org> Commit-Queue: Patryk Duda <patrykd@google.com>
* voltorb: add two properties in LED policy led-colors nodeSiyu Qin2023-01-051-0/+18
| | | | | | | | | | | | | | | | | | | According to OEM requirement, the LED color depends on battery state. Add batt-state-mask and batt-state to distinguish battery charging and discharging when AC is on. BUG=b:260546013 BRANCH=corsola TEST=1. When AC on and battery is charging, then LED is amber. 2. When AC on and battery is discharging, then LED is blue. Change-Id: I685a60f43262e4e41aa4cd5879905ac3e4ddc6ee Signed-off-by: Siyu Qin <qinsiyu@huaqin.corp-partner.google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4078724 Reviewed-by: Jeremy Bettis <jbettis@chromium.org> Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com> Reviewed-by: Ting Shen <phoenixshen@chromium.org> Reviewed-by: Mike Lee <mike5@huaqin.corp-partner.google.com>
* cbi: Check CBI WP latch as well as GSC EEPROM WPAndrew McRae2023-01-041-0/+5
| | | | | | | | | | | | | | | | If CONFIG_PLATFORM_EC_EEPROM_CBI_WP is set, check whether gp_cbi_wp has been set to verify whether EEPROM is write protected or not. BUG=b:264209013 TEST=Verify that cbi write works on Nirwen for unlocked system. BRANCH=none Change-Id: I06d587675ed2b168a38533c851d9b7a650054dbd Signed-off-by: Andrew McRae <amcrae@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4134864 Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com> Reviewed-by: Keith Short <keithshort@chromium.org>
* tree: Replace "unsigned" with "unsigned int"Andrea Grandi2023-01-041-1/+1
| | | | | | | | | | | | | | | | | Fix checkpatch error: > Prefer 'unsigned int' to bare use of 'unsigned' BUG=b:262047616 TEST=./util/compare_build.sh -b all -j 120 => MATCH BRANCH=none Change-Id: Ibf82332a1e1ea0a0a03d3993336e24883e495e05 Signed-off-by: Andrea Grandi <agrandi@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4126483 Reviewed-by: Tom Hughes <tomhughes@chromium.org> Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com>
* zephyr: named-gpios: remove DT_PATH usagesFabio Baltieri2023-01-031-4/+4
| | | | | | | | | | | | | | | | Replace a bunch of DT_PATH usages with some common macros to access the named-gpios node based on the DT compatible. BRANCH=none BUG=none TEST=cq dry run TEST=zmake compare-builds -a Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com> Change-Id: Ib99820051b5a55b68915e3b29071ee5f7e45ebfb Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4114286 Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com> Reviewed-by: Tristan Honscheid <honscheid@google.com>
* zephyr: shim: shim SHA256 API to adapot HW accelerator driverJun Lin2022-12-292-0/+140
| | | | | | | | | | | | | | | | | | | | | | | | Wrap Zephyr crypto_sha* driver APIs to meet the interface of Cros-EC SHA256 APIs. This CL has dependency on PR: https://github.com/zephyrproject-rtos/zephyr/pull/53031 BRANCH=none BUG=b:155771688 TEST=keep the same RW image; flash different RO images with/without hardware accelerator; verify the RW hash value is the same in the console message. TEST=in the test CL; move test patterns in test/sha256.c to zephyr/program/npcx_evb/npcx9/src/test_sha256.c; pass all test patterns. Signed-off-by: Jun Lin <CHLin56@nuvoton.com> Change-Id: I3979c088933d2caa09576f4aacc14d2ffb6f73f6 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4116105 Reviewed-by: Fabio Baltieri <fabiobaltieri@google.com> Tested-by: CH Lin <chlin56@nuvoton.com> Commit-Queue: CH Lin <chlin56@nuvoton.com> Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com>
* shim/src/gpio: Add save/restore GPIO controller port configure functionJosh-Tsai2022-12-281-0/+40
| | | | | | | | | | | | | | | | | | | | | | We need to save the IO expander GPIO status before the device reset, and restore the status after the device is reset completely. create the function to save and restore the port configure BRANCH=None BUG=b:260534665 TEST=zmake build winterhold TEST=IO expander GPIOs status will not clear after tcpc reset TEST=./twister -v -i --coverage -p native_posix -p unit_testing -s external/platform/ec/zephyr/test/drivers/drivers.default Change-Id: Ic35e7e412792a56fde670de252887a9bdb557b36 Signed-off-by: Josh-Tsai <josh_tsai@compal.corp-partner.google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4115054 Reviewed-by: Elthan Huang <elthan_huang@compal.corp-partner.google.com> Reviewed-by: Keith Short <keithshort@chromium.org> Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com> Commit-Queue: Keith Short <keithshort@chromium.org>
* zephyr: ec-console: remove DT_PATH usagesFabio Baltieri2022-12-231-5/+10
| | | | | | | | | | | | | | | | Use a compatible lookup to find the ec-console node, add check for duplicate nodes, drop a redundant explicit setting (it defaults to y). BRANCH=none BUG=none TEST=cq dry run TEST=zmake compare-builds -a Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com> Change-Id: Ie2920843e2315a866bb0244b86bfd1e2d5d24b5b Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4116775 Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com> Reviewed-by: Al Semjonovs <asemjonovs@google.com>
* zephyr: gpio_id: replace DT_PATH with the node pathFabio Baltieri2022-12-231-4/+4
| | | | | | | | | | | | | | | There was already a #define with the node path, may as well use it. BRANCH=none BUG=none TEST=cq dry run TEST=zmake compare-builds -a Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com> Change-Id: I69cb8d14de3b0b39e72c148797e79ba84d9733cb Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4116774 Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com> Reviewed-by: Keith Short <keithshort@chromium.org>
* zephyr: named-i2c-ports: remove DT_PATH usagesFabio Baltieri2022-12-231-3/+3
| | | | | | | | | | | | | | | | Replace a bunch of DT_PATH usages with some common macros to access the named-i2c-ports node based on the DT compatible. BRANCH=none BUG=none TEST=cq dry run TEST=zmake compare-builds -a Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com> Change-Id: I2a817fda86b83811cd3d37abeca83048ea9b9eb7 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4116773 Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com> Reviewed-by: Aaron Massey <aaronmassey@google.com>
* rex: fan: Add fan_init method to check if fan is present from CBIMadhurima Paruchuri2022-12-211-2/+2
| | | | | | | | | | | | | | | | | | | fan_init method is reading FW_FAN value from CBI and deciding if fan in present for the board. The FW_FAN value is starting at bit 0 and of size 1. FW_FAN start and size values will be updated in future when CBI is used in Rex to make decisions as per information it need to support. BUG=b:244870433 BRANCH=none TEST=zmake build rex --clobber && ./twister -T zephyr/test/rex -i --coverage --clobber Change-Id: I6aa325453dca497d85099617ab20a3ddb9a08ace Signed-off-by: Madhurima Paruchuri <mparuchuri@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4111889 Reviewed-by: Fabio Baltieri <fabiobaltieri@google.com> Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com>
* zephyr: bbram: unify bbram access macrosFabio Baltieri2022-12-211-29/+21
| | | | | | | | | | | | | | | | Unify the various bbram check/size/offset macro implementation into a common set of macros, getting rid of DT_PATH usages in the process. BRANCH=none BUG=none TEST=cq dry run TEST=zmake compare-builds -a Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com> Change-Id: Ib698a6c7236d327b761190aeac9d55daa9032a89 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4114285 Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com> Reviewed-by: Jeremy Bettis <jbettis@chromium.org>
* panic: Publish EC_HOST_EVENT_PANIC on panicRob Barnes2022-12-201-0/+4
| | | | | | | | | | | | | | | | | | | Publish EC_HOST_EVENT_PANIC when a panic occurs. The kernel may use this event to clean up before the system is reset (e.g. sync the drive). This will be a no-op if the kernel doesn't handle it. BUG=b:258195448 BRANCH=None TEST=Observe event in kernel. Pass panic_event unit test. Change-Id: I34b9847778bf17dd113e81158bbbdf999ad2ca33 Signed-off-by: Rob Barnes <robbarnes@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4063818 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org> Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com>
* zephyr: adc: add a dedicated NAMED_ADC_CHANNELS optionFabio Baltieri2022-12-192-7/+1
| | | | | | | | | | | | | | | | | | | | | Add a dedicated NAMED_ADC_CHANNELS option to decouple the platforms setting from the Zephyr ADC one. This allows running tests for code that uses only the Zephyr APIs without having to define named channels as well. Also allows dropping some #if guards that made no sense since they were guarding a data structure used outside of the guard. BRANCH=none BUG=none TEST=cq dry run TEST=zmake compare-builds -a Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com> Change-Id: I4193a8c41d3bfd684ec03407eee57660aba2c56c Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4111644 Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com> Reviewed-by: Sam Hurst <shurst@google.com>
* zephyr: add more watchdog pre-warning messageRuibin Chang2022-12-081-1/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When watchdog pre-warning interrupt is fired, we print mepc and thread name information for debug. LOW_COVERAGE_REASON=chip-specific branches BUG=b:257861373 BRANCH=none TEST=on nereid, console cmd "waitms 2600" WDT pre-warning MEPC:0x800195e0 THREAD_NAME:PD_C0 WDT pre-warning MEPC:0x80034ca2 THREAD_NAME:PD_C0 WDT pre-warning MEPC:0x80038086 THREAD_NAME:shell_uart WDT pre-warning MEPC:0x8003515a THREAD_NAME:CHARGER WDT pre-warning MEPC:0x80038080 THREAD_NAME:shell_uart WDT pre-warning MEPC:0x80038086 THREAD_NAME:shell_uart WDT pre-warning MEPC:0x80038086 THREAD_NAME:shell_uart WDT pre-warning MEPC:0x80038086 THREAD_NAME:shell_uart WDT pre-warning MEPC:0x8003a47a THREAD_NAME:KEYSCAN WDT pre-warning MEPC:0x80038086 THREAD_NAME:shell_uart WDT pre-warning MEPC:0x80038cc8 THREAD_NAME:CHARGER WDT pre-warning MEPC:0x80039474 THREAD_NAME:CHARGER WDT pre-warning MEPC:0x80038086 THREAD_NAME:shell_uart WDT pre-warning MEPC:0x80038086 THREAD_NAME:shell_uart WDT pre-warning MEPC:0x80038080 THREAD_NAME:shell_uart WDT pre-warning MEPC:0x80038086 THREAD_NAME:shell_uart *** Booting Zephyr OS build v2.7.99-16068-gda4e077ab56e *** Change-Id: Ie4fe2aa4f4f6dde2efeb332166a9272b1c362855 Signed-off-by: Ruibin Chang <Ruibin.Chang@ite.com.tw> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4054759 Reviewed-by: Keith Short <keithshort@chromium.org> Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com> Reviewed-by: Peter Marheine <pmarheine@chromium.org>
* battery: Send manufacturer access by the SMB block protocoljohnwc_yeh2022-12-081-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | MAC commands are sent via AlternateManufacturerAccess() by the SMB block protocol. The result is returned on AlternateManufacturerAccess() via an SMB block read. Ex: Read OperationStatus(0x0054) via AlternateManufacturerAccess(). 1. Send OperationStatus() to AlternateManufacturerAccess() a. SMB block write. Command = 0x44. Data sent = 54 00 (data must be sent in little endian). 2. Read the result from AlternateManufacturerAccess(). a. SMB block read. Command = 0x44. Data read = 54 00 07 03 40 40 b. The first 2 bytes 54 00, is the MAC command. c. The second 2 bytes 07 03, is the Operation Status returning in little endian, that LSB(bit15-bit0) is 0x0307. LOW_COVERAGE_REASON=support write block protocol for mfgacc_support BUG=b:255517119 BRANCH=none TEST=ectool i2cxfer 2 0x0b 0 0x44 0x02 0x54 0x00 Write successful. ectool i2cxfer 2 0x0b 7 0x44 Read bytes: 0x6 0x54 00 0x7 0x3 0x40 0x40 Signed-off-by: johnwc_yeh <johnwc_yeh@compal.corp-partner.google.com> Change-Id: I3f247e47506d04e8fc307fc5274492196947c943 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3980695 Reviewed-by: Diana Z <dzigterman@chromium.org> Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com> Reviewed-by: Elthan Huang <elthan_huang@compal.corp-partner.google.com>
* ec: Support logging system boot time infoRajesh Kumar2022-12-071-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This CL add support logging system boot time and hostcommand to get boot time info. EC logs elapsed time (in micro second) info since boot for different signal events,that can be used to calculate system boot time in cold boot and warm boot scenarios. Below are the events when EC logs time info ARAIL EC turns on A-RAIL RSMRST EC releases RSMRST# ESPIRST ESPIRST received PLTRST_LOW PLTRST# asserted PLTRST_HIGH PLTRST# deasserted EC_CUR_TIME EC current time cnt increments on every warm reboot and reset to 0 on cold reboot BUG=b:249163956 BRANCH=none TEST='ectool boottime' AP console command is used to fetch data 'reboot' on AP console to trigger warm reboot 'apshutdown' on EC console to trigger cold reboot Signed-off-by: Rajesh Kumar <rajesh3.kumar@intel.com> Change-Id: I47abe3f8a0b7ab43f2af11bf8387c006ba383020 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4081566 Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com> Tested-by: Li-Yu Yu <aaronyu@google.com> Reviewed-by: Boris Mittelberg <bmbm@google.com>
* system: Implement system safe modeRob Barnes2022-12-063-1/+92
| | | | | | | | | | | | | | | | | | | | | | Basic implementation of system safe mode recovery. System safe mode is a recovery mode that may be started after a fault/panic. It allows the AP to collect info about the fault and system state before the system resets This CL includes support for Zephyr EC and legacy CrOS EC BUG=b:249128225 BRANCH=None TEST=./twister -s external/platform/ec/zephyr/test/rw_safe_mode/rw_safe_mode.default Manually tested on skyrim Change-Id: I15139bb082011485b54e4ca7813839940bf5401a Signed-off-by: Rob Barnes <robbarnes@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4029604 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org> Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com>
* zephyr: move usbc interrupt handler to shimJason Yuan2022-12-051-0/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | various board specific TCPC interrupt handler have been moved into tcpc.c in shim. ports are now automatically configured from the i2c dts instead of hardcoded. this does not remove the handler binding from interrupts.dts or initialize the interrupt from the driver, which will be added in a followup CL. stub test handler in test/.../stubs.c has been removed and existing tests have been modified to use new tcpc driver. BUG=b:256996124 TEST=twister, usbc charging on lazor BRANCH=none Signed-off-by: Jason Yuan <jasonyuan@google.com> Change-Id: Iac05907f3c286f26329dac7f99730396d23b1166 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4024013 Commit-Queue: zhi cheng yuan <jasonyuan@chromium.org> Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com> Reviewed-by: Sam Hurst <shurst@google.com> Commit-Queue: Sam Hurst <shurst@google.com> Auto-Submit: zhi cheng yuan <jasonyuan@chromium.org> Tested-by: zhi cheng yuan <jasonyuan@chromium.org>
* Revert "ec: Support logging system boot time info"Piotr Pawliczek2022-12-031-7/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This reverts commit c8325ba18b9f4d5b1f3f3bc739e83d8f591308cf. Reason for revert: broke at least 9 cq builds (https://ci.chromium.org/ui/p/chromeos/builders/cq/cq-orchestrator/b8795833246203447793/overview) Original change's description: > ec: Support logging system boot time info > > This CL add support logging system boot time and hostcommand to get > boot time info. > EC logs elapsed time (in micro second) info since boot for different > signal events,that can be used to calculate system boot time in cold > boot and warm boot scenarios. > > Below are the events when EC logs time info > > ARAIL EC turns on A-RAIL > RSMRST EC releases RSMRST# > ESPIRST ESPIRST received > PLTRST_LOW PLTRST# asserted > PLTRST_HIGH PLTRST# deasserted > EC_CUR_TIME EC current time > cnt increments on every warm reboot and reset to 0 on > cold reboot > > BUG=b:249163956 > BRANCH=none > TEST='ectool boottime' AP console command is used to fetch data > 'reboot' on AP console to trigger warm reboot > 'apshutdown' on EC console to trigger cold reboot > > Signed-off-by: Rajesh Kumar <rajesh3.kumar@intel.com> > Change-Id: I15fedbde252e0452270ef0e3fd4391bf624169f1 > Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3794612 > Reviewed-by: Boris Mittelberg <bmbm@google.com> > Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com> Bug: b:249163956 Change-Id: Ie83026c4a3a38c3dd24522901233f06e03430a54 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4077335 Reviewed-by: Jonathon Murphy <jpmurphy@google.com> Commit-Queue: Piotr Pawliczek <pawliczek@chromium.org> Tested-by: Piotr Pawliczek <pawliczek@chromium.org>
* ec: Support logging system boot time infoRajesh Kumar2022-12-021-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This CL add support logging system boot time and hostcommand to get boot time info. EC logs elapsed time (in micro second) info since boot for different signal events,that can be used to calculate system boot time in cold boot and warm boot scenarios. Below are the events when EC logs time info ARAIL EC turns on A-RAIL RSMRST EC releases RSMRST# ESPIRST ESPIRST received PLTRST_LOW PLTRST# asserted PLTRST_HIGH PLTRST# deasserted EC_CUR_TIME EC current time cnt increments on every warm reboot and reset to 0 on cold reboot BUG=b:249163956 BRANCH=none TEST='ectool boottime' AP console command is used to fetch data 'reboot' on AP console to trigger warm reboot 'apshutdown' on EC console to trigger cold reboot Signed-off-by: Rajesh Kumar <rajesh3.kumar@intel.com> Change-Id: I15fedbde252e0452270ef0e3fd4391bf624169f1 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3794612 Reviewed-by: Boris Mittelberg <bmbm@google.com> Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com>
* ap_pwrseq: support blocking power-on if insufficient powerPeter Marheine2022-12-021-0/+28
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | This prevents the system from booting the AP if there's not enough power according to configuration. Although there is similar logic in the power button task, typical AP configuration is to boot directly after entry to S5, meaning both are needed: * From G3, this new path gates whether the system boots (matching similar logic in the legacy power sequencing code) by preventing transition to S5. * From S5 (as in after shutdown and not yet having gone to G3), the power button gates booting. BUG=b:234049176,b:242627237,b:260909787 TEST=On craask, modify MIN_POWER settings to prevent hibernate during testing and fake low battery; verify that an instrumented version of charge_prevent_power_on indicates that the battery is too low to boot, although the "factory override" still allows this DUT to boot (because hardware WP is off). BRANCH=nissa Change-Id: I9cce0817dec8ffb59c133dbe54e63037542e5e55 Signed-off-by: Peter Marheine <pmarheine@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4066722 Commit-Queue: Andrew McRae <amcrae@google.com> Tested-by: Andrew McRae <amcrae@google.com> Reviewed-by: Andrew McRae <amcrae@google.com> Code-Coverage: Andrew McRae <amcrae@google.com>
* zephyr: Remove CONFIG_PLATFORM_EC_WATCHDOGMark Hasemeyer2022-12-011-1/+1
| | | | | | | | | | | | | | | | | | | | Remove CONFIG_PLATFORM_EC_WATCHDOG. Use Zephyr's CONFIG_WATCHDOG option instead. BUG=b:217926701 BRANCH=none TEST=./twister -T zephyr/test/ TEST=zmake compare-builds -a TEST=emerge-drallion chromeos-ish && make BOARD=drallion_ish LOW_COVERAGE_REASON=watchdog_init test not yet implemented Signed-off-by: Mark Hasemeyer <markhas@google.com> Cq-Depend: chromium:4067356 Change-Id: I2b7578f6918cb3b0c4317492662ba3fc949f43e0 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4064392 Reviewed-by: Keith Short <keithshort@chromium.org> Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com> Reviewed-by: Aaron Massey <aaronmassey@google.com>
* zephyr: usb_muxes, bb_retimer: fix kconfig dependenciesFabio Baltieri2022-11-302-16/+0
| | | | | | | | | | | | | | | | Fix Kconfig dependencies for usb_muxes and bb_retimer_usb_mux so that we can safely drop the compiler guards and the source is included only if the necessary structures are defined. BRANCH=none BUG=none TEST=cq dry run Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com> Change-Id: I9ab501a81549ef10b6db7f221517ff7cce619a8f Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4054625 Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com> Reviewed-by: Jeremy Bettis <jbettis@chromium.org>
* console: Don't call console_buf_notify_chars from isrRob Barnes2022-11-301-1/+1
| | | | | | | | | | | | | | | | Check if in isr before calling uart_write_char in uart_write_char. console_buf_notify_chars attempts to acquire a mutex, which isn't allowed from an isr. BUG=None BRANCH=None TEST=Pass rw_safe_mode tests Change-Id: If5a5a4c99fae9342f2e1e3c1bf0c841e5490f692 Signed-off-by: Rob Barnes <robbarnes@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4065004 Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com> Reviewed-by: Jack Rosenthal <jrosenth@chromium.org>
* zephyr: rt9490: drop the compiler guardsFabio Baltieri2022-11-291-4/+0
| | | | | | | | | | | | | | | | | | bc12_rt9490.c is only being built if the driver or emulators are enabled, and the emulator defines both compatibles anyway, so it's not really needed. Also fix a dts syntax thing. BRANCH=none BUG=none TEST=cq dry run Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com> Change-Id: I622dbf07f74f52b5c3bdbe634c5c1bcd0774845e Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4054624 Reviewed-by: Sam Hurst <shurst@google.com> Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com>
* zephyr: Make Renesas RAA489000 TCPC chip available for Device TreeAdam Mills2022-11-251-0/+3
| | | | | | | | | | | | | | | | | Refactoring to make RAA489000 work with DT, adding the DT binding, modifying the TCPC shim to find the chip and compat. BUG=b:213963699 TEST=zmake build -a; BRANCH=main LOW_COVERAGE_REASON=Will be covered in Nissa future tests. Change-Id: I85b252a4292755a984db5b517037f26e1e9bbd61 Signed-off-by: Adam Mills <adamjmills@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4054312 Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com> Commit-Queue: Peter Marheine <pmarheine@chromium.org> Reviewed-by: Peter Marheine <pmarheine@chromium.org>
* zephyr: rt9490: merge charger and bc12 dt nodesTing Shen2022-11-241-1/+1
| | | | | | | | | | | | | | | | | | | | | | Devices that using rt9490 has a warning message during build: Warning (unique_unit_address_if_enabled): /soc/i2c@f01c40/rt9490-bc12@53: duplicate unit-address (also used in node /soc/i2c@f01c40/rt9490@53) Fix the warning by merging the two conflicting nodes. BUG=none TEST=manually verified on tentacruel BRANCH=none Signed-off-by: Ting Shen <phoenixshen@google.com> Change-Id: I098607b4c7321e4182b8ed37a229ee3ed2bfd973 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4010984 Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com> Auto-Submit: Ting Shen <phoenixshen@chromium.org> Commit-Queue: Eric Yilun Lin <yllin@google.com> Tested-by: Ting Shen <phoenixshen@chromium.org> Reviewed-by: Eric Yilun Lin <yllin@google.com>
* Revert "zephyr: Remove CONFIG_PLATFORM_EC_WATCHDOG"Keith Short2022-11-241-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This reverts commit e04250319d222ef8505d9111ba4f03eddcaf5521. Reason for revert: Breaks drallion builds. b:260270232 Original change's description: > zephyr: Remove CONFIG_PLATFORM_EC_WATCHDOG > > Remove CONFIG_PLATFORM_EC_WATCHDOG. Use Zephyr's CONFIG_WATCHDOG option > instead. > > BUG=b:217926701 > BRANCH=none > TEST=twister -T zephyr/test/ > TEST=zmake compare-builds -a > LOW_COVERAGE_REASON=watchdog_init test not yet implemented > > Signed-off-by: Mark Hasemeyer <markhas@google.com> > > Change-Id: I7d5fedfc72ed886f94a94df9d3db14224bc6fb75 > Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4050634 > Reviewed-by: Keith Short <keithshort@chromium.org> > Reviewed-by: Aaron Massey <aaronmassey@google.com> > Tested-by: Mark Hasemeyer <markhas@google.com> > Commit-Queue: Mark Hasemeyer <markhas@google.com> Bug: b:217926701 Change-Id: I01471b9544cc0792427b3ca6761fb07ee0432dc6 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4053682 Commit-Queue: Piotr Pawliczek <pawliczek@chromium.org> Commit-Queue: Keith Short <keithshort@chromium.org> Reviewed-by: Piotr Pawliczek <pawliczek@chromium.org> Tested-by: Keith Short <keithshort@chromium.org> Owners-Override: Piotr Pawliczek <pawliczek@chromium.org>
* zephyr: Remove CONFIG_PLATFORM_EC_WATCHDOGMark Hasemeyer2022-11-231-1/+1
| | | | | | | | | | | | | | | | | | | | Remove CONFIG_PLATFORM_EC_WATCHDOG. Use Zephyr's CONFIG_WATCHDOG option instead. BUG=b:217926701 BRANCH=none TEST=twister -T zephyr/test/ TEST=zmake compare-builds -a LOW_COVERAGE_REASON=watchdog_init test not yet implemented Signed-off-by: Mark Hasemeyer <markhas@google.com> Change-Id: I7d5fedfc72ed886f94a94df9d3db14224bc6fb75 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4050634 Reviewed-by: Keith Short <keithshort@chromium.org> Reviewed-by: Aaron Massey <aaronmassey@google.com> Tested-by: Mark Hasemeyer <markhas@google.com> Commit-Queue: Mark Hasemeyer <markhas@google.com>
* zephyr: leds: use INST macros for finding the device nodesFabio Baltieri2022-11-224-16/+24
| | | | | | | | | | | | | | | Use compatible and INST based macros to setup the LED nodes so that the driver does not depend on a specific path. BRANCH=none BUG=none TEST=cq dry run Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com> Change-Id: I6b8c929ecf5b02d5a44e70b5358943b215d76d1e Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4032163 Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com> Reviewed-by: Jeremy Bettis <jbettis@chromium.org>
* zephyr: kblight, displight, fan: update pwm api to use pwm_set_pulse_dtFabio Baltieri2022-11-221-2/+2
| | | | | | | | | | | | | | | | | Update the kblight, displight and fan drivers to use pwm_dt_spec and the pwm_set_pulse_dt API, makes the code a bit more compact. BRANCH=none BUG=none TEST=cq dry run TEST=poking around with gdb to the data structures Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com> Change-Id: Ib14095d9810575f6371cdd6b8ae91787adddcc6a Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4031189 Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com> Reviewed-by: Keith Short <keithshort@chromium.org> Reviewed-by: Tristan Honscheid <honscheid@google.com>
* zephyr: leds: move led value in the pwm led bindingFabio Baltieri2022-11-221-3/+3
| | | | | | | | | | | | | | | | | | Similarly to the gpio led binding, the pwm led binding is using phandle cells as values. Fix up the code to use a separate property instead, at this point the -config binding is not needed anymore and we can use the upstream pwm-leds directly. BRANCH=none BUG=b:242826402 TEST=validated the resulting structure with gdb TEST=zmake build -a; ./twister Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com> Change-Id: Iec480da15e2ff5e356bad11fbfb6031d4d56353a Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4031269 Reviewed-by: Sam Hurst <shurst@google.com> Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com>
* zephyr: Manually reorder includesJeremy Bettis2022-11-216-56/+56
| | | | | | | | | | | | | | | | | | | 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: leds: move led value in the gpio led bindingFabio Baltieri2022-11-211-1/+1
| | | | | | | | | | | | | | | | | | | | | The current cros-ec,gpio-led-pins binding is leaking values into the named-gpios binding. That's an incorrect way of using the devicetree and only works because named-gpios is not currently using the value cell and because we control the binding. Move the values in a separate property within the cros-ec,gpio-led-pins binding. BRANCH=none BUG=b:242826402 TEST=validated the resulting structure with gdb TEST=zmake build -a; ./twister Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com> Change-Id: I77a09b25cc69c5faed254da38316104b304c8f5e Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4031268 Reviewed-by: Al Semjonovs <asemjonovs@google.com> Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com>
* zephyr: led_driver: add separate config for gpio and pwmFabio Baltieri2022-11-215-16/+10
| | | | | | | | | | | | | | | | | Add separate automatic config for gpio and pwm variations of the generic devicetree led driver, this control the build and allows dropping the precompiler guards on the source files and move compat in the right files. BRANCH=none BUG=none TEST=cq dry run Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com> Change-Id: I75155d3e020b45e29f88f318c28d4a713196064c Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4031190 Reviewed-by: Wai-Hong Tam <waihong@google.com> Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com>
* zephyr: switchcap: rename binding, clean up codeFabio Baltieri2022-11-183-37/+18
| | | | | | | | | | | | | | | | | | | | | | Various cleanups on the switchcap code: - rename the bindings to add the vendor prefix - split the Kconfig option for the common code (used in project specific drivers) and the generic one (devicetree based) - drop the choice and use the compatible to select the option automatically instead - cleanup the code to remove the now unnecessary guards - use DT_INST macros instead of DT_PATH so we don't depends on the node path anymore BRANCH=none BUG=none TEST=cq dry run Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com> Change-Id: I77e790c0b7b0d947e4eafed64b0ace556a22c034 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4028145 Reviewed-by: Abe Levkoy <alevkoy@chromium.org> Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com>
* system: Ensure space for panic and jump dataRob Barnes2022-11-171-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | Ensure space is available for end of ram data. End of ram data must be located at the very end of noinit ram. This currently includes panic_data followed by jump_data. This is being enforced with linker asserts and build asserts rather than allocating the space directly so RAM utiliztion reports are still relevant. Introduce PLATFORM_EC_PRESERVED_END_OF_RAM_SIZE config option and default it to 1KB. This can be adjusted on boards that are constrained. BUG=b:246778588,b:246798928 BRANCH=None TEST=./twister -c -s zephyr/test/jump_tags/jump_tags.default && make run-kb_8042 Change-Id: I444bbe3a583396b4f9b104bb6999e78ae3ff6f2f Signed-off-by: Rob Barnes <robbarnes@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3896272 Reviewed-by: Aaron Massey <aaronmassey@google.com> Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-by: Fabio Baltieri <fabiobaltieri@google.com> Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com>
* zephyr: keyboard: split dt based keymap to its own configFabio Baltieri2022-11-162-3/+3
| | | | | | | | | | | | | | | | | Add a separate config for instantiating keyscan_config based on the devicetree, decoupling it from the main PLATFORM_EC_KEYBOARD option. The new one is selected automatically based on devicetree and the driver does not need a #if guard anymore. BRANCH=none BUG=none TEST=cq dry run Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com> Change-Id: I8e6654c7ebca8553b1f930b87c320af50895048f Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4030886 Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com> Reviewed-by: Keith Short <keithshort@chromium.org>
* zephyr: bindings: rename cros-keyscan to cros-ec,keyscanFabio Baltieri2022-11-161-2/+2
| | | | | | | | | | | | | | | Rename the cros-keyscan binding so that it has a cros-ec prefix, like most of the other "soft" bindings in the project. BRANCH=none BUG=none TEST=cq dry run Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com> Change-Id: I26d72952f44df2ab0bf6228b6f1878e3f099b8f6 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4021954 Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com> Reviewed-by: Keith Short <keithshort@chromium.org>
* test: add tests for battery_fuel_gaugeYuval Peress2022-11-161-1/+1
| | | | | | | | | | | | | | | | | | | | - 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/shim: Sort header filesJeremy Bettis2022-11-1648-134/+158
| | | | | | | | | | | | | | | | | | Sort all headers in zephyr/test with the clang-format rules used by the zephyr project. BRANCH=None BUG=b:247100970 TEST=CQ Signed-off-by: Jeremy Bettis <jbettis@google.com> Change-Id: I5fefbad560d33e2e8be1b02d0db618a19fdd403d Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4024019 Reviewed-by: Tomasz Michalec <tmichalec@google.com> Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com> Tested-by: Jeremy Bettis <jbettis@chromium.org> Commit-Queue: Tomasz Michalec <tmichalec@google.com> Auto-Submit: Jeremy Bettis <jbettis@chromium.org>
* test: system shimYuval Peress2022-11-141-1/+1
| | | | | | | | | | | | | | | Add tests for all error conditions that can be emulated at runtime for system.c's shim layer. BRANCH=none BUG=none TEST=twister Signed-off-by: Yuval Peress <peress@google.com> Change-Id: Id90dbe0c046e379f5bee5fe958a58e0928cfd157 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4025333 Reviewed-by: Abe Levkoy <alevkoy@chromium.org> Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com>
* test: cover missing accessors and init in gpio shimYuval Peress2022-11-141-2/+6
| | | | | | | | | | | | | | | | | | | | | Add tests for the following: - init with custom unused pins handler that fails - calls to gpio_or_ioex_get_level() which wrap gpio_get_level() - calls to gpio_reset_port which resets the entire struct device * - calls to setting the GPIO flags using a mask. Note, tests needed to move to 'pre_main' since they now mess with initialization. BRANCH=none BUG=none TEST=twister Signed-off-by: Yuval Peress <peress@google.com> Change-Id: Ia08bc4a810874eeaf9fff0075e83ef689550d9dd Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4026563 Reviewed-by: Aaron Massey <aaronmassey@google.com> Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com>
* gpio: optimize the gpio_set_flags_by_mask loopYuval Peress2022-11-141-5/+10
| | | | | | | | | | | | | | | Make use of __builtin_ctz in order to loop through 'flags' instead of checking each bit one by one. BRANCH=none BUG=none TEST=twister Signed-off-by: Yuval Peress <peress@google.com> Change-Id: If202aa650326f52927effca9bd2f685bcb869ff0 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4025331 Reviewed-by: Aaron Massey <aaronmassey@google.com> Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com>
* zephyr: move periodic temp read hook to shim layerDawid Niedzwiecki2022-11-141-18/+49
| | | | | | | | | | | | | | | | | | | | | | Some of the temperature sensor drivers declare periodic one second hook to update cached temperature measurement. Declare common hook and call the update function for every sensor. The change allows better manageing of the update calls, e.g. checking power-good pin. BUG=b:244474857 BRANCH=main TEST=skyrim doesn't spam "Recover Bus failed" in G3 Signed-off-by: Dawid Niedzwiecki <dn@semihalf.com> Change-Id: Ibdfe63e20c726efb738deaa23444f7d6dd87b5e2 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3909669 Reviewed-by: Diana Z <dzigterman@chromium.org> Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com> Commit-Queue: Keith Short <keithshort@chromium.org> Reviewed-by: Keith Short <keithshort@chromium.org> Tested-by: Dawid Niedzwiecki <dawidn@google.com>
* zephyr: tests: add pct2075 emulatorDawid Niedzwiecki2022-11-141-0/+2
| | | | | | | | | | | | | | | | | | | | 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>