Conditionally compile eSPI support

A board may use either the LPC bus or the eSPI bus. Only include eSPI
support for boards that use it.

Signed-off-by: Tim Crawford <tcrawford@system76.com>
This commit is contained in:
Tim Crawford
2022-11-30 08:51:54 -07:00
committed by Jeremy Soller
parent 5e884cf413
commit d687df482a
21 changed files with 42 additions and 51 deletions

View File

@ -5,7 +5,7 @@ board-common-y += battery.c
board-common-y += config.c
board-common-y += dgpu.c
board-common-y += ecpm.c
board-common-y += espi.c
board-common-$(CONFIG_BUS_ESPI) += espi.c
board-common-y += fan.c
board-common-y += gctrl.c
board-common-y += kbc.c
@ -45,6 +45,10 @@ CFLAGS+=-DLEVEL=4
# Set external programmer
PROGRAMMER=$(wildcard /dev/serial/by-id/usb-Arduino*)
ifeq ($(CONFIG_BUS_ESPI),y)
CFLAGS += -DCONFIG_BUS_ESPI=1
endif
# Include system76 common source
SYSTEM76_COMMON_DIR=src/board/system76/common
INCLUDE+=$(wildcard $(SYSTEM76_COMMON_DIR)/include/board/*.h) $(SYSTEM76_COMMON_DIR)/common.mk

View File

@ -2,8 +2,6 @@
#include <board/espi.h>
#if EC_ESPI
#include <arch/delay.h>
#include <board/power.h>
#include <common/debug.h>
@ -197,5 +195,3 @@ void espi_event(void) {
// Detect when I/O mode changes
DEBUG_CHANGED(ESGCTRL3);
}
#endif // EC_ESPI

View File

@ -11,7 +11,7 @@
void kbc_init(void) {
// Disable interrupts
*(KBC.control) = 0;
#if EC_ESPI
#if CONFIG_BUS_ESPI
// Set IRQ mode to edge-triggered, 1-cycle pulse width
*(KBC.irq) = BIT(3);
#else

View File

@ -31,7 +31,7 @@ enum PmcState {
static uint8_t pmc_sci_queue = 0;
static void pmc_sci_interrupt(void) {
#if EC_ESPI
#if CONFIG_BUS_ESPI
// Start SCI interrupt
vw_set(&VW_SCI_N, VWS_LOW);
@ -43,7 +43,7 @@ static void pmc_sci_interrupt(void) {
// Delay T_HOLD (value assumed)
delay_us(65);
#else // EC_ESPI
#else // CONFIG_BUS_ESPI
// Start SCI interrupt
gpio_set(&SCI_N, false);
*(SCI_N.control) = GPIO_OUT;
@ -57,7 +57,7 @@ static void pmc_sci_interrupt(void) {
// Delay T_HOLD (value assumed)
delay_us(65);
#endif // EC_ESPI
#endif // CONFIG_BUS_ESPI
}
bool pmc_sci(struct Pmc * pmc, uint8_t sci) {
@ -77,7 +77,7 @@ bool pmc_sci(struct Pmc * pmc, uint8_t sci) {
}
void pmc_swi(void) {
#if EC_ESPI
#if CONFIG_BUS_ESPI
// Start PME interrupt
vw_set(&VW_PME_N, VWS_LOW);
@ -89,7 +89,7 @@ void pmc_swi(void) {
// Delay T_HOLD (value assumed)
delay_us(65);
#else // EC_ESPI
#else // CONFIG_BUS_ESPI
// Start SWI interrupt
gpio_set(&SWI_N, false);
@ -101,7 +101,7 @@ void pmc_swi(void) {
// Delay T_HOLD (value assumed)
delay_us(65);
#endif // EC_ESPI
#endif // CONFIG_BUS_ESPI
}
static enum PmcState state = PMC_STATE_DEFAULT;

View File

@ -50,18 +50,18 @@ void pnp_enable() {
// Enable KBC keyboard
pnp_write(0x07, 0x06);
#if EC_ESPI
#if CONFIG_BUS_ESPI
// When using eSPI, IRQ must be inverted and edge-triggered
pnp_write(0x71, 0x02);
#endif // EC_ESPI
#endif // CONFIG_BUS_ESPI
pnp_write(0x30, 0x01);
// Enable KBC mouse
pnp_write(0x07, 0x05);
#if EC_ESPI
#if CONFIG_BUS_ESPI
// When using eSPI, IRQ must be inverted and edge-triggered
pnp_write(0x71, 0x02);
#endif // EC_ESPI
#endif // CONFIG_BUS_ESPI
pnp_write(0x30, 0x01);
// Enable SMFI

View File

@ -17,8 +17,8 @@
#include <board/wireless.h>
#include <common/debug.h>
#include <ec/espi.h>
#if EC_ESPI
#if CONFIG_BUS_ESPI
#include <ec/espi.h>
#include <board/espi.h>
#endif
@ -244,9 +244,9 @@ void power_on(void) {
}
// Check for VW changes
#if EC_ESPI
#if CONFIG_BUS_ESPI
espi_event();
#endif // EC_ESPI
#endif // CONFIG_BUS_ESPI
// Extra wait until SUSPWRDNACK is valid
delay_ms(1);
@ -491,11 +491,11 @@ void power_event(void) {
#endif
if(rst_new && !rst_last) {
DEBUG("%02X: PLT_RST# de-asserted\n", main_cycle);
#if EC_ESPI
#if CONFIG_BUS_ESPI
espi_reset();
#else // EC_ESPI
#else // CONFIG_BUS_ESPI
power_cpu_reset();
#endif // EC_ESPI
#endif // CONFIG_BUS_ESPI
}
rst_last = rst_new;
@ -512,7 +512,7 @@ void power_event(void) {
#endif
#endif // HAVE_SLP_SUS_N
#if EC_ESPI
#if CONFIG_BUS_ESPI
// ESPI systems, always power off if in S5 power state
#elif HAVE_SUSWARN_N
// EC must keep VccPRIM powered if SUSPWRDNACK is de-asserted low or system

View File

@ -7,7 +7,7 @@ EC=ite
CONFIG_EC_ITE_IT5570E=y
# Enable eSPI
CFLAGS+=-DEC_ESPI=1
CONFIG_BUS_ESPI=y
# Use S0ix
CFLAGS+=-DUSE_S0IX=1

View File

@ -7,12 +7,12 @@ EC=ite
CONFIG_EC_ITE_IT5570E=y
# Enable eSPI
CFLAGS+=-DEC_ESPI=1
# Apply PMC hack for S0ix
CFLAGS+=-DPMC_S0IX_HACK=1
CONFIG_BUS_ESPI=y
# Use S0ix
CFLAGS+=-DUSE_S0IX=1
# Apply PMC hack for S0ix
CFLAGS+=-DPMC_S0IX_HACK=1
# Include keyboard
KEYBOARD=15in_102

View File

@ -7,7 +7,7 @@ EC=ite
CONFIG_EC_ITE_IT5570E=y
# Enable eSPI
CFLAGS+=-DEC_ESPI=1
CONFIG_BUS_ESPI=y
# Use S0ix
CFLAGS+=-DUSE_S0IX=1

View File

@ -7,7 +7,7 @@ EC=ite
CONFIG_EC_ITE_IT5570E=y
# Enable eSPI
CFLAGS+=-DEC_ESPI=1
CONFIG_BUS_ESPI=y
# Use S0ix
CFLAGS+=-DUSE_S0IX=1

View File

@ -7,7 +7,7 @@ EC=ite
CONFIG_EC_ITE_IT5570E=y
# Enable eSPI
CFLAGS+=-DEC_ESPI=1
CONFIG_BUS_ESPI=y
# Include keyboard
KEYBOARD=15in_102

View File

@ -7,7 +7,7 @@ EC=ite
CONFIG_EC_ITE_IT5570E=y
# Enable eSPI
CFLAGS+=-DEC_ESPI=1
CONFIG_BUS_ESPI=y
# Include keyboard
KEYBOARD=15in_102

View File

@ -7,7 +7,7 @@ EC=ite
CONFIG_EC_ITE_IT5570E=y
# Enable eSPI
CFLAGS+=-DEC_ESPI=1
CONFIG_BUS_ESPI=y
# FIXME: Use S3 instead of S0ix
CFLAGS+=-DUSE_S0IX=1

View File

@ -7,7 +7,7 @@ EC=ite
CONFIG_EC_ITE_IT5570E=y
# Enable eSPI
CFLAGS+=-DEC_ESPI=1
CONFIG_BUS_ESPI=y
# FIXME: Use S3 instead of S0ix
CFLAGS+=-DUSE_S0IX=1

View File

@ -7,7 +7,7 @@ EC=ite
CONFIG_EC_ITE_IT5570E=y
# Enable eSPI
CFLAGS+=-DEC_ESPI=1
CONFIG_BUS_ESPI=y
# Use S0ix
CFLAGS+=-DUSE_S0IX=1

View File

@ -7,7 +7,7 @@ EC=ite
CONFIG_EC_ITE_IT5570E=y
# Enable eSPI
CFLAGS+=-DEC_ESPI=1
CONFIG_BUS_ESPI=y
# Use S0ix
CFLAGS+=-DUSE_S0IX=1

View File

@ -7,7 +7,7 @@ EC=ite
CONFIG_EC_ITE_IT5570E=y
# Enable eSPI
CFLAGS+=-DEC_ESPI=1
CONFIG_BUS_ESPI=y
# Include keyboard
KEYBOARD=15in_102

View File

@ -7,7 +7,7 @@ EC=ite
CONFIG_EC_ITE_IT5570E=y
# Enable eSPI
CFLAGS+=-DEC_ESPI=1
CONFIG_BUS_ESPI=y
# FIXME: Use S3 instead of S0ix
CFLAGS+=-DUSE_S0IX=1

View File

@ -1,7 +1,7 @@
# SPDX-License-Identifier: GPL-3.0-only
ec-y += ec.c
ec-y += espi.c
ec-$(CONFIG_BUS_ESPI) += espi.c
ec-y += gpio.c
ec-y += i2c.c
ec-y += kbc.c

View File

@ -3,15 +3,8 @@
#ifndef _EC_ESPI_H
#define _EC_ESPI_H
// eSPI not supported on IT8587E, may not be used on IT5570E
#ifndef EC_ESPI
#define EC_ESPI 0
#endif
#include <stdint.h>
#if CONFIG_EC_ITE_IT5570E
struct VirtualWire {
volatile uint8_t __xdata * index;
uint8_t shift;
@ -126,6 +119,4 @@ volatile uint8_t __xdata __at(0x3293) VWCTRL3;
volatile uint8_t __xdata __at(0x3295) VWCTRL5;
volatile uint8_t __xdata __at(0x3296) VWCTRL6;
#endif // CONFIG_EC_ITE_IT5570E
#endif // _EC_ESPI_H

View File

@ -3,17 +3,17 @@
#include <ec/espi.h>
// clang-format off
#if EC_ESPI
#if CONFIG_BUS_ESPI
// eSPI signature (byte 7 = 0xA4)
static __code const uint8_t __at(0x40) SIGNATURE[16] = {
0xA5, 0xA5, 0xA5, 0xA5, 0xA5, 0xA5, 0xA4, 0x95,
0x85, 0x12, 0x5A, 0x5A, 0xAA, 0x00, 0x55, 0x55,
};
#else // EC_ESPI
#else // CONFIG_BUS_ESPI
// LPC signature (byte 7 = 0xA5)
static __code const uint8_t __at(0x40) SIGNATURE[16] = {
0xA5, 0xA5, 0xA5, 0xA5, 0xA5, 0xA5, 0xA5, 0x94,
0x85, 0x12, 0x5A, 0x5A, 0xAA, 0x00, 0x55, 0x55,
};
#endif // EC_ESPI
#endif // CONFIG_BUS_ESPI
// clang-format on