summaryrefslogtreecommitdiff
path: root/common/button.c
Commit message (Collapse)AuthorAgeFilesLines
* reset: Log the reason for AP resets.Jonathan Brandmeyer2018-07-261-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Provides a new EC host command 'uptime info' which gathers up some information which may be useful for debugging spurious resets on the AP (was the EC reset recently? Why was the EC reset? If the EC reset the AP, why did it do so?, etc.). Provide ectool support for the same. Example results of `ectool uptimeinfo`: ``` localhost ~ # ectool uptimeinfo EC uptime: 475.368 seconds AP resets since EC boot: 2 Most recent AP reset causes: 315.903: reset: console command 363.507: reset: keyboard warm reboot EC reset flags at last EC boot: reset-pin | sysjump ``` BRANCH=none TEST=Perform some `apreset` commands from the EC console and observe their side-effects via the `ectool uptimeinfo` command on the AP side. Test sequences include no-resets through 5 resets, observing that the ring buffer handling was correct. BUG=b:110788201, b:79529789 Signed-off-by: Jonathan Brandmeyer <jbrandmeyer@chromium.org> Change-Id: I0bf29d69de471c64f905ee8aa070b15b4f34f2ba Reviewed-on: https://chromium-review.googlesource.com/1139028 Commit-Ready: Jonathan Brandmeyer <jbrandmeyer@chromium.org> Tested-by: Jonathan Brandmeyer <jbrandmeyer@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org>
* Code cleanup: Remove cold reset logicVijay Hiremath2018-04-031-2/+2
| | | | | | | | | | | | | | | | | | | | | Majority of the chipsets do not have a dedicated GPIO to trigger AP cold reset. Current code either ignores cold reset or does a warm reset instead or have a work around to put AP in S5 and then bring back to S0. In order to avoid the confusion, removed the cold reset logic and only apreset is used hence forth. BUG=b:72426192 BRANCH=none TEST=make buildall -j Manually tested on GLKRVP, apreset EC command can reset AP. Change-Id: Ie32d34f2f327ff1b61b32a4d874250dce024cf35 Signed-off-by: Vijay Hiremath <vijay.p.hiremath@intel.com> Reviewed-on: https://chromium-review.googlesource.com/991052 Commit-Ready: Vijay P Hiremath <vijay.p.hiremath@intel.com> Tested-by: Vijay P Hiremath <vijay.p.hiremath@intel.com> Reviewed-by: Aaron Durbin <adurbin@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org>
* config: Add CONFIG_BUTTON_TRIGGERED_RECOVERY.Aseda Aboagye2017-12-181-6/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | | The CONFIG_BUTTON_RECOVERY option was a little confusing especially when we have the CONFIG_DEDICATED_RECOVERY_BUTTON option. This commit renames CONFIG_BUTTON_RECOVERY to CONFIG_BUTTON_TRIGGERED_RECOVERY to help make things a little clearer. Additionally, to avoid copy paste, defining CONFIG_BUTTON_TRIGGERED_RECOVERY will populate the recovery_buttons table with either the volume buttons or a dedicated recovery button depending what the board is configured for. Lastly, if CONFIG_DEDICATED_RECOVERY_BUTTON is defined, CONFIG_BUTTON_TRIGGERED_RECOVERY is defined as well since it's implicit. BUG=chromium:783371 BRANCH=None TEST=make -j buildall Change-Id: Idccaa4d049ace0df3b98b35bdd38ac9dbd843200 Signed-off-by: Aseda Aboagye <aaboagye@google.com> Reviewed-on: https://chromium-review.googlesource.com/830917 Commit-Ready: Aseda Aboagye <aaboagye@chromium.org> Tested-by: Aseda Aboagye <aaboagye@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org> Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
* detachables: Updating button command to support multiple buttonsShelley Chen2017-11-291-30/+67
| | | | | | | | | | | | | | | | | | | | Exitting the recovery insert screen requires pushing the volume up and volume down keys simultaneously. Modifying the button command to support multiple buttons. BUG=b:69390675 BRANCH=None TEST=button vup vdown 5000 button vdown vup 5000 button vup vdowne button vdown vup Make sure that the above command press and release both volume keys. Make sure that there is a delay added into between presses/releases. Change-Id: I65817ff6c9da8c422af3345b2d0878b52387b13e Signed-off-by: Shelley Chen <shchen@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/783515 Reviewed-by: Furquan Shaikh <furquan@chromium.org>
* buttons: Make buttons[] common.Aseda Aboagye2017-11-171-6/+37
| | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* common/button: Ensure debug mode exits on timeoutFurquan Shaikh2017-08-071-7/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In all states other than STATE_NONE, ensure that there is a deferred call set after DEBUG_TIMEOUT so that debug mode exits if there is no user activity. BUG=b:64436180 BRANCH=None TEST=make -j buildall. Also, verified following: 1. All combos still work fine 2. No user input for 10 seconds after entering debug mode: ++[42.318691 DEBUG MODE: Active!] ++[53.288057 DEBUG MODE: Exit!] 3. No user input for 10 seconds on sysrq path: ++[95.675863 DEBUG MODE: Active!] +[97.200743 Button 'Volume Down' was pressed] [97.526162 Button 'Volume Down' was released] [107.528069 DEBUG MODE: Exit!] 4. No user input for 10 seconds on warm reset path: +[149.374805 DEBUG MODE: Active!] [150.863902 Button 'Volume Up' was pressed] [151.193353 Button 'Volume Up' was released] [161.199244 DEBUG MODE: Exit!] 5. Volup+Voldn still held down 10 seconds after entering debug mode: +[213.704770 DEBUG MODE: Active!] [223.705368 DEBUG MODE: Exit!] Change-Id: I8a0aa448d31b4a746c7af2519ac6f61838bc9b99 Signed-off-by: Furquan Shaikh <furquan@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/603991 Reviewed-by: Aaron Durbin <adurbin@chromium.org>
* Fizz: Boot automatically on recovery requestDaisuke Nojiri2017-07-141-0/+1
| | | | | | | | | | | | | | | | | | | | This patch clears RESET_FLAG_AP_OFF on recovery boot so that the system boots immediately regardless of the previous power state. BUG=b:63669512 BRANCH=none TEST=Verify the followings on reworked Fizz: 1. Press RB and PB in S0: FAIL(*1)/PASS 2. Press RB and PB in S5: FAIL(*1)/PASS 3. Unplug AC in S0 then press RB and plug in AC: PASS/PASS 4. Unplug AC in S5 then press RB and plug in AC: PASS/PASS (*1: b:63668669) Change-Id: If300fc9ec28ff0f7833e84a02e174e501b6a5016 Reviewed-on: https://chromium-review.googlesource.com/570948 Commit-Ready: Daisuke Nojiri <dnojiri@chromium.org> Tested-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-by: Aaron Durbin <adurbin@chromium.org>
* button: Switch on recovery LED after entering recovery modeFurquan Shaikh2017-06-281-0/+17
| | | | | | | | | | | | | | | | | | | | Recovery mode can be triggered with or without hw reinit. And both the modes are triggered using the same button combination held down for different amount of time. For recovery mode with hw reinit (>30 seconds), LED blinks for 4 seconds. However, for recovery mode without hw reinit(>10 seconds), there is no user indication. This change turns on the LED as soon as the >10 second condition is satisfied. This provides an indication to the user that recovery mode is triggered. BUG=b:62886608 BRANCH=None TEST=make -j buildall Change-Id: I949c3e7e98441131df987b6351c1f614f3b4831c Signed-off-by: Furquan Shaikh <furquan@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/549775 Tested-by: Nicolas Boichat <drinkcat@chromium.org> Reviewed-by: Nicolas Boichat <drinkcat@chromium.org>
* system: Add simplified sysrqDaisuke Nojiri2017-06-231-0/+41
| | | | | | | | | | | | | | | | | | | | On a keyboard-less, volume-button-less board, we support simplified sysrq handling. For Fizz, we use the recovery button to trigger sysrq event and holding it down to trigger warm reset. BUG=b:38418116,b:38417391 BRANCH=none TEST=On Fizz, try 1. Press recovery button and release -> sysrq sent 2. Press and hold recovery button -> warm reset 3. Press recovery button and power button -> enter recovery mode Change-Id: If8760319dba3df4545e9805b396ac89c241dae80 Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/537817 Reviewed-by: Aaron Durbin <adurbin@chromium.org>
* button: Implement emulated debug mode using buttons for detachablesFurquan Shaikh2017-06-151-0/+306
| | | | | | | | | | | | | | | | | | | | | | | | | BUG=b:36394093 BRANCH=None TEST=make -j buildall. Verified following actions: Vup+Vdn (10 seconds) --> Vdn --> Vup : Warm reset AP Vup+Vdn (10 seconds) --> Vdn -> Power: Exit debug state Vup+Vdn (10 seconds) --> Vup --> Vdn : Restart chrome Vup+Vdn (10 seconds) --> Vup --> Power : Exit debug state Vup+Vdn (10 seconds) --> Vup --> Vup --> Vdn : No action defined Vup+Vdn (10 seconds) --> Vup --> Vup --> Power: Exit debug state Vup+Vdn (10 seconds) --> Vup --> Vup --> Vup --> Vdn : Kernel panic Vup+Vdn (10 seconds) --> Vup --> Vup --> Vup --> Power: Exit debug state Vup+Vdn (10 seconds) --> Vup --> Vup --> Vup --> Vup: Exit debug state Vup+Vdn (10 seconds) --> Vdn --> Vdn : Exit debug state Change-Id: Ic49cc7463f6d8a00f3b4586754feeb3a7d23c371 Signed-off-by: Furquan Shaikh <furquan@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/520564 Reviewed-by: Nicolas Boichat <drinkcat@chromium.org>
* button: Recovery on power-on resetDaisuke Nojiri2017-05-121-4/+14
| | | | | | | | | | | | | | | | | | When cr50 detects recovery button (not keyboard) combo: recovery+power, volume-up+down+power, etc., it should (ideally) hard-reset the EC. This patch allows power-on reset in addition to reset-pin reset to enter recovery mode when recovery button combo is pressed. BUG=b:35585326 BRANCH=none TEST=make buildall. Tested on Poppy. Change-Id: I15aeef99d21ddc774441ead56fba56d459595cc9 Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/503573 Reviewed-by: Randall Spangler <rspangler@chromium.org>
* button: Allow board to define recovery buttonsDaisuke Nojiri2017-05-091-4/+15
| | | | | | | | | | | | | | This patch declares recovery_buttons array, where each board lists recovery buttons. Pressing those while the board reboots makes the system enter recovery mode. BUG=none BRANCH=none TEST=buildall Change-Id: I1f204156efbd6d2a507d67ba90f75ce857b03559 Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/486944
* common/button: Blink LED for 3 seconds when setting recovery HW_REINITstabilize-9517.BFurquan Shaikh2017-05-021-0/+29
| | | | | | | | | | | | | | | If user holds down volume up, volume down and power button for 30 seconds, set HW_REINIT event and blink LED for 3 seconds to indicate to user that the request was accepted. BUG=b:37682514 BRANCH=None TEST=make -j buildall Change-Id: I6b70d56f50d0a1cfae3fa7f337a34ac487943775 Signed-off-by: Furquan Shaikh <furquan@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/487281 Reviewed-by: Aaron Durbin <adurbin@chromium.org>
* common/button: Add support for HW_REINIT button comboFurquan Shaikh2017-05-021-0/+37
| | | | | | | | | | | | | | | | | | | | | | | If volume up + volume down + power buttons are held down for 30 seconds, then indicate to AP that HW_REINIT is requested by the user. Since recovery mode is triggered by holding down the three buttons for 10 seconds, button_check_hw_reinit_required checks for 20 more seconds only. BUG=b:37682514 BRANCH=None TEST=Verified that: 1. If volume up, volume down and power are held for 30 seconds, AP sees the hw reinit request. 2. If either of the buttons is released before 30 seconds, AP does not see the hw reinit request. Change-Id: I3a53966dcdcb84d73f160578411b6c0f62225b95 Signed-off-by: Furquan Shaikh <furquan@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/487002 Reviewed-by: Aaron Durbin <adurbin@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org> Reviewed-by: Nicolas Boichat <drinkcat@chromium.org>
* 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>
* button: Check volume up/down status and set recovery modeNicolas Boichat2017-01-201-2/+12
| | | | | | | | | | | | | | Add support for entering recovery mode using volume up/down keys. BRANCH=none BUG=chrome-os-partner:61930 TEST=Press Power+Volume Up+Volume Down, poppy enters recovery Change-Id: Id40a144e9b430cfb9dfd47048e9e96d598bc3db8 Reviewed-on: https://chromium-review.googlesource.com/428530 Commit-Ready: Nicolas Boichat <drinkcat@chromium.org> Tested-by: Nicolas Boichat <drinkcat@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org>
* button: Add console command to simulate button pressVijay Hiremath2016-09-021-1/+85
| | | | | | | | | | | | | | | BUG=chrome-os-partner:56878 BRANCH=none TEST=Using console command 'button' verified that volume button icon slides on reef. Change-Id: I8051194fd91f989f8887cebce6ea2af1b8c9f731 Signed-off-by: Vijay Hiremath <vijay.p.hiremath@intel.com> Reviewed-on: https://chromium-review.googlesource.com/380315 Commit-Ready: Bill Richardson <wfrichar@chromium.org> Tested-by: Vijay P Hiremath <vijay.p.hiremath@intel.com> Tested-by: Bill Richardson <wfrichar@chromium.org> Reviewed-by: Bill Richardson <wfrichar@chromium.org>
* mkbp: Add keyboard_update_button().Aseda Aboagye2016-07-191-1/+1
| | | | | | | | | | | | | | | | | | | | | | 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>
* Deferred: Use deferred_data instead of function pointerAnton Staaf2016-04-181-3/+6
| | | | | | | | | | | | | | | | | | | | | Previously calls to hook_call_deferred were passed the function to call, which was then looked up in the .rodata.deferred section with a linear search. This linear search can be replaced with a subtract by passing the pointer to the deferred_data object created when DECLARE_DEFERRED was invoked. Signed-off-by: Anton Staaf <robotboy@chromium.org> BRANCH=None BUG=None CQ-DEPEND=CL:*255812 TEST=make buildall -j Change-Id: I951dd1541302875b102dd086154cf05591694440 Reviewed-on: https://chromium-review.googlesource.com/334315 Commit-Ready: Bill Richardson <wfrichar@chromium.org> Tested-by: Bill Richardson <wfrichar@chromium.org> Reviewed-by: Bill Richardson <wfrichar@chromium.org>
* common: button: Add items to .bss.slow.Aseda Aboagye2015-11-091-2/+2
| | | | | | | | | | | | | | | | | | | | BUG=chrome-os-partner:46056 BUG=chrome-os-partner:46063 BRANCH=None TEST=Enable CONFIG_REPLACE_LOADER_WITH_BSS_SLOW on GLaDOS. Build, flash, and verify EC and AP boot. Press power buttons, volume buttons, and verify all functional. TEST='sysjump rw' and repeat the above tests. TEST=make -j buildall tests CQ-DEPEND=CL:311209 Change-Id: I5dfb9003e2da1660400c04938b4f3106817ffc02 Signed-off-by: Aseda Aboagye <aaboagye@google.com> Reviewed-on: https://chromium-review.googlesource.com/311412 Commit-Ready: Aseda Aboagye <aaboagye@chromium.org> Tested-by: Aseda Aboagye <aaboagye@chromium.org> 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
* Only call button handler if keyboard protocol task definedChromeOS Developer2014-02-071-0/+2
| | | | | | | | | | | | | | | | | | | | This fixes a breakage when building tests. BUG=None BRANCH=None TEST=Manual. Run "make BOARD=clapper tests" and "emerge-clapper chromeos-ec" (having cros_worked on it) Change-Id: Icdfa655b7fc246b103111f957d9c3f9e7f49c736 Signed-off-by: Dave Parker <dparker@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/184931 Reviewed-by: Bernie Thompson <bhthompson@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org> (cherry picked from commit 18baa15cc10d1d0906a47fa60ab3fb1eb2cf484e) Reviewed-on: https://chromium-review.googlesource.com/185244 Tested-by: Randall Spangler <rspangler@chromium.org> Reviewed-by: Bill Richardson <wfrichar@chromium.org> Commit-Queue: Randall Spangler <rspangler@chromium.org>
* Add support for extra buttons not on the keyboardChromeOS Developer2014-02-071-0/+127
BUG=chrome-os-partner:24370 BRANCH=tot TEST=Run button unit test. Orig-Change-Id: I61b4a6624d62831ce0bfdf7a0f36a45349b37f96 Signed-off-by: Dave Parker <dparker@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/184544 Reviewed-by: Randall Spangler <rspangler@chromium.org> (cherry picked from commit f6426cc21c20a4f876cff28b9ce7e3115f0b054a) Change-Id: I4face9bf0797a91ec8bef390093aab8e3d8f97ab Reviewed-on: https://chromium-review.googlesource.com/185243 Tested-by: Randall Spangler <rspangler@chromium.org> Reviewed-by: Bill Richardson <wfrichar@chromium.org> Commit-Queue: Randall Spangler <rspangler@chromium.org>