diff --git a/src/board/system76/common/peci.c b/src/board/system76/common/peci.c index 11d92de..9cdf1a9 100644 --- a/src/board/system76/common/peci.c +++ b/src/board/system76/common/peci.c @@ -60,13 +60,6 @@ static struct Fan __code FAN = { .interpolate = SMOOTH_FANS != 0, }; -#if CONFIG_PECI_OVER_ESPI - -// Maximum OOB channel response time in ms -#define PECI_ESPI_TIMEOUT 10 - -void peci_init(void) {} - // Returns true if peci is available bool peci_available(void) { // Ensure power state is up to date @@ -76,6 +69,7 @@ bool peci_available(void) { if (power_state != POWER_STATE_S0) return false; +#if CONFIG_BUS_ESPI // Currently waiting for host reset, PECI is not available if (espi_host_reset) return false; @@ -88,8 +82,19 @@ bool peci_available(void) { // If VW_HOST_C10 virtual wire is VWS_HIGH, PECI will wake the CPU //TODO: wake CPU every 8 seconds following Intel recommendation? return (vw_get(&VW_HOST_C10) != VWS_HIGH); +#else + // PECI is available if PLTRST# is high + return gpio_get(&BUF_PLT_RST_N); +#endif // CONFIG_BUS_ESPI } +#if CONFIG_PECI_OVER_ESPI + +// Maximum OOB channel response time in ms +#define PECI_ESPI_TIMEOUT 10 + +void peci_init(void) {} + // Returns true on success, false on error bool peci_get_temp(int16_t *data) { //TODO: Wait for completion? @@ -283,19 +288,6 @@ void peci_init(void) { PADCTLR = 0x02; } -// Returns true if peci is available -bool peci_available(void) { - // Ensure power state is up to date - update_power_state(); - - // Power state must be S0 for PECI to be useful - if (power_state != POWER_STATE_S0) - return false; - - // PECI is available if PLTRST# is high - return gpio_get(&BUF_PLT_RST_N); -} - // Returns true on success, false on error bool peci_get_temp(int16_t *data) { // Wait for any in-progress transaction to complete