summaryrefslogtreecommitdiff
path: root/common
Commit message (Collapse)AuthorAgeFilesLines
* tree: Create usb_pd_pdo.cTom Hughes2021-11-054-26/+37
| | | | | | | | | | | | | | | | | | | | genvif depends on usb_pd_policy.c. However, the usb_pd_policy.c files often depend on other symbols that are not included when building genvif. genvif only needs the pd_src_pdo and pd_src_pdo_count variables (and charge_manager_get_source_pdo() in one case). Extract these variables into their own files. BRANCH=none BUG=b:172020503 TEST=CC=clang make BOARD=zinger -j TEST=make buildall TEST=compare generated *_vif.xml files before and after change: => MATCH Signed-off-by: Tom Hughes <tomhughes@chromium.org> Change-Id: I765750cd86243a0a355dcc6a29b80fc23403d99f Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3231026 Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
* ioex: extract shell commands from ioexpander.cMichał Barnaś2021-11-053-143/+158
| | | | | | | | | | | | | | This commit extracts shell commands to manipulate ioex to different file to split generic ioex logic from shell commands. BRANCH=main BUG=b:202701452 TEST=After flashing, ioexget and ioexset should work correctly Change-Id: I8707d1dd32324ca6e7b9163b800e32ded67fdf38 Signed-off-by: Michał Barnaś <mb@semihalf.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3262093 Reviewed-by: Abe Levkoy <alevkoy@chromium.org>
* TCPMv2: Avoid hard reset on shutdown with no batteryDiana Z2021-11-031-2/+5
| | | | | | | | | | | | | | | | | When shutting down, it's generally desirable to reset Vconn to the source. However, if we're running with no battery then we should avoid this hard reset in order to prevent removing board power. BRANCH=None BUG=b:202804110 TEST=on guybrush, shutdown with a charger which swaps Vconn and ensure we don't hard reset Signed-off-by: Diana Z <dzigterman@chromium.org> Change-Id: I1b2587495b21a641c3901c5b1fcc127951305e3b Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3260165 Commit-Queue: Aseda Aboagye <aaboagye@chromium.org> Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
* ec: Implement keyboard backlight get enabledJeremy Bettis2021-11-032-2/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | Prior to crrev/c/1051027, the EC_CMD_PWM_GET_KEYBOARD_BACKLIGHT host cmd returned an enabled flag, which the FAFT test firmware_ECLidSwitch depends on. That test, however, was broken, and wasn't actually running the kb backlight portion of the test on any models, so no one ever noticed that the HC and the kblight ec console commands don't return the enabled status. Add a get_enabled function to the kblight driver struct, and add an implementation for each existing driver. BRANCH=None BUG=b:194908032 TEST=CP'd to leona branch, build EC, flash board kblight 100 ; lidclose ; kblight ; lidopen ; kblight Verified the cmd returned enabled: 1 when lights were on Change-Id: Ia6ab025901869933cf70bb49f3bf2def2987b7b3 Signed-off-by: Jeremy Bettis <jbettis@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3248888 Tested-by: Jeremy Bettis <jbettis@chromium.org> Auto-Submit: Jeremy Bettis <jbettis@chromium.org> Commit-Queue: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
* npcx: flash: Fix physical_get_protect_flags()Wealian Liao2021-11-031-0/+3
| | | | | | | | | | | | | | | | | | | | | Protecting status register by /WP works when SRP0 is enabled. The getting protect flags function should check SRP0 & QE for EC_FLASH_PROTECT_ERROR_INCONSISTENT flag. This CL adds the following: 1. SRP0 & QE bits check for npcx flash. 2. EC_FLASH_PROTECT_ERROR_UNKNOWN flag BUG=none BRANCH=none TEST=Protect a range & don't set the SRP0. Check flag by `flashinfo`. Signed-off-by: Wealian Liao <whliao@nuvoton.corp-partner.google.com> Change-Id: Iae8645aca7b0d9176e625de3656a35e675df3ef2 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3246882 Reviewed-by: Keith Short <keithshort@chromium.org> Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org> Commit-Queue: Daisuke Nojiri <dnojiri@chromium.org>
* charger: Enable hw ramp for active_chg_chipTommy Chung2021-11-021-8/+16
| | | | | | | | | | | | | | | There're some boards with more than one chg chips included (OCPC). We should set the "active chg chips" when we call charger_set_hw_ramp. BUG=b:196928096 BRANCH=none TEST=make sure that hw ramp enabled on the active chg chip. Signed-off-by: Tommy Chung <tommy.chung@quanta.corp-partner.google.com> Change-Id: I98c8ca3a189ed1794c06a789a5e685b5d8a8aa12 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3252564 Reviewed-by: Diana Z <dzigterman@chromium.org> Reviewed-by: Devin Lu <Devin.Lu@quantatw.com>
* fpsensor: Use global fingerprint OWNERS fileTom Hughes2021-11-011-5/+1
| | | | | | | | | | | BRANCH=none BUG=b:180546850 TEST=none Signed-off-by: Tom Hughes <tomhughes@chromium.org> Change-Id: I2730d8c6be88c924cfe794e38434f40bce289c07 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2702501 Reviewed-by: Craig Hesling <hesling@chromium.org>
* common/firmware_image.lds.S: Add empty text sectionTom Hughes2021-10-291-0/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Without a text section clang/lld will create one and put it at an address it selects. Even though the section it creates is empty, if the LMA is beyond the end of the flash, ec.bin will be too large since the empty space is filled with 0xFF. For example, before this change servo_micro's ec.bin is 131075 bytes instead of 131072 (0x20000) bytes. Examining the sections, we see the LMA is 0x08020003, which is three bytes beyond the flash size (0x08000000 + 0x20000 + 0x3): arm-none-eabi-objdump -h build/servo_micro/ec.obj Sections: Idx Name Size VMA LMA File off Algn ... 3 .text 00000000 08014b90 08020003 00024b90 2**2 CONTENTS, ALLOC, LOAD, READONLY, CODE ... After this change, servo_micro's ec.bin is the correct size: 131072 (0x20000) bytes. Now the .text section is at the beginning of flash: arm-none-eabi-objdump -h build/servo_micro/ec.obj Sections: Idx Name Size VMA LMA File off Algn 0 .text 00000000 08000000 08000000 000000f4 2**2 ALLOC, READONLY, CODE ... BRANCH=none BUG=b:172020503 TEST=./util/compare_build.sh -b all -j 120 => MATCH Signed-off-by: Tom Hughes <tomhughes@chromium.org> Change-Id: I48f8019fe6b77f880de0d1a0a4a176b3506f3579 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3248887 Reviewed-by: Keith Short <keithshort@chromium.org>
* common: Make EC power delivery cmd more verboseNehemiah Dureus2021-10-291-0/+51
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Added more detailed output for `pd <port> srccaps` for debugging convenience. For boards that have large enough memory, the output of srccaps will be formatted showing pdo flags, pdo type, etc.: Src 0: (Fixed) 5000mV/3000mA DRP UP USB DRD Src 1: (Aug3.0) 5000mV-2000mV/3000mA DRP UP USB DRD ... For boards that don't have enough memory to support this, defining CONFIG_CMD_PD_SRCCAPS_REDUCED_SIZE will default to displaying the old way of printing out srccaps, shown below: 0: 5000mV/3000mA 1: 5000mV-2000mV/3000mA ... BRANCH=None BUG=b:194402616 TEST=On Delbin, connected with ServoV4, execute `pd <port> srccaps`, Built all boards (make -j buildall) Signed-off-by: Nehemiah Dureus <ndureus@google.com> Cq-Depend: chromium:3248341, chromium:3248342, chromium:3248343, chromium:3248344, chromium:3252409, chromium:3252413 Change-Id: I146f619c5baaf28b56a603c3b0a96fc9efbfb26a Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3248345 Reviewed-by: Boris Mittelberg <bmbm@google.com>
* common/firmware_image: Add _start symbolTom Hughes2021-10-281-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When linking with clang (lld), it complains that it can't find the "_start" symbol: ld.lld: warning: cannot find entry symbol _start; defaulting to 0x8000000 "_start" is used by the linker to fill in the entry point address in the ELF header ("e_entry": https://refspecs.linuxbase.org/elf/elf.pdf#page=19): arm-none-eabi-readelf -e ./build/servo_micro/ec.obj ELF Header: ... Entry point address: 0x8000000 ... Add an explicit "_start" symbol at the beginning of the firmware image (entry point) to satisfy the linker. BRANCH=none BUG=b:172020503 TEST=./util/compare_build.sh -b all -j 120 => MATCH Signed-off-by: Tom Hughes <tomhughes@chromium.org> Change-Id: Id077013cb54869b92d18cea2f74be25135bc4e42 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3249156 Reviewed-by: Keith Short <keithshort@chromium.org>
* zephyr: test: Make get_time mockableAaron Massey2021-10-281-0/+9
| | | | | | | | | | | | | | | | | | Some driver code paths require control of the return value of get_time in order to be properly tested. Now get_time can be mocked during tests. BRANCH=none BUG=b:184856083 TEST=zmake testall and make runhosttests Signed-off-by: Aaron Massey <aaronmassey@chromium.org> Change-Id: I7f66542aaef015263af66d872978c40746a77292 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3219471 Commit-Queue: Aaron Massey <aaronmassey@google.com> Tested-by: Aaron Massey <aaronmassey@google.com> Reviewed-by: Yuval Peress <peress@google.com>
* battery: Move battery get/set vendor param to common/battery.cTommy Chung2021-10-281-0/+32
| | | | | | | | | | | | | | | Since the functions are copied by many boards, move them to common. The specific param regs are defined in each specific boards. BUG=b:203031618 BRANCH=none TEST=make BOARD=burnet/coachz/eve/homestar/kappa/mrbland/quackingstick/ wormdingler. Signed-off-by: Tommy Chung <tommy.chung@quanta.corp-partner.google.com> Change-Id: I77c070663ad3e800ec484bd21865c5d911a2c48b Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3220718 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
* IOEX: Fix clobbering of initial flag valuesSam Hurst2021-10-271-1/+2
| | | | | | | | | | | | | | | | | Do not clobber initial io-expander flag values set in board files. BUG=b:203907721 BRANCH=none TEST=ServoV4p1 flags are not clobbered and IO-Expanders are working Signed-off-by: Sam Hurst <shurst@google.org> Change-Id: If5d899de5071d8a8e7594de10e2efd4dfb83e838 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3239014 Tested-by: Sam Hurst <shurst@google.com> Reviewed-by: caveh jalali <caveh@chromium.org> Reviewed-by: Brian J. Nemec <bnemec@chromium.org> Commit-Queue: Sam Hurst <shurst@google.com>
* smart_battery: Store battery info in struct battery_static_infoDaisuke Nojiri2021-10-263-19/+70
| | | | | | | | | | | | | | | | | | | | | | | | | | Currently, static battery info is stored in a host command response struct (e.g. ec_response_battery_static_info_v1). It can contain only up to 8 (v0) or 12 (v1) byte strings. This patch adds struct battery_static_info, which has the full size string fields to store static battery info. This will make a host using virtual_battery.c see full size strings under /sysfs/power_supply/sbs-*. ACPI and host programs speaking EC_CMD_BATTERY_GET_STATIC will not be affected. BUG=b:198722643, b:203031618 BRANCH=None TEST=Coachz. Run ectool battery. TEST=Run cat /sys/class/power_supply/sbs-12-000b/manufacturer and and verify the string is longer than 8 chars. Change-Id: Id847d66c7c846885113f6afb05a9de1788bf92ae Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3180272 Reviewed-by: Jack Rosenthal <jrosenth@chromium.org>
* Battery: Move battery code to battery_v1.c and v2.cDaisuke Nojiri2021-10-265-531/+558
| | | | | | | | | | | | BUG=b:198722643, b:203031618 BRANCH=None TEST=buildall Change-Id: I595da56412f4d30684b00d1138f7e2339c7f5204 Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3227372 Reviewed-by: Jack Rosenthal <jrosenth@chromium.org> Reviewed-by: Keith Short <keithshort@chromium.org>
* TCPMv2: Add PD timer unit testDenis Brockus2021-10-262-3/+7
| | | | | | | | | | | | | | | | | | | Basic checks to verify setting/clearing bits for all of the currently allocated PD timers works properly BUG=b:141363146 BRANCH=none TEST=make run-usb_pd_timer Signed-off-by: Denis Brockus <dbrockus@google.com> Change-Id: I22e237d367a3b3cb28c4a9d88d6c5c375f3b44cf Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3176394 Tested-by: Abe Levkoy <alevkoy@chromium.org> Reviewed-by: Denis Brockus <dbrockus@chromium.org> Reviewed-by: Yuval Peress <peress@google.com> Commit-Queue: Denis Brockus <dbrockus@chromium.org> Auto-Submit: Denis Brockus <dbrockus@chromium.org>
* TCPMv2: Support 64 timersAbe Levkoy2021-10-261-17/+79
| | | | | | | | | | | | | | | | | Use arrays of 32-bit fields to store PD timer status for each port. Provide a mechanism to perform atomic operations on the appropriate fields for each timer. BUG=b:141363146 TEST=make run-usb_pe_drp BRANCH=none Signed-off-by: Abe Levkoy <alevkoy@chromium.org> Change-Id: I23bb4aa9df569cec7088f5b9e451e86372eaabb7 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3171334 Reviewed-by: Denis Brockus <dbrockus@chromium.org> Reviewed-by: Keith Short <keithshort@chromium.org> Commit-Queue: Denis Brockus <dbrockus@chromium.org>
* common/acpi: Disable clang warningTom Hughes2021-10-261-0/+8
| | | | | | | | | | | | | | | | | | | | | | | | When building with clang, it warns: common/acpi.c:138:11: error: result of comparison of constant 256 with expression of type 'uint8_t' (aka 'unsigned char') is always false [-Werror,-Wtautological-constant-out-of-range-compare] addr >= EC_ACPI_MEM_MAPPED_BEGIN + EC_ACPI_MEM_MAPPED_SIZE) { ~~~~ ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ It doesn't hurt to leave the check as-is. The values of EC_ACPI_MEM_MAPPED_BEGIN + EC_ACPI_MEM_MAPPED_SIZE may not be greater than or equal to 255 on every board. BRANCH=none BUG=b:172020503 TEST=CC=clang make BOARD=voema TEST=make buildall -j Signed-off-by: Tom Hughes <tomhughes@chromium.org> Change-Id: Ibb27421957e99f2f636331fbaa51dab6fa768744 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3243009 Reviewed-by: Paul Fagerburg <pfagerburg@chromium.org>
* thermal: Don't check fan off/max with custom fan control.Devin Lu2021-10-251-15/+20
| | | | | | | | | | | | | | | | | | | Currently fan off and fan max only applied for legacy fan control method. Those parameters do not affect the fan curve if CONFIG_CUSTOM_FAN_CONTROL. The patch will not check the fan off/max threshold with custom fan control. BUG=none BRANCH=none TEST=make buildall TEST=On Jinlon. Verify fan curve still work well. Signed-off-by: Devin Lu <Devin.Lu@quantatw.com> Change-Id: I49c204aba1468f793da0b890072e600e842be03f Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3141333 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-by: Zick Wei <zick.wei@quanta.corp-partner.google.com> Commit-Queue: Daisuke Nojiri <dnojiri@chromium.org>
* tablet_mode: Fix mode error after gmr360 triggeredarthur.lin2021-10-251-9/+9
| | | | | | | | | | | | | | | | | | When DUT in laptop mode and gmr_sensor_360 triggerd by unexpected, system will enter tablet mode. But system will keep in table mode even gmr_sensor_360 release. BUG=b:203383664 BRANCH=None TEST=make buildall -j DUT in laptop mode and triggerd gmr_sensor_360 then release. And check system will back to laptop mode from tablet mode normally. Signed-off-by: arthur.lin <arthur.lin@lcfc.corp-partner.google.com> Change-Id: I783aaa7e4b03977f67ce122890ab0eb548a8bd38 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3241205 Reviewed-by: Aseda Aboagye <aaboagye@chromium.org> Commit-Queue: Aseda Aboagye <aaboagye@chromium.org>
* cleanup: charger: consolidate charger_dump console commandsDeepti Deshatty2021-10-201-4/+25
| | | | | | | | | | | | | | | | | | | | Console command "charger_dump" is defined in multiple charger driver files, hence, build fails when more than one charger chip drivers are enabled for a platform. To avoid this "charger_dump" console command is defined in a common file, and this command handler invokes platform specific charger dump register api. BRANCH=none BUG=none TEST=Verified 'charger dump' command on brya Signed-off-by: Deepti Deshatty <deepti.deshatty@intel.corp-partner.google.com> Change-Id: Ic542af90b47880e90073c529f9183abc6a3f5af7 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3211760 Commit-Queue: caveh jalali <caveh@chromium.org> Reviewed-by: Vijay Hiremath <vijay.p.hiremath@intel.com> Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
* cbi-util: Fix error with setting 8 byte cbi dataThejaswani Putta2021-10-201-5/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | From the ec console, setting 8 byte size rework id value using 'cbi set <tag> value size' fails for the tag CBI_TAG_REWORK_ID, which is of 8byte size while rest of the structure members are of 4 byte size or variable length. This patch is to fix the error and allow setting of 8 byte cbi value for the rework_id. BUG=b:202870018 BRANCH=None TEST=Run the command 'cbi set 9 0x123456789abcd 8' from ec console and see it went through without errors. Run the command 'cbi' which dumps all the fields of cbi structure to check if the reworks_id(with tag 9) is updated to this set value. Signed-off-by: Thejaswani Putta <thejaswani.putta@intel.com> Change-Id: Ifaa9c19dd5ea692b51c2666cdd37da09d395cf34 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3219758 Reviewed-by: Thejaswani Putta <thejaswani.putta@intel.corp-partner.google.com> Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-by: Vijay Hiremath <vijay.p.hiremath@intel.com> Tested-by: Thejaswani Putta <thejaswani.putta@intel.corp-partner.google.com> Commit-Queue: Daisuke Nojiri <dnojiri@chromium.org>
* TCPMv2: Only clear discovery data on disconnectDiana Z2021-10-191-2/+1
| | | | | | | | | | | | | | | | | | | Currently, the HOOK_USB_PD_DISCONNECT hook runs before mode exit in the TC. This means that if the PE clears the mode data, we won't know to exit active modes. Decouple this dependency by leaving the alt mode exit code in charge of clearing the modes on disconnect. BRANCH=None BUG=None TEST=on voxel, disconnect DP monitor and verify HPD is set low Signed-off-by: Diana Z <dzigterman@chromium.org> Change-Id: Iebfddf4b7880dcfbeab08bdca426175bc549c833 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3232291 Reviewed-by: Abe Levkoy <alevkoy@chromium.org> Commit-Queue: Abe Levkoy <alevkoy@chromium.org>
* tree: Remove .bss.slowTom Hughes2021-10-198-32/+32
| | | | | | | | | | | | | | | | | | The config option to enable .bss.slow was removed in commit b224441aaaa5dd08274811d65bb795b4abc231d8 because the option was only used with kunimitsu, which was removed from the EC codebase a long time ago. Remove the reference in the linker maps to complete the cleanup. BRANCH=none BUG=b:172020503, b:172221339 TEST=make buildall Signed-off-by: Tom Hughes <tomhughes@chromium.org> Change-Id: Ibc519f9974cb26e6d15180e2ce0c359867ced1ac Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3219263 Reviewed-by: Ting Shen <phoenixshen@chromium.org>
* charge_manager: don't send new power request when DPS enabledfirmware-cr50-stab-mp-14300.B-mainfirmware-cr50-stab-14294.B-mainEric Yilun Lin2021-10-191-12/+22
| | | | | | | | | | | | | | | | | | | | | DPS would control the PD sink voltage dynamically, so charge_manager doesn't need to send a new power request if it's not sinking the max voltage. Also, merge two new powe requests into one to prevent from sending multiple requests at one time. BUG=b:169532537 TEST=enable DPS, and won't send consecutive DP requests when switching voltage BRANCH=main Change-Id: Ib706f4feb5c6434d71b9576f299898a12613aded Signed-off-by: Eric Yilun Lin <yllin@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3229049 Reviewed-by: Aseda Aboagye <aaboagye@chromium.org> Commit-Queue: Eric Yilun Lin <yllin@google.com> Tested-by: Eric Yilun Lin <yllin@google.com>
* dps: reset PD voltage when dps disabled.Eric Yilun Lin2021-10-191-0/+3
| | | | | | | | | | | | | | | | To enforce the PD voltage back to the default value, we have to force a new request. BUG=b:169532537 TEST=dps dis, and a new PD request is issued BRANCH=asurada Change-Id: I4c7d1d6019a9095099dc992411890e394c71b820 Signed-off-by: Eric Yilun Lin <yllin@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3229048 Reviewed-by: Aseda Aboagye <aaboagye@chromium.org> Commit-Queue: Eric Yilun Lin <yllin@google.com> Tested-by: Eric Yilun Lin <yllin@google.com>
* tree: Files should end with single newlineTom Hughes2021-10-1816-17/+0
| | | | | | | | | | | | | | | | | | | | | | | One of the checks that runs as part of "repo upload" looks for a single newline at the end of each file. I'm getting warnings about this when I touch files that do not follow this, even though I didn't add the extra newlines. This commit fixes all files by running the following: for f in $(find . -name '*.[ch]'); do printf '%s\n' "$(cat ${f})" > ${f}; done BRANCH=none BUG=b:172020503 TEST=./util/compare_build.sh -b all -j 120 => MATCH Signed-off-by: Tom Hughes <tomhughes@chromium.org> Change-Id: Ia3ece5b64b549d21ca11708791368002bb6e9b0e Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3229797 Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
* tree: Make all console commands staticTom Hughes2021-10-155-14/+19
| | | | | | | | | | | | | | Almost all of the console commands were already static. This change makes all of them static for consistency. BRANCH=none BUG=b:172020503 TEST=make buildall -j Signed-off-by: Tom Hughes <tomhughes@chromium.org> Change-Id: I0ac46358b6fbafa65504c648ce4de0365cdbf723 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3224372 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
* tree: Make all host commands staticTom Hughes2021-10-158-13/+24
| | | | | | | | | | | | | | Almost all of the host commands were already static. This change makes all of them static for consistency. BRANCH=none BUG=b:172020503 TEST=make buildall -j Signed-off-by: Tom Hughes <tomhughes@chromium.org> Change-Id: I8330e85e6d64a039f08d7620eed1fe897f436567 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3221786 Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
* zephyr: add support for virtual batteryMichał Barnaś2021-10-151-3/+3
| | | | | | | | | | | | | | | | | | Add Kconfigs to enable virtual battery and set virtual battery address. Change named-i2c from I2C_PORT_VIRTUAL to I2C_PORT_VIRTUAL_BATTERY. BRANCH=main BUG=b:185480578 TEST=When virtual battery is enabled, compilation fails if no virtual battery port is defined in device tree. TEST=Enable virtual battery and verify that its handlers are called properly. Change-Id: Ic88da28dc443beb89a32868d201072f39abb3a86 Signed-off-by: Michał Barnaś <mb@semihalf.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3207991 Reviewed-by: Keith Short <keithshort@chromium.org> Commit-Queue: Keith Short <keithshort@chromium.org>
* charge: respect PDO current maximum limitEric Yilun Lin2021-10-152-0/+28
| | | | | | | | | | | | | | | | | | | | | | The current input limit setting doesn't respect the PDO's current limit (e.g. when the current limit is less than CONFIG_INPUT_CURRENT_LIMIT) and this might cause the over-draining the charger. BUG=b:172878439 TEST=1) make buildall 2) modified servo-v4 which only broadcast PDOs with 250mA current limit and ensure the goroh won't sink more than 250mA. (while the CONFIG_INPUT_CURRENT_LIMIT is 512mA) BRANCH=main Change-Id: I09f8e6fb39a072ee38ea09a5c9898984f4122513 Signed-off-by: Eric Yilun Lin <yllin@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3220037 Commit-Queue: Eric Yilun Lin <yllin@google.com> Tested-by: Eric Yilun Lin <yllin@google.com> Reviewed-by: Aseda Aboagye <aaboagye@chromium.org> Reviewed-by: Diana Z <dzigterman@chromium.org>
* IOEX: Cleanup: Use IOEX_FLAGS_INITIALIZED flag to get the IOEX statusVijay Hiremath2021-10-121-8/+9
| | | | | | | | | | | | | | | | | | IOEX_FLAGS_DISABLED is replaced with IOEX_FLAGS_DEFAULT_INIT_DISABLED hence use IOEX_FLAGS_INITIALIZED flag to get the initialization status of the IOEXes. BUG=none BRANCH=none TEST=Tested on Brya. 'ioexget' command works and also default init function skips IOEX initialization. Change-Id: I98ff9643223c02388a2fa679b4631e3389fd466e Signed-off-by: Vijay Hiremath <vijay.p.hiremath@intel.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3200063 Reviewed-by: Poornima Tom <poornima.tom@intel.com> Reviewed-by: Keith Short <keithshort@chromium.org> Commit-Queue: Keith Short <keithshort@chromium.org>
* common/console: No PROMPT if CONFIG_EXPERIMENTAL_CONSOLEJes B. Klinke2021-10-121-4/+6
| | | | | | | | | | | | | | | | | | | | The existing CONFIG_EXPERIMENTAL_CONSOLE shifts responsibility of command line editing and history away from the EC. As a part of that change, the EC should not emit the prompt character ">". It seems that every instance but one had already been enclosed in ifdef. This CL will take care of that last one, as well as make sure that PROMPT and CTRL are not defined when CONFIG_EXPERIMENTAL_CONSOLE is enabled, allowing the compiler to prevent any regressions. BUG=none BRANCH=none TEST=build servo_micro with CONFIG_EXPERIMENTAL_CONSOLE enabled Signed-off-by: Jes B. Klinke <jbk@chromium.org> Change-Id: Ifdab902cf877c7adee3d8e564cd234ffb19e317b Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3213360 Reviewed-by: Aseda Aboagye <aaboagye@chromium.org> Commit-Queue: Aseda Aboagye <aaboagye@chromium.org>
* zephyr: optimize I2C mutexesDawid Niedzwiecki2021-10-111-3/+11
| | | | | | | | | | | | | | | | | | | | | | | | | I2C_PORT_COUNT is bigger than the actual physical I2C number in Zephyr. Since the access to I2C has to be controlled per physical port, limit the size of the port_mutex array. Introduce the I2C_DEVICE_COUNT define to represent the number of the physical I2C ports. It is not possible to automate it fully with the current devicetree macros. A new I2C_COPMAT defines will have to be introduced for new chips. The general assumption is that there is only one type of I2C port per chip pointed by the compatible property e.g. "nuvoton,npcx-i2c-port". BUG=b:199918263 BRANCH=none TEST=zmake testall; Make sure there is no "Access I2C without lock!" message in console. Signed-off-by: Dawid Niedzwiecki <dn@semihalf.com> Change-Id: Ie7b0570eb5629ebd4adabc8a47d0d802d847a773 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3211976 Tested-by: Dawid Niedźwiecki <dn@semihalf.com> Reviewed-by: Keith Short <keithshort@chromium.org> Commit-Queue: Dawid Niedzwiecki <dawidn@google.com>
* motion_sense: Fix Fix ap_event_interval calculationGwendal Grignou2021-10-081-1/+1
| | | | | | | | | | | | | | | | Improve precision of the new_rate_us calculation. Fixes: motion_sense: Fix ap_event_interval calculation ("5155d9c7bfc42aa3f53572e0389a8180d7f3a366") BUG=b:195264765,b:129159505,b:73557414 BRANCH=many. TEST=compile Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Change-Id: I4b3d54dedceca5652004da14f32dac6ae98747fa Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3200808 Reviewed-by: Rob Barnes <robbarnes@google.com> Reviewed-by: Diana Z <dzigterman@chromium.org>
* common/panic_output: Disable infinite recursion warningTom Hughes2021-10-081-0/+11
| | | | | | | | | | | | | | When CONFIG_CMD_STACKOVERFLOW is enabled, we explicitly want to perform infinit recursion, so we disable the warning. BRANCH=none BUG=b:172020503 TEST=make CC=arm-none-eabi-clang BOARD=npcx7_evb Signed-off-by: Tom Hughes <tomhughes@chromium.org> Change-Id: Ie243834d16ecfc55bf95756d31dc0200892cf275 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3212456 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
* common/console: Add support for ^CJes B. Klinke2021-10-081-0/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When making USB connection to the console, theoretically, one does not know if a previous session has typed a partial command into the buffer. One could send a newline before typing the desired command, but it would be even safer to have a keypress that would discard any partial command. In particular, the HyperDebug device to be used with OpenTitan is similar to Servo micro, but there will not be a daemon like servod maintaining a single USB connection. Instead each invocation of the "OpenTitan tool" (somewhat equivalent to dut-control) will establish its own connection with the USB console endpoint, and issue commands. This design increases the risk of e.g. a testing script being interrupted on the development workstation resulting in a partial command being left on the console. This change adds support for the Ctrl-C character in the EC console, having the effect of discarding any input, and printing a new command prompt. This is similar behavior to most Linux shells. BUG=b:192262089 BRANCH=none TEST=Upload to Nucleo board, manually connect to ttyUSBn Signed-off-by: Jes B. Klinke <jbk@chromium.org> Change-Id: I082b76a7db4961cd4ce2feb91745c465003d416f Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3208915 Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
* TCPMv2: Clear discovery data on detachDiana Z2021-10-071-0/+4
| | | | | | | | | | | | | | | | | | | | Previously, we'd been clearing discovery data during mode exit which was called on port detach. Now that we're only clearing mode data there, add an explicit clear to our stored data on HOOK_USB_PD_DISCONNECT to ensure we will always clear all this cached data on detach regardless of what other code blocks are doing. BRANCH=None BUG=None TEST=on voxel, plug in TBT dock and unplug. Verify we go from having many modes discovered in the 'ectool typecdiscovery' output, to having 0 modes discovered on detach Signed-off-by: Diana Z <dzigterman@chromium.org> Change-Id: If7ff58bfe4aca885f84c1636210e20cada59154f Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3209662 Reviewed-by: Abe Levkoy <alevkoy@chromium.org> Commit-Queue: Abe Levkoy <alevkoy@chromium.org>
* chgstv2: Implement battery protection for low voltageTang Qijun2021-10-071-0/+40
| | | | | | | | | | | | | | | | Deep charge inspection is a battery protection mechanism: If battery voltage is lower than 6V, deep charge for more than 30 minutes The battery voltage is still lower than 6V, the system will stop charging BRANCH=trogdor BUG=b:198226241 TEST=run-sbs_charging_v2 Signed-off-by: Tang Qijun <qijun.tang@ecs.corp-partner.google.com> Change-Id: I89adf7809992b9e71b232ad1129af1407acf05a2 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3151037 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org> Commit-Queue: Daisuke Nojiri <dnojiri@chromium.org>
* tree: Remove CONFIG_RO_HEAD_ROOM and CONFIG_RW_HEAD_ROOMTom Hughes2021-10-061-5/+0
| | | | | | | | | | | | | | | | | CONFIG_RO_HEAD_ROOM and CONFIG_RW_HEAD_ROOM are always defined as 0, so remove the values and associated code in order to simplify the code and improve readability. BRANCH=none BUG=b:172020503 TEST=./util/compare_build.sh -b all => MATCH Signed-off-by: Tom Hughes <tomhughes@chromium.org> Change-Id: Ie11d23befda674cc15dda9a2d66b9c43ea22d49e Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3205489 Reviewed-by: Ting Shen <phoenixshen@chromium.org> Reviewed-by: Mary Ruthven <mruthven@chromium.org>
* common/usbc: Fix constnessTom Hughes2021-10-061-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When building with clang, it reports: common/usbc/usb_prl_sm.c:2304:44: error: 'prl_tx_states' causes a section type conflict with 'flag_bit_names' static __const_data const struct usb_state prl_tx_states[] = { ^ common/usbc/usb_prl_sm.c:131:37: note: declared here static __const_data struct bit_name flag_bit_names[] = { ^ common/usbc/usb_prl_sm.c:2346:44: error: 'prl_hr_states' causes a section type conflict with 'flag_bit_names' static __const_data const struct usb_state prl_hr_states[] = { ^ common/usbc/usb_prl_sm.c:131:37: note: declared here static __const_data struct bit_name flag_bit_names[] = { ^ The issue is that flag_bit_names is not const. When making flag_bit_names const, we must also make the argument to print_bits const to fix the additional warning: common/usbc/usb_prl_sm.c:169:56: error: passing 'const struct bit_name [11]' to parameter of type 'struct bit_name *' discards qualifiers [-Werror,-Wincompatible-pointer-types-discards-qualifiers] print_bits(group, set_or_clear ? "Set" : "Clr", flag, flag_bit_names, ^~~~~~~~~~~~~~ common/usbc/usb_prl_sm.c:149:28: note: passing argument to parameter 'names' here struct bit_name *names, BRANCH=none BUG=b:172020503 TEST=make CC=arm-none-eabi-clang BOARD=cret Signed-off-by: Tom Hughes <tomhughes@chromium.org> Change-Id: I95d28f53755dd23fe288ae70055e09fcf44511ad Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3205487 Reviewed-by: Edward Hill <ecgh@chromium.org>
* zephyr: convert port number for I2C_CONTROL HCDawid Niedzwiecki2021-10-061-0/+9
| | | | | | | | | | | | | | | | The port number passed via the I2C control host command may be different than the one used in ZephyrEC so convert it based on the "remote-port" property in DTS. BUG=b:201408931 BRANCH=none TEST=zmake testall Signed-off-by: Dawid Niedzwiecki <dn@semihalf.com> Change-Id: I71e05df2eb4f76b8c93948a97f47193aaaa6e25e Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3205251 Reviewed-by: Yuval Peress <peress@google.com> Commit-Queue: Dawid Niedzwiecki <dawidn@google.com>
* ioex: Skip initializing IOEXes if already initializedfactory-ambassador-14265.B-mainVijay Hiremath2021-10-051-2/+8
| | | | | | | | | | | | | | | | | Some of the IOEXes are needed early than the task is initialized, those IOEXes will be initialized at the board level. This CL skips re-initializing the IOEXes from HOOK function if already initialized. BUG=none BRANCH=none TEST=Tested on ADL RVP, re-initialization of IOEX is skipped Change-Id: I3062c46992a5578bf8f0f0bc2613b6815c28a616 Signed-off-by: Vijay Hiremath <vijay.p.hiremath@intel.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3183330 Reviewed-by: Keith Short <keithshort@chromium.org> Reviewed-by: Deepti Deshatty <deepti.deshatty@intel.corp-partner.google.com> Commit-Queue: Keith Short <keithshort@chromium.org>
* main: Add board level Pre-task I2C peripheral initializationVijay Hiremath2021-10-052-5/+14
| | | | | | | | | | | | | | | | | Intel RVP requires GPIOs from few of the IO expanders to configure pins pre-task, but the current code initializes the IO expanders after the HOOK task starts. This CL allows board to configure the I2C peripherals pre-task. BUG=none BRANCH=none TEST=Tested on ADL-RVP, able to initialize IOEX pre-task Change-Id: I827e22153a98a058d04da0139e302a6ec0276b43 Signed-off-by: Vijay Hiremath <vijay.p.hiremath@intel.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3183329 Reviewed-by: Keith Short <keithshort@chromium.org> Commit-Queue: Keith Short <keithshort@chromium.org>
* i2c: Use bitbang mode for pre-task i2c transactionsJun Lin2021-10-053-4/+46
| | | | | | | | | | | | | | | | | | | | | | | | | In Intel ADL+_RVP, the keyboard is scanned by a discrete I/O expander IC and it is connected to EC via the I2C interface. EC needs to initialize the IC via I2C transaction before the task scheduling starts. It may cause the system panic if the EC's I2C driver is implemented by task-event-based. With this CL, if any of the I2C ports that need pre-task I2C transaction are defined as bitbang ports along with regular I2C ports will switch to the bitbang (GPIO) mode before the task starts and will again switch back to event based I2C upon task initialization. BRANCH=none BUG=b:199374643 TEST=issue an I2C transaction before the task scheduling starts; make sure the transaction success without panic on npcx9_evb. TEST=pass "make buildall" Signed-off-by: Jun Lin <CHLin56@nuvoton.com> Change-Id: I65460d2b612328f25bce60561bbb82995dd1cfdf Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3161869 Tested-by: Vijay Hiremath <vijay.p.hiremath@intel.com> Reviewed-by: Keith Short <keithshort@chromium.org> Commit-Queue: Keith Short <keithshort@chromium.org>
* chip/npcx: Fix enum typeTom Hughes2021-10-051-1/+1
| | | | | | | | | | | | | | | | | | | | | | | clang reports that the enum types do not match: chip/npcx/lpc.c:967:9: error: implicit conversion from enumeration type 'enum ec_error_list' to different enumeration type 'enum ec_status' [-Werror,-Wenum-conversion] return EC_SUCCESS; common/power_button_x86.c:523:9: error: implicit conversion from enumeration type 'enum ec_error_list' to different enumeration type 'enum ec_status' [-Werror,-Wenum-conversion] return EC_SUCCESS; BRANCH=none BUG=b:172020503 TEST=make CC=arm-none-eabi-clang BOARD=aleena Signed-off-by: Tom Hughes <tomhughes@chromium.org> Change-Id: I25d1526d58e1e8558153592be7174a8448c130f5 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3202998 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
* common/base_state: Fix enum typeTom Hughes2021-10-041-1/+1
| | | | | | | | | | | | | | | | | | common/base_state.c:65:9: error: implicit conversion from enumeration type 'enum ec_error_list' to different enumeration type 'enum ec_status' [-Werror,-Wenum-conversion] return EC_SUCCESS; BRANCH=none BUG=b:172020503 TEST=make CC=arm-none-eabi-clang BOARD=kakadu TEST=make buildall Signed-off-by: Tom Hughes <tomhughes@chromium.org> Change-Id: I7ad0b349270d00a1156462aa32ad19f342b6db61 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3198204 Reviewed-by: Paul Fagerburg <pfagerburg@chromium.org> Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
* common/motion_sense: Avoid comparison between negative value and unsigned charTom Hughes2021-10-011-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | clang fails to compile due to the following: common/motion_sense.c:1123:34: error: result of comparison of constant -1 with expression of type 'const uint8_t' (aka 'const unsigned char') is always false [-Werror,-Wtautological-constant-out-of-range-compare] (in->sensor_odr.sensor_num == ~~~~~~~~~~~~~~~~~~~~~~~~~ ^ common/motion_sense.c:1454:27: error: result of comparison of constant -1 with expression of type 'const uint8_t' (aka 'const unsigned char') is always false [-Werror,-Wtautological-constant-out-of-range-compare] in->spoof.sensor_id == MOTION_SENSE_ACTIVITY_SENSOR_ID) { ~~~~~~~~~~~~~~~~~~~ ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ As indicated by the TEST line, the output is identical before and after this change. BRANCH=none BUG=b:172020503 TEST=./util/compare_build.sh -b all -j 90 => MATCH Signed-off-by: Tom Hughes <tomhughes@chromium.org> Change-Id: Ieb55b385dfe9e07a8a7098ac3b456a0504215d94 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3197753 Reviewed-by: Paul Fagerburg <pfagerburg@chromium.org>
* hostcmd: Implement I2C_CONTROL host commandCaveh Jalali2021-10-011-0/+61
| | | | | | | | | | | | | | | | This adds an host command to get or set the I2C bus speed of an I2C bus located on the EC. BRANCH=none BUG=b:201039003 TEST=with follow-on patches, switched I2C bus speed between 400 kHz and 1 MHz using ectool. Change-Id: Ieaaee8d925509b103771c96bec50a90403766c1a Signed-off-by: Caveh Jalali <caveh@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3181506 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-by: Boris Mittelberg <bmbm@google.com>
* i2c: add converters between enum i2c_freq and kHzCaveh Jalali2021-10-011-0/+28
| | | | | | | | | | | | | BRANCH=none BUG=b:201039003 TEST=with follow-on patches, switched I2C bus speed between 400 kHz and 1 MHz using ectool. Change-Id: Ide60a2515d4d9a5f8e1ff841b8369e63c39f5c6a Signed-off-by: Caveh Jalali <caveh@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3198247 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-by: Boris Mittelberg <bmbm@google.com>