mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: Wolfram Sang <w.sang@pengutronix.de>
Cc: barebox@lists.infradead.org
Subject: Re: [PATCH 1/3] arm: mxs: use timeouts in block reset routines
Date: Wed, 31 Oct 2012 08:37:05 +0100	[thread overview]
Message-ID: <20121031073705.GJ1641@pengutronix.de> (raw)
In-Reply-To: <1351606875-31558-1-git-send-email-w.sang@pengutronix.de>

On Tue, Oct 30, 2012 at 03:21:13PM +0100, Wolfram Sang wrote:
> These routines can fail, add support for that. Also, put in missing
> copyright headers.
> 
> Signed-off-by: Wolfram Sang <w.sang@pengutronix.de>

Applied, thanks

Sascha

> ---
>  arch/arm/mach-mxs/common.c |   39 +++++++++++++++++++++++++++++++++++----
>  1 file changed, 35 insertions(+), 4 deletions(-)
> 
> diff --git a/arch/arm/mach-mxs/common.c b/arch/arm/mach-mxs/common.c
> index 3730633..122d883 100644
> --- a/arch/arm/mach-mxs/common.c
> +++ b/arch/arm/mach-mxs/common.c
> @@ -1,8 +1,26 @@
> +/*
> + * Freescale i.MXS common code
> + *
> + * Copyright (C) 2012 Wolfram Sang <w.sang@pengutronix.de>
> + *
> + * Based on code from LTIB:
> + * Copyright (C) 2010 Freescale Semiconductor, Inc.
> + *
> + * This program is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU General Public License as
> + * published by the Free Software Foundation; either version 2 of
> + * the License, or (at your option) any later version.
> + */
> +
>  #include <common.h>
>  #include <io.h>
> +#include <errno.h>
> +#include <clock.h>
>  #include <mach/mxs.h>
>  #include <mach/imx-regs.h>
>  
> +#define	MXS_IP_RESET_TIMEOUT	(10 * MSECOND)
> +
>  #define	MXS_BLOCK_SFTRST				(1 << 31)
>  #define	MXS_BLOCK_CLKGATE				(1 << 30)
>  
> @@ -10,7 +28,9 @@ int mxs_reset_block(void __iomem *reg, int just_enable)
>  {
>  	/* Clear SFTRST */
>  	writel(MXS_BLOCK_SFTRST, reg + BIT_CLR);
> -	mdelay(1);
> +
> +	if (wait_on_timeout(MXS_IP_RESET_TIMEOUT, !(readl(reg) & MXS_BLOCK_SFTRST)))
> +		goto timeout;
>  
>  	/* Clear CLKGATE */
>  	writel(MXS_BLOCK_CLKGATE, reg + BIT_CLR);
> @@ -18,16 +38,27 @@ int mxs_reset_block(void __iomem *reg, int just_enable)
>  	if (!just_enable) {
>  		/* Set SFTRST */
>  		writel(MXS_BLOCK_SFTRST, reg + BIT_SET);
> -		mdelay(1);
> +
> +		/* Wait for CLKGATE being set */
> +		if (wait_on_timeout(MXS_IP_RESET_TIMEOUT, readl(reg) & MXS_BLOCK_CLKGATE))
> +			goto timeout;
>  	}
>  
>  	/* Clear SFTRST */
>  	writel(MXS_BLOCK_SFTRST, reg + BIT_CLR);
> -	mdelay(1);
> +
> +	if (wait_on_timeout(MXS_IP_RESET_TIMEOUT, !(readl(reg) & MXS_BLOCK_SFTRST)))
> +		goto timeout;
>  
>  	/* Clear CLKGATE */
>  	writel(MXS_BLOCK_CLKGATE, reg + BIT_CLR);
> -	mdelay(1);
> +
> +	if (wait_on_timeout(MXS_IP_RESET_TIMEOUT, !(readl(reg) & MXS_BLOCK_CLKGATE)))
> +		goto timeout;
>  
>  	return 0;
> +
> +timeout:
> +	printf("MXS: Timeout resetting block via register 0x%p\n", reg);
> +	return -ETIMEDOUT;
>  }
> -- 
> 1.7.10.4
> 
> 
> _______________________________________________
> 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

      parent reply	other threads:[~2012-10-31  7:37 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-10-30 14:21 Wolfram Sang
2012-10-30 14:21 ` [PATCH 2/3] dma: apbh: check for errors when resetting ip core Wolfram Sang
2012-10-31  8:29   ` Juergen Beisert
2012-10-31  8:36     ` Wolfram Sang
2012-10-31  8:48       ` Juergen Beisert
2012-10-31  8:54         ` Wolfram Sang
2012-10-31  9:29           ` Juergen Beisert
2012-10-31  9:39             ` Wolfram Sang
2012-10-30 14:21 ` [PATCH 3/3] mtd: nand: mxs: " Wolfram Sang
2012-10-31  7:37 ` Sascha Hauer [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=20121031073705.GJ1641@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    --cc=w.sang@pengutronix.de \
    /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