summaryrefslogtreecommitdiff
path: root/common/mkbp_event.c
Commit message (Collapse)AuthorAgeFilesLines
* mkbp: Separate FIFO from the keyboard driverBoris Mittelberg2021-04-271-2/+2
| | | | | | | | | | | | | | Move protocol-related functionality out from the keyboard driver. This change is required to allow passing button events via MKBP on devices with non-MKBP keyboards. It reorganizes the code without changing the logic. BUG=b:170966461 BRANCH=main,firmware-dedede-13606.B,firmware-volteer-13672.B-main TEST=None Signed-off-by: Boris Mittelberg <bmbm@google.com> Change-Id: Ifb5b9d8e605f491313ee1dfe2c9950eb52152aa8 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2669355
* zephyr: add MKBP supportHyungwoo Yang2021-01-261-8/+36
| | | | | | | | | | | | | | Add MKBP support to zephyr. BUG=b:173507858 BRANCH=none TEST=make buildall -j8 build volteer on zephyr Signed-off-by: Hyungwoo Yang <hyungwoo.yang@intel.corp-partner.google.com> Change-Id: I9b7d979241b0df5dc0fa5d9741f05dc9875189ab Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2639854 Reviewed-by: Keith Short <keithshort@chromium.org>
* mkbp_event: Always mark MKBP interrupt as inactive before setting it againPatryk Duda2020-11-171-3/+47
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch fixes issue with sensors data not flowing to the AP after ChromeOS reboot. Issue occurs when ChromeOS doesn't disable sensor FIFO interrupt. During ChromeOS reboot, EC sends MKBP event to host, but event can't be served. Hook task calls force_mkbp_if_events(), scheduled by activate_mkbp_with_events(). Called function sets state.interrupt to INTERRUPT_INACTIVE and calls active_mkbp_with_events() to set MKBP interrupt again (again force_mkbp_if_events() is scheduled). This is repeated 2 times only (limited by state.failed_attempts). After 3 attempts to generate MKBP interrupt force_mkbp_if_events() function is not changing state.interrupt to INTERRUPT_INACTIVE. As a result calling activate_mkbp_with_events() doesn't set MKBP interrupt and doesn't schedule force_mkbp_if_events() to be called by hook task. When ChromeOS is running, EC is not able to send MKBP interrupt again, because it is blocked by INTERRUPT_ACTIVE state. The only way to change interrupt state is call EC_CMD_GET_NEXT_EVENT host command which will eventually call set_inactive_if_no_events(). This host command is called by host only when it receives MKBP interrupt. This patch fixes vicious circle by setting state.interrupt to INTERRUPT_INACTIVE in force_mkbp_if_events() always and calling activate_mkbp_with_events() only when failed_attempts counter doesn't exceed limit. It is safe to mark interrupt state as INACTIVE, because force_mkbp_with_events() function can be only scheduled by activate_mkbp_with_event() which will set interrupt state to ACTIVE (if there are still events waiting). Furthermore, failed_attempts counter is only reset when AP actually pulls all of the events or number of attempts is exceeded. BUG=b:162254118 BRANCH=none TEST=Flash EC ToT on eve. Boot ChromeOS then reboot it. Switch to developer console and check if sensors works by calling following command: 'local_test_runner -waituntilready false hardware.SensorRing' Signed-off-by: Patryk Duda <pdk@semihalf.com> Change-Id: Ic6acf44770aba8d5d00f070de256751128171205 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2527171 Reviewed-by: Jett Rink <jettrink@chromium.org>
* tree: rename strtoul to strtoull since it is 64-bitJett Rink2020-11-111-1/+1
| | | | | | | | | | | | | | | A long is 32-bit, but a long long is 64-bit. The function name should be strtoull if it is returning 64 bits of data. BRANCH=none BUG=b:172592963 TEST=builds Signed-off-by: Jett Rink <jettrink@chromium.org> Change-Id: I04c40f9256ed37eb1cf9b6bd1b0ef0320fe49b0c Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2530874 Commit-Queue: Jack Rosenthal <jrosenth@chromium.org> Reviewed-by: Jack Rosenthal <jrosenth@chromium.org>
* common: online_calibration: Fire MKBP event on new calibrationYuval Peress2020-03-091-1/+1
| | | | | | | | | | | | | | Implement online calibration for accelerometers and fire a new MKBP event when a new calibration value is computed. TEST=Added new unit tests BRANCH=None BUG=b:138303429,chromium:1023858 Change-Id: I31ec7164be0d8c7dac210a1ac4b94ec9ecd6a60a Signed-off-by: Yuval Peress <peress@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2012847 Reviewed-by: Jack Rosenthal <jrosenth@chromium.org>
* Fix skip interrupt logic for host eventHeng-Ruey Hsu2019-11-111-4/+10
| | | | | | | | | | | | | | | | | If CONFIG_MKBP_HOST_EVENT_WAKEUP_MASK and CONFIG_MKBP_EVENT_WAKEUP_MASK are defined at the same time, |skip_interrupt| will be set for non host events. Add a check to handle it when |events_to_add| is MKBP host event. BUG=b:135575671 BRANCH=none TEST=CONFIG_MKBP_HOST_EVENT_WAKEUP_MASK and CONFIG_MKBP_EVENT_WAKEUP_MASK work as expected. Change-Id: Iff72b0e276b63a211c249b3d1a92c0303012684e Signed-off-by: Heng-Ruey Hsu <henryhsu@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1903630 Reviewed-by: Jett Rink <jettrink@chromium.org>
* host_command: Change host command return value to enum ec_statusTom Hughes2019-10-021-3/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | If the host command handler callback function returns an int, it's easy to accidentally mix up the enum ec_error_list and enum ec_status types. The host commands always expect an enum ec_status type, so we change the return value to be of that explicit type. Compilation will then fail if you accidentally try to return an enum ec_error_list value. Ran the following commands and then manually fixed up a few remaining instances that were not caught: git grep --name-only 'static int .*(struct host_cmd_handler_args \*args)' |\ xargs sed -i 's#static int \(.*\)(struct host_cmd_handler_args \*args)#\ static enum ec_status \1(struct host_cmd_handler_args \*args)##' git grep --name-only 'int .*(struct host_cmd_handler_args \*args)' |\ xargs sed -i 's#int \(.*\)(struct host_cmd_handler_args \*args)#\ enum ec_status \1(struct host_cmd_handler_args \*args)##' BRANCH=none BUG=chromium:1004831 TEST=make buildall -j Cq-Depend: chrome-internal:1872675 Change-Id: Id93df9387ac53d016a1594dba86c6642babbfd1e Signed-off-by: Tom Hughes <tomhughes@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1816865 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-by: Jack Rosenthal <jrosenth@chromium.org>
* common/mkbp_event: Avoid accessing an uninitialized variablePatrick Georgi2019-09-041-1/+3
| | | | | | | | | | | | | | | Found by Coverity Scan #198896 BUG=none BRANCH=none TEST=none Change-Id: I0f606e49ed30ff15054c296a8e698aca68a955d3 Signed-off-by: Patrick Georgi <pgeorgi@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1781465 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org> Tested-by: Patrick Georgi <pgeorgi@chromium.org> Commit-Queue: Patrick Georgi <pgeorgi@chromium.org>
* mkbp_event: Only notify MKBP via hostevent in suspendAseda Aboagye2019-08-011-4/+7
| | | | | | | | | | | | | | | | | | | | | | | If a board is using CONFIG_MKBP_USE_GPIO_AND_HOST_EVENT, make sure that the MKBP event notiification via host event only occurs in suspend. Since MKBP events are a part of the HOST_EVENT_ALWAYS_REPORT_DEFAULT_MASK, an MKBP host event could still be set in S0, but it will not trigger an SCI since the event is not in the SCI mask. This would cause the board to prematurely wake up when suspending due to the lingering event. BUG=none BRANCH=none TEST=Flash nocturne, boot to S0, suspend, verify that no spurious wakeups occur. Change-Id: I2e3196e836934d87d1d5efefff26f58c9e2bc3b2 Signed-off-by: Aseda Aboagye <aaboagye@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1728039 Tested-by: Aseda Aboagye <aaboagye@chromium.org> Auto-Submit: Aseda Aboagye <aaboagye@chromium.org> Reviewed-by: Ravi Chandra Sadineni <ravisadineni@chromium.org> Commit-Queue: Aseda Aboagye <aaboagye@chromium.org>
* mkbp_event: Only declare EC_CMD_MKBP_WAKE_MASK host command if neededNicolas Boichat2019-07-301-2/+2
| | | | | | | | | | | | | | | | | No need to use up flash space if the command is not supported anyway. BRANCH=none BUG=chromium:988303 TEST=make buildall -j TEST=make BOARD=jerry -j32, see that there is still 156 bytes free Save 64-128 bytes on most boards. Change-Id: Ib0494969840dfc4c11d236a2932f5de688ad6d14 Signed-off-by: Nicolas Boichat <drinkcat@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1723611 Reviewed-by: Aseda Aboagye <aaboagye@chromium.org> Tested-by: Aseda Aboagye <aaboagye@chromium.org>
* common/mkbp_event: Remove prints in hc_mkbp_wake_maskNicolas Boichat2019-07-301-4/+0
| | | | | | | | | | | | | | | | They take up flash space, and should not be super useful. BRANCH=none BUG=chromium:988303 TEST=make buildall before and after Save 64-100 bytes on most boards Change-Id: I8eafb19b971f0823c0b0b704e680e063aa23dbd8 Signed-off-by: Nicolas Boichat <drinkcat@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1723610 Reviewed-by: Aseda Aboagye <aaboagye@chromium.org> Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org> Tested-by: Aseda Aboagye <aaboagye@chromium.org>
* ec_commands: Add EC_CMD_MKBP_WAKE_MASK.Aseda Aboagye2019-07-251-2/+119
| | | | | | | | | | | | | | | | | | | | | | | | This commit adds a new host command, EC_CMD_MKBP_WAKE_MASK which allows the host to retrieve and set the MKBP host event wake mask along with the MKBP event wake mask. An accompanying console command, `mkbpwakemask` is present as well to view and adjust the wake masks. In order to use this host command, one of the following EC CONFIG_* options must be enabled in the EC: CONFIG_MKBP_HOST_EVENT_WAKEUP_MASK or CONFIG_MKBP_EVENT_WAKEUP_MASK. BUG=chromium:786721 BRANCH=None TEST=Deploy new version of ectool and EC firmware on nocturne, verify that ectool can view and adjust the wake masks. Verify that masks can be adjusted via the console command as well. Change-Id: I01a389ccd571328220eadd19ded4167dea8c6faa Signed-off-by: Aseda Aboagye <aaboagye@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1700004 Reviewed-by: Jett Rink <jettrink@chromium.org> Commit-Queue: Aseda Aboagye <aaboagye@chromium.org> Tested-by: Aseda Aboagye <aaboagye@chromium.org> Auto-Submit: Aseda Aboagye <aaboagye@chromium.org>
* mkbp_event: Add CONFIG_MKBP_USE_GPIO_AND_HOST_EVENT.Aseda Aboagye2019-07-171-3/+16
| | | | | | | | | | | | | | | | | | | | | | | | | MKBP was recently refactored to offer choice in the MKBP notification method. However, if a board is using a GPIO to notify the AP of a MKBP event, and the AP cannot wake from the GPIO, the MKBP event cannot wake the system up from suspend as is. This commit simply adds a new config option, CONFIG_MKBP_USE_GPIO_AND_HOST_EVENT such that MKBP events can wake the system from suspend. Note that the board will have to add MKBP events to the host event sleep mask in coreboot. Typically on ARM devices, EC_INT_L is already a wake pin, but on Intel devices it is not; there's actually a different pin, PCH_WAKE_L which is set via sending a host event and wakes the system. BUG=b:136272898,chromium:786721 BRANCH=None TEST=Enable config option on nocturne, flash nocturne, suspend DUT, verify that MKBP events can wake the AP. Change-Id: If5026bfe3efacbc051f99a180e061c6fd679ce5a Signed-off-by: Aseda Aboagye <aaboagye@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1685786 Reviewed-by: Jett Rink <jettrink@chromium.org> Tested-by: Aseda Aboagye <aaboagye@chromium.org> Commit-Queue: Aseda Aboagye <aaboagye@chromium.org>
* config: Add CONFIG_MKBP_EVENT_WAKEUP_MASKAseda Aboagye2019-07-171-3/+12
| | | | | | | | | | | | | | | | | | | This commit adds a new CONFIG_* option, CONFIG_MKBP_EVENT_WAKEUP_MASK. This allows a board to specify which MKBP events are allowed to wake the system when it is in suspend. BUG=b:136282898,chromium:786721 BRANCH=None TEST=With some other code, flash nocturne, suspend DUT, verify that only the MKBP events in the CONFIG_MKBP_EVENT_WAKEUP_MASK wake the system up. Change-Id: Ib4d04418aacab209d0e26703500df119924090b7 Signed-off-by: Aseda Aboagye <aaboagye@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1685785 Tested-by: Aseda Aboagye <aaboagye@chromium.org> Reviewed-by: Furquan Shaikh <furquan@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org> Commit-Queue: Aseda Aboagye <aaboagye@chromium.org>
* cleanup: Rename CONFIG_MKBP_WAKEUP_MASK for clarity.Aseda Aboagye2019-07-021-11/+14
| | | | | | | | | | | | | | | | | | | | | | CONFIG_MKBP_WAKEUP_MASK is a bit confusing and is wrongly named. The comment stated that "With this option, we can define the MKBP wakeup events in this mask (as a white list) in board level, those evets allow to interrupt AP during S3.". However, these events are NOT MKBP events at all but are instead host events. This commit tries to clear things up by renaming CONFIG_MKBP_WAKEUP_MASK to CONFIG_MKBP_HOST_EVENT_WAKEUP_MASK to better show that these events are in fact host events. BUG=b:136282898 BRANCH=None TEST=`make -j buildall` Change-Id: I42beadec8217435fd30e679ccf52d784a8ef99a0 Signed-off-by: Aseda Aboagye <aaboagye@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1685784 Tested-by: Aseda Aboagye <aaboagye@chromium.org> Reviewed-by: Alexandru M Stan <amstan@chromium.org> Commit-Queue: Aseda Aboagye <aaboagye@chromium.org>
* LICENSE: remove unnecessary (c) after CopyrightTom Hughes2019-06-191-1/+1
| | | | | | | | | | | | | | | | Ran the following command: git grep -l 'Copyright (c)' | \ xargs sed -i 's/Copyright (c)/Copyright/g' BRANCH=none BUG=none TEST=make buildall -j Change-Id: I6cc4a0f7e8b30d5b5f97d53c031c299f3e164ca7 Signed-off-by: Tom Hughes <tomhughes@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1663262 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
* mkbp: take timestamp closer to hardware interruptJett Rink2019-04-241-15/+2
| | | | | | | | | | | | | | | | | We want to ensure that the timestamp we take for last mkbp is as close to the actual hardware interrupt from EC->AP. BRANCH=none BUG=b:129159505 TEST=passing CTS sensor run (except test 133 nullptr) with this change Change-Id: I94b214f021f0b63ff2883e5fe8e32acc83ce208f Signed-off-by: Jett Rink <jettrink@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1560390 Tested-by: Alexandru M Stan <amstan@chromium.org> Reviewed-by: Enrico Granata <egranata@chromium.org> Reviewed-by: Mathew King <mathewk@chromium.org> Commit-Queue: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com>
* mkbp: handle multiple writes of interruptJett Rink2019-04-181-76/+224
| | | | | | | | | | | | | | | | | | | We need to handle the case of multiple tasks trying to set the mkbp interrupt while the host command task is trying to clear it. The setting of the interrupt may also take a while and we need to ensure that we synchronize correct after a longer delay. BRANCH=none BUG=b:129159505 TEST=passing CTS sensor run (except test 133 nullptr) with this change TEST=pass CTS sensor run on eSPI-based system TEST=pass CTS sensor run on GPIO-based system Change-Id: I056b72c1210d7525c29a8555f97e6f09d773d12f Signed-off-by: Jett Rink <jettrink@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1560229 Tested-by: Alexandru M Stan <amstan@chromium.org> Reviewed-by: Jack Rosenthal <jrosenth@chromium.org>
* mkbp: non-gpio-based mkbp events, leave interruptsJett Rink2019-03-261-5/+24
| | | | | | | | | | | | | | | | | | | | | | | For non-gpio-based mkbp event delivery, we do not want to temporarily disable interrupts as the code to send the mkbp events may use mutexes or task scheduling to perform the more complicated mkbp event delivery. For simple GPIO-based implementations, pausing interrupts gives the mkbp_last_event_time marker the best chance at matching the actual time the gpio was toggled on the EC. For other implementation, we are already at the mercy of bus delays and timing for delivery so it wasn't as reliable in that case to beginning with. BRANCH=none BUG=b:128862307 TEST=Ran AIDA64 sensor tab for a long time without seeing ISH communication issue. Change-Id: Id6e63a7f7b494559bd38b4659a580fa57666ecf1 Signed-off-by: Jett Rink <jettrink@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1531773 Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com> Reviewed-by: Mathew King <mathewk@chromium.org>
* common: bit change 1 << constants with BIT(constants)Gwendal Grignou2019-03-261-1/+1
| | | | | | | | | | | | | | | | | Mechanical replacement of bit operation where operand is a constant. More bit operation exist, but prone to errors. Reveal a bug in npcx: chip/npcx/system-npcx7.c:114:54: error: conversion from 'long unsigned int' to 'uint8_t' {aka 'volatile unsigned char'} changes value from '16777215' to '255' [-Werror=overflow] BUG=None BRANCH=None TEST=None Change-Id: I006614026143fa180702ac0d1cc2ceb1b3c6eeb0 Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1518660 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
* arcada_ish: Send MKBP events over HECIMathew King2019-03-111-0/+11
| | | | | | | | | | | | | | | | This adds a 4 byte header to the HECI messages so that host commands and MKBP events can share the same HECI client. BUG=b:123634700 TEST=make buildall -j, turning on the FIFO and to enable these events is in the next cl BRANCH=none Change-Id: I3fe8dd4356bceba26ef3bf1fbff7906c5c4bf75e Signed-off-by: Mathew King <mathewk@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1506414 Tested-by: Jett Rink <jettrink@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org>
* mkbp_event,include/config.h: Clarify MKBP delivery method.Yilun Lin2019-03-071-4/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Now we have two MKBP delivery methods: 1. define CONFIG_MKBP_USE_HOST_EVENT to notify via host event 2. undef CONFIG_MKBP_USE_HOST_EVENT to notify via GPIO interrupt It may become more complicated if new notification methods introduced. e.g.: mt_scp uses IPI, rather than host event and GPIO interrupt. This CL does: 1. add CONFIG_MKBP_USE_GPIO to explicilty declare that MKBP event are sent via GPIO interrupt. 2. CONFIG_MKBP_USE_CUSTOM for boards which have custmized methods. 3. Remove weak attribute in mkbp_set_host_active (which can be done with CONFIG_MKBP_USE_CUSTOM now. 4. Removes mkbp_set_host_active function in board Nocturne. It only deliver MKBP events through GPIO interrupt now. BRANCH=None BUG=b:120808999 TEST=grep -rn "CONFIG_MKBP_USE_GPIO\|EC_INT_L" board/ baseboard/ and see the result is reasonable: 1. EC_INT_L must be 1-to-1 mapped to define CONFIG_MKBP_USE_GPIO in every board, except that meep, yorp, ampton which are defined in baseboard octopus. 2. undef CONFIG_MKBP_USE_GPIO in bip and casta, which use host event, but also have baseboard octopus. Change-Id: I4af6110e4fd3c009968075c3623ef2d91cbd770b Signed-off-by: Yilun Lin <yllin@google.com> Reviewed-on: https://chromium-review.googlesource.com/1490794 Commit-Ready: Jett Rink <jettrink@chromium.org> Tested-by: Yilun Lin <yllin@chromium.org> Reviewed-by: Furquan Shaikh <furquan@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org>
* mkbp: Enable the EC to report whether it has more events on mkbp_get_next_eventEnrico Granata2018-11-281-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | On all platforms where there is a GPIO interrupt line between EC and AP for MKBP events, the EC will keep the interrupt pin set as long as there are events to be served, but the AP will need to re-enter its IRQ handler once per event in order to serve all the events in the FIFO. This commit adds a version 2 of EC_CMD_GET_NEXT_EVENT, such that the EC will use the most-significant bit of the event type to record the fact that the EC has more events available. This, in turn, enables the AP to keep its interrupt handler thread awake and loop until all events are served. Since it uses a new command version, this change is forward and backward compatible: - new EC, old kernel: the old kernel will use the V1 command and never see the flag - new kernel, old EC: the old EC will not accept the V2 command and never send the flag BUG=b:119570064 TEST=patched Linux kernel can see and use the flag on nocturne BRANCH=nocturne Change-Id: I5bae7fdc85efcd26f7bdebcd31a7f27ecf570d88 Signed-off-by: Enrico Granata <egranata@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1341159 Commit-Ready: Gwendal Grignou <gwendal@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org>
* mkbp_event: deassert host irq when if the current event cannot be fetchedNicolas Boichat2018-11-071-3/+3
| | | | | | | | | | | | | | | | | | On boot, it is possible to encounter a case where a host event bit is set, but the FIFO is actually empty (e.g. if an event was sent when the AP is sleeping). In this case, we should still deassert interrupt to AP, if there are no other events pending. BRANCH=none BUG=b:117406392 TEST=Boot kukui, no "HC 0x67 err 9" Change-Id: I5c23b3a37c16fce673478f863b6b7660aba59ee9 Signed-off-by: Nicolas Boichat <drinkcat@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1314308 Reviewed-by: Enrico Granata <egranata@chromium.org>
* FIXUP: mkbp: add support for board-specific host notificationEnrico Granata2018-10-041-6/+6
| | | | | | | | | | | | | | This patch improves naming and documentation for the functionality introduced in crrev.com/c/1247000 TEST=build BRANCH=none BUG=b:112366846, b:112112483, b:112111610 Change-Id: Iedd2fc5492a5d35fa9c2475fe248c5aa41e83bb0 Signed-off-by: Enrico Granata <egranata@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1258562 Reviewed-by: Aaron Durbin <adurbin@chromium.org>
* mkbp: add support for board-specific host notificationEnrico Granata2018-10-021-7/+23
| | | | | | | | | | | | | | | | | | | | On Nocturne, we want to be able to decide whether MKBP events should be notified to the AP via host_set_single_event or gpio_set_level based upon runtime board-version detection instead of a static compile-time flag. Add support for this by marking the function that raises the actual IRQ to the host as weak, so that individual boards can override it with their own version. BRANCH=None BUG=b:112366846, b:112112483, b:112111610 TEST=see CL:1161546 for details Signed-off-by: Enrico Granata <egranata@chromium.org> Change-Id: Ide5ec12fbc6fea3cf23069f376066f225e1887b3 Reviewed-on: https://chromium-review.googlesource.com/1247000 Reviewed-by: Alexandru M Stan <amstan@chromium.org> Reviewed-by: Gwendal Grignou <gwendal@chromium.org>
* ec: Make it possible to build tests using clangNicolas Boichat2018-06-281-0/+2
| | | | | | | | | | | | | | | | | | We might want to try out address sanitizer/fuzzer on some host tests: make it possible to build host tests using clang. Board builds are broken, and there is no intention to fix them, at least for now. BRANCH=none BUG=chromium:854924 TEST=make buildall -j TEST=make CC=clang runtests -j Change-Id: Id49a1b8537bc403d53437a2245f4fab6ceae89ac Signed-off-by: Nicolas Boichat <drinkcat@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1107522 Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* Reland "npcx: CEC: Send CEC message in mkbp event"Stefan Adolfsson2018-05-161-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* Revert "npcx: CEC: Send CEC message in mkbp event"stabilize-10682.BIlja H. Friedel2018-05-151-1/+1
| | | | | | | | | | | | | 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-0/+12
| | | | | | | | | | | | | | | | | | | | | 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-1/+1
| | | | | | | | | | | | | | | | | | | | 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>
* power: Allow host to request higher-power wakeable S3Shawn Nematbakhsh2017-07-281-1/+3
| | | | | | | | | | | | | | | | | | | | Allow host to request a higher-power S3 variant, "wakeable S3", in which more wakeup sources will be enabled by the EC. The actual implementation and list of wake sources is left up to the chipset power driver and/or board code. BUG=b:63037490 BRANCH=gru TEST=With subsequent commit, compile on scarlet w/ power sequencing version = 2. Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org> Change-Id: I469f0cd969052f173cb176196bb6d05f6f76fdb5 Reviewed-on: https://chromium-review.googlesource.com/572210 Commit-Ready: Shawn N <shawnn@chromium.org> Tested-by: Shawn N <shawnn@chromium.org> Reviewed-by: Aseda Aboagye <aaboagye@chromium.org> Reviewed-by: Philip Chen <philipchen@chromium.org>
* mkbp_event: Properly queue events during host sleepShawn Nematbakhsh2016-11-041-10/+6
| | | | | | | | | | | | | | | | | | | | | | | | Don't queue non-wake events, and ensure wake events (and all subsequent events) always get queued. BUG=chrome-os-partner:59248, chrome-os-partner:59336 BRANCH=gru TEST=Manual on kevin, go to suspend, press volume keys dozens of times, press 'shift', verify device wakes. Place cursor on URL bar, go to suspend, type "google" quickly, verify device wakes and "google" appears on URL bar. Go to suspend, press 'VolUp' key 5 times, press keyboard, verify device wakes and no volume meter is seen on display. Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org> Change-Id: Ibe761187fbcefd686776a512786550970a6fc067 Reviewed-on: https://chromium-review.googlesource.com/405717 Commit-Queue: Douglas Anderson <dianders@chromium.org> Tested-by: Douglas Anderson <dianders@chromium.org> Reviewed-by: Douglas Anderson <dianders@chromium.org> (cherry picked from commit aa2f01566314604404e104d7975c6c755c22a601) Reviewed-on: https://chromium-review.googlesource.com/407958 Commit-Ready: Douglas Anderson <dianders@chromium.org> Reviewed-by: Stefan Reinauer <reinauer@chromium.org>
* mkbp_event: Don't use memmap'd host event maskShawn Nematbakhsh2016-11-041-3/+1
| | | | | | | | | | | | | | | | | | | | | | | | Previously the memmap'd host event mask copy wasn't always updated. Be consistent with other mkbp code and call host_get_event() to get our current mask. BUG=chrome-os-partner:59241 BRANCH=gru TEST=Manual on kevin, close lid to suspend, press volume keys, verify device doesn't wake. Open lid, verify device wakes. Run 'powerd_dbus_suspend', press volume keys, verify device doesn't wake. Press keyboard key, verify device wakes. Change-Id: I3de49efa1ebc53a9c56bed57007c48356c7e97bb Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/406547 Reviewed-by: Douglas Anderson <dianders@chromium.org> Reviewed-by: Aseda Aboagye <aaboagye@chromium.org> (cherry picked from commit 763d3b2c6f26d41e7147f860e59755af2fe87fe4) Reviewed-on: https://chromium-review.googlesource.com/407957 Commit-Ready: Douglas Anderson <dianders@chromium.org> Tested-by: Douglas Anderson <dianders@chromium.org> Reviewed-by: Stefan Reinauer <reinauer@chromium.org>
* mkbp_event: Provide host event wake mask to hostShawn Nematbakhsh2016-08-191-0/+15
| | | | | | | | | | | | | | | | | | | Use EC_CMD_HOST_EVENT_GET_WAKE_MASK (already implemented on LPC platforms) to share CONFIG_MKBP_WAKEUP_MASK with the host. BUG=chrome-os-partner:56164 BRANCH=None TEST=Run `ectool eventgetwakemask` on kevin, verify CONFIG_MKBP_WAKEUP_MASK mask is printed. Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org> Change-Id: I252c8d6297e3db97dd3df506b3a386a3ad777174 Reviewed-on: https://chromium-review.googlesource.com/372320 Commit-Ready: Douglas Anderson <dianders@chromium.org> Tested-by: Caesar Wang <wxt@rock-chips.com> Tested-by: Shawn N <shawnn@chromium.org> Reviewed-by: Aseda Aboagye <aaboagye@chromium.org> Reviewed-by: Douglas Anderson <dianders@chromium.org>
* mkbp_event: Allow host to report sleep state for non-wake event skippingShawn Nematbakhsh2016-08-121-2/+18
| | | | | | | | | | | | | | | | | | | | | | Allow the host to self-report its sleep state through EC_CMD_HOST_SLEEP_EVENT, which will typically be sent with SUSPEND param when the host begins its sleep process. While the host has self-reported that it is in SUSPEND, don't assert the interrupt line, except for designated wake events. BUG=chrome-os-partner:56156 BRANCH=None TEST=On kevin, run 'ectool hostsleepstate suspend', verify that interrupt assertion is skipped for battery host event. Run 'ectool hostsleepstate resume' and verify interrupt is again asserted by the battery host event. Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org> Change-Id: I74288465587ccf7185cec717f7c1810602361b8c Reviewed-on: https://chromium-review.googlesource.com/368391 Commit-Ready: Shawn N <shawnn@chromium.org> Tested-by: Shawn N <shawnn@chromium.org> Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
* mkbp: Clear host interrupt if no more events.Aseda Aboagye2016-08-021-1/+3
| | | | | | | | | | | | | BUG=chromium:633694 BRANCH=None TEST=Flash kevin; verify that no more console spam is present on the EC. Change-Id: I240fbe330952b82e2a5f97d0be7ebe4b2a8e2b46 Signed-off-by: Aseda Aboagye <aaboagye@google.com> Reviewed-on: https://chromium-review.googlesource.com/365470 Commit-Ready: Aseda Aboagye <aaboagye@chromium.org> Tested-by: Aseda Aboagye <aaboagye@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org>
* mkbp: Add support for buttons and switches.Aseda Aboagye2016-07-191-25/+38
| | | | | | | | | | | | | | | | | | | | | | | | | | Currently, the matrix keyboard protocol does not have support for handling non-matrixed keys. This commit adds support for buttons which do not appear in the keyboard matrix as well as switches. Additionally, the keyboard FIFO is now just a general MKBP events FIFO which MKBP events are free to use. Now, buttons and switches wil join the key matrix event. BUG=chrome-os-partner:54988 BUG=chrome-os-partner:54976 BUG=chromium:626863 BRANCH=None TEST=Flash kevin, and verify that keyboard is still functional. TEST=make -j buildall CQ-DEPEND=CL:358926 Change-Id: If4ada904cbd5d77823a0710d4671484b198c9d91 Signed-off-by: Aseda Aboagye <aaboagye@google.com> Reviewed-on: https://chromium-review.googlesource.com/358633 Commit-Ready: Aseda Aboagye <aaboagye@chromium.org> Tested-by: Aseda Aboagye <aaboagye@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org>
* mkpb: Add MKBP support over ACPIGwendal Grignou2016-06-221-0/+5
| | | | | | | | | | | | | | | | | | | | Add a host event to support MKPB: When sent, the ACPI code will send a notification to the kernel cros-ec-lpcs driver that will issue EC_CMD_GET_NEXT_EVENT. We can allow code (sensor stack for instance) that uses MKBP to work on ACPI based architecture. Obviously, host event over MKPB is not supported. BRANCH=none BUG=b:27849483 TEST=Check we get sensor events on Cyan through the sensor ring. (cyan branch) Change-Id: Iadc9c852b410cf69ef15bcbbb1b086c36687c687 Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/353634 Reviewed-by: Randall Spangler <rspangler@chromium.org>
* mkbp_event: prevent unnecessary interrupts to APKoro Chen2016-03-101-2/+2
| | | | | | | | | | | | | | | | | | | | After commit 237406c5b12ed9934fc6eab7d24f30ba6e70fdce, there is chance that pd_power_supply_reset() will be called during S0->S3, and it interrupts AP and fails suspend if we are using MKBP_EVENT. This is because mkbp_send_event() does not check power state POWER_S0S3. Modify the condition to check events when AP is not in S0. BRANCH=none BUG=chrome-os-partner:50833 TEST=powerd_dbus_suspend always works without being resumed Change-Id: Id905a2cd4d2a0376bca163f40c68bcf4208d8bf5 Signed-off-by: Koro Chen <koro.chen@mediatek.com> Reviewed-on: https://chromium-review.googlesource.com/331160 Commit-Ready: Daniel Kurtz <djkurtz@chromium.org> Tested-by: Milton Chiang <milton.chiang@mediatek.com> Reviewed-by: Wei-Ning Huang <wnhuang@chromium.org> Reviewed-by: Daniel Kurtz <djkurtz@chromium.org>
* keyboard_mkbp: set the key pressed event to wakeup APYH Huang2015-12-071-1/+2
| | | | | | | | | | | | | | | | | | When AP is suspended, only predefined events could wakeup AP. Check EC_MKBP_EVENT_KEY_MATRIX event when we use embedded keyboard to make AP wakeup from S3 power state. BRANCH=none BUG=chrome-os-partner:47554 TEST=Enter "powerd_dbus_suspend" in AP console to make system suspend and then press embedded keyboard to wakeup AP. Change-Id: I79f91776c39554a4e488e50841d3537fe85fea13 Signed-off-by: YH Huang <yh.huang@mediatek.com> Reviewed-on: https://chromium-review.googlesource.com/312156 Tested-by: Wei-Ning Huang <wnhuang@chromium.org> Reviewed-by: Wei-Ning Huang <wnhuang@chromium.org> Reviewed-by: Rong Chang <rongchang@chromium.org>
* mkbp_event: prevent AC power change events to wakeup AP.Ben Lok2015-10-061-0/+18
| | | | | | | | | | | | | | | | | | It may use MKBP event to send PD power change events to AP via interrupt. According to the spec, AC power change events do not be allowed to wake up AP. In order to avoid it, define a white list in board level, only allow those events to wakeup the AP during S3 power state. BRANCH=none BUG=chrome-os-partner:45127 TEST=manual Plug PD power adapter to oak, if system is in S3/S5 and it should starts charging, but should not wake up system/AP at all. Change-Id: I2f86697d5d3bd24d7de840e21064b91e8841f0eb Signed-off-by: Ben Lok <ben.lok@mediatek.com> Reviewed-on: https://chromium-review.googlesource.com/300360 Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* ryu: enable MBKP events for PD eventsVincent Palatin2015-05-281-1/+1
| | | | | | | | | | | | | | | | | | | enable the MKBP event feature to send host event and wire up the PD specific events. Signed-off-by: Vincent Palatin <vpalatin@chromium.org> BRANCH=none BUG=chrome-os-partner:33194 TEST=On Ryu P6, plug/unplug USB devices and add kernel trace to see the PD events happening. Change-Id: I21f47884a869987c917e56ed9b3f914815af51e4 Reviewed-on: https://chromium-review.googlesource.com/273620 Trybot-Ready: Vincent Palatin <vpalatin@chromium.org> Tested-by: Vincent Palatin <vpalatin@chromium.org> Reviewed-by: Alec Berg <alecaberg@chromium.org> Commit-Queue: Vincent Palatin <vpalatin@chromium.org>
* MKBP event signalling implementationVic Yang2014-10-241-0/+95
This implements a new API for EC modules to define MKBP event sources and send MKBP event to the AP. Also, a new host command EC_CMD_GET_NEXT_EVENT is added for the AP to query the pending MKBP events. Each event type may have custom event data sent along with the event. BRANCH=None BUG=chrome-os-partner:33194 TEST=Enable MKBP event on Ryu. Set a host event from EC console, run 'ectool nextevent', and see MKBP event 0x01 (HOST_EVENT) and the set host event. Signed-off-by: Vic Yang <victoryang@chromium.org> Change-Id: I28a1b7e826bcc102bbe39016c9bb3e37d125664c Reviewed-on: https://chromium-review.googlesource.com/224905 Reviewed-by: Randall Spangler <rspangler@chromium.org>