blob: 6fac7ffc1def2c4d20cbe05f4c046dcb5e9ab596 [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001/* SPDX-License-Identifier: GPL-2.0+ */
maxims@google.comf57bd002017-01-18 13:44:55 -08002/*
3 * (C) Copyright 2016 Google, Inc
maxims@google.comf57bd002017-01-18 13:44:55 -08004 */
5
6#ifndef _ASM_ARCH_WDT_H
7#define _ASM_ARCH_WDT_H
8
9#define WDT_BASE 0x1e785000
10
11/*
12 * Special value that needs to be written to counter_restart register to
13 * (re)start the timer
14 */
15#define WDT_COUNTER_RESTART_VAL 0x4755
16
17/* Control register */
18#define WDT_CTRL_RESET_MODE_SHIFT 5
19#define WDT_CTRL_RESET_MODE_MASK 3
20
21#define WDT_CTRL_EN (1 << 0)
22#define WDT_CTRL_RESET (1 << 1)
23#define WDT_CTRL_CLK1MHZ (1 << 4)
24#define WDT_CTRL_2ND_BOOT (1 << 7)
25
26/* Values for Reset Mode */
27#define WDT_CTRL_RESET_SOC 0
28#define WDT_CTRL_RESET_CHIP 1
29#define WDT_CTRL_RESET_CPU 2
30#define WDT_CTRL_RESET_MASK 3
31
32/* Reset Mask register */
33#define WDT_RESET_ARM (1 << 0)
34#define WDT_RESET_COPROC (1 << 1)
35#define WDT_RESET_SDRAM (1 << 2)
36#define WDT_RESET_AHB (1 << 3)
37#define WDT_RESET_I2C (1 << 4)
38#define WDT_RESET_MAC1 (1 << 5)
39#define WDT_RESET_MAC2 (1 << 6)
40#define WDT_RESET_GCRT (1 << 7)
41#define WDT_RESET_USB20 (1 << 8)
42#define WDT_RESET_USB11_HOST (1 << 9)
43#define WDT_RESET_USB11_EHCI2 (1 << 10)
44#define WDT_RESET_VIDEO (1 << 11)
45#define WDT_RESET_HAC (1 << 12)
46#define WDT_RESET_LPC (1 << 13)
47#define WDT_RESET_SDSDIO (1 << 14)
48#define WDT_RESET_MIC (1 << 15)
49#define WDT_RESET_CRT2C (1 << 16)
50#define WDT_RESET_PWM (1 << 17)
51#define WDT_RESET_PECI (1 << 18)
52#define WDT_RESET_JTAG (1 << 19)
53#define WDT_RESET_ADC (1 << 20)
54#define WDT_RESET_GPIO (1 << 21)
55#define WDT_RESET_MCTP (1 << 22)
56#define WDT_RESET_XDMA (1 << 23)
57#define WDT_RESET_SPI (1 << 24)
58#define WDT_RESET_MISC (1 << 25)
59
Cédric Le Goatercb466db2018-10-16 13:57:11 +020060#define WDT_RESET_DEFAULT \
61 (WDT_RESET_ARM | WDT_RESET_COPROC | WDT_RESET_I2C | \
62 WDT_RESET_MAC1 | WDT_RESET_MAC2 | WDT_RESET_GCRT | \
63 WDT_RESET_USB20 | WDT_RESET_USB11_HOST | WDT_RESET_USB11_EHCI2 | \
64 WDT_RESET_VIDEO | WDT_RESET_HAC | WDT_RESET_LPC | \
65 WDT_RESET_SDSDIO | WDT_RESET_MIC | WDT_RESET_CRT2C | \
66 WDT_RESET_PWM | WDT_RESET_PECI | WDT_RESET_JTAG | \
67 WDT_RESET_ADC | WDT_RESET_GPIO | WDT_RESET_MISC)
68
maxims@google.comf57bd002017-01-18 13:44:55 -080069#ifndef __ASSEMBLY__
70struct ast_wdt {
71 u32 counter_status;
72 u32 counter_reload_val;
73 u32 counter_restart;
74 u32 ctrl;
75 u32 timeout_status;
76 u32 clr_timeout_status;
77 u32 reset_width;
maxims@google.comdf35df22017-04-17 12:00:22 -070078 /* On pre-ast2500 SoCs this register is reserved. */
maxims@google.comf57bd002017-01-18 13:44:55 -080079 u32 reset_mask;
maxims@google.comf57bd002017-01-18 13:44:55 -080080};
81
maxims@google.comdf35df22017-04-17 12:00:22 -070082/**
83 * Given flags parameter passed to wdt_reset or wdt_start uclass functions,
84 * gets Reset Mode value from it.
85 *
86 * @flags: flags parameter passed into wdt_reset or wdt_start
Heinrich Schuchardt47b4c022022-01-19 18:05:50 +010087 * Return: Reset Mode value
maxims@google.comdf35df22017-04-17 12:00:22 -070088 */
89u32 ast_reset_mode_from_flags(ulong flags);
90
91/**
92 * Given flags parameter passed to wdt_reset or wdt_start uclass functions,
93 * gets Reset Mask value from it. Reset Mask is only supported on ast2500
94 *
95 * @flags: flags parameter passed into wdt_reset or wdt_start
Heinrich Schuchardt47b4c022022-01-19 18:05:50 +010096 * Return: Reset Mask value
maxims@google.comdf35df22017-04-17 12:00:22 -070097 */
98u32 ast_reset_mask_from_flags(ulong flags);
99
100/**
101 * Given Reset Mask and Reset Mode values, converts them to flags,
102 * suitable for passing into wdt_start or wdt_reset uclass functions.
103 *
104 * On ast2500 Reset Mask is 25 bits wide and Reset Mode is 2 bits wide, so they
105 * can both be packed into single 32 bits wide value.
106 *
107 * @reset_mode: Reset Mode
108 * @reset_mask: Reset Mask
109 */
110ulong ast_flags_from_reset_mode_mask(u32 reset_mode, u32 reset_mask);
maxims@google.comf57bd002017-01-18 13:44:55 -0800111#endif /* __ASSEMBLY__ */
112
113#endif /* _ASM_ARCH_WDT_H */