summaryrefslogtreecommitdiff
path: root/common
Commit message (Collapse)AuthorAgeFilesLines
* cleanup: clean up reference to power role vs cable plugJett Rink2019-10-245-35/+50
| | | | | | | | | | | | | | The PD header specifies the power role for SOP packets and cable plug for SOP' and SOP" packets. Refactor code to make this more obvious. BRANCH=none BUG=none TEST=builds and new stack runs on hatch Change-Id: I6cdb1561082d2142214ac65703ff42586b16d70b Signed-off-by: Jett Rink <jettrink@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1865986 Reviewed-by: Denis Brockus <dbrockus@chromium.org>
* cr50: Remove concept of U2F modeLouis Collard2019-10-241-3/+0
| | | | | | | | | | | | | | | | | | This was previously used to enable/disable U2F or the extended mode. This was never used to disable U2F, and the distinction between U2F and extended mode is no longer required. BRANCH=none BUG=b:133275654 TEST=build, U2FTest, enable g2f mode in u2fd, check attestation certification does not change across multiple registrations Change-Id: I323fa245bf23fb12ffed75fb8dcfc81913bafff7 Signed-off-by: Louis Collard <louiscollard@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1786886 Reviewed-by: Andrey Pronin <apronin@chromium.org>
* main: Initialize I2C pretty earlyAlexandru M Stan2019-10-241-0/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Some devices (like the keyboard, CBI) need I2C access pretty early. Until now I2C would get initialized pretty late in a hook, which was far too late for some stuff. As a result from this change, CONFIG_I2C_MASTER now implies the i2c_init() function will be called at board boot. Some chips (cr50, host tests) needed a stub i2c_init in order to compile cleanly. BUG=b/138384267 TEST=EFS doesn't happen significantly later than it used to TEST=Recovery keys now work with I2C keyboard on jacuzzi TEST=make buildall TEST=Sanity check i2c behavior (booting, "i2scan", "battery") on a variety of ECs: * ampton (ite EC, x86 AP) * bobba (npcx EC, x86 AP) * jacuzzi (stm32f0 EC, ARM AP) * cheza (npcx EC, ARM AP) BRANCH=master Change-Id: Ifa830e8e509ff16b36b4dcc86617869b1cb86ac3 Signed-off-by: Alexandru M Stan <amstan@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1772490 Reviewed-by: Jett Rink <jettrink@chromium.org> Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
* cleanup: use power and data role enums instead of intJett Rink2019-10-243-18/+22
| | | | | | | | | | | | | | | Use first class enums types instead of int for power and data role. BRANCH=none BUG=none TEST=builds and new stack works with single charger on C1 hatch Change-Id: Ied4562e6a148803140cf277bd229b6c3ed801470 Signed-off-by: Jett Rink <jettrink@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1865985 Reviewed-by: Denis Brockus <dbrockus@chromium.org> Reviewed-by: Edward Hill <ecgh@chromium.org>
* usb: call pd_execute_data_swap within tc_set_dataJett Rink2019-10-241-74/+87
| | | | | | | | | | | | | | | | | | | | We need to let board specific code run any time we change the data role on our USB-C connection. When looking at all of the calls to tc_set_data_role, I realized that we don't really reset any data role until we start a new contract with SNK/SRC ready. We will do need to call into the code that disables the MUX lines when we detach. To do this, I created a super state for SNK/SRC unattached. BRANCH=none BUG=none TEST=builds. No board has an OTG signal using the new stack yet Change-Id: I017d20b2e1973b31ebf2b8925a7f8c5488a8ee24 Signed-off-by: Jett Rink <jettrink@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1864427
* usb: fix out bounds issue for non-SOP* packetsJett Rink2019-10-231-24/+35
| | | | | | | | | | | | | Non SOP* packets (e.g. hard reset) do not have a message counter, so do not try to access the message counter field. BRANCH=none BUG=chromium:1016109 TEST=reproduced fuzz failure locally then verified fix with prints Change-Id: I2e46b43988cba92636eb9da7f86448b037fbc0a8 Signed-off-by: Jett Rink <jettrink@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1872602
* mem_commands: Flag md and rw cmds as restrictedCraig Hesling2019-10-231-5/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This marks both the md and rw console commands as restricted. This alone does nothing, unless the specific board has enabled console flags, enabled restricted console commands, and provided an implementation for console_is_restricted(). The idea is to allow boards to deny access to these commands under some runtime condition, for example when system_is_locked(). Restricted console commands were introduced in crrev.com/c/376185/4. See crrev.com/c/1867388 as an example board usage. BRANCH=nocturne BRANCH=hatch BUG=b:142559996, b:142505927 TEST=# Test on nocturne_fp, since it has not enabled # console restricted commands, at this CL. # Note that this will not be the case in future CLs. make BOARD=nocturne_fp scp build/nocturne_fp/ec.bin dut1:~/ ssh dut1 flash_fp_mcu ./ec.bin # From FPMCU UART console version # Ensure that version is custom based on workstation syslock help # Ensure that md and rw are not prefixed with "-" help list # Ensure that no "Flags" column exists md 0x0 # Ensure that this successfully reads the word rw 0x24000000 # Ensure that this successfully reads the word TEST=A positive test case is done in crrev.com/c/1867388. Signed-off-by: Craig Hesling <hesling@chromium.org> Change-Id: Ica6b1f24d9b89186ad0ff854bb6e0786392fd1df Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1868430 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
* mocks: add tcpc and usb mux mocksJett Rink2019-10-235-0/+260
| | | | | | | | | | | | BRANCH=none BUG=none TEST=use them in CL stack with tests Change-Id: I8a970dc65f7395264a8c536977951ae305e9c24f Signed-off-by: Jett Rink <jettrink@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1868831 Reviewed-by: Denis Brockus <dbrockus@chromium.org> Reviewed-by: Edward Hill <ecgh@chromium.org>
* usb: Remove invalid data role from enumJett Rink2019-10-232-5/+10
| | | | | | | | | | | | | | | | The data role as defined in the USB spec is 1 bit. Disconnected does not fit and no one is using it properly. All users of Disconnected value alias the value to DFP anyway. Just use DFP explicitly BRANCH=none BUG=none TEST=builds and runs new stack on hatch Change-Id: I5c7dddea8f34c8e3c524da8701913c87c23b42b2 Signed-off-by: Jett Rink <jettrink@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1865984
* system.c: move jump_data declarations into sysjump.hCaveh Jalali2019-10-231-29/+1
| | | | | | | | | | | | | | | this moves the jump_data related declarations out of system.c into a dedicated sysjump_impl.h header file. this will make it possible to implement unit tests for sysjump. BRANCH=none BUG=b:142031466 TEST=make buildall passes Change-Id: I7df3d24e1f9c0f203656ee8dddc234b64e2dc8c3 Signed-off-by: Caveh Jalali <caveh@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1855647 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
* pd3.0: change soft reset path for explicit contract or notDenis Brockus2019-10-221-5/+17
| | | | | | | | | | | | | | | | | | | | | Changes for PD 3.0 spec version 2.0 State machine for Source Port Soft Reset and Protocol Error, new section 8.3.3.4.1 changed entry requirements to go to state PE_SRC_Send_Soft_Reset and PE_SRC_Ready. State machine for Sink Port Soft Reset and Protocol Error, new section 8.3.3.4.2 changed entry requirements to go to state PE_SNK_Send_Soft_Reset and PE_SNK_Ready. BUG=b:141468157 BRANCH=none TEST=make buildall -j Change-Id: Ibda109fa15c0bcab34472498920bef06806e0880 Signed-off-by: Denis Brockus <dbrockus@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1863710 Reviewed-by: Jett Rink <jettrink@chromium.org>
* usbc: Add missing IS_ENABLED(CONFIG_CHARGE_MANAGER) checksEdward Hill2019-10-182-7/+7
| | | | | | | | | | | | | | | Remove the need for stubs of charge_manager_set_ceil() by adding a few missing IS_ENABLED(CONFIG_CHARGE_MANAGER) checks. BUG=none BRANCH=none TEST=buildall Change-Id: Ia70434b05107747eb773ae30ee1de5b4bd8cbcea Signed-off-by: Edward Hill <ecgh@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1869401 Reviewed-by: Denis Brockus <dbrockus@chromium.org> Commit-Queue: Denis Brockus <dbrockus@chromium.org>
* pd: Extend READY_HOLD_OFF_US timer value for SRCScott Collyer2019-10-171-4/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | The READY_HOLD_OFF_US was set to 200 msec for both SNK and SRC connections. However, in the case of SRC, there can be a race condition with charge through hubs that initiate a power swap request and the SRC port sending the VDM discover idenity message. This CL makes the holdoff timer delay longer for SRC connections and prefixes READY_HOLD_OFF_US with SNK/SRC to differentiate the two timer values. BUG=b:140092163 BRANCH=None TEST=Tested with the AA-AM1N95W charge through hub. Verfied that this can be attached to Kohaku with external power already connected and successfully power role swap into source to charge the kohaku port. Tested 20-25 connections with no failures. Prior to this change the failure rate was 1 out of 3 attempts. Change-Id: I375415fec96baf44ecd4592033e8b44ed4616011 Signed-off-by: Scott Collyer <scollyer@google.com> Signed-off-by: Tim Wawrzynczak <twawrzynczak@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1776844 Tested-by: Scott Collyer <scollyer@chromium.org> Tested-by: Jongpil Jung <jongpil19.jung@samsung.corp-partner.google.com>
* pd: Prevent trasmitting messages if rx messages are pendingScott Collyer2019-10-171-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | This CL adds a check in pd_transmit to prevent sending tx messages if there are pending rx messages to be processed. This fixes an issue where a power role swap request is received, but before the accept reply can be sent a VDM discover identity message is sent which confuses the other side of the connection. BUG=b:140092163 BRANCH=None TEST=Tested with the AA-AM1N95W charge through hub. Verfied that this can be attached to Kohaku with external power already connected and successfully power role swap into source to charge the kohaku port. Tested 20-25 connections with no failures. Prior to this change the failure rate was 1 out of 3 attempts. Change-Id: Iebe53e0fc52bf817b709d58ef3e0ee7b226b0aa9 Signed-off-by: Scott Collyer <scollyer@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1799288 Reviewed-by: Jett Rink <jettrink@chromium.org> Tested-by: Tim Wawrzynczak <twawrzynczak@chromium.org> Tested-by: Scott Collyer <scollyer@chromium.org> Commit-Queue: Scott Collyer <scollyer@chromium.org>
* common: motion_sense: Refactor common code out of event processYuval Peress2019-10-161-50/+48
| | | | | | | | | | | | | Refactor motion_sense_process to include less repeated code. TEST=buildall and run on Kohaku BUG=None BRANCH=None Change-Id: I2e5af84f20cc7e50d3ddfb39d661238643aa99b3 Signed-off-by: Yuval Peress <peress@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1856828 Reviewed-by: Gwendal Grignou <gwendal@chromium.org>
* cleanup: Refactor #ifdefs toenable use of IS_ENABLEAyushee2019-10-161-38/+42
| | | | | | | | | | | | | | This change fixes #ifdef gaurds around CONFIG_USB_PD_TCPC_LOW_POWER and CONFIG_USB_PE_SM by replacing it with IS_ENABLED condition BUG=b:141971044 BRANCH=None TEST=make buildall -j Change-Id: I889752a8c4cdd8e22c97ede99643945fe2db868a Signed-off-by: Ayushee <ayushee.shah@intel.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1863823 Reviewed-by: Keith Short <keithshort@chromium.org>
* pd: Add PE FRS unit test for new stackDenis Brockus2019-10-162-2/+28
| | | | | | | | | | | BUG=none BRANCH=none TEST=make buildall -j Change-Id: I55453ddf1d1da0fdee902a33e14357716fb12c4a Signed-off-by: Denis Brockus <dbrockus@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1859826 Reviewed-by: Jett Rink <jettrink@chromium.org>
* pd: fix timer issue on pe_prs_snk_src_source_on_runDenis Brockus2019-10-161-9/+8
| | | | | | | | | | | | BUG=none BRANCH=none TEST=make buildall -j Change-Id: I12fbeb0a85d45bce8173c0c3831f663f5b618cc8 Signed-off-by: Denis Brockus <dbrockus@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1862621 Reviewed-by: Jett Rink <jettrink@chromium.org> Reviewed-by: Edward Hill <ecgh@chromium.org>
* usbc: make pe_init() staticEdward Hill2019-10-152-2/+2
| | | | | | | | | | | | | | pe_init() is called via pe_run(), so make it static. BRANCH=none BUG=none TEST=build Change-Id: I56928369e50a2022fc7e2aee2f68f09ebe7c06b6 Signed-off-by: Edward Hill <ecgh@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1850191 Reviewed-by: Denis Brockus <dbrockus@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org>
* usbc: rename exe_state to run_stateEdward Hill2019-10-157-10/+10
| | | | | | | | | | | | | | | | | Just a simple rename. run_state() seems more readable to me, and "run" is used in many of the related functions and comments. exe_state used to be called sm_run_state_machine before the great refactoring of CL:1733744. BRANCH=none BUG=none TEST=build Change-Id: I5fe9e5b98042d7a5b9b9e9bde48ebecbda420458 Signed-off-by: Edward Hill <ecgh@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1848970 Reviewed-by: Denis Brockus <dbrockus@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org>
* usbc: remove evt_timeout from struct type_cEdward Hill2019-10-155-58/+3
| | | | | | | | | | | | | | | | Simplify the pd_task loop timeout by making it a fixed 5 milliseconds. If there is nothing to do then it shouldn't take long to realize this. This allows removal of evt_timeout, tc_set_timeout, tc_get_timeout. BRANCH=none BUG=none TEST=usbc unit tests (make -j runhosttests) Change-Id: I067309b191e5118fbe9e89a92a650fa837fb75fa Signed-off-by: Edward Hill <ecgh@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1857216 Reviewed-by: Denis Brockus <dbrockus@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org>
* power_button_x86: Make sure PWRBTN_STATE_INIT_ON base 100 millisecondsben.chen2@quanta.corp-partner.google.com2019-10-151-23/+22
| | | | | | | | | | | | | | | | Fix sub function state_machine PWRBTN_STATE_INIT_ON case, should be first check charge_prevent_power_on until POWER Button Time out. BUG=b:141260790 BRANCH=Master TEST=check PB task timing with power on timing be sure the same time. Change-Id: I15a599773afe94e0730755dd60674cb4c4ea27d6 Signed-off-by: Ben Chen <ben.chen2@quanta.corp-partner.google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1847571 Reviewed-by: Jett Rink <jettrink@chromium.org> Reviewed-by: Tim Wawrzynczak <twawrzynczak@chromium.org> Reviewed-by: Paul Fagerburg <pfagerburg@chromium.org>
* usbc: use future time for disabling timerJett Rink2019-10-141-112/+93
| | | | | | | | | | | | | | | | If we use -1 instead of 0 for disabling timers, then we don't need to check for the 0 value when evaluating the timer. BRANCH=none BUG=none TEST=builds Change-Id: Ie1e68579728d23d645d1f17f31210fc275c38e36 Signed-off-by: Jett Rink <jettrink@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1837999 Tested-by: Denis Brockus <dbrockus@chromium.org> Reviewed-by: Edward Hill <ecgh@chromium.org> Reviewed-by: Denis Brockus <dbrockus@chromium.org>
* usbc: fix pe_src_discovery return issueJett Rink2019-10-141-3/+5
| | | | | | | | | | | | | | | | We were returning early within pe_src_discovery state and not giving other conditions a chance to evaluate and transition states. BRANCH=none BUG=none TEST=builds Change-Id: If438479b5a8bf2a703760f84a85c48bc7db72507 Signed-off-by: Jett Rink <jettrink@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1837998 Tested-by: Denis Brockus <dbrockus@chromium.org> Reviewed-by: Denis Brockus <dbrockus@chromium.org> Reviewed-by: Edward Hill <ecgh@chromium.org>
* usbc: go to hard reset after noResponseTimerJett Rink2019-10-141-3/+4
| | | | | | | | | | | | | | | | | We should transition to the hard reset state after the noResponseTimer expires without getting a single PD response from a port partner until we reach the hard reset count. BRANCH=none BUG=none TEST=builds Change-Id: Iaee53369dec863ed8220b9f4ffed5f252cf08c4d Signed-off-by: Jett Rink <jettrink@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1837997 Tested-by: Denis Brockus <dbrockus@chromium.org> Reviewed-by: Denis Brockus <dbrockus@chromium.org> Reviewed-by: Edward Hill <ecgh@chromium.org>
* usbc: check positive condition before errorJett Rink2019-10-111-8/+8
| | | | | | | | | | | | | | | | | | Since it is possible for the TCPC to give us both a TX complete and have the RX message waiting for us, it makes sense to check the TX complete success case first, and only transition to the error scenario if we get an unexpected RX and we haven't completed the TX BRANCH=none BUG=none TEST=build and passes all tests Change-Id: Ifc5bc52250d25963f2ce6e4ce78f73d9881385e4 Signed-off-by: Jett Rink <jettrink@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1837996 Tested-by: Denis Brockus <dbrockus@chromium.org> Reviewed-by: Denis Brockus <dbrockus@chromium.org> Reviewed-by: Edward Hill <ecgh@chromium.org>
* usbc: update CRCReceiveTimerJett Rink2019-10-101-15/+10
| | | | | | | | | | | | | | | | | 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: Add support for migration to positive match secret.Yicheng Li2019-10-101-4/+34
| | | | | | | | | | | | | | | | | | | | On receiving an template, if the template has format version 3 and has empty positive match salt, then generate positive match salt for this template so that it has positive match secret on the next match. BRANCH=nocturne BUG=chromium:927095 TEST=make -j buildall TEST=tested enrollment, matching, deletion, multifinger on DUT nocturne TEST=tested migration on DUT nocturne, specifically, enrolled template with old FPMCU firmware, then updated firmware, verified that templates are migrated and continue to work. Change-Id: If8020acfb60a03269af9ddb41023796920116fca Signed-off-by: Yicheng Li <yichengli@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1769395 Reviewed-by: Nicolas Norvez <norvez@chromium.org> Reviewed-by: Tom Hughes <tomhughes@chromium.org>
* fpsensor: Enable positive match secret and positive match salt on enrollment.Yicheng Li2019-10-093-16/+76
| | | | | | | | | | | | | | | | | | | | | | 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-092-6/+1
| | | | | | | | | | | | | | 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>
* fpsensor: Implement command to read positive_match_secret.Yicheng Li2019-10-094-7/+107
| | | | | | | | | | | | | | | | | | | | | 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>
* cleanup: move return to separate lineJett Rink2019-10-081-4/+7
| | | | | | | | | | | | | | The return type of state machine functions are void, so put the return statement on its own line. BRANCH=none BUG=none TEST=builds Change-Id: I30f3922228840dca7441a31f0ef0727a375b351e Signed-off-by: Jett Rink <jettrink@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1847774 Reviewed-by: Edward Hill <ecgh@chromium.org>
* cleanup: moving define closer to useJett Rink2019-10-081-4/+3
| | | | | | | | | | | BRANCH=none BUG=none TEST=builds Change-Id: Ifa60ca375fda22e6d5f79610f10ca1d5b4f2e894 Signed-off-by: Jett Rink <jettrink@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1845813 Reviewed-by: Edward Hill <ecgh@chromium.org>
* cleanup: use different condition for clarityJett Rink2019-10-081-1/+2
| | | | | | | | | | | | | | | No functionality is changing, just using a different set of equivalent condition to make code more readable. BRANCH=none BUG=none TEST=builds Change-Id: I6e77758514fe20e5ae8be29eb2fd1ba85414c9b6 Signed-off-by: Jett Rink <jettrink@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1845812 Reviewed-by: Edward Hill <ecgh@chromium.org>
* usbc: fix cc interpretation errorJett Rink2019-10-081-1/+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-081-0/+44
| | | | | | | | | | | | | | | | | 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-072-19/+194
| | | | | | | | | | | 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: cleanup ppcDenis Brockus2019-10-061-37/+147
| | | | | | | | | | | | | | 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>
* printf: Deprecate %lEvan Green2019-10-051-1/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* Remove uses of %lEvan Green2019-10-056-11/+10
| | | | | | | | | | | | | | | | | | | | | | | This change removes uses of %l from the EC side of the EC codebase. This is done because the semantics of %l within printf have changed, and there are concerns that new calls to printf will be cherry-picked into old firmware branches without the printf changes. So, in preparation for disallowing %l in master, remove occurrences of %l. This change was done by manually fixing up anything found under the EC directory with the following regex: %[0-9*.-]*l[^l] Remember that anything on the host machine is fine as-is, since the host printf never changed. BUG=chromium:984041 TEST=make -j buildall BRANCH=None Change-Id: I2a97433ddab5bfb8a6031ca4ff1d3905289444e2 Signed-off-by: Evan Green <evgreen@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1834603 Reviewed-by: Jack Rosenthal <jrosenth@chromium.org>
* include: De-longify CC_MASK() and CC_ALLEvan Green2019-10-051-1/+1
| | | | | | | | | | | | | | | 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-3/+3
| | | | | | | | | | | | | | | | | | | | | | | 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: Fix formatting errorsEvan Green2019-10-059-14/+16
| | | | | | | | | | | | | | | | | | | 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-11/+0
| | | | | | | | | | | | | | | | | | | | | 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-054-7/+27
| | | | | | | | | | | | | | | | | | | | | 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-054-9/+17
| | | | | | | | | | | | | | | | 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-053-4/+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-052-4/+16
| | | | | | | | | | | | | | | | | | | | | | | | 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-057-56/+86
| | | | | | | | | | | | | | | | | | | | | 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-0510-20/+47
| | | | | | | | | | | | | | | | | | | | | | 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>