summaryrefslogtreecommitdiff
path: root/arch/arm/cpu/armv7/sunxi/psci_head.S
diff options
context:
space:
mode:
authorChen-Yu Tsai <wens@csie.org>2016-06-07 10:54:34 +0800
committerHans de Goede <hdegoede@redhat.com>2016-06-20 22:44:00 +0200
commit4257f5f8f631147803cdc6693b5046deb1a57be6 (patch)
treeb25c60fbc1921e2a47643e4008639ffb95767747 /arch/arm/cpu/armv7/sunxi/psci_head.S
parent3424c3f29970beaa3810acbc6ba3b8062a71ef09 (diff)
downloadu-boot-imx-4257f5f8f631147803cdc6693b5046deb1a57be6.zip
u-boot-imx-4257f5f8f631147803cdc6693b5046deb1a57be6.tar.gz
u-boot-imx-4257f5f8f631147803cdc6693b5046deb1a57be6.tar.bz2
sunxi: Add PSCI implementation in C
To make the PSCI backend more maintainable and easier to port to newer SoCs, rewrite the current PSCI implementation in C. Some inline assembly bits are required to access coprocessor registers. PSCI stack setup is the only part left completely in assembly. In theory this part could be split out of psci_arch_init into a separate common function, and psci_arch_init could be completely in C. Signed-off-by: Chen-Yu Tsai <wens@csie.org> Acked-by: Marc Zyngier <marc.zyngier@arm.com> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Diffstat (limited to 'arch/arm/cpu/armv7/sunxi/psci_head.S')
-rw-r--r--arch/arm/cpu/armv7/sunxi/psci_head.S66
1 files changed, 66 insertions, 0 deletions
diff --git a/arch/arm/cpu/armv7/sunxi/psci_head.S b/arch/arm/cpu/armv7/sunxi/psci_head.S
new file mode 100644
index 0000000..8fa823d
--- /dev/null
+++ b/arch/arm/cpu/armv7/sunxi/psci_head.S
@@ -0,0 +1,66 @@
+/*
+ * Copyright (C) 2013 - ARM Ltd
+ * Author: Marc Zyngier <marc.zyngier@arm.com>
+ *
+ * Based on code by Carl van Schaik <carl@ok-labs.com>.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <config.h>
+#include <linux/linkage.h>
+
+#include <asm/arch-armv7/generictimer.h>
+#include <asm/gic.h>
+#include <asm/macro.h>
+#include <asm/psci.h>
+#include <asm/arch/cpu.h>
+
+/*
+ * Memory layout:
+ *
+ * SECURE_RAM to text_end :
+ * ._secure_text section
+ * text_end to ALIGN_PAGE(text_end):
+ * nothing
+ * ALIGN_PAGE(text_end) to ALIGN_PAGE(text_end) + 0x1000)
+ * 1kB of stack per CPU (4 CPUs max).
+ */
+
+ .pushsection ._secure.text, "ax"
+
+ .arch_extension sec
+
+#define GICD_BASE (SUNXI_GIC400_BASE + 0x1000)
+#define GICC_BASE (SUNXI_GIC400_BASE + 0x2000)
+
+@ {r0, r1, r2, ip} from _do_nonsec_entry(kernel_entry, 0, machid, r2) in
+@ arch/arm/lib/bootm.c:boot_jump_linux() must remain unchanged across
+@ this function.
+ENTRY(psci_arch_init)
+ mov r6, lr
+ mov r7, r0
+ bl psci_get_cpu_id @ CPU ID => r0
+ bl psci_get_cpu_stack_top @ stack top => r0
+ sub r0, r0, #4 @ Save space for target PC
+ mov sp, r0
+ mov r0, r7
+ mov lr, r6
+
+ push {r0, r1, r2, ip, lr}
+ bl sunxi_gic_init
+ pop {r0, r1, r2, ip, pc}
+ENDPROC(psci_arch_init)
+
+ENTRY(psci_text_end)
+ .popsection