Use ESPI VW signals wherever possible

This commit is contained in:
Jeremy Soller
2023-02-22 14:27:47 -07:00
parent a5a677ee63
commit cea89a78d8
12 changed files with 42 additions and 59 deletions

View File

@ -26,8 +26,6 @@ struct Gpio __code PM_PWROK = GPIO(C, 6);
struct Gpio __code PWR_BTN_N = GPIO(D, 5); struct Gpio __code PWR_BTN_N = GPIO(D, 5);
struct Gpio __code PWR_SW_N = GPIO(B, 3); struct Gpio __code PWR_SW_N = GPIO(B, 3);
struct Gpio __code SLP_SUS_N = GPIO(H, 7); struct Gpio __code SLP_SUS_N = GPIO(H, 7);
struct Gpio __code SUSB_N_PCH = GPIO(H, 6);
struct Gpio __code SUSC_N_PCH = GPIO(H, 1);
struct Gpio __code VA_EC_EN = GPIO(J, 4); struct Gpio __code VA_EC_EN = GPIO(J, 4);
struct Gpio __code WLAN_EN = GPIO(G, 1); struct Gpio __code WLAN_EN = GPIO(G, 1);
struct Gpio __code WLAN_PWR_EN = GPIO(D, 3); struct Gpio __code WLAN_PWR_EN = GPIO(D, 3);

View File

@ -33,8 +33,6 @@ extern struct Gpio __code PWR_BTN_N;
extern struct Gpio __code PWR_SW_N; extern struct Gpio __code PWR_SW_N;
extern struct Gpio __code SLP_SUS_N; extern struct Gpio __code SLP_SUS_N;
#define HAVE_SUS_PWR_ACK 0 #define HAVE_SUS_PWR_ACK 0
extern struct Gpio __code SUSB_N_PCH;
extern struct Gpio __code SUSC_N_PCH;
extern struct Gpio __code VA_EC_EN; extern struct Gpio __code VA_EC_EN;
extern struct Gpio __code WLAN_EN; extern struct Gpio __code WLAN_EN;
extern struct Gpio __code WLAN_PWR_EN; extern struct Gpio __code WLAN_PWR_EN;

View File

