Skip to contentSkip to conversation

imx: imx8ulp: misc update from downstream

PATCH Superseded Peng Fan (OSS) 2 participants 35 messages Feb 14, 2022 – Mar 4, 2022

Subsystems (5)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover imx: imx8ulp: misc update from downstream

From: Peng Fan <[email protected]>

This patchset is to upstream NXP downstream i.MX8ULP patches
- Support Nominal/Low Drive clock settings
- Update mem map for TEE
- Release CAAM
- Support Dual boot
- Enable handshake with M33
- Update DDR and PHY settings
- Misc clock update

Clark Wang (1):
imx: imx8ulp: clock: Add clock support for i3c controller

Clement Faure (2):
misc: S400_API: add ahab_release_caam
imx: imx8ulp: release CAAM for the Cortex-A35

Ji Luo (1):
imx: imx8ulp: reserve tee memory

Peng Fan (10):
imx: imx8ulp: include pcc/cgc header in clock header
imx: imx8ulp: add CAAM clock entry
imx: imx8ulp: add ND/LD clock
imx: imx8ulp: enable MU0_B clk by default
imx: dynamic setting mmcdev and mmcroot
imx: imx8ulp_evk: Enable SD/MMC port auto detect
imx: imx8ulp: enable wdog_ad interrupt in CMC1
imx: imx8ulp_evk: enlarge CONFIG_NR_DRAM_BANKS
dt-bindings: power: imx8ulp: include power entry header
misc: imx8ulp: Update fuse driver

Ye Li (13):
imx: imx8ulp: Set COUNTER_FREQUENCY to 1Mhz
imx: imx8ulp: Add M33 handshake functions
imx: imx8ulp_evk: Remove PMIC Bucks PWM mode settings
imx: imx8ulp_evk: Skip init DDR for reboot in dual boot mode
imx: imx8ulp: cgc: Switch to NICLPAV to FRO192 before PLL4 init
misc: imx8ulp: Add OEM SRK Hash fuse support
imx: imx8ulp: Change LPAV assignment for dual boot
imx: imx8ulp: Load the lposc fuse for dual boot
misc: S400_API: Update S400 API for buffer dump
imx: imx8ulp_evk: Update LPDDR4 PHY settings
imx: imx8ulp_evk: call the handshake with M33
imx: imx8ulp_evk: Power down the domains may used in u-boot
imx: imx8ulp_evk: Enable multiple env storage devices

 arch/arm/include/asm/arch-imx8ulp/cgc.h       |    8 +-
 arch/arm/include/asm/arch-imx8ulp/clock.h     |    8 +-
 arch/arm/include/asm/arch-imx8ulp/imx-regs.h  |    1 +
 arch/arm/include/asm/arch-imx8ulp/pcc.h       |    1 +
 arch/arm/include/asm/arch-imx8ulp/s400_api.h  |    5 +-
 arch/arm/include/asm/arch-imx8ulp/sys_proto.h |    2 +
 arch/arm/include/asm/mach-imx/sys_proto.h     |    2 +
 arch/arm/mach-imx/imx8ulp/Kconfig             |    7 +
 arch/arm/mach-imx/imx8ulp/cgc.c               |  106 +-
 arch/arm/mach-imx/imx8ulp/clock.c             |  101 +-
 arch/arm/mach-imx/imx8ulp/pcc.c               |    1 +
 arch/arm/mach-imx/imx8ulp/soc.c               |  197 ++-
 board/freescale/common/Makefile               |    3 +
 board/freescale/common/mmc.c                  |   49 +
 board/freescale/imx8ulp_evk/Makefile          |    7 +-
 board/freescale/imx8ulp_evk/imx8ulp_evk.c     |   43 +-
 board/freescale/imx8ulp_evk/lpddr4_timing.c   |   32 +-
 .../freescale/imx8ulp_evk/lpddr4_timing_266.c | 1109 +++++++++++++++++
 board/freescale/imx8ulp_evk/spl.c             |   59 +-
 configs/imx8ulp_evk_defconfig                 |    2 +-
 drivers/misc/imx8ulp/fuse.c                   |    4 +-
 drivers/misc/imx8ulp/s400_api.c               |   63 +
 include/configs/imx8ulp_evk.h                 |    2 +
 include/dt-bindings/power/imx8ulp-power.h     |   26 +
 24 files changed, 1729 insertions(+), 109 deletions(-)
 create mode 100644 board/freescale/common/mmc.c
 create mode 100644 board/freescale/imx8ulp_evk/lpddr4_timing_266.c
 create mode 100644 include/dt-bindings/power/imx8ulp-power.h
Signature · 1 line
2.30.0
#1 lore raw

PATCH 1/27 imx: imx8ulp: Set COUNTER_FREQUENCY to 1Mhz

From: Ye Li <[email protected]>

The COUNTER_FREQUENCY is missed in 8ulp configs, it will cause SPL and u-boot not set the cntfrq_el0. For u-boot, this is ok, because ATF has set it. But for SPL, it will lead delay and get_timer not working.

---
 include/configs/imx8ulp_evk.h | 2 ++
 1 file changed, 2 insertions(+)
include/configs/imx8ulp_evk.h +2 -0
index 7da6802aa5..1baebedf00 100644
@@ -27,6 +27,8 @@
 
 #endif
 
+#define COUNTER_FREQUENCY		1000000 /* 1MHz */
+
 /* ENET Config */
 #if defined(CONFIG_FEC_MXC)
 #define CONFIG_ETHPRIME                 "FEC"
Signature · 1 line
2.30.0
#2 lore raw

PATCH 2/27 imx: imx8ulp: include pcc/cgc header in clock header

In reply to Peng Fan (OSS)

From: Peng Fan <[email protected]>

Only including clock.h could simplify header files.

---
 arch/arm/include/asm/arch-imx8ulp/clock.h | 3 +++
 1 file changed, 3 insertions(+)
arch/arm/include/asm/arch-imx8ulp/clock.h +3 -0
index c0f32cc087..d7c92f7058 100644
@@ -6,6 +6,9 @@
 #ifndef _ASM_ARCH_IMX8ULP_CLOCK_H
 #define _ASM_ARCH_IMX8ULP_CLOCK_H
 
+#include <asm/arch/pcc.h>
+#include <asm/arch/cgc.h>
+
 /* Mainly for compatible to imx common code. */
 enum mxc_clock {
 	MXC_ARM_CLK = 0,
Signature · 1 line
2.30.0
reviewer
#3 lore raw

Re: [PATCH 02/27] imx: imx8ulp: include pcc/cgc header in clock header

Quoted 4 lines · Peng Fan (OSS)

From: Peng Fan <[email protected]>

Only including clock.h could simplify header files.

Sorry, I don't understand this commit log.

Quoted 10 lines
---
 arch/arm/include/asm/arch-imx8ulp/clock.h | 3 +++
 1 file changed, 3 insertions(+)
arch/arm/include/asm/arch-imx8ulp/clock.h +0 -0
index c0f32cc087..d7c92f7058 100644

arch/arm/include/asm/arch-imx8ulp/clock.h line 10

Quoted 5 lines
arch/arm/include/asm/arch-imx8ulp/clock.h +2 -0
@@ -6,6 +6,9 @@
 #ifndef _ASM_ARCH_IMX8ULP_CLOCK_H
 #define _ASM_ARCH_IMX8ULP_CLOCK_H
 
+#include <asm/arch/pcc.h>
+#include <asm/arch/cgc.h>

Please explain why you need to include these two header files.

#4 lore raw

Re: [PATCH 02/27] imx: imx8ulp: include pcc/cgc header in clock header

Quoted 21 lines · Fabio Estevam
Quoted 4 lines · Peng Fan (OSS)

From: Peng Fan <[email protected]>

Only including clock.h could simplify header files.

Sorry, I don't understand this commit log.

Quoted 13 lines
---
  arch/arm/include/asm/arch-imx8ulp/clock.h | 3 +++
  1 file changed, 3 insertions(+)
arch/arm/include/asm/arch-imx8ulp/clock.h +0 -0
index c0f32cc087..d7c92f7058 100644
@@ -6,6 +6,9 @@
  #ifndef _ASM_ARCH_IMX8ULP_CLOCK_H
  #define _ASM_ARCH_IMX8ULP_CLOCK_H
 
Quoted 4 lines

arch/arm/include/asm/arch-imx8ulp/clock.h line 10

Quoted 2 lines
arch/arm/include/asm/arch-imx8ulp/clock.h +2 -0
+#include <asm/arch/pcc.h>
+#include <asm/arch/cgc.h>

Please explain why you need to include these two header files.

No need to include pcc/cgc header file both for users, only need include clock.h

Thanks,
Peng.

Quoted 1 line
#5 lore raw

PATCH 3/27 imx: imx8ulp: Add M33 handshake functions

In reply to Peng Fan (OSS)

From: Ye Li <[email protected]>

Add functions to check if M33 image is booted and handshake with M33 image via MU. A core notifies M33 to start init by FCR F0, then wait M33 init done signal by checking FSR F0.

---
 arch/arm/include/asm/arch-imx8ulp/imx-regs.h  |  1 +
 arch/arm/include/asm/arch-imx8ulp/sys_proto.h |  2 ++
 arch/arm/mach-imx/imx8ulp/soc.c               | 36 +++++++++++++++++++
 3 files changed, 39 insertions(+)
arch/arm/include/asm/arch-imx8ulp/imx-regs.h +1 -0
index 91adc85525..723bab584c 100644
@@ -14,6 +14,7 @@
 
 #define CMC0_RBASE		0x28025000
 
+#define MU0_B_BASE_ADDR		0x29220000
 #define CMC1_BASE_ADDR		0x29240000
 
 #define SIM1_BASE_ADDR		0x29290000
arch/arm/include/asm/arch-imx8ulp/sys_proto.h +2 -0
index 284ccafc98..5f030eaa0a 100644
@@ -18,4 +18,6 @@ int xrdc_config_pdac_openacc(u32 bridge, u32 index);
 enum boot_device get_boot_device(void);
 void set_lpav_qos(void);
 void load_lposc_fuse(void);
+bool m33_image_booted(void);
+int m33_image_handshake(ulong timeout_ms);
 #endif
arch/arm/mach-imx/imx8ulp/soc.c +36 -0
index 934b0ef038..b9c146fc26 100644
@@ -25,6 +25,7 @@
 #include <dm/uclass-internal.h>
 #include <fuse.h>
 #include <thermal.h>
+#include <linux/iopoll.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -136,6 +137,41 @@ enum bt_mode get_boot_mode(void)
 	return LOW_POWER_BOOT;
 }
 
