Skip to content

Commit

Permalink
driver: eSPI: drop interrupts enabling during driver initialization
Browse files Browse the repository at this point in the history
Host interface interrupts should be enabled explicitly via eSPI API
after the eSPI configuration and callbacks are set.
If we enable them during driver initialization and the host sends a eSPI
transaction before the eSPI configuration and callbacks are set, we may
encounter unexpected behavior.

Signed-off-by: Jun Lin <[email protected]>
  • Loading branch information
ChiHuaL authored and carlescufi committed Oct 7, 2022
1 parent e049cc7 commit ea066d3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
9 changes: 6 additions & 3 deletions drivers/espi/espi_npcx.c
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,6 @@ static void espi_init_wui_callback(const struct device *dev,
/* Configure MIWU setting and enable its interrupt */
npcx_miwu_interrupt_configure(wui, NPCX_MIWU_MODE_EDGE,
NPCX_MIWU_TRIG_BOTH);
npcx_miwu_irq_enable(wui);
}

/* eSPI local bus interrupt service functions */
Expand Down Expand Up @@ -1120,7 +1119,7 @@ static int espi_npcx_flash_erase(const struct device *dev,
/* Platform specific espi module functions */
void npcx_espi_enable_interrupts(const struct device *dev)
{
ARG_UNUSED(dev);
const struct espi_npcx_config *const config = dev->config;

/* Enable eSPI bus interrupt */
irq_enable(DT_INST_IRQN(0));
Expand All @@ -1129,11 +1128,13 @@ void npcx_espi_enable_interrupts(const struct device *dev)
for (int idx = 0; idx < ARRAY_SIZE(vw_in_tbl); idx++) {
npcx_miwu_irq_enable(&(vw_in_tbl[idx].vw_wui));
}

npcx_miwu_irq_enable(&config->espi_rst_wui);
}

void npcx_espi_disable_interrupts(const struct device *dev)
{
ARG_UNUSED(dev);
const struct espi_npcx_config *const config = dev->config;

/* Disable eSPI bus interrupt */
irq_disable(DT_INST_IRQN(0));
Expand All @@ -1142,6 +1143,8 @@ void npcx_espi_disable_interrupts(const struct device *dev)
for (int idx = 0; idx < ARRAY_SIZE(vw_in_tbl); idx++) {
npcx_miwu_irq_disable(&(vw_in_tbl[idx].vw_wui));
}

npcx_miwu_irq_disable(&config->espi_rst_wui);
}

/* eSPI driver registration */
Expand Down
4 changes: 0 additions & 4 deletions drivers/espi/host_subs_npcx.c
Original file line number Diff line number Diff line change
Expand Up @@ -1061,13 +1061,11 @@ int npcx_host_init_subs_core_domain(const struct device *host_bus_dev,
DT_INST_IRQ_BY_NAME(0, kbc_ibf, priority),
host_kbc_ibf_isr,
NULL, 0);
irq_enable(DT_INST_IRQ_BY_NAME(0, kbc_ibf, irq));

IRQ_CONNECT(DT_INST_IRQ_BY_NAME(0, kbc_obe, irq),
DT_INST_IRQ_BY_NAME(0, kbc_obe, priority),
host_kbc_obe_isr,
NULL, 0);
irq_enable(DT_INST_IRQ_BY_NAME(0, kbc_obe, irq));
#endif

/* Host PM channel (Host IO) sub-device interrupt installation */
Expand All @@ -1077,7 +1075,6 @@ int npcx_host_init_subs_core_domain(const struct device *host_bus_dev,
DT_INST_IRQ_BY_NAME(0, pmch_ibf, priority),
host_pmch_ibf_isr,
NULL, 0);
irq_enable(DT_INST_IRQ_BY_NAME(0, pmch_ibf, irq));
#endif

/* Host Port80 sub-device interrupt installation */
Expand All @@ -1086,7 +1083,6 @@ int npcx_host_init_subs_core_domain(const struct device *host_bus_dev,
DT_INST_IRQ_BY_NAME(0, p80_fifo, priority),
host_port80_isr,
NULL, 0);
irq_enable(DT_INST_IRQ_BY_NAME(0, p80_fifo, irq));
#endif

if (IS_ENABLED(CONFIG_PM)) {
Expand Down

0 comments on commit ea066d3

Please sign in to comment.