[PATCH 1/5] arm: mxs: Provide Kconfig option to to not use VDD5V as IMX28 PMU source

This option sets the current limit for 5V source to zero, so all the PMU outputs are primarily powered from battery source (DCDC_BAT).
This option may be set on systems, where the 5V is NOT supposed to be in any scenario powering the system - for example on systems where DCDC_BAT is connected to fixed and regulated 4.2V source (so the "battery" is not present).
Signed-off-by: Lukasz Majewski lukma@denx.de --- arch/arm/cpu/arm926ejs/mxs/spl_power_init.c | 4 ++++ arch/arm/mach-imx/mxs/Kconfig | 8 ++++++++ 2 files changed, 12 insertions(+)
diff --git a/arch/arm/cpu/arm926ejs/mxs/spl_power_init.c b/arch/arm/cpu/arm926ejs/mxs/spl_power_init.c index c33170f06d..9965810ac2 100644 --- a/arch/arm/cpu/arm926ejs/mxs/spl_power_init.c +++ b/arch/arm/cpu/arm926ejs/mxs/spl_power_init.c @@ -752,6 +752,10 @@ static void mxs_batt_boot(void) POWER_5VCTRL_CHARGE_4P2_ILIMIT_MASK, 0x8 << POWER_5VCTRL_CHARGE_4P2_ILIMIT_OFFSET);
+ if (CONFIG_IS_ENABLED(MXS_PMU_MINIMAL_VDD5V_CURRENT)) + setbits_le32(&power_regs->hw_power_5vctrl, + POWER_5VCTRL_ILIMIT_EQ_ZERO); + mxs_power_enable_4p2(); }
diff --git a/arch/arm/mach-imx/mxs/Kconfig b/arch/arm/mach-imx/mxs/Kconfig index b2026a3758..3232b0fb67 100644 --- a/arch/arm/mach-imx/mxs/Kconfig +++ b/arch/arm/mach-imx/mxs/Kconfig @@ -51,6 +51,14 @@ endchoice config SYS_SOC default "mxs"
+config SPL_MXS_PMU_MINIMAL_VDD5V_CURRENT + bool "Force minimal current draw from VDD5V by MX28 PMU" + default n + help + After setting this option, the current drawn from VDD5V + by the PMU is reduced to zero - the DCDC_BATT is used as + the main power source for PMU. + source "board/freescale/mx28evk/Kconfig" source "board/liebherr/xea/Kconfig"

This new Kconfig option allows disabling the in-PMU battery charging block. This may be required when DCDC_BAT source is powered not from battery, but from already regulated, good quality source.
Signed-off-by: Lukasz Majewski lukma@denx.de --- arch/arm/cpu/arm926ejs/mxs/spl_power_init.c | 7 +++++++ arch/arm/mach-imx/mxs/Kconfig | 4 ++++ 2 files changed, 11 insertions(+)
diff --git a/arch/arm/cpu/arm926ejs/mxs/spl_power_init.c b/arch/arm/cpu/arm926ejs/mxs/spl_power_init.c index 9965810ac2..7c584db27c 100644 --- a/arch/arm/cpu/arm926ejs/mxs/spl_power_init.c +++ b/arch/arm/cpu/arm926ejs/mxs/spl_power_init.c @@ -756,6 +756,13 @@ static void mxs_batt_boot(void) setbits_le32(&power_regs->hw_power_5vctrl, POWER_5VCTRL_ILIMIT_EQ_ZERO);
+ if (CONFIG_IS_ENABLED(MXS_PMU_DISABLE_BATT_CHARGE)) { + writel(POWER_CHARGE_PWD_BATTCHRG, + &power_regs->hw_power_charge_set); + writel(POWER_5VCTRL_PWD_CHARGE_4P2_MASK, + &power_regs->hw_power_5vctrl_set); + } + mxs_power_enable_4p2(); }
diff --git a/arch/arm/mach-imx/mxs/Kconfig b/arch/arm/mach-imx/mxs/Kconfig index 3232b0fb67..f5e45ae846 100644 --- a/arch/arm/mach-imx/mxs/Kconfig +++ b/arch/arm/mach-imx/mxs/Kconfig @@ -59,6 +59,10 @@ config SPL_MXS_PMU_MINIMAL_VDD5V_CURRENT by the PMU is reduced to zero - the DCDC_BATT is used as the main power source for PMU.
+config SPL_MXS_PMU_DISABLE_BATT_CHARGE + bool "Disable Battery Charging in MX28 PMU" + default n + source "board/freescale/mx28evk/Kconfig" source "board/liebherr/xea/Kconfig"

