summaryrefslogtreecommitdiff
path: root/include
Commit message (Collapse)AuthorAgeFilesLines
...
* common:test: Add comparators to test_util.hstabilize-12593.BYuval Peress2019-10-121-0/+4
| | | | | | | | | | | | | Add <, <=, >, >= tests to test_util.h BUG=None BRANCH=None TEST=buildall Change-Id: I5d8ddfc3eda59f0193707c77d52d97962ef1a325 Signed-off-by: Yuval Peress <peress@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1853694 Reviewed-by: Gwendal Grignou <gwendal@chromium.org>
* usbc: update CRCReceiveTimerJett Rink2019-10-101-3/+6
| | | | | | | | | | | | | | | | | Shorten the CRCReceiveTimer and document that either the pe send or error function will get called in response to a prl_ send message. BRANCH=none BUG=none TEST=build; Change-Id: Icc43886cadfdcd67c943b25aebfdfb55b2693ade Signed-off-by: Jett Rink <jettrink@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1825514 Tested-by: Denis Brockus <dbrockus@chromium.org> Commit-Queue: Denis Brockus <dbrockus@chromium.org> Reviewed-by: Denis Brockus <dbrockus@chromium.org> Reviewed-by: Edward Hill <ecgh@chromium.org>
* fpsensor: Enable positive match secret and positive match salt on enrollment.Yicheng Li2019-10-092-4/+9
| | | | | | | | | | | | | | | | | | | | | | On enrollment success, generate new positive_match_salt and send it as part of the encrypted blob. Also enable positive match secret to be read. The positive_match_salt is used to derive positive_match_secret and is different from the encryption salt for encrypting the templates. The positive_match_salt needs to be sent to biod and stored with templates because it needs to be re-uploaded to FPMCU the next time the user logs in. The positive match secret needs to be sent to biod so that it knows what to compare against at a match. BRANCH=nocturne BUG=chromium:927095 TEST=make -j buildall TEST=tested enrollment, matching and multifinger on DUT nocturne Change-Id: I3e44a972ee17c5a93bddd52340f8f2249836463a Signed-off-by: Yicheng Li <yichengli@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1828058 Reviewed-by: Nicolas Norvez <norvez@chromium.org> Reviewed-by: Tom Hughes <tomhughes@chromium.org>
* usb_pd: drop duplicate func get_max_request_mv()Yilun Lin2019-10-091-6/+0
| | | | | | | | | | | | | | The function is added by chromium:1737899 and is duplicate of pd_get_max_voltage(). TEST=make buildall -j BUG=None BRANCH=firmware-kukui-12573.B Change-Id: Ida1f56d108573a1776dcec8460dd48439427d10d Signed-off-by: Yilun Lin <yllin@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1847513 Reviewed-by: Denis Brockus <dbrockus@chromium.org>
* common: Add more macros for making unsigned intsHarry Cutts2019-10-091-2/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | A `UINT32_FROM_BYTE_ARRAY_BE` macro would be good to have for https://crrev.com/i/1898937, and since it seems there are use cases for for a little-endian variant of that and a big-endian variant for uint16_t, add those as well. BRANCH=none BUG=none TEST=Add the following host command somewhere and manually verify the results: static int command_macro_test(int argc, char **argv) { uint8_t bytes[] = { 0x01, 0x23, 0x45, 0x67 }; CPRINTF("Bytes (all hex): %02X, %02X, %02X, %02X\n", bytes[0], bytes[1], bytes[2], bytes[3]); CPRINTF("16 bits (using first two bytes of array):\n"); CPRINTF("UINT16_FROM_BYTE_ARRAY_LE(bytes, 0): %04X\n", UINT16_FROM_BYTE_ARRAY_LE(bytes, 0)); CPRINTF("UINT16_FROM_BYTE_ARRAY_BE(bytes, 0): %04X\n", UINT16_FROM_BYTE_ARRAY_BE(bytes, 0)); CPRINTF("32 bits:\n"); CPRINTF("UINT32_FROM_BYTE_ARRAY_LE(bytes, 0): %08X\n", UINT32_FROM_BYTE_ARRAY_LE(bytes, 0)); CPRINTF("UINT32_FROM_BYTE_ARRAY_BE(bytes, 0): %08X\n", UINT32_FROM_BYTE_ARRAY_BE(bytes, 0)); return EC_SUCCESS; } DECLARE_CONSOLE_COMMAND(macro_test, command_macro_test, "", "Test the UINT macros"); Change-Id: I7c2053c846f43d369402c01c0d46ce8546e4923a Signed-off-by: Harry Cutts <hcutts@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1848259 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
* common: add `RETURN_ERROR` macroHarry Cutts2019-10-091-0/+7
| | | | | | | | | | | | | | This had been used in the GT7288 driver, but is now being used quite a bit in the private repo, so it's time to put it in common. BRANCH=none BUG=chromium:1008568 TEST=Check that a board which uses the GT7288 driver builds correctly. Change-Id: I111018a73def7a30ff899f9bf435da6f89d9b86a Signed-off-by: Harry Cutts <hcutts@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1848493 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
* npcx: Ensure the watchdog isn't stopped while it is invalid to do soJett Rink2019-10-091-0/+7
| | | | | | | | | | | | | | | | | | | We cannot unlock the watchdog timer within 3 watch dog ticks of touching it per the datasheet. This is actually around 100ms so we should protect against this. Note: To avoid bringing in other dependencies into the npcx_monitor_fw, the "old" method of stopping the watchdog is used (no waiting first). BRANCH=none BUG=b:140207603 TEST=eliminates cold reset issue. Change-Id: I440d36fb9aecdd6d78bae6fc4002208198a3357f Signed-off-by: Jett Rink <jettrink@chromium.org> Signed-off-by: Tim Wawrzynczak <twawrzynczak@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1842592 Reviewed-by: ML Chao <mlchao@nuvoton.corp-partner.google.com>
* fpsensor: Implement command to read positive_match_secret.Yicheng Li2019-10-093-1/+59
| | | | | | | | | | | | | | | | | | | | | Add EC command to read positive_match_secret on match success. If the attempt to read is 5 seconds after the match, the read is not allowed (the readable bit for positive match secret is cleared). Test that the command can read the data correctly and can read for each finger only once. Test that attempt to read secret after deadline will be rejected. BRANCH=nocturne BUG=chromium:927095 TEST=make buildall TEST=tested enrollment, matching and multifinger on DUT nocturne TEST=tested that if biod requests to download template and secret for a finger that's not currently matched, reading secret will fail. Change-Id: Idc734c6392d271e2aaee1cddf7c2c5b81b727b4a Signed-off-by: Yicheng Li <yichengli@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1679372 Reviewed-by: Nicolas Norvez <norvez@chromium.org>
* usbc: fix cc interpretation errorJett Rink2019-10-081-0/+1
| | | | | | | | | | | | | | Ensure that two Rp values are interpreted as a debug accessory. Added unit test for meaningful combinations. BRANCH=none BUG=none TEST=passes unit test. Change-Id: Ia454382f20f9377edc944dc01be133e062c218b0 Signed-off-by: Jett Rink <jettrink@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1845811 Reviewed-by: Edward Hill <ecgh@chromium.org>
* fpsensor: Prepare derivation of positive match secret.Yicheng Li2019-10-082-0/+14
| | | | | | | | | | | | | | | | | Implement derivation of positive match secret for a template. This derivation will be used when biod sends a command to ask for positive match secret and the secret readable bit is set. Also add unit tests for this derivation. BRANCH=nocturne BUG=chromium:927095 TEST=make -j buildall TEST=tested enrollment, matching and multifinger on DUT nocturne Change-Id: Ife477a98573284f69c5fb07e814d9a3d09f92127 Signed-off-by: Yicheng Li <yichengli@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1639440 Reviewed-by: Nicolas Norvez <norvez@chromium.org>
* pd: FRS enable/disable and interrupt handlingDenis Brockus2019-10-074-0/+30
| | | | | | | | | | | BUG=b:138599955 BRANCH=none TEST=make buildall -j Change-Id: I0c639aae18e8c2c2d1b457e2e209f8484a834f6b Signed-off-by: Denis Brockus <dbrockus@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1825507 Reviewed-by: Edward Hill <ecgh@chromium.org>
* ppc: add AOZ1380 driverDenis Brockus2019-10-061-1/+4
| | | | | | | | | | | BUG=b:138599218 BRANCH=none TEST=make buildall -j Change-Id: Ib06053b2129623683fece8a63ee182d52cb07422 Signed-off-by: Denis Brockus <dbrockus@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1833922 Reviewed-by: Edward Hill <ecgh@chromium.org>
* ppc: cleanup ppcDenis Brockus2019-10-061-0/+5
| | | | | | | | | | | | | | Allow limited PPC chips to default to EC_ERROR_UNIMPLEMENTED for functions in the driver that are not needed. BUG=b:138599218 BRANCH=none TEST=make buildall -j Change-Id: I5242ef285eb277c06d516ab09f7a74f76d7d34b2 Signed-off-by: Denis Brockus <dbrockus@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1829405 Reviewed-by: Edward Hill <ecgh@chromium.org>
* ec_commands: Obsolete v0 and declare v1 of host command EC_CMD_POWER_INFOTim Wawrzynczak2019-10-051-7/+60
| | | | | | | | | | | | | | | | | | | | | v0 of this command is no longer used (no handler is defined), so it is removed. The new host command version gives the AP the ability to dynamically change its power settings based on the battery status, A/C, USB-PD, and the static configuration of the system and its battery. Also modified ectool to support v1 of this command and deprecate support for v0. BUG=b:139840435 BRANCH=master TEST=buildall Change-Id: I516d838581400314e626fd679ca1c5afd5e34ff6 Signed-off-by: Tim Wawrzynczak <twawrzynczak@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1825880 Reviewed-by: Paul Fagerburg <pfagerburg@chromium.org> Reviewed-by: Furquan Shaikh <furquan@chromium.org>
* printf: Deprecate %lEvan Green2019-10-051-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The semantics of %l changed during the enabling of compile-time printf format checking. Old firmware branches will treat something like %lx as a 64-bit value, but new code on master will enforce at compile-time that a long (32-bits on our ECs) is passed in as the argument. This creates a dangerous and difficult to notice situation if the following code is cherry-picked from master into an old firmware branch: printf("%lx %s", myval32, mystr); On master, this behaves correctly. On the old firmware branch, this would swallow myval32 and mystr for %lx, and then %s would grab a random stack pointer and print a string from it. Deprecating %l is our mechanism for keeping such a printf from creeping into master in the future. Obviously we can't protect against someone that checks in code that's never tested, but anyone who tests a printf with %l in it will notice their printf comes out with ERROR instead of what they want. BUG=chromium:984041 TEST=make -j buildall BRANCH=None Change-Id: I0267430363af7954c2ec5d2c45222759fe0ec2c1 Signed-off-by: Evan Green <evgreen@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1834604 Reviewed-by: Jack Rosenthal <jrosenth@chromium.org>
* include: De-longify CC_MASK() and CC_ALLEvan Green2019-10-051-2/+2
| | | | | | | | | | | | | | | These are consistently stored into 32-bit values, so there's no need for their macros to be suffixed with a long designator. BUG=chromium:984041 TEST=make -j buildall BRANCH=None Signed-off-by: Evan Green <evgreen@chromium.org> Change-Id: I0618cb30cf1afa5e0e015006e2eee9c9abfc5402 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1834602 Reviewed-by: Jack Rosenthal <jrosenth@chromium.org> Reviewed-by: caveh jalali <caveh@chromium.org>
* include: De-longify BIT() macroEvan Green2019-10-051-1/+1
| | | | | | | | | | | | | | | | | | | | | | | The BIT() macro was recently introduced to make things more comfortable to upstream Linux. However, there's no need for it to be a long. Change the macro back to being an int (int and long are the same on 32-bit platforms, which all of our ECs are), so that we can reduce the number of %l specifiers. The semantics of %l have changed, we are deprecating its use on master to reduce the risk that we accidentally cherry-pick one of those printfs to an old firmware branch. BUG=chromium:984041 TEST=make -j buildall BRANCH=None Change-Id: I95b9cd49895cc67998dcb1de9bab5b5591d93243 Signed-off-by: Evan Green <evgreen@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1834601 Reviewed-by: Jack Rosenthal <jrosenth@chromium.org> Reviewed-by: caveh jalali <caveh@chromium.org>
* printf: Enable compile-time format checkingEvan Green2019-10-054-0/+5
| | | | | | | | | | | | | | | Add annotations to allow the compiler to check printf-style format strings in the EC. BUG=chromium:984041 TEST=make -j buildall BRANCH=None Change-Id: Ic39f37f8362372de7d289becea684d9da535599a Signed-off-by: Evan Green <evgreen@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1733101 Reviewed-by: Jack Rosenthal <jrosenth@chromium.org> Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
* printf: Fix formatting errorsEvan Green2019-10-051-2/+2
| | | | | | | | | | | | | | | | | | | This change fixes the printf formatting errors found by the compile-time prinf format checker. The errors fall into a few categories: 1. Incorrect size specifier (missing or extra l). 2. Missing or extra arguments. 3. Bad line splitting. BUG=chromium:984041 TEST=make -j buildall BRANCH=none Change-Id: I5618097a581210b9fcbfc81560dec050ae30b61c Signed-off-by: Evan Green <evgreen@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1819653 Reviewed-by: Jack Rosenthal <jrosenth@chromium.org>
* printf: Correct semantics of %lEvan Green2019-10-051-1/+1
| | | | | | | | | | | | | | | | | | | | | In the standard, %l[dioux] takes an integer of type long. In the EC up until now, we had been using it as shorthand for a 64-bit long. Now that we're enabling the compile-time printf format checker, it's time to correct the semantics of %l. This is a breaking change. I would advise against cherry-picking this commit into any firmware branches. The reasoning is that the specifier now swallows a different number of arguments, causing any subsequent specifiers to be wrong. BUG=chromium:984041 TEST=make -j buildall BRANCH=None Change-Id: Ia5630e59611097dc0deda648498c7f43b9c62ac9 Signed-off-by: Evan Green <evgreen@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1829576 Reviewed-by: Jack Rosenthal <jrosenth@chromium.org>
* printf: Convert %l to %llEvan Green2019-10-051-2/+3
| | | | | | | | | | | | | | | | | | | | | In order to make our printf more standard, utilize %ll for long long arguments, rather than %l. This does cost a little bit in flash space for that extra l in a couple of places, but enables us to turn on compile-time printf format checking. For this commit only, the semantics are such that both %l and %ll take 64-bit arguments. In the next commit, %l goes to its correct behavior of taking a sizeof(long) argument. BUG=chromium:984041 TEST=make -j buildall BRANCH=none Cq-Depend:chrome-internal:1863686,chrome-internal:1860161,chrome-internal:1914029 Change-Id: I18081b55a8dbf5ef8ec15fc499ca75e59d31da58 Signed-off-by: Evan Green <evgreen@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1819652 Reviewed-by: Jack Rosenthal <jrosenth@chromium.org>
* printf: Add support for %zEvan Green2019-10-051-0/+1
| | | | | | | | | | | | | | | | When printing size_t sized integers, utilize the standard %z modifier so that the specifier format is correct. This will enable us to turn on compile-time printf format verification. BUG=chromium:984041 TEST=make -j buildall BRANCH=none Cq-Depend:chrome-internal:1860160 Change-Id: I2c95df5c0d87677cb9fcbde33ab8846708a774a1 Signed-off-by: Evan Green <evgreen@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1819651 Reviewed-by: Jack Rosenthal <jrosenth@chromium.org>
* builtin: Introduce and use inttypes.hEvan Green2019-10-052-2/+5
| | | | | | | | | | | | | | | | | | | | | In order to pass the right printf format specifiers for certain types that are compiled both in 32-bit EC and 64-bit host environments, standard macros PRIx64 and PRId64 must be introduced. These specify the correct printf format specifier in the given compilation environment for printing a 64-bit value. On the host, inttypes.h already exists. Add an inttypes.h for the EC codebase so that these macros can be used where they're needed. BUG=chromium:984041 TEST=make -j buildall BRANCH=none Change-Id: I76e3bdc88aef7da6e5234d5b86b595f7138ea9a1 Signed-off-by: Evan Green <evgreen@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1819642 Reviewed-by: caveh jalali <caveh@chromium.org> Reviewed-by: Jack Rosenthal <jrosenth@chromium.org>
* printf: Convert %b to %pbEvan Green2019-10-051-0/+15
| | | | | | | | | | | | | | | | | | | | | | | | In order to turn on compile-time printf format checking, non-standard specifiers like %b (binary) must be removed. Convert that into %pb, which takes a pointer to a structure containing the value to print, and how many bits to print. Use the convenience macro BINARY_VALUE() to package these values up into a struct whose pointer is passed to printf(). Technically this is slightly more limited functionality than we used to support given all the possible flags, field width, and precision. However every existing instance in our codebase was using %0NNb, where NN is some number. If more variants are needed, the parameters structure can be expanded in the future. BUG=chromium:984041 TEST=make -j buildall BRANCH=None Change-Id: I8ef995dcf97af688fbca98ab6ff59b84092b69e3 Signed-off-by: Evan Green <evgreen@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1733100 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
* printf: Convert %h to %phEvan Green2019-10-052-4/+19
| | | | | | | | | | | | | | | | | | | | | In order to make printf more standard, use %ph. Pass a pointer to a struct describing the buffer, including its size. Add a convenience macro so that conversion between the old style and new style is purely mechanical. The old style of %h cannot be converted directly to %ph as-is because the C standard doesn't allow flags, precision, or field width on %p. Ultimately the goal is to enable compile-time printf format checking. This gets us one step closer to that. BUG=chromium:984041 TEST=make -j buildall BRANCH=None Cq-Depend:chrome-internal:1559798,chrome-internal:1560598 Change-Id: I9c0ca124a048314c9b62d64bd55b36be55034e0e Signed-off-by: Evan Green <evgreen@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1730605
* printf: Convert %T to %pTEvan Green2019-10-052-3/+6
| | | | | | | | | | | | | | | | | | | | | | In order to be more compliant to standards, and ultimately turn on compile-time printf format validation, switch the non-standard %T into %pT, which takes a pointer to a 64-bit timestamp as an argument. For convenience, define PRINTF_TIMESTAMP_NOW, which will use the current time as the timestamp value, rather than forcing everyone to pass a pointer to get_time().val. For a couple of instances, simply use CPRINTS instead. BUG=chromium:984041 TEST=make -j buildall BRANCH=None Cq-Depend:chrome-internal:1473305 Change-Id: I83e45b55a95ea27256dc147544ae3f7e39acc5dd Signed-off-by: Evan Green <evgreen@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1704216 Reviewed-by: Jack Rosenthal <jrosenth@chromium.org> Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
* printf: Fix up %p to %pPEvan Green2019-10-051-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | In order to avoid landmines later with future extensions to %p, disallow %p by itself. The danger is that we'll have something like: printf("%pFOO", myptr), and then later will add a %pF extension, but miss this printf (maybe the string is split, maybe it's just missed). Missing a conversion during extension is worse than just seeing a print like <ptr_val>OO, since %pF likely reaches through the pointer and interprets its contents according to whatever F means. Convert existing uses of %p to %pP, so they're explicitly printing a pointer value, giving us flexibility to extend in the future. BUG=chromium:984041 TEST=make -j buildall BRANCH=None Cq-Depend:chrome-internal:1560879 Change-Id: I36a4bee8d41cb9a6139171f8de0d8f2f19468132 Signed-off-by: Evan Green <evgreen@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1730604 Reviewed-by: Jack Rosenthal <jrosenth@chromium.org>
* util: Add function to check whether a buffer is trivial (all 0x00 or all 0xff)Yicheng Li2019-10-041-0/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This function's execution time depends only on the buffer length but not on the specific bytes in the buffer. BRANCH=nocturne BUG=chromium:927095 TEST=make -j buildall TEST=timed the execution of bytes_are_trivial() on a long array with the following contents: Array 1: 0x01, 0x00, 0x00, 0x00, ..., 0x00, 0x00 (first byte nontrivial) Array 2: 0x00, 0x00, 0x00, 0x00, ..., 0x00, 0x02 (last byte nontrivial) Array 3: 0x00, 0x00, ... , 0x00, 0x03, 0x00, ..., (middle byte nontrivial) Array 4: 0x00, 0x00 , ... (trivial) (These 4 arrays have the same length.) Verified that execution on these arrays take similar amount of time, proportional to the length of the array, specifically: For 256k bytes, takes 21~40 microseconds For 128k bytes, takes 10~17 microseconds For 64k bytes, takes 5~9 microseconds For 32k bytes, takes 2~5 microseconds Because the host timer inaccuracy and potential process scheduling variations, the execution time for arrays 1-4 are sometimes not exactly the same. To avoid test flakiness, this timing test is not written to unit tests. But it should prove that bytes_are_trivial() is a constant time algorithm. Change-Id: I131748e1a4ee3a3e19a105dba5dc443bb2371d30 Signed-off-by: Yicheng Li <yichengli@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1787870
* fpsensor: Prepare positive match salt.Yicheng Li2019-10-041-0/+4
| | | | | | | | | | | | | | | | On enrollment success, generate random positive match salt. This will be used in the derivation of positive match secret. BRANCH=nocturne BUG=chromium:927095 TEST=make -j buildall TEST=tested enrollment, matching, deletion and multifinger on DUT nocturne. Change-Id: I4ad55a0221c4aa1f6e3cc56b66c2165ad9455ba0 Signed-off-by: Yicheng Li <yichengli@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1719385 Reviewed-by: Nicolas Norvez <norvez@chromium.org>
* fpsensor: Add hkdf-expand implementation for arbitrary output size.Yicheng Li2019-10-031-0/+23
| | | | | | | | | | | | | | This can be used to replace hkdf_expand_one_step in more general cases of HKDF. Also add unit tests for this. BRANCH=nocturne BUG=none TEST=make -j buildall Change-Id: Ie116b13ee33d171298eccabb8a37b59e702d0218 Signed-off-by: Yicheng Li <yichengli@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1719871 Reviewed-by: Nicolas Norvez <norvez@chromium.org>
* usbc: remove unnecessary tcpc CC readsJett Rink2019-10-021-3/+8
| | | | | | | | | | | | | | | | | | | | | | | We only need to read the CC pins when the CC evt is fired otherwise the CC pins should have the same value. It is actually incorrect/undesirable that our old PD stack queried the tpcp cc driver over i2c so frequently for the CC pins status. Also single source code that interprets the CC lines values into a UFP or DFP state. Lastly, remove extraneous timers for cc debouncing, we only need one. BRANCH=none BUG=none TEST=builds Change-Id: I65baa2e6fb92d7ab5ca12daa76225cd13b9ab974 Signed-off-by: Jett Rink <jettrink@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1825504 Reviewed-by: Denis Brockus <dbrockus@chromium.org> Reviewed-by: Sam Hurst <shurst@google.com> Commit-Queue: Denis Brockus <dbrockus@chromium.org>
* fpsensor: Add async FP_CMD_CONTEXTTom Hughes2019-10-021-0/+12
| | | | | | | | | | | | | | | | | | | | Setting the context now triggers a reset of the sensor library (see I3e25bdf7eaaf99f3801547e11a6c524f924f4726), which in turn will end up calling fp_sensor_open to re-initialize the sensor. Since some calibration is performed in that command, it takes ~173 ms, which is close enough to the EC command timeout (200 ms) that it often fails. This change makes the command "asynchronous" so that userspace can poll for the result and avoid the command timeout. BRANCH=nocturne BUG=b:137288498 TEST=make buildall -j TEST=ectool --name=cros_fp fpcontext 01234567890123456789012345678901 Change-Id: I997bf9c5b9e90eceb5375dccffcb535529a86e47 Signed-off-by: Tom Hughes <tomhughes@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1819115 Reviewed-by: Yicheng Li <yichengli@chromium.org>
* Revert "common: Refactor motion_sense_fifo"Scott Collyer2019-10-021-47/+33
| | | | | | | | | | | | | | | | | | | | | | This reverts commit 36b47ab3c06e477f5e95d6d9e84a5220248784e6. With this CL the lid angle calculation on hatch devices reports 500 which is what's used for can't caluclate a meaninfgul value. BUG=b:141840539 BRANCH=None TEST=On helios tested with this CL and saw that lid angle calculations returned 500 for lid angle. Then reverted the CL and verifed that lid angle calculations were correct. Used 'accelinfo on 10000' to check the EC reported lid angle. Change-Id: Id4e36219792d00357d2885e9944c58fe0e15c5ca Signed-off-by: Scott Collyer <scollyer@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1834705 Tested-by: Scott Collyer <scollyer@chromium.org> Reviewed-by: Yuval Peress <peress@chromium.org> Reviewed-by: Furquan Shaikh <furquan@chromium.org> Commit-Queue: Scott Collyer <scollyer@chromium.org>
* host_command: Change host command return value to enum ec_statusTom Hughes2019-10-024-5/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | If the host command handler callback function returns an int, it's easy to accidentally mix up the enum ec_error_list and enum ec_status types. The host commands always expect an enum ec_status type, so we change the return value to be of that explicit type. Compilation will then fail if you accidentally try to return an enum ec_error_list value. Ran the following commands and then manually fixed up a few remaining instances that were not caught: git grep --name-only 'static int .*(struct host_cmd_handler_args \*args)' |\ xargs sed -i 's#static int \(.*\)(struct host_cmd_handler_args \*args)#\ static enum ec_status \1(struct host_cmd_handler_args \*args)##' git grep --name-only 'int .*(struct host_cmd_handler_args \*args)' |\ xargs sed -i 's#int \(.*\)(struct host_cmd_handler_args \*args)#\ enum ec_status \1(struct host_cmd_handler_args \*args)##' BRANCH=none BUG=chromium:1004831 TEST=make buildall -j Cq-Depend: chrome-internal:1872675 Change-Id: Id93df9387ac53d016a1594dba86c6642babbfd1e Signed-off-by: Tom Hughes <tomhughes@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1816865 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-by: Jack Rosenthal <jrosenth@chromium.org>
* battery: add precharge voltageTing Shen2019-10-011-1/+7
| | | | | | | | | | | | | | | Add a precharge_voltage field to batt_info in case we need its value differ from voltage_min, and set precharge_voltage = 3.4V according to battery spec. BUG=b:139012899 TEST=observe the charging curve (see issue link above for test result) BRANCH=master Change-Id: I2e4b240a12cd023ed90aaeda922e10b262508624 Signed-off-by: Ting Shen <phoenixshen@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1795491 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
* utils: Add strstrDaisuke Nojiri2019-10-011-0/+10
| | | | | | | | | | | | | | | | | | The strstr API searches for s2 in s1 and returns the pointer to the substring found in s1. Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> BUG=none BRANCH=none TEST=make run-utils_str Change-Id: I30f5e8d03e304d28dd6e9bfeebfcaeee2e79ea85 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1818727 Tested-by: Daisuke Nojiri <dnojiri@chromium.org> Auto-Submit: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org> Commit-Queue: Jett Rink <jettrink@chromium.org>
* fpsensor: Deinit the sensor before clearing the contextTom Hughes2019-09-282-3/+7
| | | | | | | | | | | | | | | | | | | | The opaque context contains sensor state that we can't nuke from underneath the sensor library. Calling fp_sensor_deinit will release this context and allow us to safely clear the context. BRANCH=none BUG=b:124773209 TEST="fpenroll" followed by "fpclear" in the FP console TEST=On nocturne, in the UI, enroll finger, log out, and log in => then lock and unlock with finger TEST=make buildall -j Change-Id: I3e25bdf7eaaf99f3801547e11a6c524f924f4726 Signed-off-by: Tom Hughes <tomhughes@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1647294 Reviewed-by: Nicolas Norvez <norvez@chromium.org> Commit-Queue: Yicheng Li <yichengli@chromium.org> Tested-by: Yicheng Li <yichengli@chromium.org>
* common: Refactor motion_sense_fifoYuval Peress2019-09-271-33/+47
| | | | | | | | | | | | | | | This change refactors the motion_sense_fifo to uniformly prefix all the functions to avoid collisions. It also adds several unit tests and fixes a few bugs with the fifo logic. BUG=b:137758297 BRANCH=None TEST=buildall & run CTS on arcada Change-Id: I7aae45382b07d6c8858e07215c33e710c7ed27ec Signed-off-by: Yuval Peress <peress@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1704166 Reviewed-by: Jack Rosenthal <jrosenth@chromium.org>
* util/comm-i2c: upgrade to host command protocol v3Harry Cutts2019-09-261-0/+6
| | | | | | | | | | | | | | | | | | | | | We can remove the v2 code, as any boards still using it have reached end-of-life, with the exception of Samus's PD, which we only communicate with via the Kernel driver, as far as I can tell. (I verified that an `ectool` built with this change can still be used to communicate with the Samus PD.) BRANCH=none BUG=none TEST=Checked various commands (hello, version, inventory...) with `--interface=i2c` and `comm_init_i2c` modified to hard-code the I2C bus to use (as the board I tested with is not yet in sysfs). The test board is using a MAX32660, so https://crrev.com/c/1716928 was patched in for testing. Change-Id: I1e014c6f747ce29d9bf1541be51c519af98e7f45 Signed-off-by: Harry Cutts <hcutts@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1803977 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
* cleanup: remove copy of pd_cc_state enumJett Rink2019-09-262-23/+16
| | | | | | | | | | | | | | | | | | | | | The EC command interface created a separate copy of the enum pd_cc_state. Remove the EC command version and move the pd_cc_state definition to the command interface. Also remove PD_CC_NO_UFP option as there is no difference between that value and PD_CC_NONE. Split PD_CC_DEBUG_ACC into separate UFP and DFP values for clarity. BRANCH=none BUG=none TEST=builds Change-Id: Ic8c4c5ac4dd340b1e605100e35acb147c226a455 Signed-off-by: Jett Rink <jettrink@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1825503 Reviewed-by: Denis Brockus <dbrockus@chromium.org> Reviewed-by: Sam Hurst <shurst@google.com>
* usb_pd: Send SOP' DiscIdent messages on SOP NAKsPrashant Malani2019-09-231-0/+1
| | | | | | | | | | | | | | | | | | | | | | Currently, the only scenario where an SOP' message is sent is when we receive a SOP DiscIdentity Response from the UFP. However, we should be able to query the cable characteristics even if the UFP responds with a NAK. So, add handling to send a SOP' DiscIdentity even if we receive a NAK. This will not otherwise disrupt the PD connection flow. Note that there may be other situations where SOP' messages can be sent, but aren't currently being sent. BUG=chromium:1005941 BRANCH=None TEST=make -j buildall; Test on a hatch with a Pixel 2 DUT. Cable correctly responds with Cable information even after the EC receives a UFP DiscIdentity NAK. Change-Id: Ia856f2eb1547f09ae1dc0318021ad9f2458fc25a Signed-off-by: Prashant Malani <pmalani@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1808057 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
* version: Make ver_get_num_commits work for on-flash imagesDaisuke Nojiri2019-09-212-2/+13
| | | | | | | | | | | | | | | | | | | | | | EFS needs to check whether a RW version on flash is equal to or newer for rollback protection before jumping to a RW copy. Currently, ver_get_numcommits works only for the running image. This makes it work for images on flash as well. Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> BUG=chromium:998135 BRANCH=none TEST=Boot Nami. Verify version numbers are read from RAM and flash. Change-Id: I94475e40f89dc4c3173d83cb1d9d4ad38d6fab79 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1450816 Reviewed-by: Jett Rink <jettrink@chromium.org> Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-by: Aseda Aboagye <aaboagye@chromium.org> Commit-Queue: Daisuke Nojiri <dnojiri@chromium.org> Tested-by: Daisuke Nojiri <dnojiri@chromium.org>
* chip/mt_scp: support software gainTzung-Bi Shih2019-09-191-0/+5
| | | | | | | | | | | | | | | | | | | Multiply the audio data by a gain value. Note that it get muted when gain is 0. BRANCH=none BUG=b:122027734, b:123268236 TEST=1. define CONFIG_AUDIO_CODEC in board.h 2. define CONFIG_AUDIO_CODEC_DMIC in board.h 3. define CONFIG_AUDIO_CODEC_DMIC_SOFTWARE_GAIN in board.h 4. define CONFIG_AUDIO_CODEC_DMIC_MAX_SOFTWARE_GAIN in board.h 5. define CONFIG_AUDIO_CODEC_WOV in board.h 6. make BOARD=kukui_scp -j Change-Id: I8c308ffb6d7c8f5bd378524bdffc980d7b9948fa Signed-off-by: Tzung-Bi Shih <tzungbi@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1683028 Reviewed-by: Nicolas Boichat <drinkcat@chromium.org>
* audio_codec: integrate speech-microTzung-Bi Shih2019-09-191-0/+47
| | | | | | | | | | | | | | | | | | Leverage speech-micro to detect hotword. BRANCH=none BUG=b:122027734, b:123268236, b:132319180 TEST=1. define CONFIG_AUDIO_CODEC in board.h 2. define CONFIG_AUDIO_CODEC_DMIC in board.h 3. define CONFIG_AUDIO_CODEC_DMIC_SOFTWARE_GAIN in board.h 4. define CONFIG_AUDIO_CODEC_DMIC_MAX_SOFTWARE_GAIN in board.h 5. define CONFIG_AUDIO_CODEC_WOV in board.h 6. make BOARD=kukui_scp -j Change-Id: I8b238fd8bd9af8e70d5a747650eb8b7dbf4200cb Signed-off-by: Tzung-Bi Shih <tzungbi@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1602453 Reviewed-by: Nicolas Boichat <drinkcat@chromium.org>
* audio_codec: add WoV abstract layerTzung-Bi Shih2019-09-193-0/+159
| | | | | | | | | | | | | | | | | | | | | | Common logic for Wake-on-Voice. - set hotword detection model - get notifications from the chip - read audio data from the chip - use the audio data to detect hotword - send host event to AP if hotword is detected BRANCH=none BUG=b:122027734, b:123268236 TEST=1. define CONFIG_AUDIO_CODEC in board.h 2. define CONFIG_AUDIO_CODEC_DMIC in board.h 3. define CONFIG_AUDIO_CODEC_DMIC_SOFTWARE_GAIN in board.h 4. define CONFIG_AUDIO_CODEC_DMIC_MAX_SOFTWARE_GAIN in board.h 5. define CONFIG_AUDIO_CODEC_WOV in board.h 6. make BOARD=kukui_scp -j Change-Id: I26f7a8dbf9a6d57b1845fbb0666aa1d8285d9013 Signed-off-by: Tzung-Bi Shih <tzungbi@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1490800
* tablet_mode: Renaming for GMR sensorPhilip Chen2019-09-192-20/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | GMR sensors can be used to (1) detect clamshell/tablet mode (2) detect lid open/closed But hall sensors can only do (2). Therefore the naming related to "hall sensor" for tablet mode application is incorrect. This patch performs the following renaming to better reflect the reality: config: CONFIG_HALL_SENSOR -> CONFIG_GMR_TABLET_MODE CONFIG_HALL_SENSOR_CUSTOM -> CONFIG_GMR_TABLET_MODE_CUSTOM CONFIG_DPTF_MOTION_LID_NO_HALL_SENSOR -> CONFIG_DPTF_MOTION_LID_NO_GMR_SENSOR GPIO: HALL_SENSOR_GPIO_L -> GMR_TABLET_MODE_GPIO_L functions: hall_sensor_disable() -> gmr_tablet_switch_disable() hall_sensor_isr() -> gmr_tablet_switch_isr() hall_sensor_int() -> gmr_tablet_switch_init() variable: hall_sensor_at_360 -> gmr_sensor_at_360 BUG=b:139378190 BRANCH=none TEST=make buildall Change-Id: I28393d056ddd128d8ffafc16a1f9fefee5455ccc Signed-off-by: Philip Chen <philipchen@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1757275 Reviewed-by: Furquan Shaikh <furquan@chromium.org> Reviewed-by: Aseda Aboagye <aaboagye@chromium.org> Commit-Queue: Philip Chen <philipchen@chromium.org> Tested-by: Philip Chen <philipchen@chromium.org>
* g: re-implement usb console with usb-stream configuration.Namyoon Woo2019-09-192-1/+8
| | | | | | | | | | | | | | | | | | | | This patch introduces CONFIG_USB_CONSOLE_STREAM, which implements usb-console with usb-stream configuration, intending to remove code redundancy between the previous implementation (usb_console.c) and usb_stream.c. Flash usage decreases by 224 bytes, and RAM usage by 40 bytes. BUG=b:138447451 BRANCH=cr50 TEST=Checked cr50 USB console and cr50 UART console respectively. Key-in response and output are working well: ./util/uart_stress_tester.py /dev/ttyUSB0 -t 300 --debug Change-Id: I305038e1db83dc49bb12a8afdbfcc2a8135d50f5 Signed-off-by: Namyoon Woo <namyoon@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1741302 Reviewed-by: Mary Ruthven <mruthven@chromium.org>
* config: Merge CONFIG_CHARGER_V2 into CONFIG_CHARGERKeith Short2019-09-182-6/+1
| | | | | | | | | | | | | | | | For all boards that defined CONFIG_CHARGER, CONFIG_CHARGER_V2 is also defined. Remove references to CONFIG_CHARGER_V2 from board header files. Replace CONFIG_CHARGER_V2 in common C modules with CONFIG_CHARGER when appropriate. BUG=b:139699769 BRANCH=none TEST=make buildall -j Change-Id: I6b54baf4ad2406bbed629b6b272dad9ea6a81280 Signed-off-by: Keith Short <keithshort@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1789420 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
* touchpad_gt7288: Basic driver for Goodix GT7288Harry Cutts2019-09-182-0/+9
| | | | | | | | | | | | | | | | | | | | | | A simple driver which allows touch reports and firmware version information to be read. If the appropriate config flag is set, console commands are included for testing. Unlike the other two touchpad drivers already implemented, which simply receive I2C HID events and send them straight out again over USB HID, we want to do some processing on the touchpad data in the board directory. For that reason, this driver leaves handling the touch interrupts up to the user. BRANCH=none BUG=none TEST=With https://crrev.com/c/1716928 patched, run the various host commands and check the output. Change-Id: Ia38e516473b78fb052ae18ca89acc5d815b53bd6 Signed-off-by: Harry Cutts <hcutts@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1799290 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
* pd: Exit DP mode on sysjumpSam Hurst2019-09-171-0/+8
| | | | | | | | | | | | | | | Exits all USB PD Alternate Modes after a system jump BUG=b:140807930 BRANCH=none TEST=manual Change-Id: Ie0843e0c9f1dcacecc2109cd0565a90cfafed306 Signed-off-by: Sam Hurst <shurst@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1797661 Tested-by: Sam Hurst <shurst@google.com> Reviewed-by: Denis Brockus <dbrockus@chromium.org> Commit-Queue: Denis Brockus <dbrockus@chromium.org>