diff options
-rw-r--r-- | baseboard/volteer/baseboard.c | 3 | ||||
-rw-r--r-- | baseboard/volteer/baseboard.h | 1 | ||||
-rw-r--r-- | board/halvor/gpio.inc | 1 | ||||
-rw-r--r-- | board/malefor/gpio.inc | 1 | ||||
-rw-r--r-- | board/volteer/board.c | 1 | ||||
-rw-r--r-- | board/volteer/gpio.inc | 1 | ||||
-rw-r--r-- | common/throttle_ap.c | 50 | ||||
-rw-r--r-- | include/config.h | 2 | ||||
-rw-r--r-- | include/throttle_ap.h | 13 |
9 files changed, 73 insertions, 0 deletions
diff --git a/baseboard/volteer/baseboard.c b/baseboard/volteer/baseboard.c index 84ad7e8089..4f2df794cc 100644 --- a/baseboard/volteer/baseboard.c +++ b/baseboard/volteer/baseboard.c @@ -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); diff --git a/baseboard/volteer/baseboard.h b/baseboard/volteer/baseboard.h index edd4152b9c..86963673f6 100644 --- a/baseboard/volteer/baseboard.h +++ b/baseboard/volteer/baseboard.h @@ -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 diff --git a/board/halvor/gpio.inc b/board/halvor/gpio.inc index 93f48572e1..454b4f1bcd 100644 --- a/board/halvor/gpio.inc +++ b/board/halvor/gpio.inc @@ -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) diff --git a/board/malefor/gpio.inc b/board/malefor/gpio.inc index b80350e97f..9d84bd1429 100644 --- a/board/malefor/gpio.inc +++ b/board/malefor/gpio.inc @@ -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) diff --git a/board/volteer/board.c b/board/volteer/board.c index 873f9dda6b..3a81bbf35c 100644 --- a/board/volteer/board.c +++ b/board/volteer/board.c @@ -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" diff --git a/board/volteer/gpio.inc b/board/volteer/gpio.inc index 4888d7d4f0..73634db510 100644 --- a/board/volteer/gpio.inc +++ b/board/volteer/gpio.inc @@ -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) 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 diff --git a/include/config.h b/include/config.h index 45fdc4e2a4..9c5c7e3ca8 100644 --- a/include/config.h +++ b/include/config.h @@ -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 diff --git a/include/throttle_ap.h b/include/throttle_ap.h index 442a6cb634..fbfa36aed3 100644 --- a/include/throttle_ap.h +++ b/include/throttle_ap.h @@ -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, |