xref: /rk3399_ARM-atf/plat/imx/common/include/imx_wdog.h (revision 1dcc28cfbac5dae3992ad9581f9ea68f6cb339c1)
1 /*
2  * Copyright (c) 2018, ARM Limited and Contributors. All rights reserved.
3  *
4  * SPDX-License-Identifier: BSD-3-Clause
5  */
6 
7 #ifndef __IMX_WDOG_H__
8 #define __IMX_WDOG_H__
9 
10 #include <arch.h>
11 #include <stdint.h>
12 
13 struct wdog_regs {
14 	uint16_t wcr;
15 	uint16_t wsr;
16 	uint16_t wrsr;
17 	uint16_t wicr;
18 	uint16_t wmcr;
19 };
20 
21 /* WCR bits */
22 #define WCR_WDZST		BIT(0)
23 #define WCR_WDBG		BIT(1)
24 #define WCR_WDE			BIT(2)
25 #define WCR_WDT			BIT(3)
26 #define WCR_SRS			BIT(4)
27 #define WCR_WDA			BIT(5)
28 #define WCR_SRE			BIT(6)
29 #define WCR_WDW			BIT(7)
30 #define WCR_WT(x)		((x) << 8)
31 
32 /* WSR bits */
33 #define WSR_FIRST		0x5555
34 #define WSR_SECOND		0xAAAA
35 
36 /* WRSR bits */
37 #define WRSR_SFTW		BIT(0)
38 #define WRSR_TOUT		BIT(1)
39 #define WRSR_POR		BIT(4)
40 
41 /* WICR bits */
42 static inline int wicr_calc_wict(int sec, int half_sec)
43 {
44 	int wict_bits;
45 
46 	/* Represents WICR bits 7 - 0 */
47 	wict_bits = ((sec << 1) | (half_sec ? 1 : 0));
48 
49 	return wict_bits;
50 }
51 
52 #define WICR_WTIS		BIT(14)
53 #define WICR_WIE		BIT(15)
54 
55 /* WMCR bits */
56 #define WMCR_PDE		BIT(0)
57 
58 /* External facing API */
59 void imx_wdog_init(void);
60 
61 #endif /* __IMX_WDOG_H__ */
62