From 4c47d98a44679566aa1a7752aa389bf03dd5f2cb Mon Sep 17 00:00:00 2001
From: Jon Medhurst <tixy@linaro.org>
Date: Mon, 13 Jan 2014 20:47:24 +0000
Subject: [PATCH] juno: Override platform_get_core_pos and
 platform_is_primary_cpu

Signed-off-by: Jon Medhurst <tixy@linaro.org>
---
 plat/juno/aarch64/plat_helpers.S | 28 ++++++++++++++++++++++++++++
 plat/juno/platform.h             |  2 +-
 plat/juno/platform.mk            |  1 +
 3 files changed, 30 insertions(+), 1 deletion(-)

diff --git a/plat/juno/aarch64/plat_helpers.S b/plat/juno/aarch64/plat_helpers.S
index 00e885060..cd6cbde26 100644
--- a/plat/juno/aarch64/plat_helpers.S
+++ b/plat/juno/aarch64/plat_helpers.S
@@ -46,3 +46,31 @@
 plat_report_exception:
 	/* Juno todo: Come up with a way of reporting errors */
 	ret
+
+	/*
+	 * Return 0 to 3 for the A53s and 4 or 5 for the A57s
+	 */
+	.globl	platform_get_core_pos
+platform_get_core_pos:; .type platform_get_core_pos, %function
+	and	x1, x0, #MPIDR_CPU_MASK
+	and	x0, x0, #MPIDR_CLUSTER_MASK
+	eor	x0, x0, #(1 << MPIDR_AFFINITY_BITS)  // swap A53/A57 order
+	add	x0, x1, x0, LSR #6
+	ret
+
+
+	/* -----------------------------------------------------
+	 * void platform_is_primary_cpu (unsigned int mpid);
+	 *
+	 * Given the mpidr say whether this cpu is the primary
+	 * cpu (applicable ony after a cold boot)
+	 * -----------------------------------------------------
+	 */
+	.globl	platform_is_primary_cpu
+platform_is_primary_cpu:; .type platform_is_primary_cpu, %function
+	/* Warning: this function is called without a valid stack */
+	/* Juno todo: allow configuration of primary CPU using SCC */
+	and	x0, x0, #(MPIDR_CLUSTER_MASK | MPIDR_CPU_MASK)
+	cmp	x0, #PRIMARY_CPU
+	cset	x0, eq
+	ret
diff --git a/plat/juno/platform.h b/plat/juno/platform.h
index 3656a51c3..2728988bf 100644
--- a/plat/juno/platform.h
+++ b/plat/juno/platform.h
@@ -74,7 +74,7 @@
 #define PLATFORM_CORE_COUNT		(PLATFORM_CLUSTER1_CORE_COUNT + \
 						PLATFORM_CLUSTER0_CORE_COUNT)
 #define PLATFORM_MAX_CPUS_PER_CLUSTER	4
-#define PRIMARY_CPU			0x0
+#define PRIMARY_CPU			0x100
 #define MAX_IO_DEVICES			3
 #define MAX_IO_HANDLES			4
 
diff --git a/plat/juno/platform.mk b/plat/juno/platform.mk
index 16c7f7600..62a6d315f 100644
--- a/plat/juno/platform.mk
+++ b/plat/juno/platform.mk
@@ -78,6 +78,7 @@ BL1_SOURCES		+=	bl1_plat_setup.c			\
 				cci400.c
 
 BL2_SOURCES		+=	bl2_plat_setup.c			\
+				plat_helpers.S				\
 				plat_common.c
 
 BL31_SOURCES		+=	bl31_plat_setup.c			\
-- 
GitLab