Skip to contentSkip to conversation

question: mx7ulp - LDO_ENABLED_MODE

DISCUSSION Jorge Ramirez-Ortiz 2 participants 15 messages Jan 16, 2020 – Jan 17, 2020

Subsystems (3)
lore
Share & tools
lore

Jorge Ramirez-Ortiz

#0 lore raw

Hi Fabio,

I am trying to enable LDO in an imx7ulp based board but somehow the board locks up as soon I write to PMC1_RUN (using the init_ldo_mode sequence).

I think it is interesting that bit PMC0_CTRL_PMC1ON is already set so I am wondering if you think it is possible - in your experience- that ROM might have already configured LDO? or was this also the case - this bit already set- when you tested the feature?

I also noticed that if I dont execute the init_ldo_mode sequence and just check for the LODEN bit [see snipet below], this is already set which too seems strange.

any suggestions or thoughts?

thanks in advance!

Jorge

#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;
}
reviewer
#1 lore raw

Hi Jorge,

Quoted 6 lines · Foundries

Hi Fabio,

I am trying to enable LDO in an imx7ulp based board but somehow the board locks up as soon I write to PMC1_RUN (using the init_ldo_mode sequence).

Just looked at the i.MX7UL Reference Manual and it says:

"28.5.9.1.1 Using internal LDO regulator
After a POR event, when the PMC 0 is running in RUN mode and the PMC 1 is turned off, the process to turn on the PMC 1 using the internal LDO regulator is as follows:
• Assert the LDOEN bit (PMC0_CTRL).
• Assert the LDOOKDIS bit (PMC0_CTRL) if required.
• Assert the PMC1ON bit (PMC0_CTRL)."

So it seems we need to change the order to:

arch/arm/mach-imx/mx7ulp/soc.c +3 -3
@@ -122,9 +122,6 @@ static void init_ldo_mode(void)
 {
        unsigned int reg;
 
-       /* Set LDOOKDIS */
-       setbits_le32(PMC0_BASE_ADDR + PMC0_CTRL, PMC0_CTRL_LDOOKDIS);
-
        /* Set LDOVL to 0.95V in PMC1_RUN */
        reg = readl(PMC1_BASE_ADDR + PMC1_RUN);
        reg &= ~PMC1_LDOVL_MASK;
@@ -151,6 +148,9 @@ static void init_ldo_mode(void)
        /* Set LDOEN bit */
        setbits_le32(PMC0_BASE_ADDR + PMC0_CTRL, PMC0_CTRL_LDOEN);
 
+       /* Set LDOOKDIS */
+       setbits_le32(PMC0_BASE_ADDR + PMC0_CTRL, PMC0_CTRL_LDOOKDIS);
+
        /* Set the PMC1ON bit */
        setbits_le32(PMC0_BASE_ADDR + PMC0_CTRL, PMC0_CTRL_PMC1ON);
 }

Does this help?

Quoted 4 lines

I think it is interesting that bit PMC0_CTRL_PMC1ON is already set so I am wondering if you think it is possible - in your experience- that ROM might have already configured LDO? or was this also the case - this bit already set- when you tested the feature?

I think it was not set by default. I can confirm tomorrow with a i.MX7ULP Embedded Artists board.

Regards,

Fabio Estevam

reviewer
#2 lore raw

Hi Jorge,

Quoted 4 lines · Fabio Estevam
Quoted 4 lines

I think it is interesting that bit PMC0_CTRL_PMC1ON is already set so I am wondering if you think it is possible - in your experience- that ROM might have already configured LDO? or was this also the case - this bit already set- when you tested the feature?

I think I understand the problem now.

We are currently acessing the PMC0 registers, which control the M4 side.

M4 has LDO enabled set by the ROM, so that's why you see it enabled by default.

We need to access the PMC1 registers instead of PMC0.

Could you please test these two patches? (They were only compiled tested)

Regards,

Fabio Estevam
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-ldofixpmc.patch
Type: text/x-patch
Size: 2437 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20200116/6cebbc2d/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0002-ldofixorder.patch
Type: text/x-patch
Size: 1558 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20200116/6cebbc2d/attachment-0001.bin>

reviewer
#3 lore raw

Hi Jorge,

Quoted 1 line · Fabio Estevam

