1*6a0abce4SKuninori Morimoto /* SPDX-License-Identifier: GPL-2.0 2*6a0abce4SKuninori Morimoto * 3f15cbe6fSPaul Mundt * include/asm-sh/cpu-sh2/watchdog.h 4f15cbe6fSPaul Mundt * 5f15cbe6fSPaul Mundt * Copyright (C) 2002, 2003 Paul Mundt 6f15cbe6fSPaul Mundt */ 7f15cbe6fSPaul Mundt #ifndef __ASM_CPU_SH2_WATCHDOG_H 8f15cbe6fSPaul Mundt #define __ASM_CPU_SH2_WATCHDOG_H 9f15cbe6fSPaul Mundt 10f15cbe6fSPaul Mundt /* 11f15cbe6fSPaul Mundt * More SH-2 brilliance .. its not good enough that we can't read 12f15cbe6fSPaul Mundt * and write the same sizes to WTCNT, now we have to read and write 13f15cbe6fSPaul Mundt * with different sizes at different addresses for WTCNT _and_ RSTCSR. 14f15cbe6fSPaul Mundt * 15f15cbe6fSPaul Mundt * At least on the bright side no one has managed to screw over WTCSR 16f15cbe6fSPaul Mundt * in this fashion .. yet. 17f15cbe6fSPaul Mundt */ 18f15cbe6fSPaul Mundt /* Register definitions */ 19f15cbe6fSPaul Mundt #define WTCNT 0xfffffe80 20f15cbe6fSPaul Mundt #define WTCSR 0xfffffe80 21f15cbe6fSPaul Mundt #define RSTCSR 0xfffffe82 22f15cbe6fSPaul Mundt 23f15cbe6fSPaul Mundt #define WTCNT_R (WTCNT + 1) 24f15cbe6fSPaul Mundt #define RSTCSR_R (RSTCSR + 1) 25f15cbe6fSPaul Mundt 26f15cbe6fSPaul Mundt /* Bit definitions */ 27f15cbe6fSPaul Mundt #define WTCSR_IOVF 0x80 28f15cbe6fSPaul Mundt #define WTCSR_WT 0x40 29f15cbe6fSPaul Mundt #define WTCSR_TME 0x20 30f15cbe6fSPaul Mundt #define WTCSR_RSTS 0x00 31f15cbe6fSPaul Mundt 32f15cbe6fSPaul Mundt #define RSTCSR_RSTS 0x20 33f15cbe6fSPaul Mundt 34f15cbe6fSPaul Mundt /** 35f15cbe6fSPaul Mundt * sh_wdt_read_rstcsr - Read from Reset Control/Status Register 36f15cbe6fSPaul Mundt * 37f15cbe6fSPaul Mundt * Reads back the RSTCSR value. 38f15cbe6fSPaul Mundt */ sh_wdt_read_rstcsr(void)39f15cbe6fSPaul Mundtstatic inline __u8 sh_wdt_read_rstcsr(void) 40f15cbe6fSPaul Mundt { 41f15cbe6fSPaul Mundt /* 42f15cbe6fSPaul Mundt * Same read/write brain-damage as for WTCNT here.. 43f15cbe6fSPaul Mundt */ 449d56dd3bSPaul Mundt return __raw_readb(RSTCSR_R); 45f15cbe6fSPaul Mundt } 46f15cbe6fSPaul Mundt 47f15cbe6fSPaul Mundt /** 48f15cbe6fSPaul Mundt * sh_wdt_write_csr - Write to Reset Control/Status Register 49f15cbe6fSPaul Mundt * 50f15cbe6fSPaul Mundt * @val: Value to write 51f15cbe6fSPaul Mundt * 52f15cbe6fSPaul Mundt * Writes the given value @val to the lower byte of the control/status 53f15cbe6fSPaul Mundt * register. The upper byte is set manually on each write. 54f15cbe6fSPaul Mundt */ sh_wdt_write_rstcsr(__u8 val)55f15cbe6fSPaul Mundtstatic inline void sh_wdt_write_rstcsr(__u8 val) 56f15cbe6fSPaul Mundt { 57f15cbe6fSPaul Mundt /* 58f15cbe6fSPaul Mundt * Note: Due to the brain-damaged nature of this register, 59f15cbe6fSPaul Mundt * we can't presently touch the WOVF bit, since the upper byte 60f15cbe6fSPaul Mundt * has to be swapped for this. So just leave it alone.. 61f15cbe6fSPaul Mundt */ 629d56dd3bSPaul Mundt __raw_writeb((WTCNT_HIGH << 8) | (__u16)val, RSTCSR); 63f15cbe6fSPaul Mundt } 64f15cbe6fSPaul Mundt 65f15cbe6fSPaul Mundt #endif /* __ASM_CPU_SH2_WATCHDOG_H */ 66f15cbe6fSPaul Mundt 67