diff mbox series

mx7ulp: Only enable LDO if it is not already enabled

Message ID 20200117190714.14998-1-festevam@gmail.com
State New
Headers show
Series mx7ulp: Only enable LDO if it is not already enabled | expand

Commit Message

Fabio Estevam Jan. 17, 2020, 7:07 p.m. UTC
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.

Reported-by: Jorge Ramirez-Ortiz <jorge at foundries.io>
Signed-off-by: Fabio Estevam <festevam at gmail.com>
---
 arch/arm/mach-imx/mx7ulp/soc.c | 32 +++++++++++++++++---------------
 1 file changed, 17 insertions(+), 15 deletions(-)

Comments

Fabio Estevam Jan. 20, 2020, 4:20 p.m. UTC | #1
Hi Jorge,

On Fri, Jan 17, 2020 at 4:07 PM Fabio Estevam <festevam at gmail.com> wrote:
>
> 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.
>
> Reported-by: Jorge Ramirez-Ortiz <jorge at foundries.io>
> Signed-off-by: Fabio Estevam <festevam at gmail.com>

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

Thanks
Jorge Ramirez-Ortiz, Foundries Jan. 20, 2020, 5:38 p.m. UTC | #2
On 20/01/20 13:20:11, Fabio Estevam wrote:
> Hi Jorge,
> 
> On Fri, Jan 17, 2020 at 4:07 PM Fabio Estevam <festevam at gmail.com> wrote:
> >
> > 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.
> >
> > Reported-by: Jorge Ramirez-Ortiz <jorge at foundries.io>
> > Signed-off-by: Fabio Estevam <festevam at gmail.com>
> 
> 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?

> 
> Thanks
Fabio Estevam Jan. 20, 2020, 5:39 p.m. UTC | #3
Hi Jorge,

On Mon, Jan 20, 2020 at 2:38 PM Jorge Ramirez-Ortiz, Foundries
<jorge at foundries.io> wrote:

> 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
Jorge Ramirez-Ortiz, Foundries Jan. 20, 2020, 6:13 p.m. UTC | #4
On 17/01/20 16:07:14, Fabio Estevam wrote:
> 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.
> 
> Reported-by: Jorge Ramirez-Ortiz <jorge at foundries.io>

Tested-by: Jorge Ramirez-Ortiz <jorge at foundries.io>

> Signed-off-by: Fabio Estevam <festevam at gmail.com>
> ---
>  arch/arm/mach-imx/mx7ulp/soc.c | 32 +++++++++++++++++---------------
>  1 file changed, 17 insertions(+), 15 deletions(-)
> 
> diff --git a/arch/arm/mach-imx/mx7ulp/soc.c b/arch/arm/mach-imx/mx7ulp/soc.c
> index 8345b01398..4d84193dec 100644
> --- a/arch/arm/mach-imx/mx7ulp/soc.c
> +++ b/arch/arm/mach-imx/mx7ulp/soc.c
> @@ -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;
> -- 
> 2.17.1
>
diff mbox series

Patch

diff --git a/arch/arm/mach-imx/mx7ulp/soc.c b/arch/arm/mach-imx/mx7ulp/soc.c
index 8345b01398..4d84193dec 100644
--- a/arch/arm/mach-imx/mx7ulp/soc.c
+++ b/arch/arm/mach-imx/mx7ulp/soc.c
@@ -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;