Could you please test these two patches? (They were only compiled tested)

Please discard these patches. Just realized that CTRL is at a different offset for PMC1.

Please try these instead.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-ldofixpmc.patch.patch
Type: text/x-patch
Size: 1890 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20200116/941b10ca/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0002-ldofixorder.patch
Type: text/x-patch
Size: 1566 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20200116/941b10ca/attachment-0001.bin>

#4 lore raw
Quoted 10 lines · Fabio Estevam

Hi Jorge,

Quoted 1 line · Fabio Estevam

Could you please test these two patches? (They were only compiled tested)

Please discard these patches. Just realized that CTRL is at a different offset for PMC1.

Please try these instead.

um still nothing.
will debug more in the morning - will add more debug info. thanks for the quick responses!

jorge

Quoted 112 lines

From 50d4598ae23c549fe3809bfa5f365364ac36d71b Mon Sep 17 00:00:00 2001
From: Fabio Estevam <[email protected]>
Date: Thu, 16 Jan 2020 18:59:30 -0300
Subject: [PATCH 1/2] mx7ulp: Fix the PMC register set

On i.MX7ULP the PMC0 registers control the M4 side and the PMC1 controls the A7 side.

In order to enable the A7 LDO-enabled mode the PMC1 registers need to configured instead.

---
 arch/arm/mach-imx/mx7ulp/soc.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)
arch/arm/mach-imx/mx7ulp/soc.c +5 -4
index 8345b01398..481cfe226a 100644
@@ -16,6 +16,7 @@
 #define PMC0_CTRL_LDOOKDIS	BIT(30)
 #define PMC0_CTRL_PMC1ON	BIT(24)
 #define PMC1_BASE_ADDR		0x40400000
+#define PMC1_CTRL		0x24
 #define PMC1_RUN		0x8
 #define PMC1_STOP		0x10
 #define PMC1_VLPS		0x14
@@ -123,7 +124,7 @@ static void init_ldo_mode(void)
 	unsigned int reg;
 
 	/* Set LDOOKDIS */
-	setbits_le32(PMC0_BASE_ADDR + PMC0_CTRL, PMC0_CTRL_LDOOKDIS);
+	setbits_le32(PMC1_BASE_ADDR + PMC1_CTRL, PMC0_CTRL_LDOOKDIS);
 
 	/* Set LDOVL to 0.95V in PMC1_RUN */
 	reg = readl(PMC1_BASE_ADDR + PMC1_RUN);
@@ -149,10 +150,10 @@ static void init_ldo_mode(void)
 	writel(PMC1_BASE_ADDR + PMC1_VLPS, reg);
 
 	/* Set LDOEN bit */
-	setbits_le32(PMC0_BASE_ADDR + PMC0_CTRL, PMC0_CTRL_LDOEN);
+	setbits_le32(PMC1_BASE_ADDR + PMC1_CTRL, PMC0_CTRL_LDOEN);
 
 	/* Set the PMC1ON bit */
-	setbits_le32(PMC0_BASE_ADDR + PMC0_CTRL, PMC0_CTRL_PMC1ON);
+	setbits_le32(PMC1_BASE_ADDR + PMC1_CTRL, PMC0_CTRL_PMC1ON);
 }
 #endif
 
