Lines Matching refs:p
203 static void cpwd_toggleintr(struct cpwd *p, int index, int enable) in cpwd_toggleintr() argument
205 unsigned char curregs = cpwd_readb(p->regs + PLD_IMASK); in cpwd_toggleintr()
209 (p->devs[index].intr_mask); in cpwd_toggleintr()
216 cpwd_writeb(curregs, p->regs + PLD_IMASK); in cpwd_toggleintr()
222 static void cpwd_resetbrokentimer(struct cpwd *p, int index) in cpwd_resetbrokentimer() argument
224 cpwd_toggleintr(p, index, WD_INTR_ON); in cpwd_resetbrokentimer()
225 cpwd_writew(WD_BLIMIT, p->devs[index].regs + WD_LIMIT); in cpwd_resetbrokentimer()
235 struct cpwd *p = (struct cpwd *) data; in cpwd_brokentimer() local
245 if (p->devs[id].runstatus & WD_STAT_BSTOP) { in cpwd_brokentimer()
247 cpwd_resetbrokentimer(p, id); in cpwd_brokentimer()
261 static void cpwd_pingtimer(struct cpwd *p, int index) in cpwd_pingtimer() argument
263 if (cpwd_readb(p->devs[index].regs + WD_STATUS) & WD_S_RUNNING) in cpwd_pingtimer()
264 cpwd_readw(p->devs[index].regs + WD_DCNTR); in cpwd_pingtimer()
271 static void cpwd_stoptimer(struct cpwd *p, int index) in cpwd_stoptimer() argument
273 if (cpwd_readb(p->devs[index].regs + WD_STATUS) & WD_S_RUNNING) { in cpwd_stoptimer()
274 cpwd_toggleintr(p, index, WD_INTR_OFF); in cpwd_stoptimer()
276 if (p->broken) { in cpwd_stoptimer()
277 p->devs[index].runstatus |= WD_STAT_BSTOP; in cpwd_stoptimer()
278 cpwd_brokentimer((unsigned long) p); in cpwd_stoptimer()
290 static void cpwd_starttimer(struct cpwd *p, int index) in cpwd_starttimer() argument
292 if (p->broken) in cpwd_starttimer()
293 p->devs[index].runstatus &= ~WD_STAT_BSTOP; in cpwd_starttimer()
295 p->devs[index].runstatus &= ~WD_STAT_SVCD; in cpwd_starttimer()
297 cpwd_writew(p->devs[index].timeout, p->devs[index].regs + WD_LIMIT); in cpwd_starttimer()
298 cpwd_toggleintr(p, index, WD_INTR_ON); in cpwd_starttimer()
301 static int cpwd_getstatus(struct cpwd *p, int index) in cpwd_getstatus() argument
303 unsigned char stat = cpwd_readb(p->devs[index].regs + WD_STATUS); in cpwd_getstatus()
304 unsigned char intr = cpwd_readb(p->devs[index].regs + PLD_IMASK); in cpwd_getstatus()
315 if (intr & p->devs[index].intr_mask) { in cpwd_getstatus()
329 if (p->broken && in cpwd_getstatus()
330 (p->devs[index].runstatus & WD_STAT_BSTOP)) { in cpwd_getstatus()
331 if (p->devs[index].runstatus & WD_STAT_SVCD) { in cpwd_getstatus()
345 if (p->devs[index].runstatus & WD_STAT_SVCD) in cpwd_getstatus()
353 struct cpwd *p = dev_id; in cpwd_interrupt() local
358 spin_lock_irq(&p->lock); in cpwd_interrupt()
360 cpwd_stoptimer(p, WD0_ID); in cpwd_interrupt()
361 p->devs[WD0_ID].runstatus |= WD_STAT_SVCD; in cpwd_interrupt()
363 spin_unlock_irq(&p->lock); in cpwd_interrupt()
370 struct cpwd *p = cpwd_device; in cpwd_open() local
385 if (!p->initialized) { in cpwd_open()
386 if (request_irq(p->irq, &cpwd_interrupt, in cpwd_open()
387 IRQF_SHARED, DRIVER_NAME, p)) { in cpwd_open()
388 pr_err("Cannot register IRQ %d\n", p->irq); in cpwd_open()
392 p->initialized = true; in cpwd_open()
415 struct cpwd *p = cpwd_device; in cpwd_ioctl() local
432 cpwd_pingtimer(p, index); in cpwd_ioctl()
440 if (p->enabled) in cpwd_ioctl()
442 cpwd_stoptimer(p, index); in cpwd_ioctl()
444 cpwd_starttimer(p, index); in cpwd_ioctl()
452 setopt = cpwd_getstatus(p, index); in cpwd_ioctl()
458 cpwd_starttimer(p, index); in cpwd_ioctl()
462 if (p->enabled) in cpwd_ioctl()
465 cpwd_stoptimer(p, index); in cpwd_ioctl()
502 struct cpwd *p = cpwd_device; in cpwd_write() local
506 cpwd_pingtimer(p, index); in cpwd_write()
536 struct cpwd *p; in cpwd_probe() local
541 p = kzalloc(sizeof(*p), GFP_KERNEL); in cpwd_probe()
543 if (!p) { in cpwd_probe()
548 p->irq = op->archdata.irqs[0]; in cpwd_probe()
550 spin_lock_init(&p->lock); in cpwd_probe()
552 p->regs = of_ioremap(&op->resource[0], 0, in cpwd_probe()
554 if (!p->regs) { in cpwd_probe()
567 p->enabled = (prop_val ? true : false); in cpwd_probe()
570 p->reboot = (prop_val ? true : false); in cpwd_probe()
574 p->timeout = simple_strtoul(str_prop, NULL, 10); in cpwd_probe()
581 p->broken = (str_prop && !strcmp(str_prop, WD_BADMODEL)); in cpwd_probe()
583 if (!p->enabled) in cpwd_probe()
584 cpwd_toggleintr(p, -1, WD_INTR_OFF); in cpwd_probe()
591 struct miscdevice *mp = &p->devs[i].misc; in cpwd_probe()
597 p->devs[i].regs = p->regs + (i * WD_TIMER_REGSZ); in cpwd_probe()
598 p->devs[i].intr_mask = (WD0_INTR_MASK << i); in cpwd_probe()
599 p->devs[i].runstatus &= ~WD_STAT_BSTOP; in cpwd_probe()
600 p->devs[i].runstatus |= WD_STAT_INIT; in cpwd_probe()
601 p->devs[i].timeout = p->timeout; in cpwd_probe()
603 p->devs[i].timeout = *parms[i]; in cpwd_probe()
605 err = misc_register(&p->devs[i].misc); in cpwd_probe()
613 if (p->broken) { in cpwd_probe()
616 cpwd_timer.data = (unsigned long) p; in cpwd_probe()
623 platform_set_drvdata(op, p); in cpwd_probe()
624 cpwd_device = p; in cpwd_probe()
632 misc_deregister(&p->devs[i].misc); in cpwd_probe()
635 of_iounmap(&op->resource[0], p->regs, 4 * WD_TIMER_REGSZ); in cpwd_probe()
638 kfree(p); in cpwd_probe()
644 struct cpwd *p = platform_get_drvdata(op); in cpwd_remove() local
648 misc_deregister(&p->devs[i].misc); in cpwd_remove()
650 if (!p->enabled) { in cpwd_remove()
651 cpwd_stoptimer(p, i); in cpwd_remove()
652 if (p->devs[i].runstatus & WD_STAT_BSTOP) in cpwd_remove()
653 cpwd_resetbrokentimer(p, i); in cpwd_remove()
657 if (p->broken) in cpwd_remove()
660 if (p->initialized) in cpwd_remove()
661 free_irq(p->irq, p); in cpwd_remove()
663 of_iounmap(&op->resource[0], p->regs, 4 * WD_TIMER_REGSZ); in cpwd_remove()
664 kfree(p); in cpwd_remove()