From mboxrd@z Thu Jan 1 00:00:00 1970 From: Peng Fan Date: Wed, 18 Jul 2018 09:35:49 +0800 Subject: [U-Boot] [PATCH V2 19/32] imx8: add arch_cpu_init arch_cpu_init_dm In-Reply-To: <20180718013602.26574-1-peng.fan@nxp.com> References: <20180718013602.26574-1-peng.fan@nxp.com> Message-ID: <20180718013602.26574-20-peng.fan@nxp.com> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de Add arch_cpu_init(_dm) mainly to open the channel between ACore and SCU. Signed-off-by: Peng Fan Cc: Stefano Babic --- arch/arm/include/asm/arch-imx8/sys_proto.h | 9 ++++++ arch/arm/mach-imx/imx8/cpu.c | 51 ++++++++++++++++++++++++++++++ 2 files changed, 60 insertions(+) diff --git a/arch/arm/include/asm/arch-imx8/sys_proto.h b/arch/arm/include/asm/arch-imx8/sys_proto.h index f9a3016132..73ffaba7d5 100644 --- a/arch/arm/include/asm/arch-imx8/sys_proto.h +++ b/arch/arm/include/asm/arch-imx8/sys_proto.h @@ -6,5 +6,14 @@ #include #include +struct pass_over_info_t { + u16 barker; + u16 len; + u32 g_bt_cfg_shadow; + u32 card_address_mode; + u32 bad_block_count_met; + u32 g_ap_mu; +}; + enum boot_device get_boot_device(void); int print_bootinfo(void); diff --git a/arch/arm/mach-imx/imx8/cpu.c b/arch/arm/mach-imx/imx8/cpu.c index 389f422be7..e461fcfcd6 100644 --- a/arch/arm/mach-imx/imx8/cpu.c +++ b/arch/arm/mach-imx/imx8/cpu.c @@ -95,6 +95,57 @@ int print_cpuinfo(void) } #endif +#define BT_PASSOVER_TAG 0x504F +struct pass_over_info_t *get_pass_over_info(void) +{ + struct pass_over_info_t *p = + (struct pass_over_info_t *)PASS_OVER_INFO_ADDR; + + if (p->barker != BT_PASSOVER_TAG || + p->len != sizeof(struct pass_over_info_t)) + return NULL; + + return p; +} + +int arch_cpu_init(void) +{ + struct pass_over_info_t *pass_over = get_pass_over_info(); + + if (pass_over && pass_over->g_ap_mu == 0) { + /* + * When ap_mu is 0, means the u-boot is boot + * from first container + */ + sc_misc_boot_status(-1, SC_MISC_BOOT_STATUS_SUCCESS); + } + + return 0; +} + +int arch_cpu_init_dm(void) +{ + struct udevice *devp; + int node, ret; + + node = fdt_node_offset_by_compatible(gd->fdt_blob, -1, "fsl,imx8-mu"); + ret = device_bind_driver_to_node(gd->dm_root, "imx8_scu", "imx8_scu", + offset_to_ofnode(node), &devp); + + if (ret) { + printf("could not find scu %d\n", ret); + return ret; + } + + ret = device_probe(devp); + if (ret) { + printf("could not find scu %d\n", ret); + return ret; + } + + return 0; +} + int print_bootinfo(void) { enum boot_device bt_dev = get_boot_device(); -- 2.14.1