2 * include/asm-sh/watchdog.h
4 * Copyright (C) 2002, 2003 Paul Mundt
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation; either version 2 of the License, or (at your
9 * option) any later version.
11 #ifndef __ASM_SH_WATCHDOG_H
12 #define __ASM_SH_WATCHDOG_H
15 #include <linux/types.h>
16 #include <linux/config.h>
17 #include <asm/cpu/watchdog.h>
21 * See asm/cpu-sh2/watchdog.h for explanation of this stupidity..
24 # define WTCNT_R WTCNT
28 # define WTCSR_R WTCSR
31 #define WTCNT_HIGH 0x5a
32 #define WTCSR_HIGH 0xa5
34 #define WTCSR_CKS2 0x04
35 #define WTCSR_CKS1 0x02
36 #define WTCSR_CKS0 0x01
39 * CKS0-2 supports a number of clock division ratios. At the time the watchdog
40 * is enabled, it defaults to a 41 usec overflow period .. we overload this to
41 * something a little more reasonable, and really can't deal with anything
42 * lower than WTCSR_CKS_1024, else we drop back into the usec range.
44 * Clock Division Ratio Overflow Period
45 * --------------------------------------------
46 * 1/32 (initial value) 41 usecs
55 #define WTCSR_CKS_32 0x00
56 #define WTCSR_CKS_64 0x01
57 #define WTCSR_CKS_128 0x02
58 #define WTCSR_CKS_256 0x03
59 #define WTCSR_CKS_512 0x04
60 #define WTCSR_CKS_1024 0x05
61 #define WTCSR_CKS_2048 0x06
62 #define WTCSR_CKS_4096 0x07
65 * sh_wdt_read_cnt - Read from Counter
67 * Reads back the WTCNT value.
69 static inline __u8 sh_wdt_read_cnt(void)
71 return ctrl_inb(WTCNT_R);
75 * sh_wdt_write_cnt - Write to Counter
77 * @val: Value to write
79 * Writes the given value @val to the lower byte of the timer counter.
80 * The upper byte is set manually on each write.
82 static inline void sh_wdt_write_cnt(__u8 val)
84 ctrl_outw((WTCNT_HIGH << 8) | (__u16)val, WTCNT);
88 * sh_wdt_read_csr - Read from Control/Status Register
90 * Reads back the WTCSR value.
92 static inline __u8 sh_wdt_read_csr(void)
94 return ctrl_inb(WTCSR_R);
98 * sh_wdt_write_csr - Write to Control/Status Register
100 * @val: Value to write
102 * Writes the given value @val to the lower byte of the control/status
103 * register. The upper byte is set manually on each write.
105 static inline void sh_wdt_write_csr(__u8 val)
107 ctrl_outw((WTCSR_HIGH << 8) | (__u16)val, WTCSR);
110 #endif /* __KERNEL__ */
111 #endif /* __ASM_SH_WATCHDOG_H */