-
Notifications
You must be signed in to change notification settings - Fork 73
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enable system WDT with timeout of 8s
Enable WDT to ensure the system: - Does not hang processing any task, such as previous cases of PECI commands never completing. - Does not take longer than the timeout period to complete all outstanding tasks. A timeout of 8s is used to remain close to the existing use of the WDT in scratch ROM, which was set to 10s. Signed-off-by: Tim Crawford <[email protected]>
- Loading branch information
Showing
7 changed files
with
80 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
// SPDX-License-Identifier: GPL-3.0-only | ||
|
||
// External Timer and External Watchdog (ETWD) | ||
|
||
#include <ec/etwd.h> | ||
#include <common/macro.h> | ||
|
||
enum EwtCfg { | ||
// Lock EWTCFG register | ||
LETWCFG = BIT(0), | ||
// Lock ET1PS register | ||
LETPS1 = BIT(1), | ||
// Lock ET1CNTLx registers | ||
LET1CNTL = BIT(2), | ||
// Lock EWDCNTLx registers | ||
LEWDCNTL = BIT(3), | ||
// External WDT clock source | ||
EWDSRC = BIT(4), | ||
// Enable key match function to touch the WDT | ||
EWDKEYEN = BIT(5), | ||
// Lock ET1 and EWDT registers | ||
LOCK_ALL = LETWCFG | LETPS1 | LET1CNTL | LEWDCNTL, | ||
}; | ||
|
||
enum EtwdPrescaler { | ||
ETWD_PRESCALER_32768_HZ = 0, | ||
ETWD_PRESCALER_1024_HZ = 1, | ||
ETWD_PRESCALER_32_HZ = 2, | ||
ETWD_PRESCALER_EC_CLK = 3, // Not available for ET1PS | ||
}; | ||
|
||
void wdt_init(void) { | ||
ET1PSR = ETWD_PRESCALER_1024_HZ; | ||
ETWCFG = EWDKEYEN | EWDSRC; | ||
|
||
// Start ET1 so EWDT can be started | ||
ET1CNTLLR = 0xFF; | ||
|
||
// Start EWDT with timeout of 8s | ||
// TODO: Determine time based on system performance or requirement | ||
EWDCNTLHR = 0x20; | ||
EWDCNTLLR = 0; | ||
|
||
ETWCFG |= LOCK_ALL; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters