Skip to contentSkip to conversation

MX28: Check if we are using a valid VBUS for power initialization

PATCH Superseded Otavio Salvador 2 participants 4 messages Aug 4, 2012 Arm (32-bit)

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 MX28: Check if we are using a valid VBUS for power initialization

---
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(-)
arch/arm/cpu/arm926ejs/mx28/spl_power_init.c +19 -7
index 4b09b0c..fdf810c 100644
@@ -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;
 	}
Signature · 1 line
1.7.10.4
#1 lore raw

PATCH v3 1/1 MX28: Check if we are using a valid VBUS for power initialization

Dear Otavio Salvador,

Quoted 36 lines

---
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(-)

(quoted diff) +0 -0

b/arch/arm/cpu/arm926ejs/mx28/spl_power_init.c index 4b09b0c..fdf810c 100644

arch/arm/cpu/arm926ejs/mx28/spl_power_init.c +9 -0
@@ -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 =

arch/arm/cpu/arm926ejs/mx28/spl_power_init.c void mx28_handle_5v_conflict(void) · line 592

Quoted 7 lines
arch/arm/cpu/arm926ejs/mx28/spl_power_init.c +4 -0
@@ -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.

arch/arm/cpu/arm926ejs/mx28/spl_power_init.c void mx28_handle_5v_conflict(void) · line 597

Quoted 6 lines
arch/arm/cpu/arm926ejs/mx28/spl_power_init.c +1 -1
 			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.

Quoted 8 lines
arch/arm/cpu/arm926ejs/mx28/spl_power_init.c +1 -0
 			mx28_boot_valid_5v();
 			break;
 		} else {
+			/* Neither 5v sees 5v so we power down */
 			mx28_powerdown();
 			break;
 		}

arch/arm/cpu/arm926ejs/mx28/spl_power_init.c void mx28_5v_boot(void) · line 618

Quoted 9 lines
arch/arm/cpu/arm926ejs/mx28/spl_power_init.c +1 -5
@@ -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?

arch/arm/cpu/arm926ejs/mx28/spl_power_init.c void mx28_5v_boot(void) · line 629

Quoted 12 lines
arch/arm/cpu/arm926ejs/mx28/spl_power_init.c +3 -1
+		(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

#2 lore raw

PATCH v3 1/1 MX28: Check if we are using a valid VBUS for power initialization

Quoted 40 lines · Marek Vasut

Dear Otavio Salvador,

Quoted 38 lines

---
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(-)

(quoted diff) +0 -0

b/arch/arm/cpu/arm926ejs/mx28/spl_power_init.c index 4b09b0c..fdf810c 100644

arch/arm/cpu/arm926ejs/mx28/spl_power_init.c +9 -0
@@ -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);
 
Quoted 7 lines

arch/arm/cpu/arm926ejs/mx28/spl_power_init.c void mx28_handle_5v_conflict(void) · line 592

Quoted 5 lines
arch/arm/cpu/arm926ejs/mx28/spl_power_init.c +4 -0
              if (tmp & POWER_STS_VDDIO_BO) {
+                     /*
+                      * VDDIO has a brownout, then the VDD5V_GT_VDDIO becomes
+                      * unreliable
+                      */

These should go into separate patch.

Ok; will split it.

Quoted 8 lines

arch/arm/cpu/arm926ejs/mx28/spl_power_init.c void mx28_handle_5v_conflict(void) · line 597

Quoted 6 lines
arch/arm/cpu/arm926ejs/mx28/spl_power_init.c +1 -1
                      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.

On bootlets mx28_valid_vbus() just returns 1 but the code of mx23 does implement it and on the datasheet of mx28 it seems a valid check.

Quoted 11 lines
Quoted 11 lines
arch/arm/cpu/arm926ejs/mx28/spl_power_init.c +1 -0
                      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;
 
Quoted 10 lines

arch/arm/cpu/arm926ejs/mx28/spl_power_init.c void mx28_5v_boot(void) · line 618

Quoted 6 lines
arch/arm/cpu/arm926ejs/mx28/spl_power_init.c +1 -5
-     /*
-      * 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?

Yes; this check is there too. But the comment about the difference between mx23 and mx28 code is applied here too.

Quoted 5 lines
Quoted 5 lines
arch/arm/cpu/arm926ejs/mx28/spl_power_init.c +1 -0
+             (readl(&power_regs->hw_power_sts) & POWER_STS_VDD5V_GT_VDDIO)) {
              mx28_boot_valid_5v();
              return;
      }
 
Quoted 7 lines

arch/arm/cpu/arm926ejs/mx28/spl_power_init.c void mx28_5v_boot(void) · line 629

Quoted 7 lines
arch/arm/cpu/arm926ejs/mx28/spl_power_init.c +2 -1
      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;
      }

Regards,

Signature · 3 lines
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
#3 lore raw

PATCH v3 1/1 MX28: Check if we are using a valid VBUS for power initialization

Dear Otavio Salvador,

Quoted 5 lines · Marek Vasut
Quoted 4 lines

Dear Otavio Salvador,

Quoted 2 lines

---

[...]

Quoted 7 lines
Quoted 7 lines
Quoted 6 lines
arch/arm/cpu/arm926ejs/mx28/spl_power_init.c +1 -5
-     /*
-      * 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() &&
Quoted 6 lines
Quoted 3 lines

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?

Yes; this check is there too. But the comment about the difference between mx23 and mx28 code is applied here too.

According to 5VCTRL register (mx28 11.12.2) bit 4 (VBUSVALID_5VDETECT), this check is even redundant. Actually, if you don't use the VBUSVALID comparator, this check might fail I think.

Quoted 15 lines
Quoted 15 lines
Quoted 15 lines

+ (readl(&power_regs->hw_power_sts) &
POWER_STS_VDD5V_GT_VDDIO)) {

              mx28_boot_valid_5v();
              return;
      
      }
      
      early_delay(1000);
arch/arm/cpu/arm926ejs/mx28/spl_power_init.c +2 -1
-     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)) {

Quoted 6 lines
Quoted 4 lines
Quoted 4 lines
              mx28_boot_valid_5v();
              return;
      
      }

Regards,

Best regards,
Marek Vasut