summaryrefslogtreecommitdiff
path: root/common/device_state.c
Commit message (Collapse)AuthorAgeFilesLines
* cr50: Clean up device state codeRandall Spangler2017-08-081-14/+43
| | | | | | | | | | | | | | | | | | | | This mostly adds a bunch of comments, but does make a few changes to the code: 1) The devices console command now prints both the current device state and the last known state. 2) servo_state_unknown() also checks if we're bit-banging the EC UART, since that could also cause EC_DETECT to go high. BUG=none BRANCH=cr50 TEST=make buildall; use 'devices' command Change-Id: I73e7524545ef49494eb36155b99f4042c1fd466d Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/602695 Reviewed-by: Mary Ruthven <mruthven@chromium.org>
* device_state: signal if device_set_state changed the stateMary Ruthven2017-01-231-6/+7
| | | | | | | | | | | | | | | | Each device keeps track of the last known state. If device_set_state updates the device state to a new known state, then return true. Cr50 uses this returned value to check if the state has changed instead of calculating it itself. BUG=none BRANCH=none TEST=device detection still works Change-Id: I8afac178c2c731def6f4f62ff7023fe169ec1479 Signed-off-by: Mary Ruthven <mruthven@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/430970 Reviewed-by: Aaron Durbin <adurbin@chromium.org>
* Cr50: The devices command is safe.Bill Richardson2016-10-011-3/+3
| | | | | | | | | | | | | All it does is show the AP/EC/Servo state BUG=chrome-os-partner:57408 BRANCH=none TEST=make buildall; try on Gru with and without CR50_DEV=1 Signed-off-by: Bill Richardson <wfrichar@chromium.org> Change-Id: I375be8e4d9c6f01aa90d0830da1927732740ed92 Reviewed-on: https://chromium-review.googlesource.com/391611 Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
* cr50: notify chipset hooks when the AP state changesMary Ruthven2016-09-221-54/+6
| | | | | | | | | | | | | | | | | | | | | Cr50 monitors UART1 RX to sense the state of the AP. This signal can be used to tell if it is in S0. If the signal is pulled up then the AP is on. If it is not pulled up then the AP is not in S0. This change notifies HOOK_CHIPSET_SUSPEND when UART1 RX is not pulled up, and then notifies HOOK_CHIPSET_RESUME when the signal is high again. The AP usb can be disabled during suspend, so this change changes the hook that triggers disabling the AP usb to be attached to HOOK_CHIPSET_SUSPEND instead of HOOK_CHIPSET_RESUME. BUG=chrome-os-partner:55747 BRANCH=none TEST=buildall Change-Id: I47fb38a4bbcd72424ec2535d61e87f820cf1bcd7 Signed-off-by: Mary Ruthven <mruthven@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/383978 Reviewed-by: Bill Richardson <wfrichar@chromium.org>
* cr50: remove unused detect_off interruptMary Ruthven2016-09-211-6/+3
| | | | | | | | | | | | | | | | The interrupts to detect when the falling edge on the UART signals are currently disabled and never reenabled. Power off is detected by polling and not through interrupts. This change removes all of those falling edge interrupts. BUG=none BRANCH=none TEST=cr50 can detect when the EC, AP, and Servo are off or on Change-Id: I0fd8a0d970f3235b26af6b90dd395ea7c75e0c17 Signed-off-by: Mary Ruthven <mruthven@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/385192 Reviewed-by: Bill Richardson <wfrichar@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>
* cr50: disable device monitoring when not in ccdMary Ruthven2016-07-121-0/+76
| | | | | | | | | | | | | | | When cr50 is not trying to do ccd, we dont need to monitor the devices. Disable device state detection interrupts and the AP and EC UARTs. BUG=none BRANCH=none TEST=gru and kevin monitor devices correctly when ccd is enabled, and dont monitor anything when it is disabled. Change-Id: Ic3f5974320486ff6dd0147c490a1c294cc2f6a76 Signed-off-by: Mary Ruthven <mruthven@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/356770 Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
* cr50: monitor the state of Servo, the EC, and APMary Ruthven2016-05-271-0/+29
There are a couple of issues that cr50 has when it cannot know the state of servo, the EC, and the AP. This change adds support so we can detect when the AP or EC has been powered on and when servo has been connected. It uses the UART RX signals to monitor the power state of the AP and EC. The TX signals are used to monitor the state of servo. BUG=chrome-os-partner:52056,chrome-os-partner:52322 BRANCH=none TEST=verify device states are correct when the AP and EC are powered on or off and when Servo is attached or detached Change-Id: Id0a2281b65cb367ecc8d0ca2f9a576672318a5fb Signed-off-by: Mary Ruthven <mruthven@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/344019