Commit 414a6759 authored by Wim Van Sebroeck's avatar Wim Van Sebroeck

[WATCHDOG] MIPS RM9000 on-chip watchdog device - patch 3

Move start and stop code into seperate functions
Signed-off-by: default avatarWim Van Sebroeck <wim@iguana.be>
parent 97846e3c
...@@ -111,6 +111,30 @@ static irqreturn_t wdt_gpi_irqhdl(int irq, void *ctxt, struct pt_regs *regs) ...@@ -111,6 +111,30 @@ static irqreturn_t wdt_gpi_irqhdl(int irq, void *ctxt, struct pt_regs *regs)
/* Watchdog functions */ /* Watchdog functions */
static void wdt_gpi_start(void)
{
u32 reg;
lock_titan_regs();
reg = titan_readl(CPGIG1ER);
titan_writel(reg | (0x100 << wd_ctr), CPGIG1ER);
iob();
unlock_titan_regs();
}
static void wdt_gpi_stop(void)
{
u32 reg;
lock_titan_regs();
reg = titan_readl(CPCCR) & ~(0xf << (wd_ctr * 4));
titan_writel(reg, CPCCR);
reg = titan_readl(CPGIG1ER);
titan_writel(reg & ~(0x100 << wd_ctr), CPGIG1ER);
iob();
unlock_titan_regs();
}
static void wdt_gpi_set_timeout(unsigned int to) static void wdt_gpi_set_timeout(unsigned int to)
{ {
u32 reg; u32 reg;
...@@ -134,7 +158,6 @@ static void wdt_gpi_set_timeout(unsigned int to) ...@@ -134,7 +158,6 @@ static void wdt_gpi_set_timeout(unsigned int to)
static int wdt_gpi_open(struct inode *i, struct file *f) static int wdt_gpi_open(struct inode *i, struct file *f)
{ {
int res; int res;
u32 reg;
if (unlikely(0 > atomic_dec_if_positive(&opencnt))) if (unlikely(0 > atomic_dec_if_positive(&opencnt)))
return -EBUSY; return -EBUSY;
...@@ -152,12 +175,7 @@ static int wdt_gpi_open(struct inode *i, struct file *f) ...@@ -152,12 +175,7 @@ static int wdt_gpi_open(struct inode *i, struct file *f)
return res; return res;
wdt_gpi_set_timeout(timeout); wdt_gpi_set_timeout(timeout);
wdt_gpi_start();
lock_titan_regs();
reg = titan_readl(CPGIG1ER);
titan_writel(reg | (0x100 << wd_ctr), CPGIG1ER);
iob();
unlock_titan_regs();
printk(KERN_INFO "%s: watchdog started, timeout = %u seconds\n", printk(KERN_INFO "%s: watchdog started, timeout = %u seconds\n",
wdt_gpi_name, timeout); wdt_gpi_name, timeout);
...@@ -173,15 +191,7 @@ static int wdt_gpi_release(struct inode *i, struct file *f) ...@@ -173,15 +191,7 @@ static int wdt_gpi_release(struct inode *i, struct file *f)
locked = 1; locked = 1;
} else { } else {
if (expect_close) { if (expect_close) {
u32 reg; wdt_gpi_stop();
lock_titan_regs();
reg = titan_readl(CPCCR) & ~(0xf << (wd_ctr * 4));
titan_writel(reg, CPCCR);
reg = titan_readl(CPGIG1ER);
titan_writel(reg & ~(0x100 << wd_ctr), CPGIG1ER);
iob();
unlock_titan_regs();
free_irq(wd_irq, &miscdev); free_irq(wd_irq, &miscdev);
printk(KERN_INFO "%s: watchdog stopped\n", wdt_gpi_name); printk(KERN_INFO "%s: watchdog stopped\n", wdt_gpi_name);
} else { } else {
...@@ -293,17 +303,9 @@ wdt_gpi_ioctl(struct file *f, unsigned int cmd, unsigned long arg) ...@@ -293,17 +303,9 @@ wdt_gpi_ioctl(struct file *f, unsigned int cmd, unsigned long arg)
static int static int
wdt_gpi_notify(struct notifier_block *this, unsigned long code, void *unused) wdt_gpi_notify(struct notifier_block *this, unsigned long code, void *unused)
{ {
if(code == SYS_DOWN || code == SYS_HALT) { if (code == SYS_DOWN || code == SYS_HALT)
u32 reg; wdt_gpi_stop();
lock_titan_regs();
reg = titan_readl(CPCCR) & ~(0xf << (wd_ctr * 4));
titan_writel(reg, CPCCR);
reg = titan_readl(CPGIG1ER);
titan_writel(reg & ~(0x100 << wd_ctr), CPGIG1ER);
iob();
unlock_titan_regs();
}
return NOTIFY_DONE; return NOTIFY_DONE;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment