* [U-Boot] [PATCH v2] i.MX28: Check if we are using a valid VBUS for power initialization
@ 2012-07-16 21:44 Otavio Salvador
2012-07-16 21:46 ` Marek Vasut
0 siblings, 1 reply; 3+ messages in thread
From: Otavio Salvador @ 2012-07-16 21:44 UTC (permalink / raw)
To: u-boot
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
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@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
+ */
mx28_powerdown();
break;
}
- if (tmp & POWER_STS_VDD5V_GT_VDDIO) {
+ if (mx28_valid_vbus() || (tmp & POWER_STS_VDD5V_GT_VDDIO)) {
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() &&
+ (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;
}
--
1.7.10.4
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [U-Boot] [PATCH v2] i.MX28: Check if we are using a valid VBUS for power initialization
2012-07-16 21:44 [U-Boot] [PATCH v2] i.MX28: Check if we are using a valid VBUS for power initialization Otavio Salvador
@ 2012-07-16 21:46 ` Marek Vasut
2012-07-16 21:53 ` Otavio Salvador
0 siblings, 1 reply; 3+ messages in thread
From: Marek Vasut @ 2012-07-16 21:46 UTC (permalink / raw)
To: u-boot
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
>
> 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
> + */
> mx28_powerdown();
> break;
> }
>
> - if (tmp & POWER_STS_VDD5V_GT_VDDIO) {
> + if (mx28_valid_vbus() || (tmp & POWER_STS_VDD5V_GT_VDDIO)) {
> 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() &&
> + (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() &&
This is still likely to break any device that doesn't source it's 5V power
supply from USB
> + (readl(&power_regs->hw_power_sts) & POWER_STS_VDD5V_GT_VDDIO)) {
> mx28_boot_valid_5v();
> return;
> }
Best regards,
Marek Vasut
^ permalink raw reply [flat|nested] 3+ messages in thread
* [U-Boot] [PATCH v2] i.MX28: Check if we are using a valid VBUS for power initialization
2012-07-16 21:46 ` Marek Vasut
@ 2012-07-16 21:53 ` Otavio Salvador
0 siblings, 0 replies; 3+ messages in thread
From: Otavio Salvador @ 2012-07-16 21:53 UTC (permalink / raw)
To: u-boot
On Mon, Jul 16, 2012 at 6:46 PM, Marek Vasut <marek.vasut@gmail.com> wrote:
...
>> early_delay(1000);
>> - if (readl(&power_regs->hw_power_sts) & POWER_STS_VDD5V_GT_VDDIO) {
>> + if (mx28_valid_vbus() &&
>
> This is still likely to break any device that doesn't source it's 5V power
> supply from USB
I might be missing something here but the conflict function handles
this case and if any is available it boots.
--
Otavio Salvador O.S. Systems
E-mail: otavio at ossystems.com.br http://www.ossystems.com.br
Mobile: +55 53 9981-7854 http://projetos.ossystems.com.br
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2012-07-16 21:53 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-07-16 21:44 [U-Boot] [PATCH v2] i.MX28: Check if we are using a valid VBUS for power initialization Otavio Salvador
2012-07-16 21:46 ` Marek Vasut
2012-07-16 21:53 ` Otavio Salvador
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.