driver: bbram: npcx: fix the way to clear bbram status

Bits in the BBRAM status register (BKUP_STS) are write-1-to-clear bits.
The current driver writes 0 to clear those bits, which is incorrect.
Fix it in this commit.

Signed-off-by: Jun Lin <CHLin56@nuvoton.com>
This commit is contained in:
Jun Lin 2024-06-13 17:42:56 +08:00 committed by Alberto Escolar
parent 383b97b742
commit e555f20462
1 changed files with 9 additions and 1 deletions

View File

@ -26,8 +26,16 @@ static int get_bit_and_reset(const struct device *dev, int mask)
{
int result = DRV_STATUS(dev) & mask;
/* Clear the bit(s) */
/*
* Clear the bit(s):
* For emulator, write 0 to clear status bit(s).
* For real chip, write 1 to clear status bit(s).
*/
#ifdef CONFIG_BBRAM_NPCX_EMUL
DRV_STATUS(dev) &= ~mask;
#else
DRV_STATUS(dev) = mask;
#endif
return result;
}