From 861f1f2cc89de4b0280231f042e85b8557d46da7 Mon Sep 17 00:00:00 2001 From: Tim Crawford Date: Mon, 17 Oct 2022 10:12:06 -0600 Subject: [PATCH] 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. --- Makefile | 2 +- src/board/system76/addw1/board.mk | 2 +- src/board/system76/addw2/board.mk | 2 +- src/board/system76/bonw14/board.mk | 2 +- src/board/system76/common/pwm.c | 2 +- src/board/system76/darp5/board.mk | 2 +- src/board/system76/darp7/board.mk | 2 +- src/board/system76/darp8/board.mk | 2 +- src/board/system76/galp3-c/board.mk | 2 +- src/board/system76/galp5/board.mk | 2 +- src/board/system76/galp6/board.mk | 2 +- src/board/system76/gaze15/board.mk | 2 +- src/board/system76/gaze16-3050/board.mk | 2 +- src/board/system76/gaze16-3060/board.mk | 2 +- src/board/system76/gaze17-3050/board.mk | 2 +- src/board/system76/gaze17-3060/board.mk | 2 +- src/board/system76/lemp10/board.mk | 2 +- src/board/system76/lemp11/board.mk | 2 +- src/board/system76/lemp9/board.mk | 2 +- src/board/system76/oryp5/board.mk | 2 +- src/board/system76/oryp6/board.mk | 2 +- src/board/system76/oryp7/board.mk | 2 +- src/board/system76/oryp8/board.mk | 2 +- src/board/system76/oryp9/board.mk | 2 +- src/ec/ite/ec.c | 4 ++-- src/ec/ite/ec.mk | 10 ++++++---- src/ec/ite/espi.c | 4 ++-- src/ec/ite/i2c.c | 2 +- src/ec/ite/include/ec/espi.h | 4 ++-- src/ec/ite/include/ec/gctrl.h | 2 +- src/ec/ite/include/ec/gpio.h | 2 +- src/ec/ite/include/ec/i2c.h | 2 +- src/ec/ite/include/ec/pwm.h | 2 +- src/ec/ite/include/ec/scratch.h | 4 ++-- src/ec/ite/include/ec/smbus.h | 2 +- 35 files changed, 44 insertions(+), 42 deletions(-) diff --git a/Makefile b/Makefile index 23c7570..3b4b52d 100644 --- a/Makefile +++ b/Makefile @@ -43,7 +43,7 @@ SRC += $(foreach src, $(keyboard-y), $(KEYBOARD_DIR)/$(src)) # Include the embedded controller's source EC_DIR=src/ec/$(EC) 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 SRC += $(foreach src, $(ec-y), $(EC_DIR)/$(src)) diff --git a/src/board/system76/addw1/board.mk b/src/board/system76/addw1/board.mk index 15e9287..6ca8a8d 100644 --- a/src/board/system76/addw1/board.mk +++ b/src/board/system76/addw1/board.mk @@ -4,7 +4,7 @@ board-y += board.c board-y += gpio.c EC=ite -EC_VARIANT=it8587e +CONFIG_EC_ITE_IT8587E=y # Include keyboard KEYBOARD=15in_102 diff --git a/src/board/system76/addw2/board.mk b/src/board/system76/addw2/board.mk index e5cb595..171b83d 100644 --- a/src/board/system76/addw2/board.mk +++ b/src/board/system76/addw2/board.mk @@ -4,7 +4,7 @@ board-y += board.c board-y += gpio.c EC=ite -EC_VARIANT=it5570e +CONFIG_EC_ITE_IT5570E=y # Include keyboard KEYBOARD=15in_102 diff --git a/src/board/system76/bonw14/board.mk b/src/board/system76/bonw14/board.mk index 9873c6d..fd539d1 100644 --- a/src/board/system76/bonw14/board.mk +++ b/src/board/system76/bonw14/board.mk @@ -4,7 +4,7 @@ board-y += board.c board-y += gpio.c EC=ite -EC_VARIANT=it5570e +CONFIG_EC_ITE_IT5570E=y # Include keyboard KEYBOARD=15in_102_nkey diff --git a/src/board/system76/common/pwm.c b/src/board/system76/common/pwm.c index 77d049f..4135913 100644 --- a/src/board/system76/common/pwm.c +++ b/src/board/system76/common/pwm.c @@ -26,7 +26,7 @@ void pwm_init(void) { // Turn off CPU fan (temperature control in peci_get_fan_duty) DCR2 = 0; -#ifdef it5570e +#if CONFIG_EC_ITE_IT5570E // Reload counters when they reach 0 instead of immediately PWMLCCR = 0xFF; #endif diff --git a/src/board/system76/darp5/board.mk b/src/board/system76/darp5/board.mk index 6a83799..ab1cc00 100644 --- a/src/board/system76/darp5/board.mk +++ b/src/board/system76/darp5/board.mk @@ -4,7 +4,7 @@ board-y += board.c board-y += gpio.c EC=ite -EC_VARIANT=it8587e +CONFIG_EC_ITE_IT8587E=y # Include keyboard KEYBOARD=15in_102 diff --git a/src/board/system76/darp7/board.mk b/src/board/system76/darp7/board.mk index e2180e1..cf67eca 100644 --- a/src/board/system76/darp7/board.mk +++ b/src/board/system76/darp7/board.mk @@ -4,7 +4,7 @@ board-y += board.c board-y += gpio.c EC=ite -EC_VARIANT=it5570e +CONFIG_EC_ITE_IT5570E=y # Enable eSPI CFLAGS+=-DEC_ESPI=1 diff --git a/src/board/system76/darp8/board.mk b/src/board/system76/darp8/board.mk index 1b19bbc..7c393ad 100644 --- a/src/board/system76/darp8/board.mk +++ b/src/board/system76/darp8/board.mk @@ -4,7 +4,7 @@ board-y += board.c board-y += gpio.c EC=ite -EC_VARIANT=it5570e +CONFIG_EC_ITE_IT5570E=y # Enable eSPI CFLAGS+=-DEC_ESPI=1 diff --git a/src/board/system76/galp3-c/board.mk b/src/board/system76/galp3-c/board.mk index cf9bc94..b74a8c7 100644 --- a/src/board/system76/galp3-c/board.mk +++ b/src/board/system76/galp3-c/board.mk @@ -4,7 +4,7 @@ board-y += board.c board-y += gpio.c EC=ite -EC_VARIANT=it8587e +CONFIG_EC_ITE_IT8587E=y # Include keyboard KEYBOARD=14in_86 diff --git a/src/board/system76/galp5/board.mk b/src/board/system76/galp5/board.mk index 5fc2623..f4a6945 100644 --- a/src/board/system76/galp5/board.mk +++ b/src/board/system76/galp5/board.mk @@ -4,7 +4,7 @@ board-y += board.c board-y += gpio.c EC=ite -EC_VARIANT=it5570e +CONFIG_EC_ITE_IT5570E=y # Enable eSPI CFLAGS+=-DEC_ESPI=1 diff --git a/src/board/system76/galp6/board.mk b/src/board/system76/galp6/board.mk index 1ff1318..d354272 100644 --- a/src/board/system76/galp6/board.mk +++ b/src/board/system76/galp6/board.mk @@ -4,7 +4,7 @@ board-y += board.c board-y += gpio.c EC=ite -EC_VARIANT=it5570e +CONFIG_EC_ITE_IT5570E=y # Enable eSPI CFLAGS+=-DEC_ESPI=1 diff --git a/src/board/system76/gaze15/board.mk b/src/board/system76/gaze15/board.mk index 18ebb7b..8c4cb9f 100644 --- a/src/board/system76/gaze15/board.mk +++ b/src/board/system76/gaze15/board.mk @@ -4,7 +4,7 @@ board-y += board.c board-y += gpio.c EC=ite -EC_VARIANT=it5570e +CONFIG_EC_ITE_IT5570E=y # Include keyboard KEYBOARD=15in_102 diff --git a/src/board/system76/gaze16-3050/board.mk b/src/board/system76/gaze16-3050/board.mk index d0028a0..1fe95e7 100644 --- a/src/board/system76/gaze16-3050/board.mk +++ b/src/board/system76/gaze16-3050/board.mk @@ -4,7 +4,7 @@ board-y += board.c board-y += gpio.c EC=ite -EC_VARIANT=it5570e +CONFIG_EC_ITE_IT5570E=y # Enable eSPI CFLAGS+=-DEC_ESPI=1 diff --git a/src/board/system76/gaze16-3060/board.mk b/src/board/system76/gaze16-3060/board.mk index 406620e..7625e15 100644 --- a/src/board/system76/gaze16-3060/board.mk +++ b/src/board/system76/gaze16-3060/board.mk @@ -4,7 +4,7 @@ board-y += board.c board-y += gpio.c EC=ite -EC_VARIANT=it5570e +CONFIG_EC_ITE_IT5570E=y # Enable eSPI CFLAGS+=-DEC_ESPI=1 diff --git a/src/board/system76/gaze17-3050/board.mk b/src/board/system76/gaze17-3050/board.mk index 1e90add..10c17d7 100644 --- a/src/board/system76/gaze17-3050/board.mk +++ b/src/board/system76/gaze17-3050/board.mk @@ -4,7 +4,7 @@ board-y += board.c board-y += gpio.c EC=ite -EC_VARIANT=it5570e +CONFIG_EC_ITE_IT5570E=y # Enable eSPI CFLAGS+=-DEC_ESPI=1 diff --git a/src/board/system76/gaze17-3060/board.mk b/src/board/system76/gaze17-3060/board.mk index 0de8278..f1161d8 100644 --- a/src/board/system76/gaze17-3060/board.mk +++ b/src/board/system76/gaze17-3060/board.mk @@ -4,7 +4,7 @@ board-y += board.c board-y += gpio.c EC=ite -EC_VARIANT=it5570e +CONFIG_EC_ITE_IT5570E=y # Enable eSPI CFLAGS+=-DEC_ESPI=1 diff --git a/src/board/system76/lemp10/board.mk b/src/board/system76/lemp10/board.mk index 612fba8..a1accd6 100644 --- a/src/board/system76/lemp10/board.mk +++ b/src/board/system76/lemp10/board.mk @@ -4,7 +4,7 @@ board-y += board.c board-y += gpio.c EC=ite -EC_VARIANT=it5570e +CONFIG_EC_ITE_IT5570E=y # Enable eSPI CFLAGS+=-DEC_ESPI=1 diff --git a/src/board/system76/lemp11/board.mk b/src/board/system76/lemp11/board.mk index 7fd4134..07273fd 100644 --- a/src/board/system76/lemp11/board.mk +++ b/src/board/system76/lemp11/board.mk @@ -4,7 +4,7 @@ board-y += board.c board-y += gpio.c EC=ite -EC_VARIANT=it5570e +CONFIG_EC_ITE_IT5570E=y # Enable eSPI CFLAGS+=-DEC_ESPI=1 diff --git a/src/board/system76/lemp9/board.mk b/src/board/system76/lemp9/board.mk index 0d6c5c7..2ec0ec0 100644 --- a/src/board/system76/lemp9/board.mk +++ b/src/board/system76/lemp9/board.mk @@ -4,7 +4,7 @@ board-y += board.c board-y += gpio.c EC=ite -EC_VARIANT=it5570e +CONFIG_EC_ITE_IT5570E=y # Include keyboard KEYBOARD=14in_83 diff --git a/src/board/system76/oryp5/board.mk b/src/board/system76/oryp5/board.mk index 36c0d45..d4ed478 100644 --- a/src/board/system76/oryp5/board.mk +++ b/src/board/system76/oryp5/board.mk @@ -4,7 +4,7 @@ board-y += board.c board-y += gpio.c EC=ite -EC_VARIANT=it8587e +CONFIG_EC_ITE_IT8587E=y # Include keyboard KEYBOARD=15in_102 diff --git a/src/board/system76/oryp6/board.mk b/src/board/system76/oryp6/board.mk index e5508c4..0da4fa2 100644 --- a/src/board/system76/oryp6/board.mk +++ b/src/board/system76/oryp6/board.mk @@ -4,7 +4,7 @@ board-y += board.c board-y += gpio.c EC=ite -EC_VARIANT=it5570e +CONFIG_EC_ITE_IT5570E=y # Include keyboard KEYBOARD=15in_102 diff --git a/src/board/system76/oryp7/board.mk b/src/board/system76/oryp7/board.mk index e5508c4..0da4fa2 100644 --- a/src/board/system76/oryp7/board.mk +++ b/src/board/system76/oryp7/board.mk @@ -4,7 +4,7 @@ board-y += board.c board-y += gpio.c EC=ite -EC_VARIANT=it5570e +CONFIG_EC_ITE_IT5570E=y # Include keyboard KEYBOARD=15in_102 diff --git a/src/board/system76/oryp8/board.mk b/src/board/system76/oryp8/board.mk index a5d9239..b4772f7 100644 --- a/src/board/system76/oryp8/board.mk +++ b/src/board/system76/oryp8/board.mk @@ -4,7 +4,7 @@ board-y += board.c board-y += gpio.c EC=ite -EC_VARIANT=it5570e +CONFIG_EC_ITE_IT5570E=y # Enable eSPI CFLAGS+=-DEC_ESPI=1 diff --git a/src/board/system76/oryp9/board.mk b/src/board/system76/oryp9/board.mk index c0301b0..ca3b85d 100644 --- a/src/board/system76/oryp9/board.mk +++ b/src/board/system76/oryp9/board.mk @@ -4,7 +4,7 @@ board-y += board.c board-y += gpio.c EC=ite -EC_VARIANT=it5570e +CONFIG_EC_ITE_IT5570E=y # Enable eSPI CFLAGS+=-DEC_ESPI=1 diff --git a/src/ec/ite/ec.c b/src/ec/ite/ec.c index a8d077e..8e43d0a 100644 --- a/src/ec/ite/ec.c +++ b/src/ec/ite/ec.c @@ -6,7 +6,7 @@ #include void ec_init(void) { -#ifdef it8587e +#if CONFIG_EC_ITE_IT8587E RSTS = (0b10U << 6) | BIT(2); #else RSTS = (0b01U << 6) | BIT(2); @@ -17,7 +17,7 @@ void ec_init(void) { } void ec_read_post_codes(void) { -#ifdef it5570e +#if CONFIG_EC_ITE_IT5570E while (P80H81HS & 1) { uint8_t p80h = P80HD; uint8_t p81h = P81HD; diff --git a/src/ec/ite/ec.mk b/src/ec/ite/ec.mk index 8eb07ca..168ed46 100644 --- a/src/ec/ite/ec.mk +++ b/src/ec/ite/ec.mk @@ -9,16 +9,18 @@ ec-y += pmc.c ec-y += ps2.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_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 # 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 else -$(error Unsupported EC: $(EC_VARIANT)) +$(error Unsupported EC) endif ARCH=8051 diff --git a/src/ec/ite/espi.c b/src/ec/ite/espi.c index d923756..9c56c71 100644 --- a/src/ec/ite/espi.c +++ b/src/ec/ite/espi.c @@ -2,7 +2,7 @@ #include -#ifdef it5570e +#if CONFIG_EC_ITE_IT5570E // Not all wires are defined or implemented // Index 2 - AP to EC @@ -63,4 +63,4 @@ void vw_set(struct VirtualWire * vw, enum VirtualWireState state) __critical { *vw->index = index; } -#endif // it5570e +#endif // CONFIG_EC_ITE_IT5570E diff --git a/src/ec/ite/i2c.c b/src/ec/ite/i2c.c index a75bd05..26d0c15 100644 --- a/src/ec/ite/i2c.c +++ b/src/ec/ite/i2c.c @@ -32,7 +32,7 @@ struct I2C __code I2C_1 = { .trasla = TRASLAB, }; -#ifdef it5570e +#if CONFIG_EC_ITE_IT5570E struct I2C __code I2C_4 = { .hosta = HOSTAE, .hoctl = HOCTLE, diff --git a/src/ec/ite/include/ec/espi.h b/src/ec/ite/include/ec/espi.h index b4b6954..5110577 100644 --- a/src/ec/ite/include/ec/espi.h +++ b/src/ec/ite/include/ec/espi.h @@ -10,7 +10,7 @@ #include -#ifdef it5570e +#if CONFIG_EC_ITE_IT5570E struct VirtualWire { 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(0x3296) VWCTRL6; -#endif // it5570e +#endif // CONFIG_EC_ITE_IT5570E #endif // _EC_ESPI_H diff --git a/src/ec/ite/include/ec/gctrl.h b/src/ec/ite/include/ec/gctrl.h index 8f9c507..ba2b79b 100644 --- a/src/ec/ite/include/ec/gctrl.h +++ b/src/ec/ite/include/ec/gctrl.h @@ -8,7 +8,7 @@ volatile uint8_t __xdata __at(0x2006) RSTS; volatile uint8_t __xdata __at(0x200A) BADRSEL; 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(0x2031) P80HD; volatile uint8_t __xdata __at(0x2032) P81HD; diff --git a/src/ec/ite/include/ec/gpio.h b/src/ec/ite/include/ec/gpio.h index 4a9c1e2..e9c3d88 100644 --- a/src/ec/ite/include/ec/gpio.h +++ b/src/ec/ite/include/ec/gpio.h @@ -52,7 +52,7 @@ volatile uint8_t __xdata __at(0x16FE) GCR15; volatile uint8_t __xdata __at(0x16E0) GCR16; volatile uint8_t __xdata __at(0x16E1) GCR17; 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(0x16E5) GCR20; volatile uint8_t __xdata __at(0x16E6) GCR21; diff --git a/src/ec/ite/include/ec/i2c.h b/src/ec/ite/include/ec/i2c.h index f3ce5d8..10227a7 100644 --- a/src/ec/ite/include/ec/i2c.h +++ b/src/ec/ite/include/ec/i2c.h @@ -7,7 +7,7 @@ extern struct I2C __code I2C_0; extern struct I2C __code I2C_1; -#ifdef it5570e +#if CONFIG_EC_ITE_IT5570E extern struct I2C __code I2C_4; #endif diff --git a/src/ec/ite/include/ec/pwm.h b/src/ec/ite/include/ec/pwm.h index 6676a0c..43b96fb 100644 --- a/src/ec/ite/include/ec/pwm.h +++ b/src/ec/ite/include/ec/pwm.h @@ -62,7 +62,7 @@ volatile uint8_t __xdata __at(0x1823) ZTIER; // Tachometer switch control register volatile uint8_t __xdata __at(0x1848) TSWCTLR; -#ifdef it5570e +#if CONFIG_EC_ITE_IT5570E // PWM Load Counter Control Register volatile uint8_t __xdata __at(0x185A) PWMLCCR; #endif diff --git a/src/ec/ite/include/ec/scratch.h b/src/ec/ite/include/ec/scratch.h index da3d82f..518a53d 100644 --- a/src/ec/ite/include/ec/scratch.h +++ b/src/ec/ite/include/ec/scratch.h @@ -9,14 +9,14 @@ volatile uint8_t __xdata __at(0x1040) SCAR0L; volatile uint8_t __xdata __at(0x1041) SCAR0M; volatile uint8_t __xdata __at(0x1042) SCAR0H; -#ifdef it8587e +#if CONFIG_EC_ITE_IT8587E // SCAR1 is in xram at 0x800-0xC00 volatile uint8_t __xdata __at(0x1043) SCAR1L; volatile uint8_t __xdata __at(0x1044) SCAR1M; volatile uint8_t __xdata __at(0x1045) SCAR1H; #endif -#ifdef it8587e +#if CONFIG_EC_ITE_IT8587E #define SCARL SCAR1L #define SCARM SCAR1M #define SCARH SCAR1H diff --git a/src/ec/ite/include/ec/smbus.h b/src/ec/ite/include/ec/smbus.h index 6727dcd..75d0b40 100644 --- a/src/ec/ite/include/ec/smbus.h +++ b/src/ec/ite/include/ec/smbus.h @@ -95,7 +95,7 @@ volatile uint8_t __xdata __at(0x1C44) RESLADR2B; // SMCLK timing setting for channel B volatile uint8_t __xdata __at(0x1C41) SCLKTSB; -#ifdef it5570e +#if CONFIG_EC_ITE_IT5570E // Host status for channel E volatile uint8_t __xdata __at(0x1CA0) HOSTAE; // Host control for channel E