14697abeaSmaxims@google.com /* 24697abeaSmaxims@google.com * (C) Copyright 2016 Google, Inc 34697abeaSmaxims@google.com * 44697abeaSmaxims@google.com * SPDX-License-Identifier: GPL-2.0+ 54697abeaSmaxims@google.com */ 64697abeaSmaxims@google.com 74697abeaSmaxims@google.com #ifndef _ASM_ARCH_WDT_H 84697abeaSmaxims@google.com #define _ASM_ARCH_WDT_H 94697abeaSmaxims@google.com 104697abeaSmaxims@google.com #define WDT_BASE 0x1e785000 114697abeaSmaxims@google.com 124697abeaSmaxims@google.com /* 134697abeaSmaxims@google.com * Special value that needs to be written to counter_restart register to 144697abeaSmaxims@google.com * (re)start the timer 154697abeaSmaxims@google.com */ 164697abeaSmaxims@google.com #define WDT_COUNTER_RESTART_VAL 0x4755 174697abeaSmaxims@google.com 184697abeaSmaxims@google.com /* Control register */ 194697abeaSmaxims@google.com #define WDT_CTRL_RESET_MODE_SHIFT 5 204697abeaSmaxims@google.com #define WDT_CTRL_RESET_MODE_MASK 3 214697abeaSmaxims@google.com 224697abeaSmaxims@google.com #define WDT_CTRL_EN (1 << 0) 234697abeaSmaxims@google.com #define WDT_CTRL_RESET (1 << 1) 244697abeaSmaxims@google.com #define WDT_CTRL_CLK1MHZ (1 << 4) 254697abeaSmaxims@google.com #define WDT_CTRL_2ND_BOOT (1 << 7) 264697abeaSmaxims@google.com 274697abeaSmaxims@google.com /* Values for Reset Mode */ 284697abeaSmaxims@google.com #define WDT_CTRL_RESET_SOC 0 294697abeaSmaxims@google.com #define WDT_CTRL_RESET_CHIP 1 304697abeaSmaxims@google.com #define WDT_CTRL_RESET_CPU 2 314697abeaSmaxims@google.com #define WDT_CTRL_RESET_MASK 3 324697abeaSmaxims@google.com 334697abeaSmaxims@google.com /* Reset Mask register */ 344697abeaSmaxims@google.com #define WDT_RESET_ARM (1 << 0) 354697abeaSmaxims@google.com #define WDT_RESET_COPROC (1 << 1) 364697abeaSmaxims@google.com #define WDT_RESET_SDRAM (1 << 2) 374697abeaSmaxims@google.com #define WDT_RESET_AHB (1 << 3) 384697abeaSmaxims@google.com #define WDT_RESET_I2C (1 << 4) 394697abeaSmaxims@google.com #define WDT_RESET_MAC1 (1 << 5) 404697abeaSmaxims@google.com #define WDT_RESET_MAC2 (1 << 6) 414697abeaSmaxims@google.com #define WDT_RESET_GCRT (1 << 7) 424697abeaSmaxims@google.com #define WDT_RESET_USB20 (1 << 8) 434697abeaSmaxims@google.com #define WDT_RESET_USB11_HOST (1 << 9) 444697abeaSmaxims@google.com #define WDT_RESET_USB11_EHCI2 (1 << 10) 454697abeaSmaxims@google.com #define WDT_RESET_VIDEO (1 << 11) 464697abeaSmaxims@google.com #define WDT_RESET_HAC (1 << 12) 474697abeaSmaxims@google.com #define WDT_RESET_LPC (1 << 13) 484697abeaSmaxims@google.com #define WDT_RESET_SDSDIO (1 << 14) 494697abeaSmaxims@google.com #define WDT_RESET_MIC (1 << 15) 504697abeaSmaxims@google.com #define WDT_RESET_CRT2C (1 << 16) 514697abeaSmaxims@google.com #define WDT_RESET_PWM (1 << 17) 524697abeaSmaxims@google.com #define WDT_RESET_PECI (1 << 18) 534697abeaSmaxims@google.com #define WDT_RESET_JTAG (1 << 19) 544697abeaSmaxims@google.com #define WDT_RESET_ADC (1 << 20) 554697abeaSmaxims@google.com #define WDT_RESET_GPIO (1 << 21) 564697abeaSmaxims@google.com #define WDT_RESET_MCTP (1 << 22) 574697abeaSmaxims@google.com #define WDT_RESET_XDMA (1 << 23) 584697abeaSmaxims@google.com #define WDT_RESET_SPI (1 << 24) 594697abeaSmaxims@google.com #define WDT_RESET_MISC (1 << 25) 604697abeaSmaxims@google.com 614697abeaSmaxims@google.com #ifndef __ASSEMBLY__ 624697abeaSmaxims@google.com struct ast_wdt { 634697abeaSmaxims@google.com u32 counter_status; 644697abeaSmaxims@google.com u32 counter_reload_val; 654697abeaSmaxims@google.com u32 counter_restart; 664697abeaSmaxims@google.com u32 ctrl; 674697abeaSmaxims@google.com u32 timeout_status; 684697abeaSmaxims@google.com u32 clr_timeout_status; 694697abeaSmaxims@google.com u32 reset_width; 70*1eb0a464Smaxims@google.com /* On pre-ast2500 SoCs this register is reserved. */ 714697abeaSmaxims@google.com u32 reset_mask; 724697abeaSmaxims@google.com }; 734697abeaSmaxims@google.com 74*1eb0a464Smaxims@google.com /** 75*1eb0a464Smaxims@google.com * Given flags parameter passed to wdt_reset or wdt_start uclass functions, 76*1eb0a464Smaxims@google.com * gets Reset Mode value from it. 77*1eb0a464Smaxims@google.com * 78*1eb0a464Smaxims@google.com * @flags: flags parameter passed into wdt_reset or wdt_start 79*1eb0a464Smaxims@google.com * @return Reset Mode value 80*1eb0a464Smaxims@google.com */ 81*1eb0a464Smaxims@google.com u32 ast_reset_mode_from_flags(ulong flags); 82*1eb0a464Smaxims@google.com 83*1eb0a464Smaxims@google.com /** 84*1eb0a464Smaxims@google.com * Given flags parameter passed to wdt_reset or wdt_start uclass functions, 85*1eb0a464Smaxims@google.com * gets Reset Mask value from it. Reset Mask is only supported on ast2500 86*1eb0a464Smaxims@google.com * 87*1eb0a464Smaxims@google.com * @flags: flags parameter passed into wdt_reset or wdt_start 88*1eb0a464Smaxims@google.com * @return Reset Mask value 89*1eb0a464Smaxims@google.com */ 90*1eb0a464Smaxims@google.com u32 ast_reset_mask_from_flags(ulong flags); 91*1eb0a464Smaxims@google.com 92*1eb0a464Smaxims@google.com /** 93*1eb0a464Smaxims@google.com * Given Reset Mask and Reset Mode values, converts them to flags, 94*1eb0a464Smaxims@google.com * suitable for passing into wdt_start or wdt_reset uclass functions. 95*1eb0a464Smaxims@google.com * 96*1eb0a464Smaxims@google.com * On ast2500 Reset Mask is 25 bits wide and Reset Mode is 2 bits wide, so they 97*1eb0a464Smaxims@google.com * can both be packed into single 32 bits wide value. 98*1eb0a464Smaxims@google.com * 99*1eb0a464Smaxims@google.com * @reset_mode: Reset Mode 100*1eb0a464Smaxims@google.com * @reset_mask: Reset Mask 101*1eb0a464Smaxims@google.com */ 102*1eb0a464Smaxims@google.com ulong ast_flags_from_reset_mode_mask(u32 reset_mode, u32 reset_mask); 1034697abeaSmaxims@google.com #endif /* __ASSEMBLY__ */ 1044697abeaSmaxims@google.com 1054697abeaSmaxims@google.com #endif /* _ASM_ARCH_WDT_H */ 106