summaryrefslogtreecommitdiff
path: root/common/power_button.c
Commit message (Collapse)AuthorAgeFilesLines
* ish: Trim down the release branchstabilize-wristpin-14469.59.B-ishstabilize-voshyr-14637.B-ishstabilize-quickfix-14695.187.B-ishstabilize-quickfix-14695.124.B-ishstabilize-quickfix-14526.91.B-ishstabilize-14695.85.B-ishstabilize-14695.107.B-ishstabilize-14682.B-ishstabilize-14633.B-ishstabilize-14616.B-ishstabilize-14589.B-ishstabilize-14588.98.B-ishstabilize-14588.14.B-ishstabilize-14588.123.B-ishstabilize-14536.B-ishstabilize-14532.B-ishstabilize-14528.B-ishstabilize-14526.89.B-ishstabilize-14526.84.B-ishstabilize-14526.73.B-ishstabilize-14526.67.B-ishstabilize-14526.57.B-ishstabilize-14498.B-ishstabilize-14496.B-ishstabilize-14477.B-ishstabilize-14469.9.B-ishstabilize-14469.8.B-ishstabilize-14469.58.B-ishstabilize-14469.41.B-ishstabilize-14442.B-ishstabilize-14438.B-ishstabilize-14411.B-ishstabilize-14396.B-ishstabilize-14395.B-ishstabilize-14388.62.B-ishstabilize-14388.61.B-ishstabilize-14388.52.B-ishstabilize-14385.B-ishstabilize-14345.B-ishstabilize-14336.B-ishstabilize-14333.B-ishrelease-R99-14469.B-ishrelease-R98-14388.B-ishrelease-R102-14695.B-ishrelease-R101-14588.B-ishrelease-R100-14526.B-ishfirmware-cherry-14454.B-ishfirmware-brya-14505.B-ishfirmware-brya-14505.71.B-ishfactory-kukui-14374.B-ishfactory-guybrush-14600.B-ishfactory-cherry-14455.B-ishfactory-brya-14517.B-ishJack Rosenthal2021-11-051-227/+0
| | | | | | | | | | | | | | | | | | | | | | In the interest of making long-term branch maintenance incur as little technical debt on us as possible, we should not maintain any files on the branch we are not actually using. This has the added effect of making it extremely clear when merging CLs from the main branch when changes have the possibility to affect us. The follow-on CL adds a convenience script to actually pull updates from the main branch and generate a CL for the update. BUG=b:204206272 BRANCH=ish TEST=make BOARD=arcada_ish && make BOARD=drallion_ish Signed-off-by: Jack Rosenthal <jrosenth@chromium.org> Change-Id: I17e4694c38219b5a0823e0a3e55a28d1348f4b18 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3262038 Reviewed-by: Jett Rink <jettrink@chromium.org> Reviewed-by: Tom Hughes <tomhughes@chromium.org>
* power_button: Use polling instead of forever wait for releaseWai-Hong Tam2020-08-011-5/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The existing logic may cause infinite wait, if the power_button_wait_for_release() is called during debouncing, i.e. after the interrupt is triggered, but before the debouncing function power_button_change_deferred() is called. The interrupt sets power_button_is_stable to 0. It makes entering the loop to wait for a event. After debouncing, if found out it is a false alarm, it sets power_button_is_stable back to 1 and does nothing. The HOOK_POWER_BUTTON_CHANGE is not notified. So no way to escape the loop. The HOOK_POWER_BUTTON_CHANGE is supposed to wake the task. This CL simply changes the logic to polling, that prevents the above forever wait issue. We use task_wait_event() instead of usleep() to wait. It will be woken up immediately if the power button is debouned and changed. However, it is not guaranteed, like the cases that the power button is debounced but not changed, or the power button has not been debounced. BRANCH=None BUG=b:161652942 TEST=Tested a previously failed scenario: waked from hibernate, checked AP auto-booting into S0, not stuck at S5S3. TEST=Tested the normal case: hold Refresh + Power -> release Refresh, checked staying in S5S3. Release power, checked transit to S0. Change-Id: I10b67513c232b7ebe26af4d5b88e064cea9e6dc7 Signed-off-by: Wai-Hong Tam <waihong@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2330577 Reviewed-by: Jett Rink <jettrink@chromium.org>
* PB: Make CONFIG_POWER_BUTTON_INIT_IDLE commonDaisuke Nojiri2020-06-131-0/+31
| | | | | | | | | | | | | | | | | Currently CONFIG_POWER_BUTTON_INIT_IDLE is available only for NPCX chips. This patch moves the code to common/power_button.c. There is no functionality change. BUG=b:37536389 BRANCH=none TEST=Verify no functionality change on Puff. Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> Change-Id: Ib4b1182900acea21e5210a2f9a699da18fe55611 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2242661 Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
* Button: Clean up button librarydnojiri2020-03-051-24/+20
| | | | | | | | | | | | | | | | | | | | Define BUTTON_DEBOUNCE_US and use it for recovery, volume, and power. Use struct button_config for characterizing power button. Introduce CONFIG_POWER_BUTTON_FLAGS for power button customization. Signed-off-by: dnojiri <dnojiri@chromium.org> BUG=none BRANCH=none TEST=Verified power button works on Helios. TEST=Verified powerbtn command works on Helios. Change-Id: I4fd0db1da6190127f223d9c27b02ae370fa91c03 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2088279 Reviewed-by: Craig Hesling <hesling@chromium.org> Commit-Queue: Daisuke Nojiri <dnojiri@chromium.org> Tested-by: Daisuke Nojiri <dnojiri@chromium.org> Auto-Submit: Daisuke Nojiri <dnojiri@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>
* powerbtn/button: fix crash on 0ms sleepRuben Rodriguez Buchillon2019-01-241-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | This change guards against crashing the EC when calling button or powerbtn with a 0 as the argument. BRANCH=None BUG=chromium:905829 TEST=manual testing on soraka > powerbtn 0 Simulating 0 ms power button press. Simulating power button release. > button vup 0 > Change-Id: I022c9e48b0977b71b8706e5ffe8356a226a59077 Signed-off-by: Ruben Rodriguez Buchillon <coconutruben@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1428500 Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com> Reviewed-by: Hung-Te Lin <hungte@chromium.org> Reviewed-by: Yilun Lin <yllin@chromium.org> Reviewed-by: Nicolas Boichat <drinkcat@chromium.org>
* cleanup: DECLARE_CONSOLE_COMMAND only needs 4 argsBill Richardson2016-08-241-2/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | Since pretty much always, we've declared console commands to take a "longhelp" argument with detailed explanations of what the command does. But since almost as long, we've never actually used that argument for anything - we just silently throw it away in the macro. There's only one command (usbchargemode) that even thinks it defines that argument. We're never going to use this, let's just get rid of it. BUG=none BRANCH=none CQ-DEPEND=CL:*279060 CQ-DEPEND=CL:*279158 CQ-DEPEND=CL:*279037 TEST=make buildall; tested on Cr50 hardware Everything builds. Since we never used this arg anyway, there had better not be any difference in the result. Change-Id: Id3f71a53d02e3dc625cfcc12aa71ecb50e35eb9f Signed-off-by: Bill Richardson <wfrichar@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/374163 Reviewed-by: Myles Watson <mylesgw@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org>
* Deferred: Use deferred_data instead of function pointerAnton Staaf2016-04-181-3/+4
| | | | | | | | | | | | | | | | | | | | | 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>
* cleanup: Fix signed vs unsigned typingShawn Nematbakhsh2016-02-031-1/+1
| | | | | | | | | | | | | | | | | | - ec_response_thermal_get_threshold.value is unsigned, so it can not be less than zero. - make power_button_wait_for_release() take a signed int, to match its existing usage. BUG=None TEST=`make buildall -j` BRANCH=None Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org> Change-Id: Ie5748df3d9904d1e417adc38fee18f8cb3ce9750 Reviewed-on: https://chromium-review.googlesource.com/325840 Commit-Ready: Shawn N <shawnn@chromium.org> Tested-by: Shawn N <shawnn@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org>
* Power Button: Wait for power button to be stable when waiting for releaseAlexandru M Stan2015-02-101-1/+39
| | | | | | | | | | | | | | | | | | The debounce timer might be too slow to actually update the state of debounced_power_pressed by the time we do power_button_is_pressed in the S3->S5 state transition. Solution is to move the power_button_wait_for_release function here and make sure there are no deferreds active. BUG=chrome-os-partner:35948 TEST=During dev mode screen, press power button, note the device stays off TEST=Print debounced_power_pressed in power_button_is_pressed(void), note it's not 0 when power button is actually pressed BRANCH=veyron Change-Id: I8258e9e5524bd65d6ea9c77ea5649304d2195bf0 Signed-off-by: Alexandru M Stan <amstan@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/244590 Reviewed-by: Randall Spangler <rspangler@chromium.org>
* power_button: expose raw signal assertionAaron Durbin2014-08-211-2/+11
| | | | | | | | | | | | | | | It's useful to expose the logic of the power button assertion according to the CONFIG active level at the hardware input. Therefore, provide power_button_signal_asserted(). BUG=chrome-os-partner:31481 BRANCH=None TEST=Benson tested this on ryu since has the button cables. Change-Id: Ica48bfe981550700a067406cb72908e14dbccba9 Signed-off-by: Aaron Durbin <adurbin@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/213298 Reviewed-by: Alec Berg <alecaberg@chromium.org>
* power_button: allow to modify the active levelVincent Palatin2014-07-291-1/+7
| | | | | | | | | | | | | | | | | | | On most platforms, the power button is active low, but the power button on Ryu is active high. Add CONFIG_POWER_BUTTON_ACTIVE_STATE to override the default active state. Signed-off-by: Vincent Palatin <vpalatin@chromium.org> BRANCH=none BUG=none TEST=on Ryu, use the servo pwr_button to start and stop the AP. Change-Id: I11c6bb3c700bccd3606ce1fa1a69905671792990 Reviewed-on: https://chromium-review.googlesource.com/207274 Reviewed-by: Vic Yang <victoryang@chromium.org> Tested-by: Vic Yang <victoryang@chromium.org> Commit-Queue: Vic Yang <victoryang@chromium.org>
* Add cprints() and ccprints()Vic Yang2014-05-211-2/+2
| | | | | | | | | | | | | | | | | | | | | 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>
* Refactored keyboard scan enable flag to allow for multiple disable reasonsAlec Berg2014-04-111-2/+2
| | | | | | | | | | | | | | | | | | | | | | Refactored keyboard scan enable/disable flag such that it is a mask of potential disable sources. When all disable sources are off, scanning is enabled, otherwise scanning is disabled. This fixes a recently introduced bug in which enabling/disabling keyboard scanning due to lid angle in S3 was interfering with enabling/disabling keyboard scanning due to power button. This also allows for easy expansion for future causes for disabling keyboard scanning. BUG=chrome-os-partner:27851 BRANCH=rambi TEST=Manual tests with a glimmer. Used the ksstate console command to check state of keyboard scanning under all permutations of power button pressed/unpressed, lid switch open/closed, and lid angle in tablet position vs. laptop positon. Change-Id: Ied4c5ebb94510b1078cd81d71373c0f1bd0d6678 Signed-off-by: Alec Berg <alecaberg@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/194287 Reviewed-by: Randall Spangler <rspangler@chromium.org>
* Config option for using power button with lid closedstabilize-5414.Bstabilize-5412.BChromeOS Developer2014-02-011-1/+7
| | | | | | | | | | | | | | | BUG=chrome-os-partner:24912 BRANCH=baytrail TEST=Manual. Enable CONFIG_POWER_BUTTON_IGNORE_LID on a device, boot it, and go into dock mode with external monitor attached. Fake-close the lid with a magnet or servo. Verify the power button still sends press/release events to the host with evtest. Change-Id: Idb05375eee0743a8a2c459070854c03fe3afe894 Signed-off-by: Dave Parker <dparker@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/184493 Reviewed-by: Randall Spangler <rspangler@chromium.org>
* Fix leaving keyboard scanning disabled on brief power button pressRandall Spangler2013-08-091-4/+4
| | | | | | | | | | | | | | | | | | | | If the power button is pressed for a shorter period than the debounce timeout, then the debounced state never changes. This was causing the power button state machine to disable scanning (in the interrupt handler) but never re-enable it (in the deferred handler). Easy fix; just re-enable based on whether the current state is released, not whether the debounced state is transitioning to released. BUG=chrome-os-partner:21772 BRANCH=all (falco, pit, etc.) TEST=type on console. briefly flick power button. type more; should work. Change-Id: I9723a6aa10f122fcee62702b85ce7981b1c8103a Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/65238 Reviewed-by: Duncan Laurie <dlaurie@chromium.org>
* Split out power button code from switch.cRandall Spangler2013-04-251-0/+135
The power button code is platform-independent. This change splits the code out of the LM4 switch.c module so that a subseqent change to STM32 platforms can start using it. BUG=chrome-os-partner:18945 BRANCH=none TEST=manual 1. Power+refresh+esc goes to recovery mode, 2. Press power button at recovery screen turns off. 3. With system off, power button turns system on. 4. Press power button for a second; screen locks. 5. Press power button while typing; blocks keystrokes while it's pressed. 6. Hold power button down for 8 sec; system forced to shutdown. 7. From EC console, with system on: hostevent clear hostevent -> event 0x04 is clear press power button hostevent -> event 0x04 is set 8. From EC console, with system off: powerbtn -> system turns on powerbtn 5000 -> system turns off, just like power button was held for 5 sec Change-Id: If2a9b02514a201e1d03c857d128e2ccab51a16ef Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/49217 Reviewed-by: Bill Richardson <wfrichar@chromium.org>