mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [Patch] ARM/MXS/i.MX28: distinguish POR and wake-up event correctly
@ 2012-11-30 11:14 Juergen Beisert
  2012-12-03  8:50 ` Sascha Hauer
  0 siblings, 1 reply; 2+ messages in thread
From: Juergen Beisert @ 2012-11-30 11:14 UTC (permalink / raw)
  To: barebox

When the built-in RTC in the i.MX28 is programmed to wake-up the SoC, the RTC
reports two events: RST and WAKE. RST is okay in this case, because the PMIC
was really powered down. But the real event is the WAKE from the RTC and
should have precedence over the RST event. So, report the WAKE event for this
special case.

Signed-off-by: Juergen Beisert <jbe@pengutronix.de>

diff --git a/drivers/watchdog/im28wd.c b/drivers/watchdog/im28wd.c
index ca32a72..bc19369 100644
--- a/drivers/watchdog/im28wd.c
+++ b/drivers/watchdog/im28wd.c
@@ -82,6 +82,17 @@ static void __maybe_unused imx28_detect_reset_source(const struct imx28_wd *p)
 	if (reg & MXS_RTC_PERSISTENT0_EXT_RST) {
 		writel(MXS_RTC_PERSISTENT0_EXT_RST,
 			p->regs + MXS_RTC_PERSISTENT0 + MXS_RTC_CLR_ADDR);
+		/*
+		 * if the RTC has woken up the SoC, additionally the ALARM_WAKE
+		 * bit is set. This bit should have precedence, because it
+		 * reports the real event, why we are here.
+		 */
+		if (reg & MXS_RTC_PERSISTENT0_ALARM_WAKE) {
+			writel(MXS_RTC_PERSISTENT0_ALARM_WAKE,
+				p->regs + MXS_RTC_PERSISTENT0 + MXS_RTC_CLR_ADDR);
+			set_reset_source(RESET_WKE);
+			return;
+		}
 		set_reset_source(RESET_POR);
 		return;
 	}


-- 
Pengutronix e.K.                              | Juergen Beisert             |
Linux Solutions for Science and Industry      | http://www.pengutronix.de/  |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [Patch] ARM/MXS/i.MX28: distinguish POR and wake-up event correctly
  2012-11-30 11:14 [Patch] ARM/MXS/i.MX28: distinguish POR and wake-up event correctly Juergen Beisert
@ 2012-12-03  8:50 ` Sascha Hauer
  0 siblings, 0 replies; 2+ messages in thread
From: Sascha Hauer @ 2012-12-03  8:50 UTC (permalink / raw)
  To: Juergen Beisert; +Cc: barebox

On Fri, Nov 30, 2012 at 12:14:04PM +0100, Juergen Beisert wrote:
> When the built-in RTC in the i.MX28 is programmed to wake-up the SoC, the RTC
> reports two events: RST and WAKE. RST is okay in this case, because the PMIC
> was really powered down. But the real event is the WAKE from the RTC and
> should have precedence over the RST event. So, report the WAKE event for this
> special case.
> 
> Signed-off-by: Juergen Beisert <jbe@pengutronix.de>

Applied, thanks

Sascha

> 
> diff --git a/drivers/watchdog/im28wd.c b/drivers/watchdog/im28wd.c
> index ca32a72..bc19369 100644
> --- a/drivers/watchdog/im28wd.c
> +++ b/drivers/watchdog/im28wd.c
> @@ -82,6 +82,17 @@ static void __maybe_unused imx28_detect_reset_source(const struct imx28_wd *p)
>  	if (reg & MXS_RTC_PERSISTENT0_EXT_RST) {
>  		writel(MXS_RTC_PERSISTENT0_EXT_RST,
>  			p->regs + MXS_RTC_PERSISTENT0 + MXS_RTC_CLR_ADDR);
> +		/*
> +		 * if the RTC has woken up the SoC, additionally the ALARM_WAKE
> +		 * bit is set. This bit should have precedence, because it
> +		 * reports the real event, why we are here.
> +		 */
> +		if (reg & MXS_RTC_PERSISTENT0_ALARM_WAKE) {
> +			writel(MXS_RTC_PERSISTENT0_ALARM_WAKE,
> +				p->regs + MXS_RTC_PERSISTENT0 + MXS_RTC_CLR_ADDR);
> +			set_reset_source(RESET_WKE);
> +			return;
> +		}
>  		set_reset_source(RESET_POR);
>  		return;
>  	}
> 
> 
> -- 
> Pengutronix e.K.                              | Juergen Beisert             |
> Linux Solutions for Science and Industry      | http://www.pengutronix.de/  |
> 
> _______________________________________________
> barebox mailing list
> barebox@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox
> 

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2012-12-03  8:50 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-11-30 11:14 [Patch] ARM/MXS/i.MX28: distinguish POR and wake-up event correctly Juergen Beisert
2012-12-03  8:50 ` Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox