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>
This commit is contained in:
Keith Short 2020-03-24 15:35:58 -06:00 committed by Commit Bot
parent 4f312996f9
commit 68b77f7c6c
9 changed files with 73 additions and 0 deletions

View File

@ -661,6 +661,9 @@ static void baseboard_init(void)
*/
pwm_enable(PWM_CH_LED4_SIDESEL, 1);
pwm_set_duty(PWM_CH_LED4_SIDESEL, 50);
/* Enable monitoring of the PROCHOT input to the EC */
gpio_enable_interrupt(GPIO_EC_PROCHOT_IN_L);
}
DECLARE_HOOK(HOOK_INIT, baseboard_init, HOOK_PRIO_DEFAULT);

View File

@ -96,6 +96,7 @@
#define CONFIG_THERMISTOR
#define CONFIG_STEINHART_HART_3V3_30K9_47K_4050B
#define CONFIG_THROTTLE_AP
#define CONFIG_CHIPSET_CAN_THROTTLE
/* Common charger defines */
#define CONFIG_CHARGE_MANAGER

View File

@ -94,6 +94,7 @@ GPIO(EC_PCH_RTCRST, PIN(7, 6), GPIO_OUT_LOW)
GPIO(EC_PCH_WAKE_ODL, PIN(7, 4), GPIO_ODR_HIGH)
GPIO(EC_ENTERING_RW, PIN(E, 3), GPIO_OUT_LOW)
GPIO(EC_PROCHOT_ODL, PIN(6, 3), GPIO_ODR_HIGH)
UNIMPLEMENTED(EC_PROCHOT_IN_L)
GPIO(SYS_RST_ODL, PIN(C, 5), GPIO_ODR_HIGH)
GPIO(EC_PCH_INT_ODL, PIN(B, 0), GPIO_ODR_HIGH)

View File

@ -94,6 +94,7 @@ GPIO(EC_PCH_RTCRST, PIN(7, 6), GPIO_OUT_LOW)
GPIO(EC_PCH_WAKE_ODL, PIN(7, 4), GPIO_ODR_HIGH)
GPIO(EC_ENTERING_RW, PIN(E, 3), GPIO_OUT_LOW)
GPIO(EC_PROCHOT_ODL, PIN(6, 3), GPIO_ODR_HIGH)
UNIMPLEMENTED(EC_PROCHOT_IN_L)
GPIO(SYS_RST_ODL, PIN(C, 5), GPIO_ODR_HIGH)
GPIO(EC_PCH_INT_ODL, PIN(B, 0), GPIO_ODR_HIGH)

View File

@ -21,6 +21,7 @@
#include "system.h"
#include "task.h"
#include "tablet_mode.h"
#include "throttle_ap.h"
#include "uart.h"
#include "usb_pd_tbt.h"
#include "util.h"

View File

@ -94,6 +94,7 @@ GPIO(EC_PCH_RTCRST, PIN(7, 6), GPIO_OUT_LOW)
GPIO(EC_PCH_WAKE_ODL, PIN(7, 4), GPIO_ODR_HIGH)
GPIO(EC_ENTERING_RW, PIN(E, 3), GPIO_OUT_LOW)
GPIO(EC_PROCHOT_ODL, PIN(6, 3), GPIO_ODR_HIGH)
GPIO_INT(EC_PROCHOT_IN_L, PIN(F, 0), GPIO_INT_BOTH, throttle_ap_prochot_input_interrupt)
GPIO(SYS_RST_ODL, PIN(C, 5), GPIO_ODR_HIGH)
GPIO(EC_PCH_INT_ODL, PIN(B, 0), GPIO_ODR_HIGH)

View File

@ -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

View File

@ -2948,6 +2948,8 @@
/*
* On x86 systems, define this option if the CPU_PROCHOT signal is active low.
* This setting also applies to monitoring the PROCHOT input if provided by
* the board.
*/
#undef CONFIG_CPU_PROCHOT_ACTIVE_LOW

View File

@ -52,6 +52,19 @@ void throttle_ap(enum throttle_level level,
enum throttle_type type,
enum throttle_sources source);
/**
* Interrupt handler to monitor PROCHOT input to the EC. The PROCHOT signal
* can be asserted by the AP or by other devices on the board, such as chargers
* and voltage regulators.
*
* The board initialization is responsible for enabling the interrupt.
*
* @param signal GPIO signal connected to PROCHOT input. The polarity of this
* signal is active high unless CONFIG_CPU_PROCHOT_ACTIVE_LOW
* is defined.
*/
void throttle_ap_prochot_input_interrupt(enum gpio_signal signal);
#else
static inline void throttle_ap(enum throttle_level level,
enum throttle_type type,