@@ -198,7 +199,7 @@ static bool ldo_mode_is_enabled(void)
 {
 	unsigned int reg;
 
-	reg = readl(PMC0_BASE_ADDR + PMC0_CTRL);
+	reg = readl(PMC1_BASE_ADDR + PMC1_CTRL);
 	if (reg & PMC0_CTRL_LDOEN)
 		return true;
 	else
Signature · 24 lines
2.17.1


From d1a07fb70610184c042df7f593dd0ff8302235c8 Mon Sep 17 00:00:00 2001
From: Fabio Estevam <[email protected]>
Date: Thu, 16 Jan 2020 19:00:23 -0300
Subject: [PATCH 2/2] mx7ulp: Fix the order for enabling LDO

As per the i.MX7ULP Reference Manual:

"28.5.9.1.1 Using internal LDO regulator
After a POR event, when the PMC 0 is running in RUN mode and the PMC 1 is turned
off, the process to turn on the PMC 1 using the internal LDO regulator
is as follows:
- Assert the LDOEN bit (PMC0_CTRL).
- Assert the LDOOKDIS bit (PMC0_CTRL) if required.
- Assert the PMC1ON bit (PMC0_CTRL)."

So follow the recommended intialization order.

Signed-off-by: Fabio Estevam <[email protected]>
---
 arch/arm/mach-imx/mx7ulp/soc.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
arch/arm/mach-imx/mx7ulp/soc.c +3 -3
index 481cfe226a..9b114a8604 100644
@@ -123,9 +123,6 @@ static void init_ldo_mode(void)
 {
 	unsigned int reg;
 
-	/* Set LDOOKDIS */
-	setbits_le32(PMC1_BASE_ADDR + PMC1_CTRL, PMC0_CTRL_LDOOKDIS);
-
 	/* Set LDOVL to 0.95V in PMC1_RUN */
 	reg = readl(PMC1_BASE_ADDR + PMC1_RUN);
 	reg &= ~PMC1_LDOVL_MASK;
@@ -152,6 +149,9 @@ static void init_ldo_mode(void)
 	/* Set LDOEN bit */
 	setbits_le32(PMC1_BASE_ADDR + PMC1_CTRL, PMC0_CTRL_LDOEN);
 
+	/* Set LDOOKDIS */
+	setbits_le32(PMC1_BASE_ADDR + PMC1_CTRL, PMC0_CTRL_LDOOKDIS);
+
 	/* Set the PMC1ON bit */
 	setbits_le32(PMC1_BASE_ADDR + PMC1_CTRL, PMC0_CTRL_PMC1ON);
 }
Signature · 1 line
2.17.1
reviewer
#5 lore raw
Quoted 3 lines · Gmail

um still nothing.
will debug more in the morning - will add more debug info. thanks for the quick responses!

Ok, just tested mainline U-Boot (without any changes) on my i.MX7ULP boards.

On mx7ulp_evk I see:

PMC1: LDO bypass mode

and on mx7ul_com board I see:

PMC1: LDO enabled mode

The code I did to set and check LDO enabled is according to the RM and it seems to behave properly on these two boards.

Let me know if you make any progress.

Fabio Estevam

#6 lore raw
Quoted 9 lines · Fabio Estevam
Quoted 3 lines · Gmail

um still nothing.
will debug more in the morning - will add more debug info. thanks for the quick responses!

Ok, just tested mainline U-Boot (without any changes) on my i.MX7ULP boards.

Quoted 7 lines

On mx7ulp_evk I see:

PMC1: LDO bypass mode

and on mx7ul_com board I see:

PMC1: LDO enabled mode

right but is the initialization code being executed? please could you check? I also see that message on my board but only as long as the ldo init does not get called.

Quoted 7 lines

The code I did to set and check LDO enabled is according to the RM and it seems to behave properly on these two boards.

Let me know if you make any progress.

Fabio Estevam

#7 lore raw
In reply to Fabio Estevam
Quoted 46 lines · Fabio Estevam

Hi Jorge,

Quoted 6 lines · Foundries

Hi Fabio,

I am trying to enable LDO in an imx7ulp based board but somehow the board locks up as soon I write to PMC1_RUN (using the init_ldo_mode sequence).

Just looked at the i.MX7UL Reference Manual and it says:

"28.5.9.1.1 Using internal LDO regulator
After a POR event, when the PMC 0 is running in RUN mode and the PMC 1 is turned off, the process to turn on the PMC 1 using the internal LDO regulator is as follows:
• Assert the LDOEN bit (PMC0_CTRL).
• Assert the LDOOKDIS bit (PMC0_CTRL) if required.
• Assert the PMC1ON bit (PMC0_CTRL)."

So it seems we need to change the order to:

arch/arm/mach-imx/mx7ulp/soc.c +3 -3
@@ -122,9 +122,6 @@ static void init_ldo_mode(void)
 {
        unsigned int reg;
 
-       /* Set LDOOKDIS */
-       setbits_le32(PMC0_BASE_ADDR + PMC0_CTRL, PMC0_CTRL_LDOOKDIS);
-
        /* Set LDOVL to 0.95V in PMC1_RUN */
        reg = readl(PMC1_BASE_ADDR + PMC1_RUN);
        reg &= ~PMC1_LDOVL_MASK;
@@ -151,6 +148,9 @@ static void init_ldo_mode(void)
        /* Set LDOEN bit */
        setbits_le32(PMC0_BASE_ADDR + PMC0_CTRL, PMC0_CTRL_LDOEN);
 
+       /* Set LDOOKDIS */
+       setbits_le32(PMC0_BASE_ADDR + PMC0_CTRL, PMC0_CTRL_LDOOKDIS);
+
        /* Set the PMC1ON bit */
        setbits_le32(PMC0_BASE_ADDR + PMC0_CTRL, PMC0_CTRL_PMC1ON);
 }
Quoted 1 line

Does this help?

no, unfortunately the same thing.
I think PMC0_CTRL_PMC1ON should not be on but cant figure out who sets it up.

Quoted 8 lines
Quoted 5 lines

I think it is interesting that bit PMC0_CTRL_PMC1ON is already set so I am wondering if you think it is possible - in your experience- that ROM might have already configured LDO? or was this also the case - this bit already set- when you tested the feature?

I think it was not set by default. I can confirm tomorrow with a i.MX7ULP Embedded Artists board.

that would be awesome. thanks a lot!

Quoted 4 lines

Regards,

Fabio Estevam

reviewer
#8 lore raw
In reply to Jorge Ramirez-Ortiz

Hi Jorge,

Quoted 7 lines · Foundries

Hi Fabio,

I am trying to enable LDO in an imx7ulp based board but somehow the board locks up as soon I write to PMC1_RUN (using the init_ldo_mode sequence).

Quoted 8 lines

I think it is interesting that bit PMC0_CTRL_PMC1ON is already set so I am wondering if you think it is possible - in your experience- that ROM might have already configured LDO? or was this also the case - this bit already set- when you tested the feature?

I also noticed that if I dont execute the init_ldo_mode sequence and just check for the LODEN bit [see snipet below], this is already set which too seems strange.

On a i.MX7ULP Embedded Artists board I noticed that LDOEN bit comes set after POR too.

Should we do something like this to avoid re-initializing the PMC1?

arch/arm/mach-imx/mx7ulp/soc.c +3 -0
@@ -122,6 +122,9 @@ 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);
#9 lore raw
Quoted 28 lines · Fabio Estevam

