make: Add config for each ITE EC

EC_VARIANT is only used on AVR as a parameter to avrdude.

Replace its use on ITE with 2 choices:

- CONFIG_EC_ITE_IT8587E
- CONFIG_EC_ITE_IT5570E

Replace the EC defines with a matching define for the variable.
This commit is contained in:
Tim Crawford
2022-10-17 10:12:06 -06:00
committed by Tim Crawford
parent ac9631f948
commit 861f1f2cc8
35 changed files with 44 additions and 42 deletions

View File

@ -43,7 +43,7 @@ SRC += $(foreach src, $(keyboard-y), $(KEYBOARD_DIR)/$(src))
# Include the embedded controller's source # Include the embedded controller's source
EC_DIR=src/ec/$(EC) EC_DIR=src/ec/$(EC)
INCLUDE+=$(wildcard $(EC_DIR)/include/ec/*.h) $(EC_DIR)/ec.mk INCLUDE+=$(wildcard $(EC_DIR)/include/ec/*.h) $(EC_DIR)/ec.mk
CFLAGS+=-I$(EC_DIR)/include -D__EC__=$(EC_VARIANT) -D$(EC_VARIANT) CFLAGS+=-I$(EC_DIR)/include
include $(EC_DIR)/ec.mk include $(EC_DIR)/ec.mk
SRC += $(foreach src, $(ec-y), $(EC_DIR)/$(src)) SRC += $(foreach src, $(ec-y), $(EC_DIR)/$(src))

View File

@ -4,7 +4,7 @@ board-y += board.c
board-y += gpio.c board-y += gpio.c
EC=ite EC=ite
EC_VARIANT=it8587e CONFIG_EC_ITE_IT8587E=y
# Include keyboard # Include keyboard
KEYBOARD=15in_102 KEYBOARD=15in_102

View File

@ -4,7 +4,7 @@ board-y += board.c
board-y += gpio.c board-y += gpio.c
EC=ite EC=ite
EC_VARIANT=it5570e CONFIG_EC_ITE_IT5570E=y
# Include keyboard # Include keyboard
KEYBOARD=15in_102 KEYBOARD=15in_102

View File

@ -4,7 +4,7 @@ board-y += board.c
board-y += gpio.c board-y += gpio.c
EC=ite EC=ite
EC_VARIANT=it5570e CONFIG_EC_ITE_IT5570E=y
# Include keyboard # Include keyboard
KEYBOARD=15in_102_nkey KEYBOARD=15in_102_nkey

View File

@ -26,7 +26,7 @@ void pwm_init(void) {
// Turn off CPU fan (temperature control in peci_get_fan_duty) // Turn off CPU fan (temperature control in peci_get_fan_duty)
DCR2 = 0; DCR2 = 0;
#ifdef it5570e #if CONFIG_EC_ITE_IT5570E
// Reload counters when they reach 0 instead of immediately // Reload counters when they reach 0 instead of immediately
PWMLCCR = 0xFF; PWMLCCR = 0xFF;
#endif #endif

View File

@ -4,7 +4,7 @@ board-y += board.c
board-y += gpio.c board-y += gpio.c
EC=ite EC=ite
EC_VARIANT=it8587e CONFIG_EC_ITE_IT8587E=y
# Include keyboard # Include keyboard
KEYBOARD=15in_102 KEYBOARD=15in_102

View File

@ -4,7 +4,7 @@ board-y += board.c
board-y += gpio.c board-y += gpio.c
EC=ite EC=ite
EC_VARIANT=it5570e CONFIG_EC_ITE_IT5570E=y
# Enable eSPI # Enable eSPI
CFLAGS+=-DEC_ESPI=1 CFLAGS+=-DEC_ESPI=1

View File

@ -4,7 +4,7 @@ board-y += board.c
board-y += gpio.c board-y += gpio.c
EC=ite EC=ite
EC_VARIANT=it5570e CONFIG_EC_ITE_IT5570E=y
# Enable eSPI # Enable eSPI
CFLAGS+=-DEC_ESPI=1 CFLAGS+=-DEC_ESPI=1

View File

@ -4,7 +4,7 @@ board-y += board.c
board-y += gpio.c board-y += gpio.c
EC=ite EC=ite
EC_VARIANT=it8587e CONFIG_EC_ITE_IT8587E=y
# Include keyboard # Include keyboard
KEYBOARD=14in_86 KEYBOARD=14in_86

View File

@ -4,7 +4,7 @@ board-y += board.c
board-y += gpio.c board-y += gpio.c
EC=ite EC=ite
EC_VARIANT=it5570e CONFIG_EC_ITE_IT5570E=y
# Enable eSPI # Enable eSPI
CFLAGS+=-DEC_ESPI=1 CFLAGS+=-DEC_ESPI=1

View File

@ -4,7 +4,7 @@ board-y += board.c
board-y += gpio.c board-y += gpio.c
EC=ite EC=ite
EC_VARIANT=it5570e CONFIG_EC_ITE_IT5570E=y
# Enable eSPI # Enable eSPI
CFLAGS+=-DEC_ESPI=1 CFLAGS+=-DEC_ESPI=1

View File

@ -4,7 +4,7 @@ board-y += board.c
board-y += gpio.c board-y += gpio.c
EC=ite EC=ite
EC_VARIANT=it5570e CONFIG_EC_ITE_IT5570E=y
# Include keyboard # Include keyboard
KEYBOARD=15in_102 KEYBOARD=15in_102

View File

@ -4,7 +4,7 @@ board-y += board.c
board-y += gpio.c board-y += gpio.c
EC=ite EC=ite
EC_VARIANT=it5570e CONFIG_EC_ITE_IT5570E=y
# Enable eSPI # Enable eSPI
CFLAGS+=-DEC_ESPI=1 CFLAGS+=-DEC_ESPI=1

View File

@ -4,7 +4,7 @@ board-y += board.c
board-y += gpio.c board-y += gpio.c
EC=ite EC=ite
EC_VARIANT=it5570e CONFIG_EC_ITE_IT5570E=y
# Enable eSPI # Enable eSPI
CFLAGS+=-DEC_ESPI=1 CFLAGS+=-DEC_ESPI=1

View File

@ -4,7 +4,7 @@ board-y += board.c
board-y += gpio.c board-y += gpio.c
EC=ite EC=ite
EC_VARIANT=it5570e CONFIG_EC_ITE_IT5570E=y
# Enable eSPI # Enable eSPI
CFLAGS+=-DEC_ESPI=1 CFLAGS+=-DEC_ESPI=1

View File

@ -4,7 +4,7 @@ board-y += board.c
board-y += gpio.c board-y += gpio.c
EC=ite EC=ite
EC_VARIANT=it5570e CONFIG_EC_ITE_IT5570E=y
# Enable eSPI # Enable eSPI
CFLAGS+=-DEC_ESPI=1 CFLAGS+=-DEC_ESPI=1

View File

@ -4,7 +4,7 @@ board-y += board.c
board-y += gpio.c board-y += gpio.c
EC=ite EC=ite
EC_VARIANT=it5570e CONFIG_EC_ITE_IT5570E=y
# Enable eSPI # Enable eSPI
CFLAGS+=-DEC_ESPI=1 CFLAGS+=-DEC_ESPI=1

View File

@ -4,7 +4,7 @@ board-y += board.c
board-y += gpio.c board-y += gpio.c
EC=ite EC=ite
EC_VARIANT=it5570e CONFIG_EC_ITE_IT5570E=y
# Enable eSPI # Enable eSPI
CFLAGS+=-DEC_ESPI=1 CFLAGS+=-DEC_ESPI=1

View File

@ -4,7 +4,7 @@ board-y += board.c
board-y += gpio.c board-y += gpio.c
EC=ite EC=ite
EC_VARIANT=it5570e CONFIG_EC_ITE_IT5570E=y
# Include keyboard # Include keyboard
KEYBOARD=14in_83 KEYBOARD=14in_83

View File

@ -4,7 +4,7 @@ board-y += board.c
board-y += gpio.c board-y += gpio.c
EC=ite EC=ite
EC_VARIANT=it8587e CONFIG_EC_ITE_IT8587E=y
# Include keyboard # Include keyboard
KEYBOARD=15in_102 KEYBOARD=15in_102

View File

@ -4,7 +4,7 @@ board-y += board.c
board-y += gpio.c board-y += gpio.c
EC=ite EC=ite
EC_VARIANT=it5570e CONFIG_EC_ITE_IT5570E=y
# Include keyboard # Include keyboard
KEYBOARD=15in_102 KEYBOARD=15in_102

View File

@ -4,7 +4,7 @@ board-y += board.c
board-y += gpio.c board-y += gpio.c
EC=ite EC=ite
EC_VARIANT=it5570e CONFIG_EC_ITE_IT5570E=y
# Include keyboard # Include keyboard
KEYBOARD=15in_102 KEYBOARD=15in_102

View File

@ -4,7 +4,7 @@ board-y += board.c
board-y += gpio.c board-y += gpio.c
EC=ite EC=ite
EC_VARIANT=it5570e CONFIG_EC_ITE_IT5570E=y
# Enable eSPI # Enable eSPI
CFLAGS+=-DEC_ESPI=1 CFLAGS+=-DEC_ESPI=1

View File

@ -4,7 +4,7 @@ board-y += board.c
board-y += gpio.c board-y += gpio.c
EC=ite EC=ite
EC_VARIANT=it5570e CONFIG_EC_ITE_IT5570E=y
# Enable eSPI # Enable eSPI
CFLAGS+=-DEC_ESPI=1 CFLAGS+=-DEC_ESPI=1

View File

@ -6,7 +6,7 @@
#include <common/macro.h> #include <common/macro.h>
void ec_init(void) { void ec_init(void) {
#ifdef it8587e #if CONFIG_EC_ITE_IT8587E
RSTS = (0b10U << 6) | BIT(2); RSTS = (0b10U << 6) | BIT(2);
#else #else
RSTS = (0b01U << 6) | BIT(2); RSTS = (0b01U << 6) | BIT(2);
@ -17,7 +17,7 @@ void ec_init(void) {
} }
void ec_read_post_codes(void) { void ec_read_post_codes(void) {
#ifdef it5570e #if CONFIG_EC_ITE_IT5570E
while (P80H81HS & 1) { while (P80H81HS & 1) {
uint8_t p80h = P80HD; uint8_t p80h = P80HD;
uint8_t p81h = P81HD; uint8_t p81h = P81HD;

View File

@ -9,16 +9,18 @@ ec-y += pmc.c
ec-y += ps2.c ec-y += ps2.c
ec-y += signature.c ec-y += signature.c
ifeq ($(EC_VARIANT), it8587e) ifeq ($(CONFIG_EC_ITE_IT8587E), y)
CFLAGS+=-DCONFIG_EC_ITE_IT8587E=1
# SRAM is 4096 bytes, but SRAM at address 2048 is used for scratch ROM # SRAM is 4096 bytes, but SRAM at address 2048 is used for scratch ROM
SRAM_SIZE=2048 SRAM_SIZE=2048
else ifeq ($(EC_VARIANT), it5570e) else ifeq ($(CONFIG_EC_ITE_IT5570E), y)
CFLAGS+=-DCONFIG_EC_ITE_IT5570E=1
# SRAM is 6144 bytes, only 4096 bytes are mapped at address 0. Region at # SRAM is 6144 bytes, only 4096 bytes are mapped at address 0. Region at
# 0x0E00-0x1000 is used for AP communication. So this is brought down to 2048, # 0x0E00-0x1000 is used for AP communication. So this is brought down to 2048,
# which matches it8587e limits # which matches IT8587E limits
SRAM_SIZE=2048 SRAM_SIZE=2048
else else
$(error Unsupported EC: $(EC_VARIANT)) $(error Unsupported EC)
endif endif
ARCH=8051 ARCH=8051

View File

@ -2,7 +2,7 @@
#include <ec/espi.h> #include <ec/espi.h>
#ifdef it5570e #if CONFIG_EC_ITE_IT5570E
// Not all wires are defined or implemented // Not all wires are defined or implemented
// Index 2 - AP to EC // Index 2 - AP to EC
@ -63,4 +63,4 @@ void vw_set(struct VirtualWire * vw, enum VirtualWireState state) __critical {
*vw->index = index; *vw->index = index;
} }
#endif // it5570e #endif // CONFIG_EC_ITE_IT5570E

View File

@ -32,7 +32,7 @@ struct I2C __code I2C_1 = {
.trasla = TRASLAB, .trasla = TRASLAB,
}; };
#ifdef it5570e #if CONFIG_EC_ITE_IT5570E
struct I2C __code I2C_4 = { struct I2C __code I2C_4 = {
.hosta = HOSTAE, .hosta = HOSTAE,
.hoctl = HOCTLE, .hoctl = HOCTLE,

View File

@ -10,7 +10,7 @@
#include <stdint.h> #include <stdint.h>
#ifdef it5570e #if CONFIG_EC_ITE_IT5570E
struct VirtualWire { struct VirtualWire {
volatile uint8_t __xdata * index; volatile uint8_t __xdata * index;
@ -126,6 +126,6 @@ volatile uint8_t __xdata __at(0x3293) VWCTRL3;
volatile uint8_t __xdata __at(0x3295) VWCTRL5; volatile uint8_t __xdata __at(0x3295) VWCTRL5;
volatile uint8_t __xdata __at(0x3296) VWCTRL6; volatile uint8_t __xdata __at(0x3296) VWCTRL6;
#endif // it5570e #endif // CONFIG_EC_ITE_IT5570E
#endif // _EC_ESPI_H #endif // _EC_ESPI_H

View File

@ -8,7 +8,7 @@
volatile uint8_t __xdata __at(0x2006) RSTS; volatile uint8_t __xdata __at(0x2006) RSTS;
volatile uint8_t __xdata __at(0x200A) BADRSEL; volatile uint8_t __xdata __at(0x200A) BADRSEL;
volatile uint8_t __xdata __at(0x200D) SPCTRL1; volatile uint8_t __xdata __at(0x200D) SPCTRL1;
#ifdef it5570e #if CONFIG_EC_ITE_IT5570E
volatile uint8_t __xdata __at(0x2030) P80H81HS; volatile uint8_t __xdata __at(0x2030) P80H81HS;
volatile uint8_t __xdata __at(0x2031) P80HD; volatile uint8_t __xdata __at(0x2031) P80HD;
volatile uint8_t __xdata __at(0x2032) P81HD; volatile uint8_t __xdata __at(0x2032) P81HD;

View File

@ -52,7 +52,7 @@ volatile uint8_t __xdata __at(0x16FE) GCR15;
volatile uint8_t __xdata __at(0x16E0) GCR16; volatile uint8_t __xdata __at(0x16E0) GCR16;
volatile uint8_t __xdata __at(0x16E1) GCR17; volatile uint8_t __xdata __at(0x16E1) GCR17;
volatile uint8_t __xdata __at(0x16E2) GCR18; volatile uint8_t __xdata __at(0x16E2) GCR18;
#ifdef it5570e #if CONFIG_EC_ITE_IT5570E
volatile uint8_t __xdata __at(0x16E4) GCR19; volatile uint8_t __xdata __at(0x16E4) GCR19;
volatile uint8_t __xdata __at(0x16E5) GCR20; volatile uint8_t __xdata __at(0x16E5) GCR20;
volatile uint8_t __xdata __at(0x16E6) GCR21; volatile uint8_t __xdata __at(0x16E6) GCR21;

View File

@ -7,7 +7,7 @@
extern struct I2C __code I2C_0; extern struct I2C __code I2C_0;
extern struct I2C __code I2C_1; extern struct I2C __code I2C_1;
#ifdef it5570e #if CONFIG_EC_ITE_IT5570E
extern struct I2C __code I2C_4; extern struct I2C __code I2C_4;
#endif #endif

View File

@ -62,7 +62,7 @@ volatile uint8_t __xdata __at(0x1823) ZTIER;
// Tachometer switch control register // Tachometer switch control register
volatile uint8_t __xdata __at(0x1848) TSWCTLR; volatile uint8_t __xdata __at(0x1848) TSWCTLR;
#ifdef it5570e #if CONFIG_EC_ITE_IT5570E
// PWM Load Counter Control Register // PWM Load Counter Control Register
volatile uint8_t __xdata __at(0x185A) PWMLCCR; volatile uint8_t __xdata __at(0x185A) PWMLCCR;
#endif #endif

View File

@ -9,14 +9,14 @@
volatile uint8_t __xdata __at(0x1040) SCAR0L; volatile uint8_t __xdata __at(0x1040) SCAR0L;
volatile uint8_t __xdata __at(0x1041) SCAR0M; volatile uint8_t __xdata __at(0x1041) SCAR0M;
volatile uint8_t __xdata __at(0x1042) SCAR0H; volatile uint8_t __xdata __at(0x1042) SCAR0H;
#ifdef it8587e #if CONFIG_EC_ITE_IT8587E
// SCAR1 is in xram at 0x800-0xC00 // SCAR1 is in xram at 0x800-0xC00
volatile uint8_t __xdata __at(0x1043) SCAR1L; volatile uint8_t __xdata __at(0x1043) SCAR1L;
volatile uint8_t __xdata __at(0x1044) SCAR1M; volatile uint8_t __xdata __at(0x1044) SCAR1M;
volatile uint8_t __xdata __at(0x1045) SCAR1H; volatile uint8_t __xdata __at(0x1045) SCAR1H;
#endif #endif
#ifdef it8587e #if CONFIG_EC_ITE_IT8587E
#define SCARL SCAR1L #define SCARL SCAR1L
#define SCARM SCAR1M #define SCARM SCAR1M
#define SCARH SCAR1H #define SCARH SCAR1H

View File

@ -95,7 +95,7 @@ volatile uint8_t __xdata __at(0x1C44) RESLADR2B;
// SMCLK timing setting for channel B // SMCLK timing setting for channel B
volatile uint8_t __xdata __at(0x1C41) SCLKTSB; volatile uint8_t __xdata __at(0x1C41) SCLKTSB;
#ifdef it5570e #if CONFIG_EC_ITE_IT5570E
// Host status for channel E // Host status for channel E
volatile uint8_t __xdata __at(0x1CA0) HOSTAE; volatile uint8_t __xdata __at(0x1CA0) HOSTAE;
// Host control for channel E // Host control for channel E