@ -14,10 +14,6 @@
#define USE_PECI_OVER_ESPI 0 #define USE_PECI_OVER_ESPI 0
#endif #endif
#ifndef USE_S0IX
#define USE_S0IX 0
#endif
// Fan speed is the lowest requested over HEATUP seconds // Fan speed is the lowest requested over HEATUP seconds
#ifndef BOARD_HEATUP #ifndef BOARD_HEATUP
#define BOARD_HEATUP 4 #define BOARD_HEATUP 4
@ -246,13 +242,14 @@ int16_t peci_wr_pkg_config(uint8_t index, uint16_t param, uint32_t data) {
uint8_t peci_get_fan_duty(void) { uint8_t peci_get_fan_duty(void) {
uint8_t duty; uint8_t duty;
#if USE_S0IX #if CONFIG_BUS_ESPI
// Use PECI if platform is not in CS // Use PECI if CPU is not in C10 sleep state
peci_on = gpio_get(&SLP_S0_N); // HOST_C10 virtual wire is high when CPU is in C10 sleep state
#else // USE_S0IX peci_on = !vw_get(&VW_HOST_C10);
#else // CONFIG_BUS_ESPI
// Use PECI if in S0 state // Use PECI if in S0 state
peci_on = power_state == POWER_STATE_S0; peci_on = power_state == POWER_STATE_S0;
#endif // USE_S0IX #endif // CONFIG_BUS_ESPI
if (peci_on) { if (peci_on) {
int16_t peci_offset = 0; int16_t peci_offset = 0;

View File

@ -22,10 +22,6 @@
#include <board/espi.h> #include <board/espi.h>
#endif #endif
#ifndef USE_S0IX
#define USE_S0IX 0
#endif
#define GPIO_SET_DEBUG(G, V) \ #define GPIO_SET_DEBUG(G, V) \
{ \ { \
DEBUG("%s = %s\n", #G, V ? "true" : "false"); \ DEBUG("%s = %s\n", #G, V ? "true" : "false"); \
@ -64,14 +60,6 @@
#define HAVE_SLP_SUS_N 1 #define HAVE_SLP_SUS_N 1
#endif #endif
#ifndef HAVE_SUSB_N_PCH
#define HAVE_SUSB_N_PCH 1
#endif
#ifndef HAVE_SUSC_N_PCH
#define HAVE_SUSC_N_PCH 1
#endif
#ifndef HAVE_SUSWARN_N #ifndef HAVE_SUSWARN_N
#define HAVE_SUSWARN_N 1 #define HAVE_SUSWARN_N 1
#endif #endif
@ -133,36 +121,41 @@ enum PowerState power_state = POWER_STATE_OFF;
enum PowerState calculate_power_state(void) { enum PowerState calculate_power_state(void) {
//TODO: Deep Sx states using SLP_SUS# //TODO: Deep Sx states using SLP_SUS#
#if HAVE_SUSB_N_PCH #if CONFIG_BUS_ESPI
if (gpio_get(&SUSB_N_PCH)) { // Use eSPI virtual wires if available
// S3, S4, and S5 planes powered
return POWER_STATE_S0;
}
#else
// Use eSPI virtual wire if there is no dedicated GPIO
if (vw_get(&VW_SLP_S3_N)) { if (vw_get(&VW_SLP_S3_N)) {
// S3, S4, and S5 planes powered // S3, S4, and S5 planes powered
return POWER_STATE_S0; return POWER_STATE_S0;
} }
#endif
#if HAVE_SUSC_N_PCH
if (gpio_get(&SUSC_N_PCH)) {
// S4 and S5 planes powered
return POWER_STATE_S3;
}
#else
// Use eSPI virtual wire if there is no dedicated GPIO
if (vw_get(&VW_SLP_S4_N)) { if (vw_get(&VW_SLP_S4_N)) {
// S4 and S5 planes powered // S4 and S5 planes powered
return POWER_STATE_S3; return POWER_STATE_S3;
} }
#endif
if (vw_get(&VW_SLP_S5_N)) {
// S5 plane powered
return POWER_STATE_S5;
}
#else // CONFIG_BUS_ESPI
// Use dedicated GPIOs if not using ESPI
if (gpio_get(&SUSB_N_PCH)) {
// S3, S4, and S5 planes powered
return POWER_STATE_S0;
}
if (gpio_get(&SUSC_N_PCH)) {
// S4 and S5 planes powered
return POWER_STATE_S3;
}
if (gpio_get(&EC_RSMRST_N)) { if (gpio_get(&EC_RSMRST_N)) {
// S5 plane powered // S5 plane powered
return POWER_STATE_S5; return POWER_STATE_S5;
} }
#endif // CONFIG_BUS_ESPI
return POWER_STATE_OFF; return POWER_STATE_OFF;
} }
@ -346,11 +339,12 @@ static bool power_peci_limit(bool ac) {
void power_set_limit(void) { void power_set_limit(void) {
static bool last_power_limit_ac = true; static bool last_power_limit_ac = true;
// We don't use power_state because the latency needs to be low // We don't use power_state because the latency needs to be low
#if USE_S0IX #if CONFIG_BUS_ESPI
if (gpio_get(&SLP_S0_N)) { // HOST_C10 virtual wire is high when CPU is in C10 sleep state
#else if (!vw_get(&VW_HOST_C10)) {
#else // CONFIG_BUS_ESPI
if (gpio_get(&BUF_PLT_RST_N)) { if (gpio_get(&BUF_PLT_RST_N)) {
#endif #endif // CONFIG_BUS_ESPI
bool ac = !gpio_get(&ACIN_N); bool ac = !gpio_get(&ACIN_N);
if (last_power_limit_ac != ac) { if (last_power_limit_ac != ac) {
if (power_peci_limit(ac)) { if (power_peci_limit(ac)) {
@ -361,7 +355,7 @@ void power_set_limit(void) {
last_power_limit_ac = true; last_power_limit_ac = true;
} }
} }
#else #else // HAVE_DGPU
void power_set_limit(void) {} void power_set_limit(void) {}
#endif // HAVE_DGPU #endif // HAVE_DGPU
@ -582,8 +576,9 @@ void power_event(void) {
static uint32_t last_time = 0; static uint32_t last_time = 0;
uint32_t time = time_get(); uint32_t time = time_get();
if (power_state == POWER_STATE_S0) { if (power_state == POWER_STATE_S0) {
#if USE_S0IX #if CONFIG_BUS_ESPI
if (!gpio_get(&SLP_S0_N)) { // HOST_C10 virtual wire is high when CPU is in C10 sleep state
if (vw_get(&VW_HOST_C10)) {
// Modern suspend, flashing green light // Modern suspend, flashing green light
if ((time - last_time) >= 1000) { if ((time - last_time) >= 1000) {
gpio_set(&LED_PWR, !gpio_get(&LED_PWR)); gpio_set(&LED_PWR, !gpio_get(&LED_PWR));

View File

@ -27,8 +27,6 @@ struct Gpio __code PCH_PWROK_EC = GPIO(F, 3);
struct Gpio __code PWR_BTN_N = GPIO(D, 5); struct Gpio __code PWR_BTN_N = GPIO(D, 5);
struct Gpio __code PWR_SW_N = GPIO(B, 3); struct Gpio __code PWR_SW_N = GPIO(B, 3);
struct Gpio __code SLP_SUS_N = GPIO(J, 4); struct Gpio __code SLP_SUS_N = GPIO(J, 4);
struct Gpio __code SUSB_N_PCH = GPIO(H, 6);
struct Gpio __code SUSC_N_PCH = GPIO(H, 1);
struct Gpio __code VA_EC_EN = GPIO(H, 7); struct Gpio __code VA_EC_EN = GPIO(H, 7);
struct Gpio __code WLAN_EN = GPIO(G, 1); struct Gpio __code WLAN_EN = GPIO(G, 1);
struct Gpio __code WLAN_PWR_EN = GPIO(A, 3); struct Gpio __code WLAN_PWR_EN = GPIO(A, 3);

View File

@ -34,8 +34,6 @@ extern struct Gpio __code PWR_BTN_N;
extern struct Gpio __code PWR_SW_N; extern struct Gpio __code PWR_SW_N;
extern struct Gpio __code SLP_SUS_N; extern struct Gpio __code SLP_SUS_N;
#define HAVE_SUS_PWR_ACK 0 #define HAVE_SUS_PWR_ACK 0
extern struct Gpio __code SUSB_N_PCH;
extern struct Gpio __code SUSC_N_PCH;
extern struct Gpio __code VA_EC_EN; extern struct Gpio __code VA_EC_EN;
extern struct Gpio __code WLAN_EN; extern struct Gpio __code WLAN_EN;
extern struct Gpio __code WLAN_PWR_EN; extern struct Gpio __code WLAN_PWR_EN;

View File

@ -34,7 +34,7 @@ CFLAGS+=\
-DCHARGER_CHARGE_VOLTAGE=17600 \ -DCHARGER_CHARGE_VOLTAGE=17600 \
-DCHARGER_INPUT_CURRENT=11500 -DCHARGER_INPUT_CURRENT=11500
# Use PECI over ESPI # Use PECI over ESPI
CFLAGS+=-DUSE_PECI_OVER_ESPI=1 CFLAGS+=-DUSE_PECI_OVER_ESPI=1
# Set CPU power limits in watts # Set CPU power limits in watts

View File

@ -34,8 +34,6 @@ extern struct Gpio __code PWR_BTN_N;
extern struct Gpio __code PWR_SW_N; extern struct Gpio __code PWR_SW_N;
extern struct Gpio __code SLP_SUS_N; extern struct Gpio __code SLP_SUS_N;
#define HAVE_SUS_PWR_ACK 0 #define HAVE_SUS_PWR_ACK 0
#define HAVE_SUSB_N_PCH 0
#define HAVE_SUSC_N_PCH 0
extern struct Gpio __code VA_EC_EN; extern struct Gpio __code VA_EC_EN;
#define HAVE_WLAN_EN 0 #define HAVE_WLAN_EN 0
extern struct Gpio __code WLAN_PWR_EN; extern struct Gpio __code WLAN_PWR_EN;

View File

@ -26,8 +26,6 @@ struct Gpio __code PCH_PWROK_EC = GPIO(C, 6);
struct Gpio __code PWR_BTN_N = GPIO(D, 5); struct Gpio __code PWR_BTN_N = GPIO(D, 5);
struct Gpio __code PWR_SW_N = GPIO(B, 3); struct Gpio __code PWR_SW_N = GPIO(B, 3);
struct Gpio __code SLP_SUS_N = GPIO(H, 7); struct Gpio __code SLP_SUS_N = GPIO(H, 7);
struct Gpio __code SUSB_N_PCH = GPIO(H, 6);
struct Gpio __code SUSC_N_PCH = GPIO(H, 1);
struct Gpio __code SWI_N = GPIO(B, 5); struct Gpio __code SWI_N = GPIO(B, 5);
struct Gpio __code USB_PWR_EN_N = GPIO(E, 3); struct Gpio __code USB_PWR_EN_N = GPIO(E, 3);
struct Gpio __code VA_EC_EN = GPIO(J, 4); struct Gpio __code VA_EC_EN = GPIO(J, 4);

View File

@ -35,8 +35,6 @@ extern struct Gpio __code PWR_SW_N;
extern struct Gpio __code SLP_SUS_N; extern struct Gpio __code SLP_SUS_N;
#define HAVE_SUSWARN_N 0 #define HAVE_SUSWARN_N 0
#define HAVE_SUS_PWR_ACK 0 #define HAVE_SUS_PWR_ACK 0
extern struct Gpio __code SUSB_N_PCH;
extern struct Gpio __code SUSC_N_PCH;
extern struct Gpio __code SWI_N; extern struct Gpio __code SWI_N;
extern struct Gpio __code USB_PWR_EN_N; extern struct Gpio __code USB_PWR_EN_N;
extern struct Gpio __code VA_EC_EN; extern struct Gpio __code VA_EC_EN;

View File

@ -34,6 +34,8 @@ struct VirtualWire __code VW_SUS_ACK_N = VIRTUAL_WIRE(40, 0);
// Index 41 - AP to EC (platform specific) // Index 41 - AP to EC (platform specific)
struct VirtualWire __code VW_SUS_WARN_N = VIRTUAL_WIRE(41, 0); struct VirtualWire __code VW_SUS_WARN_N = VIRTUAL_WIRE(41, 0);
struct VirtualWire __code VW_SUS_PWRDN_ACK = VIRTUAL_WIRE(41, 1); struct VirtualWire __code VW_SUS_PWRDN_ACK = VIRTUAL_WIRE(41, 1);
// Index 47 - AP to EC (platform specific)
struct VirtualWire __code VW_HOST_C10 = VIRTUAL_WIRE(47, 0);
enum VirtualWireState vw_get(struct VirtualWire *vw) __critical { enum VirtualWireState vw_get(struct VirtualWire *vw) __critical {
uint8_t index = *vw->index; uint8_t index = *vw->index;

View File

@ -59,6 +59,8 @@ extern struct VirtualWire __code VW_SUS_ACK_N;
// Index 41 - AP to EC (platform specific) // Index 41 - AP to EC (platform specific)
extern struct VirtualWire __code VW_SUS_WARN_N; extern struct VirtualWire __code VW_SUS_WARN_N;
extern struct VirtualWire __code VW_SUS_PWRDN_ACK; extern struct VirtualWire __code VW_SUS_PWRDN_ACK;
// Index 47 - AP to EC (platform specific)
extern struct VirtualWire __code VW_HOST_C10;
// General capabilities and configurations // General capabilities and configurations
volatile uint8_t __xdata __at(0x3107) ESGCAC0; volatile uint8_t __xdata __at(0x3107) ESGCAC0;
@ -154,6 +156,7 @@ volatile uint8_t __xdata __at(0x3207) VWIDX7;
volatile uint8_t __xdata __at(0x3240) VWIDX40; volatile uint8_t __xdata __at(0x3240) VWIDX40;
volatile uint8_t __xdata __at(0x3241) VWIDX41; volatile uint8_t __xdata __at(0x3241) VWIDX41;
volatile uint8_t __xdata __at(0x3242) VWIDX42; volatile uint8_t __xdata __at(0x3242) VWIDX42;
volatile uint8_t __xdata __at(0x3247) VWIDX47;
// Virtual wire control // Virtual wire control
volatile uint8_t __xdata __at(0x3290) VWCTRL0; volatile uint8_t __xdata __at(0x3290) VWCTRL0;