diff options
author | Philip Chen <philipchen@google.com> | 2017-08-10 19:48:31 -0700 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2017-08-17 20:41:54 -0700 |
commit | c556e8b3e21edd6150feb41e2a69701b49254899 (patch) | |
tree | f6375622fae0eb8e18fe39320177c8929f21fe32 /power/rk3399.c | |
parent | 7a41d77b15830990c198b22f027bc925f7bc6382 (diff) | |
download | chrome-ec-c556e8b3e21edd6150feb41e2a69701b49254899.tar.gz |
power: Support non-INT power signal pins
Optionally do polling for power signal pins
which are not set as INT pins.
BUG=b:64528567
BRANCH=none
TEST=boot scarlet rev1 with a non-INT power signal pin
Change-Id: I327753fcc0f1c6482c5f5eb3df28f67181b4eb62
Signed-off-by: Philip Chen <philipchen@google.com>
Reviewed-on: https://chromium-review.googlesource.com/611649
Commit-Ready: Philip Chen <philipchen@chromium.org>
Tested-by: Philip Chen <philipchen@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Diffstat (limited to 'power/rk3399.c')
-rw-r--r-- | power/rk3399.c | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/power/rk3399.c b/power/rk3399.c index f7e756b91a..9dbbd1bc4a 100644 --- a/power/rk3399.c +++ b/power/rk3399.c @@ -53,6 +53,8 @@ #define IN_PGOOD_S0 (IN_PGOOD_S3 | IN_PGOOD_PP900_S0 | IN_PGOOD_AP) /* This board can optionally wake-on-USB in S3 */ #define S3_USB_WAKE + /* This board has non-INT power signal pins */ + #define POWER_SIGNAL_POLLING #else #define IN_PGOOD_S3 (IN_PGOOD_PP5000) #define IN_PGOOD_S0 (IN_PGOOD_S3 | IN_PGOOD_AP | IN_PGOOD_SYS) @@ -570,3 +572,38 @@ static void lid_changed(void) } DECLARE_HOOK(HOOK_LID_CHANGE, lid_changed, HOOK_PRIO_DEFAULT); #endif + +#ifdef POWER_SIGNAL_POLLING +/* + * Polling for non-INT power signal pins. + * Call power_signal_interrupt() when the GPIO status of those pins changes. + */ +static void power_signal_changed(void) +{ + static uint8_t in_signals; /* Current power signal status */ + uint8_t inew = 0; + const struct power_signal_info *s = power_signal_list; + int i; + + BUILD_ASSERT(POWER_SIGNAL_COUNT <= 8); + + for (i = 0; i < POWER_SIGNAL_COUNT; i++, s++) { + /* Skip if this is an INT pin. */ + if (s->gpio < GPIO_IH_COUNT) + continue; + + if (gpio_get_level(s->gpio) == s->level) + inew |= 1 << i; + } + + if (inew != in_signals) { + /* + * Pass a fake power gpio_signal to power_signal_interrupt(). + * Note that here we make power_signal_interrupt() reentrant. + */ + power_signal_interrupt(POWER_SIGNAL_COUNT); + in_signals = inew; + } +} +DECLARE_HOOK(HOOK_TICK, power_signal_changed, HOOK_PRIO_DEFAULT); +#endif |