On 11/12/2014 12:18 PM, Naidu.Tellapati@xxxxxxxxxx wrote: [..] > + > +static int pdc_wdt_keepalive(struct watchdog_device *wdt_dev) > +{ > + struct pdc_wdt_dev *wdt = watchdog_get_drvdata(wdt_dev); > + > + writel(PDC_WD_TICKLE1_MAGIC, wdt->base + PDC_WD_TICKLE1); > + writel(PDC_WD_TICKLE2_MAGIC, wdt->base + PDC_WD_TICKLE2); > + > + return 0; > +} > + > +static int pdc_wdt_stop(struct watchdog_device *wdt_dev) > +{ > + unsigned int val; > + struct pdc_wdt_dev *wdt = watchdog_get_drvdata(wdt_dev); > + > + val = readl(wdt->base + PDC_WD_CONFIG); > + val &= ~BIT(31); > + writel(val, wdt->base + PDC_WD_CONFIG); > + /* Must tickle to finish the stop */ > + pdc_wdt_keepalive(wdt_dev); > + > + return 0; > +} > + > +static int pdc_wdt_set_timeout(struct watchdog_device *wdt_dev, > + unsigned int new_timeout) > +{ > + unsigned int val; > + struct pdc_wdt_dev *wdt = watchdog_get_drvdata(wdt_dev); > + > + if (new_timeout < PDC_WD_MIN_TIMEOUT || > + new_timeout > PDC_WD_MAX_TIMEOUT) > + return -EINVAL; > + > + wdt->wdt_dev.timeout = new_timeout; > + > + /* round up to the next power of 2 */ > + new_timeout = order_base_2(new_timeout); > + val = readl(wdt->base + PDC_WD_CONFIG); > + > + /* number of 32.768KHz clocks, 2^(n+1) (14 is 1 sec) */ > + val &= ~PDC_WD_CONFIG_DELAY; > + val |= (new_timeout + MIN_TIMEOUT_SHIFT) << PDC_WD_CONFIG_DELAY_SHIFT; > + writel(val, wdt->base + PDC_WD_CONFIG); > + > + return 0; > +} > + > +static int pdc_wdt_set_pretimeout(struct watchdog_device *wdt_dev, > + unsigned int new_pretimeout) > +{ > + int delay; > + unsigned int val; > + struct pdc_wdt_dev *wdt = watchdog_get_drvdata(wdt_dev); > + > + /* > + * Pretimeout is measured in seconds before main timeout. > + * Subtract and round it once, and it will effectively change > + * if the main timeout is changed. > + */ > + delay = wdt->wdt_dev.timeout; > + if (!new_pretimeout) > + new_pretimeout = PDC_WD_MAX_TIMEOUT; > + else if (new_pretimeout > 0 && new_pretimeout < delay) > + new_pretimeout = delay - new_pretimeout; > + else > + return -EINVAL; > + > + pretimeout = new_pretimeout; > + new_pretimeout = ilog2(new_pretimeout); > + val = readl(wdt->base + PDC_WD_CONFIG); > + > + /* number of 32.768KHz clocks, 2^(n+1) (14 is 1 sec) */ > + val &= ~PDC_WD_CONFIG_REMIND; > + val |= (new_pretimeout + MIN_TIMEOUT_SHIFT) > + << PDC_WD_CONFIG_REMIND_SHIFT; > + writel(val, wdt->base + PDC_WD_CONFIG); > + wdt->pretimeout = pretimeout; > + > + return 0; > +} > + > +/* Start the watchdog timer (delay should already be set */ > +static int pdc_wdt_start(struct watchdog_device *wdt_dev) > +{ > + int ret; > + unsigned int val; > + struct pdc_wdt_dev *wdt = watchdog_get_drvdata(wdt_dev); > + > + ret = pdc_wdt_set_timeout(&wdt->wdt_dev, wdt->wdt_dev.timeout); > + if (ret < 0) > + return ret; > + Please double check it, but I think you don't need to set the timeout here. You set the default at probe time; and then it'll get set by the ioctl if it changes. -- Ezequiel -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html