Hi Jorge,

Quoted 7 lines · Foundries

Hi Fabio,

I am trying to enable LDO in an imx7ulp based board but somehow the board locks up as soon I write to PMC1_RUN (using the init_ldo_mode sequence).

Quoted 8 lines

I think it is interesting that bit PMC0_CTRL_PMC1ON is already set so I am wondering if you think it is possible - in your experience- that ROM might have already configured LDO? or was this also the case - this bit already set- when you tested the feature?

I also noticed that if I dont execute the init_ldo_mode sequence and just check for the LODEN bit [see snipet below], this is already set which too seems strange.

On a i.MX7ULP Embedded Artists board I noticed that LDOEN bit comes set after POR too.

Should we do something like this to avoid re-initializing the PMC1?

arch/arm/mach-imx/mx7ulp/soc.c static void init_ldo_mode(void) · line 129

Quoted 8 lines
arch/arm/mach-imx/mx7ulp/soc.c +3 -0
@@ -122,6 +122,9 @@ 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);

not sure about this but I guess it makes sense (btw have you checked in your boards if the init_ldo_mode code executes all the write steps?)

when I check the voltage configuration for PMC1_RUN it does not show 0.95V but the default (1.0V - ie: 0x28 at offset 0x08 bits 21-16). I still havent figured out who might be configuring/enabling it for the A7 though.

#10 lore raw
In reply to Fabio Estevam
Quoted 28 lines · Fabio Estevam

Hi Jorge,

Quoted 7 lines · Foundries

Hi Fabio,

I am trying to enable LDO in an imx7ulp based board but somehow the board locks up as soon I write to PMC1_RUN (using the init_ldo_mode sequence).

Quoted 8 lines

I think it is interesting that bit PMC0_CTRL_PMC1ON is already set so I am wondering if you think it is possible - in your experience- that ROM might have already configured LDO? or was this also the case - this bit already set- when you tested the feature?

