From: Ezequiel Garcia <ezequiel.garcia-1AXoQHu6uovQT0dZR+AlfA@public.gmane.org>
To: Naidu.Tellapati-1AXoQHu6uovQT0dZR+AlfA@public.gmane.org,
wim-IQzOog9fTRqzQB+pC5nmwQ@public.gmane.org,
linux-0h96xk9xTtrk1uMJSBkQmQ@public.gmane.org,
James.Hartley-1AXoQHu6uovQT0dZR+AlfA@public.gmane.org,
abrestic-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org,
Jude.Abraham-1AXoQHu6uovQT0dZR+AlfA@public.gmane.org
Cc: linux-watchdog-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: Re: [PATCH 1/2] watchdog: ImgTec PDC Watchdog Timer Driver
Date: Thu, 13 Nov 2014 10:05:11 -0300 [thread overview]
Message-ID: <5464AC87.6000004@imgtec.com> (raw)
In-Reply-To: <1415805483-26268-2-git-send-email-Naidu.Tellapati-1AXoQHu6uovQT0dZR+AlfA@public.gmane.org>
On 11/12/2014 12:18 PM, Naidu.Tellapati-1AXoQHu6uovQT0dZR+AlfA@public.gmane.org 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-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
prev parent reply other threads:[~2014-11-13 13:05 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <1415805483-26268-1-git-send-email-Naidu.Tellapati@imgtec.com>
[not found] ` <1415805483-26268-3-git-send-email-Naidu.Tellapati@imgtec.com>
[not found] ` <1415805483-26268-3-git-send-email-Naidu.Tellapati-1AXoQHu6uovQT0dZR+AlfA@public.gmane.org>
2014-11-13 4:09 ` [PATCH 2/2] DT: watchdog: Add ImgTec PDC Watchdog Timer binding documentation Andrew Bresticker
[not found] ` <CAL1qeaHrjccd4KYAUMvWEKqhM9DFNyKWE=-2k0ux+76XR+Q5tQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2014-11-13 12:58 ` Jude Abraham
[not found] ` <89F3BC60EA3A0141B1F6C2A661D95E5E3F192BAA-C8yLA94LPOy3snIXRfWIHVBRoQTxkR7k@public.gmane.org>
2014-11-13 13:08 ` James Hogan
[not found] ` <5464AD4B.1000509-1AXoQHu6uovQT0dZR+AlfA@public.gmane.org>
2014-11-13 19:07 ` Andrew Bresticker
[not found] ` <CAL1qeaHEGZWs8PPrX5cNpUWXDL3D_5Y2w772eKBEO0G+5q_p-g-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2014-11-14 3:18 ` Naidu Tellapati
[not found] ` <1415805483-26268-2-git-send-email-Naidu.Tellapati@imgtec.com>
[not found] ` <1415805483-26268-2-git-send-email-Naidu.Tellapati-1AXoQHu6uovQT0dZR+AlfA@public.gmane.org>
2014-11-13 4:56 ` [PATCH 1/2] watchdog: ImgTec PDC Watchdog Timer Driver Andrew Bresticker
2014-11-13 12:58 ` Jude Abraham
[not found] ` <89F3BC60EA3A0141B1F6C2A661D95E5E3F192BB4-C8yLA94LPOy3snIXRfWIHVBRoQTxkR7k@public.gmane.org>
2014-11-13 13:26 ` James Hogan
[not found] ` <5464B191.9020401-1AXoQHu6uovQT0dZR+AlfA@public.gmane.org>
2014-11-14 13:08 ` Naidu Tellapati
[not found] ` <27E62D98F903554192E3C13AFCC91C3C2F505E3E-C8yLA94LPOy3snIXRfWIHVBRoQTxkR7k@public.gmane.org>
2014-11-14 14:08 ` James Hartley
2014-11-13 13:05 ` Ezequiel Garcia [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=5464AC87.6000004@imgtec.com \
--to=ezequiel.garcia-1axoqhu6uovqt0dzr+alfa@public.gmane.org \
--cc=James.Hartley-1AXoQHu6uovQT0dZR+AlfA@public.gmane.org \
--cc=Jude.Abraham-1AXoQHu6uovQT0dZR+AlfA@public.gmane.org \
--cc=Naidu.Tellapati-1AXoQHu6uovQT0dZR+AlfA@public.gmane.org \
--cc=abrestic-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org \
--cc=devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-0h96xk9xTtrk1uMJSBkQmQ@public.gmane.org \
--cc=linux-watchdog-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=wim-IQzOog9fTRqzQB+pC5nmwQ@public.gmane.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).