From patchwork Tue May 5 12:28:43 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peng Fan X-Patchwork-Id: 245132 List-Id: U-Boot discussion From: peng.fan at nxp.com (Peng Fan) Date: Tue, 5 May 2020 20:28:43 +0800 Subject: [PATCH 07/10] imx: imx8qm/qxp: check whether m4 partition booted In-Reply-To: <20200505122846.15992-1-peng.fan@nxp.com> References: <20200505122846.15992-1-peng.fan@nxp.com> Message-ID: <20200505122846.15992-8-peng.fan@nxp.com> Add code to check m4 partition booted or not, we will use this to runtime set device tree file that passed to Linux Kernel. Signed-off-by: Peng Fan --- arch/arm/include/asm/arch-imx8/sys_proto.h | 1 + arch/arm/mach-imx/imx8/cpu.c | 30 ++++++++++++++++++++++++++++++ board/freescale/imx8qxp_mek/spl.c | 2 +- 3 files changed, 32 insertions(+), 1 deletion(-) diff --git a/arch/arm/include/asm/arch-imx8/sys_proto.h b/arch/arm/include/asm/arch-imx8/sys_proto.h index 2a08ef939d..6f1fc8f999 100644 --- a/arch/arm/include/asm/arch-imx8/sys_proto.h +++ b/arch/arm/include/asm/arch-imx8/sys_proto.h @@ -29,3 +29,4 @@ int sc_pm_setup_uart(sc_rsrc_t uart_rsrc, sc_pm_clock_rate_t clk_rate); int imx8_power_domain_lookup_name(const char *name, struct power_domain *power_domain); void imx8_power_off_pd_devices(const char *permanent_on_devices[], int size); +bool m4_parts_booted(void); diff --git a/arch/arm/mach-imx/imx8/cpu.c b/arch/arm/mach-imx/imx8/cpu.c index 103a29746a..6d7b17b464 100644 --- a/arch/arm/mach-imx/imx8/cpu.c +++ b/arch/arm/mach-imx/imx8/cpu.c @@ -585,3 +585,33 @@ void board_boot_order(u32 *spl_boot_list) spl_boot_list[0] = BOOT_DEVICE_NOR; } } + +bool m4_parts_booted(void) +{ + sc_rm_pt_t m4_parts[2]; + int err; + + err = sc_rm_get_resource_owner(-1, SC_R_M4_0_PID0, &m4_parts[0]); + if (err) { + printf("%s get resource [%d] owner error: %d\n", __func__, + SC_R_M4_0_PID0, err); + return false; + } + + if (sc_pm_is_partition_started(-1, m4_parts[0])) + return true; + + if (is_imx8qm()) { + err = sc_rm_get_resource_owner(-1, SC_R_M4_1_PID0, &m4_parts[1]); + if (err) { + printf("%s get resource [%d] owner error: %d\n", + __func__, SC_R_M4_1_PID0, err); + return false; + } + + if (sc_pm_is_partition_started(-1, m4_parts[1])) + return true; + } + + return false; +} diff --git a/board/freescale/imx8qxp_mek/spl.c b/board/freescale/imx8qxp_mek/spl.c index 32b61095b0..eefee64ab1 100644 --- a/board/freescale/imx8qxp_mek/spl.c +++ b/board/freescale/imx8qxp_mek/spl.c @@ -58,7 +58,7 @@ void spl_board_init(void) void spl_board_prepare_for_boot(void) { - imx_power_off_pd_devices(NULL, 0); + imx8_power_off_pd_devices(NULL, 0); } #ifdef CONFIG_SPL_LOAD_FIT