[PATCH 4/4] ARM/MXS: add reset cause detection

Marc Kleine-Budde mkl at pengutronix.de
Thu Jul 12 15:56:25 EDT 2012


On 07/12/2012 03:47 PM, Juergen Beisert wrote:
> Signed-off-by: Juergen Beisert <jbe at pengutronix.de>
> ---
>  drivers/watchdog/im28wd.c |   25 +++++++++++++++++++++++++
>  1 file changed, 25 insertions(+)
> 
> diff --git a/drivers/watchdog/im28wd.c b/drivers/watchdog/im28wd.c
> index b016910..c465f87 100644
> --- a/drivers/watchdog/im28wd.c
> +++ b/drivers/watchdog/im28wd.c
> @@ -21,6 +21,7 @@
>  #include <errno.h>
>  #include <malloc.h>
>  #include <watchdog.h>
> +#include <reset_source.h>
>  
>  #define MXS_RTC_CTRL 0x0
>  #define MXS_RTC_SET_ADDR 0x4
> @@ -73,6 +74,27 @@ static int imx28_watchdog_set_timeout(struct watchdog *wd, unsigned timeout)
>  	return 0;
>  }
>  
> +static void __maybe_unused imx28_detect_reset_source(const struct imx28_wd *p)
> +{
> +	u32 reg;
> +
> +	reg = readl(p->regs + MXS_RTC_PERSISTENT0);
> +	if (reg & MXS_RTC_PERSISTENT0_EXT_RST) {
> +		writel(MXS_RTC_PERSISTENT0_EXT_RST,
> +			p->regs + MXS_RTC_PERSISTENT0 + MXS_RTC_CLR_ADDR);
> +		set_reset_source(RESET_POR);
> +		return;
> +	}
> +	if (reg & MXS_RTC_PERSISTENT0_THM_RST) {
> +		writel(MXS_RTC_PERSISTENT0_THM_RST,
> +			p->regs + MXS_RTC_PERSISTENT0 + MXS_RTC_CLR_ADDR);
> +		set_reset_source(RESET_RST);
> +		return;
> +	}
> +
> +	set_reset_source(RESET_RST);
> +}
> +
>  static int imx28_wd_probe(struct device_d *dev)
>  {
>  	struct imx28_wd *priv;
> @@ -94,6 +116,9 @@ static int imx28_wd_probe(struct device_d *dev)
>  	if (rc != 0)
>  		goto on_error;
>  
> +#ifdef CONFIG_GLOBALVAR
What about:

	if (IS_ENABLED(CONFIG_GLOBALVAR))

> +	imx28_detect_reset_source(priv);
> +#endif
>  	dev->priv = priv;
>  	return 0;
>  


-- 
Pengutronix e.K.                  | Marc Kleine-Budde           |
Industrial Linux Solutions        | Phone: +49-231-2826-924     |
Vertretung West/Dortmund          | Fax:   +49-5121-206917-5555 |
Amtsgericht Hildesheim, HRA 2686  | http://www.pengutronix.de   |

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 262 bytes
Desc: OpenPGP digital signature
URL: <http://lists.infradead.org/pipermail/barebox/attachments/20120712/d9ac3756/attachment.sig>


More information about the barebox mailing list