summaryrefslogtreecommitdiff
path: root/common/keyboard_mkbp.c
Commit message (Collapse)AuthorAgeFilesLines
* keyboard_mkbp: report switches result until init'dEric Yilun Lin2020-12-311-2/+18
| | | | | | | | | | | | | | | | | When sysjump, the switch results will be re-evluated, and if the AP is up, this might report the intermediate switch states and misalign the switches states between EC and AP. This CL delay reporting the switches until all the switches are inited. BUG=b:173962511 TEST=AP boot to OS, sysjump, and system stays at S0 BRANCH=none Change-Id: Ifce7654ae8f6eb651cf1f7402c8e9e34f1b713f6 Signed-off-by: Eric Yilun Lin <yllin@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2607206 Reviewed-by: Ting Shen <phoenixshen@chromium.org>
* keyboard_mkbp: Add a virtual switch EC_MKBP_FRONT_PROXIMITYWai-Hong Tam2020-11-181-0/+3
| | | | | | | | | | | | | | | 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>
* tree: Use new atomic_* implementationDawid Niedzwiecki2020-10-271-2/+2
| | | | | | | | | | | | | | | | | | | | | | | It is done as a part of porting to Zephyr. Since the implementation of atomic functions is done for all architectures use atomic_* instead of deprecated_atomic_*. Sometimes there was a compilation error "discards 'volatile' qualifier" due to dropping "volatile" in the argument of the functions, thus some pointers casts need to be made. It shouldn't cause any issues, because we are sure about generated asm (store operation will be performed). BUG=b:169151160 BRANCH=none TEST=buildall Signed-off-by: Dawid Niedzwiecki <dn@semihalf.com> Change-Id: I98f590c323c3af52035e62825e8acfa358e0805a Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2478949 Tested-by: Jett Rink <jettrink@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org> Reviewed-by: Tom Hughes <tomhughes@chromium.org>
* tree: rename atomic_* functions to deprecated_atomic_*Jack Rosenthal2020-09-291-2/+2
| | | | | | | | | | | | | | | | We will move to an API compatible with Zephyr's API. See the bug for complete rationale and plan. BUG=b:169151160 BRANCH=none TEST=buildall Signed-off-by: Jack Rosenthal <jrosenth@chromium.org> Change-Id: Id611f663446abf00b24298a669f2ae47fef7f632 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2427507 Tested-by: Dawid Niedźwiecki <dn@semihalf.com> Reviewed-by: Tom Hughes <tomhughes@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org>
* ec: change usage of "sane" per inclusive languagePaul Fagerburg2020-07-221-1/+1
| | | | | | | | | | | | | | | | Google is working to change its source code to use more inclusive language. To that end, replace the terms "sane", "sanity check", and similar with inclusive/non-stigmatizing alternatives. BUG=b:161832469 BRANCH=None TEST=`make buildall -j` succeeds. `grep -Eir "sane|sanity" .` shows results only in third-party code or documentation. Signed-off-by: Paul Fagerburg <pfagerburg@chromium.org> Change-Id: I29e78ab27f84f17b1ded75cfa10868fa4e5ae88c Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2311169 Reviewed-by: Jett Rink <jettrink@chromium.org>
* mkbp: keyboard_clear_buffer should only drop keyboard eventsTing Shen2020-03-131-1/+30
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Two hooks in HOOK_LID_CHANGE has race condition: 1) keyboard_lid_change() wakes up KEYSCAN task and calls keyboard_clear_buffer() to clear the MKBP fifo 2) mkbp_lid_change() pushes EC_MKBP_LID_OPEN event into the same fifo. mkbp_lid_change has lowest priority, so usually the flow looks like keyboard_lid_change() keyboard_clear_buffer() mkbp_lid_change() EC_MKBP_LID_OPEN event inserted after buffer clear, everything good. But in Juniper, we found that sometimes the flow becomes keyboard_lid_change() mkbp_lid_change() keyboard_clear_buffer() And cause the EC_MKBP_LID_OPEN dropped before sending to host. To fix this, change the behavior of keyboard_clear_buffer() to keep all non-keyboard events inside the queue. So EC_MKBP_LID_OPEN will never be removed regardless of how task is scheduled. BUG=b:149880594 TEST=1) On Jacuzzi, host able to receive lid switch event 2) Set the priority mkbp_lid_change to 1(highest) and verify 1) still works BRANCH=kukui Signed-off-by: Ting Shen <phoenixshen@google.com> Change-Id: I55d7c6c45ecb6505134e430689887ce98ea0c29b Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2098018 Reviewed-by: Eric Yilun Lin <yllin@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org> Tested-by: Ting Shen <phoenixshen@chromium.org> Commit-Queue: Ting Shen <phoenixshen@chromium.org>
* host_command: Change host command return value to enum ec_statusTom Hughes2019-10-021-3/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* 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>
* common: bit change 1 << constants with BIT(constants)Gwendal Grignou2019-03-261-16/+16
| | | | | | | | | | | | | | | | | 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>
* Keyboard: Allow keyboard size to be set at run timeDaisuke Nojiri2018-10-191-6/+7
| | | | | | | | | | | | | | | | | | | | | | | Currently, the keyboard size (i.e. number of columns) is static. This patch allows it to be configured at run time. It's required to support a keyboard with/without keypad in a single image. KEYBOARD_COLS_MAX has the build time col size. It's used to allocate exact spaces for arrays. Actual keyboard scanning is done using keyboard_cols, which holds a runtime col size. Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> BUG=b:117126568 BRANCH=none TEST=Verify keyboard functionality on Sona and Veyron. Change-Id: I4b3552be0b4b315c3fe5a6884cf25e10aba8be7c Reviewed-on: https://chromium-review.googlesource.com/1285292 Commit-Ready: Daisuke Nojiri <dnojiri@chromium.org> Tested-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org>
* common: add API to expose detachable "base" stateDmitry Torokhov2018-08-221-0/+14
| | | | | | | | | | | | | | | | | | 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>
* host_events: Bump up host events and masks to 64-bitFurquan Shaikh2017-11-211-1/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* buttons: Make buttons[] common.Aseda Aboagye2017-11-171-10/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | Nearly every board had a buttons array defined in which its contents had the standard volume buttons. This commit creates a single common buttons array that can contain the standard volume buttons and recovery buttons. If a board has volume up and down buttons, they can simply define CONFIG_VOLUME_BUTTONS and it will populate the buttons array with the standard definition. The buttons are active low and have a 30 ms debounce period. Similiarly, if a board has a dedicated recovery button, defining CONFIG_DEDICATED_RECOVERY_BUTTON will also populate the buttons array with a recovery button. BUG=chromium:783371 BRANCH=None TEST=make -j buildall. TEST=Flash a device with CONFIG_VOLUME_BUTTONS, verify pressing volume buttons still work. Change-Id: Ie5d63670ca4c6b146ec8ffb64d40ea9ce437b913 Signed-off-by: Aseda Aboagye <aaboagye@google.com> Reviewed-on: https://chromium-review.googlesource.com/773794 Commit-Ready: Aseda Aboagye <aaboagye@chromium.org> Tested-by: Aseda Aboagye <aaboagye@chromium.org> Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-by: Shawn N <shawnn@chromium.org>
* keyboard_mkbp: Fix FIFO lockingShawn Nematbakhsh2017-11-101-7/+33
| | | | | | | | | | | | | | | | | | keyboard_clear_buffer() should not trash FIFO contents without synchronization from fifo_add() / fifo_remove(), otherwise a bad FIFO state may ensue. BUG=chromium:781554 BRANCH=gru TEST=Verify KB is functional on kevin through suspend / resume, verify keyboard functions as S3 wake. Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org> Change-Id: I5d28c72359f6e1ce8778725a15c51cdfcd8ab90b Reviewed-on: https://chromium-review.googlesource.com/761300 Commit-Ready: Shawn N <shawnn@chromium.org> Tested-by: Shawn N <shawnn@chromium.org> Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
* MKBP: Add kbpress for boards w/o keyscan tasks.Aseda Aboagye2017-07-281-0/+64
| | | | | | | | | | | | | | | | For FAFT testing with devices without a matrix keyboard but with an EC, add support for the 'kbpress' command. BUG=None BRANCH=None TEST=Flash fizz EC; verify kbpress works okay. Change-Id: I202b52a97f3a7e781981b4f58adde4c0a7b60abd Signed-off-by: Aseda Aboagye <aaboagye@google.com> Reviewed-on: https://chromium-review.googlesource.com/585828 Commit-Ready: Aseda Aboagye <aaboagye@chromium.org> Tested-by: Shelley Chen <shchen@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org>
* button: Add recovery button to mkbp button stateFurquan Shaikh2017-07-211-0/+5
| | | | | | | | | | | | | | Pass in recovery button press/release information to AP using MKBP button driver. BUG=b:63893483 BRANCH=None TEST=Behavior verified by Shelley. Change-Id: I7a6e50ec8595d99327b5fc8e822bf762e0ce13e0 Signed-off-by: Furquan Shaikh <furquan@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/580539 Reviewed-by: Aaron Durbin <adurbin@chromium.org>
* keyboard: Clear typematic when disabling keyboardDaisuke Nojiri2017-05-031-0/+3
| | | | | | | | | | | | | | | | This patch clears the typematic buffer when disabling keyboard scan. When the device goes to tablet mode with a key being pressed, this should prevent keyboard_protocol_task from sending scan codes to the host. BUG=b:35585725 BRANCH=none TEST=make buildall. Tested on Electro. Change-Id: I73e9d2948b472458814967307412aebeb410ff2e Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/425075 Reviewed-by: Aaron Durbin <adurbin@chromium.org>
* system: Fixups in emulated sysrq codeNicolas Boichat2017-04-061-1/+1
| | | | | | | | | | | | | | | | Follow-up to CL:456520, addressing a few more comments. BRANCH=none BUG=b:35775099 TEST=sysrq available in EC console TEST=sysrq h => help message in AP console TEST=sysrq b => AP reboots Change-Id: I692afa7c911882f00d92b8e6d83889c52821e171 Reviewed-on: https://chromium-review.googlesource.com/468506 Commit-Ready: Nicolas Boichat <drinkcat@chromium.org> Tested-by: Nicolas Boichat <drinkcat@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org>
* system: Add support for emulated sysrqNicolas Boichat2017-03-311-0/+18
| | | | | | | | | | | | | | | | | | | | On keyboard-less design, we will implement a special debug mode, based on button sequences, to transmit sysrq events to the AP. This implements the new MKBP event to send sysrq, and a console command to test it. Later CL will implement debug mode itself. BRANCH=none BUG=b:35775099 TEST=sysrq available in EC console TEST=sysrq h => help message in AP console TEST=sysrq b => AP reboots Change-Id: I71d3f77497baf8cc7fac65cd040ce20513b507bc Reviewed-on: https://chromium-review.googlesource.com/456520 Commit-Ready: Nicolas Boichat <drinkcat@chromium.org> Tested-by: Nicolas Boichat <drinkcat@chromium.org> Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
* mkbp: Support devices having buttons but no keyboardPhilip Chen2017-02-211-1/+4
| | | | | | | | | | | | | | | | | | | If we turn on CONFIG_KEYBOARD_PROTOCOL_MKBP on devices without keyscan task, we'll see a few compile errors due to dependencies on keyscan. This is the fix. BUG=chrome-os-partner:62987 BRANCH=none TEST=make buildall -j Change-Id: Ib0dd1570f0e1a2de084cf1c5f75b8e3ad1cb301a Reviewed-on: https://chromium-review.googlesource.com/443745 Reviewed-by: Shawn N <shawnn@chromium.org> Commit-Queue: Philip Chen <philipchen@chromium.org> Tested-by: Philip Chen <philipchen@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/444946 Commit-Ready: Philip Chen <philipchen@chromium.org>
* console: Add non-verbose print config optionShawn Nematbakhsh2017-02-111-1/+1
| | | | | | | | | | | | | | | | | Shorten certain long prints and reduce the precision of timestamp prints when CONFIG_CONSOLE_VERBOSE is undef'd. BUG=chromium:688743 BRANCH=gru TEST=On kevin, cold reset the EC, boot to OS, and verify cros_ec.log contains all data since sysjump and is < 2K bytes (~1500 bytes). Change-Id: Ia9390867788d0ab3087f827b0296107b4e9d4bca Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/438932 Commit-Ready: Shawn N <shawnn@chromium.org> Tested-by: Shawn N <shawnn@chromium.org> Reviewed-by: Shawn N <shawnn@chromium.org>
* common: Add tablet_mode APIGwendal Grignou2016-11-081-3/+2
| | | | | | | | | | | | | | | | | | | Simple API to set/get the tablet mode. It can be set via lid angle calculation or if a board has a dedicated HAL sensor/GPIO. Merged from glados branch, add MKBP switch support. BUG=chromium:606718 BRANCH=gru TEST=Check with Cave that both mode works. Reviewed-on: https://chromium-review.googlesource.com/402089 Reviewed-by: Shawn N <shawnn@chromium.org> (cherry picked from commit c940f36ceabcf2425284001298f03ebdb4c3079e) Change-Id: I2ee5130f3e0a1307ec3ea543f7a32d66bc32b31d Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/404915 Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
* mkbp_event: Properly queue events during host sleepShawn Nematbakhsh2016-11-041-9/+11
| | | | | | | | | | | | | | | | | | | | | | | | 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: Send event when in tablet modeGwendal Grignou2016-09-091-3/+19
| | | | | | | | | | | | | | When tablet mode is detected, send an event to the AP. BUG=chromium:606718 BRANCH=none TEST=Check with evtest that events are sent when the tablet goes in tablet mode and back to device mode. Change-Id: I49f2404b5ecf87e71fa5aef4c8ce9c9beda26a15 Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/380414 Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
* mkbp: Extend EC_CMD_MKBP_GET_INFO.Aseda Aboagye2016-07-191-9/+98
| | | | | | | | | | | | | | | | | | | | - Added ability to query the buttons and switches. - Added ability to report the available buttons or switches. BUG=chromium:626863 BRANCH=None TEST=make -j buildall CQ-DEPEND=CL:358633 CQ-DEPEND=CL:358634 CQ-DEPEND=CL:358989 Change-Id: Ie821491269e8d09578eba92127895c0b6b8e91a9 Signed-off-by: Aseda Aboagye <aaboagye@google.com> Reviewed-on: https://chromium-review.googlesource.com/358926 Commit-Ready: Aseda Aboagye <aaboagye@chromium.org> Tested-by: Aseda Aboagye <aaboagye@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org>
* mkbp: Add keyboard_update_button().Aseda Aboagye2016-07-191-0/+44
| | | | | | | | | | | | | | | | | | | | | | MKBP can now support buttons, so this commit adds the keyboard_update_button() function which will be used to handle the non-matrixed buttons. BUG=chrome-os-partner:54976 BUG=chromium:626863 BRANCH=None TEST=Flash kevin, press volume and power buttons and verify that keyboard is still functional. TEST=make -j buildall CQ-DEPEND=CL:358633 Change-Id: I1c2d36d2113715cf6bd8c6fa7b26fe9253f6ac9f Signed-off-by: Aseda Aboagye <aaboagye@google.com> Reviewed-on: https://chromium-review.googlesource.com/358634 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-79/+150
| | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* oak: enable MBKP events for PD eventsBen Lok2015-08-311-1/+1
| | | | | | | | | | | | | | | | | | | (refer to CL:273620) enable the MKBP event feature to send host event and wire up the PD specific events. But, CONFIG_MKBP_EVENT conflicts with CONFIG_KEYBOARD_PROTOCOL_MKBP, due to the GPIO name of EC interrupt pin. Align the GPIO naming of EC interrupt pin to EC_INT_L. BRANCH=none BUG=chrome-os-partner:44643 TEST=On Oak rev3, plug/unplug USB devices and add kernel trace to see the PD events happening. Change-Id: I10de9c6611583bb6165bdc1848e542d4b8bba954 Signed-off-by: Ben Lok <ben.lok@mediatek.com> Reviewed-on: https://chromium-review.googlesource.com/296012 Reviewed-by: Vincent Palatin <vpalatin@chromium.org> Reviewed-by: Rong Chang <rongchang@chromium.org>
* keyboard_mkbp: fix interrupt handling with MKBP_EVENTVincent Palatin2015-05-301-1/+8
| | | | | | | | | | | | | | | | | | | | | | | | | When CONFIG_MKBP_EVENT is enabled, the current code is incorrect because we have a race condition when sending a new event (we force first the interrupt, then send the actual event content to the mkbp event framework which forces again the interrupt level). If the software still called EC_CMD_MKBP_STATE while CONFIG_MKBP_EVENT is enabled, this will kill the interrupt as soon as the FIFO is empty even though other events are pending in order to be backward compatible with firmware using the interrupt has a hint when polling the keyboard. Signed-off-by: Vincent Palatin <vpalatin@chromium.org> BRANCH=none BUG=chrome-os-partner:33194 TEST=make buildall fiddle with keyboard on Oak. Change-Id: Iafaf4174124934328c4a0172adeca651e5551f28 Reviewed-on: https://chromium-review.googlesource.com/274070 Reviewed-by: Randall Spangler <rspangler@chromium.org> Commit-Queue: Vincent Palatin <vpalatin@chromium.org> Trybot-Ready: Vincent Palatin <vpalatin@chromium.org> Tested-by: Vincent Palatin <vpalatin@chromium.org>
* MKBP event signalling implementationVic Yang2014-10-241-1/+23
| | | | | | | | | | | | | | | | | | | 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>
* Add cprints() and ccprints()Vic Yang2014-05-211-3/+3
| | | | | | | | | | | | | | | | | | | | | Our code base contains a lot of debug messages in this pattern: CPRINTF("[%T xxx]\n") or ccprintf("[%T xxx]\n") The strings are taking up spaces in the EC binaries, so let's refactor this by adding cprints() and ccprints(). cprints() is just like cprintf(), except that it adds the brackets and the timestamp. ccprints() is equivalent to cprints(CC_CONSOLE, ...) This saves us hundreds of bytes in EC binaries. BUG=chromium:374575 TEST=Build and check flash size BRANCH=None Change-Id: Ifafe8dc1b80e698b28ed42b70518c7917b49ee51 Signed-off-by: Vic Yang <victoryang@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/200490 Reviewed-by: Randall Spangler <rspangler@chromium.org>
* cleanup: add square brackets to make test parser easierLouis Yung-Chieh Lo2014-05-071-1/+1
| | | | | | | | | | | | | | | | This may not contain all. I filtered out possible code by the following command: find . -name "*.h*" -o -name "*.c*" | xargs grep -n CPRINTF | \ grep -v "\[" | grep -v define | less BUG=none BRANCH=none TEST=make buildall tuntests Change-Id: I674f84f5966b34aeb8d4321d22629b450627a120 Signed-off-by: Louis Yung-Chieh Lo <yjlou@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/197997
* cleanup: mkbp keyboard moduleRandall Spangler2013-10-301-10/+0
| | | | | | | | | | | | | | | | | | | Rather than compile it by default for host-based tests, only compile it for the few tests that actually use it. Since those (and all boards) now only use if if they also have a keyscan task, we can get rid of the #ifdefs in keyboard_mkbp.c as well. And remove a TODO we'll never do... BUG=chrome-os-partner:18343 BRANCH=none TEST=build all boards; pass unit tests. These pass: util/make_all.sh make BOARD=pit tests Change-Id: I44d1806cfb375027a7ed0b33a5e9bdbbed8ccddc Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/174513
* cleanup: FIFO comment in MKBP driverRandall Spangler2013-10-221-1/+9
| | | | | | | | | | | | | | | A 16-element FIFO consumes 208 bytes of RAM, which isn't too horrible. No code changes, just expanding on a comment. BUG=none BRANCH=none TEST=build spring Change-Id: Ibb51970b6fc72623435d21bd0b368c3e60da24da Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/173922 Reviewed-by: Vic Yang <victoryang@chromium.org>
* Replace generated CONFIG_TASK_ macros with HAS_TASK_Bill Richardson2013-04-241-3/+3
| | | | | | | | | | | | | | | CONFIG_ macros should be set directly. Expanding the task names in the same way made it difficult to tell what was a configuration choice and what was due to changes in ec.tasklist BUG=chrome-os-partner:18343 TEST=build all, run link BRANCH=none Change-Id: Ib82e34f974238ee2dd216f33b701b6f4c6a4f1f1 Signed-off-by: Bill Richardson <wfrichar@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/49098 Reviewed-by: Randall Spangler <rspangler@chromium.org>
* Fix kb_deghost testVic Yang2013-04-111-1/+1
| | | | | | | | | | BUG=chrome-os-partner:18598 TEST=Run test on Spring BRANCH=none Change-Id: Ia95ba6144dbdac0ffe77f6aef9c4ed948de181d8 Signed-off-by: Vic Yang <victoryang@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/47841
* Decouple keyboard MKBP code from key scan codeVic Yang2013-04-081-36/+58
| | | | | | | | | | | | | | | When unit testing, we may need to disable key scan task but leave keyboard protocol code for testing. Also fix a bug in determining if ENABLE flag is set. BUG=chrome-os-partner:18598 TEST=Remove KEYSCAN task and build for spring. BRANCH=none Change-Id: I3b3adf1257e8446fd1f57bce50b4c7a029b1ce3b Signed-off-by: Vic Yang <victoryang@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/47539
* Inhibit host interrupt for battery_key.Todd Broch2013-04-041-2/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Battery key is used to signal to the host that USB charging status has changed. This virtual keystroke should not wake the device like physical keystroke does. Change still copies keystroke to the keyboard fifo but bypasses sending host interrupt. Signed-off-by: Todd Broch <tbroch@chromium.org> BRANCH=spring BUG=chrome-os-partner:18333 TEST=manual, Scenario1: suspend device then plug/unplug USB charging. Device doesn't wake. When resume 'cat /sys/class/power_supply/cros_ec-charger/online' is correct. Scenario2: while true ; do cat /sys/class/power_supply/cros_ec-charger/online done plug/unplug USB charging and device online status changes in a timely manner Change-Id: I8938798b30e70c0c5021405d4fc5da9ce398c311 Reviewed-on: https://gerrit.chromium.org/gerrit/47251 Reviewed-by: Vincent Palatin <vpalatin@chromium.org> Tested-by: Todd Broch <tbroch@chromium.org> Commit-Queue: Todd Broch <tbroch@chromium.org>
* Merge lm4 and stm32 implementations of keyboard_scanRandall Spangler2013-03-291-459/+104
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Scanning is now performed identically on all platforms. keyboard_scan talks to chip-specific keyboard_raw on the bottom end, and 8042 or mkbp keyboard protocol on the top end. 8042 can now take advantage of CONFIG_KEYBOARD_TEST to simulate scan results. BUG=chrome-os-partner:18360 BRANCH=none TEST=compile all boards; test keyboard on spring and link 1) Type on keyboard. Should produce keystrokes. 2) At EC console: kbpress 3 7 1 kbpress 3 7 0 Should produce 'r' keystroke(s); key repeat should kick in if you wait a while between the commands. 3) Hold power button while typing. Should not produce keystrokes. 4) Reboot with power+refresh+esc. Should go to recovery mode. 5) While the system is up, alt+volup+R should reboot the AP. Change-Id: I48e0bca15b869162672b5f54ffcb561f6fcf0f45 Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/46666 Reviewed-by: Bill Richardson <wfrichar@chromium.org>
* Move files in preparation for merging keyboard_scan modulesRandall Spangler2013-03-271-0/+656
This is part one of a series to merge the keyboard scan interface to be common across all platforms. This change just moves and renames files and APIs and removes some read code, and sets up protocol-specific CONFIG options. It makes the next CL which actually merges keyboard scanning easier to parse. BUG=chrome-os-partner:18360 BRANCH=none TEST=compile all boards; test keyboard on spring and link Change-Id: I815a40aae4e5d5f333b8501aff9656080533d913 Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/46549 Reviewed-by: Bill Richardson <wfrichar@chromium.org>