diff options
author | Keith Short <keithshort@chromium.org> | 2020-03-24 15:35:58 -0600 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2020-03-28 01:02:14 +0000 |
commit | 68b77f7c6ca95602d9cc5d63798c620e190c30f6 (patch) | |
tree | 8d1f524d730296ac228ee6ce80b1d18d0e01fb25 /common/throttle_ap.c | |
parent | 4f312996f9d74ebb2ca62cc053564797bd28f8c4 (diff) | |
download | chrome-ec-68b77f7c6ca95602d9cc5d63798c620e190c30f6.tar.gz |
Volteer: add monitoring for PROCHOT input
Add monotoring of the PROCHOT input to the EC.
BUG=b:152340521
BRANCH=none
TEST=makebuild all
TEST=Assert PROCHOT output from the EC and confirm EC console logging or
PROCHOT input.
Signed-off-by: Keith Short <keithshort@chromium.org>
Change-Id: Ib28537a227ea40ac947f7b999a85354b1ae4c111
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2120067
Reviewed-by: Abe Levkoy <alevkoy@chromium.org>
Commit-Queue: Abe Levkoy <alevkoy@chromium.org>
Diffstat (limited to 'common/throttle_ap.c')
-rw-r--r-- | common/throttle_ap.c | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/common/throttle_ap.c b/common/throttle_ap.c index 8ecc71c207..52b9c96127 100644 --- a/common/throttle_ap.c +++ b/common/throttle_ap.c @@ -8,19 +8,25 @@ #include "chipset.h" #include "common.h" #include "console.h" +#include "hooks.h" #include "host_command.h" #include "task.h" #include "throttle_ap.h" +#include "timer.h" #include "util.h" /* Console output macros */ #define CPUTS(outstr) cputs(CC_THERMAL, outstr) #define CPRINTS(format, args...) cprints(CC_THERMAL, format, ## args) +#define PROCHOT_IN_DEBOUNCE_US (100 * MSEC) + /*****************************************************************************/ /* This enforces the virtual OR of all throttling sources. */ static struct mutex throttle_mutex; static uint32_t throttle_request[NUM_THROTTLE_TYPES]; +static int debounced_prochot_in; +static enum gpio_signal gpio_prochot_in = GPIO_COUNT; void throttle_ap(enum throttle_level level, enum throttle_type type, @@ -70,6 +76,50 @@ void throttle_ap(enum throttle_level level, } +static void prochot_input_deferred(void) +{ + int prochot_in; + + /* + * Shouldn't be possible, but better to protect against buffer + * overflow + */ + ASSERT(signal_is_gpio(gpio_prochot_in)); + + prochot_in = gpio_get_level(gpio_prochot_in); + + if (IS_ENABLED(CONFIG_CPU_PROCHOT_ACTIVE_LOW)) + prochot_in = !prochot_in; + + if (prochot_in == debounced_prochot_in) + return; + + debounced_prochot_in = prochot_in; + + if (debounced_prochot_in) + CPRINTS("External PROCHOT assertion detected"); + else + CPRINTS("External PROCHOT condition cleared"); +} +DECLARE_DEFERRED(prochot_input_deferred); + +void throttle_ap_prochot_input_interrupt(enum gpio_signal signal) +{ + /* + * Save the PROCHOT signal that generated the interrupt so we don't + * rely on a specific pin name. + */ + if (gpio_prochot_in == GPIO_COUNT) + gpio_prochot_in = signal; + + /* + * Trigger deferred notification of PROCHOT change so we can ignore + * any pulses that are too short. + */ + hook_call_deferred(&prochot_input_deferred_data, + PROCHOT_IN_DEBOUNCE_US); +} + /*****************************************************************************/ /* Console commands */ #ifdef CONFIG_CMD_APTHROTTLE |