summaryrefslogtreecommitdiff
path: root/common
Commit message (Collapse)AuthorAgeFilesLines
* LICENSE: remove unnecessary (c) after CopyrightTom Hughes2019-06-1987-87/+87
| | | | | | | | | | | | | | | | Ran the following command: git grep -l 'Copyright (c)' | \ xargs sed -i 's/Copyright (c)/Copyright/g' BRANCH=none BUG=none TEST=make buildall -j Change-Id: I6cc4a0f7e8b30d5b5f97d53c031c299f3e164ca7 Signed-off-by: Tom Hughes <tomhughes@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1663262 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
* new_nvmem: use CC_SYSTEM as the console channelMary Ruthven2019-06-181-12/+11
| | | | | | | | | | | | | BUG=none BRANCH=cr50 TEST=dump_nvmem still prints when only the command channel is active. Other new_nvmem messages are only printed when CC_SYSTEM is active. There aren't any extra newlines in these messages. Change-Id: Ia32689265a406994c22335c247b37eeb1618a01a Signed-off-by: Mary Ruthven <mruthven@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1656634 Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
* nvmem: use CC_SYSTEM instead of CC_COMMANDMary Ruthven2019-06-181-2/+2
| | | | | | | | | | | | | | | Use CC_SYSTEM for nvmem print statments instead of CC_COMMAND, so the CC_COMMAND channel will only have command output. BUG=none BRANCH=cr50 TEST=chan 0 restricts the console, so it only prints command output. Nvmem prints are still enabled by default. Change-Id: Ief79c930416a3560f7316c0df77c73504d855070 Signed-off-by: Mary Ruthven <mruthven@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1656628 Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
* fpsensor: delete extra slash in build pathYicheng Li2019-06-152-4/+4
| | | | | | | | | | | | | | | | | | | | Delete extra slashes in build.mk so that the build target names are correct. BRANCH=nocturne BUG=chromium:973618 TEST=make -j buildall TEST=no more extra slashes: CC RW/common/fpsensor/fpsensor.o CC RW/common/fpsensor/fpsensor_state.o CC RW/common/fpsensor/fpsensor.o CC RW/common/fpsensor/fpsensor_state.o CC RO/common/fpsensor/fpsensor_state.o Change-Id: Ibb8a975462242487c9dfbf84558cbbc97d31e87f Signed-off-by: Yicheng Li <yichengli@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1658516 Reviewed-by: Nicolas Norvez <norvez@chromium.org>
* fpsensor: Change new files' year to 2019Yicheng Li2019-06-151-1/+1
| | | | | | | | | | | | | | Although the code is moved from files created in 2017, these are new files, so change the year to 2019. BRANCH=nocturne BUG=none TEST=make -j buildall Change-Id: I15015c7ad1a713437b04395fd09e6641019f5ff7 Signed-off-by: Yicheng Li <yichengli@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1660092 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
* fpsensor: Add unit test for derive_encryption_key().Yicheng Li2019-06-143-3/+3
| | | | | | | | | | | | | | | | | Mock rollback_get_secret() and use it to test derive_encryption_key(). BRANCH=nocturne BUG=chromium:927095 TEST=make -j buildall TEST=tested enrollment, matching and multifinger on nocturne DUT TEST=verified test key vectors by running boringSSL's HKDF (https://boringssl.googlesource.com/boringssl/+/c0b4c72b6d4c6f4828a373ec454bd646390017d4/crypto/hkdf/) locally Change-Id: Ie2f51e4f64788d938e43d0c5c18685d1cfdd001c Signed-off-by: Yicheng Li <yichengli@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1652495 Reviewed-by: Nicolas Norvez <norvez@chromium.org>
* motionsense: prevent loop after missing eventsJett Rink2019-06-141-8/+10
| | | | | | | | | | | | | | | | | | We don't need to loop to figure out when to schedule the next sensor collection event, just schedule it as soon as possible. This eliminates a watchdog reset when we miss scheduling the sensor task and get really far behind. BRANCH=none BUG=b:133190570 TEST=normal operation is fine, based on longs of failing results in bug, this should prevent the watch reset. Change-Id: I3001028ba393b51d1958f0136ba040eaee5e52d1 Signed-off-by: Jett Rink <jettrink@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1658521 Reviewed-by: Yuval Peress <peress@chromium.org> Reviewed-by: Jack Rosenthal <jrosenth@chromium.org>
* fpsensor: Move crypto-related code to fpsensor_crypto.cYicheng Li2019-06-135-138/+162
| | | | | | | | | | | | | | | | | | Move crypto-related code to common/fpsensor/fpsensor_state.c. This facilitates unittesting because we can control whether to link in crypto-related code, and also facilitates mocking the encryption engine. BRANCH=nocturne BUG=chromium:927095 TEST=ran unittests TEST=tested enrollment, matching and multifinger on DUT nocturne Change-Id: I5bffc1460cbe2c9e3d6294ea5fff41f14019f0eb Signed-off-by: Yicheng Li <yichengli@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1648922 Reviewed-by: Nicolas Norvez <norvez@chromium.org> Reviewed-by: Tom Hughes <tomhughes@chromium.org>
* keyboard_scan: Send kb events at start of debouncing period.Jes Klinke2019-06-111-40/+27
| | | | | | | | | | | | | | | | | | | | Current behavior is to start a timer upon first detecting a transition of any one cell of the keyboard matrix, and then generate a keyboard event (press or release) only after that timer has expired. Due to the fact that the release timer has a longer period than the press timer, in some cases, e.g. releasing the shift key right before depressing another key, events could end up getting re-ordered. BUG=chromium:547131 BRANCH=master TEST=make run-kb_scan Signed-off-by: Jes Klinke <jbk@google.com> Change-Id: If3de2e629dc9df4325d8c17590d6624a41e27187 Bug: 547131 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1579905 Tested-by: Jes Klinke <jbk@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org> Commit-Queue: Jes Klinke <jbk@chromium.org>
* TCPC: Make tcpc_config handle other bus typesDaisuke Nojiri2019-06-102-6/+9
| | | | | | | | | | | | | | | | | | | | | Currently, tcpc_config assumes TCPCs are on I2C bus. ITE's EC has an embedded TCPC. This patch adds bus_type field to struct tcpc_config_t so that a TCPC location on other type of bus can be specified. Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> BUG=none BRANCH=none TEST=buildall Change-Id: Ieac733011700b351e6323f46070dcf46d9e1154b Reviewed-on: https://chromium-review.googlesource.com/1640305 Commit-Ready: Daisuke Nojiri <dnojiri@chromium.org> Tested-by: Daisuke Nojiri <dnojiri@chromium.org> Legacy-Commit-Queue: Commit Bot <commit-bot@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org>
* minute-ia: ish software panicDenis Brockus2019-06-111-0/+26
| | | | | | | | | | | | | | | | | | | Adding functions for software panic to ISH. This includes panic_set_reason, panic_get_reason and software_panic. Added extra output when a software panic is detected. Had to touch nds32/panic.c in order to make panic_sw_reasons common. BUG=b:134502392 BRANCH=none TEST=Verified with crash assert, with CONFIG_DEBUG_ASSERT defined Change-Id: Iebfe62a7dcd59b4bbed82b450dfd44cc8eaed1da Signed-off-by: Denis Brockus <dbrockus@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1648958 Reviewed-by: Jack Rosenthal <jrosenth@chromium.org>
* ectool: Clarify addressing mode for I2C commandsDaisuke Nojiri2019-06-101-1/+1
| | | | | | | | | | | | | | | | | | This patch updates the help message for i2cread, i2cwrite, i2cxfer to clarify which addressing mode (7-bit or 8-bit) each command uses. Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> BUG=chromium:971296 BRANCH=none TEST=buildall Change-Id: I757e8a1d30ad19dbc333a30a97f8049f007853d1 Reviewed-on: https://chromium-review.googlesource.com/1641600 Commit-Ready: Daisuke Nojiri <dnojiri@chromium.org> Tested-by: Daisuke Nojiri <dnojiri@chromium.org> Legacy-Commit-Queue: Commit Bot <commit-bot@chromium.org> Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
* common/battery: Avoid negative display percentagesEvan Green2019-06-081-0/+2
| | | | | | | | | | | | | | | | | Battery charges less than batt_host_shutdown_pct cause the display charge to go negative. This looks silly in EC console prints: [38.474266 Battery 2% (Display -2.-7 %) / 3h:15 to full] BUG=b:134586427 BRANCH=None TEST=Run kohaku down to low battery, observe display stays at 0. Change-Id: If8eb477b8bb21451069bac5c1474b7a408b30582 Signed-off-by: Evan Green <evgreen@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1650136 Reviewed-by: Tim Wawrzynczak <twawrzynczak@chromium.org> Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
* fpsensor: Add API to check FP sensor encryption status.Yicheng Li2019-06-072-8/+30
| | | | | | | | | | | | | | | | | | Add EC command for the host to query FP sensor encryption status. Currently it's just FP TPM seed has been set or not. Add unit test for this command. Also add ectool command for querying encryption status. BRANCH=nocturne BUG=chromium:952275 TEST=ran unittests TEST=tested enrollment, matching and multifinger on DUT nocturne. TEST=tested querying sensor encryption status using ectool. Change-Id: I07d1e471ead85a517105b38d1ddd793c3046ce8f Signed-off-by: Yicheng Li <yichengli@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1633272 Reviewed-by: Nicolas Norvez <norvez@chromium.org>
* get rid of compiler warningsVadim Bendebury2019-06-071-1/+1
| | | | | | | | | | | | | | | | | | | The upcoming change of the set of gcc invocation flags would trigger a warnings about a potentially uninitialized variable use. Even though the variables are guaranteed to be initialized in the two cases being touched, let's just pacify the compiler so that in places where it is important we do get the uninitialized variable warning and compilation failure. BRANCH=cr50, cr50-mp BUG=b:134623681 TEST='make buildall -j' succeeds with the new compiler invocation Change-Id: I5ac392d7628931d9e02ea153b3c8a2e7c285050d Signed-off-by: Vadim Bendebury <vbendeb@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1648923 Reviewed-by: Mary Ruthven <mruthven@chromium.org>
* fpsensor: Replace ccprintf/s with CCPRINTF/STom Hughes2019-06-071-11/+11
| | | | | | | | | | | | | | | The CCPRINTF/S macro provides more control over the logging output and we already use it everywhere else in the file. BRANCH=none BUG=b:124773209 TEST=make buildall -j TEST=view log messages in FP console Change-Id: Idbdbfe7a5fdb590288e9926aabf21412cfe50549 Signed-off-by: Tom Hughes <tomhughes@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1646883 Reviewed-by: Nicolas Norvez <norvez@chromium.org>
* common: Add EC_CMD_LOCATE_CHIPDaisuke Nojiri2019-06-063-29/+56
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch replaces EC_CMD_I2C_LOOKUP with EC_CMD_LOCATE_CHIP. This is a more generic command which locates a peripheral chip in i2c or other bus types. Additionally, it includes the following changes: - Change chip (device) type # of CBI_EEPROM (from 1 to 0). - Support TCPCs. localhost ~ # ectool locatechip 0 0 BUS: I2C; Port: 0; Address: 0x50 (7-bit format) localhost ~ # ectool locatechip 1 0 BUS: I2C; Port: 0; Address: 0x0b (7-bit format) localhost ~ # ectool locatechip 1 1 BUS: I2C; Port: 1; Address: 0x29 (7-bit format) localhost ~ # ectool locatechip 1 2 EC result 11 (OVERFLOW) Index too large localhost ~ # ectool locatechip 2 Usage: locatechip <type> <index> <type> is one of: 0: CBI_EEPROM 1: TCPCs <index> instance # of <type> Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> BUG=none BRANCH=none TEST=Verified ectool locatechip work on Nami. Change-Id: I1a773ced65b1c5ce3656f03eff04a6eadd4bc5ff Reviewed-on: https://chromium-review.googlesource.com/1614582 Commit-Ready: Daisuke Nojiri <dnojiri@chromium.org> Tested-by: Daisuke Nojiri <dnojiri@chromium.org> Legacy-Commit-Queue: Commit Bot <commit-bot@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org> Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
* common: motion_sense: Spread timestamps in motion sense fifoYuval Peress2019-06-061-35/+305
| | | | | | | | | | | | | | | | | | | | | | | | | | | | This changes moves the specialized logic for timestamp spreading away from the accelgyro_lsm6dsm and into the main motion_sense loop. The motion_sense_fifo_add_data function was replaced by a stage equivalent, and a commit function was added. Similarly, internal static functions for motion_sense.c were renamed to use the stage terminology. The idea is: When a sensor is read, it might provide more than one measurement though the only known timestamp is the one that caused the interrupt. Staging this data allows us to use the same fifo queue space that the entries would consume eventually anyway without making the entries readable. Upon commit, the timestamp entries are spread if needed. Note that if tight timestamps are disabled, the commit becomes a simple tail move. BUG=chromium:966506 BRANCH=None TEST=Ran CTS on arcada. Change-Id: Ib7d0a75c9c56fc4e275aed794058a5eca58ff47f Signed-off-by: Yuval Peress <peress@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1637416 Reviewed-by: Jack Rosenthal <jrosenth@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org>
* fpsensor: Add instructions for using screen instead of minicomTom Hughes2019-06-061-1/+18
| | | | | | | | | | | | | | Also increase timeout to provide enough time to hit enter when download prompt pops up. BRANCH=none BUG=b:124996507 TEST=fpcapture from fingerprint console Change-Id: I1e608161aceae4431dedcaffd648d20549b97a8b Signed-off-by: Tom Hughes <tomhughes@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1593956 Reviewed-by: Nicolas Norvez <norvez@chromium.org>
* tpm: reset command_ready bit when entering idle stateVadim Bendebury2019-06-051-4/+6
| | | | | | | | | | | | | | | | | | | | TPM could enter idle state even when current command has not yet been fully processed (for instance if the AP releases locality at an arbitrary moment). The status register command_ready bit needs to be unconditionally reset when TPM enters idle state. BRANCH=cr50, cr50-mp BUG=none TEST=verified reliable behavior during lengthy concurrent runs of processes accessing TPM. The same type of testing was causing occasional TPM lockups before this fix. Change-Id: I6e1dc334713c666e4ef566d41bd0cbff841f1179 Signed-off-by: Vadim Bendebury <vbendeb@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1643828 Reviewed-by: Andrey Pronin <apronin@chromium.org>
* chocodile_vpdmcu: Firmware refactoringSam Hurst2019-06-058-324/+2357
| | | | | | | | | | | | | | | | | Move code in header files into c source files. BUG=b:133341676 BRANCH=none TEST=manual Charge-Through was tested on an Atlas running a DRP USB-C/PD state machine with CTUnattached.SNK and CTAttached.SNK states. Change-Id: Ib1b51a778b937e02908f0bc8866bc91a39831163 Signed-off-by: Sam Hurst <shurst@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1626036 Reviewed-by: Jett Rink <jettrink@chromium.org> Commit-Queue: Sam Hurst <shurst@google.com> Tested-by: Sam Hurst <shurst@google.com>
* 8042: Only send back ACK in response to reset command(0xff)Furquan Shaikh2019-06-051-3/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 8042 keyboard command reset (0xff) was returning ACK(0xfa) as well as BAT(0xaa). From [1], 0xaa seems to be represent OK. However, the spec does not expect OK to be sent in response to reset command. Coreboot libpayload 8042 driver was recently updated to send a reset command on initialization to make it work with certain payloads. Sending back 0xaa along with ACK seems to make the initialization fail because it is not expecting anything other than ACK. This change gets rid of the return value 0xaa that was being sent for reset command. [1] http://zet.aluzina.org/images/d/d4/8042.pdf BUG=b:134366527 BRANCH=None TEST=Verified that keyboard initialization no longer fails in depthcharge. Change-Id: I0ac917dc94aa381ab705474cd7bcf494fb8b10d6 Signed-off-by: Furquan Shaikh <furquan@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1641756 Reviewed-by: Frank Wu <frank_wu@compal.corp-partner.google.com> Reviewed-by: Duncan Laurie <dlaurie@google.com> Tested-by: Frank Wu <frank_wu@compal.corp-partner.google.com> Tested-by: Furquan Shaikh <furquan@chromium.org> Commit-Queue: Furquan Shaikh <furquan@chromium.org>
* common: queue: Update chunk struct and get read/write logicYuval Peress2019-06-051-9/+15
| | | | | | | | | | | | | | | | | | | | | | | | This change updates the queue_get_write_chunk and queue_get_read_chunk logic to return an updated queue_chunk. The new chunk uses a void * for the buffer and replaces length with count. This more tightly aligns to how the rest of the queue functions operate. Further, it adds the ability to offset the write chunk. This is important as it allows wrapping. For example: With a queue of 8 units, 1 byte each. Assume H=2, T=5. Previously, we were only able to ever get the 3 bytes at 5-7. Using the offset of 3 though, we can now also get the 2 byte write chunk 0-1. BUG=chromium:966506 BRANCH=None TEST=Added unit tests Change-Id: I40216c36aa0dc95ec4d15fc587d4b1f08a17ef73 Signed-off-by: Yuval Peress <peress@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1637415 Reviewed-by: Enrico Granata <egranata@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org>
* Add OWNERS files for fingerprintTom Hughes2019-06-051-0/+7
| | | | | | | | | | | | BRANCH=none BUG=chromium:967924 TEST=none Change-Id: Ief50a64d45cc6862fab3417e3f8350d3c581209e Signed-off-by: Tom Hughes <tomhughes@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1633909 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-by: Nicolas Norvez <norvez@chromium.org>
* Move fingerprint files to their own directoryTom Hughes2019-06-054-1/+17
| | | | | | | | | | | | | | We will be adding more files in the future, so this declutters the common directory. It also lets us add a separate OWNERS file. BRANCH=none BUG=chromium:968518 TEST=make buildall -j Change-Id: I22c08851fe2d5fbdb5beff8cc72a68618c85fb0e Signed-off-by: Tom Hughes <tomhughes@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1637440 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
* charge_manager: customize dedicated port propertiesTing Shen2019-06-051-10/+42
| | | | | | | | | | | | | | | | | | | Kukui's pogo charger breaks the basic assumption of a dedicated charger. Add board specific functions to customize them. Also add a check to make sure the value of DEDICATED_CHARGE_PORT is good. BUG=b:128386458 TEST=combine with CL:1535087, verify that `ectool usbpdpower 1` correctly reports its status. BRANCH=None Change-Id: I6c698ea6a6fb4ab765f87c6fea0b35d5a757295a Signed-off-by: Ting Shen <phoenixshen@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1569090 Reviewed-by: Yilun Lin <yllin@chromium.org> Tested-by: Ting Shen <phoenixshen@chromium.org> Commit-Queue: Ting Shen <phoenixshen@chromium.org>
* USB PD: Only maintain contracts over sysjump when sinkingDiana Z2019-06-041-9/+18
| | | | | | | | | | | | | | | | | | | | | | Currently, the pd_task will attempt to maintain both source and sink contracts after an unlocked sysjump or unlocked EC reset. However, the pd_task will disable Vbus to any partners it was sourcing, causing the soft reset process to lead to a hard reset and disconnection. Since the port partner will be without Vbus and unable to respond, treat the contract as terminated and the port as the default state. BUG=b:132110509 BRANCH=octopus TEST=unlocked sysjumps with a display port dongle and hoho to ensure they were treated as disconnected, unlocked sysjumps with charger to ensure it was soft reset Change-Id: Ie477f393ea828a4e880c8e8ccbe72539e8be721a Signed-off-by: Diana Z <dzigterman@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1639212 Reviewed-by: Jett Rink <jettrink@chromium.org> Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
* USB PD: Disable Vconn as well as Vbus on initDiana Z2019-06-041-1/+7
| | | | | | | | | | | | | | | | | | | | | | Currently, the pd_task will call a power supply reset during init which cuts Vbus to the port partner. However, on a sysjump we may still be sourcing Vconn to a partner which will leave it in an inconsistent state of having Vconn but no Vbus. Depending on the port partner's power topology, they may even feedback some amount of voltage on Vbus, causing them to be detected as a charger. After disabling Vbus to the port partner, disable Vconn as well. BUG=b:132110509 BRANCH=octopus TEST=unlocked EC resets and sysjumps with a display port dongle and hoho, ensuring neither was detected as a low power charger after Change-Id: Ica9b72167bc981faeaebac18bac476ca9b7bfe7f Signed-off-by: Diana Z <dzigterman@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1639211 Reviewed-by: Jett Rink <jettrink@chromium.org> Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
* common: board_[read/write]_serial weak reference cleanupDenis Brockus2019-06-031-22/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | board_read_serial and board_write_serial were prototyped as weak and this made all instances, that included that prototype, weak as well. In order to not lose information from the prototype, default and override functions, I changed to use the override weak marker symbols. These functions defaulted for specific configurations as different functionality and used an #ifdef tree to do this. I made these a single definition for each function and used IS_ENABLED instead of the #ifdef tree. I also added a definition for the case that the configuration would not have produced a function. BUG=none BRANCH=none TEST=make buildall -j Change-Id: Ie41c53f3a17d665358e46eefd3ded3066ee80a7d Signed-off-by: Denis Brockus <dbrockus@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1631583 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org> Reviewed-by: Jack Rosenthal <jrosenth@chromium.org> Commit-Queue: Jett Rink <jettrink@chromium.org>
* Makefile: Replace flag -DX with -DX= to be supported by IS_ENABLED().Yilun Lin2019-06-031-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | IS_ENABLED works for an empty-string-defined macro. However, -D options default to define the macro to 1. This CL forces those macros, such as BOARD_* CHIP_*, CORE_*, CHIP_VARIANT_* and CHIP_FAMILIY_*, to be defined as an empty string, so that it can be supported by IS_ENABLED macro. TEST=use if(IS_ENABLED(BOARD_KRANE)) and see compilation success. TEST=compares build directory w/ and w/o this CL, and see the .smap are the same: ls build/*/*/ec.*.smap | sed -e 's|build/||' | \ xargs -I{} diff -u -a build/{} build.new/{} BUG=none BRANCH=None Change-Id: I96e2aa1cb5f3369e5e445a674595a9234f26707a Signed-off-by: Yilun Lin <yllin@google.com> Reviewed-on: https://chromium-review.googlesource.com/1627840 Commit-Ready: Yilun Lin <yllin@chromium.org> Tested-by: Yilun Lin <yllin@chromium.org> Legacy-Commit-Queue: Commit Bot <commit-bot@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org> Reviewed-by: Jack Rosenthal <jrosenth@chromium.org> Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
* flash_log_vc: return proper error valueVadim Bendebury2019-06-031-1/+1
| | | | | | | | | | | | | | | | | | | | | Vendor command handler should return a vendor command error code which is ORed with VENDOR_RC_ERR by the vendor command routing function. Before this patch flash log vendor command handler was returning VENDOR_RC_ERR, which is filtered out by gsctool resulting in a return value of zero when there in fact is an error. BRANCH=cr50, cr50-mp BUG=b:132287488 TEST=with appropriate fixes in gsctool (coming in the next patch) was able to run concurrently for a long time a process constantly adding log entries using Cr50 CLI command, and a process constantly retrieving log entries using 'gsctool -L' Change-Id: I2094c0b342d65e6c2a382079f81fb10fc8bacab9 Signed-off-by: Vadim Bendebury <vbendeb@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1639093 Reviewed-by: Andrey Pronin <apronin@chromium.org>
* common/i2c_master: Add a subcommand to protect all TCPC portsKarthikeyan Ramasubramanian2019-05-302-32/+29
| | | | | | | | | | | | | | | | | | | | | | | | Currently the I2C tunnels of all TCPC ports are protected implicitly when the system jump is disabled. Depthcharge issues that command after the EC jumps to RW and before the TCPC firmware update is applied. This leads to failure while updating the TCPC firmware and hence a reboot loop. Fix this behavior by adding a sub-command to protect all the I2C tunnels so that depthcharge can issue that command after both EC SW Sync and TCPC Firmware update are done. BUG=b:129545729 BRANCH=None TEST=make -j buildall; Boot to ChromeOS. Force a TCPC FW update and ensure that the reboot loop does not happen. Change-Id: I5dd2314cf82dcfff520dc32ce3ced232326ab3d5 Signed-off-by: Karthikeyan Ramasubramanian <kramasub@google.com> Reviewed-on: https://chromium-review.googlesource.com/1605260 Commit-Ready: Karthikeyan Ramasubramanian <kramasub@chromium.org> Tested-by: Karthikeyan Ramasubramanian <kramasub@chromium.org> Legacy-Commit-Queue: Commit Bot <commit-bot@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org> Reviewed-by: Diana Z <dzigterman@chromium.org>
* Prevent power on with disconnected batteryDiana Z2019-05-301-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | Currently, if a battery is disconnected but reporting a charge percentage over CONFIG_CHARGER_MIN_BAT_PCT_FOR_POWER_ON_WITH_AC, a system will be allowed to boot despite the battery not providing power yet. This change verifies that the battery is connected, as well as having a high enough charge percentage before allowing boot. BUG=b:133724948 BRANCH=octopus TEST=verified casta can power on once CONFIG_CHARGER_MIN_BAT_PCT_FOR_POWER_ON_WITH_AC is passed and battery is connected Change-Id: Ide9fe041a328bbeaeee8b9e7f9788b5731ac80ea Signed-off-by: Diana Z <dzigterman@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1635531 Reviewed-by: Justin TerAvest <teravest@chromium.org> Reviewed-by: Karthikeyan Ramasubramanian <kramasub@chromium.org> Commit-Queue: Karthikeyan Ramasubramanian <kramasub@chromium.org> Tested-by: Karthikeyan Ramasubramanian <kramasub@chromium.org> Legacy-Commit-Queue: Commit Bot <commit-bot@chromium.org>
* chgmgr: Allow boards to customize supplier_priorityDaisuke Nojiri2019-05-291-2/+2
| | | | | | | | | | | | | | | | | | | Currently, supplier_priority is shared across boards. This patch makes it weakly defined so that boards can customize it. Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> BUG=none BRANCH=none TEST=Verify BC12, PD work on Flapjack. buildall. Change-Id: Ie1e73758c611414512425121164bf7d56cf02697 Reviewed-on: https://chromium-review.googlesource.com/1622889 Commit-Ready: Daisuke Nojiri <dnojiri@chromium.org> Tested-by: Daisuke Nojiri <dnojiri@chromium.org> Legacy-Commit-Queue: Commit Bot <commit-bot@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org> Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
* common: Remove unnecessary null checkJacob Garber2019-05-281-3/+0
| | | | | | | | | | | | | | | | supported_modes is an array of structs, and addresses of array elements cannot be null. BUG=none BRANCH=none TEST=none Change-Id: I1268e024ba8b2469d1bc70be27b3e98044a7ac04 Signed-off-by: Jacob Garber <jgarber1@ualberta.ca> Found-by: Coverity CID 141742 Reviewed-on: https://chromium-review.googlesource.com/1629279 Legacy-Commit-Queue: Commit Bot <commit-bot@chromium.org> Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
* fpsensor: move hardware-independent code to fpsensor_state.cYicheng Li2019-05-283-165/+159
| | | | | | | | | | | | | | | | Split common/fpsensor.c so that it contains only hardware-dependent code, and put hardware-independent code to common/fpsensor_state.c. This facilitates unit testing of hardware-independent code. BRANCH=nocturne BUG=chromium:952275 TEST=ran unittests Change-Id: I0c050c7affa83e7cb935e2b657b2823cafe4c35f Signed-off-by: Yicheng Li <yichengli@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1625774 Legacy-Commit-Queue: Commit Bot <commit-bot@chromium.org> Reviewed-by: Nicolas Norvez <norvez@chromium.org>
* common: Remove duplicate error checkJacob Garber2019-05-281-3/+1
| | | | | | | | | | | | | | | | This argument count check is already performed at the beginning of the function and is useless anyway since we've already accessed argv[1]. BUG=none BRANCH=none TEST=none Change-Id: I9f1de3c5e67bb0db5564d8a1161b2ae646e8dfe9 Signed-off-by: Jacob Garber <jgarber1@ualberta.ca> Found-by: Coverity CID 141743 Reviewed-on: https://chromium-review.googlesource.com/1629277 Legacy-Commit-Queue: Commit Bot <commit-bot@chromium.org> Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
* PECI: Move non-chipset specific PECI code to common folderVijay Hiremath2019-05-282-0/+166
| | | | | | | | | | | | | | | | | | | | | | | The Platform Environment Control Interface (PECI) is a thermal management standard with one-wire bus interface that provides a communication channel between Intel processor and chipset components to external monitoring or control devices. As we can read the CPU temperature over PECI more accurately than the thermistors, we can eliminate usage of thermistors for reading CPU temperature. BUG=b:128666114 BRANCH=none TEST=Manually tested on Dragonegg, able read CPU temperature. Change-Id: Ie0845ca776e6a7e14511dc9315d6d83cdd5f09a6 Signed-off-by: Vijay Hiremath <vijay.p.hiremath@intel.com> Reviewed-on: https://chromium-review.googlesource.com/1622740 Commit-Ready: Vijay P Hiremath <vijay.p.hiremath@intel.com> Tested-by: Vijay P Hiremath <vijay.p.hiremath@intel.com> Legacy-Commit-Queue: Commit Bot <commit-bot@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org>
* usb_port_power_smart: support a new usb_charge_mode - USB_CHARGE_MODE_DEFAULT.Marco Chen2019-05-241-10/+3
| | | | | | | | | | | | | | | | | | | | | OS can leverage `ectool usbchargemode` to control the usb_charge_mode in the EC. In this case, we might want to set mode back to the default one defined in the config of board level therefore the new usb_charge_mode is added for this purpose. BUG=b:130767435 BRANCH=octopus TEST=1. make -j buildall 2. ectool usbchargemode 0 0x5 0 3. usb charging mode is set to CDP in Octopus board Change-Id: Ib7397993fc49e6c744dc55b9adace95dd6b8bd3a Signed-off-by: Marco Chen <marcochen@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1621452 Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com> Legacy-Commit-Queue: Commit Bot <commit-bot@chromium.org> Reviewed-by: Diana Z <dzigterman@chromium.org> Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
* usb_port_power_smart: data of USB_SYSJUMP_TAG is a struct not uint8_t.Marco Chen2019-05-241-5/+8
| | | | | | | | | | | | | | | | | | BUG=b:130767435 BRANCH=octopus TEST=1. `make buildall -j4` 2. execute `ectool usbchargemode 0 2 1` in EC RO stage. 3. jump to EC RW stage. 4. check whether charge_mode in RW is restored well in usb_charge_init() Change-Id: I57346d3d92fa58a4d07b7509846123fc8f0c93fc Signed-off-by: Marco Chen <marcochen@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1626890 Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com> Legacy-Commit-Queue: Commit Bot <commit-bot@chromium.org> Reviewed-by: Diana Z <dzigterman@chromium.org> Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
* nvmem: make page header checksums different between prod and devVadim Bendebury2019-05-241-13/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | When moving an H1 between prod and dev Cr50 images, it is important to quickly determine that the NVMEM contents are not retrievable. The first object verified by the initialization routine is the page header, but since SHA value is used for integrity verification, it does not change despite the fact that the mode (and encryption keys as a result) changed. Using encrypted header value for integrity verification guarantees that when transition between prod and dev modes happen the initialization function discovers it right away and reinitializes NVMEM instead of trying to interpret corrupted objects. The host/dcrypto stub used for unit tests and fuzzing needs to be modified to ensure that page headers read from uninitialized flash do not look valid (where encrypted value of 0xffffffff is 0xffffffff). BRANCH=cr50, cr50-mp BUG=b:129710256 TEST=make buildall -j successd, as well as migration of a Chrome OS device from legacy to new nvmem layout. Change-Id: I613513cc67b14f553d2760919d6058f8dbed6e41 Signed-off-by: Vadim Bendebury <vbendeb@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1615423 Legacy-Commit-Queue: Commit Bot <commit-bot@chromium.org> Reviewed-by: Andrey Pronin <apronin@chromium.org>
* nvmem: do not run when crypto is disabledVadim Bendebury2019-05-241-0/+23
| | | | | | | | | | | | | | | | | | There is no point in trying any nvmem operations when encryption/decryption services are not available. Test changes necessary to make sure test app compiles and runs successfully. BRANCH=cr50, cr50-mp BUG=b:132800220 TEST=The device does not crash any more after tpm is disabled. Change-Id: I97f9afc6e4d5377162500fc757084e4d5a57d37d Signed-off-by: Vadim Bendebury <vbendeb@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1615424 Legacy-Commit-Queue: Commit Bot <commit-bot@chromium.org> Reviewed-by: Andrey Pronin <apronin@chromium.org>
* usb/mux: Do not connect MUX when PD disconnectedstabilize-12222.BRuibin Chang2019-05-231-10/+27
| | | | | | | | | | | | | | | | | | | | | | | | | | | | When chipset power up to S5->S3 state set PD_EVENT_POWER_STATE_CHANGE, pd task set mux usb mode whether c-port is attached or not. If c-port is nothing attached at the setting moment, then mux detects nothing and goes to low power state. Plug-in type-c usb device, after debounce pass, we set mux usb mode and mux responds i2C NAK (due to in low power mode). This CL changes that do not connect MUX when PD disconnected. For example ps8751 is used for mux case. When power up(S5->S3), we should set mux none mode whether c-port is attached or not. Once type-c usb device plug-in, after cc debounce pass, we will set mux usb mode in X_DEBOUNCE_DISCONNECT state. BRANCH=None BUG=b:133196882 TEST=After console cmd reboot and reboot hard, type-c usb device plug-in on ampton and get type-c port status by "ectool usbpdmuxinfo". Change-Id: Ia538af48c450e12af1438a6aa9a6e4e426e2f616 Signed-off-by: Ruibin Chang <Ruibin.Chang@ite.com.tw> Reviewed-on: https://chromium-review.googlesource.com/1609262 Legacy-Commit-Queue: Commit Bot <commit-bot@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org> Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
* motionsense: Convert in_spoof_mode to a more generic flagsYuval Peress2019-05-231-11/+14
| | | | | | | | | | | | BUG=b:129159505 BRANCH=arcada TEST=I ran `make buildall` since this change isn't used yet it doesn't affect run-time behavior. Change-Id: I01857d679b800f9b53762c659ebd9a018cbf16db Signed-off-by: Yuval Peress <peress@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1612251 Legacy-Commit-Queue: Commit Bot <commit-bot@chromium.org>
* flash_log: add vendor command, timestamp base accessorVadim Bendebury2019-05-231-1/+35
| | | | | | | | | | | | | | | | The new vendor command allows to get and increase the flash log timestamp base. BRANCH=cr50, cr50-mp BUG=b:132287488 TEST=verified in the next patch in the series. Change-Id: Idc76012b7e7894b95cd70eeffeb50562a91b9656 Signed-off-by: Vadim Bendebury <vbendeb@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1610720 Legacy-Commit-Queue: Commit Bot <commit-bot@chromium.org> Reviewed-by: Andrey Pronin <apronin@chromium.org> Reviewed-by: Namyoon Woo <namyoon@chromium.org>
* flash_log: add api for setting base timestampVadim Bendebury2019-05-231-6/+47
| | | | | | | | | | | | | | | | | | | | | | | | The Cr50 environment does not have a wall clock, which makes it impossible to associate flash log entries with real time. This patch provides an API which allows to set a base time value and then use it plus current Cr50 uptime to generate more sensible flash log timestamps. Care is taken to ensure that attempts to set timestamp base such that it would cause a log timestamps rollback do not succeed. A unit test is being added to verify this behavior. BRANCH=none BUG=b:132287488 TEST='make buildall -j' (which runs the new tests) succeeds. Change-Id: I7521df1bac5aef67e0cf634c183bf1618655f48d Signed-off-by: Vadim Bendebury <vbendeb@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1610719 Legacy-Commit-Queue: Commit Bot <commit-bot@chromium.org> Reviewed-by: Andrey Pronin <apronin@chromium.org>
* common: dptf: Guard against wild sensor IDsEvan Green2019-05-231-0/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | If developers have not set up TEMP_SENSOR_COUNT correctly, or the caller starts sending wild sensor_id or idx values down, then the EC will do arbitrary reads and writes over its own memory. In one case, the PD log buffer indices are next in memory, so we would see the following spew in the kernel (every 60 seconds, since the kernel only checks that often): [ 138.151937] PDLOG 2019/05/17 22:46:26.913 P0 Disconnected [ 138.158512] PDLOG 2019/05/17 22:46:04.936 P0 Disconnected [ 138.165066] PDLOG 2019/05/17 22:46:04.935 P0 Disconnected [ 138.171643] PDLOG 2019/05/17 22:46:04.935 P0 Disconnected [ 138.178162] PDLOG 2019/05/17 22:46:04.935 P0 Disconnected ... BUG=b:132999028 BRANCH=none TEST=Build and boot hatch, observe no more log spam Change-Id: If2e20972c3268e84bb4cdfa315c6b7f7cb76868f Signed-off-by: Evan Green <evgreen@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1623176 Legacy-Commit-Queue: Commit Bot <commit-bot@chromium.org> Reviewed-by: Furquan Shaikh <furquan@chromium.org> Reviewed-by: Scott Collyer <scollyer@chromium.org>
* common: dptf: Fix function name typoEvan Green2019-05-231-2/+2
| | | | | | | | | | | | | | s/dpft_check_temp_threshold/dptf_check_temp_threshold/ BUG=b:132999028 BRANCH=none TEST=make -j BOARD=hatch Change-Id: I453a154ee9e4a58ce88e7d6ffe34f14ae8b08d65 Signed-off-by: Evan Green <evgreen@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1623175 Legacy-Commit-Queue: Commit Bot <commit-bot@chromium.org> Reviewed-by: Furquan Shaikh <furquan@chromium.org>
* I2C: Make pass-through debug messages more informativeDaisuke Nojiri2019-05-211-22/+24
| | | | | | | | | | | | | | | | | | | | | | | | | | This patch makes debug printf messages more informative as follows: - All messages are prefixed with I2C_PTHRU - Don't print pointers for read or write buffers - Print out buffer data With the patch, messages will look as follows: [7.335059 I2C_PTHRU xfer port=1 addr=0x16 rlen=0 flags=0x3] out: 0x03 0x01 0xe0 Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> BUG=none BRANCH=none TEST=Verify the messages are printed as expected Change-Id: I144b2d1d517070b6cdb492f71baa7f20c27e29b9 Reviewed-on: https://chromium-review.googlesource.com/1604162 Commit-Ready: Daisuke Nojiri <dnojiri@chromium.org> Tested-by: Daisuke Nojiri <dnojiri@chromium.org> Legacy-Commit-Queue: Commit Bot <commit-bot@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org>
* USB-PD: Consolidate tcpc_config declarations in usb_pd_tcpm.hDaisuke Nojiri2019-05-211-1/+0
| | | | | | | | | | | | | | | | | | Currently, tcpc_config is declared in two places. This patch consolidates declarations in usb_pd_tcpm.h. Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> BUG=none BRANCH=none TEST=buildall Change-Id: I4f30d06b1eaeb6a83b664de76116d85d65a9fc97 Reviewed-on: https://chromium-review.googlesource.com/1616007 Commit-Ready: Daisuke Nojiri <dnojiri@chromium.org> Tested-by: Daisuke Nojiri <dnojiri@chromium.org> Legacy-Commit-Queue: Commit Bot <commit-bot@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org>