summaryrefslogtreecommitdiff
path: root/include/ec_commands.h
Commit message (Collapse)AuthorAgeFilesLines
* zephyr: Avoid duplicate definition of GENMASK, etc.Simon Glass2020-12-241-0/+7
| | | | | | | | | | | | | | These two macros are defined by Zephyr after this header is included. Avoid this with an #ifdef. BUG=b:175434113 BRANCH=none TEST=build zephyr for volteer Signed-off-by: Simon Glass <sjg@chromium.org> Change-Id: Iaa802de3e49bbdbb68bf9044be28a93bd095c7de Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2600227 Reviewed-by: Keith Short <keithshort@chromium.org>
* virtual mux: Wait for mux config ACK from the kernelDivya Sasidharan2020-12-151-0/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | This CL: 1. Add a new config CONFIG_USB_MUX_AP_ACK_REQUEST to enable request for ACK from AP 1. Adds a new feature flag to inform the AP that an ACK is needed for boards supporting Burnside bridge retimer. 2. Adds a new host command for the EC to wait for mux config ACK for entering and exiting the safe mode. 3. Adds 12.5msec delay after configuring retimer and SoC as recommended. BUG=b:166300460,b:161327513 BRANCH=none TEST=Verify Type-C dock is functional with multiple hotplugs and flipped orientation. Verify USB3.0 is detected and not downgraded. Verify no regression with TBT3 and USB4 dock. Cq-Depend: chromium:2530517 Change-Id: I5b8224648f0fc36b30e24ca3e7254d708c676149 Signed-off-by: Divya Sasidharan <divya.s.sasidharan@intel.com> Signed-off-by: Ayushee Shah <ayushee.shah@intel.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2366127 Commit-Queue: YH Lin <yueherngl@chromium.org> Commit-Queue: Abe Levkoy <alevkoy@chromium.org> Reviewed-by: Abe Levkoy <alevkoy@chromium.org>
* ec_commands: add struct ec_response_activity_dataChing-Kang Yen2020-12-111-7/+11
| | | | | | | | | | | | | | Add struct ec_response_activity_data to handle activity data in include/ec_commands.h. BRANCH=None BUG=b:169374265 TEST=make buildall Signed-off-by: Ching-Kang Yen <chingkang@chromium.org> Change-Id: I5f40d45d656ae91acc6e9364261c548f302383ae Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2581708 Reviewed-by: Gwendal Grignou <gwendal@chromium.org>
* PCHG: Send device event to hostDaisuke Nojiri2020-12-101-0/+1
| | | | | | | | | | | | | | | | | This patch makes PCHG send EC_HOST_EVENT_DEVICE on every state machine cycle. The host is expected to retrieve the device event mask through EC_CMD_DEVICE_EVENT and updates port status if the mask has EC_DEVICE_EVENT_WLC. BUG=b:173235954 BRANCH=Trogdor TEST=Enabled and disabled EC_DEVICE_EVENT_WLC via deviceevent command and verified the sysfs node is updated. Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> Change-Id: I9dece6bc35599db3d6ae30452fd8e97bbaeab9af Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2579722 Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* PCHG: Add host commandDaisuke Nojiri2020-12-101-0/+47
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch adds a host command to get the peripheral charge port count and status. $ ectool pchg 1 $ ectool pchg 0 State: CHARGING (4) Battery: 50% Flags: 0x0 $ ectool pchg 0 foo Invalid parameter count Usage1: pchg Usage2: pchg <port> Usage1 prints the number of ports. Usage2 prints the status of a port. $ ectool pchg 100 Bad port index BUG=b:173235954 BRANCH=Trogdor TEST=Done on CoachZ. See the description above. Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> Change-Id: I33f261e48b16d5933b6f3ca9f3c12fec476edda3 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2555628 Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* ec_commands: Add GENMASK macrosTom Hughes2020-11-251-0/+8
| | | | | | | | | | | | | | GENMASK is used in ec_commands.h, but is not defined if not compiling in kernel or Chrome OS EC environments. BRANCH=none BUG=b:144959033 TEST=make buildall Signed-off-by: Tom Hughes <tomhughes@chromium.org> Change-Id: I439b0d77c47f3921f7bf2afd04c62cc72d668ea6 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2558857 Reviewed-by: Keith Short <keithshort@chromium.org>
* Ectool: support reboot AP from G3 state with configurable delay.ravindr12020-11-231-4/+12
| | | | | | | | | | | | | | | On using Ectool command - reboot_ap_on_g3 [<delay>] && shutdown -h now, AP must perform a reboot from G3 state to S0 state with configurable delay in seconds on it's next corresponding shutdown cycle. BUG=b:172885634 BRANCH=none TEST=Run Ectool command - reboot_ap_on_g3 50 && shutdown -h now. Change-Id: I2c5eb304d27a9647f0adc220d91de2d0b4061460 Signed-off-by: ravindr1 <ravindra@intel.corp-partner.google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2528731 Reviewed-by: Keith Short <keithshort@chromium.org>
* keyboard_mkbp: Add a virtual switch EC_MKBP_FRONT_PROXIMITYWai-Hong Tam2020-11-181-0/+1
| | | | | | | | | | | | | | | Add a new virtual switch to indicate whether a nearby object is present in front of the device. The implementation will be added later. BRANCH=None BUG=b:168714440 TEST=Built the image correctly. Change-Id: I4cc71a35d8aac391719a5966ec2d57a5bb1d4761 Signed-off-by: Wai-Hong Tam <waihong@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2543111 Reviewed-by: Paul Fagerburg <pfagerburg@chromium.org>
* system: Add EC_REBOOT_COLD_AP_OFF commandPi-Hsun Shih2020-11-171-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | Add EC_REBOOT_COLD_AP_OFF as a command of EC_CMD_REBOOT_EC host command, that would cold reboot EC without booting AP. BUG=chromium:1121907 TEST=With CL:2422025 CL:2459802, echo 1 > /var/lib/power_manager/reset_ec_on_next_shutdown click shutdown on UI and observe that EC is rebooted and AP is still off. TEST=With CL:2422025 CL:2459802, echo 1 > /var/lib/power_manager/reset_ec_on_next_shutdown dbus-send --system --print-reply --dest=org.chromium.PowerManager \ /org/chromium/PowerManager \ org.chromium.PowerManager.RequestRestart \ int32:0 string:test observe that EC is rebooted. Change-Id: Ifccff3831d785091b7c99def0e43a0d20bfc412b Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2428361 Commit-Queue: Pi-Hsun Shih <pihsun@chromium.org> Tested-by: Pi-Hsun Shih <pihsun@chromium.org> Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
* common: motion_sense: Add spoofing activityChing-Kang Yen2020-11-131-2/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | make spoof command able to spoof activity state: ectool motionsense spoof -- NUM activity ACT [EN] [0/1] This commit also remove unused parameter |sensor_num| from list_activities, set_activity, get_activity in ectool. BRANCH=None BUG=b:123434029 TEST=buildall TEST=ectool motionsense spoof 4 activity 4 1 0 ectool motionsense spoof 4 activity 4 ectool motionsense get_activity 4 ectool motionsense spoof 4 activity 4 1 1 ectool motionsense get_activity 4 ectool motionsense spoof 4 activity 4 0 ectool motionsense get_activity 4 ectool motionsense spoof 4 activity 4 1 ectool motionsense get_activity 4 Signed-off-by: Ching-Kang Yen <chingkang@chromium.org> Change-Id: I819c156ae7fe50c5cf6216d0f44012d192fb528e Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2477393 Reviewed-by: Gwendal Grignou <gwendal@chromium.org>
* ec_command: don't assume BUILD_ASSERT is undefinedJett Rink2020-11-111-0/+3
| | | | | | | | | | | | | | | | In the scenario where we are not building from platform/ec, we define BUILD_ASSERT to a no-op. We should only do that if the BUILD_ASSERT macro is undefined; otherwise we should just leave the definition. BRANCH=none BUG=none TEST=build EC and zephyr code without issue Signed-off-by: Jett Rink <jettrink@chromium.org> Change-Id: I6d51106f51217279acb2dcf252ee8ac3383f9959 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2532684 Commit-Queue: Jack Rosenthal <jrosenth@chromium.org> Reviewed-by: Jack Rosenthal <jrosenth@chromium.org>
* Add EC_CMD_BATTERY_GET_STATIC v1 for zorkPeter Marheine2020-11-101-0/+22
| | | | | | | | | | | | | | | | | | | | | | | | Some zork variants have battery model names that differ only beyond the 7th character, which cannot be differentiated with the current limitation of 8 characters per battery string. Introduce a new hostcmd version that allows longer battery strings and enable it on Zork. Because allowing longer strings through the host memory map is more difficult and not required (because getting the full longer string is mostly only useful for servicing), the host memory map is unchanged. ectool is updated to use hostcmd (rather than memory map) if the new command version is available, in order to take advantage of it. BUG=b:171854783 TEST=ectool battery prints longer strings when supported by the EC; a hacked EC on morphius can return 11 characters of text. An EC running older firmware still works with a new ectool. BRANCH=zork Change-Id: I63d20d4f690b6945cb1d423aafaf55dafc039211 Signed-off-by: Peter Marheine <pmarheine@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2519243 Reviewed-by: Edward Hill <ecgh@chromium.org>
* ec_commands: unify comments from kernel ec_commandGwendal Grignou2020-11-051-6/+1
| | | | | | | | | | | | | | | | Merge changes from crrev.com/c/2044498 into ec code base. Fixes a8b2362e82e1 ("TCPMv1: Cleanup sending TBT control flags to host") Fixes 340804c765a2 ("usb_pd: Sending Thunderbolts-compatible host notification") BUG=b:147460168,b:148114593,b:140644242 BRANCH=none TEST=Compile Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Change-Id: I0a08c21d375d055eb010a6752807d82f5e8e0003 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2520296 Reviewed-by: Vijay P Hiremath <vijay.p.hiremath@intel.com> Reviewed-by: Keith Short <keithshort@chromium.org>
* features: Define AP-driven mode entryAbe Levkoy2020-10-261-0/+5
| | | | | | | | | | | | | | Add EC_FEATURE_TYPEC_REQURE_AP_MODE_ENTRY. BUG=b:168030639 TEST=make buildall BRANCH=none Signed-off-by: Abe Levkoy <alevkoy@chromium.org> Change-Id: I413abdfb123b3b7119fa1862b018557de81c2cbd Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2411181 Reviewed-by: Diana Z <dzigterman@chromium.org> Commit-Queue: Diana Z <dzigterman@chromium.org>
* TCPMv2: Add typeccontrol enter-mode subcommandAbe Levkoy2020-10-221-0/+9
| | | | | | | | | | | | | | | | | | Define and implement TYPEC_CONTROL_COMMAND_ENTER_MODE. Allow DPM state to be accessed asynchronously by host commands. Add support for this command to ectool. BUG=b:168030639 TEST=Attach DP dongle; discovers but does not enter TEST=ectool typeccontrol 1 2 0; enters DP TEST=Attach TBT dock and TBT active cable; discovers but does not enter TEST=ectool typeccontrol 1 2 1; enters TBT BRANCH=none Change-Id: I218c4b9a92004ef1efe9a27b2a920031961b33f3 Signed-off-by: Abe Levkoy <alevkoy@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2454538 Reviewed-by: Diana Z <dzigterman@chromium.org>
* TCPMv2: Report TYPEC commands as a featureDiana Z2020-10-211-0/+2
| | | | | | | | | | | | | | | | | | | | To ease the AP's use of the new TYPEC_* host commands, add a feature flag to indicate their presence. Since ToT TCPMv2 always supports these commands, use that configuration as the trigger for it. Note for firmware branch pickers: this commit should only be picked if the branch is also picking the corresponding TYPEC commands (currently as of this CL: STATUS, DISCOVERY, and CONTROL). BRANCH=None BUG=b:167700356 TEST=on waddledoo, confirm Type-c command support shows up in "ectool inventory" Signed-off-by: Diana Z <dzigterman@chromium.org> Change-Id: I4ff78c9b6ca297933611d4abf239fb67b1221751 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2473100 Reviewed-by: Abe Levkoy <alevkoy@chromium.org>
* TCPMv2: Add fields for sink capabilities to TYPEC_STATUSDiana Z2020-10-211-5/+2
| | | | | | | | | | | | | | | | | Round out the final fields of the new TYPEC_STATUS v0 command return with sink capabilities fields. Note that they are not yet being populated, but are being added now to avoid unnecessary return versioning in the coming months when the command is being used. BRANCH=None BUG=b:167700356 TEST=make -j buildall Signed-off-by: Diana Z <dzigterman@chromium.org> Change-Id: I38a6e96a9ec4974e11b85839abcd4deafcf96b6c Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2473099 Reviewed-by: Jett Rink <jettrink@chromium.org> Reviewed-by: Abe Levkoy <alevkoy@chromium.org>
* TCPMv2: Report source capabilities in TYPEC_STATUSDiana Z2020-10-211-2/+81
| | | | | | | | | | | | | | | | Report the source capabilities for a port to the TYPEC_STATUS host command, and add decoding for the interesting fields here to ectool. BRANCH=None BUG=b:167700356 TEST=on waddledoo, confirm source capability decoding from ectool matches that from TotalPhase for servo_v4 and a charger Signed-off-by: Diana Z <dzigterman@chromium.org> Change-Id: Ib79c36c613c47fc60cfd8736202216ee40fbb42f Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2473098 Reviewed-by: Jett Rink <jettrink@chromium.org> Reviewed-by: Abe Levkoy <alevkoy@chromium.org>
* TCPMv2: Report partner PD revisions in TYPEC_STATUSDiana Z2020-10-211-15/+39
| | | | | | | | | | | | | | | | | | Gather and report both SOP and SOP' revisions for port partners. BRANCH=None BUG=b:167700356 TEST=on waddledoo, confirmed SOP and SOP' revisions were reported correctly with: - active cable and non-PD partner - PD 3.0 dock and active cable - PD 2.0 dock and active cable - PD 3.0 and PD 2.0 partners with no e-mark cable Signed-off-by: Diana Z <dzigterman@chromium.org> Change-Id: I6448e5b80212b171a44864f90ae5cdfecbcb7244 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2473097 Reviewed-by: Jett Rink <jettrink@chromium.org>
* ec_commands: fix DP PIN assignment flagEric Yilun Lin2020-10-071-7/+7
| | | | | | | | | | | | | | | The DP PIN assignment mask was shifted by 1 bit since CL:2432452. BUG=b:170191143, b:167700356 TEST=ensure asurada DP out BRANCH=none Change-Id: I05806d2f49fa74c2bfc6f5fb27fb9afe5f8225d8 Signed-off-by: Eric Yilun Lin <yllin@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2452131 Reviewed-by: Diana Z <dzigterman@chromium.org> Commit-Queue: Diana Z <dzigterman@chromium.org>
* TCPMv2: Add event clear to TYPEC_CONTROLDiana Z2020-10-051-1/+5
| | | | | | | | | | | | | | | | | When the AP has finished processing events, it can use TYPEC_CONTROL to clear the specific events it has completed. This also fixes an issue with the control command structure byte alignment. BRANCH=None BUG=b:148816435 TEST=on waddledoo, plug in Apple dongle and clear SOP discovery event with "ectool typecontrol" Signed-off-by: Diana Z <dzigterman@chromium.org> Change-Id: I38d522f346bfd500b72109db46f78a9c135ce96e Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2432457 Reviewed-by: Jett Rink <jettrink@chromium.org> Reviewed-by: Abe Levkoy <alevkoy@chromium.org>
* TCPMv2: Notify on SOP and SOP' discovery completeDiana Z2020-10-051-0/+3
| | | | | | | | | | | | | | | | | | | | | Notify the AP when the task has finished discovery. The AP doesn't need notification if nothing was found, but does need notification by transmit type as long as at least DiscoverIdentity was returned. BRANCH=None BUG=b:148816435 TEST=on waddledoo, verify: - events are 0 with nothing plugged in - events show SOP complete with Apple dongle - events show SOP and SOP' complete with TBT dock - events show SOP complete with Moshi (DiscoverIdentity only) - events show SOP complete with WooHub (Mode discovery will NAK) Signed-off-by: Diana Z <dzigterman@chromium.org> Change-Id: I5fcfc1ba2bde40c70400462dcc4efc2b7b60d0ca Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2432456 Reviewed-by: Abe Levkoy <alevkoy@chromium.org>
* TCPMv2: Add events to TYPEC_STATUS host commandDiana Z2020-10-051-1/+3
| | | | | | | | | | | | | | Add retrieval of the event bits to the TYPEC_STATUS host command and ectool output. BRANCH=None BUG=b:167700356 TEST=on waddledoo, verify events show up in "ectool typecstatus" Signed-off-by: Diana Z <dzigterman@chromium.org> Change-Id: If9f4f9b56acb6108c5f87f0d2ddf7a7d945f9403 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2432455 Reviewed-by: Abe Levkoy <alevkoy@chromium.org>
* TCPMv2: Add PD_EVENT_TYPECDiana Z2020-10-051-4/+6
| | | | | | | | | | | | | | | | | | The kernel uses the EC_CMD_PD_HOST_EVENT_STATUS command after receiving notifications from the EC. TCPMv2 will be moving to track events in a per-port manner with the new EC_CMD_TYPEC_STATUS command, and the new PD_EVENT_TYPEC flag will indicate that the kernel should use this new command to retrieve more specific events. BRANCH=None BUG=b:148816435 TEST=make -j buildall Signed-off-by: Diana Z <dzigterman@chromium.org> Change-Id: Ie76fc5abfbf2c433645577a61efdcce7f1dcc0c2 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2432453 Reviewed-by: Abe Levkoy <alevkoy@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org>
* TCPMv2: Add TYPEC_STATUS commandDiana Z2020-10-051-1/+114
| | | | | | | | | | | | | | | | | | | | | | | The TYPEC_STATUS command will be deprecating the informational return from the USB_PD_CONTROL host command. It brings over the enablement, role, and connection information from the older command. Cable specifics are excluded as they are redundant with the discovery return. Information about the mux state is also added for convenience. Additionally, this moves enums and defines which are a part of our overall pd_* API to the ec_commands.h file to ensure consumers have the same field values available for interpretation as the EC. BRANCH=None BUG=b:167700356 TEST=on waddledoo, plug in chargers and dongles and ensure outputs from "ectool typecstatus <port>" match "ectool usbpd <port>" and "ectool usbpdmuxinfo" Signed-off-by: Diana Z <dzigterman@chromium.org> Change-Id: Ic7afc0b282b88fdb34cb9a6feef22ad913bb4aae Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2432452 Reviewed-by: Abe Levkoy <alevkoy@chromium.org>
* host_event_commands: Return access denied for prohibited accessDaisuke Nojiri2020-09-221-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | Currently, EC_CMD_HOST_EVENT returns the same error code for non-existing masks and prohibited access to the existing masks. This patch makes the command return ACCESS_DENIED for the latter case so that the host can distinguish the two cases. ToT BIOS won't be affected because the EC's return codes are collapsed to -1 or -(request size). $ ectool hostevent set 1 0 Set isn't permitted for mask 1. BUG=b:168939843 BRANCH=None TEST=Verified on Atlas. See above. Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> Change-Id: Ia346dbffd459985d5eea8a955e22822d402d5388 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2422805 Reviewed-by: Furquan Shaikh <furquan@chromium.org> Commit-Queue: Furquan Shaikh <furquan@chromium.org>
* TCPMv2: Define typeccontrol host commandAbe Levkoy2020-09-211-0/+20
| | | | | | | | | | | | | | | For now, just support exiting the entered mode, if that mode happens to be DisplayPort (getting TBT3 and USB4 to work correctly will require some more work). Support this command in ectool. BUG=b:168030639 TEST=ectool typeccontrol 0 1; observe DP Exit Mode exchange in PD trace BRANCH=none Signed-off-by: Abe Levkoy <alevkoy@chromium.org> Change-Id: Ib30479cc88696115060e9ff74f6815ce074e6bf5 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2415069 Reviewed-by: Diana Z <dzigterman@chromium.org>
* TCPMv2: Add EC_CMD_TYPEC_DISCOVERYDiana Z2020-09-031-0/+37
| | | | | | | | | | | | | | | | | | | | | | | | | | | | This host command will return all discovery information for the given port and transmit type (SOP, SOP'). Each piece of information includes a count of the number of valid fields filled in to the arrays. To keep the command consolidated and easy to parse, this means there will be some number of bytes in each response which do not contain useful information. With this method, we may fit 7 SVID entries with mode information, which is less than the 16 which the EC can store, but more than most port partners present. BRANCH=None BUG=b:165264379 TEST=on waddledoo, confirm ectool shows: -no discovery information with nothing plugged in -no discovery information with a charger which doesn't reply to VDMs -SOP identity but no SVIDs with Moshi, which NAKs DiscoverSVIDs -SOP identity and all SVIDs with Apple 3-in-1 -SOP and SOP' identity and all SVIDs with TBT dock Signed-off-by: Diana Z <dzigterman@chromium.org> Change-Id: Idf21b23ebe4cda62781762188601b2cc35ede65d Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2363417 Reviewed-by: Jett Rink <jettrink@chromium.org> Commit-Queue: Jett Rink <jettrink@chromium.org>
* ec_commands: add uint16_t alias to motion_sensor_data for light sensorsIkjoon Jang2020-09-021-0/+2
| | | | | | | | | | | | | | | | Current EC protocol defines motion sensor's 3-axis raw data type as i16 but in case of light sensor, this should be u16 to support up to 65535. This patch explicitly declares u16 type in protocol definition BUG=b:162396219 TEST=Build BRANCH=none Change-Id: Ie38c7d72d9a8ab5d83d23edfa3faeb7fccaa0082 Signed-off-by: Ikjoon Jang <ikjn@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2328948 Reviewed-by: Gwendal Grignou <gwendal@chromium.org>
* fpsensor: Run maintenance when in maintenance modeTom Hughes2020-08-311-0/+3
| | | | | | | | | | | | BRANCH=none BUG=b:76037094 TEST=make buildall -j Signed-off-by: Tom Hughes <tomhughes@chromium.org> Change-Id: Ibe8649c3cf77ef4542b5fc46d7df5eee03293b56 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2364755 Commit-Queue: Craig Hesling <hesling@chromium.org> Reviewed-by: Craig Hesling <hesling@chromium.org>
* driver: add icm426xx chip type defineJean-Baptiste Maneyrol2020-08-291-0/+1
| | | | | | | | | | | | | | | | Add new enum motionsensor_chip and update ectool motionsense. BUG=chromium:1117541 BRANCH=None TEST=ectool motionsense info Cq-Depend: chromium:2317888 Signed-off-by: Jean-Baptiste Maneyrol <jmaneyrol@invensense.com> Change-Id: I07736d61bdb7332bfdc44c8f7294233e43a6e00d Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2374647 Reviewed-by: Gwendal Grignou <gwendal@chromium.org> Commit-Queue: Gwendal Grignou <gwendal@chromium.org> Tested-by: Gwendal Grignou <gwendal@chromium.org>
* endeavour: add pse host commandJeff Chase2020-08-181-0/+27
| | | | | | | | | | | | | This will allow userspace to turn PoE ports off and on. BUG=b:163786867 TEST=manual BRANCH=none Change-Id: Ib9716c5ebc6806f79c8cf85843b93d8c1ff0cba3 Signed-off-by: Jeff Chase <jnchase@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2354544 Reviewed-by: Ting Shen <phoenixshen@chromium.org>
* common: motion_sense: Add on-body/off-body detectionGwendal Grignou2020-08-141-0/+19
| | | | | | | | | | | | | | | | This CL adds the interface for on-body/off-body detection - state: 1 : on-body, 0 : off-body. When activity is enabled, EC sends an event when the body detection changes. The host can now query the current value of the activity. BRANCH=None BUG=b:123434029 TEST=compile Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Change-Id: I007a5fe6c9030ab5c0c47995db3498751218d9c9 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2229803
* cbi: add Second Source Factory Cache (SSFC) CBI fieldMarco Chen2020-08-131-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | SSFC field will be leveraged to record what second source is used in the DUT by probing components in the factory or RMA. Firmware code should refer to this field to judge what driver should be configured for a specific component. For example, the board code can arrange what sensor driver should be set into motion_sensors array if there are multiple sources of base or lid sensor. As the definition of FW_CONFIG, it describe which "features" the firmware code should enable or disable. For example, whether lid / base sensors should be enabled or not but not care about what second source is in this DUT. BRANCH=none BUG=b:163285687 TEST=call `cbi-util` to create the cbi image with SSFC and show created content. TEST=`make buildall -j` TEST=`make runhosttests -j` Change-Id: Icb4aa00ae47ab025198e7fd5edd6aab96a4bf53e Signed-off-by: Marco Chen <marcochen@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2344268 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org> Commit-Queue: Jett Rink <jettrink@chromium.org>
* ec_commands: Add host commands for regulator control.Pi-Hsun Shih2020-07-231-0/+83
| | | | | | | | | | | | BUG=b:149274957 TEST=build BRANCH=none Change-Id: I9c7b5dec7e2f66ab64750b48acd914a1c86dfd3d Signed-off-by: Pi-Hsun Shih <pihsun@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2247431 Reviewed-by: Jett Rink <jettrink@chromium.org> Commit-Queue: Jett Rink <jettrink@chromium.org>
* audio_codec: add the command to reset I2S RXYu-Hsuan Hsu2020-07-081-0/+1
| | | | | | | | | | | | | | | | | | Adds EC_CODEC_I2S_RX_RESET to reset I2S RX because it is not sure that the I2S RX is always disabled when the kernel booting. For example, it will keep enabled if the kernel crashes while cros_ec_codec is used. BRANCH=none BUG=b:158316196 TEST=Able to reset I2S RX from the kernel. Change-Id: I461e5a3c73a4066a9ceb097fc5320aef98d81db4 Signed-off-by: Yu-Hsuan Hsu <yuhsuan@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2284503 Reviewed-by: Edward Hill <ecgh@chromium.org> Reviewed-by: Tzung-Bi Shih <tzungbi@chromium.org> Tested-by: Yu-Hsuan Hsu <yuhsuan@chromium.org> Commit-Queue: Edward Hill <ecgh@chromium.org>
* npcx: Add a new flag to check for initial power-onAndrew McRae2020-06-231-0/+1
| | | | | | | | | | | | | | | | | | | | | The CR50 will reset the EC on some platforms after power-on. Add a reset flag to detect this and treat the second restart as a power-on restart rather than reset. Subsume the CONFIG_GPIO_INIT_POWER_ON_DELAY_MS config to make it clear what the behaviour will be. BUG=b:151329011 TEST=Confirm on dalboz, puff & variants that second reset is treated correctly. BRANCH=none Change-Id: Ib66de920403f08099b87d1eff797270606b44f8f Signed-off-by: Andrew McRae <amcrae@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2255830 Reviewed-by: Peter Marheine <pmarheine@chromium.org> Commit-Queue: Andrew McRae <amcrae@chromium.org> Tested-by: Andrew McRae <amcrae@chromium.org>
* Battery: Implement smart discharge systemDaisuke Nojiri2020-06-201-0/+38
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Currently, CrOS EC chooses only one of the two powre-saving states when the system is left idle. One is to hibernate and the other is to cut off the battery. And these are determined at compile time. If the system hibernates, EC will not have a chance to cut off the battery before the state of charge reaches critical low. If the system is in cutoff, it requires an AC adapter to wake up. So, neither behavior is ideal. This patch introduces the smart discharge system. Given the number of hours to zero capacity as a target, it tries to choose the better state for idling. For example, if the state of charge is high, it will hibernate the system because the target can be met before the battery completely drains. If the state of charge is low, it will keep the EC up so that it can cutoff the battery. Tests are done on Bloog as follows: Verify EC selects not to hibernate when the remaining capacity is below the stay-up threshold. The ectool smartdischarge command is tested as follows: localhost ~ # ectool smartdischarge Hours to zero capacity: 0 h Stay-up threshold: 0 mAh Cutoff threshold: 0 mAh Hibernate discharge rate: 0 uA Cutoff discharge rate: 0 uA localhost ~ # ectool smartdischarge 2160 Hours to zero capacity: 2160 h Stay-up threshold: 0 mAh Cutoff threshold: 0 mAh Hibernate discharge rate: 0 uA Cutoff discharge rate: 0 uA localhost ~ # ectool smartdischarge 2160 200 1500 EC result 3 (INVALID_PARAM) localhost ~ # ectool smartdischarge 2160 1500 200 Hours to zero capacity: 2160 h Stay-up threshold: 3240 mAh Cutoff threshold: 432 mAh Hibernate discharge rate: 1500 uA Cutoff discharge rate: 200 uA localhost ~ # ectool smartdischarge 2160 1500 0 EC result 3 (INVALID_PARAM) localhost ~ # ectool smartdischarge 0 Hours to zero capacity: 0 h Stay-up threshold: 0 mAh Cutoff threshold: 0 mAh Hibernate discharge rate: 1500 uA Cutoff discharge rate: 200 uA Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> BUG=b:152431365, b:157602162 BRANCH=none TEST=See above Change-Id: I1470b13203f3653ae0e495cd5ec8ed05f3c5102f Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2216392 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org> Commit-Queue: Daisuke Nojiri <dnojiri@chromium.org> Tested-by: Daisuke Nojiri <dnojiri@chromium.org> Auto-Submit: Daisuke Nojiri <dnojiri@chromium.org>
* PB: Clear AP_IDLE for EC_REBOOT_HIBERNATE_CLEAR_AP_OFFDaisuke Nojiri2020-06-131-1/+1
| | | | | | | | | | | | | | | | This patch fixes the EC_REBOOT_HIBERNATE_CLEAR_AP_OFF command to match the change made by CL:2213730. There is no functionality change. BUG=b:37536389 BRANCH=none TEST=Verify ectool hibernate-clear-ap-off works. Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> Change-Id: I70ec3a38b0ceaca8a79c6e2c6df127fb145496e2 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2242662 Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
* usb_pd: USB4: Limit the cable speedAyushee2020-06-051-1/+2
| | | | | | | | | | | | | | | | | | | | | | | Added 'get_usb4_cable_speed()' to return USB4 speed as per the port, the speed supported by DUT's port or cable speed whichever is lowest. Added configuring the cable speed in cros_ec_usb_pd_control according to the mux setting. Removed 'set_max_usb4_cable_speed()' to retain cable's actual VDO response. BUG=b:157671582 BRANCH=none TEST=1. Able to set USB4/USB3.2 Gen2 cable speed when DFP isn't gen 3 capable. 2. Able to limit cable speed according to the port, if the cable speed is higher. Signed-off-by: Ayushee <ayushee.shah@intel.com> Change-Id: I21bba7e5a2aa8ca54f304ef8418320f319f020b1 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2220826 Reviewed-by: Keith Short <keithshort@chromium.org>
* system: Add EC_RESET_FLAG_AP_IDLEDaisuke Nojiri2020-05-231-0/+1
| | | | | | | | | | | | | | This patch adds EC_RESET_FLAG_AP_IDLE. It will make RW leave the AP idle on start-up. The AP will continue to sequence up or down. BUG=b:154778457 BRANCH=none TEST=Verify test_that suite:faft_bios passes. Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> Change-Id: Ib4cad6c52952b139d4c6bea98747fe701c53a230 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2213729 Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
* system: Add EC_RESET_FLAG_EFSDaisuke Nojiri2020-05-141-0/+1
| | | | | | | | | | | | | | | | | This patch adds EC_RESET_FLAG_EFS. It indicates EC jumped to RW by successfully running EFS. system_jumped_late can be used to avoid running some code twice (once in RO and again in RW). Such code is currently (wrongly) guarded by system_jumped_to_this_image. BUG=b:156101251, chromium:1072743 BRANCH=none TEST=Verified the bug is fixed. Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> Change-Id: I58fc18510b2f95dfd116cbacba09875cb7cf5051 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2200245
* OCPC: Add concept of active charger ICAseda Aboagye2020-05-011-0/+1
| | | | | | | | | | | | | | | | | | | | | | | With OCPC, one charger IC per Type-C port, there are now multiple charger ICs present in the system. This commit adds the beginning of OCPC support by adding the notion of an active charger IC. Charge Manager will select the active charger IC based upon the charge port. Boards must define this mapping in a board specific function. Additionally, this commit adds chgnum as a parameter to charger_set_input_current_limit(). BUG=b:148981052 BRANCH=None TEST=With other patches, verify that the active charger IC is able to be saved and retrieved. Change-Id: Iba4a8958171ad6e1630b0ca3d07d128bc1f2c4dd Signed-off-by: Aseda Aboagye <aaboagye@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2135963 Tested-by: Aseda Aboagye <aaboagye@chromium.org> Reviewed-by: Diana Z <dzigterman@chromium.org> Commit-Queue: Aseda Aboagye <aaboagye@chromium.org>
* driver: Add BMI260 basic driver supportChing-Kang Yen2020-04-231-0/+1
| | | | | | | | | | | | | | | | | | | | Add BMI260 accel/gyro driver code. Be able to do initial configuration, start up sensor, config interrupt and fifo, perform calibration, and access the sensor data from AP. BRANCH=None BUG=b:146144827 TEST=make -j4 BOARD=volteer \ && flash_ec --image build/volteer/ec.bin --board volteer Then, check sensor data is available on DUT by "ectool motionsense". TEST=make buildall -j TEST=tast run ${IP} hardware.SensorRing Cq-Depend: chromium:2148802 Change-Id: I5124ee8359a74f98cfe8d26da640325f5e00cb15 Signed-off-by: Ching-Kang Yen <chingkang@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2086534 Reviewed-by: Gwendal Grignou <gwendal@chromium.org>
* ec_commands.h: Add host command EC_CMD_GET_KEYBD_CONFIGRajat Jain2020-04-151-0/+78
| | | | | | | | | | | | | | Add command to query the EC for the keyboard layout. Also add supporting data structures for the exchange. BUG=b:146501925 TEST=Build BRANCH=firmware-hatch-12672.B Signed-off-by: Rajat Jain <rajatja@google.com> Change-Id: I7031196bc1f7f86e8dcd6baaa9fd967bef16d2e2 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2133824 Reviewed-by: Jett Rink <jettrink@chromium.org>
* EFS2: Add EC_FEATURE_EFS2dnojiri2020-03-311-0/+6
| | | | | | | | | | | | | | | | | | This patch adds EC_EEATURE_EFS2. It allows AP, servo, and a developer to query whether EFS2 is supported or not. Signed-off-by: dnojiri <dnojiri@chromium.org> BUG=b/152449880 BRANCH=none TEST=Verify ectool inventory prints 38 on Helios. Change-Id: Id308cad4115314380ca47c45c3212e2e6fb4095d Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2125410 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org> Tested-by: Daisuke Nojiri <dnojiri@chromium.org> Auto-Submit: Daisuke Nojiri <dnojiri@chromium.org> Commit-Queue: Daisuke Nojiri <dnojiri@chromium.org>
* driver: lis2ds12: Add driver supportMario Tesi2020-03-271-0/+1
| | | | | | | | | | | | | | | | | | | | | Added ACC LIS2DS/LIS2DS12 driver support. Features included: - FIFO support with watermark interrupt events - Uses shared function with other ST MEMs devices BUG=none BRANCH=master TEST=Tested on discovery_stmems target BOARD with LIS2DS connected to EC i2c master bus and motion sense task running. All basic features tested including changing in ODR and Full Scale Range. Also tested FIFO features and interrupt management. Change-Id: I8a9e96f59ebdca7e622cff29676c5e1a9e0d58f5 Signed-off-by: Mario Tesi <mario.tesi@st.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/481480 Commit-Queue: Tim Wawrzynczak <twawrzynczak@chromium.org> Tested-by: Inno.Park <ih.yoo.park@samsung.corp-partner.google.com> Reviewed-by: Gwendal Grignou <gwendal@chromium.org>
* cbi: Support PCB supplier fieldAbe Levkoy2020-03-241-0/+1
| | | | | | | | | | | | | | | | | | | Add support for PCB_SUPPLIER, to distinguish boards of the same type with different PCB suppliers. BUG=b:140244489 TEST=ectool cbi set 7 0 1 0; ectool cbi get 7 TEST=cbi on EC console after writing with ectool TEST=/usr/share/userfeedback/scripts/cbi_info after writing with ectool TEST=cbi-util create --pcb_supplier 1 ...; cbi-util show ... BRANCH=none Change-Id: Ieadba91694f4775cc86c2c4b09cdf0874b9ad444 Signed-off-by: Abe Levkoy <alevkoy@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2108710 Reviewed-by: Jett Rink <jettrink@chromium.org> Tested-by: George Engelbrecht <engeg@google.com> Commit-Queue: George Engelbrecht <engeg@google.com>
* Button: add ectool command to simulate button presspandeyan2020-03-171-0/+37
| | | | | | | | | | | | | | | | | | Added a new ectool command 'ectool button' for simulating volume up and volume down button operations along with the duration in milli-seconds for which button needs to be pressed. BUG=b:149659987 BRANCH=None TEST=Tested on hatch board. From Kernel console, entered the below commands: $ectool button vup 500 Observed volume UP key press on EC console. Change-Id: I6fcdf80ea45b80403f72af89ce99214226731d0f Signed-off-by: pandeyan <anshuman.pandey@intel.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2059929 Reviewed-by: Jett Rink <jettrink@chromium.org>
* ec_commands: Add limits.h for linux kernel compatibilityGwendal Grignou2020-03-121-3/+3
| | | | | | | | | | | | | For Uxx_MAX macros, we need to include limits.h. BUG=chromium:945948 BRANCH=none TEST=compile. Check kernel 4.19 with this change compiles as well. Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Change-Id: Id498a1c647acab3007d5e368ed4b15382ef1c392 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2098871 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>