Skip to content

Commit a60d88e

Browse files
ChiHuaLkartben
authored andcommitted
drivers: bbram: npcx: bypass npcx49nf errata rev1.5 No.2.30
This commit workarounds the BBRAM status register write issue in npcx4: A write operation to the BKUP_STS register might disable write to all the Battery-Backed RAM (BBRM). The workaround is to perform a fake read from the BKUP_STS register after every write to this register. Signed-off-by: Jun Lin <[email protected]>
1 parent dbd1449 commit a60d88e

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

drivers/bbram/Kconfig.npcx

+9
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,12 @@ config BBRAM_NPCX_EMUL
1515
depends on EMUL
1616
help
1717
Enable the emulator for the NPCX BBRAM.
18+
19+
config BBRAM_NPCX_STATUS_REG_WRITE_WORKAROUND
20+
bool
21+
default y if SOC_SERIES_NPCX4
22+
help
23+
Workaround the issue documented in NPCX49nF errata rev1_5, No.2.30.
24+
A write operation to the BKUP_STS register might disable write to all
25+
the Battery-Backed RAM. The workaround is to read the BKUP_STS
26+
register after every write to this register.

drivers/bbram/bbram_npcx.c

+6-1
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,12 @@ static int get_bit_and_reset(const struct device *dev, int mask)
3535
DRV_STATUS(dev) &= ~mask;
3636
#else
3737
DRV_STATUS(dev) = mask;
38+
39+
if (IS_ENABLED(CONFIG_BBRAM_NPCX_STATUS_REG_WRITE_WORKAROUND)) {
40+
uint8_t __unused read_unused;
41+
42+
read_unused = DRV_STATUS(dev);
43+
}
3844
#endif
3945

4046
return result;
@@ -72,7 +78,6 @@ static int bbram_npcx_read(const struct device *dev, size_t offset, size_t size,
7278
return -EINVAL;
7379
}
7480

75-
7681
bytecpy(data, ((uint8_t *)config->base_addr + offset), size);
7782
return 0;
7883
}

0 commit comments

Comments
 (0)