summaryrefslogtreecommitdiff
path: root/include/ec_commands.h
Commit message (Collapse)AuthorAgeFilesLines
* common: add API to expose detachable "base" stateDmitry Torokhov2018-08-221-1/+2
| | | | | | | | | | | | | | | | | | On some detachables, when base is attached, we know right away that the device should transition from tablet to clamshell mode. However on other detachables we need additional information (i.e. base position) before we decide whether to transition in/out of tablet mode. For such detachables let's allow them to signal a new "base attached" switch event, so that the rest of the stack is not confused. BUG=b:73133611 BRANCH=nocturne TEST=Build and boot Change-Id: I9be3450cba52bf9f0bad8333402f68b0c7903090 Signed-off-by: Dmitry Torokhov <dtor@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1176801 Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
* adc: Add ectool command for reading ADC channels.Aseda Aboagye2018-08-171-0/+14
| | | | | | | | | | | | | | BUG=b:76155036, b:112757066 BRANCH=None TEST=Flash nocturne; update ectool; verify that `ectool adcread <ch>` works as expected. Change-Id: I42545d25f005a7eb9e0af54c8b5cb72d5d844084 Signed-off-by: Aseda Aboagye <aaboagye@google.com> Reviewed-on: https://chromium-review.googlesource.com/1180095 Commit-Ready: Aseda Aboagye <aaboagye@chromium.org> Tested-by: Aseda Aboagye <aaboagye@chromium.org> Reviewed-by: Edward Hill <ecgh@chromium.org>
* fpsensor: Add timing statistics.Aseda Aboagye2018-08-101-0/+17
| | | | | | | | | | | | | | | | | | | | This commit adds some basic timing statistics around fingerprint capture, matching, and overall timing for returning a response for a fingerprint. A new host command is added, EC_CMD_FP_STATS, which returns these metrics. Additionally, ectool has been extended with the `fpstats` to command retrieve these metrics. BUG=b:111316382 BRANCH=None TEST=Flash nocturne_fp, perform capture and match, view results using ectool and verify that they are reasonable. Change-Id: Ib675116eebc8131d7b30e721d00eccfdb8905821 Signed-off-by: Aseda Aboagye <aaboagye@google.com> Reviewed-on: https://chromium-review.googlesource.com/1162961 Commit-Ready: Aseda Aboagye <aaboagye@chromium.org> Tested-by: Aseda Aboagye <aaboagye@chromium.org> Reviewed-by: Nicolas Norvez <norvez@chromium.org>
* Add DRAM part number support to CBIAaron Durbin2018-08-081-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Allow one to encode the DRAM part number in CBI. Both cbi-util and ectool are updated. $ cbi-util create --file ~/cbi_image --board_version 0 --oem_id 6 --sku_id 255 --dram_part_num "012345679abcdef" --size 256 CBI image is created successfully $ hexdump -C ~/cbi_image 00000000 43 42 49 47 00 00 23 00 00 01 00 01 01 06 02 01 |CBIG..#.........| 00000010 ff 03 10 30 31 32 33 34 35 36 37 39 61 62 63 64 |...012345679abcd| 00000020 65 66 00 ff ff ff ff ff ff ff ff ff ff ff ff ff |ef..............| 00000030 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |................| * 00000100 $ cbi-util show --file ~/cbi_image CBI image: /home/adurbin/cbi_image TOTAL_SIZE: 35 Data Field: name: value (hex, tag, size) BOARD_VERSION: 0 (0x0, 0, 1) OEM_ID: 6 (0x6, 1, 1) SKU_ID: 255 (0xff, 2, 1) DRAM_PART_NUM: 012345679abcdef (3, 16) Data validated successfully localhost /tmp # ./ectool cbi set 0 0 1 2 localhost /tmp # ./ectool cbi set 1 6 1 1 localhost /tmp # ./ectool cbi set 2 255 1 1 localhost /tmp # ./ectool cbi set 3 H9HCNNNBPUMLHR 0 0 localhost /tmp # ./ectool cbi get 0 As integer: 0 (0x0) As binary: 00 localhost /tmp # ./ectool cbi get 1 As integer: 6 (0x6) As binary: 06 localhost /tmp # ./ectool cbi get 2 As integer: 255 (0xff) As binary: ff localhost /tmp # ./ectool cbi get 3 H9HCNNNBPUMLHR BUG=b:112203105 BRANCH=None TEST=Commands executed above. Change-Id: I2d519ad16a158db4e624d3a03912434d0e8fdd73 Signed-off-by: Aaron Durbin <adurbin@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1165622 Reviewed-by: Furquan Shaikh <furquan@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org>
* rollback: Add host command to add entropyNicolas Boichat2018-07-311-0/+26
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | To generate a new secret, we add entropy (generated from local HW TRNG) to the existing secret (sha256(old secret || entropy)). This essentially re-keys the EC. On STM32H7, erasing rollback flash block can take up to 4 seconds, which exceeds the timeout of a normal host command. Therefore, ADD_ENTROPY command is asynchronous (adding the entropy itself is performed in a deferred hook), and its status must be checked repeatedly by the host. In some cases, it is critical that the old key is not left in the backup rollback block(s). For this purpose, we add a special action ADD_ENTROPY_RESET_ASYNC that adds entropy multiple times, until all the rollback blocks have been overwritten. BRANCH=none BUG=b:111190988 TEST=EC> rollbackinfo DUT> ./ectool --name=cros_fp reboot_ec RO && \ sleep 0.3 && ./ectool --name=cros_fp addentropy EC> rollbackinfo => See that that a single rollback block has been overridden TEST=Repeat with ./ectool --name=cros_fp addentropy reset => See that both rollback blocks have been overridden Change-Id: I3058b0a91591fab543ba6890f7356e671016edfa Signed-off-by: Nicolas Boichat <drinkcat@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1132826 Reviewed-by: Nicolas Norvez <norvez@chromium.org>
* reset: Log the reason for AP resets.Jonathan Brandmeyer2018-07-261-0/+49
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Provides a new EC host command 'uptime info' which gathers up some information which may be useful for debugging spurious resets on the AP (was the EC reset recently? Why was the EC reset? If the EC reset the AP, why did it do so?, etc.). Provide ectool support for the same. Example results of `ectool uptimeinfo`: ``` localhost ~ # ectool uptimeinfo EC uptime: 475.368 seconds AP resets since EC boot: 2 Most recent AP reset causes: 315.903: reset: console command 363.507: reset: keyboard warm reboot EC reset flags at last EC boot: reset-pin | sysjump ``` BRANCH=none TEST=Perform some `apreset` commands from the EC console and observe their side-effects via the `ectool uptimeinfo` command on the AP side. Test sequences include no-resets through 5 resets, observing that the ring buffer handling was correct. BUG=b:110788201, b:79529789 Signed-off-by: Jonathan Brandmeyer <jbrandmeyer@chromium.org> Change-Id: I0bf29d69de471c64f905ee8aa070b15b4f34f2ba Reviewed-on: https://chromium-review.googlesource.com/1139028 Commit-Ready: Jonathan Brandmeyer <jbrandmeyer@chromium.org> Tested-by: Jonathan Brandmeyer <jbrandmeyer@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org>
* ectool: Handle "Dead pixels: UNKNOWN" in "fpinfo"Nicolas Norvez2018-07-231-0/+2
| | | | | | | | | | | | | | | | | | | | | The "Dead pixels" entry printed out after the "fpinfo" command is always returning 0 because b/76037094 hasn't been implemented yet. This is misleading since people assume that the feature has been implemented. Use the special value 0x3FF to report "UNKNOWN" rather than 0 dead pixels in that case. Signed-off-by: Nicolas Norvez <norvez@chromium.org> BRANCH=None BUG=b:111695472 TEST=check output of "ectool --name=cros_fp fpinfo", both before and after updating the firmware Change-Id: I12b12123dbe95aa9b629a7c2747533571f0f99f0 Reviewed-on: https://chromium-review.googlesource.com/1145738 Commit-Ready: Nicolas Norvez <norvez@chromium.org> Tested-by: Nicolas Norvez <norvez@chromium.org> Reviewed-by: Nicolas Boichat <drinkcat@chromium.org>
* sensor: Add flag for tight timestampingGwendal Grignou2018-07-031-0/+2
| | | | | | | | | | | | | | | | | | | Kernel needs to be aware of the the new timestamp code to apply proper filtering/spreading. This flag set means that timestamps are always after every sensor sample, and both timestamps (sensor sample and fifo info) are recorded with minimal latency and jitter. TEST=Add 'dev_err(dev, "feature 36 = %d\n", cros_ec_check_features(ec, 36));' in kernel/drivers/platform/chrome/cros_ec_dev.c See the bit set (16, not 0) in dmesg. BUG=b/111079027, b/109786990 Change-Id: Ia71703e035d7a6eac1e0a483caa62b7c75e5cb2a Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Signed-off-by: Alexandru M Stan <amstan@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1123218
* cleanup: remove incorrect commentJett Rink2018-07-031-1/+1
| | | | | | | | | | | | | The chip field maps to the PD port id and should not always be 0. BRANCH=none BUG=none TEST=none Change-Id: I271ca8ed22b8f1c640a2aa97d41547ac07162fe9 Signed-off-by: Jett Rink <jettrink@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1123313 Reviewed-by: Raul E Rangel <rrangel@chromium.org>
* phaser: add new lis2de chip typePaul Ma2018-06-301-0/+1
| | | | | | | | | | | | | | | Add new motion sense chip type MOTIONSENSE_CHIP_LIS2DE and make ectool support it. also use +/- 2g range for lis2de to get one extra bit of precision. BRANCH=none BUG=b:110604678 TEST=boot phaser360 board, run 'ectool motionsense info 0' Change-Id: Idd8a797e5a8b38efcd0a4ac47eb584534106fb86 Signed-off-by: Paul Ma <magf@bitland.corp-partner.google.com> Reviewed-on: https://chromium-review.googlesource.com/1118094 Reviewed-by: Jett Rink <jettrink@chromium.org>
* ec/google: Add command to fetch keyboard ID from ECparis_yeh2018-06-201-0/+11
| | | | | | | | | | | | | | | | | Sort k-prefix host commands and descriptions in alphabetical order BRANCH=master BUG=b:80168723 TEST=Check 'ectool kbid' on a reworked DUT using keyboard samples Change-Id: If2ad654e5ef269d03365db7c3286c2281aa9d9ef Signed-off-by: paris_yeh <pyeh@google.com> Reviewed-on: https://chromium-review.googlesource.com/1097997 Commit-Ready: Paris Yeh <pyeh@chromium.org> Tested-by: Paris Yeh <pyeh@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org> Reviewed-by: Paris Yeh <pyeh@chromium.org> Reviewed-by: Nicolas Boichat <drinkcat@chromium.org>
* acpi: Add map for controlling USB port powerEmil Lundmark2018-05-291-0/+9
| | | | | | | | | | | | | | | | | | | Some devices have GPIO pins that control USB port power connected to the EC, so they cannot be toggled by ACPI. This patch adds a memory map between the EC and ACPI that can be used on such devices. It can hold the power state of up to 8 USB ports. Currently, only dumb power ports are supported. BUG=chromium:833436 BRANCH=fizz TEST=On a fizz that runs BIOS with EC_ACPI_MEM_USB_PORT_POWER mapped, check that both reads and writes are propagated. Change-Id: I413defcb9e4d234fea7f54d46b6b8a1a10efa31e Signed-off-by: Emil Lundmark <lndmrk@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1069273 Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com> Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* charger: Modify manual mode to save desired current/voltageScott Collyer2018-05-211-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Previously manual_mode used the current values of voltage/current to set the desired values for each charge_request() call. Since manual mode is entered/exited in the host command task, this can easily lead to a race condition where the charger gets disabled in the host command task, the reenabled by the charger task. This in turn makes the ectool chargecontrol idle command unreliable. This CL replaces manual mode with two variables, manual_voltage and manual_current. The default values are -1 which means that they are inactive. When the ectool command 'chargecontrol idle' is executed, it sets both variables to 0. This then removes the race condition possibility as each iteration of the charger loop will use manual_voltage and/or manual_current if not -1. BRANCH=coral BUG=b:68364154 TEST=Manual Executed 'ectool chargecontrol idle' and 'ectool chargecontrol normal' numerous times and verified that the charging was disabled/resumed each time as expected. Without this fix the problem could be reproduced always in less than 10 attempts, typcially less than 5. With this CL charging is disabled reliably each time and I'm not able to reproduce the problem. Change-Id: I1ed9cdb42249cdf72ab34dd95b8f42c09d9a490c Signed-off-by: Scott Collyer <scollyer@google.com> Reviewed-on: https://chromium-review.googlesource.com/851419 Tested-by: Scott Collyer <scollyer@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org> Reviewed-by: Shawn N <shawnn@chromium.org> Commit-Queue: Scott Collyer <scollyer@chromium.org> (cherry picked from commit b7254f38979f274acc66330905399ff5ddf4129b) Reviewed-on: https://chromium-review.googlesource.com/922069 Commit-Ready: Daisuke Nojiri <dnojiri@chromium.org> Tested-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
* Reland "npcx: CEC: Send CEC message in mkbp event"Stefan Adolfsson2018-05-161-11/+42
| | | | | | | | | | | | | | | | | | | | | | | | | | | | This reverts commit f139d3a0ca9215b5b5bb2abc1f120ff6171036c9. Reason for revert: Verified that the problem is in the kernel, not EC. Original change's description: > Revert "npcx: CEC: Send CEC message in mkbp event" > > This reverts commit 74b5a2ccb58739d4e21fdeb36e40fe01c0ca7ede. > > Suspected to have broken perf tests by keeping a CPU busy on kevin/bob. > > BUG=chromium:842873, b:76467407 > > Change-Id: Iebbbb4623116840b851656e3ec28e75dc99cff79 > Reviewed-on: https://chromium-review.googlesource.com/1060073 > Reviewed-by: Ilja H. Friedel <ihf@chromium.org> > Tested-by: Ilja H. Friedel <ihf@chromium.org> Bug: chromium:842873, b:76467407 Change-Id: I7d8990b2b8901b7de08f190a993bec645bbdacd2 Reviewed-on: https://chromium-review.googlesource.com/1061854 Commit-Ready: Stefan Adolfsson <sadolfsson@chromium.org> Tested-by: Stefan Adolfsson <sadolfsson@chromium.org> Reviewed-by: Stefan Adolfsson <sadolfsson@chromium.org> Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* fpsensor: add capture type for reset pixel testVincent Palatin2018-05-161-0/+2
| | | | | | | | | | | | | | | | | | | | | Add the FP_CAPTURE_RESET_TEST capture mode to be able to perform the reset pixel values test. Update ectool accordingly and also remove the deprecated 'fpcheckpixels' command. Signed-off-by: Vincent Palatin <vpalatin@chromium.org> BRANCH=poppy BUG=b:78597564 TEST=run 'ectool --name=cros_fp fpmode capture test_reset', then 'ectool --name=cros_fp fpframe > test.pnm' CQ-DEPEND=CL:*626747 Change-Id: I183f33b1cb9ba4db67219b8f7740d29dc0551f2d Reviewed-on: https://chromium-review.googlesource.com/1061074 Commit-Ready: Vincent Palatin <vpalatin@chromium.org> Tested-by: Vincent Palatin <vpalatin@chromium.org> Reviewed-by: Nicolas Boichat <drinkcat@chromium.org>
* Revert "npcx: CEC: Send CEC message in mkbp event"stabilize-10682.BIlja H. Friedel2018-05-151-42/+11
| | | | | | | | | | | | | This reverts commit 74b5a2ccb58739d4e21fdeb36e40fe01c0ca7ede. Suspected to have broken perf tests by keeping a CPU busy on kevin/bob. BUG=chromium:842873, b:76467407 Change-Id: Iebbbb4623116840b851656e3ec28e75dc99cff79 Reviewed-on: https://chromium-review.googlesource.com/1060073 Reviewed-by: Ilja H. Friedel <ihf@chromium.org> Tested-by: Ilja H. Friedel <ihf@chromium.org>
* motion_sense: Lower jitter of EC->AP timestampAlexandru M Stan2018-05-141-1/+3
| | | | | | | | | | | | | | | | | | | | | When the EC sends an interrupt to the AP notifying it of new accelerometer data we need to make sure the spot we record the timestamp of the event is virtually identical to the spot the AP records the same point in time. Therefore a better spot for that is right next to the gpio toggling of the interrupt line. BUG=b:67743747 TEST=In the kernel, fifo_info->info.timestamp still has sane values. TEST=CTS should still pass BRANCH=master Change-Id: Ic77101a045123e779f576c46b401c765304976fd Signed-off-by: Alexandru M Stan <amstan@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/802976 Reviewed-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org>
* npcx: CEC: Send CEC message in mkbp eventStefan Adolfsson2018-05-121-11/+42
| | | | | | | | | | | | | | | | | | | | Instead of fetching incoming CEC messages using a specific read command, extend the standard mkbp event so the CEC message can be delivered directly inside the event. Signed-off-by: Stefan Adolfsson <sadolfsson@chromium.org> BUG=b:76467407 BRANCH=none TEST="ectool cec read" still working with a kernel that has support for the increased mkbp size. CQ-DEPEND=CL:1046186,CL:1051085 Change-Id: Id9d944be86ba85084b979d1df9057f7f3e7a1fd0 Reviewed-on: https://chromium-review.googlesource.com/1051105 Commit-Ready: Stefan Adolfsson <sadolfsson@chromium.org> Tested-by: Stefan Adolfsson <sadolfsson@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org>
* charge_manager: add host cmd to get port countFabien Parent2018-05-111-0/+11
| | | | | | | | | | | | | | | | | The kernel is only able to know the number of USB PD port through EC_CMD_USB_PD_PORTS, but the kernel needs also to be able to know that there is a dedicated port. Add a host command that will return the total number of charge port (USB PD + BJ). BRANCH=None BUG=chromium:841944 TEST=Called command from kernel driver and checked that the port count was the expected value. Change-Id: I6ccd8a2dee35bbe8bb66dfbe09d1cc09c54b73a0 Signed-off-by: Fabien Parent <fparent@baylibre.com> Reviewed-on: https://chromium-review.googlesource.com/1046593 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
* CEC: Add CEC APIStefan Adolfsson2018-05-091-0/+70
| | | | | | | | | | | | | | | | | Add HDMI CEC commands and events. Will be used by npcx CEC implementation. Signed-off-by: Stefan Adolfsson <sadolfsson@chromium.org> BUG=b:76467407 BRANCH=none TEST=Build ec-utils and chromeos-ec Change-Id: I9008eb77179c296d6d07d321f48ba24585323607 Reviewed-on: https://chromium-review.googlesource.com/995440 Commit-Ready: Stefan Adolfsson <sadolfsson@chromium.org> Tested-by: Stefan Adolfsson <sadolfsson@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org>
* fpsensor: export matched finger indexVincent Palatin2018-05-091-0/+4
| | | | | | | | | | | | | | | | | | | | | Update the fingerprint match event to include the index of the template which matched. Signed-off-by: Vincent Palatin <vpalatin@chromium.org> BRANCH=poppy BUG=b:77516790 TEST=on ZerbleBarn, enroll 5 fingers and do matching from the console, see the proper finger index in the trace. TEST=on Meowth, check unmodified biod still works for match with the updated MCU firmware. CQ-DEPEND=CL:*621808 Change-Id: I5be77ba65ce232989606274aba9a6c20841d533c Reviewed-on: https://chromium-review.googlesource.com/1047267 Commit-Ready: Vincent Palatin <vpalatin@chromium.org> Tested-by: Vincent Palatin <vpalatin@chromium.org> Reviewed-by: Nicolas Norvez <norvez@chromium.org>
* Features: Add EXEC_IN_RAMDaisuke Nojiri2018-04-041-0/+2
| | | | | | | | | | | | | | | This patch adds execution-in-ram, opposite of XIP: execution-in-place (a.k.a. XIP) to the EC features. It can be currently implied by CONFIG_EXTERNAL_STORAGE. BUG=b:77306460 BRANCH=none TEST=Verify ectool prints EXEC_IN_RAM on Fizz. Change-Id: I4a7fb3b267864debe59fd211956371eceac57613 Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/995968 Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* yorp: Enable lid, base accel and gyro sensorDivya Sasidharan2018-03-221-0/+1
| | | | | | | | | | | | | | | | This is initial configuration changes and enable motion sensor task. BUG=b:74129963,b:74132236 BRANCH=none TEST=Verified "make buildall -j and make BOARD=yorp" Change-Id: Ia45d6434a2c034c0ec650d7b46d6f664848f9153 Signed-off-by: Divya Sasidharan <divya.s.sasidharan@intel.com> Reviewed-on: https://chromium-review.googlesource.com/961459 Commit-Ready: Divya S Sasidharan <divya.s.sasidharan@intel.com> Tested-by: Divya S Sasidharan <divya.s.sasidharan@intel.com> Reviewed-by: Jett Rink <jettrink@chromium.org>
* fpsensor: add enrollment and matching interfaceVincent Palatin2018-03-201-3/+91
| | | | | | | | | | | | | | | | | | | | | | | | | | Add the state machine and the interfacing to the enrollment and matching algorithm providing by the private driver part. Implement the host commands interface for it (based on MKBP event) along with the console debug commands to exercise it. Signed-off-by: Vincent Palatin <vpalatin@chromium.org> BRANCH=none BUG=b:72360575 TEST=On ZerbleBarn console, use 'fpenroll' then 'fpmatch' for several fingers. TEST=With ZerbleBarn and a servo-v2, retrieve and upload templates with 'ectool_servo fptemplate'. TEST=On Meowth, exercise with the prototype of biod CrosFpBiometricsManager. CQ-DEPEND=CL:*555078 Change-Id: I10b0d76d3faa898a682cf9a2eb7fc7e212b0c20c Reviewed-on: https://chromium-review.googlesource.com/886401 Commit-Ready: Vincent Palatin <vpalatin@chromium.org> Tested-by: Vincent Palatin <vpalatin@chromium.org> Reviewed-by: Nicolas Boichat <drinkcat@chromium.org>
* driver: lsm6dsm: Add ectool support.Gwendal Grignou2018-03-191-0/+1
| | | | | | | | | | | BUG=b:73546254 BRANCH=master TEST=compile Change-Id: If914dfbf7bb30e934b711d8f89c46af2787f917c Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/924406 Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
* driver: accel_lis2dh: Fix interfaceGwendal Grignou2018-03-191-0/+1
| | | | | | | | | | | | | Add support in ectool, expose min/max ODR. BUG=b:73546254 BRANCH=master TEST=compile Change-Id: Ib09c06e17d7d73aaab91680672de4d5267299c7f Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/924405 Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
* CBI: Make data offset and size variableDaisuke Nojiri2018-02-161-12/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Currently CBI data offset and size are fixed. This patch makes them variable. Each data item consists of <tag><size><value> where <tag> is a numeric value assigned to each data item, <size> is the number of bytes used for <value>. BUG=b:70294260 BRANCH=none TEST=Use 'ectool cbi set' to set board version, oem, sku. Verify the contents by cbi console command and ectool cbi get. 1. ectool cbi set 0 0x202 2 2 (Init CBI and write board ver. of size 2) 2. ectool cbi set 1 1 1 (write oem id of size 1) 3. ectool cbi set 2 2 1 (write sku id of size 1) 4. ectool cbi get 0 514 (0x202) 5. ectool cbi get 1 1 (0x1) 6. ectool cbi get 2 2 (0x2) 7. Run cbi console command: CBI_VERSION: 0x0000 TOTAL_SIZE: 18 BOARD_VERSION: 514 (0x202) OEM_ID: 1 (0x1) SKU_ID: 2 (0x2) 43 42 49 8c 00 00 12 00 00 02 02 02 01 01 01 02 01 02 Change-Id: I5a30a4076e3eb448f4808d2af8ec4ef4c016ae5e Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/920905 Reviewed-by: Aaron Durbin <adurbin@chromium.org>
* fpsensor: add quality test capture typeVincent Palatin2018-02-161-0/+2
| | | | | | | | | | | | | | | | | | | Add support for an additional finger image capture type used for quality testing. Signed-off-by: Vincent Palatin <vpalatin@chromium.org> BRANCH=none BUG=b:72360575, b:71770455 TEST=On Meowth, run 'ectool --name=cros_fp fpmode capture qual' then 'ectool --name=cros_fp fpframe raw > finger_mq.bin' Change-Id: I1b9525dc2adf0b91aef2f7124803c90d6a3bb0ca Reviewed-on: https://chromium-review.googlesource.com/924124 Commit-Ready: Vincent Palatin <vpalatin@chromium.org> Tested-by: Vincent Palatin <vpalatin@chromium.org> Reviewed-by: Aseda Aboagye <aaboagye@chromium.org> Reviewed-by: Nicolas Norvez <norvez@chromium.org>
* battery: Allow 2 batteries to be fetched via ACPINicolas Boichat2018-02-091-2/+7
| | | | | | | | | | | | | | | | | | | | | We share the same shared memory fields for both batteries. When the host wants to switch battery to read out: - The host sets EC_ACPI_MEM_BATTERY_INDEX to the required index - EC then swaps the data is the shared memory fields, then update EC_MEMMAP_BATT_INDEX - Host waits for EC_MEMMAP_BATT_INDEX to have the required value, then fetches the data BRANCH=none BUG=b:65697620 TEST=Boot lux, both /sys/class/power_supply/BAT0 and BAT1 are present, data is valid. TEST=Unplug base, BAT1 goes away, replug, BAT1 comes back. Change-Id: Icce12f9eef2f6f8cde9bae0a968a65e1703d0369 Signed-off-by: Nicolas Boichat <drinkcat@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/888382 Reviewed-by: Gwendal Grignou <gwendal@google.com>
* charge_state_v2: Basic dual-battery charging algorithmNicolas Boichat2018-01-261-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | First version of the algorithm, some TODOs are left in the code but this, generally, works reasonably well. When charging, we allocate input current in this general order: - Base system (fixed, low, number) - Lid system (based on PSYS) - Lid battery (estimating how much current the battery actually requires) - Base battery (similar estimation) - Provide everything else to lid When discharging, we generally: - First discharge the base battery - Then discharge the lid battery BRANCH=none BUG=b:71881017 TEST=Flash lux and wand, EC-EC communication works, adapter power is split in a sensible way, and discharging works fine. Change-Id: I8a4f87963962fc5466b2fedf1347eb4dadd35740 Signed-off-by: Nicolas Boichat <drinkcat@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/659460 Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com> Reviewed-by: Randall Spangler <rspangler@chromium.org>
* fpsensor: update interfaceVincent Palatin2018-01-231-3/+27
| | | | | | | | | | | | | | | | | | | | | Update the FP MCU interface to include a few convenient diagnostics functions for factory testing. It's mostly backward compatible, but overall this interface never shipped in anything, so not a big deal regardless. Signed-off-by: Vincent Palatin <vpalatin@chromium.org> BRANCH=none BUG=b:71986991 TEST=ectool --name=cros_fp fpinfo && ectool --name=cros_fp fpcheckpixels CQ-DEPEND=CL:*546799 Change-Id: Ic641f891ace02d79af9339cf6cb59a2960e506a7 Reviewed-on: https://chromium-review.googlesource.com/873924 Commit-Ready: Vincent Palatin <vpalatin@chromium.org> Tested-by: Vincent Palatin <vpalatin@chromium.org> Reviewed-by: Shawn N <shawnn@chromium.org>
* CBI: Allow get command to reload data from EEPROMDaisuke Nojiri2018-01-181-1/+10
| | | | | | | | | | | | | | | | | | This patch adds CBI_GET_RELOAD flag to EC_CMD_GET_CROS_BOARD_INFO command. When the flag is set, the command will be forced to read data from EEPROM even, ignoring the data cached by the previous read. This allows ectool to verify a write was successful without reboot. BUG=b:70294260 BRANCH=none TEST=ectool cbi set 0 0x1234 && ectool cbi get 0 1 Change-Id: I3e7ced5be56a74c605870a4c0622c0a2f47963bb Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/874155 Reviewed-by: Randall Spangler <rspangler@chromium.org>
* CBI: Add host command to set board infoDaisuke Nojiri2018-01-181-0/+23
| | | | | | | | | | | | | This patch adds host command to write board information in EERPOM. BUG=b:70294260 BRANCH=none TEST=Run ectool cbi set <type> <value> to write BOARD_VERSION, OEM_ID, and SKU_ID. Enable WP and verify cbi set command fails. Change-Id: I39536d146313408ace666f350a107d89b331bf7a Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/865570
* CBI: Add host command to get board infoDaisuke Nojiri2018-01-181-0/+21
| | | | | | | | | | | | | This patch adds host command to get board info from EEPROM. BUG=b:70294260 BRANCH=none TEST=Run ectool cbi get <type> to get board version, OEM, SKU Change-Id: I41a84d3eea6da9d88fa8122db36dcd1df515842d Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/865161 Reviewed-by: Randall Spangler <rspangler@chromium.org>
* ec_commands: EC_CMD_BATTERY_GET_DYNAMIC: Clarify the meaning of flagsNicolas Boichat2018-01-101-1/+3
| | | | | | | | | | | | | | | | | | flags are actually _not_ BATT_FLAG_*, but EC_BATT_FLAG_*. Clarify that in the comment, and add a new EC_BATT_FLAG_INVALID flag to indicate that some of the data may be invalid (dual-battery master needs to know that to make appropriate charging/discharging decision). BRANCH=none BUG=b:65697962 BUG=b:65697620 TEST=Flash hammer and wand, flags make sense. Change-Id: I3c428c850020a29b3f452504b60b52946a04c503 Signed-off-by: Nicolas Boichat <drinkcat@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/859400 Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* EFS: Add EFS_VERIFY host commandDaisuke Nojiri2018-01-091-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | | If a bios carries an EC image signed by a wrong key, EFS EC falls back to the previous slot upon reboot. Vboot currently does not handle this case and tries to update the EC with an incompatible image again. When this happens, a user sees 'applying critical update' screen repeatedly. This patch adds EFS_VERIFYV host command. Vboot on AP calls it to check whether the EC likes a newly updated image or not. If the verification fails, it's considered as update failure and vboot displays 'broken' screen. BUG=b:71719323 BRANCH=none TEST=Flash EC SPI with an image which has a different RO key. Boot DUT and let it run software sync. EC-RO rejects the updated image and falls back to the previous one. The update counter is incremented and vboot shows the 'broken' screen, requesting recovery. Change-Id: I8a107a376963baa146ff691c50d80018ec3e429c Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/858159 Reviewed-by: Randall Spangler <rspangler@chromium.org>
* ec_commands: Add sync sensorGwendal Grignou2018-01-081-0/+3
| | | | | | | | | | | | | | | | | | | SYNC motion sensor are use to count event. It sends an event to the AP each time a GPIO goes low/high, the datum contains a 16 bit counter. The location indicates the source of the event, as Android sensor hal will use this information (via sysfs location attribute) to link the sensor with other subsystem. BUG=b:67743747 BRANCH=none TEST=Unit tests. Change-Id: Ia808b25730ad4100efa216c6a86b7b090197c5a3 Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/848496 Reviewed-by: Alexandru M Stan <amstan@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org>
* ec_commands: battery_dynamic_info: Rename current to actual_currentNicolas Boichat2018-01-041-2/+2
| | | | | | | | | | | | | | | | current is actually a reserved keyword in the Linux kernel, replace it by actual_current. And voltage by actual_voltage for consistency. BRANCH=none BUG=b:65697962 BUG=b:65697620 TEST=make buildall -j Change-Id: I8b8115174d15a1cc4b1189a54104bfec559ed72c Signed-off-by: Nicolas Boichat <drinkcat@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/848460 Reviewed-by: Gwendal Grignou <gwendal@chromium.org>
* ec_commands: Add commands required for EC-EC communicationNicolas Boichat2017-12-191-0/+66
| | | | | | | | | | | | | | | | | | | | | This adds 3 commands to obtain static and dynamic battery information, as well as control base charger state. These host commands are meant to be used as part of the EC-EC communication protocol (based on hostcmd v4 protocol), but could be used in the future to pass information between AP and EC, especially when more than 1 battery is present, which would be hard to support with the current MEMMAP-based approach. BRANCH=none BUG=b:65697962 BUG=b:65697620 TEST=Build wand and lux boards, flash it, EC-EC communication works. Signed-off-by: Nicolas Boichat <drinkcat@chromium.org> Change-Id: I263454794394838918832c9e4623835ab2f3a3da Reviewed-on: https://chromium-review.googlesource.com/670380 Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* ec_commands: Remove zero-size structsRandall Spangler2017-12-131-30/+27
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The size of empty structs (and unions) varies between C and C++. When including in C++ code our external API in ec_commands.h header with extern "C". clang will complain (correctly) for all empty structs: error: empty struct has size 0 in C, size 1 in C++ [-Werror,-Wextern-c-compat] Remove them from the ec_commands.h header file. ectool.c has some ugly macros which assume subcommands have both requests and responses. Change those macros so they only reference the non-empty sub-structs. The macros are still ugly, but generate identical output, and don't rely upon zero-length structs. BUG=chromium:792408 BRANCH=none TEST=manual 1) Compile the following using 'clang -Wall -Werror': #include <stdint.h> extern "C" { #include "include/ec_commands.h" } int main(void) { return 0; } It compiles without error. 2) Copy the lb_command_paramcount, ms_command_sizes, and cs_paramcount globals from ectool.c to a dummy .c file and compile with 'gcc -S' to generate assembly. Do the same after applying this patch. Confirm the arrays have the same contents. Change-Id: Iad76f10315b97205b42118ce070463071fe97128 Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/820649 Reviewed-by: Vincent Palatin <vpalatin@chromium.org> Reviewed-by: Shawn N <shawnn@chromium.org>
* motion: Add bh1730 as a motion sensorYB.Ha2017-12-081-0/+1
| | | | | | | | | | | | | | | | - Add ROHM ambient light sensor driver - Add als sensor to motion sensors BRANCH=glados BUG=b:67022366 TEST=This driver is tested in caroline Signed-off-by: yb.ha <ybha@samsung.com> Change-Id: Ic73c50e17b412975f7850b7348ce310180f7a6eb Reviewed-on: https://chromium-review.googlesource.com/784659 Commit-Ready: YongBeum Ha <ybha@samsung.com> Tested-by: YongBeum Ha <ybha@samsung.com> Reviewed-by: Gwendal Grignou <gwendal@google.com>
* host_events: Introduce unified host event commandJenny TC2017-12-061-0/+82
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Unified Host Event Programming Interface (UHEPI) enables a unified host command EC_CMD_PROGRAM_HOST_EVENT to set/get/clear different host events. Old host event commands (0x87, 0x88, 0x89, 0x8A, 0x8B, 0x8C, 0x8D, 0x8E, 0x8F) is supported for backward compatibility. But newer version of BIOS/OS is expected to use UHEPI command (EC_CMD_PROGRAM_HOST_EVENT) The UHEPI also enables the active and lazy wake masks. Active wake mask is the mask that is programmed in the LPC driver (i.e. the mask that is actively used by LPC driver for waking the host during suspended state). It is same as the current wake mask that is set by the smihandler on host just before entering sleep state S3/S5. On the other hand, lazy wake masks are per-sleep masks (S0ix, S3, S5) so that they can be used by EC to set the active wake mask depending upon the type of sleep that the host has entered. This allows the host BIOS to perform one-time programming of the wake masks for each supported sleep type and then EC can take care of appropriately setting the active mask when host enters a particular sleep state. BRANCH=none BUG=b:63969337 TEST=make buildall -j. And verfieid following scenario 1). Verified wake masks with ec hostevent command on S0,S3,S5 and S0ix 2). suspend_stress_test with S3 and S0ix 3). Verified "mosys eventlog list" in S3 and s0ix resume to confirm wake sources (Lid, power buttton and Mode change) 4). Verified "mosys eventlog list" in S5 resume to confirm wake sources (Power Button) 5). Verified above scenarios with combination of Old BIOS + New EC and New BIOS + Old EC(making get_feature_flags1() return 0) Change-Id: Idb82ee87fffb475cd3fa9771bf7a5efda67af616 Signed-off-by: Jenny TC <jenny.tc@intel.com> Reviewed-on: https://chromium-review.googlesource.com/576047 Commit-Ready: Jenny Tc <jenny.tc@intel.com> Commit-Ready: Jenny Tc <jenny.tc@intel.corp-partner.google.com> Tested-by: Jenny Tc <jenny.tc@intel.com> Tested-by: Jenny Tc <jenny.tc@intel.corp-partner.google.com> Reviewed-by: Furquan Shaikh <furquan@chromium.org>
* system: Allow hibernate to clear AP_OFF flagDaisuke Nojiri2017-12-051-1/+2
| | | | | | | | | | | | | | | | | | | After firmware update, cr50 toggles the EC's reset line, expecting the system will boot. This isn't the case for Chromebox because it sets AP_OFF flag on a clean shutdown (to restore the previous power state after power loss & restore). This patch adds EC_REBOOT_HIBERNATE_CLEAR_AP_OFF to EC reboot command. It makes EC first clear AP_OFF then hibernate. BUG=b:69721737 BRANCH=none TEST=Verify Fizz reboot after cr50 update. Change-Id: If3207d7284f244ca1adf0d516ef744dbc739a9c1 Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/802632 Reviewed-by: Aaron Durbin <adurbin@chromium.org>
* hostevents: Reclaim EC_HOST_EVENT_EXTENDED bitFurquan Shaikh2017-11-281-6/+0
| | | | | | | | | | | | | | | Now that we have support for 64-bit events, there is no need to reserve a bit in lower 32 bits for extended events. BUG=b:69329196 BRANCH=None TEST=make -j buildall Change-Id: Ide02c4384c2b3ab4a63b028f126c48b73d6cd269 Signed-off-by: Furquan Shaikh <furquan@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/791863 Reviewed-by: Randall Spangler <rspangler@chromium.org> Reviewed-by: Shawn N <shawnn@chromium.org>
* charge_manager: Add EC_CMD_OVERRIDE_DEDICATED_CHARGER_LIMITDaisuke Nojiri2017-11-281-0/+10
| | | | | | | | | | | | | | | | | | Usually, the max current and supply voltage of dedicated chargers are not known to the EC. This patch adds EC_CMD_OVERRIDE_DEDICATED_CHARGER_LIMIT, which allows the host to change the max current and supply voltage of the dedicated charge port. BUG=b:64442692 BRANCH=none TEST=make runtests && buildall. Boot Fizz and let coreboot set the adapter current and voltage. Change-Id: I29b3f5762f8b316ca363c23e230530cdf4ca207a Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/769152
* ec_commands: Add structs for host command protocol V4Randall Spangler2017-11-221-1/+135
| | | | | | | | | | | | | | | This only adds the structs for V4 packets. Host command support for them is coming in a subsequent CL. V3 packets will continue to be supported for a while, until all sides support V4. BUG=chromium:787159 BRANCH=none TEST=make -j runtests Change-Id: I7e188a063d8ed60c85f3b8359959c424e3ccd1d9 Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/780452 Reviewed-by: Nicolas Boichat <drinkcat@chromium.org>
* host_events: Bump up host events and masks to 64-bitFurquan Shaikh2017-11-211-3/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | With the upcoming change to add a new command to get/set/clear host events and masks, it seems to be the right time to bump up the host events and masks to 64-bit. We are already out of available host events. This change opens up at least 32 bits for new host events. Old EC commands to operate on host events/masks will still deal with lower 32-bits of the events/mask. On the other hand, the new command being added will take care of the entire 64-bit events/masks. This ensures that old BIOS and kernel versions can still work with the newer EC versions. BUG=b:69329196 BRANCH=None TEST=make -j buildall. Verified: 1. hostevent set 0x4000 ==> Sets correct bit in host events 2. hostevent clear 0x4000 ==> Clears correct bit in host events 3. Kernel is able to query and read correct host event bits from EC. Verified using evtest. 4. Coreboot is able to read correct wake reason from EC. Verified using mosys eventlog list. Change-Id: Idcb24ea364ac6c491efc2f8dd9e29a9df6149e07 Signed-off-by: Furquan Shaikh <furquan@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/770925 Reviewed-by: Randall Spangler <rspangler@chromium.org>
* Fizz: Modify thermal tableRyan Zhang2017-11-061-0/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Modify thermal table for Fizz reference patches: 627542, 288256, 329359 on off RPM step0 0 step1 16 2 2800 step2 27 18 3200 step3 35 29 3400 step4 43 37 4200 step5 54 45 4800 step6 64 56 5200 step7 97 83 5600 Prochot degree: active when t >= 88C release when t <= 85C Shutdown degree: when t >= 90C BUG=b:67487721, b:64439568 BRANCH=master TEST=fan target speed follows table, make -j buildall pass Change-Id: I3378668a560b8ddc568fe9cbf2703613fad8e4b6 Signed-off-by: Ryan Zhang <ryan.zhang@quanta.corp-partner.google.com> Reviewed-on: https://chromium-review.googlesource.com/729606 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
* pd: Add "freeze" dual-role policyShawn Nematbakhsh2017-10-191-0/+1
| | | | | | | | | | | | | | | | | Add a new DRP policy to "freeze" the power role of each port, never toggling automatically, though manual role swaps may still occur. BUG=chromium:769895 BRANCH=servo TEST=On servo_v4, verify DUT port stays in SRC role and POWER port stays in SNK role while disconnected. Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org> Change-Id: Ibff3cd1ffaf0e884b030c231003763a57acbe02e Reviewed-on: https://chromium-review.googlesource.com/715276 Commit-Ready: Shawn N <shawnn@chromium.org> Tested-by: Shawn N <shawnn@chromium.org> Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* host_event_commands: Add support for always reporting masksFurquan Shaikh2017-10-181-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add a new mask type (ALWAYS_REPORT mask) that is set by default to certain host events that should always be reported to the host irrespective of the state of SCI, SMI and wake masks. This mask includes host events like critical events resulting in shutdown or reboot, events that are consumed by BIOS, etc. Now that ALWAYS_REPORT mask is added, this change also updates the way EC manages set/query operations for host events: 1. During set operation, EC will check if the host event is present in any of the 4 masks - SCI, SMI, wake and always report. If yes, then it is set in hostevents. 2. During query operation, EC will extract the lowest set event from hostevents, clear it and return it back to the host. In order to reflect the above change in EC behavior, a new feature bit is used EC_FEATURE_UNIFIED_WAKE_MASKS. This allows the host to decide when wake mask needs to be set before checking for host events. BUG=None BRANCH=None TEST=make -j buildall. Also verified following: 1. Wake from S3 works as expected. Host is able to log correct wake sources (Verified power button, lid open, base key press and tablet mode change on soraka). 2. Wake from S5 works as expected. Host is able to log correct wake sources (Verified power button, lid open on soraka). 3. Wake from S0ix works as expected (Verified power button, lid open on soraka). 4. Software method to trigger recovery still works fine: reboot ap-off hostevent set 0x4000 powerb Change-Id: I62e5c1f82247c82348cd019e082883d86ec2688f Signed-off-by: Furquan Shaikh <furquan@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/719578 Reviewed-by: Aaron Durbin <adurbin@chromium.org>