Skip to content

Commit 6a340f6

Browse files
GTLin08jhedberg
authored andcommitted
drivers/espi: it8xxx2: Add a config to share h2ram pool space
The h2ram is an independent 4KB section. With default settings of CONFIG_ESPI_PERIPHERAL_HOST_CMD_PARAM_PORT_NUM and CONFIG_ESPI_PERIPHERAL_ACPI_SHM_REGION_PORT_NUM, There is a 2KB gap that is unused. This change was made to make unused gap can be reused by other modules to reduce overall RAM usage. Signed-off-by: Tim Lin <tim2.lin@ite.corp-partner.google.com>
1 parent 3b2b513 commit 6a340f6

File tree

2 files changed

+24
-2
lines changed

2 files changed

+24
-2
lines changed

drivers/espi/Kconfig.it8xxx2

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,4 +145,20 @@ config ESPI_IT8XXX2_PORT_81_CYCLE
145145
This allows EC to accept 2 bytes of port 80 data written from the Host.
146146
(e.g. using iotools: iotools io_write16 0x80 0x1234)
147147

148+
config ESPI_IT8XXX2_H2RAM_SHARED
149+
bool "Shared access to h2ram_pool"
150+
help
151+
Enabling this option exposes the eSPI driver h2ram_pool as a
152+
global symbol (non-static), allowing other modules to reuse
153+
this memory space.
154+
The configurations CONFIG_ESPI_PERIPHERAL_HOST_CMD_PARAM_PORT_NUM and
155+
CONFIG_ESPI_PERIPHERAL_ACPI_SHM_REGION_PORT_NUM have a gap in RAM space.
156+
By enabling CONFIG_ESPI_IT8XXX2_H2RAM_SHARED, this unused gap can be
157+
reused by other modules to reduce overall RAM usage.
158+
159+
NOTE: A build-time assertion must ensure that the shared region size
160+
does not exceed the available space defined by
161+
CONFIG_ESPI_PERIPHERAL_HOST_CMD_PARAM_PORT_NUM and
162+
CONFIG_ESPI_PERIPHERAL_ACPI_SHM_REGION_PORT_NUM.
163+
148164
endif #ESPI_IT8XXX2

drivers/espi/espi_it8xxx2.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -948,8 +948,14 @@ static const struct ec2i_t pmc2_settings[] = {
948948
#endif
949949
#endif
950950

951-
static uint8_t h2ram_pool[MAX(H2RAM_ACPI_SHM_MAX, H2RAM_EC_HOST_CMD_MAX)]
952-
__attribute__((section(".h2ram_pool")));
951+
#ifdef CONFIG_ESPI_IT8XXX2_H2RAM_SHARED
952+
#define H2RAM_STORAGE
953+
#else
954+
#define H2RAM_STORAGE static
955+
#endif
956+
957+
H2RAM_STORAGE uint8_t h2ram_pool[MAX(H2RAM_ACPI_SHM_MAX, H2RAM_EC_HOST_CMD_MAX)]
958+
__attribute__((section(".h2ram_pool")));
953959

954960
#define H2RAM_WINDOW_SIZE(ram_size) ((find_msb_set((ram_size) / 16) - 1) & 0x7)
955961

0 commit comments

Comments
 (0)