/* 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)
{
u32 reg;
static int wdt_gpi_open(struct inode *i, struct file *f)
{
int res;
- u32 reg;
if (unlikely(0 > atomic_dec_if_positive(&opencnt)))
return -EBUSY;
return res;
wdt_gpi_set_timeout(timeout);
-
- lock_titan_regs();
- reg = titan_readl(CPGIG1ER);
- titan_writel(reg | (0x100 << wd_ctr), CPGIG1ER);
- iob();
- unlock_titan_regs();
+ wdt_gpi_start();
printk(KERN_INFO "%s: watchdog started, timeout = %u seconds\n",
wdt_gpi_name, timeout);
locked = 1;
} else {
if (expect_close) {
- 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();
+ wdt_gpi_stop();
free_irq(wd_irq, &miscdev);
printk(KERN_INFO "%s: watchdog stopped\n", wdt_gpi_name);
} else {
static int
wdt_gpi_notify(struct notifier_block *this, unsigned long code, void *unused)
{
- if(code == SYS_DOWN || code == SYS_HALT) {
- 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();
- }
+ if (code == SYS_DOWN || code == SYS_HALT)
+ wdt_gpi_stop();
+
return NOTIFY_DONE;
}