Skip to content

Commit 7c2478e

Browse files
Dino-Linashif
authored andcommitted
espi/it8xxx2: supports host command interrupt requested by custom opcode
Enables or disables host command interrupt when ECUSTOM_HOST_SUBS_INTERRUPT_EN opcode is requested. Signed-off-by: Dino Li <[email protected]>
1 parent 0facdd8 commit 7c2478e

File tree

1 file changed

+31
-5
lines changed

1 file changed

+31
-5
lines changed

drivers/espi/espi_it8xxx2.c

Lines changed: 31 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -503,7 +503,9 @@ static void pmc1_it8xxx2_init(const struct device *dev)
503503
pmc_reg->PM1CTL |= PMC_PM1CTL_IBFIE;
504504
IRQ_CONNECT(IT8XXX2_PMC1_IBF_IRQ, 0, pmc1_it8xxx2_ibf_isr,
505505
DEVICE_DT_INST_GET(0), 0);
506-
irq_enable(IT8XXX2_PMC1_IBF_IRQ);
506+
if (!IS_ENABLED(CONFIG_ESPI_PERIPHERAL_CUSTOM_OPCODE)) {
507+
irq_enable(IT8XXX2_PMC1_IBF_IRQ);
508+
}
507509
}
508510
#endif
509511

@@ -579,7 +581,9 @@ static void pmc2_it8xxx2_init(const struct device *dev)
579581
pmc_reg->PM2CTL |= PMC_PM2CTL_IBFIE;
580582
IRQ_CONNECT(IT8XXX2_PMC2_IBF_IRQ, 0, pmc2_it8xxx2_ibf_isr,
581583
DEVICE_DT_INST_GET(0), 0);
582-
irq_enable(IT8XXX2_PMC2_IBF_IRQ);
584+
if (!IS_ENABLED(CONFIG_ESPI_PERIPHERAL_CUSTOM_OPCODE)) {
585+
irq_enable(IT8XXX2_PMC2_IBF_IRQ);
586+
}
583587
}
584588
#endif
585589

@@ -744,6 +748,28 @@ static int espi_it8xxx2_receive_vwire(const struct device *dev,
744748
return 0;
745749
}
746750

751+
#ifdef CONFIG_ESPI_PERIPHERAL_CUSTOM_OPCODE
752+
static void host_custom_opcode_enable_interrupts(void)
753+
{
754+
if (IS_ENABLED(CONFIG_ESPI_PERIPHERAL_HOST_IO)) {
755+
irq_enable(IT8XXX2_PMC1_IBF_IRQ);
756+
}
757+
if (IS_ENABLED(CONFIG_ESPI_PERIPHERAL_EC_HOST_CMD)) {
758+
irq_enable(IT8XXX2_PMC2_IBF_IRQ);
759+
}
760+
}
761+
762+
static void host_custom_opcode_disable_interrupts(void)
763+
{
764+
if (IS_ENABLED(CONFIG_ESPI_PERIPHERAL_HOST_IO)) {
765+
irq_disable(IT8XXX2_PMC1_IBF_IRQ);
766+
}
767+
if (IS_ENABLED(CONFIG_ESPI_PERIPHERAL_EC_HOST_CMD)) {
768+
irq_disable(IT8XXX2_PMC2_IBF_IRQ);
769+
}
770+
}
771+
#endif /* CONFIG_ESPI_PERIPHERAL_CUSTOM_OPCODE */
772+
747773
static int espi_it8xxx2_manage_callback(const struct device *dev,
748774
struct espi_callback *callback, bool set)
749775
{
@@ -921,12 +947,12 @@ static int espi_it8xxx2_write_lpc_request(const struct device *dev,
921947
(struct pmc_regs *)config->base_pmc;
922948

923949
switch (op) {
924-
/* Enable/Disable PMC1 (port 62h/66h) interrupt */
950+
/* Enable/Disable PMCx interrupt */
925951
case ECUSTOM_HOST_SUBS_INTERRUPT_EN:
926952
if (*data) {
927-
irq_enable(IT8XXX2_PMC1_IBF_IRQ);
953+
host_custom_opcode_enable_interrupts();
928954
} else {
929-
irq_disable(IT8XXX2_PMC1_IBF_IRQ);
955+
host_custom_opcode_disable_interrupts();
930956
}
931957
break;
932958
case ECUSTOM_HOST_CMD_SEND_RESULT:

0 commit comments

Comments
 (0)