aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/char/watchdog
diff options
context:
space:
mode:
authorWim Van Sebroeck <wim@iguana.be>2006-11-17 17:36:08 -0500
committerWim Van Sebroeck <wim@iguana.be>2006-11-17 17:36:08 -0500
commit414a675964e5636b53b37827b646138f166507d3 (patch)
tree45d9f613129c2fb5b8ad1714080bbc183674535e /drivers/char/watchdog
parent97846e3ccbcbcc966e23a91b0d190efd1f889c9b (diff)
[WATCHDOG] MIPS RM9000 on-chip watchdog device - patch 3
Move start and stop code into seperate functions Signed-off-by: Wim Van Sebroeck <wim@iguana.be>
Diffstat (limited to 'drivers/char/watchdog')
-rw-r--r--drivers/char/watchdog/rm9k_wdt.c56
1 files changed, 29 insertions, 27 deletions
diff --git a/drivers/char/watchdog/rm9k_wdt.c b/drivers/char/watchdog/rm9k_wdt.c
index 1aad9138f714..22aab8703eda 100644
--- a/drivers/char/watchdog/rm9k_wdt.c
+++ b/drivers/char/watchdog/rm9k_wdt.c
@@ -111,6 +111,30 @@ static irqreturn_t wdt_gpi_irqhdl(int irq, void *ctxt, struct pt_regs *regs)
111 111
112 112
113/* Watchdog functions */ 113/* Watchdog functions */
114static void wdt_gpi_start(void)
115{
116 u32 reg;
117
118 lock_titan_regs();
119 reg = titan_readl(CPGIG1ER);
120 titan_writel(reg | (0x100 << wd_ctr), CPGIG1ER);
121 iob();
122 unlock_titan_regs();
123}
124
125static void wdt_gpi_stop(void)
126{
127 u32 reg;
128
129 lock_titan_regs();
130 reg = titan_readl(CPCCR) & ~(0xf << (wd_ctr * 4));
131 titan_writel(reg, CPCCR);
132 reg = titan_readl(CPGIG1ER);
133 titan_writel(reg & ~(0x100 << wd_ctr), CPGIG1ER);
134 iob();
135 unlock_titan_regs();
136}
137
114static void wdt_gpi_set_timeout(unsigned int to) 138static void wdt_gpi_set_timeout(unsigned int to)
115{ 139{
116 u32 reg; 140 u32 reg;
@@ -134,7 +158,6 @@ static void wdt_gpi_set_timeout(unsigned int to)
134static int wdt_gpi_open(struct inode *i, struct file *f) 158static int wdt_gpi_open(struct inode *i, struct file *f)
135{ 159{
136 int res; 160 int res;
137 u32 reg;
138 161
139 if (unlikely(0 > atomic_dec_if_positive(&opencnt))) 162 if (unlikely(0 > atomic_dec_if_positive(&opencnt)))
140 return -EBUSY; 163 return -EBUSY;
@@ -152,12 +175,7 @@ static int wdt_gpi_open(struct inode *i, struct file *f)
152 return res; 175 return res;
153 176
154 wdt_gpi_set_timeout(timeout); 177 wdt_gpi_set_timeout(timeout);
155 178 wdt_gpi_start();
156 lock_titan_regs();
157 reg = titan_readl(CPGIG1ER);
158 titan_writel(reg | (0x100 << wd_ctr), CPGIG1ER);
159 iob();
160 unlock_titan_regs();
161 179
162 printk(KERN_INFO "%s: watchdog started, timeout = %u seconds\n", 180 printk(KERN_INFO "%s: watchdog started, timeout = %u seconds\n",
163 wdt_gpi_name, timeout); 181 wdt_gpi_name, timeout);
@@ -173,15 +191,7 @@ static int wdt_gpi_release(struct inode *i, struct file *f)
173 locked = 1; 191 locked = 1;
174 } else { 192 } else {
175 if (expect_close) { 193 if (expect_close) {
176 u32 reg; 194 wdt_gpi_stop();
177
178 lock_titan_regs();
179 reg = titan_readl(CPCCR) & ~(0xf << (wd_ctr * 4));
180 titan_writel(reg, CPCCR);
181 reg = titan_readl(CPGIG1ER);
182 titan_writel(reg & ~(0x100 << wd_ctr), CPGIG1ER);
183 iob();
184 unlock_titan_regs();
185 free_irq(wd_irq, &miscdev); 195 free_irq(wd_irq, &miscdev);
186 printk(KERN_INFO "%s: watchdog stopped\n", wdt_gpi_name); 196 printk(KERN_INFO "%s: watchdog stopped\n", wdt_gpi_name);
187 } else { 197 } else {
@@ -293,17 +303,9 @@ wdt_gpi_ioctl(struct file *f, unsigned int cmd, unsigned long arg)
293static int 303static int
294wdt_gpi_notify(struct notifier_block *this, unsigned long code, void *unused) 304wdt_gpi_notify(struct notifier_block *this, unsigned long code, void *unused)
295{ 305{
296 if(code == SYS_DOWN || code == SYS_HALT) { 306 if (code == SYS_DOWN || code == SYS_HALT)
297 u32 reg; 307 wdt_gpi_stop();
298 308
299 lock_titan_regs();
300 reg = titan_readl(CPCCR) & ~(0xf << (wd_ctr * 4));
301 titan_writel(reg, CPCCR);
302 reg = titan_readl(CPGIG1ER);
303 titan_writel(reg & ~(0x100 << wd_ctr), CPGIG1ER);
304 iob();
305 unlock_titan_regs();
306 }
307 return NOTIFY_DONE; 309 return NOTIFY_DONE;
308} 310}
309 311