ARM: PSCI: Split out common stack setup code from psci_arch_init
authorChen-Yu Tsai <wens@csie.org>
Sun, 19 Jun 2016 04:38:31 +0000 (12:38 +0800)
committerHans de Goede <hdegoede@redhat.com>
Fri, 15 Jul 2016 13:54:56 +0000 (15:54 +0200)
Every platform has the same stack setup code in assembly as part of
psci_arch_init.

Move this out into a common separate function, psci_stack_setup, for
all platforms. This will allow us to move the remaining parts of
psci_arch_init into C code, or drop it entirely.

Also provide a stub no-op psci_arch_init for platforms that don't need
their own specific setup code.

Signed-off-by: Chen-Yu Tsai <wens@csie.org>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
arch/arm/cpu/armv7/ls102xa/psci.S
arch/arm/cpu/armv7/mx7/psci.S
arch/arm/cpu/armv7/nonsec_virt.S
arch/arm/cpu/armv7/psci.S
arch/arm/cpu/armv7/sunxi/psci_head.S
arch/arm/mach-tegra/psci.S

index cf5cd48bcbec037015e422273f6b8a6df292a535..86116e1fcc6568080b074c4e9f4f5bf1201dc70b 100644 (file)
@@ -111,16 +111,6 @@ psci_cpu_off:
 1:     wfi
        b       1b
 
-.globl psci_arch_init
-psci_arch_init:
-       mov     r6, lr
-
-       bl      psci_get_cpu_id
-       bl      psci_get_cpu_stack_top
-       mov     sp, r0
-
-       bx      r6
-
        .globl psci_text_end
 psci_text_end:
        .popsection
index 34c6ab33f058745993221ec2c1c097a86241fc98..12cca7cc6deb4f2f1d29ce96d2e135625c0386ee 100644 (file)
@@ -9,22 +9,6 @@
 
        .arch_extension sec
 
-       @ r1 = target CPU
-       @ r2 = target PC
-
-.globl psci_arch_init
-psci_arch_init:
-       mov     r6, lr
-
-       bl      psci_get_cpu_id
-       bl      psci_get_cpu_stack_top
-       mov     sp, r0
-
-       bx      r6
-
-       @ r1 = target CPU
-       @ r2 = target PC
-
 .globl psci_cpu_on
 psci_cpu_on:
        push    {lr}
index b7563edbe6bc0d81891abdd47f62f85b5a1be663..95ce9387b83e972414b6de2d5711a9f40fe097df 100644 (file)
@@ -49,8 +49,13 @@ _secure_monitor:
        mcr     p15, 0, r5, c12, c0, 1
        isb
 
-       @ Obtain a secure stack, and configure the PSCI backend
+       @ Obtain a secure stack
+       bl      psci_stack_setup
+
+       @ Configure the PSCI backend
+       push    {r0, r1, r2, ip}
        bl      psci_arch_init
+       pop     {r0, r1, r2, ip}
 #endif
 
 #ifdef CONFIG_ARM_ERRATA_773022
index ab408378fcae329592d03b590dc0205cb2272b2b..46fcf770c214b9e6adc1f5c71592aec445f4b38f 100644 (file)
@@ -211,6 +211,24 @@ ENTRY(psci_get_cpu_stack_top)
        bx      lr
 ENDPROC(psci_get_cpu_stack_top)
 
+@ {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_stack_setup)
+       mov     r6, lr
+       mov     r7, r0
+       bl      psci_get_cpu_id         @ CPU ID => r0
+       bl      psci_get_cpu_stack_top  @ stack top => r0
+       mov     sp, r0
+       mov     r0, r7
+       bx      r6
+ENDPROC(psci_stack_setup)
+
+ENTRY(psci_arch_init)
+       mov     pc, lr
+ENDPROC(psci_arch_init)
+.weak psci_arch_init
+
 ENTRY(psci_cpu_entry)
        bl      psci_enable_smp
 
index 8fa823d1df3a7e2bf3d1bb0d9b6c421216bdc425..e51db04cf1e2109d36f99d691060f795bf83c56a 100644 (file)
 #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}
+       b       sunxi_gic_init
 ENDPROC(psci_arch_init)
 
 ENTRY(psci_text_end)
index b836da1c0ed79b958c5544cfeff36a55b90314fe..75068f34c052689670dcbe8e4424c959b18acde5 100644 (file)
@@ -61,9 +61,6 @@ ENTRY(psci_arch_init)
        ldrne   r7, [r5]
        mcrne   p15, 0, r7, c14, c0, 0  @ write CNTFRQ to CPU1..3
 
-       bl      psci_get_cpu_stack_top  @ stack top => r0
-       mov     sp, r0
-
        bx      r6
 ENDPROC(psci_arch_init)