diff options
Diffstat (limited to 'arch/sh/include/asm/watchdog.h')
-rw-r--r-- | arch/sh/include/asm/watchdog.h | 86 |
1 files changed, 72 insertions, 14 deletions
diff --git a/arch/sh/include/asm/watchdog.h b/arch/sh/include/asm/watchdog.h index f024fed00a72..85a7aca7fb8f 100644 --- a/arch/sh/include/asm/watchdog.h +++ b/arch/sh/include/asm/watchdog.h | |||
@@ -2,6 +2,8 @@ | |||
2 | * include/asm-sh/watchdog.h | 2 | * include/asm-sh/watchdog.h |
3 | * | 3 | * |
4 | * Copyright (C) 2002, 2003 Paul Mundt | 4 | * Copyright (C) 2002, 2003 Paul Mundt |
5 | * Copyright (C) 2009 Siemens AG | ||
6 | * Copyright (C) 2009 Valentin Sitdikov | ||
5 | * | 7 | * |
6 | * This program is free software; you can redistribute it and/or modify it | 8 | * 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 | 9 | * under the terms of the GNU General Public License as published by the |
@@ -13,10 +15,18 @@ | |||
13 | #ifdef __KERNEL__ | 15 | #ifdef __KERNEL__ |
14 | 16 | ||
15 | #include <linux/types.h> | 17 | #include <linux/types.h> |
18 | #include <linux/io.h> | ||
19 | |||
20 | #define WTCNT_HIGH 0x5a | ||
21 | #define WTCSR_HIGH 0xa5 | ||
22 | |||
23 | #define WTCSR_CKS2 0x04 | ||
24 | #define WTCSR_CKS1 0x02 | ||
25 | #define WTCSR_CKS0 0x01 | ||
26 | |||
16 | #include <cpu/watchdog.h> | 27 | #include <cpu/watchdog.h> |
17 | #include <asm/io.h> | ||
18 | 28 | ||
19 | /* | 29 | /* |
20 | * See cpu-sh2/watchdog.h for explanation of this stupidity.. | 30 | * See cpu-sh2/watchdog.h for explanation of this stupidity.. |
21 | */ | 31 | */ |
22 | #ifndef WTCNT_R | 32 | #ifndef WTCNT_R |
@@ -27,13 +37,6 @@ | |||
27 | # define WTCSR_R WTCSR | 37 | # define WTCSR_R WTCSR |
28 | #endif | 38 | #endif |
29 | 39 | ||
30 | #define WTCNT_HIGH 0x5a | ||
31 | #define WTCSR_HIGH 0xa5 | ||
32 | |||
33 | #define WTCSR_CKS2 0x04 | ||
34 | #define WTCSR_CKS1 0x02 | ||
35 | #define WTCSR_CKS0 0x01 | ||
36 | |||
37 | /* | 40 | /* |
38 | * CKS0-2 supports a number of clock division ratios. At the time the watchdog | 41 | * CKS0-2 supports a number of clock division ratios. At the time the watchdog |
39 | * is enabled, it defaults to a 41 usec overflow period .. we overload this to | 42 | * is enabled, it defaults to a 41 usec overflow period .. we overload this to |
@@ -60,13 +63,68 @@ | |||
60 | #define WTCSR_CKS_2048 0x06 | 63 | #define WTCSR_CKS_2048 0x06 |
61 | #define WTCSR_CKS_4096 0x07 | 64 | #define WTCSR_CKS_4096 0x07 |
62 | 65 | ||
66 | #if defined(CONFIG_CPU_SUBTYPE_SH7785) || defined(CONFIG_CPU_SUBTYPE_SH7780) | ||
67 | /** | ||
68 | * sh_wdt_read_cnt - Read from Counter | ||
69 | * Reads back the WTCNT value. | ||
70 | */ | ||
71 | static inline __u32 sh_wdt_read_cnt(void) | ||
72 | { | ||
73 | return __raw_readl(WTCNT_R); | ||
74 | } | ||
75 | |||
76 | /** | ||
77 | * sh_wdt_write_cnt - Write to Counter | ||
78 | * @val: Value to write | ||
79 | * | ||
80 | * Writes the given value @val to the lower byte of the timer counter. | ||
81 | * The upper byte is set manually on each write. | ||
82 | */ | ||
83 | static inline void sh_wdt_write_cnt(__u32 val) | ||
84 | { | ||
85 | __raw_writel((WTCNT_HIGH << 24) | (__u32)val, WTCNT); | ||
86 | } | ||
87 | |||
88 | /** | ||
89 | * sh_wdt_write_bst - Write to Counter | ||
90 | * @val: Value to write | ||
91 | * | ||
92 | * Writes the given value @val to the lower byte of the timer counter. | ||
93 | * The upper byte is set manually on each write. | ||
94 | */ | ||
95 | static inline void sh_wdt_write_bst(__u32 val) | ||
96 | { | ||
97 | __raw_writel((WTBST_HIGH << 24) | (__u32)val, WTBST); | ||
98 | } | ||
99 | /** | ||
100 | * sh_wdt_read_csr - Read from Control/Status Register | ||
101 | * | ||
102 | * Reads back the WTCSR value. | ||
103 | */ | ||
104 | static inline __u32 sh_wdt_read_csr(void) | ||
105 | { | ||
106 | return __raw_readl(WTCSR_R); | ||
107 | } | ||
108 | |||
109 | /** | ||
110 | * sh_wdt_write_csr - Write to Control/Status Register | ||
111 | * @val: Value to write | ||
112 | * | ||
113 | * Writes the given value @val to the lower byte of the control/status | ||
114 | * register. The upper byte is set manually on each write. | ||
115 | */ | ||
116 | static inline void sh_wdt_write_csr(__u32 val) | ||
117 | { | ||
118 | __raw_writel((WTCSR_HIGH << 24) | (__u32)val, WTCSR); | ||
119 | } | ||
120 | #else | ||
63 | /** | 121 | /** |
64 | * sh_wdt_read_cnt - Read from Counter | 122 | * sh_wdt_read_cnt - Read from Counter |
65 | * Reads back the WTCNT value. | 123 | * Reads back the WTCNT value. |
66 | */ | 124 | */ |
67 | static inline __u8 sh_wdt_read_cnt(void) | 125 | static inline __u8 sh_wdt_read_cnt(void) |
68 | { | 126 | { |
69 | return ctrl_inb(WTCNT_R); | 127 | return __raw_readb(WTCNT_R); |
70 | } | 128 | } |
71 | 129 | ||
72 | /** | 130 | /** |
@@ -78,7 +136,7 @@ static inline __u8 sh_wdt_read_cnt(void) | |||
78 | */ | 136 | */ |
79 | static inline void sh_wdt_write_cnt(__u8 val) | 137 | static inline void sh_wdt_write_cnt(__u8 val) |
80 | { | 138 | { |
81 | ctrl_outw((WTCNT_HIGH << 8) | (__u16)val, WTCNT); | 139 | __raw_writew((WTCNT_HIGH << 8) | (__u16)val, WTCNT); |
82 | } | 140 | } |
83 | 141 | ||
84 | /** | 142 | /** |
@@ -88,7 +146,7 @@ static inline void sh_wdt_write_cnt(__u8 val) | |||
88 | */ | 146 | */ |
89 | static inline __u8 sh_wdt_read_csr(void) | 147 | static inline __u8 sh_wdt_read_csr(void) |
90 | { | 148 | { |
91 | return ctrl_inb(WTCSR_R); | 149 | return __raw_readb(WTCSR_R); |
92 | } | 150 | } |
93 | 151 | ||
94 | /** | 152 | /** |
@@ -100,8 +158,8 @@ static inline __u8 sh_wdt_read_csr(void) | |||
100 | */ | 158 | */ |
101 | static inline void sh_wdt_write_csr(__u8 val) | 159 | static inline void sh_wdt_write_csr(__u8 val) |
102 | { | 160 | { |
103 | ctrl_outw((WTCSR_HIGH << 8) | (__u16)val, WTCSR); | 161 | __raw_writew((WTCSR_HIGH << 8) | (__u16)val, WTCSR); |
104 | } | 162 | } |
105 | 163 | #endif /* CONFIG_CPU_SUBTYPE_SH7785 || CONFIG_CPU_SUBTYPE_SH7780 */ | |
106 | #endif /* __KERNEL__ */ | 164 | #endif /* __KERNEL__ */ |
107 | #endif /* __ASM_SH_WATCHDOG_H */ | 165 | #endif /* __ASM_SH_WATCHDOG_H */ |