summaryrefslogtreecommitdiff
path: root/common
Commit message (Collapse)AuthorAgeFilesLines
* util: Add function to check whether a buffer is trivial (all 0x00 or all 0xff)Yicheng Li2019-10-042-10/+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
* kukui_scp: support CONFIG_PRESERVE_LOGSYilun Lin2019-10-041-1/+2
| | | | | | | | | | | | | | | | | Enable CONFIG_PRESERVE_LOGS to gather more information when SCP is crashed. TEST=1. crash scp 2. restart scp 3. restart timberslide to ensure the logs are fetched 4. see that untransmitted logs are fetched into /var/log/cros_scp.log BUG=b:140220117 BRANCH=none Change-Id: I12635afa6c92fd8fa9cc889ce75999f855f18db0 Signed-off-by: Yilun Lin <yllin@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1833943 Reviewed-by: Nicolas Boichat <drinkcat@chromium.org>
* fpsensor: Prepare positive match salt.Yicheng Li2019-10-042-2/+12
| | | | | | | | | | | | | | | | 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>
* audio_codec: fix compile errorTzung-Bi Shih2019-10-034-4/+4
| | | | | | | | | | | | | | | | | | | | | | Fixes compile error: error: initialization of 'int (*)(struct host_cmd_handler_args *)' from incompatible pointer type 'enum ec_status (*)(struct host_cmd_handler_args *)' [-Werror=incompatible-pointer-types] Commit 83d793839 ("host_command: Change host command return value to enum ec_status") changes return code to enum ec_status for host commands. Changes the function pointers accordingly. BRANCH=none BUG=chromium:1004831 BUG=b:123268236 TEST=make BOARD=kukui_scp clean && make BOARD=kukui_scp -j Change-Id: I8d38cbd732746b3fc0098b22d1faa2f04716d275 Signed-off-by: Tzung-Bi Shih <tzungbi@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1835881 Reviewed-by: Nicolas Boichat <drinkcat@chromium.org>
* fpsensor: Add hkdf-expand implementation for arbitrary output size.Yicheng Li2019-10-031-1/+57
| | | | | | | | | | | | | | 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>
* fpsensor: Fix public buildTom Hughes2019-10-032-0/+33
| | | | | | | | | | | | | | Add stubs for fp_sensor_init and fp_sensor_deinit when building without the private FP sensor files. BRANCH=none BUG=b:124773209,b:141924178 TEST=make buildall -j Change-Id: Ie85a4bb0e568b205ada0d378ae658e8fe478c0a9 Signed-off-by: Tom Hughes <tomhughes@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1834274 Reviewed-by: Nicolas Norvez <norvez@chromium.org>
* usbc: turn on/off vconn appropriatelyJett Rink2019-10-021-38/+34
| | | | | | | | | | | | | | | | | | - Ensure that Vconn does not turn off during a power role swap either way - Reduce the amount of time we wait for power supply and vconn power to be ready to the maximum of either (instead of adding their delays) - Drop unnecessary VCONN conditionals BRANCH=none BUG=none TEST=builds Change-Id: Ic1d43351e3407c246159570559de3588ee685640 Signed-off-by: Jett Rink <jettrink@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1825505 Reviewed-by: Sam Hurst <shurst@google.com> Reviewed-by: Denis Brockus <dbrockus@chromium.org>
* usbc: remove unnecessary tcpc CC readsJett Rink2019-10-024-361/+135
| | | | | | | | | | | | | | | | | | | | | | | 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-7/+25
| | | | | | | | | | | | | | | | | | | | 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-022-223/+173
| | | | | | | | | | | | | | | | | | | | | | 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-0258-171/+228
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* utils: Add strstrDaisuke Nojiri2019-10-011-0/+25
| | | | | | | | | | | | | | | | | | 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>
* cr50: nvmem: fix list_index after erased header at page endAndrey Pronin2019-10-011-3/+3
| | | | | | | | | | | | | | | | | Before this CL, if the last 4 bytes of the last page were not written, after reading those bytes to check if they contain a header, the mt was rewinded to the end of the previous container, but list_index stayed pointing to the next page. Which could lead to skipping pages when creating the next container. This CL fixes it. BRANCH=none BUG=b:140139297 TEST=running test_nvmem with CL:1828184 applied doesn't lead to error 14 Change-Id: Icc8d1b8eb5cfc0f0230706ed386c2ef9b4936cae Signed-off-by: Andrey Pronin <apronin@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1830372 Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
* cr50: nvmem: fix total vars overflow checkAndrey Pronin2019-10-011-1/+1
| | | | | | | | | | | | | | | | | | | Before this CL, when changing an already existing variable, setvar_() was ensuring that the new size of *all* variables is smaller than the limit for one variable. This CL fixes the check: now it checks that the new size of all variables is smaller than the total variables size limit. BRANCH=none BUG=b:141774726 TEST=running test_nvmem with CL:1828184 applied doesn't lead to overflows in setvar. Change-Id: Icc70d728a2d6986d98b686980081e1cbba132195 Signed-off-by: Andrey Pronin <apronin@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1829292 Reviewed-by: Vadim Bendebury <vbendeb@chromium.org> Commit-Queue: Jason Clinton <jclinton@chromium.org>
* cr50: nvmem: release var buf in setvar overflow caseAndrey Pronin2019-10-011-1/+3
| | | | | | | | | | | | | | | | | Before this CL, if overflow condition was detected for an existing variable, the buffer allocated by find_var() was not released. This CL fixes this issue. BRANCH=none BUG=b:141774483 TEST=running test_nvmem with CL:1828184 applied doesn't lead to memory leaks. Change-Id: Ie09561232a613fb1f90f9a9456af73106ceb44ff Signed-off-by: Andrey Pronin <apronin@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1829291 Reviewed-by: Vadim Bendebury <vbendeb@chromium.org> Commit-Queue: Jason Clinton <jclinton@chromium.org>
* cr50: debounce successive TPM reset pulsesVadim Bendebury2019-10-011-5/+2
| | | | | | | | | | | | | | | | | | | | | | | | | Some platforms generate more than one pulse when resetting, many Intel SOCs generate two pulses, some other chips could go even higher. TPM reset on Cr50 is processed asynchronously, repetitive pulses result in multiple reset processing cycles.In case pulses are coming too soon one after another this could cause some race conditions. Let's ignore repetitive reset pulses unless there has been an attempt by the host to read a register (which is usually the very first action of the AP when booting up). BRANCH=cr50, cr50-mp BUG=none TEST=observed that only one reset is happening on an Octopus device, while there are two pulses present on the PLT_RST_L line. Verified proper reboot multiple times in a row. Change-Id: Ie1b124d41be0388bd8e12d0084827782de62cfa0 Signed-off-by: Vadim Bendebury <vbendeb@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1755059 Reviewed-by: Mary Ruthven <mruthven@chromium.org>
* cleanup: fix byte access and ifdefs for BBRAM_PD2Jett Rink2019-09-301-3/+0
| | | | | | | | | | | | | | Ensure that PD2 is accessed as a single byte instead of 4 bytes and remove unnecessary ifdef guards in all chip implementations. BRANCH=none BUG=none TEST=builds Change-Id: I319d8d6a8456662235ab4d8dcda6bda7e8ed7c15 Signed-off-by: Jett Rink <jettrink@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1809938 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
* fpsensor: Deinit the sensor before clearing the contextTom Hughes2019-09-285-9/+50
| | | | | | | | | | | | | | | | | | | | 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-272-173/+223
| | | | | | | | | | | | | | | 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>
* usb_pd_protocol: add missing CPRINTF argumentCaveh Jalali2019-09-261-1/+1
| | | | | | | | | | | | | This adds the missing "port" argument to a printf. BUG=none BRANCH=none TEST=buildall passed, boots on atlas Change-Id: Ia0e27b323bf6f274efbd3498c8e7e5c7d7b81a1a Signed-off-by: Caveh Jalali <caveh@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1825875 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
* cleanup: remove copy of pd_cc_state enumJett Rink2019-09-263-20/+21
| | | | | | | | | | | | | | | | | | | | | 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>
* pd: Add Fast role swap to the PE state machineDenis Brockus2019-09-231-30/+145
| | | | | | | | | | | | | | Optimized code to use PRS path when possible in FRS execution. Added super state for shared path to default PRS path for debug. Unit tests will be created after the state machine changes are completed. BUG=b:138599955 BRANCH=none TEST=make buildall -j Change-Id: Ic9098dba6b86f161df9e6636194476aac5ecba56 Signed-off-by: Denis Brockus <dbrockus@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1809385
* USB-PD: SOP'/SOP" packet header fieldRuibin Chang2019-09-231-8/+20
| | | | | | | | | | | | | | | | | | | | SOP'/SOP" message header bit field: bit5:should reserved bit8:0b Message originated from a DFP or UFP 1b Message originated from a Cable Plug. reference: PD3.0 v2.0 spec table 6-1 message header. BUG=None BRANCH=None TEST=test on baord: reef_it8320 SRC connects to SNK via E-mark cable, sources Vconn successfully, check SOP' header bit field by Lecroy analyzer. Change-Id: Ie9b9d8507d84d5b4c694cc906eb7da8715b88a5f Signed-off-by: Ruibin Chang <Ruibin.Chang@ite.com.tw> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1725379 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
* cr50: Refactor access to U2F stateLouis Collard2019-09-231-14/+36
| | | | | | | | | | | | | | | | | | | | This moves U2F state from global variables to a struct that must be accessed through a function, which will load that state if it is not already loaded. This is to protect against accidental use of uninitialized global state. BRANCH=none BUG=b:140361043 TEST=flash to soraka, U2FTest, generate key, wait for deep sleep, authenticate using key Change-Id: I4681c00fbcfac71f4e178af52461f75a635cced5 Signed-off-by: Louis Collard <louiscollard@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1786885 Reviewed-by: Andrey Pronin <apronin@chromium.org>
* usb_pd: Send SOP' DiscIdent messages on SOP NAKsPrashant Malani2019-09-231-3/+19
| | | | | | | | | | | | | | | | | | | | | | 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-213-18/+30
| | | | | | | | | | | | | | | | | | | | | | 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>
* pd: Chunked TX State Machine changesDenis Brockus2019-09-191-43/+65
| | | | | | | | | | | | | | | | | Comment when TCH states are embedded. TCH_Message_Sent and TCH_Report_Error states were redundantly implemented inline. I added these states so it would match the spec more closely. BUG=none BRANCH=none TEST=make buildall -j Change-Id: Ib911aa8ac99be5eb0372e55b658a0542c02596fd Signed-off-by: Denis Brockus <dbrockus@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1773132 Reviewed-by: Jett Rink <jettrink@chromium.org>
* pd: RCH_Processing_Extended_Message cleanupDenis Brockus2019-09-191-19/+13
| | | | | | | | | | | | | | | Change first chunk processing to be handled embedded in RCH_Wait_For_Message_From_Protocol_Layer run to get the actual first chunk and don't rely on the chunk headers to indicate the first chunk BUG=none BRANCH=none TEST=make buildall -j Change-Id: Iadb606dfaca7b3f4d3ff6528dcfbd3e6aad196a4 Signed-off-by: Denis Brockus <dbrockus@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1773118
* chip/mt_scp: support software gainTzung-Bi Shih2019-09-191-0/+11
| | | | | | | | | | | | | | | | | | | 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-193-0/+78
| | | | | | | | | | | | | | | | | | 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-1/+414
| | | | | | | | | | | | | | | | | | | | | | 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-32/+33
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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/+235
| | | | | | | | | | | | | | | | | | | | 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-183-7/+2
| | | | | | | | | | | | | | | | 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>
* rollback: Remove unnecessary shadow variableCraig Hesling2019-09-171-2/+0
| | | | | | | | | | | | | | | | | | | | | | | | | BRANCH=none BUG=none TEST=make buildall -j TEST=make BOARD=nocturne_fp ssh dut1 mount -oremount,rw / scp build/nocturne_fp/ec.bin dut1:~/ # CCD Cr50 Console wp disable # Back to host ssh dut1 flash_fp_mcu '~/ec.bin' ssh dut1 touch /opt/google/biod/fw/.disable_fp_updater ssh dut1 rm -rf '/var/log/*' ssh dut1 reboot # FPMCU UART Console > version > rollback Change-Id: If88fda706198184abfc47188eec31f7817c986da Signed-off-by: Craig Hesling <hesling@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1808066 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
* usb_pd: Remove unused port argument from functionsPrashant Malani2019-09-171-5/+5
| | | | | | | | | | | | | | | dfp_discover_identity() and dfp_discover_svids() don't seem to be using the "port" argument. So, remove it. BUG=None BRANCH=None TEST=make -j tests; make -j buildall Change-Id: Ica8c8b96512932c8a905a49c6594dc79ca04fea0 Signed-off-by: Prashant Malani <pmalani@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1806363 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-by: Benson Leung <bleung@google.com>
* Change get_shmem_size() to max allocatable bytesGurleen Grewal2019-09-171-1/+3
| | | | | | | | | | | | | BUG=b/140066993 TEST=run "make buidall" and verify that test nvmem passed, In cr50 console: "flashread 0 7000" should succeed Change-Id: If3979559da5d61c27bbca7639a220fca862bbc91 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1802158 Tested-by: Gurleen Grewal <gurleengrewal@chromium.org> Tested-by: Gurleen Grewal <gurleengrewal@google.com> Reviewed-by: Vadim Bendebury <vbendeb@chromium.org> Commit-Queue: Vadim Bendebury <vbendeb@chromium.org>
* pd: Exit DP mode on sysjumpSam Hurst2019-09-173-22/+28
| | | | | | | | | | | | | | | 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>
* audio_codec: add I2S RX abstract layerTzung-Bi Shih2019-09-172-0/+120
| | | | | | | | | | | | | | | | | | | | | | Common I2S RX host commands: - set_sample_depth - set_daifmt - set_bclk 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_I2S_RX in board.h 6. make BOARD=kukui_scp -j Change-Id: I9031bad5429f51ab9f911098f38ed7eb0fa59d18 Signed-off-by: Tzung-Bi Shih <tzungbi@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1564503 Commit-Queue: Sean Abraham <seanabraham@chromium.org> Reviewed-by: Nicolas Boichat <drinkcat@chromium.org>
* audio_codec: support software gainTzung-Bi Shih2019-09-171-0/+30
| | | | | | | | | | | | | | | | | | | | Chip or board can define a scaler for software gain for up to 8 channels. 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. make BOARD=kukui_scp -j Change-Id: I38418ca9bda7973f35d35947a55cad8180eb4df0 Signed-off-by: Tzung-Bi Shih <tzungbi@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1683027 Commit-Queue: Sean Abraham <seanabraham@chromium.org> Reviewed-by: Cheng-Yi Chiang <cychiang@chromium.org> Reviewed-by: Nicolas Boichat <drinkcat@chromium.org>
* audio_codec: add DMIC abstract layerTzung-Bi Shih2019-09-172-0/+78
| | | | | | | | | | | | | | | | | | | Common DMIC host commands: - get_max_gain - get_gain_idx - set_gain_idx 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. make BOARD=kukui_scp -j Change-Id: I7b4cc11645675f9d790947b17c3ea385dae13483 Signed-off-by: Tzung-Bi Shih <tzungbi@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1564502 Commit-Queue: Sean Abraham <seanabraham@chromium.org> Reviewed-by: Nicolas Boichat <drinkcat@chromium.org>
* audio_codec: add common abstract layerTzung-Bi Shih2019-09-172-0/+139
| | | | | | | | | | | | | | | | | | | | | | Common utilities: - register shared memory (SHM) - console channel Common host commands: - get_capabilities - get_shm_addr - set_shm_addr BRANCH=none BUG=b:122027734, b:123268236 TEST=1. define CONFIG_AUDIO_CODEC in board.h 2. make BOARD=kukui_scp -j Change-Id: I90e3e112bf8fdffc13eb486e0c608c264650768b Signed-off-by: Tzung-Bi Shih <tzungbi@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1616882 Reviewed-by: Nicolas Boichat <drinkcat@chromium.org> Commit-Queue: Sean Abraham <seanabraham@chromium.org>
* pd: RX msgs are dropped while in the TCH_WAIT_FOR_TRANSMISSION_COMPLETE StateSam Hurst2019-09-161-8/+2
| | | | | | | | | | | | | | | | | | | | | Pass received messages to Received Chunk State machine if Transmit Chunk State Machine is not in TCH_WAIT_FOR_MESSAGE_REQUEST_FROM_PE and TCH_WAIT_FOR_TRANSMISSION_COMPLETE. This prevents received messages from being dropped when in the TCH_WAIT_FOR_TRANSMISSION_COMPLETE state. The state machine functionality is the same. BUG=b:140886587 BRANCH=none TEST=manual Change-Id: I7464b56da7ccc8523ad36d9f0c862f7d4f5e550e Signed-off-by: Sam Hurst <shurst@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1799126 Tested-by: Sam Hurst <shurst@google.com> Reviewed-by: Denis Brockus <dbrockus@chromium.org> Commit-Queue: Sam Hurst <shurst@google.com>
* pd: Fix Incorrect Message Header Rev number sent to port partnerSam Hurst2019-09-161-1/+2
| | | | | | | | | | | | | | | | | | When constructing a message, the current SOP* is used instead of the last SOP*. And last SOP* is cleared on port detach. BUG=b:140865004 BRANCH=none TEST=manual   Used Total Phase analyzer to verify that correct Message Header   Revisions. Change-Id: I7f09746a36c9bcd4380ab6c6544f04b7079189ed Signed-off-by: Sam Hurst <shurst@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1797371 Tested-by: Sam Hurst <shurst@google.com> Reviewed-by: Denis Brockus <dbrockus@chromium.org> Commit-Queue: Sam Hurst <shurst@google.com>
* pd: pd_send_vdm function causes an assert when called from non pd taskSam Hurst2019-09-161-3/+0
| | | | | | | | | | | | | | | | pd_send_vdm is an API function that can be called from any task but it generates an assert if called outside the pd task. BUG=b:140939776 BRANCH=none TEST=manual Change-Id: Id5c61542ba3b6422fb08dc8de88694b120fb9043 Signed-off-by: Sam Hurst <shurst@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1801854 Tested-by: Sam Hurst <shurst@google.com> Reviewed-by: Denis Brockus <dbrockus@chromium.org> Commit-Queue: Denis Brockus <dbrockus@chromium.org>
* common/btle_ll.c: define default return valuePatrick Georgi2019-09-121-1/+1
| | | | | | | | | | | | | | | Found by Coverity Scan #160945 BUG=none BRANCH=none TEST=none Change-Id: I9689d88785db721c48c29d793c5b783a6f4dd583 Signed-off-by: Patrick Georgi <pgeorgi@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1801205 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org> Tested-by: Patrick Georgi <pgeorgi@chromium.org> Commit-Queue: Patrick Georgi <pgeorgi@chromium.org>
* common/flash.c: Support finding the flash_bank_index for offset 0Patrick Georgi2019-09-121-0/+3
| | | | | | | | | | | | | | | | | | According to the algorithm that's always the first entry, but it always returned -1 so far. Found by Coverity Scan #174434 BUG=none BRANCH=none TEST=none Change-Id: Idd3f2794b559bea47f8425791351a8d0bc1424d6 Signed-off-by: Patrick Georgi <pgeorgi@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1793583 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org> Tested-by: Patrick Georgi <pgeorgi@chromium.org> Commit-Queue: Patrick Georgi <pgeorgi@chromium.org>
* tablet_mode: expose console command.Ravi Chandra Sadineni2019-09-121-0/+37
| | | | | | | | | | | | | | Expose console command to force tablet mode. This helps in testing whether a given device wakes on tablet mode switch. BUG=b:133262012 BRANCH=None TEST=Deploy on hatch and play with the command. Change-Id: Id6ffbf5226590e10a0758a07761f78024d57bb58 Signed-off-by: Ravi Chandra Sadineni <ravisadineni@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1797370 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
* tcpm: Hold tPSHardReset after receiving hard reset from sink deviceYilun Lin2019-09-101-4/+6
| | | | | | | | | | | | | | | | USB-PD3.0 ver1.2 "7.3.13 Sink Initiated Hard Reset" Policy Engine should wait tPSHardReset after receiving Hard Reset. TEST=Pass the USB-PD Compliance Test TDA.2.3.1.1: POW-SRC-LOAD-P-PC TDA.2.3.1.2: POW-SRC-LOAD-CP-ACC BUG=b:139914412 BRANCH=none Change-Id: I2595d9f8618de7ec85e834195d77cd9928d198f6 Signed-off-by: Yilun Lin <yllin@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1770331 Reviewed-by: Jett Rink <jettrink@chromium.org>
* cutoff: ensure logs are flushed before cut-offYilun Lin2019-09-101-0/+2
| | | | | | | | | | | | | | Logs may not appear in the console without flush if battery been cut-off. TEST=See the logs are flushed to console before cutoff BRANCH=None BUG=None Change-Id: I73363856c50dea1ec409b8041d96227d6538bcc3 Signed-off-by: Yilun Lin <yllin@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1772863 Reviewed-by: Nicolas Boichat <drinkcat@chromium.org>