Skip to contentSkip to conversation

mx7ulp: Only enable LDO if it is not already enabled

PATCH New Fabio Estevam 3 participants 7 messages Jan 17, 2020 – Feb 3, 2020

Subsystems (3)
lore
Share & tools
lore

Fabio Estevam

author reviewer
#0 lore raw

PATCH 1/1 mx7ulp: Only enable LDO if it is not already enabled

LDO mode may be already enabled by the ROM and enabling it again can cause U-Boot to hang.

Avoid this problem by only enabling LDO mode if it is initially disabled.

---
 arch/arm/mach-imx/mx7ulp/soc.c | 32 +++++++++++++++++---------------
 1 file changed, 17 insertions(+), 15 deletions(-)
arch/arm/mach-imx/mx7ulp/soc.c +17 -15
index 8345b01398..4d84193dec 100644
@@ -117,11 +117,28 @@ void init_wdog(void)
 	disable_wdog(WDG2_RBASE);
 }
 
+#define PMC0_BASE_ADDR		0x410a1000
+#define PMC0_CTRL		0x28
+#define PMC0_CTRL_LDOEN		BIT(31)
+
+static bool ldo_mode_is_enabled(void)
+{
+	unsigned int reg;
+
+	reg = readl(PMC0_BASE_ADDR + PMC0_CTRL);
+	if (reg & PMC0_CTRL_LDOEN)
+		return true;
+	else
+		return false;
+}
 #if defined(CONFIG_LDO_ENABLED_MODE)
 static void init_ldo_mode(void)
 {
 	unsigned int reg;
 
+	if (ldo_mode_is_enabled())
+		return;
+
 	/* Set LDOOKDIS */
 	setbits_le32(PMC0_BASE_ADDR + PMC0_CTRL, PMC0_CTRL_LDOOKDIS);
 
@@ -190,21 +207,6 @@ const char *get_imx_type(u32 imxtype)
 	return "7ULP";
 }
 
-#define PMC0_BASE_ADDR		0x410a1000
-#define PMC0_CTRL		0x28
-#define PMC0_CTRL_LDOEN		BIT(31)
-
-static bool ldo_mode_is_enabled(void)
-{
-	unsigned int reg;
-
-	reg = readl(PMC0_BASE_ADDR + PMC0_CTRL);
-	if (reg & PMC0_CTRL_LDOEN)
-		return true;
-	else
-		return false;
-}
-
 int print_cpuinfo(void)
 {
 	u32 cpurev;
Signature · 1 line
2.17.1
author reviewer
#1 lore raw

PATCH 1/1 mx7ulp: Only enable LDO if it is not already enabled

Hi Jorge,

Quoted 8 lines · Fabio Estevam

LDO mode may be already enabled by the ROM and enabling it again can cause U-Boot to hang.

Avoid this problem by only enabling LDO mode if it is initially disabled.

Please test this patch when you have a chance and if it works for you please provide your Tested-by tag.

Thanks

#2 lore raw

PATCH 1/1 mx7ulp: Only enable LDO if it is not already enabled

Quoted 7 lines · Fabio Estevam

Hi Jorge,

Quoted 4 lines · Fabio Estevam

LDO mode may be already enabled by the ROM and enabling it again can cause U-Boot to hang.

Quoted 7 lines
Quoted 4 lines

Avoid this problem by only enabling LDO mode if it is initially disabled.

Please test this patch when you have a chance and if it works for you please provide your Tested-by tag.

hi Favio

yes I did test it the other day. Do you need me to re-submit your patch or you can add my Tested-by: just as per the reported by?

Quoted 2 lines

Thanks

author reviewer
#3 lore raw

PATCH 1/1 mx7ulp: Only enable LDO if it is not already enabled

Hi Jorge,

Quoted 4 lines · Foundries

hi Favio

yes I did test it the other day. Do you need me to re-submit your patch or you can add my Tested-by: just as per the reported by?

Just reply to this email with your Tested-by and patchwork will pick it.

Thanks

#4 lore raw

PATCH 1/1 mx7ulp: Only enable LDO if it is not already enabled

In reply to Fabio Estevam
Quoted 6 lines · Fabio Estevam

LDO mode may be already enabled by the ROM and enabling it again can cause U-Boot to hang.

Avoid this problem by only enabling LDO mode if it is initially disabled.

Quoted 63 lines
---
 arch/arm/mach-imx/mx7ulp/soc.c | 32 +++++++++++++++++---------------
 1 file changed, 17 insertions(+), 15 deletions(-)
arch/arm/mach-imx/mx7ulp/soc.c +17 -15
index 8345b01398..4d84193dec 100644
@@ -117,11 +117,28 @@ void init_wdog(void)
 	disable_wdog(WDG2_RBASE);
 }
 
