Skip to content

Commit 5835928

Browse files
Wealian Liaonashif
authored andcommitted
drivers: watchdog: npcx: mask the WDRST_STS when accessing T0CSR
Register T0CSR bit 4 is WDRST_STS which is used to check whether the chip has watchdog reset from the last power-up or vcc1_rst. WDRST_STS hardware is design to write one clear. For the original read-modify-write, it will reset the WDRST_STS unexpected. Add a mask to avoid it. Signed-off-by: Wealian Liao <[email protected]>
1 parent a31bd15 commit 5835928

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

drivers/watchdog/wdt_npcx.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,8 @@ static inline void wdt_t0out_reload(const struct device *dev)
8888

8989
key = irq_lock();
9090
/* Reload and restart T0 timer */
91-
inst->T0CSR |= BIT(NPCX_T0CSR_RST);
91+
inst->T0CSR = (inst->T0CSR & ~BIT(NPCX_T0CSR_WDRST_STS)) |
92+
BIT(NPCX_T0CSR_RST);
9293
/* Wait for timer is loaded and restart */
9394
while (IS_BIT_SET(inst->T0CSR, NPCX_T0CSR_RST))
9495
;
@@ -312,8 +313,8 @@ static int wdt_npcx_init(const struct device *dev)
312313
inst->TWCFG = BIT(NPCX_TWCFG_WDSDME) | BIT(NPCX_TWCFG_WDCT0I);
313314

314315
/* Disable early touch functionality */
315-
inst->T0CSR |= BIT(NPCX_T0CSR_TESDIS);
316-
316+
inst->T0CSR = (inst->T0CSR & ~BIT(NPCX_T0CSR_WDRST_STS)) |
317+
BIT(NPCX_T0CSR_TESDIS);
317318
/*
318319
* Plan clock frequency of T0 timer and watchdog timer as below:
319320
* - T0 Timer freq is LFCLK/32 Hz

0 commit comments

Comments
 (0)