All of lore.kernel.org
 help / color / mirror / Atom feed
From: Marek Vasut <marex@denx.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v3] MX28: Check if we are using a valid VBUS for power initialization
Date: Sun, 5 Aug 2012 00:49:04 +0200	[thread overview]
Message-ID: <201208050049.04363.marex@denx.de> (raw)
In-Reply-To: <1344120280-7469-1-git-send-email-otavio@ossystems.com.br>

Dear Otavio Salvador,

> Signed-off-by: Otavio Salvador <otavio@ossystems.com.br>
> ---
> Changes in v2:
> - add comments
> - fix when we have vbus OR vdd5v
> - improve patch short description
> 
> Changes in v3:
> - change short-description prefix
> 
>  arch/arm/cpu/arm926ejs/mx28/spl_power_init.c |   26
> +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7
> deletions(-)
> 
> diff --git a/arch/arm/cpu/arm926ejs/mx28/spl_power_init.c
> b/arch/arm/cpu/arm926ejs/mx28/spl_power_init.c index 4b09b0c..fdf810c
> 100644
> --- a/arch/arm/cpu/arm926ejs/mx28/spl_power_init.c
> +++ b/arch/arm/cpu/arm926ejs/mx28/spl_power_init.c
> @@ -564,6 +564,15 @@ void mx28_batt_boot(void)
>  		0x8 << POWER_5VCTRL_CHARGE_4P2_ILIMIT_OFFSET);
>  }
> 
> +static int mx28_valid_vbus(void)
> +{
> +	struct mx28_power_regs *power_regs =
> +		(struct mx28_power_regs *)MXS_POWER_BASE;
> +
> +	/* iMX23 uses POWER_STS_VBUSVALID_STATUS at same offset */
> +	return readl(&power_regs->hw_power_sts) & POWER_STS_VBUSVALID0_STATUS;
> +}
> +
>  void mx28_handle_5v_conflict(void)
>  {
>  	struct mx28_power_regs *power_regs =
> @@ -577,14 +586,19 @@ void mx28_handle_5v_conflict(void)
>  		tmp = readl(&power_regs->hw_power_sts);
> 
>  		if (tmp & POWER_STS_VDDIO_BO) {
> +			/*
> +			 * VDDIO has a brownout, then the VDD5V_GT_VDDIO becomes
> +			 * unreliable
> +			 */

These should go into separate patch.

>  			mx28_powerdown();
>  			break;
>  		}
> 
> -		if (tmp & POWER_STS_VDD5V_GT_VDDIO) {
> +		if (mx28_valid_vbus() || (tmp & POWER_STS_VDD5V_GT_VDDIO)) {

And if VDD5V_GT_VDDIO isn't true, this will crash.

>  			mx28_boot_valid_5v();
>  			break;
>  		} else {
> +			/* Neither 5v sees 5v so we power down */
>  			mx28_powerdown();
>  			break;
>  		}
> @@ -601,17 +615,15 @@ void mx28_5v_boot(void)
>  	struct mx28_power_regs *power_regs =
>  		(struct mx28_power_regs *)MXS_POWER_BASE;
> 
> -	/*
> -	 * NOTE: In original IMX-Bootlets, this also checks for VBUSVALID,
> -	 * but their implementation always returns 1 so we omit it here.
> -	 */
> -	if (readl(&power_regs->hw_power_sts) & POWER_STS_VDD5V_GT_VDDIO) {
> +	if (mx28_valid_vbus() &&

And again ... you unconditionally add something that will break other boards 
that aren't supplied from 5V. This part isn't present in mx28 bootlets if I'm 
right, yes?

> +		(readl(&power_regs->hw_power_sts) & POWER_STS_VDD5V_GT_VDDIO)) {
>  		mx28_boot_valid_5v();
>  		return;
>  	}
> 
>  	early_delay(1000);
> -	if (readl(&power_regs->hw_power_sts) & POWER_STS_VDD5V_GT_VDDIO) {
> +	if (mx28_valid_vbus() &&
> +		(readl(&power_regs->hw_power_sts) & POWER_STS_VDD5V_GT_VDDIO)) {
>  		mx28_boot_valid_5v();
>  		return;
>  	}

Best regards,
Marek Vasut

  reply	other threads:[~2012-08-04 22:49 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-08-04 22:44 [U-Boot] [PATCH v3] MX28: Check if we are using a valid VBUS for power initialization Otavio Salvador
2012-08-04 22:49 ` Marek Vasut [this message]
2012-08-04 23:23   ` Otavio Salvador
2012-08-04 23:40     ` Marek Vasut

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=201208050049.04363.marex@denx.de \
    --to=marex@denx.de \
    --cc=u-boot@lists.denx.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 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.