+#define PMC0_BASE_ADDR		0x410a1000
+#define PMC0_CTRL		0x28
+#define PMC0_CTRL_LDOEN		BIT(31)
+
+static bool ldo_mode_is_enabled(void)
+{
+	unsigned int reg;
+
+	reg = readl(PMC0_BASE_ADDR + PMC0_CTRL);
+	if (reg & PMC0_CTRL_LDOEN)
+		return true;
+	else
+		return false;
+}
 #if defined(CONFIG_LDO_ENABLED_MODE)
 static void init_ldo_mode(void)
 {
 	unsigned int reg;
 
+	if (ldo_mode_is_enabled())
+		return;
+
 	/* Set LDOOKDIS */
 	setbits_le32(PMC0_BASE_ADDR + PMC0_CTRL, PMC0_CTRL_LDOOKDIS);
 
@@ -190,21 +207,6 @@ const char *get_imx_type(u32 imxtype)
 	return "7ULP";
 }
 
-#define PMC0_BASE_ADDR		0x410a1000
-#define PMC0_CTRL		0x28
-#define PMC0_CTRL_LDOEN		BIT(31)
-
-static bool ldo_mode_is_enabled(void)
-{
-	unsigned int reg;
-
-	reg = readl(PMC0_BASE_ADDR + PMC0_CTRL);
-	if (reg & PMC0_CTRL_LDOEN)
-		return true;
-	else
-		return false;
-}
-
 int print_cpuinfo(void)
 {
 	u32 cpurev;
Signature · 1 line
2.17.1
#5 lore raw

PATCH 1/1 mx7ulp: Only enable LDO if it is not already enabled

In reply to Fabio Estevam

Hi Fabio,

Quoted 16 lines · Fabio Estevam

LDO mode may be already enabled by the ROM and enabling it again can cause U-Boot to hang.

Avoid this problem by only enabling LDO mode if it is initially disabled.

---
 arch/arm/mach-imx/mx7ulp/soc.c | 32 +++++++++++++++++---------------
 1 file changed, 17 insertions(+), 15 deletions(-)
arch/arm/mach-imx/mx7ulp/soc.c +0 -0
index 8345b01398..4d84193dec 100644

arch/arm/mach-imx/mx7ulp/soc.c void init_wdog(void) · line 123

Quoted 7 lines
arch/arm/mach-imx/mx7ulp/soc.c +4 -0
@@ -117,11 +117,28 @@ void init_wdog(void)
 	disable_wdog(WDG2_RBASE);
 }
 
+#define PMC0_BASE_ADDR		0x410a1000
+#define PMC0_CTRL		0x28
+#define PMC0_CTRL_LDOEN		BIT(31)
+

But are they not already defined at the beginning of the file ? They were duplicated later, and you let them duplicated.

Best regards,
Stefano

Quoted 44 lines
arch/arm/mach-imx/mx7ulp/soc.c +13 -15
+static bool ldo_mode_is_enabled(void)
+{
+	unsigned int reg;
+
+	reg = readl(PMC0_BASE_ADDR + PMC0_CTRL);
+	if (reg & PMC0_CTRL_LDOEN)
+		return true;
+	else
+		return false;
+}
 #if defined(CONFIG_LDO_ENABLED_MODE)
 static void init_ldo_mode(void)
 {
 	unsigned int reg;
 
+	if (ldo_mode_is_enabled())
+		return;
+
 	/* Set LDOOKDIS */
 	setbits_le32(PMC0_BASE_ADDR + PMC0_CTRL, PMC0_CTRL_LDOOKDIS);
 
@@ -190,21 +207,6 @@ const char *get_imx_type(u32 imxtype)
 	return "7ULP";
 }
 
-#define PMC0_BASE_ADDR		0x410a1000
-#define PMC0_CTRL		0x28
-#define PMC0_CTRL_LDOEN		BIT(31)
-
-static bool ldo_mode_is_enabled(void)
-{
-	unsigned int reg;
-
-	reg = readl(PMC0_BASE_ADDR + PMC0_CTRL);
-	if (reg & PMC0_CTRL_LDOEN)
-		return true;
-	else
-		return false;
-}
-
 int print_cpuinfo(void)
 {
 	u32 cpurev;
Signature · 5 lines
=====================================================================
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sbabic at denx.de
=====================================================================
author reviewer
#6 lore raw

PATCH 1/1 mx7ulp: Only enable LDO if it is not already enabled

Hi Stefano,

Quoted 2 lines · Stefano Babic

But are they not already defined at the beginning of the file ? They were duplicated later, and you let them duplicated.

Good catch. I have just sent a v2 series fixing this.

Thanks