+bool m33_image_booted(void)
+{
+	u32 gp6;
+
+	/* DGO_GP6 */
+	gp6 = readl(SIM_SEC_BASE_ADDR + 0x28);
+	if (gp6 & BIT(5))
+		return true;
+
+	return false;
+}
+
+int m33_image_handshake(ulong timeout_ms)
+{
+	u32 fsr;
+	int ret;
+	ulong timeout_us = timeout_ms * 1000;
+
+	/* enable MU0_MUB clock before access the register of MU0_MUB */
+	pcc_clock_enable(3, MU0_B_PCC3_SLOT, true);
+
+	/* Notify m33 that it's ready to do init srtm(enable mu receive interrupt and so on) */
+	setbits_le32(MU0_B_BASE_ADDR + 0x100, BIT(0)); /* set FCR F0 flag of MU0_MUB */
+
+	/*
+	 * Wait m33 to set FCR F0 flag of MU0_MUA
+	 * Clear FCR F0 flag of MU0_MUB after m33 has set FCR F0 flag of MU0_MUA
+	 */
+	ret = readl_poll_sleep_timeout(MU0_B_BASE_ADDR + 0x104, fsr, fsr & BIT(0), 10, timeout_us);
+	if (!ret)
+		clrbits_le32(MU0_B_BASE_ADDR + 0x100, BIT(0));
+
+	return ret;
+}
+
 #define CMC_SRS_TAMPER                    BIT(31)
 #define CMC_SRS_SECURITY                  BIT(30)
 #define CMC_SRS_TZWDG                     BIT(29)
Signature · 1 line
2.30.0
#6 lore raw

PATCH 4/27 imx: imx8ulp: clock: Add clock support for i3c controller

In reply to Peng Fan (OSS)

From: Clark Wang <[email protected]>

Add i3c controller clock enable/disable function for imx8ulp.

---
 arch/arm/mach-imx/imx8ulp/clock.c | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)
arch/arm/mach-imx/imx8ulp/clock.c +26 -0
index 91580b2c29..6f52ccee34 100644
@@ -237,6 +237,32 @@ u32 imx_get_i2cclk(u32 i2c_num)
 }
 #endif
 
+#if IS_ENABLED(CONFIG_SYS_I2C_IMX_I3C)
+int enable_i3c_clk(unsigned char enable, u32 i3c_num)
+{
+	if (i3c_num != 8)
+		return -EINVAL;
+
+	if (enable) {
+		pcc_clock_enable(3, I3C2_PCC3_SLOT, false);
+		pcc_clock_sel(3, I3C2_PCC3_SLOT, SOSC_DIV2);
+		pcc_clock_enable(3, I3C2_PCC3_SLOT, true);
+		pcc_reset_peripheral(3, I3C2_PCC3_SLOT, false);
+	} else {
+		pcc_clock_enable(3, I3C2_PCC3_SLOT, false);
+	}
+	return 0;
+}
+
+u32 imx_get_i3cclk(u32 i3c_num)
+{
+	if (i3c_num != 8)
+		return 0;
+
+	return pcc_clock_get_rate(3, I3C2_PCC3_SLOT);
+}
+#endif
+
 void enable_usboh3_clk(unsigned char enable)
 {
 	if (enable) {
Signature · 1 line
2.30.0
reviewer
#7 lore raw

Re: [PATCH 04/27] imx: imx8ulp: clock: Add clock support for i3c controller

Quoted 17 lines · Peng Fan (OSS)

From: Clark Wang <[email protected]>

Add i3c controller clock enable/disable function for imx8ulp.

---
 arch/arm/mach-imx/imx8ulp/clock.c | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)
arch/arm/mach-imx/imx8ulp/clock.c +0 -0
index 91580b2c29..6f52ccee34 100644

arch/arm/mach-imx/imx8ulp/clock.c u32 imx_get_i2cclk(u32 i2c_num) · line 243

Quoted 7 lines
arch/arm/mach-imx/imx8ulp/clock.c +4 -0
@@ -237,6 +237,32 @@ u32 imx_get_i2cclk(u32 i2c_num)
 }
 #endif
 
