Skip to content

Commit 51978d9

Browse files
ChiHuaLcarlescufi
authored andcommitted
driver: eSPI: npcx: workaround the errata rev1_2, No.3.10
Enabling an eSPI channel (r.g. Peripheral Channel, Virtual Wire Channel, etc.) during an eSPI transaction might (with low probability) cause the eSPI_SIF module to transition to a wrong state and therefore response with FATAL_ERROR on an incoming transaction. This CL workarounds this issue by clearing the bit 4 of NPCX eSPI specific register#2. Signed-off-by: Jun Lin <[email protected]>
1 parent 8a4aeeb commit 51978d9

File tree

4 files changed

+37
-7
lines changed

4 files changed

+37
-7
lines changed

drivers/espi/Kconfig.npcx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,17 @@ config ESPI_NPCX_PERIPHERAL_HOST_CMD_PARAM_SIZE
3030
Please notice the valid value in npcx ec series for this option is
3131
8/16/32/64/128/256/512/1024/2048/4096 bytes.
3232

33+
config ESPI_NPCX_BYPASS_CH_ENABLE_FATAL_ERROR
34+
bool
35+
depends on SOC_SERIES_NPCX7 || SOC_SERIES_NPCX9
36+
default y
37+
help
38+
Workaround the issue documented in NPCX99nF errata rev1_2, No.3.10.
39+
Enabling an eSPI channel during an eSPI transaction might
40+
(with low probability) cause the eSPI_SIF module to transition to
41+
a wrong state and therefore response with FATAL_ERROR on an incoming
42+
transaction.
43+
3344
# The default value 'y' for the existing options if ESPI_NPCX is selected.
3445
if ESPI_NPCX
3546

drivers/espi/espi_npcx.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -865,6 +865,14 @@ static int espi_npcx_init(const struct device *dev)
865865
return ret;
866866
}
867867

868+
if (IS_ENABLED(CONFIG_ESPI_NPCX_BYPASS_CH_ENABLE_FATAL_ERROR)) {
869+
/* Enable the access to the NPCX_ONLY_ESPI_REG2 register */
870+
inst->NPCX_ONLY_ESPI_REG1 = NPCX_ONLY_ESPI_REG1_UNLOCK_REG2;
871+
inst->NPCX_ONLY_ESPI_REG2 &= ~BIT(NPCX_ONLY_ESPI_REG2_TRANS_END_CONFIG);
872+
/* Disable the access to the NPCX_ONLY_ESPI_REG2 register */
873+
inst->NPCX_ONLY_ESPI_REG1 = NPCX_ONLY_ESPI_REG1_LOCK_REG2;
874+
}
875+
868876
/* Enable events which share the same espi bus interrupt */
869877
for (i = 0; i < ARRAY_SIZE(espi_bus_isr_tbl); i++) {
870878
inst->ESPIIE |= BIT(espi_bus_isr_tbl[i].int_en_bit);

soc/arm/nuvoton_npcx/common/reg/reg_def.h

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -636,29 +636,36 @@ struct espi_reg {
636636
volatile uint32_t PERCFG;
637637
/* 0x04C: Peripheral Channel Control */
638638
volatile uint32_t PERCTL;
639-
volatile uint32_t reserved2[44];
639+
/* 0x050: Status Image Register */
640+
volatile uint16_t STATUS_IMG;
641+
volatile uint16_t reserved2[79];
642+
/* 0x0F0: NPCX specific eSPI Register1 */
643+
volatile uint8_t NPCX_ONLY_ESPI_REG1;
644+
/* 0x0F1: NPCX specific eSPI Register2 */
645+
volatile uint8_t NPCX_ONLY_ESPI_REG2;
646+
volatile uint16_t reserved3[7];
640647
/* 0x100 - 127: Virtual Wire Event Slave-to-Master 0 - 9 */
641648
volatile uint32_t VWEVSM[10];
642-
volatile uint32_t reserved3[6];
649+
volatile uint32_t reserved4[6];
643650
/* 0x140 - 16F: Virtual Wire Event Master-to-Slave 0 - 11 */
644651
volatile uint32_t VWEVMS[12];
645-
volatile uint32_t reserved4[99];
652+
volatile uint32_t reserved5[99];
646653
/* 0x2FC: Virtual Wire Channel Control */
647654
volatile uint32_t VWCTL;
648655
/* 0x300 - 34F: OOB Receive Buffer 0 - 19 */
649656
volatile uint32_t OOBRXBUF[20];
650-
volatile uint32_t reserved5[12];
657+
volatile uint32_t reserved6[12];
651658
/* 0x380 - 3CF: OOB Transmit Buffer 0-19 */
652659
volatile uint32_t OOBTXBUF[20];
653-
volatile uint32_t reserved6[11];
660+
volatile uint32_t reserved7[11];
654661
/* 0x3FC: OOB Channel Control used in 'direct' mode */
655662
volatile uint32_t OOBCTL_DIRECT;
656663
/* 0x400 - 443: Flash Receive Buffer 0-16 */
657664
volatile uint32_t FLASHRXBUF[17];
658-
volatile uint32_t reserved7[15];
665+
volatile uint32_t reserved8[15];
659666
/* 0x480 - 497: Flash Transmit Buffer 0-5 */
660667
volatile uint32_t FLASHTXBUF[6];
661-
volatile uint32_t reserved8[25];
668+
volatile uint32_t reserved9[25];
662669
/* 0x4FC: Flash Channel Control used in 'direct' mode */
663670
volatile uint32_t FLASHCTL_DIRECT;
664671
};
@@ -753,6 +760,9 @@ struct espi_reg {
753760
#define NPCX_FLASHCTL_CHKSUMSEL 15
754761
#define NPCX_FLASHCTL_AMTEN 16
755762

763+
#define NPCX_ONLY_ESPI_REG1_UNLOCK_REG2 0x55
764+
#define NPCX_ONLY_ESPI_REG1_LOCK_REG2 0
765+
#define NPCX_ONLY_ESPI_REG2_TRANS_END_CONFIG 4
756766
/*
757767
* Mobile System Wake-Up Control (MSWC) device registers
758768
*/

soc/arm/nuvoton_npcx/common/registers.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ NPCX_REG_OFFSET_CHECK(twd_reg, WDCP, 0x010);
6464
/* ESPI register structure check */
6565
NPCX_REG_SIZE_CHECK(espi_reg, 0x500);
6666
NPCX_REG_OFFSET_CHECK(espi_reg, FLASHCFG, 0x034);
67+
NPCX_REG_OFFSET_CHECK(espi_reg, NPCX_ONLY_ESPI_REG1, 0x0f0);
6768
NPCX_REG_OFFSET_CHECK(espi_reg, VWEVMS, 0x140);
6869
NPCX_REG_OFFSET_CHECK(espi_reg, VWCTL, 0x2fc);
6970
NPCX_REG_OFFSET_CHECK(espi_reg, OOBTXBUF, 0x380);

0 commit comments

Comments
 (0)