summaryrefslogtreecommitdiff
path: root/common
Commit message (Collapse)AuthorAgeFilesLines
* usb_update: Add support for INJECT_ENTROPY commandNicolas Boichat2017-05-251-0/+24
| | | | | | | | | | | | | | | | | | | | | As part of the pairing process, AP needs to be able to inject some entropy into the base. Let's also define PAIR_CHALLENGE, which will be implemented in a later CL. BRANCH=none BUG=b:38487027 TEST=Flash hammer. On host, reboot hammer to RO: usb_updater2 -r; sleep 0.5; usb_updater2 -s usb_updater2 -e (adds entropy) EC console: check that rollbackinfo shows secret is updated Change-Id: I964bb578c6bfbb1ab5105a70b43682d51df4ed47 Reviewed-on: https://chromium-review.googlesource.com/513807 Commit-Ready: Nicolas Boichat <drinkcat@chromium.org> Tested-by: Nicolas Boichat <drinkcat@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org>
* Enable two-byte responses from host command handlers.Jeff Andersen2017-05-251-2/+2
| | | | | | | | | | | | | | | | | | | | Previously, result codes were being stored as `enum ec_status` values. The compiler was forcing this value to only be one byte large, since that's all that was necessary to represent all the values of that enum. This change fixes this bug by switching result code variable types from `enum ec_status` to `uint16_t`. BRANCH=none BUG=none TEST=make buildall -j Change-Id: Iacdca51dc6c1de677d2fbb59ad6dd2572d21ea7f Reviewed-on: https://chromium-review.googlesource.com/513609 Commit-Ready: Jeff Andersen <jeffandersen@google.com> Tested-by: Jeff Andersen <jeffandersen@google.com> Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
* rollback: Add option to store secret in rollback infoNicolas Boichat2017-05-253-32/+139
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | For pairing purpose, we want to store some secret random number in the base. The most convenient location for this is the rollback region. Since the rollback region can now be updated without incrementing rollback_min_version (when we add entropy to the secret), we need to add an increasing id to tell the code which rollback region is the latest. We also add console commands to manually add entropy. BRANCH=none BUG=b:38486828 TEST=Flash hammer (with or without CONFIG_ROLLBACK_ENTROPY_SIZE set) rollbackinfo => 1 version 0 block, 1 empty block, RW verifies correctly. rollbackupdate 0; rollbackinfo => No change rollbackupdate 1; reboot => RO refuses to jump to RW only when CONFIG_ROLLBACK_ENTROPY_SIZE is set: rollbackinfo => Secret is [00..00] on both blocks (so the data was copied correctly) rollbackupdate 2, 3, 4; rollbackinfo => Writes alternate between the 2 blocks. rollbackupdate 2 => Refuses to downgrade version TEST=From blank secret [00..00], 'rollbackaddent Hello' updates it to [ba..fa], which matches the output of: (dd if=/dev/zero bs=1 count=32; echo -n Hello) | sha256sum Change-Id: I79c3e790e56e21958cc1b4ba05bd4e5f359d3090 Reviewed-on: https://chromium-review.googlesource.com/511985 Commit-Ready: Nicolas Boichat <drinkcat@chromium.org> Tested-by: Nicolas Boichat <drinkcat@chromium.org> Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* power_button_x86: Initialize to on if button is pressedDaisuke Nojiri2017-05-231-0/+3
| | | | | | | | | | | | | | This change sets the initial power button state to init-on if the power button is pressed. BUG=b:37274183 BRANCH=none TEST=Enter recovery mode by power+recovery button press. Change-Id: I6ed849bc303e7cdbcb975ae2a6ff278093c86088 Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/486946 Reviewed-by: Duncan Laurie <dlaurie@google.com>
* rollback: Add CONFIG_ROLLBACK_UPDATE config optionNicolas Boichat2017-05-231-19/+21
| | | | | | | | | | | | | | | | Typically, we do not need RW section to be able to update rollback information (rollback block should be protected when RW is running), so we can save some flash space by undefining this option. BRANCH=none BUG=b:35586219 TEST=make newsizes saves ~420 bytes on hammer and staff. Change-Id: Ic457673e56ace083f2ebb1ca0f37f54bf125bfa4 Reviewed-on: https://chromium-review.googlesource.com/511983 Commit-Ready: Nicolas Boichat <drinkcat@chromium.org> Tested-by: Nicolas Boichat <drinkcat@chromium.org> Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* cr50: allow vendor command to turn update on even in prod imagesVadim Bendebury2017-05-231-1/+1
| | | | | | | | | | | | | | We want to always be able to update cr50 image to a newer version, even if the AP is not cooperating. BRANCH=cr50 BUG=b:35580805 TEST=verified that update of a prod image is possible Change-Id: I3bbe2c4aca8bf0c3129f4495db0e76405a2ed189 Signed-off-by: Vadim Bendebury <vbendeb@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/511285 Reviewed-by: Nick Sanders <nsanders@chromium.org>
* common: sensors: add extra sensor attributesNick Vaccaro2017-05-181-3/+16
| | | | | | | | | | | | | | | | | | | | | | Adds min_frequency and max_frequency to struct motion_sensor_t. New attributes min_frequency and max_frequency are now returned in ectool's MOTIONSENSE_CMD_INFO response. Incremented ectool's MOTIONSENSE_CMD_INFO version to version 3. Add constants for MIN_FREQUENCY and MAX_FREQUENCY to each sensor's header file. BRANCH=none BUG=chromium:615059 TEST=build/boot and verify MOTIONSENSE_CMD_INFO response on kevin, make buildall -j passes. Change-Id: I66db9715c122ef6bb4665ad5d086a9ecc9c7c93a Signed-off-by: Nick Vaccaro <nvaccaro@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/482703 Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
* power_button: Allow PB to be idle at power-onDaisuke Nojiri2017-05-181-1/+1
| | | | | | | | | | | | | | | | This change adds CONFIG_POWER_BUTTON_INIT_IDLE. When it's set, the system starts with the power button state idle. It means when the board boots from power-off, it stays at G3. BUG=b:37536389 BRANCH=none TEST=Power on Fizz. Verify it stays at G3. Verify it boots by pressing power button. Change-Id: I09a62a69d9f201b2dc261838cc9b4425fe3a8dc1 Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/486945 Reviewed-by: Duncan Laurie <dlaurie@google.com>
* keyboard_8042: Allow scancode sets to be mutableDuncan Laurie2017-05-181-1/+17
| | | | | | | | | | | | | | | | | | | Add an option to allow the scancode sets to be mutable. The only reason to use this is to allow a scancode to be changed at runtime, for instance to support different keyboards in one image. The side effect of this is the scancode sets are moved out of the shared RO section. BUG=b:36735408 BRANCH=none TEST=make -j buildall Change-Id: Iefb97691d1f295411d7b5db603d9214d41af49fd Signed-off-by: Duncan Laurie <dlaurie@google.com> Reviewed-on: https://chromium-review.googlesource.com/506717 Reviewed-by: Aseda Aboagye <aaboagye@chromium.org> Reviewed-by: Furquan Shaikh <furquan@chromium.org>
* host_command: Throttle printing of "+" for repeated commandsNicolas Boichat2017-05-181-1/+10
| | | | | | | | | | | | | | | | | | | | When AP boots and FW screen is shown (e.g. in developer mode), AP FW is querying MKBP status in a loop, leading to a lot of "+" being printed in the EC console. To avoid this issue, let's print "(++)" after a command is received 5 times in a row. BRANCH=none BUG=b:37925684 TEST=Set GBB flags to 0x4a38, reasonable number of "+" is printed on EC console on boot, which firmware screen is being shown. Change-Id: I8368c558b97e7a2513b979322bd4bba442626b27 Reviewed-on: https://chromium-review.googlesource.com/505948 Commit-Ready: Nicolas Boichat <drinkcat@chromium.org> Tested-by: Nicolas Boichat <drinkcat@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org>
* keyboard_8042: Add scancode entries for new matrixDuncan Laurie2017-05-171-4/+4
| | | | | | | | | | | | | | | | | | Add the new scan codes for the updated keyboard matrix: R0,C3 = Search (in addition to existing location at R1,C0) R0,C5 = New key using code 0[e0 58] and 1[e0 07] There are no changes to existing scan codes. BUG=b:36735408 BRANCH=none TEST=make -j buildall Change-Id: Ieba22eacd21a5c2dde3c7c43eb62b767fc0db42e Signed-off-by: Duncan Laurie <dlaurie@google.com> Reviewed-on: https://chromium-review.googlesource.com/506716 Reviewed-by: Furquan Shaikh <furquan@chromium.org>
* charge_state_v2: Remove assert for no AC and no batteryDuncan Laurie2017-05-171-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The assert in the charge state machine when there is no battery and no AC is causing a lot of headaches during development, and I don't believe it adds any value to panic the EC like this as it prevents the system from coming up and any debug from happening. This is especially bad with H1 locking out any useful debug by preventing flashing the EC. On Eve EVT we have some 'bad' batteries that are not correctly asserting presence pin, and when powering with adapter this this check happens before AC_PRESENT asserts because the USB PD negotiation is still happening so the EC gets stuck in a reboot loop. Similarly we had issues with the Krill board in the Whale BFT station that was triggering the same assert. In both cases there is an underlying hardware issue which is being investigated separately, but it is impossible to debug these systems because the EC will not come up. With this assert removed the EC and AP can boot and the LED blinks red to indicate there is battery a problem and the OS also reports a problem that the battery cannot be found, and we are able to do further debug without having to open the case. Additionally the error message is printed every ~second and it is very obvious from the EC console that there is a problem. Similar issues were reported at various points on Glados, Chell, Kevin, Elm, and Reef. BUG=b:35563537 BRANCH=none TEST=successfully boot and debug a failing Eve system Change-Id: I002b26d54428d29192a7097f1aae18f3223c5707 Signed-off-by: Duncan Laurie <dlaurie@google.com> Reviewed-on: https://chromium-review.googlesource.com/477733 Reviewed-by: Scott Collyer <scollyer@chromium.org>
* npcx: flash: Add write-protect support for internal flash of npcx7 ecstabilize-9554.BMulin Chao2017-05-121-0/+10
| | | | | | | | | | | | | | | | | | | | | | | | | In order to support write-protect mechanism for the internal flash of npcx7 ec, WP_IF, bit 5 of DEV_CTL4, is used to achieve this by controlling the WP_L pin of internal flash. During ec initialization or any utilities related to access status registers, we'll protect them if WP_L is active. Please notice the type of WP_IF is R/W1S. It means we only can unlock write protection of internal flash by rebooting ec. This CL also includes: 1. Add protect_range array of npcx7's internal flash (W25Q80) for write-protect mechanism. 2. Add bypass of bit 7 of DEVCNT. BRANCH=none BUG=none TEST=No build errors for all boards using npcx5 series. (Besides gru) Build poppy board and upload FW to platform. No issues found. Passed flash write-protect checking on npcx796f evb. Change-Id: I0e669ce8b6eaebd85e062c6751e1f3dd809e21e2 Signed-off-by: Mulin Chao <mlchao@nuvoton.com> Reviewed-on: https://chromium-review.googlesource.com/501727 Reviewed-by: Randall Spangler <rspangler@chromium.org>
* button: Recovery on power-on resetDaisuke Nojiri2017-05-121-4/+14
| | | | | | | | | | | | | | | | | | When cr50 detects recovery button (not keyboard) combo: recovery+power, volume-up+down+power, etc., it should (ideally) hard-reset the EC. This patch allows power-on reset in addition to reset-pin reset to enter recovery mode when recovery button combo is pressed. BUG=b:35585326 BRANCH=none TEST=make buildall. Tested on Poppy. Change-Id: I15aeef99d21ddc774441ead56fba56d459595cc9 Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/503573 Reviewed-by: Randall Spangler <rspangler@chromium.org>
* uart: fix compile warning when !defined CONFIG_CONSOLE_ENABLE_READ_V1Wei-Ning Huang2017-05-121-2/+2
| | | | | | | | | | | | | | | Fix compile warning when CONFIG_CONSOLE_ENABLE_READ_V1 is undefined. BRANCH=none BUG=b:37584134 TEST=with CONFIG_CONSOLE_ENABLE_READ_V1 undefined, `make BOARD=rose -j` Change-Id: I86f57e6fe92032ad688e861688f99b3f430404f4 Signed-off-by: Wei-Ning Huang <wnhuang@google.com> Reviewed-on: https://chromium-review.googlesource.com/504687 Commit-Ready: Wei-Ning Huang <wnhuang@chromium.org> Tested-by: Wei-Ning Huang <wnhuang@chromium.org> Reviewed-by: Rong Chang <rongchang@chromium.org>
* charger: Add dedicated (non-type-c) chargerDaisuke Nojiri2017-05-111-31/+50
| | | | | | | | | | | | | | | | This patch adds a dedicated charge port. The number of such ports is specified by CONFIG_DEDICATED_CHARGE_PORT_COUNT. It works as a sink only. The total number of charge ports is represented by CHARGE_PORT_COUNT. BUG=chromium:721383 BRANCH=none TEST=make buildall. Boot Fizz off of barrel jack. Change-Id: Ibbb11f3e1c66e35b5abe190e49161eeaa2009994 Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/501468 Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* rwsig: expose a new feature bit when RWSIG task is enabledWei-Ning Huang2017-05-111-0/+3
| | | | | | | | | | | | | | | | | | Expose EC_FEATURE_RWSIG if RWSIG task is enabled. This allows flashrom to run EC_CMD_RWSIG_ACTION and abort RWSIG jump, then perform regular firmware update flow. BRANCH=none BUG=b:37584134 TEST=on eve, `ectool --name=cros_tp inventory` should show 'RWSIG task'. Change-Id: Iea14f4f01fab201767dccd07d711ae9e1b638f6a Signed-off-by: Wei-Ning Huang <wnhuang@google.com> Reviewed-on: https://chromium-review.googlesource.com/497788 Commit-Ready: Wei-Ning Huang <wnhuang@chromium.org> Tested-by: Wei-Ning Huang <wnhuang@chromium.org> Reviewed-by: Nicolas Boichat <drinkcat@chromium.org> Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* rwsig: protect flash with EC_FLASH_PROTECT_ALL_NOW whenever possibleWei-Ning Huang2017-05-101-13/+20
| | | | | | | | | | | | | | | | | | | Use EC_FLASH_PROTECT_ALL_NOW to protect all flash before jump if posisble. If EC_FLASH_PROTECT_ALL_NOW does not work, try EC_FLASH_PROTECT_ALL_AT_BOOT next. BUG=b:37584134 TEST=on rose: 1) `flashwp enable` 2) `reboot` 3) `flashinfo` flags contains 'all_now' Change-Id: I2773410e97fae082fc6c20d47bdae3d991c57063 Reviewed-on: https://chromium-review.googlesource.com/497155 Commit-Ready: Wei-Ning Huang <wnhuang@chromium.org> Tested-by: Wei-Ning Huang <wnhuang@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org> Reviewed-by: Nicolas Boichat <drinkcat@chromium.org>
* button: Allow board to define recovery buttonsDaisuke Nojiri2017-05-091-4/+15
| | | | | | | | | | | | | | This patch declares recovery_buttons array, where each board lists recovery buttons. Pressing those while the board reboots makes the system enter recovery mode. BUG=none BRANCH=none TEST=buildall Change-Id: I1f204156efbd6d2a507d67ba90f75ce857b03559 Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/486944
* Allow lid-less configurationDaisuke Nojiri2017-05-092-0/+7
| | | | | | | | | | | | | | | | | | | power_button_x86.c and switch.c assume there is a lid switch. This patch separate them so that a board with power button but with no lid can be configured properly. This patch also moves backlight control to the board directory so that only the boards with a backlight turn it on/off when power state changes. BUG=none BRANCH=none TEST=boot fizz. make buildall. Change-Id: If4070cdc4b1221fae68b35ec3497335d81f192fd Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/489602 Reviewed-by: Aaron Durbin <adurbin@chromium.org>
* virtual_battery: prevent access out of bounds of memoryphilipchen2017-05-091-2/+11
| | | | | | | | | | | | | | | | | | | BUG=chromium:717737 BRANCH=none TEST=manually run 'power_supply_info' a few times and see consistent battery parameters TEST=access cached smart battery registers from the host command and see it returns 0 for out of bounds of memory Change-Id: I87cf2900ff93a952dc88cd9c3da82321533e4eb5 Reviewed-on: https://chromium-review.googlesource.com/495628 Reviewed-by: Douglas Anderson <dianders@chromium.org> Commit-Queue: Philip Chen <philipchen@chromium.org> Tested-by: Philip Chen <philipchen@chromium.org> (cherry picked from commit 96514bb2d21dbe8b4cc6177db9e916384649e28f) Reviewed-on: https://chromium-review.googlesource.com/499607 Commit-Ready: Philip Chen <philipchen@chromium.org> Reviewed-by: Philip Chen <philipchen@chromium.org>
* keyboard_scan: Add option to not handle boot key combinationsNicolas Boichat2017-05-081-0/+8
| | | | | | | | | | | | | | | | | | On some boards, the boot key combinations do not make a lot of sense, so we can just not process them and save a little bit of code space. BRANCH=none BUG=b:37422577 TEST=Flash hammer TEST=make newsizes shows we save 156 bytes in hammer RW. Change-Id: Ic96d7ed1dbee10f44f8b08568ab70b2f20961842 Reviewed-on: https://chromium-review.googlesource.com/495968 Commit-Ready: Nicolas Boichat <drinkcat@chromium.org> Tested-by: Nicolas Boichat <drinkcat@chromium.org> Reviewed-by: Furquan Shaikh <furquan@chromium.org> Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* keyboard_scan: Add option to not handle special key combinationsNicolas Boichat2017-05-081-0/+4
| | | | | | | | | | | | | | | | | On some boards, the special alt-volup-r/h combinations do not make a lot of sense, so we can just not process them and save a little bit of code space. BRANCH=none BUG=b:37422577 TEST=Flash hammer, alt-volup-r/h does not do anything special TEST=make newsizes shows we save 124 bytes in hammer RW. Change-Id: I92770fd6b8ff90780162a6b1de428a550bb44e9b Reviewed-on: https://chromium-review.googlesource.com/495967 Commit-Ready: Nicolas Boichat <drinkcat@chromium.org> Tested-by: Nicolas Boichat <drinkcat@chromium.org> Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* uart: add config to optionally enable EC_CMD_CONSOLE_READ v1Wei-Ning Huang2017-05-061-1/+7
| | | | | | | | | | | | | | | | | | | The cros_ec_debugfs creates the `console_log` debugfs entry if EC supports EC_CMD_CONSOLE_READ version 1. On device where i2c command latency is critical, periodic console_read is impacting the timing of commands. BRANCH=none BUG=b:37584134 TEST=on rose with CONFIG_CONSOLE_ENABLE_READ_V1 undefined, the kernel should not create cros_tp/console_log. Change-Id: I40d0b959ef36f2f410155fa30e01c8169032a3e9 Signed-off-by: Wei-Ning Huang <wnhuang@google.com> Reviewed-on: https://chromium-review.googlesource.com/494546 Commit-Ready: Wei-Ning Huang <wnhuang@chromium.org> Tested-by: Wei-Ning Huang <wnhuang@chromium.org> Reviewed-by: Gwendal Grignou <gwendal@chromium.org>
* rwsig: add host command for controlling rwsig taskWei-Ning Huang2017-05-061-0/+22
| | | | | | | | | | | | | | | | | | | Add new host command EC_CMD_RWSIG_ACTION for controlling rwsig task. This allow us to make firmware stay at RO without toggling reset pin. flashrom can use this host command and removed the need to use any out-of-band pin to toggle the reset pin (and make RWSIG stay in RO). BRANCH=none BUG=b:37584134 TEST=on eve, `ectool --name=cros_tp rwsigaction abort` should prevent EC from jumpping to RW after RWSIG check. Change-Id: Ia435e4e3ea8ed612a1250d3bf755ca50e5db9d37 Signed-off-by: Wei-Ning Huang <wnhuang@google.com> Reviewed-on: https://chromium-review.googlesource.com/497787 Commit-Ready: Wei-Ning Huang <wnhuang@chromium.org> Tested-by: Wei-Ning Huang <wnhuang@chromium.org> Reviewed-by: Nicolas Boichat <drinkcat@chromium.org>
* keyboard: Clear typematic when disabling keyboardDaisuke Nojiri2017-05-033-3/+8
| | | | | | | | | | | | | | | | This patch clears the typematic buffer when disabling keyboard scan. When the device goes to tablet mode with a key being pressed, this should prevent keyboard_protocol_task from sending scan codes to the host. BUG=b:35585725 BRANCH=none TEST=make buildall. Tested on Electro. Change-Id: I73e9d2948b472458814967307412aebeb410ff2e Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/425075 Reviewed-by: Aaron Durbin <adurbin@chromium.org>
* pd: Ignore Augmented PDOs when choosing PDO to request.Todd Broch2017-05-021-0/+4
| | | | | | | | | | | | | | | | | | | Augmented PDOs are part of the PD3.0 specification. As present USB PD sinks can't support these PDO types we need to ignore them. BRANCH=samus,glados,oak,gru,reef BUG=b:37476637 TEST=manual, On samus, plug-in blackcat (EVT) charger and see it ignore these Augmented PDOs when making its PDO request. Change-Id: I28a0377e1486368f25f37cad640af71244a4c30b Reviewed-on: https://chromium-review.googlesource.com/484687 Commit-Ready: Todd Broch <tbroch@chromium.org> Tested-by: Todd Broch <tbroch@chromium.org> Reviewed-by: Benson Leung <bleung@chromium.org> Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* common/button: Blink LED for 3 seconds when setting recovery HW_REINITstabilize-9517.BFurquan Shaikh2017-05-021-0/+29
| | | | | | | | | | | | | | | If user holds down volume up, volume down and power button for 30 seconds, set HW_REINIT event and blink LED for 3 seconds to indicate to user that the request was accepted. BUG=b:37682514 BRANCH=None TEST=make -j buildall Change-Id: I6b70d56f50d0a1cfae3fa7f337a34ac487943775 Signed-off-by: Furquan Shaikh <furquan@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/487281 Reviewed-by: Aaron Durbin <adurbin@chromium.org>
* common/led_common: Add API for controlling LED stateFurquan Shaikh2017-05-021-0/+9
| | | | | | | | | | | | | | | 1. Provide led_control API that can be used by different drivers to control the state of LED (0=off, 1=on, 2=reset) 2. Add a new LED ID for recovery HW_REINIT indication. BUG=b:37682514 BRANCH=None TEST=make -j buildall Change-Id: I27334bde2b879046746456a610208f3fc2dd68b4 Signed-off-by: Furquan Shaikh <furquan@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/487840 Reviewed-by: Aaron Durbin <adurbin@chromium.org>
* common/button: Add support for HW_REINIT button comboFurquan Shaikh2017-05-021-0/+37
| | | | | | | | | | | | | | | | | | | | | | | If volume up + volume down + power buttons are held down for 30 seconds, then indicate to AP that HW_REINIT is requested by the user. Since recovery mode is triggered by holding down the three buttons for 10 seconds, button_check_hw_reinit_required checks for 20 more seconds only. BUG=b:37682514 BRANCH=None TEST=Verified that: 1. If volume up, volume down and power are held for 30 seconds, AP sees the hw reinit request. 2. If either of the buttons is released before 30 seconds, AP does not see the hw reinit request. Change-Id: I3a53966dcdcb84d73f160578411b6c0f62225b95 Signed-off-by: Furquan Shaikh <furquan@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/487002 Reviewed-by: Aaron Durbin <adurbin@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org> Reviewed-by: Nicolas Boichat <drinkcat@chromium.org>
* common/usb_update: Add support for UPDATE_EXTRA_CMD_UNLOCK_ROLLBACKNicolas Boichat2017-05-021-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | AP will use that command to tell base EC that it believe the current FW is functionning correctly, and that the rollback region can be unlocked for an update on the next reboot. BRANCH=none BUG=b:35586219 BUG=b:35587171 TEST=- Flash hammer ToT image with rollback version 0 > flashwp true; reboot > flashinfo => all flash is protected - Update CONFIG_ROLLBACK_VERSION to 1 $ make BOARD=hammer -j - Flash new RW $ sudo extra/usb_updater/usb_updater2 -w $ sudo extra/usb_updater/usb_updater2 -r $ sleep 0.5 $ sudo extra/usb_updater/usb_updater2 -s $ sudo extra/usb_updater/usb_updater2 build/hammer/ec.bin > rollbackinfo rollback minimum version: 0 RW rollback version: 1 - Tell RW to unprotect rollback $ sudo extra/usb_updater/usb_updater2 -u $ sudo extra/usb_updater/usb_updater2 -r > rollbackinfo rollback minimum version: 1 RW rollback version: 1 Change-Id: Ib52253e9b8bba872688d6f601d9bfad8862be25f Reviewed-on: https://chromium-review.googlesource.com/489889 Commit-Ready: Nicolas Boichat <drinkcat@chromium.org> Tested-by: Nicolas Boichat <drinkcat@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org>
* common/usb_update: Support CMD_UNLOCK_RW even with CONFIG_RWSIG is unsetNicolas Boichat2017-05-021-1/+1
| | | | | | | | | | | | | | | | | | Starting with be294d4ef "hammer: Only define required options for RO and RW" we do not define CONFIG_RWSIG for the RW section. However, we want CMD_UNLOCK_RW to be usable when EC is in RW section, to unlock itself in prevision for an update on the next reboot. BRANCH=none BUG=b:35587171 TEST=Update hammer using usb_updater2 Change-Id: I7ae001363697bc3e17d4a59b21413d35101228cb Reviewed-on: https://chromium-review.googlesource.com/489888 Commit-Ready: Nicolas Boichat <drinkcat@chromium.org> Tested-by: Nicolas Boichat <drinkcat@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org>
* usb_update: 1-byte response to extra commandsNicolas Boichat2017-05-021-1/+1
| | | | | | | | | | | | | | | The existing commands do not really need longer response code. Future commands can always reply with more data as needed. BRANCH=none BUG=b:35587171 TEST=Update hammer using usb_updater2 Change-Id: I37cb8ac444d58216a7d98c9090043b06d95c74e1 Reviewed-on: https://chromium-review.googlesource.com/489887 Commit-Ready: Nicolas Boichat <drinkcat@chromium.org> Tested-by: Nicolas Boichat <drinkcat@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org>
* usb_port_power: Allow variable number of portsDaisuke Nojiri2017-05-012-59/+40
| | | | | | | | | | | | | | | | | Currently, usb_port_power_dumb allows fixed number of ports (2) and usb_port_power_smart allows less than 4 ports. This change removes the limitation and makes them accept variable number of ports. BUG=chromium:715178 BRANCH=none TEST=Verified usbchargemode returns consistent charge_mode across sysjumps on Electro. Change-Id: I7675c65ba03d3e6f7f53b2fe48cbe510231d945a Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/481077 Reviewed-by: Randall Spangler <rspangler@chromium.org>
* rollback: Print RW rollback version as wellNicolas Boichat2017-05-011-0/+4
| | | | | | | | | | | | | | | This is useful for debugging, to understand if the RW rollback version is ahead of current rollback version. BRANCH=none BUG=b:35586219 TEST=Flash hammer, rollbackinfo in EC console Change-Id: I2634199845f1b35447e0938a35b862f79cb24ffa Reviewed-on: https://chromium-review.googlesource.com/489886 Commit-Ready: Nicolas Boichat <drinkcat@chromium.org> Tested-by: Nicolas Boichat <drinkcat@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org>
* virtual_battery: Fix energy readingsDouglas Anderson2017-05-011-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The virtual battery "energy" readings were totally broken. Rather than reporting things in units of "10 mW" they were reporting things in units of "10 uW". That's because they were doing this math: result = mV * mA / 10 Said another way: result = (V / 1000) * (A / 1000) / 10 result = (V * A) / (100000) / 10 result = W / 1000000 / 10 result = uW / 10 Aside from the fact that clients were expecting things in "10 mW" instead of "10 uW", we got even more random results. That's because we return to the client in a 16-bit variable, so we were kinda randomly truncating things. Doh. BRANCH=ToT BUG=chromium:717304 TEST=power_supply_info Unfortunately when you try to report sane values for "10 uA" in a 16-bit result, it doesn't work too well ( Change-Id: I8075dffd7ab6b372be5b8fdf293acc96c5878036 Signed-off-by: Douglas Anderson <dianders@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/492546 Reviewed-by: Aseda Aboagye <aaboagye@chromium.org> (cherry picked from commit 01ceab68cd6b542f8c6355425e6ac6da698e0ebf) Reviewed-on: https://chromium-review.googlesource.com/492568 Commit-Ready: Aseda Aboagye <aaboagye@chromium.org> Tested-by: Aseda Aboagye <aaboagye@chromium.org>
* BD9995X: Enable/Disable charger depending on charging currentJames Chao2017-04-301-5/+0
| | | | | | | | | | | | | | | | | | | | | | If charging current is set to 0mA during charging, reference of charge current feedback amp (VREF_CHG) is set to 0V. Hence the DCDC stops switching (because of the EA offset). To eliminate this issue, disable/enable charger depending on the charging current is zero or non-zero respectively. BUG=b:37413065 BRANCH=reef TEST=test 'ectool chargecontrol normal/idle/discharge' are working Change-Id: Id31876afe365a476fb906e059ab519b7a0c9a7c6 Signed-off-by: james_chao <james_chao@asus.com> Signed-off-by: Vijay Hiremath <vijay.p.hiremath@intel.com> Reviewed-on: https://chromium-review.googlesource.com/486101 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org> (cherry picked from commit 6da9ed8786e90ee91b39934180fe84e01ac30260) Reviewed-on: https://chromium-review.googlesource.com/489812 Commit-Ready: Vijay P Hiremath <vijay.p.hiremath@intel.com> Tested-by: Vijay P Hiremath <vijay.p.hiremath@intel.com>
* common: add feature bit for touchpad supportWei-Ning Huang2017-04-271-0/+3
| | | | | | | | | | | | | | | | Add a new 'feature' bit to allow the host to auto-detect a TP MCU. Signed-off-by: Wei-Ning Huang <wnhuang@google.com> BRANCH=none BUG=b:37584134 TEST=on eve with TP connected, look at the feature bit. Change-Id: I81b30b96b31fc8dcb6769dd146fb33cdd487fddf Reviewed-on: https://chromium-review.googlesource.com/485422 Commit-Ready: Wei-Ning Huang <wnhuang@chromium.org> Tested-by: Wei-Ning Huang <wnhuang@chromium.org> Reviewed-by: Gwendal Grignou <gwendal@chromium.org>
* rwsig: do not jump if reset source is hard pin resetWei-Ning Huang2017-04-271-3/+15
| | | | | | | | | | | | | | | | | | | According to the new MCU secure update model, EC should wait for host if reset source is reset-pin. BRANCH=none BUG=b:37584134 TEST=on rose, toggle reset pin from host. EC should stay in RO, showing [0.426089 Hard pin-reset detected, disable RW jump] in console. Change-Id: Ie1908cb0744773e2e3ca8b3d8c627b8a9ef4567f Reviewed-on: https://chromium-review.googlesource.com/485199 Commit-Ready: Wei-Ning Huang <wnhuang@chromium.org> Tested-by: Wei-Ning Huang <wnhuang@chromium.org> Reviewed-by: Nicolas Boichat <drinkcat@chromium.org>
* rwsig: add host command for getting rwsig statusWei-Ning Huang2017-04-271-0/+15
| | | | | | | | | | | | | | | | | | | Add a new host command EC_CMD_RWSIG_CHECK_STATUS for getting rwsig status and rw firmware hash. This command is used to check the RW signature of newly updated RW image. A new subcommand is also added to ectool. BRANCH=none BUG=b:37584134 TEST=on rose board `ectool rwsigstatus` works Change-Id: I33d8709f5248d3a4b8bedb36ded84a93dc8c971f Signed-off-by: Wei-Ning Huang <wnhuang@google.com> Reviewed-on: https://chromium-review.googlesource.com/485079 Commit-Ready: Wei-Ning Huang <wnhuang@chromium.org> Tested-by: Wei-Ning Huang <wnhuang@chromium.org> Reviewed-by: Nicolas Boichat <drinkcat@chromium.org>
* i2c: separate slave and master codeWei-Ning Huang2017-04-263-21/+30
| | | | | | | | | | | | | | | | | | | | Split i2c.c code in two (i2c_slave.c and i2c_master.c). i2c_slave.c is used when EC has no i2c device connected (i2c master code not needed) but EC is connected to AP via i2c. BRANCH=none BUG=b:37584134 TEST=1. Compile rose board with CONFIG_I2C and CONFIG_CMD_HOSTCMD. Then make sure EC_CMD_GET_PROTOCOL_INFO works. 2. On Kevin and Elm, cherry-pick to firmware branch respectively, build and flash ec, i2c function works. Change-Id: I1f95ad277713c5e30913e0a010ca03dfd9ec248c Signed-off-by: Wei-Ning Huang <wnhuang@google.com> Reviewed-on: https://chromium-review.googlesource.com/484999 Commit-Ready: Wei-Ning Huang <wnhuang@chromium.org> Tested-by: Wei-Ning Huang <wnhuang@chromium.org> Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* rwsig/update_fw: Prevent race in rollback protectionNicolas Boichat2017-04-262-7/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | There is a window where the rollback information in RW could potentially be updated during RW signature verification. We make sure this cannot happen by: - Preventing update over USB while RWSIG is running - When system is locked, only update rollback information if RW region is locked: this guarantees that RW cannot be modified from boot until RW is validated, and then until rollback information is updated. Also, remove rollback_lock() in rwsig_check_signature: rwsig_jump_now() protects all flash, which also protects rollback. This reduces the number of required reboots on rollback update. BRANCH=none BUG=b:35586219 BUG=b:35587171 TEST=Add long delay in rwsig_check_signature, make sure EC cannot be updated while verification is in progress. Change-Id: I7a51fad8a64b7e258b3a7e15d75b3dab64ce1c94 Reviewed-on: https://chromium-review.googlesource.com/479176 Commit-Ready: Nicolas Boichat <drinkcat@chromium.org> Tested-by: Nicolas Boichat <drinkcat@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org>
* rwsig: protect all flash before jumping to RWNicolas Boichat2017-04-261-2/+21
| | | | | | | | | | | | | | | | | | | | | On "normal" EC, we do protect RW as part of software sync, which would call flash_command_protect (which indirectly calls flash_protect_at_boot). Here, we don't want to (and can't) rely on the host to tell us to protect the RW, so we need to protect it ourselves before jumping to RW. This does feel a little redundant with rollback_lock though, since ALL will protect both RW and ROLLBACK: a later CL will fix that up. BRANCH=none BUG=b:35587171 TEST=flashwp true; reboot; RO protects all flash before booting to RW Change-Id: I820cabb01d1ca4aa47b81fc013a1670134a6be09 Reviewed-on: https://chromium-review.googlesource.com/476453 Commit-Ready: Nicolas Boichat <drinkcat@chromium.org> Tested-by: Nicolas Boichat <drinkcat@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org>
* common/usb_update: add support for extra commandsNicolas Boichat2017-04-261-2/+95
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add support for 4 extra commands that are required to update hammer: - UPDATE_EXTRA_CMD_IMMEDIATE_RESET - UPDATE_EXTRA_CMD_JUMP_TO_RW: Tells the RWSIG task to jump to RW as soon as possible (assuming the image verifies) - UPDATE_EXTRA_CMD_STAY_IN_RO: Tells the RWSIG task to not jump to RW, and stay in RO, to leave enough time for AP to update RW. - UPDATE_EXTRA_CMD_UNLOCK_RW: Tells EC to unlock the RW section so that it can be updated (on next reboot). BRANCH=none BUG=b:35587171 TEST=Test RO+RW update cd extra/usb_updater; make # Jump to RW sudo ./usb_updater2 -j sleep 0.5 # Update RO, then reboot sudo ./usb_updater2 ../../build/hammer/ec.bin sleep 0.5 # Update RW (first tell RO to not jump to RW) sudo ./usb_updater2 -s sudo ./usb_updater2 ../../build/hammer/ec.bin TEST=Test RW update only, with RO protected On EC console: flashwp true; reboot cd extra/usb_updater; make # Tell RW to unprotect RW and jump back to RO sudo ./usb_updater2 -w sudo ./usb_updater2 -r sleep 0.5 # Update RW, then reboot sudo ./usb_updater2 -s sudo ./usb_updater2 ../../build/hammer/ec.bin Change-Id: I5e8df7bdb4f06f2ac7b47de53dcde69c5002f578 Reviewed-on: https://chromium-review.googlesource.com/458470 Commit-Ready: Nicolas Boichat <drinkcat@chromium.org> Tested-by: Nicolas Boichat <drinkcat@chromium.org> Reviewed-by: Nicolas Boichat <drinkcat@chromium.org>
* common/update_fw: Board/chip-specific first_response_pduNicolas Boichat2017-04-211-22/+35
| | | | | | | | | | | | | | | | | | | | | | | | | cr50 and hammer/common code are such different chips that reusing the same first_response_pdu does not make much sense. Instead, we can use 2 different headers, the updater knows which response to expect based on USB product ID. In the common code answer, we can reply with the EC version string, as well as rollback information and key version ID, which will be required for reliable updating. BRANCH=none BUG=b:35587171 BUG=b:36375666 TEST=usb_updater2 can update hammer, and read its version, rollback version and key version. Change-Id: I20b04070606767c71df3e6286d53e238e13375c0 Reviewed-on: https://chromium-review.googlesource.com/476452 Commit-Ready: Nicolas Boichat <drinkcat@chromium.org> Tested-by: Nicolas Boichat <drinkcat@chromium.org> Reviewed-by: Nick Sanders <nsanders@chromium.org> Reviewed-by: Nicolas Boichat <drinkcat@chromium.org>
* Revert "system: Shutdown AP before entering hibernate mode"Duncan Laurie2017-04-211-18/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This reverts commit 20c439be209a9cc0bb949ad21f289c453126395f. Reason for revert: This breaks hibernate on skylake boards and needs to be tested on more than just kevin before submitting. BUG=chromium:702451 BRANCH=none TEST=power down and successfully hibernate on Eve Original change's description: > system: Shutdown AP before entering hibernate mode > > BUG=chromium:702451 > BRANCH=none > TEST=manually test on gru: confirm > 'Alt+VolUp+h' puts gru in hibernate mode and > AC plug-in wakes it up. > > Change-Id: I3e1134b866dea5d3cc61f9b3dad31c3ff0bd9096 > Reviewed-on: https://chromium-review.googlesource.com/470787 > Commit-Ready: Philip Chen <philipchen@chromium.org> > Tested-by: Philip Chen <philipchen@chromium.org> > Reviewed-by: Aseda Aboagye <aaboagye@chromium.org> > TBR=rspangler@chromium.org,aaboagye@chromium.org,philipchen@chromium.org # Not skipping CQ checks because original CL landed > 1 day ago. BUG=chromium:702451 Change-Id: Ie847a5e3efb28256b00ddc6534d8ae6bbbba7121 Reviewed-on: https://chromium-review.googlesource.com/482989 Commit-Ready: Duncan Laurie <dlaurie@chromium.org> Tested-by: Duncan Laurie <dlaurie@chromium.org> Reviewed-by: Philip Chen <philipchen@chromium.org> Reviewed-by: Duncan Laurie <dlaurie@chromium.org>
* USB: Remove usb_charge_ports_enabledDaisuke Nojiri2017-04-201-19/+0
| | | | | | | | | | | | | usb_charge_ports_enabled is not used. BUG=none BRANCH=none TEST=make buildall Change-Id: I9465b65e9fab2603a4258adc4ae5f16d6bfc93c4 Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/481076 Reviewed-by: Randall Spangler <rspangler@chromium.org>
* common/usb_update: Statically allocate update bufferNicolas Boichat2017-04-171-25/+3
| | | | | | | | | | | | | | | | This makes error handling simpler, and also guarantees at compile time that EC will be able to allocate that much memory. BRANCH=none BUG=b:35587171 TEST=Update hammer using usb_updater2 Change-Id: Ifd4c5da80e98ee93b558679ab1cac8d5d89512e3 Reviewed-on: https://chromium-review.googlesource.com/479175 Commit-Ready: Nicolas Boichat <drinkcat@chromium.org> Tested-by: Nicolas Boichat <drinkcat@chromium.org> Reviewed-by: Nick Sanders <nsanders@chromium.org> Reviewed-by: Nicolas Boichat <drinkcat@chromium.org>
* power_button_x86: Reset power button setting on chipset transitionsFurquan Shaikh2017-04-171-0/+21
| | | | | | | | | | | | | | | | | Power button pulse is disabled by the host whenever it wants to treat the power button as an input and not trigger SMI. Clear this setting whenever there is a chipset state transition to default pulse enabled. BUG=b:37277943 BRANCH=None TEST=make -j buildall Change-Id: Id0cb3748bf7e25ad9111170116113151d9bed69e Signed-off-by: Furquan Shaikh <furquan@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/476090 Reviewed-by: Aaron Durbin <adurbin@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org>
* power_button_x86: Fix power button pulse enabling/disablingFurquan Shaikh2017-04-171-2/+2
| | | | | | | | | | | | | BUG=b:37277943 BRANCH=None TEST=Verified that wake from power button works in S3. Also, verified that menu selection works fine with this change. Change-Id: I8e644af3fb7fbc0147f1acb12b6df945815b5e73 Signed-off-by: Furquan Shaikh <furquan@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/475974 Reviewed-by: Aaron Durbin <adurbin@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org>