Skip to content

Commit f76f292

Browse files
Dino-Linashif
authored andcommitted
espi/it8xxx2: enable EC to accept port 81 cycle
This allows EC to accept 2 bytes of port 80 data written from the Host. Signed-off-by: Dino Li <[email protected]>
1 parent 64a373f commit f76f292

File tree

3 files changed

+29
-3
lines changed

3 files changed

+29
-3
lines changed

drivers/espi/Kconfig.it8xxx2

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,4 +127,19 @@ config ESPI_IT8XXX2_PNPCFG_DEVICE_KBC_MOUSE
127127
With this option enabled, EC will send IRQ12 signal to host when the
128128
KBC mouse output buffer is full.
129129

130+
# On IT8xxx2 series, this configuration option has limitation:
131+
# Port 80 and 81 I/O cycles share the same interrupt source and there is no
132+
# status bit to indicate which cycle triggered the interrupt and data registers
133+
# of these two ports are read only. Hence EC have to read these two data
134+
# registers at the same time in the ISR.
135+
# It means that the Host must alwasy write 2 bytes of data to port 80 otherwise
136+
# port 81 data will not be updated.
137+
config ESPI_IT8XXX2_PORT_81_CYCLE
138+
bool "EC accepts 0x81 I/O cycle from eSPI transaction"
139+
depends on ESPI_PERIPHERAL_DEBUG_PORT_80
140+
help
141+
With this option enabled, EC will accept 0x81 I/O cycle from the Host.
142+
This allows EC to accept 2 bytes of port 80 data written from the Host.
143+
(e.g. using iotools: iotools io_write16 0x80 0x1234)
144+
130145
endif #ESPI_IT8XXX2

drivers/espi/espi_it8xxx2.c

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -517,7 +517,11 @@ static void port80_it8xxx2_isr(const struct device *dev)
517517
ESPI_PERIPHERAL_NODATA
518518
};
519519

520-
evt.evt_data = gctrl->GCTRL_P80HDR;
520+
if (IS_ENABLED(CONFIG_ESPI_IT8XXX2_PORT_81_CYCLE)) {
521+
evt.evt_data = gctrl->GCTRL_P80HDR | (gctrl->GCTRL_P81HDR << 8);
522+
} else {
523+
evt.evt_data = gctrl->GCTRL_P80HDR;
524+
}
521525
/* Write 1 to clear this bit */
522526
gctrl->GCTRL_P80H81HSR |= BIT(0);
523527

@@ -529,8 +533,13 @@ static void port80_it8xxx2_init(const struct device *dev)
529533
ARG_UNUSED(dev);
530534
struct gctrl_it8xxx2_regs *const gctrl = ESPI_IT8XXX2_GET_GCTRL_BASE;
531535

532-
/* Accept Port 80h Cycle */
533-
gctrl->GCTRL_SPCTRL1 |= IT8XXX2_GCTRL_ACP80;
536+
/* Accept Port 80h (and 81h) Cycle */
537+
if (IS_ENABLED(CONFIG_ESPI_IT8XXX2_PORT_81_CYCLE)) {
538+
gctrl->GCTRL_SPCTRL1 |=
539+
(IT8XXX2_GCTRL_ACP80 | IT8XXX2_GCTRL_ACP81);
540+
} else {
541+
gctrl->GCTRL_SPCTRL1 |= IT8XXX2_GCTRL_ACP80;
542+
}
534543
IRQ_CONNECT(IT8XXX2_PORT_80_IRQ, 0, port80_it8xxx2_isr,
535544
DEVICE_DT_INST_GET(0), 0);
536545
irq_enable(IT8XXX2_PORT_80_IRQ);

soc/ite/ec/common/chip_chipregs.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1661,6 +1661,8 @@ struct gctrl_it8xxx2_regs {
16611661
#define IT8XXX2_GCTRL_ILM0_ENABLE BIT(0)
16621662
/* Accept Port 80h Cycle */
16631663
#define IT8XXX2_GCTRL_ACP80 BIT(6)
1664+
/* Accept Port 81h Cycle */
1665+
#define IT8XXX2_GCTRL_ACP81 BIT(3)
16641666
/* USB Debug Enable */
16651667
#define IT8XXX2_GCTRL_MCCR_USB_EN BIT(7)
16661668
/* USB Pad Power-On Enable */

0 commit comments

Comments
 (0)