All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ezequiel Garcia <ezequiel.garcia@imgtec.com>
To: <Naidu.Tellapati@imgtec.com>, <wim@iguana.be>,
	<linux@roeck-us.net>, <James.Hartley@imgtec.com>,
	<abrestic@chromium.org>, <Jude.Abraham@imgtec.com>
Cc: <linux-watchdog@vger.kernel.org>, <devicetree@vger.kernel.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@imgtec.com>



On 11/12/2014 12:18 PM, Naidu.Tellapati@imgtec.com 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

WARNING: multiple messages have this Message-ID (diff)
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

  parent reply	other threads:[~2014-11-13 13:06 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-11-12 15:18 [PATCH 0/2] watchdog: Add support for ImgTec PowerDown Controller Watchdog Timer Naidu.Tellapati
2014-11-12 15:18 ` [PATCH 1/2] watchdog: ImgTec PDC Watchdog Timer Driver Naidu.Tellapati
2014-11-13  4:56   ` Andrew Bresticker
2014-11-13  4:56     ` Andrew Bresticker
2014-11-13 12:58     ` Jude Abraham
2014-11-13 12:58       ` Jude Abraham
2014-11-13 13:26       ` James Hogan
2014-11-13 13:26         ` James Hogan
2014-11-14 13:08         ` Naidu Tellapati
2014-11-14 13:08           ` Naidu Tellapati
2014-11-14 14:08           ` James Hartley
2014-11-14 14:08             ` James Hartley
2014-11-13 13:05   ` Ezequiel Garcia [this message]
2014-11-13 13:05     ` Ezequiel Garcia
2014-11-12 15:18 ` [PATCH 2/2] DT: watchdog: Add ImgTec PDC Watchdog Timer binding documentation Naidu.Tellapati
2014-11-13  4:09   ` Andrew Bresticker
2014-11-13  4:09     ` Andrew Bresticker
2014-11-13 12:58     ` Jude Abraham
2014-11-13 12:58       ` Jude Abraham
2014-11-13 13:08       ` James Hogan
2014-11-13 13:08         ` James Hogan
2014-11-13 19:07         ` Andrew Bresticker
2014-11-13 19:07           ` Andrew Bresticker
2014-11-14  3:18           ` Naidu Tellapati
2014-11-14  3:18             ` Naidu Tellapati

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@imgtec.com \
    --cc=James.Hartley@imgtec.com \
    --cc=Jude.Abraham@imgtec.com \
    --cc=Naidu.Tellapati@imgtec.com \
    --cc=abrestic@chromium.org \
    --cc=devicetree@vger.kernel.org \
    --cc=linux-watchdog@vger.kernel.org \
    --cc=linux@roeck-us.net \
    --cc=wim@iguana.be \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.