#if defined(CONFIG_SYS_MEM_RSVD_FOR_MMU) || defined(CONFIG_DEFINE_TCM_OCM_MMAP)
void tcm_init(u8 mode)
{
- puts("WARNING: Initializing TCM overwrites TCM content\n");
- initialize_tcm(mode);
- memset((void *)ZYNQMP_TCM_BASE_ADDR, 0, ZYNQMP_TCM_SIZE);
+ int ret;
+
+ ret = check_tcm_mode(mode);
+ if (!ret) {
+ puts("WARNING: Initializing TCM overwrites TCM content\n");
+ initialize_tcm(mode);
+ memset((void *)ZYNQMP_TCM_BASE_ADDR, 0, ZYNQMP_TCM_SIZE);
+ }
+
+ if (ret == -EACCES)
+ printf("ERROR: Split to lockstep mode required reset/disable cpu\n");
+
+ /* Ignore if ret is -EAGAIN, trying to initialize same mode again */
}
#endif
unsigned int zynqmp_get_silicon_version(void);
+int check_tcm_mode(bool mode);
void initialize_tcm(bool mode);
void mem_map_fill(void);
#if defined(CONFIG_SYS_MEM_RSVD_FOR_MMU) || defined(CONFIG_DEFINE_TCM_OCM_MMAP)
#include <asm/arch/hardware.h>
#include <asm/arch/sys_proto.h>
#include <asm/io.h>
+#include <linux/bitfield.h>
#include <linux/delay.h>
+#include <linux/errno.h>
#include <linux/string.h>
#define LOCK 0
}
}
+int check_tcm_mode(bool mode)
+{
+ u32 tmp, cpu_state;
+ bool mode_prev;
+
+ tmp = readl(&rpu_base->rpu_glbl_ctrl);
+ mode_prev = FIELD_GET(ZYNQMP_RPU_GLBL_CTRL_SPLIT_LOCK_MASK, tmp);
+
+ tmp = readl(&crlapb_base->rst_lpd_top);
+ cpu_state = FIELD_GET(ZYNQMP_CRLAPB_RST_LPD_R50_RST_MASK |
+ ZYNQMP_CRLAPB_RST_LPD_R51_RST_MASK, tmp);
+ cpu_state = cpu_state ? false : true;
+
+ if ((mode_prev == SPLIT && mode == LOCK) && cpu_state)
+ return -EACCES;
+
+ if (mode_prev == mode)
+ return -EAGAIN;
+
+ return 0;
+}
+
static void mark_r5_used(u32 nr, u8 mode)
{
u32 mask = 0;