I also noticed that if I dont execute the init_ldo_mode sequence and just check for the LODEN bit [see snipet below], this is already set which too seems strange.

On a i.MX7ULP Embedded Artists board I noticed that LDOEN bit comes set after POR too.

Should we do something like this to avoid re-initializing the PMC1?

arch/arm/mach-imx/mx7ulp/soc.c static void init_ldo_mode(void) · line 129

Quoted 8 lines
arch/arm/mach-imx/mx7ulp/soc.c +3 -0
@@ -122,6 +122,9 @@ 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);

btw was checking the TRM manual (Chapter 28, PMC - page 1172)

[..]
PMC1 power mode[LDOVL] fields don’t necessarily satisfy the operation voltage levels required by the system. Such operation voltage requirements can be found on i.MX 7ULP Data Sheet. In this sense, no power transition should be performed before ensuring the mentioned register fields are matching the required operation voltage levels expressed on the data sheet.

=> 0.95V in the ldt_init function, is it in the data sheet? I just cant find that particular document

reviewer
#11 lore raw
Quoted 11 lines · Gmail

btw was checking the TRM manual (Chapter 28, PMC - page 1172)

[..]
PMC1 power mode[LDOVL] fields don’t necessarily satisfy the operation voltage levels required by the system. Such operation voltage requirements can be found on i.MX 7ULP Data Sheet. In this sense, no power transition should be performed before ensuring the mentioned register fields are matching the required operation voltage levels expressed on the data sheet.

=> 0.95V in the ldt_init function, is it in the data sheet? I just cant find that particular document

Yes, please take a look at https://www.nxp.com/docs/en/data-sheet/IMX7ULPCEC.pdf

(Table 5 - Search for PMC1_STOP[LDOVL] where it shows 0.95V as the typical value)

#12 lore raw
Quoted 12 lines · Fabio Estevam
Quoted 9 lines · Gmail

btw was checking the TRM manual (Chapter 28, PMC - page 1172)

[..]
PMC1 power mode[LDOVL] fields don’t necessarily satisfy the operation voltage levels required by the system. Such operation voltage requirements can be found on i.MX 7ULP Data Sheet. In this sense, no power transition should be performed before ensuring the mentioned register fields are matching the required operation voltage levels expressed on the data sheet.

Quoted 7 lines
Quoted 2 lines

=> 0.95V in the ldt_init function, is it in the data sheet? I just cant find that particular document

Yes, please take a look at https://www.nxp.com/docs/en/data-sheet/IMX7ULPCEC.pdf

(Table 5 - Search for PMC1_STOP[LDOVL] where it shows 0.95V as the typical value)

thanks a lot Favio. The part I am working with is 08SC. (not 05 or 07). Is that the same as yours?

wondering if something is different for this part...

reviewer
#13 lore raw
Quoted 2 lines · Gmail

thanks a lot Favio. The part I am working with is 08SC. (not 05 or 07). Is that the same as yours?

On the Embedded Artists board there is a 08SC i.MX7ULP version.

On the i.MX7ULP EVK that I have access to there is a 05SC.

On the 08SC part I do see that it comes with LDOEN turned on by default.

On the 05SC part it comes with LDOEN turned off by default.

I wondering if we should go ahead with this fix:
http://code.bulix.org/5gfb8t-1094747

In case LDO is already enabled, then we use the LDO settings that were configured by the ROM.

Does this fix the hang problem?

#14 lore raw
Quoted 8 lines · Fabio Estevam
Quoted 2 lines · Gmail

thanks a lot Favio. The part I am working with is 08SC. (not 05 or 07). Is that the same as yours?

On the Embedded Artists board there is a 08SC i.MX7ULP version.

Quoted 8 lines

On the i.MX7ULP EVK that I have access to there is a 05SC.

On the 08SC part I do see that it comes with LDOEN turned on by default.

On the 05SC part it comes with LDOEN turned off by default.

I wondering if we should go ahead with this fix:
http://code.bulix.org/5gfb8t-1094747

yes I think so.

Quoted 3 lines

In case LDO is already enabled, then we use the LDO settings that were configured by the ROM.

yeah sounds good to me. I triple check in case the M4 was setting the LDO (who knows) but is not being done by my firmware. So it must be the ROM

Quoted 2 lines

Does this fix the hang problem?

yes