MLK-16747 imx8m: use SIP to start/check M4
authorPeng Fan <peng.fan@nxp.com>
Wed, 1 Nov 2017 10:09:28 +0000 (18:09 +0800)
committerJason Liu <jason.hui.liu@nxp.com>
Thu, 2 Nov 2017 18:37:29 +0000 (02:37 +0800)
Use SIP to start/Check M4.

Signed-off-by: Peng Fan <peng.fan@nxp.com>
Reviewed-by: Ye Li <ye.li@nxp.com>
arch/arm/cpu/armv8/imx8/cpu.c
arch/arm/cpu/armv8/imx8m/soc.c
arch/arm/imx-common/Makefile
arch/arm/imx-common/sip.c [new file with mode: 0644]
arch/arm/include/asm/imx-common/sys_proto.h

index f0c8a5f..d94c5d9 100644 (file)
@@ -649,19 +649,6 @@ bool is_usb_boot(void)
 #define FSL_SIP_BUILDINFO_GET_COMMITHASH       0x00
 extern uint32_t _end_ofs;
 
-static unsigned long call_imx_sip(unsigned long id, unsigned long reg0, unsigned long reg1, unsigned long reg2)
-{
-       struct pt_regs regs;
-       regs.regs[0] = id;
-       regs.regs[1] = reg0;
-       regs.regs[2] = reg1;
-       regs.regs[3] = reg2;
-
-       smc_call(&regs);
-
-       return regs.regs[0];
-}
-
 static void set_buildinfo_to_env(uint32_t scfw, char *mkimage, char *atf)
 {
        if (!mkimage || !atf)
index af69ce2..f1a5fb0 100644 (file)
@@ -256,11 +256,12 @@ void imx_get_mac_from_fuse(int dev_id, unsigned char *mac)
 #endif
 
 #ifdef CONFIG_IMX_BOOTAUX
-#define M4RCR (0xC)
+#define FSL_SIP_SRC            0xC2000005
+#define FSL_SIP_SRC_M4_START   0x00
+#define FSL_SIP_SRC_M4_STARTED 0x01
 int arch_auxiliary_core_up(u32 core_id, ulong boot_private_data)
 {
        u32 stack, pc;
-       u32 val;
 
        if (!boot_private_data)
                return -EINVAL;
@@ -273,24 +274,14 @@ int arch_auxiliary_core_up(u32 core_id, ulong boot_private_data)
        writel(pc, M4_BOOTROM_BASE_ADDR + 4);
 
        /* Enable M4 */
-       val = readl(SRC_BASE_ADDR + M4RCR);
-       val &= ~SRC_SCR_M4C_NON_SCLR_RST_MASK;
-       val |= SRC_SCR_M4_ENABLE_MASK;
-       writel(val, SRC_BASE_ADDR + M4RCR);
+       call_imx_sip(FSL_SIP_SRC, FSL_SIP_SRC_M4_START, 0, 0);
 
        return 0;
 }
 
 int arch_auxiliary_core_check_up(u32 core_id)
 {
-       unsigned val;
-
-       val = readl(SRC_BASE_ADDR + M4RCR);
-
-       if (val & 0x00000001)
-               return 0;  /* assert in reset */
-
-       return 1;
+       return call_imx_sip(FSL_SIP_SRC, FSL_SIP_SRC_M4_STARTED, 0, 0);
 }
 #endif
 
index baa9f8b..30d18a3 100644 (file)
@@ -15,6 +15,9 @@ obj-$(CONFIG_IMX_BOOTAUX) += imx_bootaux.o
 obj-$(CONFIG_SYS_I2C_MXC) += i2c-mxv7.o
 obj-y += cpu.o
 endif
+
+obj-$(CONFIG_ARM64) += sip.o
+
 ifeq ($(SOC),$(filter $(SOC),mx5 mx6))
 obj-y  += cpu.o speed.o
 obj-$(CONFIG_SYS_I2C_MXC) += i2c-mxv7.o
diff --git a/arch/arm/imx-common/sip.c b/arch/arm/imx-common/sip.c
new file mode 100644 (file)
index 0000000..72db30c
--- /dev/null
@@ -0,0 +1,22 @@
+/*
+ * Copyright 2017 NXP
+ *
+ * SPDX-License-Identifier:    GPL-2.0+
+ */
+
+#include <common.h>
+#include <asm/arch/sys_proto.h>
+
+unsigned long call_imx_sip(unsigned long id, unsigned long reg0, unsigned long reg1, unsigned long reg2)
+{
+       struct pt_regs regs;
+
+       regs.regs[0] = id;
+       regs.regs[1] = reg0;
+       regs.regs[2] = reg1;
+       regs.regs[3] = reg2;
+
+       smc_call(&regs);
+
+       return regs.regs[0];
+}
index c0c74d8..c2c1a81 100644 (file)
@@ -85,4 +85,8 @@ void pcie_power_up(void);
 void pcie_power_off(void);
 int arch_auxiliary_core_up(u32 core_id, ulong boot_private_data);
 int arch_auxiliary_core_check_up(u32 core_id);
+
+#ifdef CONFIG_ARM64
+unsigned long call_imx_sip(unsigned long id, unsigned long reg0, unsigned long reg1, unsigned long reg2);
+#endif
 #endif