+#if IS_ENABLED(CONFIG_SYS_I2C_IMX_I3C)
+int enable_i3c_clk(unsigned char enable, u32 i3c_num)
+{
+       if (i3c_num != 8)

What does this magic 8 mean? Please replace with some more meaningful define.

arch/arm/mach-imx/imx8ulp/clock.c u32 imx_get_i2cclk(u32 i2c_num) · line 259

Quoted 3 lines
arch/arm/mach-imx/imx8ulp/clock.c +3 -0
+u32 imx_get_i3cclk(u32 i3c_num)
+{
+       if (i3c_num != 8)

Same here.

#8 lore raw

PATCH 5/27 imx: imx8ulp: add CAAM clock entry

In reply to Peng Fan (OSS)

From: Peng Fan <[email protected]>

Add CAAM clock entry in PCC3

---
 arch/arm/include/asm/arch-imx8ulp/pcc.h | 1 +
 arch/arm/mach-imx/imx8ulp/pcc.c         | 1 +
 2 files changed, 2 insertions(+)
arch/arm/include/asm/arch-imx8ulp/pcc.h +1 -0
index 46386f1aba..d9b2d7c299 100644
@@ -52,6 +52,7 @@ enum pcc3_entry {
 	UPOWER_PCC3_SLOT = 40,
 	WDOG3_PCC3_SLOT = 42,
 	WDOG4_PCC3_SLOT = 43,
+	CAAM_PCC3_SLOT = 46,
 	XRDC_MGR_PCC3_SLOT = 47,
 	SEMA42_1_PCC3_SLOT = 48,
 	ROMCP1_PCC3_SLOT = 49,
arch/arm/mach-imx/imx8ulp/pcc.c +1 -0
index 7909d770af..e3c6d6760b 100644
@@ -135,6 +135,7 @@ static struct pcc_entry pcc3_arrays[] = {
 	{PCC3_RBASE, UPOWER_PCC3_SLOT,		CLKSRC_NO_PCS, PCC_NO_DIV, PCC_NO_RST_B},
 	{PCC3_RBASE, WDOG3_PCC3_SLOT,		CLKSRC_PER_BUS, PCC_HAS_DIV, PCC_HAS_RST_B},
 	{PCC3_RBASE, WDOG4_PCC3_SLOT,		CLKSRC_PER_BUS, PCC_HAS_DIV, PCC_HAS_RST_B},
+	{PCC3_RBASE, CAAM_PCC3_SLOT,		CLKSRC_NO_PCS, PCC_NO_DIV, PCC_HAS_RST_B},
 	{PCC3_RBASE, XRDC_MGR_PCC3_SLOT,	CLKSRC_NO_PCS, PCC_NO_DIV, PCC_NO_RST_B},
 	{PCC3_RBASE, SEMA42_1_PCC3_SLOT,	CLKSRC_PER_BUS, PCC_NO_DIV, PCC_NO_RST_B},
 	{PCC3_RBASE, ROMCP1_PCC3_SLOT,		CLKSRC_NO_PCS, PCC_NO_DIV, PCC_NO_RST_B},
Signature · 1 line
2.30.0
#9 lore raw

PATCH 6/27 imx: imx8ulp_evk: Remove PMIC Bucks PWM mode settings

In reply to Peng Fan (OSS)

From: Ye Li <[email protected]>

This workaround is not needed on i.MX8ULP proto-1B EVK as board has fixed the problem. Because we don't support proto-1A any longer, remove the PMIC settings.

---
 board/freescale/imx8ulp_evk/spl.c | 18 ------------------
 1 file changed, 18 deletions(-)
board/freescale/imx8ulp_evk/spl.c +0 -18
index c17d5eff7d..b314901409 100644
@@ -35,24 +35,6 @@ u32 spl_boot_device(void)
 
 int power_init_board(void)
 {
-	u32 pmic_reg;
-
-	/* PMIC set bucks1-4 to PWM mode */
-	upower_pmic_i2c_read(0x10, &pmic_reg);
-	upower_pmic_i2c_read(0x14, &pmic_reg);
-	upower_pmic_i2c_read(0x21, &pmic_reg);
-	upower_pmic_i2c_read(0x2e, &pmic_reg);
-
-	upower_pmic_i2c_write(0x10, 0x3d);
-	upower_pmic_i2c_write(0x14, 0x7d);
-	upower_pmic_i2c_write(0x21, 0x7d);
-	upower_pmic_i2c_write(0x2e, 0x3d);
-
-	upower_pmic_i2c_read(0x10, &pmic_reg);
-	upower_pmic_i2c_read(0x14, &pmic_reg);
-	upower_pmic_i2c_read(0x21, &pmic_reg);
-	upower_pmic_i2c_read(0x2e, &pmic_reg);
-
 	/* Set buck3 to 1.1v OD */
 	upower_pmic_i2c_write(0x22, 0x28);
 	return 0;
Signature · 1 line
2.30.0
#10 lore raw

PATCH 7/27 imx: imx8ulp: add ND/LD clock

In reply to Peng Fan (OSS)

From: Peng Fan <[email protected]>

Add a new ddr script, defconfig for ND
Configure the clock for ND mode
changing A35 to 960M for OD mode
Update NIC CLK for the various modes
Introduce clock_init_early/late, late is used after pmic voltage setting, early is used in the very early stage for upower mu, lpuart and etc.

Note: NIC runs at 324MHz, 442MHz has some random kernel hang issue with cpuidle enabled now.

---
 arch/arm/include/asm/arch-imx8ulp/cgc.h       |    6 +-
 arch/arm/include/asm/arch-imx8ulp/clock.h     |    5 +-
 arch/arm/mach-imx/imx8ulp/Kconfig             |    7 +
 arch/arm/mach-imx/imx8ulp/cgc.c               |   78 +-
 arch/arm/mach-imx/imx8ulp/clock.c             |   70 +-
 arch/arm/mach-imx/imx8ulp/soc.c               |    2 +-
 board/freescale/imx8ulp_evk/Makefile          |    7 +-
 .../freescale/imx8ulp_evk/lpddr4_timing_266.c | 1109 +++++++++++++++++
 board/freescale/imx8ulp_evk/spl.c             |   15 +-
 9 files changed, 1252 insertions(+), 47 deletions(-)
 create mode 100644 board/freescale/imx8ulp_evk/lpddr4_timing_266.c
arch/arm/include/asm/arch-imx8ulp/cgc.h +3 -3
index ad3edc85ad..e45f04624d 100644
@@ -146,10 +146,10 @@ struct cgc2_regs {
 };
 
 u32 cgc_clk_get_rate(enum cgc_clk clk);
-void cgc1_pll3_init(void);
-void cgc1_pll2_init(void);
+void cgc1_pll3_init(ulong freq);
+void cgc1_pll2_init(ulong freq);
 void cgc1_soscdiv_init(void);
-void cgc1_init_core_clk(void);
+void cgc1_init_core_clk(ulong freq);
 void cgc2_pll4_init(void);
 void cgc2_ddrclk_config(u32 src, u32 div);
 void cgc2_ddrclk_wait_unlock(void);
arch/arm/include/asm/arch-imx8ulp/clock.h +4 -1
index d7c92f7058..2946cc1911 100644
@@ -9,6 +9,8 @@
 #include <asm/arch/pcc.h>
 #include <asm/arch/cgc.h>
 
+#define MHZ(X)	((X) * 1000000UL)
+
 /* Mainly for compatible to imx common code. */
 enum mxc_clock {
 	MXC_ARM_CLK = 0,
@@ -39,7 +41,8 @@ void init_clk_usdhc(u32 index);
 void init_clk_fspi(int index);
 void init_clk_ddr(void);
 int set_ddr_clk(u32 phy_freq_mhz);
-void clock_init(void);
+void clock_init_early(void);
+void clock_init_late(void);
 void cgc1_enet_stamp_sel(u32 clk_src);
 void mxs_set_lcdclk(u32 base_addr, u32 freq_in_khz);
 void reset_lcdclk(void);
arch/arm/mach-imx/imx8ulp/Kconfig +7 -0
index 963fc93d34..efbcaa5adc 100644
@@ -7,6 +7,13 @@ config IMX8ULP
 config SYS_SOC
 	default "imx8ulp"
 
+config IMX8ULP_LD_MODE
+	bool
+	default n
+
+config IMX8ULP_ND_MODE
+	bool "i.MX8ULP Low Driver Mode"
+
 choice
 	prompt "i.MX8ULP board select"
 	optional
arch/arm/mach-imx/imx8ulp/cgc.c +56 -22

158 lines not on this page · raw message

arch/arm/mach-imx/imx8ulp/clock.c +53 -17

90 lines not on this page · raw message

arch/arm/mach-imx/imx8ulp/soc.c +1 -1
index b9c146fc26..b4f0ca6a2e 100644
@@ -596,7 +596,7 @@ int arch_cpu_init(void)
 
 		xrdc_mrc_region_set_access(2, CONFIG_SPL_TEXT_BASE, 0xE00);
 
-		clock_init();
+		clock_init_early();
 	} else {
 		/* reconfigure core0 reset vector to ROM */
 		set_core0_reset_vector(0x1000);
board/freescale/imx8ulp_evk/Makefile +6 -1
index b2e72b4e85..b6ca238de5 100644
@@ -3,5 +3,10 @@
 obj-y   += imx8ulp_evk.o
 
 ifdef CONFIG_SPL_BUILD
-obj-y += spl.o ddr_init.o lpddr4_timing.o
+obj-y += spl.o ddr_init.o
+ifdef CONFIG_IMX8ULP_ND_MODE
+obj-y += lpddr4_timing_264.o
+else
+obj-y += lpddr4_timing.o
+endif
 endif
board/freescale/imx8ulp_evk/lpddr4_timing_266.c new file +1109 -0

1,109 lines not on this page · raw message

board/freescale/imx8ulp_evk/spl.c +13 -2
index b314901409..d3cdad2d76 100644
@@ -35,8 +35,17 @@ u32 spl_boot_device(void)
 
 int power_init_board(void)
 {
-	/* Set buck3 to 1.1v OD */
-	upower_pmic_i2c_write(0x22, 0x28);
+	if (IS_ENABLED(CONFIG_IMX8ULP_LD_MODE)) {
+		/* Set buck3 to 0.9v LD */
+		upower_pmic_i2c_write(0x22, 0x18);
+	} else if (IS_ENABLED(CONFIG_IMX8ULP_ND_MODE)) {
+		/* Set buck3 to 1.0v ND */
+		upower_pmic_i2c_write(0x22, 0x20);
+	} else {
+		/* Set buck3 to 1.1v OD */
+		upower_pmic_i2c_write(0x22, 0x28);
+	}
+
 	return 0;
 }
 
@@ -69,6 +78,8 @@ void spl_board_init(void)
 
 	power_init_board();
 
+	clock_init_late();
+
 	/* DDR initialization */
 	spl_dram_init();
 
Signature · 1 line
2.30.0
reviewer
#11 lore raw

Re: [PATCH 07/27] imx: imx8ulp: add ND/LD clock

Quoted 4 lines · Peng Fan (OSS)

From: Peng Fan <[email protected]>

Add a new ddr script, defconfig for ND

What does ND, LD and OD stand for?

Quoted 2 lines

Configure the clock for ND mode
changing A35 to 960M for OD mode

s/960M/960MHz

Quoted 11 lines

Update NIC CLK for the various modes
Introduce clock_init_early/late, late is used after pmic voltage setting, early is used in the very early stage for upower mu, lpuart and etc.

Note: NIC runs at 324MHz, 442MHz has some random kernel hang issue with cpuidle enabled now.

arch/arm/mach-imx/imx8ulp/Kconfig config IMX8ULP · line 12

Quoted 3 lines
arch/arm/mach-imx/imx8ulp/Kconfig +3 -0
+config IMX8ULP_LD_MODE
+       bool
+       default n

'default n' is already the default. Just remove it.

#12 lore raw

PATCH 8/27 imx: imx8ulp_evk: Skip init DDR for reboot in dual boot mode

In reply to Peng Fan (OSS)

From: Ye Li <[email protected]>

When M33 is LPAV owner in dual boot, DDR, PCC5, CGC2 won't be reset during APD reset. So no need to init DDR again after reboot, but need to reconfigure the PLL4 PFD/PFDDIV/LPAV NIC etc, because kernel may change or disable some of them.

---
 arch/arm/include/asm/arch-imx8ulp/cgc.h |  2 +-
 arch/arm/mach-imx/imx8ulp/cgc.c         | 20 +++++++++++---------
 arch/arm/mach-imx/imx8ulp/clock.c       |  2 +-
 board/freescale/imx8ulp_evk/spl.c       | 12 ++++++++++--
 4 files changed, 23 insertions(+), 13 deletions(-)
arch/arm/include/asm/arch-imx8ulp/cgc.h +1 -1
index e45f04624d..83a246b15a 100644
@@ -150,7 +150,7 @@ void cgc1_pll3_init(ulong freq);
 void cgc1_pll2_init(ulong freq);
 void cgc1_soscdiv_init(void);
 void cgc1_init_core_clk(ulong freq);
-void cgc2_pll4_init(void);
+void cgc2_pll4_init(bool pll4_reset);
 void cgc2_ddrclk_config(u32 src, u32 div);
 void cgc2_ddrclk_wait_unlock(void);
 u32 cgc1_sosc_div(enum cgc_clk clk);
arch/arm/mach-imx/imx8ulp/cgc.c +11 -9
index 494ddb0f32..ccd977f1a5 100644
@@ -187,7 +187,7 @@ void cgc1_pll3_init(ulong freq)
 	}
 }
 
-void cgc2_pll4_init(void)
+void cgc2_pll4_init(bool pll4_reset)
 {
 	/* Disable PFD DIV and clear DIV */
 	writel(0x80808080, &cgc2_regs->pll4div_pfd0);
@@ -196,16 +196,18 @@ void cgc2_pll4_init(void)
 	/* Gate off and clear PFD  */
 	writel(0x80808080, &cgc2_regs->pll4pfdcfg);
 
-	/* Disable PLL4 */
-	writel(0x0, &cgc2_regs->pll4csr);
+	if (pll4_reset) {
+		/* Disable PLL4 */
+		writel(0x0, &cgc2_regs->pll4csr);
 
-	/* Configure PLL4 to 528Mhz and clock source from SOSC */
-	writel(22 << 16, &cgc2_regs->pll4cfg);
-	writel(0x1, &cgc2_regs->pll4csr);
+		/* Configure PLL4 to 528Mhz and clock source from SOSC */
+		writel(22 << 16, &cgc2_regs->pll4cfg);
+		writel(0x1, &cgc2_regs->pll4csr);
 
-	/* wait for PLL4 output valid */
-	while (!(readl(&cgc2_regs->pll4csr) & BIT(24)))
-		;
+		/* wait for PLL4 output valid */
+		while (!(readl(&cgc2_regs->pll4csr) & BIT(24)))
+			;
+	}
 
 	/* Enable all 4 PFDs */
 	setbits_le32(&cgc2_regs->pll4pfdcfg, 18 << 0); /* 528 */
arch/arm/mach-imx/imx8ulp/clock.c +1 -1
index 7c45a717be..cc13ccd5ea 100644
@@ -101,7 +101,7 @@ void init_clk_ddr(void)
 	writel(0xc0000000, PCC5_LPDDR4_ADDR);
 
 	/* enable pll4 and ddrclk*/
-	cgc2_pll4_init();
+	cgc2_pll4_init(true);
 	cgc2_ddrclk_config(4, 1);
 
 	/* enable ddr pcc */
board/freescale/imx8ulp_evk/spl.c +10 -2
index d3cdad2d76..e6949b5e43 100644
@@ -24,8 +24,16 @@ DECLARE_GLOBAL_DATA_PTR;
 
 void spl_dram_init(void)
 {
-	init_clk_ddr();
-	ddr_init(&dram_timing);
+	/* Reboot in dual boot setting no need to init ddr again */
+	bool ddr_enable = pcc_clock_is_enable(5, LPDDR4_PCC5_SLOT);
+
+	if (!ddr_enable) {
+		init_clk_ddr();
+		ddr_init(&dram_timing);
+	} else {
+		/* reinit pfd/pfddiv and lpavnic except pll4*/
+		cgc2_pll4_init(false);
+	}
 }
 
 u32 spl_boot_device(void)
Signature · 1 line
2.30.0
#13 lore raw

PATCH 9/27 imx: imx8ulp: cgc: Switch to NICLPAV to FRO192 before PLL4 init

In reply to Peng Fan (OSS)

From: Ye Li <[email protected]>

When reset with dual boot mode, the LPAV domain won't power down due to its master is not assigned to APD. So the NICLPAV keeps the last setting to use PLL4PFD1. So before SPL initialize the PLL4, we need to switch NICLPAV to FRO192, otherwise system will hang.

---
 arch/arm/mach-imx/imx8ulp/cgc.c | 8 ++++++++
 1 file changed, 8 insertions(+)
arch/arm/mach-imx/imx8ulp/cgc.c +8 -0
index ccd977f1a5..d240abaee4 100644
@@ -189,6 +189,14 @@ void cgc1_pll3_init(ulong freq)
 
 void cgc2_pll4_init(bool pll4_reset)
 {
+	/* Check the NICLPAV first to ensure not from PLL4 PFD1 clock */
+	if ((readl(&cgc2_regs->niclpavclk) & GENMASK(29, 28)) == BIT(28)) {
+		/* switch to FRO 192 first */
+		clrbits_le32(&cgc2_regs->niclpavclk, GENMASK(29, 28));
+		while (!(readl(&cgc2_regs->niclpavclk) & BIT(27)))
+			;
+	}
+
 	/* Disable PFD DIV and clear DIV */
 	writel(0x80808080, &cgc2_regs->pll4div_pfd0);
 	writel(0x80808080, &cgc2_regs->pll4div_pfd1);
Signature · 1 line
2.30.0
#14 lore raw

PATCH 10/27 imx: imx8ulp: enable MU0_B clk by default

In reply to Peng Fan (OSS)

From: Peng Fan <[email protected]>

Enable MU0_B clk by default. When M33 image is loaded by Jlink, the previous method not enable MU0_B clk and not able to communicate with M33, so let's enable it by default.

And we not put it under kernel dts, because it conflicts with i.MX8QM suspend/resume logic which requires large change.

---
 arch/arm/mach-imx/imx8ulp/clock.c | 3 +++
 arch/arm/mach-imx/imx8ulp/soc.c   | 3 ---
 2 files changed, 3 insertions(+), 3 deletions(-)
arch/arm/mach-imx/imx8ulp/clock.c +3 -0
index cc13ccd5ea..398d8c849f 100644
@@ -214,6 +214,9 @@ void clock_init_late(void)
 		pcc_reset_peripheral(4, SDHC2_PCC4_SLOT, false);
 	}
 
+	/* enable MU0_MUB clock before access the register of MU0_MUB */
+	pcc_clock_enable(3, MU0_B_PCC3_SLOT, true);
+
 	/*
 	 * Enable clock division
 	 * TODO: may not needed after ROM ready.
arch/arm/mach-imx/imx8ulp/soc.c +0 -3
index b4f0ca6a2e..e95a159147 100644
@@ -155,9 +155,6 @@ int m33_image_handshake(ulong timeout_ms)
 	int ret;
 	ulong timeout_us = timeout_ms * 1000;
 
-	/* enable MU0_MUB clock before access the register of MU0_MUB */
-	pcc_clock_enable(3, MU0_B_PCC3_SLOT, true);
-
 	/* Notify m33 that it's ready to do init srtm(enable mu receive interrupt and so on) */
 	setbits_le32(MU0_B_BASE_ADDR + 0x100, BIT(0)); /* set FCR F0 flag of MU0_MUB */
 
Signature · 1 line
2.30.0
#15 lore raw

PATCH 11/27 misc: imx8ulp: Add OEM SRK Hash fuse support

In reply to Peng Fan (OSS)

From: Ye Li <[email protected]>

Since latest S400 firmware has supported to read OEM SRK Hash, add it to the driver's table

---
 drivers/misc/imx8ulp/fuse.c | 1 +
 1 file changed, 1 insertion(+)
drivers/misc/imx8ulp/fuse.c +1 -0
index d1feb62ab5..01db470e8f 100644
@@ -61,6 +61,7 @@ struct s400_map_entry s400_api_mapping_table[] = {
 	{ 1, 8 },	/* LOCK */
 	{ 2, 8 },	/* ECID */
 	{ 7, 4, 0, 1 },	/* OTP_UNIQ_ID */
+	{ 15, 8 }, /* OEM SRK HASH */
 	{ 23, 1, 4, 2 }, /* OTFAD */
 };
 
Signature · 1 line
2.30.0
#16 lore raw

PATCH 12/27 imx: imx8ulp: Change LPAV assignment for dual boot

In reply to Peng Fan (OSS)

From: Ye Li <[email protected]>

Assign the LPAV owner to RTD, and assign LPAV masters and peripherals to APD. So except the masters and peripherals, other resources (like DDR, cgc2, pcc5) in LPAV won't be reset during reboot and suspend.

No needs to initialize DDR again after reboot.

---
 arch/arm/mach-imx/imx8ulp/soc.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)
arch/arm/mach-imx/imx8ulp/soc.c +6 -5
index e95a159147..b0ddaef222 100644
@@ -523,10 +523,10 @@ static int trdc_set_access(void)
 	return 0;
 }
 
-void lpav_configure(void)
+void lpav_configure(bool lpav_to_m33)
 {
-	/* LPAV to APD */
-	setbits_le32(SIM_SEC_BASE_ADDR + 0x44, BIT(7));
+	if (!lpav_to_m33)
+		setbits_le32(SIM_SEC_BASE_ADDR + 0x44, BIT(7)); /* LPAV to APD */
 
 	/* PXP/GPU 2D/3D/DCNANO/MIPI_DSI/EPDC/HIFI4 to APD */
 	setbits_le32(SIM_SEC_BASE_ADDR + 0x4c, 0x7F);
@@ -583,8 +583,9 @@ int arch_cpu_init(void)
 				release_rdc(RDC_TRDC);
 
 			trdc_set_access();
-
-			lpav_configure();
+			lpav_configure(false);
+		} else {
+			lpav_configure(true);
 		}
 
 		/* Release xrdc, then allow A35 to write SRAM2 */
Signature · 1 line
2.30.0
#17 lore raw

PATCH 13/27 imx: imx8ulp: Load the lposc fuse for dual boot

In reply to Peng Fan (OSS)

From: Ye Li <[email protected]>

Found the lposc fuse loading having impact to cpu idle in kernel. Without the loading in dual boot mode, kernel will hang after idle for a while.

---
 board/freescale/imx8ulp_evk/spl.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
board/freescale/imx8ulp_evk/spl.c +2 -4
index e6949b5e43..9bc9081617 100644
@@ -76,10 +76,8 @@ void spl_board_init(void)
 
 	/* After AP set iomuxc0, the i2c can't work, Need M33 to set it now */
 
-	/* Load the lposc fuse for single boot to work around ROM issue,
-	 *  The fuse depends on S400 to read.
-	 */
-	if (is_soc_rev(CHIP_REV_1_0) && get_boot_mode() == SINGLE_BOOT)
+	/* Load the lposc fuse to work around ROM issue. The fuse depends on S400 to read. */
+	if (is_soc_rev(CHIP_REV_1_0))
 		load_lposc_fuse();
 
 	upower_init();
Signature · 1 line
2.30.0
#18 lore raw

PATCH 14/27 misc: S400_API: add ahab_release_caam

In reply to Peng Fan (OSS)

From: Clement Faure <[email protected]>

Add ahab_release_caam() function to the S400 API.

---
 arch/arm/include/asm/arch-imx8ulp/s400_api.h |  2 ++
 drivers/misc/imx8ulp/s400_api.c              | 29 ++++++++++++++++++++
 2 files changed, 31 insertions(+)
arch/arm/include/asm/arch-imx8ulp/s400_api.h +2 -0
index c848f0dfb8..b788661b09 100644
@@ -19,6 +19,7 @@
 #define AHAB_READ_FUSE_REQ_CID	0x97
 #define AHAB_RELEASE_RDC_REQ_CID   0xC4
 #define AHAB_WRITE_FUSE_REQ_CID	0xD6
+#define AHAB_CAAM_RELEASE_CID 0xD7
 
 #define S400_MAX_MSG          8U
 
@@ -37,5 +38,6 @@ int ahab_verify_image(u32 img_id, u32 *response);
 int ahab_forward_lifecycle(u16 life_cycle, u32 *response);
 int ahab_write_fuse(u16 fuse_id, u32 fuse_val, bool lock, u32 *response);
 int ahab_read_common_fuse(u16 fuse_id, u32 *fuse_words, u32 fuse_num, u32 *response);
+int ahab_release_caam(u32 core_did, u32 *response);
 
 #endif
drivers/misc/imx8ulp/s400_api.c +29 -0
index d76a95febe..dd5f9f25da 100644
@@ -242,3 +242,32 @@ int ahab_write_fuse(u16 fuse_id, u32 fuse_val, bool lock, u32 *response)
 
 	return ret;
 }
+
+int ahab_release_caam(u32 core_did, u32 *response)
+{
+	struct udevice *dev = gd->arch.s400_dev;
+	int size = sizeof(struct imx8ulp_s400_msg);
+	struct imx8ulp_s400_msg msg;
+	int ret;
+
+	if (!dev) {
+		printf("s400 dev is not initialized\n");
+		return -ENODEV;
+	}
+
+	msg.version = AHAB_VERSION;
+	msg.tag = AHAB_CMD_TAG;
+	msg.size = 2;
+	msg.command = AHAB_CAAM_RELEASE_CID;
+	msg.data[0] = core_did;
+
+	ret = misc_call(dev, false, &msg, size, &msg, size);
+	if (ret)
+		printf("Error: %s: ret %d, response 0x%x\n",
+		       __func__, ret, msg.data[0]);
+
+	if (response)
+		*response = msg.data[0];
+
+	return ret;
+}
Signature · 1 line
2.30.0
#19 lore raw

PATCH 15/27 misc: S400_API: Update S400 API for buffer dump

In reply to Peng Fan (OSS)

From: Ye Li <[email protected]>

Add ahab_dump_buffer API to dump AHAB buffer for debug purpose

---
 arch/arm/include/asm/arch-imx8ulp/s400_api.h |  3 +-
 drivers/misc/imx8ulp/s400_api.c              | 34 ++++++++++++++++++++
 2 files changed, 36 insertions(+), 1 deletion(-)
arch/arm/include/asm/arch-imx8ulp/s400_api.h +2 -1
index b788661b09..1856659877 100644
@@ -21,7 +21,7 @@
 #define AHAB_WRITE_FUSE_REQ_CID	0xD6
 #define AHAB_CAAM_RELEASE_CID 0xD7
 
-#define S400_MAX_MSG          8U
+#define S400_MAX_MSG          255U
 
 struct imx8ulp_s400_msg {
 	u8 version;
@@ -39,5 +39,6 @@ int ahab_forward_lifecycle(u16 life_cycle, u32 *response);
 int ahab_write_fuse(u16 fuse_id, u32 fuse_val, bool lock, u32 *response);
 int ahab_read_common_fuse(u16 fuse_id, u32 *fuse_words, u32 fuse_num, u32 *response);
 int ahab_release_caam(u32 core_did, u32 *response);
+int ahab_dump_buffer(u32 *buffer, u32 buffer_length);
 
 #endif
drivers/misc/imx8ulp/s400_api.c +34 -0
index dd5f9f25da..3ffdeb2ad2 100644
@@ -271,3 +271,37 @@ int ahab_release_caam(u32 core_did, u32 *response)
 
 	return ret;
 }
+
+int ahab_dump_buffer(u32 *buffer, u32 buffer_length)
+{
+	struct udevice *dev = gd->arch.s400_dev;
+	int size = sizeof(struct imx8ulp_s400_msg);
+	struct imx8ulp_s400_msg msg;
+	int ret, i = 0;
+
+	if (!dev) {
+		printf("s400 dev is not initialized\n");
+		return -ENODEV;
+	}
+
+	msg.version = AHAB_VERSION;
+	msg.tag = AHAB_CMD_TAG;
+	msg.size = 1;
+	msg.command = AHAB_LOG_CID;
+
+	ret = misc_call(dev, false, &msg, size, &msg, size);
+	if (ret) {
+		printf("Error: %s: ret %d, response 0x%x\n",
+		       __func__, ret, msg.data[0]);
+
+		return ret;
+	}
+
+	if (buffer) {
+		buffer[i++] = *(u32 *)&msg; /* Need dump the response header */
+		for (; i < buffer_length && i < msg.size; i++)
+			buffer[i] = msg.data[i - 1];
+	}
+
+	return i;
+}
Signature · 1 line
2.30.0
#20 lore raw

PATCH 16/27 imx: imx8ulp: release CAAM for the Cortex-A35

In reply to Peng Fan (OSS)

From: Clement Faure <[email protected]>

Release the CAAM for the A35 from the SPL.

---
 board/freescale/imx8ulp_evk/spl.c | 8 ++++++++
 1 file changed, 8 insertions(+)
board/freescale/imx8ulp_evk/spl.c +8 -0
index 9bc9081617..66bfc2bd0c 100644
@@ -19,6 +19,7 @@
 #include <asm/arch/ddr.h>
 #include <asm/arch/rdc.h>
 #include <asm/arch/upower.h>
+#include <asm/arch/s400_api.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -60,6 +61,8 @@ int power_init_board(void)
 void spl_board_init(void)
 {
 	struct udevice *dev;
+	u32 res;
+	int ret;
 
 	uclass_find_first_device(UCLASS_MISC, &dev);
 
@@ -98,6 +101,11 @@ void spl_board_init(void)
 
 	/* Call it after PS16 power up */
 	set_lpav_qos();
+
+	/* Enable A35 access to the CAAM */
+	ret = ahab_release_caam(0x7, &res);
+	if (ret)
+		printf("ahab release caam failed %d, 0x%x\n", ret, res);
 }
 
 void board_init_f(ulong dummy)
Signature · 1 line
2.30.0
#21 lore raw

PATCH 17/27 imx: imx8ulp_evk: Update LPDDR4 PHY settings

In reply to Peng Fan (OSS)

From: Ye Li <[email protected]>

Update DDR PHY settings to support LPDDR4 mode only by adjusting DQ VREF ctrl, ODT and pads drive strength.

---
 board/freescale/imx8ulp_evk/lpddr4_timing.c | 32 ++++++++++-----------
 1 file changed, 16 insertions(+), 16 deletions(-)
board/freescale/imx8ulp_evk/lpddr4_timing.c +16 -16
index 4546e92b01..09240999ce 100644
@@ -701,7 +701,7 @@ struct dram_cfg_param ddr_phy_f1_cfg[] = {
 	{ 0x2e064154, 0x2000000 },	/* 85 */
 	{ 0x2e064158, 0x51515042 },	/* 86 */
 	{ 0x2e06415c, 0x31c06000 },	/* 87 */
-	{ 0x2e064160, 0x9bf000a },	/* 88 */
+	{ 0x2e064160, 0x6bf000a },	/* 88 */
 	{ 0x2e064164, 0xc0c000 },	/* 89 */
 	{ 0x2e064168, 0x1000000 },	/* 90 */
 	{ 0x2e06416c, 0x10001000 },	/* 91 */
@@ -777,7 +777,7 @@ struct dram_cfg_param ddr_phy_f1_cfg[] = {
 	{ 0x2e064554, 0x2000000 },	/* 341 */
 	{ 0x2e064558, 0x51515042 },	/* 342 */
 	{ 0x2e06455c, 0x31c06000 },	/* 343 */
-	{ 0x2e064560, 0x9bf000a },	/* 344 */
+	{ 0x2e064560, 0x6bf000a },	/* 344 */
 	{ 0x2e064564, 0xc0c000 },	/* 345 */
 	{ 0x2e064568, 0x1000000 },	/* 346 */
 	{ 0x2e06456c, 0x10001000 },	/* 347 */
@@ -854,7 +854,7 @@ struct dram_cfg_param ddr_phy_f1_cfg[] = {
 	{ 0x2e064954, 0x2000000 },	/* 597 */
 	{ 0x2e064958, 0x51515042 },	/* 598 */
 	{ 0x2e06495c, 0x31c06000 },	/* 599 */
-	{ 0x2e064960, 0x9bf000a },	/* 600 */
+	{ 0x2e064960, 0x6bf000a },	/* 600 */
 	{ 0x2e064964, 0xc0c000 },	/* 601 */
 	{ 0x2e064968, 0x1000000 },	/* 602 */
 	{ 0x2e06496c, 0x10001000 },	/* 603 */
@@ -930,7 +930,7 @@ struct dram_cfg_param ddr_phy_f1_cfg[] = {
 	{ 0x2e064d54, 0x2000000 },	/* 853 */
 	{ 0x2e064d58, 0x51515042 },	/* 854 */
 	{ 0x2e064d5c, 0x31c06000 },	/* 855 */
-	{ 0x2e064d60, 0x9bf000a },	/* 856 */
+	{ 0x2e064d60, 0x6bf000a },	/* 856 */
 	{ 0x2e064d64, 0xc0c000 },	/* 857 */
 	{ 0x2e064d68, 0x1000000 },	/* 858 */
 	{ 0x2e064d6c, 0x10001000 },	/* 859 */
@@ -1032,7 +1032,7 @@ struct dram_cfg_param ddr_phy_f1_cfg[] = {
 	{ 0x2e065860, 0x8040201 },	/* 1560 */
 	{ 0x2e065864, 0x2010201 },	/* 1561 */
 	{ 0x2e065868, 0xf0f0f },	/* 1562 */
-	{ 0x2e06586c, 0x241b42 },	/* 1563 */
+	{ 0x2e06586c, 0x241342 },	/* 1563 */
 	{ 0x2e065874, 0x1020000 },	/* 1565 */
 	{ 0x2e065878, 0x701 },	/* 1566 */
 	{ 0x2e06587c, 0x54 },	/* 1567 */
@@ -1047,7 +1047,7 @@ struct dram_cfg_param ddr_phy_f1_cfg[] = {
 	{ 0x2e0658a0, 0x4410 },	/* 1576 */
 	{ 0x2e0658a4, 0x4410 },	/* 1577 */
 	{ 0x2e0658b0, 0x60000 },	/* 1580 */
-	{ 0x2e0658b8, 0x96 },	/* 1582 */
+	{ 0x2e0658b8, 0x66 },	/* 1582 */
 	{ 0x2e0658bc, 0x10000 },	/* 1583 */
 	{ 0x2e0658c0, 0x8 },	/* 1584 */
 	{ 0x2e0658d8, 0x3000000 },	/* 1590 */
@@ -1074,20 +1074,20 @@ struct dram_cfg_param ddr_phy_f1_cfg[] = {
 	{ 0x2e065980, 0x300 },	/* 1632 */
 	{ 0x2e065984, 0x300 },	/* 1633 */
 	{ 0x2e065988, 0x300 },	/* 1634 */
-	{ 0x2e06598c, 0x4bf77 },	/* 1635 */
-	{ 0x2e065990, 0x77 },	/* 1636 */
-	{ 0x2e065994, 0x27f },	/* 1637 */
-	{ 0x2e06599c, 0x27f },	/* 1639 */
-	{ 0x2e0659a4, 0x27f00 },	/* 1641 */
+	{ 0x2e06598c, 0x337cc },	/* 1635 */
+	{ 0x2e065990, 0x8 },	/* 1636 */
+	{ 0x2e065994, 0x1b7 },	/* 1637 */
+	{ 0x2e06599c, 0x1b7 },	/* 1639 */
+	{ 0x2e0659a4, 0x1b700 },	/* 1641 */
 	{ 0x2e0659a8, 0x1980000 },	/* 1642 */
-	{ 0x2e0659ac, 0x27fcc },	/* 1643 */
-	{ 0x2e0659b4, 0x27f00 },	/* 1645 */
+	{ 0x2e0659ac, 0x1b7cc },	/* 1643 */
+	{ 0x2e0659b4, 0x1b700 },	/* 1645 */
 	{ 0x2e0659b8, 0x1980000 },	/* 1646 */
-	{ 0x2e0659bc, 0x27f00 },	/* 1647 */
+	{ 0x2e0659bc, 0x1b700 },	/* 1647 */
 	{ 0x2e0659c0, 0x1980000 },	/* 1648 */
-	{ 0x2e0659c4, 0x27f00 },	/* 1649 */
+	{ 0x2e0659c4, 0x1b700 },	/* 1649 */
 	{ 0x2e0659c8, 0x1980000 },	/* 1650 */
-	{ 0x2e0659cc, 0x27f00 },	/* 1651 */
+	{ 0x2e0659cc, 0x1b700 },	/* 1651 */
 	{ 0x2e0659d0, 0x1980000 },	/* 1652 */
 	{ 0x2e0659d4, 0x20040003 },	/* 1653 */
 };
Signature · 1 line
2.30.0
#22 lore raw

PATCH 18/27 imx: imx8ulp_evk: call the handshake with M33

In reply to Peng Fan (OSS)

From: Ye Li <[email protected]>

If M33 handshake is successful, TPM and DSI panel MUX setting is done by M33, no need to set them.
If handshake is failed or M33 is not booted, continue the TPM and DSI panel MUX setting

---
 board/freescale/imx8ulp_evk/imx8ulp_evk.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)
board/freescale/imx8ulp_evk/imx8ulp_evk.c +9 -1
index 1502e4dbb6..b61a4cfbe8 100644
@@ -101,10 +101,18 @@ void mipi_dsi_panel_backlight(void)
 
 int board_init(void)
 {
+	int sync = -ENODEV;
+
 	if (IS_ENABLED(CONFIG_FEC_MXC))
 		setup_fec();
 
-	if (IS_ENABLED(CONFIG_DM_VIDEO)) {
+	if (m33_image_booted()) {
+		sync = m33_image_handshake(1000);
+		printf("M33 Sync: %s\n", sync ? "Timeout" : "OK");
+	}
+
+	/* When sync with M33 is failed, use local driver to set for video */
+	if (sync != 0 && IS_ENABLED(CONFIG_DM_VIDEO)) {
 		mipi_dsi_mux_panel();
 		mipi_dsi_panel_backlight();
 	}
Signature · 1 line
2.30.0
#23 lore raw

PATCH 19/27 imx: imx8ulp_evk: Power down the domains may used in u-boot

In reply to Peng Fan (OSS)

From: Ye Li <[email protected]>

Since ATF power domain will hold the enable counter for each power domain, We need to power off them before entering kernel to avoid this power domain can't be really powered off.

---
 board/freescale/imx8ulp_evk/imx8ulp_evk.c | 30 +++++++++++++++++++++++
 1 file changed, 30 insertions(+)
board/freescale/imx8ulp_evk/imx8ulp_evk.c +30 -0
index b61a4cfbe8..1bd308148f 100644
@@ -13,6 +13,8 @@
 #include <miiphy.h>
 #include <netdev.h>
 #include <asm/gpio.h>
+#include <power-domain.h>
+#include <dt-bindings/power/imx8ulp-power.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -129,3 +131,31 @@ int board_late_init(void)
 {
 	return 0;
 }
+
+void board_quiesce_devices(void)
+{
+	/* Disable the power domains may used in u-boot before entering kernel */
+#if CONFIG_IS_ENABLED(POWER_DOMAIN)
+	struct udevice *scmi_devpd;
+	int ret, i;
+	struct power_domain pd;
+	ulong ids[] = { IMX8ULP_PD_FLEXSPI2, IMX8ULP_PD_USB0, IMX8ULP_PD_USDHC0,
+			IMX8ULP_PD_USDHC1, IMX8ULP_PD_USDHC2_USB1, IMX8ULP_PD_DCNANO,
+			IMX8ULP_PD_MIPI_DSI };
+
+	ret = uclass_get_device(UCLASS_POWER_DOMAIN, 0, &scmi_devpd);
+	if (ret) {
+		printf("Cannot get scmi devpd: err=%d\n", ret);
+		return;
+	}
+
+	pd.dev = scmi_devpd;
+
+	for (i = 0; i < ARRAY_SIZE(ids); i++) {
+		pd.id = ids[i];
+		ret = power_domain_off(&pd);
+		if (ret)
+			printf("power_domain_off %lu failed: err=%d\n", ids[i], ret);
+	}
+#endif
+}
Signature · 1 line
2.30.0
#24 lore raw

PATCH 20/27 imx: dynamic setting mmcdev and mmcroot

In reply to Peng Fan (OSS)

From: Peng Fan <[email protected]>

Dynamic setting mmcdev and mmcroot.
Then when boot linux, we can have correct "root=/dev/mmcblk[x]p2"

---
 arch/arm/include/asm/mach-imx/sys_proto.h |  2 +
 board/freescale/common/Makefile           |  3 ++
 board/freescale/common/mmc.c              | 49 +++++++++++++++++++++++
 3 files changed, 54 insertions(+)
 create mode 100644 board/freescale/common/mmc.c
arch/arm/include/asm/mach-imx/sys_proto.h +2 -0
index 88216af7eb..8be3a721cd 100644
@@ -229,6 +229,8 @@ int mxs_reset_block(struct mxs_register_32 *reg);
 int mxs_wait_mask_set(struct mxs_register_32 *reg, u32 mask, u32 timeout);
 int mxs_wait_mask_clr(struct mxs_register_32 *reg, u32 mask, u32 timeout);
 
+void board_late_mmc_env_init(void);
+
 unsigned long call_imx_sip(unsigned long id, unsigned long reg0,
 			   unsigned long reg1, unsigned long reg2,
 			   unsigned long reg3);
board/freescale/common/Makefile +3 -0
index 0ddfb59d7d..81d97cd436 100644
@@ -67,6 +67,9 @@ obj-$(CONFIG_ZM7300)		+= zm7300.o
 obj-$(CONFIG_POWER_PFUZE100)	+= pfuze.o
 obj-$(CONFIG_DM_PMIC_PFUZE100)	+= pfuze.o
 obj-$(CONFIG_POWER_MC34VR500)	+= mc34vr500.o
+ifneq (,$(filter $(SOC), imx8ulp))
+obj-y				+= mmc.o
+endif
 
 obj-$(CONFIG_LS102XA_STREAM_ID)	+= ls102xa_stream_id.o
 
board/freescale/common/mmc.c new file +49 -0

49 lines not on this page · raw message

Signature · 1 line
2.30.0
#25 lore raw

PATCH 21/27 imx: imx8ulp_evk: Enable SD/MMC port auto detect

In reply to Peng Fan (OSS)

From: Peng Fan <[email protected]>

Enable the SD/MMC port auto detect.
The mmc relevant env can be reset when auto detect is enabled.

---
 board/freescale/imx8ulp_evk/imx8ulp_evk.c | 3 +++
 1 file changed, 3 insertions(+)
board/freescale/imx8ulp_evk/imx8ulp_evk.c +3 -0
index 1bd308148f..5ca72e171c 100644
@@ -129,6 +129,9 @@ int board_early_init_f(void)
 
 int board_late_init(void)
 {
+#if CONFIG_IS_ENABLED(ENV_IS_IN_MMC)
+	board_late_mmc_env_init();
+#endif
 	return 0;
 }
 
Signature · 1 line
2.30.0
#26 lore raw

PATCH 22/27 imx: imx8ulp: enable wdog_ad interrupt in CMC1

In reply to Peng Fan (OSS)

From: Peng Fan <[email protected]>

Enable wdog_ad interrupt being triggered by CMC1 to CM33 to let CM33 know A35 reset and reinitialize rpmsg.
Clear wdog_ad and AD_PERIPH reset interrupt after A35 up, otherwise M33 will always receive interrupt.

---
 arch/arm/mach-imx/imx8ulp/soc.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)
arch/arm/mach-imx/imx8ulp/soc.c +13 -0
index b0ddaef222..86ca4ffad9 100644
@@ -570,6 +570,19 @@ int arch_cpu_init(void)
 		int ret;
 		bool rdc_en = true; /* Default assume DBD_EN is set */
 
+		/* Enable System Reset Interrupt using WDOG_AD */
+		setbits_le32(CMC1_BASE_ADDR + 0x8C, BIT(13));
+		/* Clear AD_PERIPH Power switch domain out of reset interrupt flag */
+		setbits_le32(CMC1_BASE_ADDR + 0x70, BIT(4));
+
+		if (readl(CMC1_BASE_ADDR + 0x90) & BIT(13)) {
+			/* Clear System Reset Interrupt Flag Register of WDOG_AD */
+			setbits_le32(CMC1_BASE_ADDR + 0x90, BIT(13));
+			/* Reset WDOG to clear reset request */
+			pcc_reset_peripheral(3, WDOG3_PCC3_SLOT, true);
+			pcc_reset_peripheral(3, WDOG3_PCC3_SLOT, false);
+		}
+
 		/* Disable wdog */
 		init_wdog();
 
Signature · 1 line
2.30.0
#27 lore raw

PATCH 23/27 imx: imx8ulp: reserve tee memory

In reply to Peng Fan (OSS)

From: Ji Luo <[email protected]>

The TEE memory should be reserved when TEE is present, so need to runtime update dram bank and memory information according to tee present or not.

---
 arch/arm/mach-imx/imx8ulp/soc.c | 102 +++++++++++++++++++++++++++++++-
 1 file changed, 100 insertions(+), 2 deletions(-)
arch/arm/mach-imx/imx8ulp/soc.c +100 -2
index 86ca4ffad9..7aa89aefe8 100644
@@ -412,6 +412,17 @@ static struct mm_region imx8ulp_arm64_mem_map[] = {
 
 struct mm_region *mem_map = imx8ulp_arm64_mem_map;
 
+static unsigned int imx8ulp_find_dram_entry_in_mem_map(void)
+{
+	int i;
+
+	for (i = 0; i < ARRAY_SIZE(imx8ulp_arm64_mem_map); i++)
+		if (imx8ulp_arm64_mem_map[i].phys == CONFIG_SYS_SDRAM_BASE)
+			return i;
+
+	hang();	/* Entry not found, this must never happen. */
+}
+
 /* simplify the page table size to enhance boot speed */
 #define MAX_PTE_ENTRIES		512
 #define MAX_MEM_MAP_REGIONS	16
@@ -443,19 +454,106 @@ u64 get_page_table_size(void)
 
 void enable_caches(void)
 {
-	/* TODO: add TEE memmap region */
+	/* If OPTEE runs, remove OPTEE memory from MMU table to avoid speculative prefetch */
+	if (rom_pointer[1]) {
+		/*
+		 * TEE are loaded, So the ddr bank structures
+		 * have been modified update mmu table accordingly
+		 */
+		int i = 0;
+		int entry = imx8ulp_find_dram_entry_in_mem_map();
+		u64 attrs = imx8ulp_arm64_mem_map[entry].attrs;
+
+		while (i < CONFIG_NR_DRAM_BANKS &&
+		       entry < ARRAY_SIZE(imx8ulp_arm64_mem_map)) {
+			if (gd->bd->bi_dram[i].start == 0)
+				break;
+			imx8ulp_arm64_mem_map[entry].phys = gd->bd->bi_dram[i].start;
+			imx8ulp_arm64_mem_map[entry].virt = gd->bd->bi_dram[i].start;
+			imx8ulp_arm64_mem_map[entry].size = gd->bd->bi_dram[i].size;
+			imx8ulp_arm64_mem_map[entry].attrs = attrs;
+			debug("Added memory mapping (%d): %llx %llx\n", entry,
+			      imx8ulp_arm64_mem_map[entry].phys, imx8ulp_arm64_mem_map[entry].size);
+			i++; entry++;
+		}
+	}
 
 	icache_enable();
 	dcache_enable();
 }
 
+__weak int board_phys_sdram_size(phys_size_t *size)
+{
+	if (!size)
+		return -EINVAL;
+
+	*size = PHYS_SDRAM_SIZE;
+	return 0;
+}
+
 int dram_init(void)
 {
-	gd->ram_size = PHYS_SDRAM_SIZE;
+	unsigned int entry = imx8ulp_find_dram_entry_in_mem_map();
+	phys_size_t sdram_size;
+	int ret;
+
+	ret = board_phys_sdram_size(&sdram_size);
+	if (ret)
+		return ret;
+
+	/* rom_pointer[1] contains the size of TEE occupies */
+	if (rom_pointer[1])
+		gd->ram_size = sdram_size - rom_pointer[1];
+	else
+		gd->ram_size = sdram_size;
+
+	/* also update the SDRAM size in the mem_map used externally */
+	imx8ulp_arm64_mem_map[entry].size = sdram_size;
+	return 0;
+}
+
+int dram_init_banksize(void)
+{
+	int bank = 0;
+	int ret;
+	phys_size_t sdram_size;
+
+	ret = board_phys_sdram_size(&sdram_size);
+	if (ret)
+		return ret;
+
+	gd->bd->bi_dram[bank].start = PHYS_SDRAM;
+	if (rom_pointer[1]) {
+		phys_addr_t optee_start = (phys_addr_t)rom_pointer[0];
+		phys_size_t optee_size = (size_t)rom_pointer[1];
+
+		gd->bd->bi_dram[bank].size = optee_start - gd->bd->bi_dram[bank].start;
+		if ((optee_start + optee_size) < (PHYS_SDRAM + sdram_size)) {
+			if (++bank >= CONFIG_NR_DRAM_BANKS) {
+				puts("CONFIG_NR_DRAM_BANKS is not enough\n");
+				return -1;
+			}
+
+			gd->bd->bi_dram[bank].start = optee_start + optee_size;
+			gd->bd->bi_dram[bank].size = PHYS_SDRAM +
+				sdram_size - gd->bd->bi_dram[bank].start;
+		}
+	} else {
+		gd->bd->bi_dram[bank].size = sdram_size;
+	}
 
 	return 0;
 }
 
+phys_size_t get_effective_memsize(void)
+{
+	/* return the first bank as effective memory */
+	if (rom_pointer[1])
+		return ((phys_addr_t)rom_pointer[0] - PHYS_SDRAM);
+
+	return gd->ram_size;
+}
+
 #ifdef CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG
 void get_board_serial(struct tag_serialnr *serialnr)
 {
Signature · 1 line
2.30.0
#28 lore raw

PATCH 24/27 imx: imx8ulp_evk: enlarge CONFIG_NR_DRAM_BANKS

In reply to Peng Fan (OSS)

From: Peng Fan <[email protected]>

When TEE is present, the DRAM maybe split to two parts, so enlarge CONFIG_NR_DRAM_BANKS

---
 configs/imx8ulp_evk_defconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
configs/imx8ulp_evk_defconfig +1 -1
index 0e2a646ebf..4eaf3085b2 100644
@@ -5,7 +5,7 @@ CONFIG_SYS_MALLOC_LEN=0x1002000
 CONFIG_SYS_MALLOC_F_LEN=0x2000
 CONFIG_SPL_LIBCOMMON_SUPPORT=y
 CONFIG_SPL_LIBGENERIC_SUPPORT=y
-CONFIG_NR_DRAM_BANKS=1
+CONFIG_NR_DRAM_BANKS=2
 CONFIG_ENV_SIZE=0x2000
 CONFIG_ENV_OFFSET=0x400000
 CONFIG_IMX_CONFIG=""
Signature · 1 line
2.30.0
reviewer
#29 lore raw

Re: [PATCH 24/27] imx: imx8ulp_evk: enlarge CONFIG_NR_DRAM_BANKS

Hi Peng,

Quoted 5 lines · Peng Fan (OSS)

From: Peng Fan <[email protected]>

When TEE is present, the DRAM maybe split to two parts, so enlarge CONFIG_NR_DRAM_BANKS

I think this description is confusing.

CONFIG_NR_DRAM_BANKS should be set according to how many DDR chips are connected.

The usage of TEE is not relevant to CONFIG_NR_DRAM_BANKS.

#30 lore raw

Re: [PATCH 24/27] imx: imx8ulp_evk: enlarge CONFIG_NR_DRAM_BANKS

Quoted 9 lines · Fabio Estevam

Hi Peng,

Quoted 5 lines · Peng Fan (OSS)

From: Peng Fan <[email protected]>

When TEE is present, the DRAM maybe split to two parts, so enlarge CONFIG_NR_DRAM_BANKS

Quoted 6 lines

I think this description is confusing.

CONFIG_NR_DRAM_BANKS should be set according to how many DDR chips are connected.

The usage of TEE is not relevant to CONFIG_NR_DRAM_BANKS.

TEE locates in the middle of DRAM memory space, it will split the DRAM. I not have other idea how to support this without enlarge CONFIG_NR_DRAM_BANKS.

Thanks,
Peng.

Quoted 1 line
#31 lore raw

PATCH 25/27 dt-bindings: power: imx8ulp: include power entry header

In reply to Peng Fan (OSS)

From: Peng Fan <[email protected]>

Introdue i.MX8ULP power entry header

---
 include/dt-bindings/power/imx8ulp-power.h | 26 +++++++++++++++++++++++
 1 file changed, 26 insertions(+)
 create mode 100644 include/dt-bindings/power/imx8ulp-power.h
include/dt-bindings/power/imx8ulp-power.h new file +26 -0
new file mode 100644
index 0000000000..a556b2e96d
@@ -0,0 +1,26 @@
+/* SPDX-License-Identifier: (GPL-2.0 OR MIT) */
+/*
+ *  Copyright 2021 NXP
+ */
+
+#ifndef __DT_BINDINGS_IMX8ULP_POWER_H__
+#define __DT_BINDINGS_IMX8ULP_POWER_H__
+
+#define IMX8ULP_PD_DMA1		0
+#define IMX8ULP_PD_FLEXSPI2	1
+#define IMX8ULP_PD_USB0		2
+#define IMX8ULP_PD_USDHC0	3
+#define IMX8ULP_PD_USDHC1	4
+#define IMX8ULP_PD_USDHC2_USB1	5
+#define IMX8ULP_PD_DCNANO	6
+#define IMX8ULP_PD_EPDC		7
+#define IMX8ULP_PD_DMA2		8
+#define IMX8ULP_PD_GPU2D	9
+#define IMX8ULP_PD_GPU3D	10
+#define IMX8ULP_PD_HIFI4	11
+#define IMX8ULP_PD_ISI		12
+#define IMX8ULP_PD_MIPI_CSI	13
+#define IMX8ULP_PD_MIPI_DSI	14
+#define IMX8ULP_PD_PXP		15
+
+#endif
Signature · 1 line
2.30.0
reviewer
#32 lore raw

Re: [PATCH 25/27] dt-bindings: power: imx8ulp: include power entry header

Hi Peng,

Quoted 4 lines · Peng Fan (OSS)

From: Peng Fan <[email protected]>

Introdue i.MX8ULP power entry header

s/Introdue/Introduce

Please explain why this header file is needed.

You introduce this header file on 25/27, but I don't see any usage of it on 26/27 and 27/27.

#33 lore raw

PATCH 26/27 imx: imx8ulp_evk: Enable multiple env storage devices

In reply to Peng Fan (OSS)

From: Ye Li <[email protected]>

Enable multiple storages for u-boot env:
MMC or SPI flash or NOWHERE for usb
so u-boot can runtime select the storage flash according to boot device.

---
 arch/arm/mach-imx/imx8ulp/soc.c | 36 +++++++++++++++++++++++++++++++++
 1 file changed, 36 insertions(+)
arch/arm/mach-imx/imx8ulp/soc.c +36 -0
index 7aa89aefe8..e40df1e290 100644
@@ -26,6 +26,8 @@
 #include <fuse.h>
 #include <thermal.h>
 #include <linux/iopoll.h>
+#include <env.h>
+#include <env_internal.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -785,3 +787,37 @@ u32 spl_arch_boot_image_offset(u32 image_offset, u32 rom_bt_dev)
 
 	return image_offset;
 }
+
+enum env_location env_get_location(enum env_operation op, int prio)
+{
+	enum boot_device dev = get_boot_device();
+	enum env_location env_loc = ENVL_UNKNOWN;
+
+	if (prio)
+		return env_loc;
+
+	switch (dev) {
+#ifdef CONFIG_ENV_IS_IN_SPI_FLASH
+	case QSPI_BOOT:
+		env_loc = ENVL_SPI_FLASH;
+		break;
+#endif
+#ifdef CONFIG_ENV_IS_IN_MMC
+	case SD1_BOOT:
+	case SD2_BOOT:
+	case SD3_BOOT:
+	case MMC1_BOOT:
+	case MMC2_BOOT:
+	case MMC3_BOOT:
+		env_loc =  ENVL_MMC;
+		break;
+#endif
+	default:
+#if defined(CONFIG_ENV_IS_NOWHERE)
+		env_loc = ENVL_NOWHERE;
+#endif
+		break;
+	}
+
+	return env_loc;
+}
Signature · 1 line
2.30.0
#34 lore raw

PATCH 27/27 misc: imx8ulp: Update fuse driver

In reply to Peng Fan (OSS)

From: Peng Fan <[email protected]>

- According to S400 API, the fuse bank 25 (Testconfig2) is able to access. Add it into driver's mapping table.
- According to FSB words list, the reserved 48 words are ahead of the bank 5 and bank 6. Fix the wrong position.

---
 drivers/misc/imx8ulp/fuse.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/misc/imx8ulp/fuse.c +2 -1
index 01db470e8f..090e702d9f 100644
@@ -34,9 +34,9 @@ struct s400_map_entry {
 struct fsb_map_entry fsb_mapping_table[] = {
 	{ 3, 8 },
 	{ 4, 8 },
+	{ -1, 48 }, /* Reserve 48 words */
 	{ 5, 8 },
 	{ 6, 8 },
-	{ -1, 48 }, /* Reserve 48 words */
 	{ 8,  4, true },
 	{ 24, 4, true },
 	{ 26, 4, true },
@@ -63,6 +63,7 @@ struct s400_map_entry s400_api_mapping_table[] = {
 	{ 7, 4, 0, 1 },	/* OTP_UNIQ_ID */
 	{ 15, 8 }, /* OEM SRK HASH */
 	{ 23, 1, 4, 2 }, /* OTFAD */
+	{ 25, 8 }, /* Test config2 */
 };
 
 static s32 map_fsb_fuse_index(u32 bank, u32 word, bool *redundancy)
Signature · 1 line
2.30.0