summaryrefslogtreecommitdiff
path: root/include
Commit message (Collapse)AuthorAgeFilesLines
* TCPC: Cleanup: Enable PPC from PD or Power MUXVijay Hiremath2021-04-203-2/+12
| | | | | | | | | | | | | | | Some PD chips have integrated SRC FET and control the SRC/SINK FET from GPIOs hence cleaned up the code to enable Power Path Control from either from PD or from Power MUX. BUG=none BRANCH=none TEST=make buildall -j Change-Id: I77f96b681fd2e5fca35bce425e4bd5ec87d5ccfd Signed-off-by: Vijay Hiremath <vijay.p.hiremath@intel.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2828980 Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
* driver: bmi: fix use of I2C_PORT_ACCELYuval Peress2021-04-161-0/+19
| | | | | | | | | | | | | | | | | | | | | The BMI driver is currently using I2C_PORT_ACCEL incorrectly as a CONFIG_ value. Update the use cases to a new config option that selects between SPI and I2C communication specifically for the chip. To avoid a lot of device.h changes, the value of the config value is automatically inferred if not explicitly set. BRANCH=none BUG=b:185392974, b:146065507 TEST=zmake testall TEST=make buildall Signed-off-by: Yuval Peress <peress@chromium.org> Change-Id: I6196cc595dc61877ab2b8ed5416bebee51276927 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2829010 Commit-Queue: Keith Short <keithshort@chromium.org> Reviewed-by: Keith Short <keithshort@chromium.org>
* driver: icm: fix use of I2C_PORT_ACCELYuval Peress2021-04-161-0/+19
| | | | | | | | | | | | | | | | | | | | | The ICM driver is currently using I2C_PORT_ACCEL incorrectly as a CONFIG_ value. Update the use cases to a new config option that selects between SPI and I2C communication specifically for the chip. To avoid a lot of device.h changes, the value of the config value is automatically inferred if not explicitly set. BRANCH=none BUG=b:185392974, b:146065507 TEST=zmake testall TEST=make buildall Signed-off-by: Yuval Peress <peress@chromium.org> Change-Id: I8b1a507a76031c2bb1aaf4ca7b14b92252a941f8 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2826920 Commit-Queue: Keith Short <keithshort@chromium.org> Reviewed-by: Keith Short <keithshort@chromium.org>
* zephyr: test_util: Add TEST_SUITE macroTomasz Michalec2021-04-161-0/+6
| | | | | | | | | | | | | | | TEST_SUITE macro allows to define Zephyr test as test suite instead of test_main(). Test suite can be used as part of bigger test. BUG=b:185205123 BRANCH=none TEST=zmake testall TEST=make runhosttests Signed-off-by: Tomasz Michalec <tm@semihalf.com> Change-Id: I834ccf38e256c918623e96bb39597a0b22a874c0 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2825910 Reviewed-by: Jeremy Bettis <jbettis@chromium.org>
* include/system: support interrupt_disable_all of RISCV in zephyrtim2021-04-161-0/+2
| | | | | | | | | | | | | | | We need to call the function of interrupt_disable_all in the case of not cortex_m CPU. BUG=b:185202623 BRANCH=none TEST=zmake -lDEBUG configure -b -B zephyr/build_ite zephyr/projects/it8xxx2_evb/ (no warning) Signed-off-by: tim <tim2.lin@ite.corp-partner.google.com> Change-Id: I852d530ba1e319dbe4656e23d8f143566dd7a626 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2797684 Reviewed-by: Keith Short <keithshort@chromium.org>
* mp2964: Add PMIC driverCaveh Jalali2021-04-161-0/+3
| | | | | | | | | | | | | | | | | This adds a driver for the mp2964 IMVP9.1 PMIC. This driver enables programming control registers within the PMIC. BRANCH=none BUG=b:185424011 TEST=buildall passes. functional testing was done with the follow-on patch. Change-Id: I9b2d89007b5f6933ceeb9a1bcd3bbefb819888a3 Signed-off-by: Caveh Jalali <caveh@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2827950 Reviewed-by: Keith Short <keithshort@chromium.org> Reviewed-by: Tim Wawrzynczak <twawrzynczak@chromium.org> Commit-Queue: Keith Short <keithshort@chromium.org>
* zephyr: use interrupt based RX bufferingYuval Peress2021-04-151-2/+3
| | | | | | | | | | | | | | | | | | | | Poll-based RX was technically incorrect since Zephyr was setting up the UART to FIFO mode (instead of byte mode). This change replaces polling the RX UART with interrupt based callbacks. When calling uart_shell_stop(), the ISR will be replaced and will instead queue items to a ring buffer which can be read from uart_getc() (it can also be cleared via the uart_clear_input() function). BRANCH=none BUG=b:181352041 TEST=Build volteer, run, see expected 0xec07 from the GSC. Cq-Depend: chromium:2730870, chromium:2730869 Signed-off-by: Yuval Peress <peress@chromium.org> Change-Id: I5d2b61e914b56f678a259b373969522da87e8df3 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2728824 Reviewed-by: Keith Short <keithshort@chromium.org> Commit-Queue: Keith Short <keithshort@chromium.org>
* TCPMv2: Generate Hard Reset eventAbe Levkoy2021-04-151-0/+1
| | | | | | | | | | | | | | | Inform the AP when the PRL completes a Hard Reset. BUG=b:183946291 TEST=Observe event during transition-to-default states TEST=With kernel patch, observe mode reentry after Hard Reset BRANCH=firmware-volteer-13672.B-main Signed-off-by: Abe Levkoy <alevkoy@chromium.org> Change-Id: I4af576bd3a8fb57d820bd91d74817040214eaa5b Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2799924 Reviewed-by: Diana Z <dzigterman@chromium.org> Commit-Queue: Diana Z <dzigterman@chromium.org>
* zephyr: Adjust watchdog warning timer value and delay timeMulin Chao2021-04-141-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Adjusts the watchdog warning timer value and its delay time definitions to meet original chromium ec behavior. The system handles the warning event at CONFIG_AUX_TIMER_PERIOD_MS & issues the watchdog reset event at CONFIG_WATCHDOG_PERIOD_MS. Zephyr NPCX watchdog provides a config WDT_NPCX_DELAY_CYCLES for watchdog timeout delay. Set the zephyr timeout to CONFIG_AUX_TIMER_PERIOD_MS as warning time. So the NPCX watchdog hardware issue reset event at CONFIG_AUX_TIMER_PERIOD_MS + WDT_NPCX_DELAY_CYCLES. BUG=b:184683548 BRANCH=none TEST=Build & boot ec on volteer. TEST= `waitms 1000` warning doesn't issue & ec doesn't reboot `waitms 1200` warning issue & ec doesn't reboot `waitms 1500` warning issue & ec doesn't reboot `waitms 1700` warning issue & ec reboot Cq-Depend: chromium:2813911 Signed-off-by: Mulin Chao <mlchao@nuvoton.com> Signed-off-by: Wealian Liao <whliao@nuvoton.corp-partner.google.com> Change-Id: Ibee9c18cd9d2bae6d34ee9366755dec99687c3d4 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2814728 Reviewed-by: Wai-Hong Tam <waihong@google.com> Reviewed-by: Keith Short <keithshort@chromium.org> Commit-Queue: Keith Short <keithshort@chromium.org>
* cbi: fix documentTing Shen2021-04-141-2/+2
| | | | | | | | | | | | | | | | The macro name does not match the implementation in common/cbi.c. BUG=none TEST=make BRANCH=main Signed-off-by: Ting Shen <phoenixshen@google.com> Change-Id: I3c51d1e6030a6a9d2d058bc5bfb2b12c8d78a0af Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2823470 Tested-by: Ting Shen <phoenixshen@chromium.org> Auto-Submit: Ting Shen <phoenixshen@chromium.org> Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org> Commit-Queue: Ting Shen <phoenixshen@chromium.org>
* watchdog: Add config for the leading time of warning timerWealian Liao2021-04-141-3/+7
| | | | | | | | | | | | | | | | Originally, the config CONFIG_AUX_TIMER_PERIOD_MS uses hard-coded for the leading time of the warning timer. Add config for the leading time. BUG=none BRANCH=none TEST=ALLOW_CONFIG=1 make buildall Signed-off-by: Wealian Liao <whliao@nuvoton.corp-partner.google.com> Change-Id: If4b15ffc12dbb11d3782c875eaa6c35b51105901 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2821109 Reviewed-by: Wai-Hong Tam <waihong@google.com> Reviewed-by: Keith Short <keithshort@chromium.org>
* TCPMV2: Remove redundant chunking time constantsAbe Levkoy2021-04-131-2/+0
| | | | | | | | | | | | | | Remove PD_T_CHUNK_SENDER_REQ and PD_T_CHUNK_SENDER_RSP. They are redundant with PD_T_CHUNK_SENDER_REQUEST and PD_T_CHUNK_SENDER_RESPONSE. BUG=b:179443762 TEST=make buildall BRANCH=firmware-volteer-13672.B-main Signed-off-by: Abe Levkoy <alevkoy@chromium.org> Change-Id: Idf12b08af92bbff57fc9a587d17367ade7d8cef3 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2812139 Reviewed-by: Diana Z <dzigterman@chromium.org>
* Export even more symbols from ps8xxxSimon Glass2021-04-131-0/+9
| | | | | | | | | | | | | | | | | It turns out we need more symbols for some boards, such as when the board_get_ps8xxx_product_id() function is implemented. Export some more things. BUG=b:183296099 BRANCH=none TEST=make BOARD=lazor -j30 Build lazor on zephyr Change-Id: Iccef72582f6033a1a34abe28a636ebe254f1bd5a Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2822390 Reviewed-by: Wai-Hong Tam <waihong@google.com>
* ec: Filter non-FIXED PDOs in servo_v4{p1}Jeremy Bettis2021-04-131-0/+6
| | | | | | | | | | | | | | | | | | | | | | Add a new config CONFIG_USB_PD_ONLY_FIXED_PDOS. If that config is enabled, ignore non-FIXED PDOs in both the console command `ada_srccaps` and also when selecting the preferred PDO for a voltage. Enable CONFIG_USB_PD_ONLY_FIXED_PDOS for servo_v4 and servo_v4p1, since they don't expose non-fixed PDO in their srccaps. Without this change, there is a risk that the "best" PDO for a given voltage will be non-FIXED and then that voltage just won't be supported at all. BRANCH=none BUG=b:178484932 TEST=added Change-Id: I0d1187ca372120c7fe21d627e1b82b59f6334add Signed-off-by: Jeremy Bettis <jbettis@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2809353 Tested-by: Jeremy Bettis <jbettis@chromium.org> Commit-Queue: Keith Short <keithshort@chromium.org> Reviewed-by: Keith Short <keithshort@chromium.org>
* ec: Parse battery and augmented PDOs correctly.Jeremy Bettis2021-04-121-2/+2
| | | | | | | | | | | | | | | | Fixes pd_extract_pdo_power() to output the correct voltage and current for non-fixed PDOs. Add unit test. BRANCH=none BUG=b:178484932 TEST=added Signed-off-by: Jeremy Bettis <jbettis@google.com> Change-Id: I6de55be3c753e01ef26424896c6fd41b8df8f94b Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2805226 Commit-Queue: Jeremy Bettis <jbettis@chromium.org> Tested-by: Jeremy Bettis <jbettis@chromium.org> Reviewed-by: Keith Short <keithshort@chromium.org>
* cbi: API for EC to update fw_config tagScott Collyer2021-04-101-0/+14
| | | | | | | | | | | | | | | | | | This CL adds an API to the CBI to allow the EC to update the FW_CONFIG tag field. This API is dependent on not having a the chipset task defined. BUG=b:164157329 BRANCH=quiche TEST=Verified on quiche that long button presses toggle bit 0 of the FW_CONFIG field. Signed-off-by: Scott Collyer <scollyer@google.com> Change-Id: I3a4360b32feac4a04fe53b518c122940f4b340f5 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2776227 Tested-by: Scott Collyer <scollyer@chromium.org> Reviewed-by: Sam Hurst <shurst@google.com> Commit-Queue: Scott Collyer <scollyer@chromium.org>
* Power: Add configurable S5 timeoutDiana Z2021-04-101-0/+1
| | | | | | | | | | | | | | | | Similar to the hibdelay command, allow the time we spend in S5 to be configurable for the sake of power testing in this state. It may be set to 0 for an immediate drop, or -1 to stay in S5 forever. BRANCH=None BUG=b:184941436 TEST=make -j buildall Signed-off-by: Diana Z <dzigterman@chromium.org> Change-Id: If2f8cf91ba982822e2e33cb17f84f38c40907d2e Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2818526 Commit-Queue: Aseda Aboagye <aaboagye@chromium.org> Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
* TCPMV2: Default PD Policy ManagementSam Hurst2021-04-091-0/+41
| | | | | | | | | | | | | | | | | | | A simple implementation to manage PD Policies on honeybun devices. This is meant as an interim solution until a more robust solution is implemented BUG=b:183026242 BRANCH=none TEST=make runtests Tested on Voxel by plugging in a dock Signed-off-by: Sam Hurst <shurst@google.com> Change-Id: Ib8b38754e21b8497fe28855a7f80d2962a4ae7f4 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2774128 Reviewed-by: Yuval Peress <peress@chromium.org> Reviewed-by: Diana Z <dzigterman@chromium.org> Commit-Queue: Diana Z <dzigterman@chromium.org>
* zephyr: Stub out interrupt_disable_all() for testsKeith Short2021-04-091-0/+2
| | | | | | | | | | | | | | | Stub out interrupt_disable_all() definition for tests to fix compiler warnings. BUG=none BRANCH=none TEST=zmake testall Signed-off-by: Keith Short <keithshort@chromium.org> Change-Id: Id605aa41c9977f1b231779b1a29c769e4dd90335 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2816143 Commit-Queue: Yuval Peress <peress@chromium.org> Reviewed-by: Yuval Peress <peress@chromium.org>
* zephyr: Fix compiler warnings from zephyr testsKeith Short2021-04-091-3/+3
| | | | | | | | | | | | | | | Fix the warning that an attribute declaration must precede the definition. BUG=none BRANCH=none TEST=zmake testall Signed-off-by: Keith Short <keithshort@chromium.org> Change-Id: I9b0394d276e0fb39983cd43269804a70139c0655 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2816140 Commit-Queue: Yuval Peress <peress@chromium.org> Reviewed-by: Yuval Peress <peress@chromium.org>
* pd commands: support PD console command srccapsEric Yilun Lin2021-04-081-0/+7
| | | | | | | | | | | | | | | | | | | | | | | This allows servo querying DUT's srccap easier. BUG=b:140256624 TEST=on servo_v4 (TCPMv1) and Asurada (TCPMv2) tested that 1. plug adapter `pd 0 srccaps` show the PDOs 2. unplug adapter `pd 0 srccaps` show nothing sample output: > pd 1 srccaps 0: 5000mV/3000mA 1: 9000mV/2000mA 2: 12000mV/1500mA 3: 3300mV-5900mV/3000mA 4: 3300mV-11000mV/2000mA BRANCH=servo Change-Id: Iadf9f9d91359c96b188509a28b3dc42a7e7b2223 Signed-off-by: Eric Yilun Lin <yllin@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2804008 Reviewed-by: Wai-Hong Tam <waihong@google.com>
* usb_common: support parse Augmented PDOEric Yilun Lin2021-04-081-2/+4
| | | | | | | | | | | | | | | | | | Change the function signature to void pd_extract_pdo_power(uint32_t pdo, uint32_t *ma, uint32_t *max_mv, uint32_t *min_mv); Replace the original caller with an extra unused parameter, no functional changes. BUG=none TEST=`pd 0 srccaps` prints the correct PDO info BRANCH=asurada Change-Id: I9b508e1a13737fe3ed61e6086416cff0c8ffb9a9 Signed-off-by: Eric Yilun Lin <yllin@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2810660 Reviewed-by: Wai-Hong Tam <waihong@google.com>
* Revert "fpsensor: Support building firmware that works for both sensors"Tom Hughes2021-04-075-439/+122
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This reverts commit ac08c9d1dbc9f587df3ee6b15d58c0203f7e356e. Reason for revert: Breaks public build Original change's description: > fpsensor: Support building firmware that works for both sensors > > This is a refactoring to allow building FPMCU firmware that works for > one FPC sensor and one ELAN sensor. > > 1. When both drivers implement our common functions, e.g. fp_sensor_init(), > rename them to fp_sensor_init_fpc() and fp_sensor_init_elan(). > 2. There are a few functions implemented not in FPC driver but in FPC > private library, e.g. fp_sensor_finger_status(). I kept this as-is for > FPC but renamed the one in ELAN driver to fp_sensor_finger_status_elan() > 3. If building for ELAN, need to hardcode elan=1 in hatch_fp/board.c > because the sensor type GPIO always says FPC. > > BRANCH=none > BUG=b:175158241 > TEST=make run-fpsensor; make run-fpsensor_status; > make run-fpsensor_crypto > TEST=make -j BOARD=dartmonkey > TEST=add CONFIG_FP_SENSOR_ELAN515 to board/hatch_fp/board.h; > make -j BOARD=bloonchipper > Firmware binary fully works on Dragonair (FPC) and Voema (ELAN) > TEST=run device tests with http://crrev/c/2750547 and > http://crrev/i/3654297 on Dragonclaw, all pass > > Change-Id: I789090dbdfe35ac6aefd6a629fa4c7bde89dc437 > Signed-off-by: Yicheng Li <yichengli@chromium.org> > Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2727971 > Reviewed-by: Tom Hughes <tomhughes@chromium.org> > Commit-Queue: Tom Hughes <tomhughes@chromium.org> Bug: b:175158241, b:184616069 Change-Id: I2a02a6eefc316e7e13aa188f1ae16672dce2babd Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2809521 Auto-Submit: Tom Hughes <tomhughes@chromium.org> Tested-by: Tom Hughes <tomhughes@chromium.org> Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com> Commit-Queue: caveh jalali <caveh@chromium.org>
* it8xxx2: add support option CONFIG_PRESERVE_LOGSDino Li2021-04-072-2/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | On it8xxx2 chips, assert WRST# to reset itself will clear memory content to default value, this is a HW mechanism. So if CONFIG_PRESERVE_LOGS and CONFIG_IT83XX_HARD_RESET_BY_GPG1 are enabled at the same time, we have to save EC logs into flash before reset. We will restore logs from flash on the next initialization before jumping to main routine. BUG=b:183899510, b:183466169 BRANCH=none TEST=1) __image_size is same as ec.RW.bin size. 2) buildall. 3) manually verify reboot, poweroff, and sysjump from AP console: localhost ~ # ectool uptimeinfo EC uptime: 64.755 seconds AP resets since EC boot: 0 Most recent AP reset causes: EC reset flags at last EC boot: reset-pin | power-on localhost ~ # reboot ... localhost ~ # ectool uptimeinfo EC uptime: 19.334 seconds AP resets since EC boot: 0 Most recent AP reset causes: 71.609: reset: at AP's request EC reset flags at last EC boot: reset-pin | power-on | hard localhost ~ # poweroff ... localhost ~ # ectool uptimeinfo EC uptime: 20.627 seconds AP resets since EC boot: 0 Most recent AP reset causes: 71.609: reset: at AP's request 32.149: reset: at AP's request EC reset flags at last EC boot: reset-pin | power-on | hard localhost ~ # ectool reboot_ec RW localhost ~ # ectool uptimeinfo EC uptime: 37.998 seconds AP resets since EC boot: 0 Most recent AP reset causes: 71.609: reset: at AP's request 32.149: reset: at AP's request EC reset flags at last EC boot: reset-pin | power-on | sysjump | hard localhost ~ # Change-Id: I76b5f172b7728dc5ce9bf3a965cb7b2d638f8fc3 Signed-off-by: Dino Li <Dino.Li@ite.com.tw> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2794322 Reviewed-by: Eric Yilun Lin <yllin@chromium.org>
* PD_INT: Add ability to process non-TCPC alerts in PD_INTDiana Z2021-04-061-0/+7
| | | | | | | | | | | | | | | | Some boards may have other chips sharing the TCPC interrupt line, in which case their alerts may need to be handled at the same priority as the TCPC itself. Otherwise, it becomes difficult to respond quickly to TCPC interrupts. BRANCH=None BUG=b:182534117,b:183679237 TEST=make -j buildall Signed-off-by: Diana Z <dzigterman@chromium.org> Change-Id: I905f20eeb0dd89c8516de31005d402a890906595 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2803460 Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
* bq25720: Add VSYS_TH2 tuning supportCaveh Jalali2021-04-061-0/+10
| | | | | | | | | | | | | | | | | | This adds support for tuning the bq25720 VSYS_TH2 threshold so that a custom threshold voltage can be specified. The default 3.2v for 1S batteries and 5.9v for 2S (or more) batteries may need to be adjusted to improve system stability. When VSYS droops to this threshold, PROCHOT is asserted to reduce system power demand. BRANCH=none BUG=b:183474163 TEST=with rest of patch stack, booted brya to the OS without a battery Signed-off-by: Caveh Jalali <caveh@chromium.org> Change-Id: I7f52a369371eb93860b14ad8438b790af231c450 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2798979 Reviewed-by: Keith Short <keithshort@chromium.org> Commit-Queue: Keith Short <keithshort@chromium.org>
* PCHG: Support firmware updateDaisuke Nojiri2021-04-052-7/+129
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch adds EC_CMD_PCHG_UPDATE, which allows the host to update firmware of ctn730 via I2C. An updater (e.g. ectool) is expected to issue EC_PCHG_UPDATE_CMD_OPEN, multiple EC_PCHG_UPDATE_CMD_WRITEs, then EC_PCHG_UPDATE_CLOSE. Each sub-command completion is notified to the host via EC_MKBP_EVENT_PCHG. An updater is supposed to wait for the previous sub-command to complete before proceeding to the next. Example: localhost ~ # ectool pchg 0 State: DOWNLOAD (6) FW Version: 0x104 localhost ~ # ectool pchg 0 update 0x207000 0x105 /path/to/image.bin Update file /path/to/image.bin (85632 bytes) is opened. Writing firmware (port=0 ver=0x105 addr=0x207000 bsize=128): ********************************************************************** FW update session closed (CRC32=0x7bd5c66f). localhost ~ # ectool pchg 0 reset Reset port 0 complete localhost ~ # ectool pchg 0 State: ENABLED (2) FW Version: 0x105 BUG=b:182600604, b:173235954 BRANCH=trogdor TEST=ectool pchg 0 update 0x201200 0x105 /tmp/user_ee_X0.1_V1.5.bin TEST=ectool pchg 0 reset Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> Change-Id: I9c62f1714dd69428ab5870c443cb4eb77881a6c6 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2757099
* crc: Don't use crc_hw.h for host toolsDaisuke Nojiri2021-04-051-2/+2
| | | | | | | | | | | | | | | | | Currently, crc_hw.h is included when CONFIG_HW_CRC is defined. This breaks host tools which call crc32 APIs because they run on an AP (which has no 'hw_crc'). This patch avoids using crc_hw.h for host tools. BUG=none BRANCH=none TEST=buildall Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> Change-Id: I50f496275f4d8969950bf51e3de5cff9697e3b29 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2800717 Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* fpsensor: Support building firmware that works for both sensorsYicheng Li2021-04-025-122/+439
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is a refactoring to allow building FPMCU firmware that works for one FPC sensor and one ELAN sensor. 1. When both drivers implement our common functions, e.g. fp_sensor_init(), rename them to fp_sensor_init_fpc() and fp_sensor_init_elan(). 2. There are a few functions implemented not in FPC driver but in FPC private library, e.g. fp_sensor_finger_status(). I kept this as-is for FPC but renamed the one in ELAN driver to fp_sensor_finger_status_elan() 3. If building for ELAN, need to hardcode elan=1 in hatch_fp/board.c because the sensor type GPIO always says FPC. BRANCH=none BUG=b:175158241 TEST=make run-fpsensor; make run-fpsensor_status; make run-fpsensor_crypto TEST=make -j BOARD=dartmonkey TEST=add CONFIG_FP_SENSOR_ELAN515 to board/hatch_fp/board.h; make -j BOARD=bloonchipper Firmware binary fully works on Dragonair (FPC) and Voema (ELAN) TEST=run device tests with http://crrev/c/2750547 and http://crrev/i/3654297 on Dragonclaw, all pass Change-Id: I789090dbdfe35ac6aefd6a629fa4c7bde89dc437 Signed-off-by: Yicheng Li <yichengli@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2727971 Reviewed-by: Tom Hughes <tomhughes@chromium.org> Commit-Queue: Tom Hughes <tomhughes@chromium.org>
* zephyr: Move ADC-shim code into zephyr/shimSimon Glass2021-04-021-18/+1
| | | | | | | | | | | | | | | Most of the shim code is in zephyr/ rather than in the ECOS code. Move the ADC one as well, to keep it consistent. BUG=b:175881324 BRANCH=none TEST=build Zephyr with lazor and some other CLs and see that the ADC enum is now available and there are not build errors Change-Id: Ib1b31c1b885e3ca5b184f4f708776357ac87cbbf Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2801171 Reviewed-by: Wai-Hong Tam <waihong@google.com>
* ppc/syv682x: support C versionEric Yilun Lin2021-04-011-0/+11
| | | | | | | | | | | | | | | | | | | | | | C version won't block I2C accessing to CONTROL4(to on/off Vconn) reg when smart discahrge enabled. This allows us to re-enable the smart discahrge on boards using SYV682C. This CL support the feature by adding: 1. CONFIG_USBC_PPC_SYV682C 2. CONFIG_USBC_PPC_SYV682X_SMART_DISCHARGE also, hayato uses different SYV682 versions across revisions, add a overridable function syv682x_board_is_syv682c() for handling board revision issue. BUG=b:160548079 b:176876036 TEST=Hayato meets tVconnOff, and tVbusDischarge BRANCH=asurada Change-Id: I89b57b8c20907249d5d97140289fb0570bd58b46 Signed-off-by: Eric Yilun Lin <yllin@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2738506 Reviewed-by: Ting Shen <phoenixshen@chromium.org>
* Create a public header for bmi160Hyungwoo Yang2021-03-311-0/+32
| | | | | | | | | | | | | | | | Create a separate public header for bmi160 so we can include it from Zephyr. BUG=b:173507858 BRANCH=none TEST=make BOARD=lazor -j4 Change-Id: Ib35d473b3f4e1a566ef35cd5e203b6acbf93319b Signed-off-by: Hyungwoo Yang <hyungwoo.yang@intel.corp-partner.google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2793047 Reviewed-by: Jack Rosenthal <jrosenth@chromium.org> Commit-Queue: Jack Rosenthal <jrosenth@chromium.org> Tested-by: Jack Rosenthal <jrosenth@chromium.org>
* TCPMv2: PRL: Enahnce support for the tx message discard pathScott Collyer2021-03-311-3/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This CL modifies the tx message discard path in the PRL. The states that should have triggered tx message discard events, would only act on messages pending from PE, but not passed yet to the phy. This behavior was required to account for the serial nature of the different PRL state machines and inherent delay in sending/receiving messages to/from off chip TCPCs via the I2C bus. This CL adds a new WAIT value to the xmit_status enum so that a message being sent to the phy but not reponse yet can be known. In addition, xmit_status == DISCARDED is no longer treated automatically as a protocol error. BUG=b:181179550,b:173028144 BRANCH=None TEST=Running VDMU.E16 compliance test. Validated that the SVDM command sequence is properly interrupted in most all cases. This test only fails if collision events are present which is a happening on honybuns for 2 reasons: 1) GRL test waits too long to interrupt the VDM command (~1 msec) 2) honeybuns ucpd is faster since it doesn't have i2c delays. Signed-off-by: Scott Collyer <scollyer@google.com> Change-Id: I2bec09b96d7f6ea6122fcb369246717950987ca8 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2752251 Tested-by: Scott Collyer <scollyer@chromium.org> Reviewed-by: Diana Z <dzigterman@chromium.org> Commit-Queue: Scott Collyer <scollyer@chromium.org>
* Add a common header for board_vbus_sink_enable()Simon Glass2021-03-311-0/+11
| | | | | | | | | | | | | | | | This function prototype is defined in quite a few files, none of which is visible to Zephyr. Add a prototype in one place and remove the others. BUG=b:183296099 BRANCH=none TEST=make buildall Signed-off-by: Simon Glass <sjg@chromium.org> Change-Id: I2f3f1e08614408e7b8f6bb0633a478765c73beaa Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2789800 Reviewed-by: Jack Rosenthal <jrosenth@chromium.org>
* Add a common header for board_is_sourcing_vbus()Simon Glass2021-03-311-0/+10
| | | | | | | | | | | | | | | | This function prototype is defined in lots of files, none of which is visible to Zephyr. Add a prototype in one place and remove the others. BUG=b:183296099 BRANCH=none TEST=make buildall Signed-off-by: Simon Glass <sjg@chromium.org> Change-Id: Ia324327a69b117483ab9ee5c85eba93c0fb5ad9c Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2789799 Reviewed-by: Jack Rosenthal <jrosenth@chromium.org>
* raa489000: Add raa489000_enable_asgate()Aseda Aboagye2021-03-301-0/+9
| | | | | | | | | | | | | | | | | | | This commit exports a function to allow the ASGATE to be enabled or disabled when the charger IC is in the READY state. This can help to achieve a VBUS level of 0V if the READY state is required/desired. BUG=b:183220414 BRANCH=dedede TEST=With some other patches to use this function, build and flash on madoo, plug in a charger, remove charger, verify that VBUS goes down to less than 200mV and decays to 0. Signed-off-by: Aseda Aboagye <aaboagye@google.com> Change-Id: Icb5316d9c206138e68fa4e55dee5b454182921e9 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2793057 Tested-by: Aseda Aboagye <aaboagye@chromium.org> Reviewed-by: Diana Z <dzigterman@chromium.org> Commit-Queue: Aseda Aboagye <aaboagye@chromium.org>
* common: motion_sense: Prevent on/off body from waking up deviceGwendal Grignou2021-03-292-2/+13
| | | | | | | | | | | | | | | | | | | | Introduce a new flag: BYPASS_FIFO to raise an interrupt to the AP when an event is sent. It is not as strong as WAKEUP, as it does not wake up the AP. BYPASS_FIFO must be set when WAKEUP is set. It is applied to sync sensor as well as gesture/activity sensor. BUG=b:123434029 BRANCH=trogdor TEST=Compile Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Change-Id: Id5aba71e6d11ef31f7fa2c67ba2e07178d088b1b Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2780834 Reviewed-by: Ching-Kang Yen <chingkang@chromium.org> Tested-by: Ching-Kang Yen <chingkang@chromium.org> Commit-Queue: Ching-Kang Yen <chingkang@chromium.org>
* common/battery: Provide function to lower input voltagePatryk Duda2021-03-291-0/+6
| | | | | | | | | | | | | | This patch introduces generic version of function that sets voltage limit when chipset is off and battery is fully charged. BUG=b:182546058 BRANCH=none TEST=make -j buildall Signed-off-by: Patryk Duda <pdk@semihalf.com> Change-Id: Ib7606c8d1ab3fe1dc650a3abcef9ebc207335ab5 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2773218 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
* Revert "ps8815: delete CONFIG_USB_PD_TCPM_PS8815_FORCE_DID"Zhuohao Lee2021-03-251-0/+6
| | | | | | | | | | | | | | | | | This reverts commit e2761c8be4571adcfc425a9187290872ffa9d02d. In order to support the old TCPC chip which bcd revision is smaller than 0x7, we need to bring back the CONFIG_USB_PD_TCPM_PS8815_FORCE_DID and force the TCPC firmware be updated in the factory line. BUG=b:177251013, b:159289062, b:182018599, b:178978970 BRANCH=firmware-volteer-13672.B TEST=the old TCPC chip can update its firmware. Signed-off-by: Zhuohao Lee <zhuohao@chromium.org> Change-Id: I66d12aee569137cc7823a186e3251ca8b187e767 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2784327 Reviewed-by: Keith Short <keithshort@chromium.org>
* honeybuns: Add full usb-pd support for C0Scott Collyer2021-03-241-2/+2
| | | | | | | | | | | | | | | | | | | | | This CL adds config options and board level structs to fully support USB-PD on port C0 for both gingerbread and quiche. This includes all the svdm response functions required for support of DP Alt-mode as a UFP_D. This also includes honeybuns specific version of usb-pd policy functions. BUG=b:175660576 BRANCH=None TEST=Verify that C0 port can establish PD contract, enter ALT-DP mode and extend display over DP/HDMI connectors. Signed-off-by: Scott Collyer <scollyer@google.com> Change-Id: I11edee85e63381f00114e9fbe012a37fd8174279 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2699455 Tested-by: Scott Collyer <scollyer@chromium.org> Reviewed-by: Diana Z <dzigterman@chromium.org> Commit-Queue: Scott Collyer <scollyer@chromium.org>
* ctn730: Print firmware versionDaisuke Nojiri2021-03-242-0/+7
| | | | | | | | | | | | | | | | | | This patch makes ctn730 driver print the firmware version. EC_CMD_PCHG is updated to version 1 and returns firmware version of a charger chip. Version 0 of EC_CMD_PCHG is deprecated. BUG=b:182600604, b:173235954, b:183151376 BRANCH=Trogdor TEST=Verify firmware version is printed on EC console. TEST=ectool pchg 0 (for version 1) TEST=cat /sys/class/power_supply/PCHG0/* (for version 0) "ERR kernel: [ 33.394847] cros-ec-pchg cros-ec-pchg.13.auto: Unable to get port.0 status (err:-524)" Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> Change-Id: Ib7bb9a7225fe914bc6c8d600d0f4766dbf75ace8 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2757098
* zephyr: provide a definition of K_MUTEX_DEFINE for CrOS EC OSJack Rosenthal2021-03-231-0/+8
| | | | | | | | | | | | | | | | | | | | Create a compatible K_MUTEX_DEFINE() for CrOS EC OS. This allows us to use K_MUTEX_DEFINE() in shared code without needing special Zephyr-only guards. K_MUTEX_DEFINE() will allow us to stop much of our usage of k_mutex_init(), which can often be forgotten, leaving mutexes uninitialized. BUG=b:177677037 BRANCH=none TEST=follow up CLs do some conversion to K_MUTEX_DEFINE they compile in both CrOS EC OS and Zephyr OS Signed-off-by: Jack Rosenthal <jrosenth@chromium.org> Change-Id: I11a9bcf1648447a7f1cb587bb0ebdf0c62381346 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2782231 Reviewed-by: Simon Glass <sjg@chromium.org>
* Create a public header for isl923xSimon Glass2021-03-231-0/+51
| | | | | | | | | | | | | | | | Add a separate public header for this chip so we can include it from Zephyr. Update the charger file to use that header, so it builds on Zephyr. BUG=b:183296099 BRANCH=none TEST=make BOARD=lazor -j4 Signed-off-by: Simon Glass <sjg@chromium.org> Change-Id: I54506ef17ecda2683f1c1a933f1978df458e08ea Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2774916 Reviewed-by: Jack Rosenthal <jrosenth@chromium.org> Reviewed-by: Keith Short <keithshort@chromium.org>
* bq25710: Consolidate NARROW_VDC definitionCaveh Jalali2021-03-231-1/+2
| | | | | | | | | | | | | | | | | This consolidates the selection of CONFIG_CHARGER_NARROW_VDC to config.h for the bq25710 and bq25720 charger chips. The driver requires NARROW_VDC to be enabled, so move this setting to config.h similar to other chargers. BRANCH=none BUG=b:173575131 TEST=buildall passes Change-Id: I6c1768aff5d581544c4b7182f32ec45851a3a243 Signed-off-by: Caveh Jalali <caveh@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2780831 Reviewed-by: Abe Levkoy <alevkoy@chromium.org> Commit-Queue: Abe Levkoy <alevkoy@chromium.org>
* charger: Update BQ25720 configsCaveh Jalali2021-03-221-5/+1
| | | | | | | | | | | | | | | | | This updates how we select between the BQ25720 and BQ25710 charger chips. The BQ25720 charger chip can now be enabled without enabling the BQ25710 charger chip. Both chips are still supported by the same driver and the choice of BQ25720 vs. BQ25710 remains a compile time configuration. BRANCH=none BUG=b:180980490 TEST=buildall passes Change-Id: If632af0b68d8cf73e5c2436a05b1641e4467d8f8 Signed-off-by: Caveh Jalali <caveh@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2774701 Reviewed-by: Keith Short <keithshort@chromium.org>
* zephyr: Add ADC mul and div factors supportDawid Niedzwiecki2021-03-221-0/+2
| | | | | | | | | | | | | | | | Some boards need to adjust ADC measurements with multiplication and division factors so add support for these also in Zephyr. BUG=b:175881324 BRANCH=none TEST=Add mul and div factors in the dts file and verify measurements with the "adc" console command Signed-off-by: Dawid Niedzwiecki <dn@semihalf.com> Change-Id: I6b716e20af18623249a4a972b6f3db8eec09a376 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2775487 Reviewed-by: Wai-Hong Tam <waihong@google.com> Commit-Queue: Wai-Hong Tam <waihong@google.com>
* lazor: move declaration of battery_cell_type to ln9310.hJack Rosenthal2021-03-221-0/+9
| | | | | | | | | | | | | | | | | | | ln9310 driver depends on these functions (sadly), so it does not make sense to be declaring them in board.h. Specifically, the Zephyr build won't include Lazor's board.h. ln9310.h is the best home I can think of for now. Ideally we could refactor this later so that the ln9310 driver wasn't depending on board-specific functions. BUG=b:183054226 BRANCH=none TEST=buildall Signed-off-by: Jack Rosenthal <jrosenth@chromium.org> Change-Id: I7c82d2ed3d3c16d8131238cd236741e31de5b0c7 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2776221 Reviewed-by: Simon Glass <sjg@chromium.org>
* TCPMv2: PE: Add mechanism to request source power roleScott Collyer2021-03-201-0/+11
| | | | | | | | | | | | | | | | | | | | | This CL makes the function pd_can_source_from_device() overridable. This default implementation is used in deciding whether to request a power role swap. By making this overridable, boards have the option of implementing custom per port policy for requesting power role swaps. BUG=b:182441965 BRANCH=None TEST=verfied that on quiche when attaching as a sink that a power role swap request is generated. Previously, quiche relied on the host requesting a power role swap. Signed-off-by: Scott Collyer <scollyer@google.com> Change-Id: I9c5bdb77405a6075de9c5b4269213f810a20cc6c Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2722989 Commit-Queue: Scott Collyer <scollyer@chromium.org> Tested-by: Scott Collyer <scollyer@chromium.org> Reviewed-by: Diana Z <dzigterman@chromium.org>
* driver: ln9310: move ln9310.h header to include/Jack Rosenthal2021-03-201-0/+188
| | | | | | | | | | | | | | | Move driver/ln9310.h to include/driver/ln9310.h so this header can be readily included from Zephyr builds. BUG=b:183054226 BRANCH=none TEST=buildall Signed-off-by: Jack Rosenthal <jrosenth@chromium.org> Change-Id: I47c1d8dc8af90c690639ef1621cc66a9946ba40b Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2776220 Reviewed-by: Simon Glass <sjg@chromium.org> Reviewed-by: Wai-Hong Tam <waihong@google.com>
* charge_state: provide stub definition of charge_want_shutdownJack Rosenthal2021-03-201-0/+7
| | | | | | | | | | | | | | | | | | | | | | | Common power sequencing code (e.g., sc7180 power sequencing) calls charge_want_shutdown() to check there is enough battery. If the charger hasn't been enabled, the power sequencing code is expected to never call charge_want_shutdown (this has already been implemented for intel x86, for example). However, there's a bunch of ARM power sequencing code which does not guard the calls, and adding a bunch of ifdefs or IS_ENABLED to them would look bad. Provide a stub definition which indicates the charger never wants a shutdown if there's no charging enabled. BUG=b:183054226 BRANCH=none TEST=compile sc7180 without charger Signed-off-by: Jack Rosenthal <jrosenth@chromium.org> Change-Id: I1429be4262c005752be49668aeb7274e540d8342 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2774361 Reviewed-by: Simon Glass <sjg@chromium.org>