This new Kconfig option allows disabling the in-PMU battery charging block. This may be required when DCDC_BAT source is powered not from battery, but from already regulated, good quality source. Signed-off-by: Lukasz Majewski lukma@denx.de
Applied to u-boot-imx, master, thanks !
Best regards, Stefano Babic

The IMX28 PMU (Power Management Unit) has a dedicated Linear Regulator to produce (by default) 4.2V output - available outside the chip as VDD_4P2.
When system is supposed to not use VDD5V as a main power source - instead the DCDC_BATT is used; it is safe to disable this regulator.
As the in-PMU DCDC switching regulator (from which DCDC_VDDA, DCDC_VDDIO and DCDC_VDDD are generated) can be driven from DCDC_BATT or output of this 4P2 regulator - by disabling the latter the use of the DCDC_BATT is forced.
To be more specific - according to NXP's AN4199 the DCDC_BATT source is preferred (over VDD5V), as more efficient and stable source for industrial applications.
Signed-off-by: Lukasz Majewski lukma@denx.de --- arch/arm/cpu/arm926ejs/mxs/spl_power_init.c | 3 ++- arch/arm/mach-imx/mxs/Kconfig | 7 +++++++ 2 files changed, 9 insertions(+), 1 deletion(-)
diff --git a/arch/arm/cpu/arm926ejs/mxs/spl_power_init.c b/arch/arm/cpu/arm926ejs/mxs/spl_power_init.c index 7c584db27c..24f61b4b56 100644 --- a/arch/arm/cpu/arm926ejs/mxs/spl_power_init.c +++ b/arch/arm/cpu/arm926ejs/mxs/spl_power_init.c @@ -763,7 +763,8 @@ static void mxs_batt_boot(void) &power_regs->hw_power_5vctrl_set); }
- mxs_power_enable_4p2(); + if (CONFIG_IS_ENABLED(MXS_PMU_ENABLE_4P2_LINEAR_REGULATOR)) + mxs_power_enable_4p2(); }
/** diff --git a/arch/arm/mach-imx/mxs/Kconfig b/arch/arm/mach-imx/mxs/Kconfig index f5e45ae846..5cffc26103 100644 --- a/arch/arm/mach-imx/mxs/Kconfig +++ b/arch/arm/mach-imx/mxs/Kconfig @@ -63,6 +63,13 @@ config SPL_MXS_PMU_DISABLE_BATT_CHARGE bool "Disable Battery Charging in MX28 PMU" default n
+config SPL_MXS_PMU_ENABLE_4P2_LINEAR_REGULATOR + bool "Enable the 4P2 linear regulator in MX28 PMU" + default y + help + This option enables the 4P2 linear regulator (derived + from VDD5V) - so the VDD4P2 power source is operational. + source "board/freescale/mx28evk/Kconfig" source "board/liebherr/xea/Kconfig"

The IMX28 PMU (Power Management Unit) has a dedicated Linear Regulator to produce (by default) 4.2V output - available outside the chip as VDD_4P2. When system is supposed to not use VDD5V as a main power source - instead the DCDC_BATT is used; it is safe to disable this regulator. As the in-PMU DCDC switching regulator (from which DCDC_VDDA, DCDC_VDDIO and DCDC_VDDD are generated) can be driven from DCDC_BATT or output of this 4P2 regulator - by disabling the latter the use of the DCDC_BATT is forced. To be more specific - according to NXP's AN4199 the DCDC_BATT source is preferred (over VDD5V), as more efficient and stable source for industrial applications. Signed-off-by: Lukasz Majewski lukma@denx.de
Applied to u-boot-imx, master, thanks !
Best regards, Stefano Babic

This commit provides function, which when debugging output is enabled dumps the IMX28 PMU registers.
Signed-off-by: Lukasz Majewski lukma@denx.de --- arch/arm/cpu/arm926ejs/mxs/spl_power_init.c | 24 +++++++++++++++++++++ 1 file changed, 24 insertions(+)
diff --git a/arch/arm/cpu/arm926ejs/mxs/spl_power_init.c b/arch/arm/cpu/arm926ejs/mxs/spl_power_init.c index 24f61b4b56..7ea029e371 100644 --- a/arch/arm/cpu/arm926ejs/mxs/spl_power_init.c +++ b/arch/arm/cpu/arm926ejs/mxs/spl_power_init.c @@ -41,6 +41,29 @@ static void mxs_power_clock2xtal(void) &clkctrl_regs->hw_clkctrl_clkseq_set); }
+static void mxs_power_regs_dump(void) +{ + struct mxs_power_regs *power_regs = + (struct mxs_power_regs *)MXS_POWER_BASE; + + debug("ctrl:\t\t 0x%x\n", readl(&power_regs->hw_power_ctrl)); + debug("5vctrl:\t\t 0x%x\n", readl(&power_regs->hw_power_5vctrl)); + debug("minpwr:\t\t 0x%x\n", readl(&power_regs->hw_power_minpwr)); + debug("charge:\t\t 0x%x\n", readl(&power_regs->hw_power_charge)); + debug("vddctrl:\t 0x%x\n", readl(&power_regs->hw_power_vdddctrl)); + debug("vddactrl:\t 0x%x\n", readl(&power_regs->hw_power_vddactrl)); + debug("vddioctrl:\t 0x%x\n", readl(&power_regs->hw_power_vddioctrl)); + debug("vddmemctrl:\t 0x%x\n", readl(&power_regs->hw_power_vddmemctrl)); + debug("dcdc4p2:\t 0x%x\n", readl(&power_regs->hw_power_dcdc4p2)); + debug("misc:\t\t 0x%x\n", readl(&power_regs->hw_power_misc)); + debug("dclimits:\t 0x%x\n", readl(&power_regs->hw_power_dclimits)); + debug("loopctrl:\t 0x%x\n", readl(&power_regs->hw_power_loopctrl)); + debug("sts:\t\t 0x%x\n", readl(&power_regs->hw_power_sts)); + debug("speed:\t\t 0x%x\n", readl(&power_regs->hw_power_speed)); + debug("battmonitor:\t 0x%x\n", + readl(&power_regs->hw_power_battmonitor)); +} + /** * mxs_power_clock2pll() - Switch CPU core clock source to PLL * @@ -1280,6 +1303,7 @@ void mxs_power_init(void) POWER_CTRL_DCDC4P2_BO_IRQ, &power_regs->hw_power_ctrl_clr);
writel(POWER_5VCTRL_PWDN_5VBRNOUT, &power_regs->hw_power_5vctrl_set); + mxs_power_regs_dump();
early_delay(1000); }

This commit provides function, which when debugging output is enabled dumps the IMX28 PMU registers. Signed-off-by: Lukasz Majewski lukma@denx.de
Applied to u-boot-imx, master, thanks !
Best regards, Stefano Babic

This patch adjusts XEA's PMU setup as this board is supposed to be mainly powered from DCDC_BATT source.
Moreover, in this HW design the VDD_4P2 is not used as well.
Signed-off-by: Lukasz Majewski lukma@denx.de --- configs/imx28_xea_defconfig | 3 +++ 1 file changed, 3 insertions(+)
diff --git a/configs/imx28_xea_defconfig b/configs/imx28_xea_defconfig index 579545f4ed..3d92a06999 100644 --- a/configs/imx28_xea_defconfig +++ b/configs/imx28_xea_defconfig @@ -13,6 +13,9 @@ CONFIG_SPL_DM_SPI=y CONFIG_DEFAULT_DEVICE_TREE="imx28-xea" CONFIG_SPL_TEXT_BASE=0x1000 CONFIG_TARGET_XEA=y +CONFIG_SPL_MXS_PMU_MINIMAL_VDD5V_CURRENT=y +CONFIG_SPL_MXS_PMU_DISABLE_BATT_CHARGE=y +# CONFIG_SPL_MXS_PMU_ENABLE_4P2_LINEAR_REGULATOR is not set CONFIG_SPL_MMC=y CONFIG_SPL_SERIAL=y CONFIG_SPL_STACK=0x20000

This patch adjusts XEA's PMU setup as this board is supposed to be mainly powered from DCDC_BATT source. Moreover, in this HW design the VDD_4P2 is not used as well. Signed-off-by: Lukasz Majewski lukma@denx.de
Applied to u-boot-imx, master, thanks !
Best regards, Stefano Babic

On 5/9/23 16:32, Lukasz Majewski wrote:
This option sets the current limit for 5V source to zero, so all the PMU outputs are primarily powered from battery source (DCDC_BAT).
This option may be set on systems, where the 5V is NOT supposed to be in any scenario powering the system - for example on systems where DCDC_BAT is connected to fixed and regulated 4.2V source (so the "battery" is not present).
Is it possible to dig this information out of DT or is the DT not available in SPL for this platform ?

Hi Marek,
On 5/9/23 16:32, Lukasz Majewski wrote:
This option sets the current limit for 5V source to zero, so all the PMU outputs are primarily powered from battery source (DCDC_BAT).
This option may be set on systems, where the 5V is NOT supposed to be in any scenario powering the system - for example on systems where DCDC_BAT is connected to fixed and regulated 4.2V source (so the "battery" is not present).
Is it possible to dig this information out of DT or is the DT not available in SPL for this platform ?
This platform uses only SPL_OF_PLATDATA to keep the SPL size < 40 KiB.
I would prefer to keep this as Kconfig as the PMU driver is not supporting DT and in fact now ARCH_MX28 only has two boards supported - XEA and imx28evk.
Best regards,
Lukasz Majewski
--
DENX Software Engineering GmbH, Managing Director: Erika Unter HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-59 Fax: (+49)-8142-66989-80 Email: lukma@denx.de

On 5/9/23 16:46, Lukasz Majewski wrote:
Hi Marek,
Hi,
On 5/9/23 16:32, Lukasz Majewski wrote:
This option sets the current limit for 5V source to zero, so all the PMU outputs are primarily powered from battery source (DCDC_BAT).
This option may be set on systems, where the 5V is NOT supposed to be in any scenario powering the system - for example on systems where DCDC_BAT is connected to fixed and regulated 4.2V source (so the "battery" is not present).
Is it possible to dig this information out of DT or is the DT not available in SPL for this platform ?
This platform uses only SPL_OF_PLATDATA to keep the SPL size < 40 KiB.
I would prefer to keep this as Kconfig as the PMU driver is not supporting DT and in fact now ARCH_MX28 only has two boards supported - XEA and imx28evk.
Why not use the platdata then ? This makes it far better, as the code is actually always compiled and doesn't start to bitrot.

Hi Marek,
On 5/9/23 16:46, Lukasz Majewski wrote:
Hi Marek,
Hi,
On 5/9/23 16:32, Lukasz Majewski wrote:
This option sets the current limit for 5V source to zero, so all the PMU outputs are primarily powered from battery source (DCDC_BAT).
This option may be set on systems, where the 5V is NOT supposed to be in any scenario powering the system - for example on systems where DCDC_BAT is connected to fixed and regulated 4.2V source (so the "battery" is not present).
Is it possible to dig this information out of DT or is the DT not available in SPL for this platform ?
This platform uses only SPL_OF_PLATDATA to keep the SPL size < 40 KiB.
I would prefer to keep this as Kconfig as the PMU driver is not supporting DT and in fact now ARCH_MX28 only has two boards supported - XEA and imx28evk.
Why not use the platdata then ? This makes it far better, as the code is actually always compiled and doesn't start to bitrot.
As fair as I can tell - the MX28 PMU driver in SPL is not supporting OF_PLATDATA. Or have I overlooked something?
I would like to investigate the PMU issue, and avoid extra work to provide platdata support for two supported imx287 based boards.
Best regards,
Lukasz Majewski
--
DENX Software Engineering GmbH, Managing Director: Erika Unter HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-59 Fax: (+49)-8142-66989-80 Email: lukma@denx.de

On 5/9/23 17:04, Lukasz Majewski wrote:
Hi Marek,
On 5/9/23 16:46, Lukasz Majewski wrote:
Hi Marek,
Hi,
On 5/9/23 16:32, Lukasz Majewski wrote:
This option sets the current limit for 5V source to zero, so all the PMU outputs are primarily powered from battery source (DCDC_BAT).
This option may be set on systems, where the 5V is NOT supposed to be in any scenario powering the system - for example on systems where DCDC_BAT is connected to fixed and regulated 4.2V source (so the "battery" is not present).
Is it possible to dig this information out of DT or is the DT not available in SPL for this platform ?
This platform uses only SPL_OF_PLATDATA to keep the SPL size < 40 KiB.
I would prefer to keep this as Kconfig as the PMU driver is not supporting DT and in fact now ARCH_MX28 only has two boards supported - XEA and imx28evk.
Why not use the platdata then ? This makes it far better, as the code is actually always compiled and doesn't start to bitrot.
As fair as I can tell - the MX28 PMU driver in SPL is not supporting OF_PLATDATA. Or have I overlooked something?
I would like to investigate the PMU issue, and avoid extra work to provide platdata support for two supported imx287 based boards.
Hum, considering that this platform is basically legacy and winding down, I guess that's OK too.

Hi Marek,
On 5/9/23 17:04, Lukasz Majewski wrote:
Hi Marek,
On 5/9/23 16:46, Lukasz Majewski wrote:
Hi Marek,
Hi,
On 5/9/23 16:32, Lukasz Majewski wrote:
This option sets the current limit for 5V source to zero, so all the PMU outputs are primarily powered from battery source (DCDC_BAT).
This option may be set on systems, where the 5V is NOT supposed to be in any scenario powering the system - for example on systems where DCDC_BAT is connected to fixed and regulated 4.2V source (so the "battery" is not present).
Is it possible to dig this information out of DT or is the DT not available in SPL for this platform ?
This platform uses only SPL_OF_PLATDATA to keep the SPL size < 40 KiB.
I would prefer to keep this as Kconfig as the PMU driver is not supporting DT and in fact now ARCH_MX28 only has two boards supported - XEA and imx28evk.
Why not use the platdata then ? This makes it far better, as the code is actually always compiled and doesn't start to bitrot.
As fair as I can tell - the MX28 PMU driver in SPL is not supporting OF_PLATDATA. Or have I overlooked something?
I would like to investigate the PMU issue, and avoid extra work to provide platdata support for two supported imx287 based boards.
Hum, considering that this platform is basically legacy and winding down, I guess that's OK too.
Are there any other issues to be solved? Or is this patch set eligible for pulling?
(Especially that NXP has confirmed that approach used in this patch set is in sync with their idea of PMU usage).
Best regards,
Lukasz Majewski
--
DENX Software Engineering GmbH, Managing Director: Erika Unter HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-59 Fax: (+49)-8142-66989-80 Email: lukma@denx.de

On 5/19/23 10:41, Lukasz Majewski wrote:
Hello Lukasz,
On 5/9/23 16:32, Lukasz Majewski wrote: > This option sets the current limit for 5V source to zero, so all > the PMU outputs are primarily powered from battery source > (DCDC_BAT). > > This option may be set on systems, where the 5V is NOT supposed > to be in any scenario powering the system - for example on > systems where DCDC_BAT is connected to fixed and regulated 4.2V > source (so the "battery" is not present).
Is it possible to dig this information out of DT or is the DT not available in SPL for this platform ?
This platform uses only SPL_OF_PLATDATA to keep the SPL size < 40 KiB.
I would prefer to keep this as Kconfig as the PMU driver is not supporting DT and in fact now ARCH_MX28 only has two boards supported - XEA and imx28evk.
Why not use the platdata then ? This makes it far better, as the code is actually always compiled and doesn't start to bitrot.
As fair as I can tell - the MX28 PMU driver in SPL is not supporting OF_PLATDATA. Or have I overlooked something?
I would like to investigate the PMU issue, and avoid extra work to provide platdata support for two supported imx287 based boards.
Hum, considering that this platform is basically legacy and winding down, I guess that's OK too.
Are there any other issues to be solved? Or is this patch set eligible for pulling?
(Especially that NXP has confirmed that approach used in this patch set is in sync with their idea of PMU usage).
I think this is just waiting for Stefano to pick and do a MR

Hi Lukasz,
The series looks good. Only a minor comment:
On Tue, May 9, 2023 at 11:33 AM Lukasz Majewski lukma@denx.de wrote:
+config SPL_MXS_PMU_MINIMAL_VDD5V_CURRENT
bool "Force minimal current draw from VDD5V by MX28 PMU"
default n
Please drop "default n" as it is already the default.
The same applies to patch 2/5.
Thanks

This option sets the current limit for 5V source to zero, so all the PMU outputs are primarily powered from battery source (DCDC_BAT). This option may be set on systems, where the 5V is NOT supposed to be in any scenario powering the system - for example on systems where DCDC_BAT is connected to fixed and regulated 4.2V source (so the "battery" is not present). Signed-off-by: Lukasz Majewski lukma@denx.de
Applied to u-boot-imx, master, thanks !
Best regards, Stefano Babic
participants (4)
-
Fabio Estevam
-
Lukasz Majewski
-
Marek Vasut
-
sbabic@denx.de