Dan Handley | 9df4804 | 2015-03-19 18:58:55 +0000 | [diff] [blame] | 1 | /* |
Vikram Kanigiri | 7208419 | 2016-02-08 16:29:30 +0000 | [diff] [blame] | 2 | * Copyright (c) 2013-2016, ARM Limited and Contributors. All rights reserved. |
Dan Handley | 9df4804 | 2015-03-19 18:58:55 +0000 | [diff] [blame] | 3 | * |
dp-arm | fa3cf0b | 2017-05-03 09:38:09 +0100 | [diff] [blame] | 4 | * SPDX-License-Identifier: BSD-3-Clause |
Dan Handley | 9df4804 | 2015-03-19 18:58:55 +0000 | [diff] [blame] | 5 | */ |
| 6 | #include <arch.h> |
| 7 | #include <asm_macros.S> |
| 8 | #include <cpu_macros.S> |
| 9 | #include <css_def.h> |
| 10 | |
| 11 | .weak plat_secondary_cold_boot_setup |
Soby Mathew | fec4eb7 | 2015-07-01 16:16:20 +0100 | [diff] [blame] | 12 | .weak plat_get_my_entrypoint |
David Wang | 323ebe8 | 2015-10-22 13:30:50 +0800 | [diff] [blame] | 13 | .globl css_calc_core_pos_swap_cluster |
Soby Mathew | fec4eb7 | 2015-07-01 16:16:20 +0100 | [diff] [blame] | 14 | .weak plat_is_my_cpu_primary |
Dan Handley | 9df4804 | 2015-03-19 18:58:55 +0000 | [diff] [blame] | 15 | |
Sandrine Bailleux | 4c79d20 | 2015-04-29 16:28:52 +0100 | [diff] [blame] | 16 | /* --------------------------------------------------------------------- |
| 17 | * void plat_secondary_cold_boot_setup(void); |
Dan Handley | 9df4804 | 2015-03-19 18:58:55 +0000 | [diff] [blame] | 18 | * |
Sandrine Bailleux | 4c79d20 | 2015-04-29 16:28:52 +0100 | [diff] [blame] | 19 | * In the normal boot flow, cold-booting secondary CPUs is not yet |
| 20 | * implemented and they panic. |
| 21 | * |
| 22 | * When booting an EL3 payload, secondary CPUs are placed in a holding |
| 23 | * pen, waiting for their mailbox to be populated. Note that all CPUs |
| 24 | * share the same mailbox ; therefore, populating it will release all |
| 25 | * CPUs from their holding pen. If finer-grained control is needed then |
| 26 | * this should be handled in the code that secondary CPUs jump to. |
| 27 | * --------------------------------------------------------------------- |
Dan Handley | 9df4804 | 2015-03-19 18:58:55 +0000 | [diff] [blame] | 28 | */ |
| 29 | func plat_secondary_cold_boot_setup |
Sandrine Bailleux | 4c79d20 | 2015-04-29 16:28:52 +0100 | [diff] [blame] | 30 | #ifndef EL3_PAYLOAD_BASE |
| 31 | /* TODO: Implement secondary CPU cold boot setup on CSS platforms */ |
Dan Handley | 9df4804 | 2015-03-19 18:58:55 +0000 | [diff] [blame] | 32 | cb_panic: |
| 33 | b cb_panic |
Sandrine Bailleux | 4c79d20 | 2015-04-29 16:28:52 +0100 | [diff] [blame] | 34 | #else |
| 35 | mov_imm x0, PLAT_ARM_TRUSTED_MAILBOX_BASE |
| 36 | |
| 37 | /* Wait until the mailbox gets populated */ |
| 38 | poll_mailbox: |
| 39 | ldr x1, [x0] |
| 40 | cbz x1, 1f |
| 41 | br x1 |
| 42 | 1: |
| 43 | wfe |
| 44 | b poll_mailbox |
| 45 | #endif /* EL3_PAYLOAD_BASE */ |
Dan Handley | 9df4804 | 2015-03-19 18:58:55 +0000 | [diff] [blame] | 46 | endfunc plat_secondary_cold_boot_setup |
| 47 | |
Sandrine Bailleux | daf9a9d | 2015-07-10 16:49:31 +0100 | [diff] [blame] | 48 | /* --------------------------------------------------------------------- |
Soby Mathew | a0fedc4 | 2016-06-16 14:52:04 +0100 | [diff] [blame] | 49 | * uintptr_t plat_get_my_entrypoint (void); |
Dan Handley | 9df4804 | 2015-03-19 18:58:55 +0000 | [diff] [blame] | 50 | * |
Sandrine Bailleux | daf9a9d | 2015-07-10 16:49:31 +0100 | [diff] [blame] | 51 | * Main job of this routine is to distinguish between a cold and a warm |
| 52 | * boot. On CSS platforms, this distinction is based on the contents of |
| 53 | * the Trusted Mailbox. It is initialised to zero by the SCP before the |
| 54 | * AP cores are released from reset. Therefore, a zero mailbox means |
| 55 | * it's a cold reset. |
Dan Handley | 9df4804 | 2015-03-19 18:58:55 +0000 | [diff] [blame] | 56 | * |
Sandrine Bailleux | daf9a9d | 2015-07-10 16:49:31 +0100 | [diff] [blame] | 57 | * This functions returns the contents of the mailbox, i.e.: |
| 58 | * - 0 for a cold boot; |
| 59 | * - the warm boot entrypoint for a warm boot. |
| 60 | * --------------------------------------------------------------------- |
Dan Handley | 9df4804 | 2015-03-19 18:58:55 +0000 | [diff] [blame] | 61 | */ |
Soby Mathew | fec4eb7 | 2015-07-01 16:16:20 +0100 | [diff] [blame] | 62 | func plat_get_my_entrypoint |
Soby Mathew | feac8fc | 2015-09-29 15:47:16 +0100 | [diff] [blame] | 63 | mov_imm x0, PLAT_ARM_TRUSTED_MAILBOX_BASE |
Sandrine Bailleux | daf9a9d | 2015-07-10 16:49:31 +0100 | [diff] [blame] | 64 | ldr x0, [x0] |
| 65 | ret |
Soby Mathew | fec4eb7 | 2015-07-01 16:16:20 +0100 | [diff] [blame] | 66 | endfunc plat_get_my_entrypoint |
Dan Handley | 9df4804 | 2015-03-19 18:58:55 +0000 | [diff] [blame] | 67 | |
Soby Mathew | fec4eb7 | 2015-07-01 16:16:20 +0100 | [diff] [blame] | 68 | /* ----------------------------------------------------------- |
Soby Mathew | a0fedc4 | 2016-06-16 14:52:04 +0100 | [diff] [blame] | 69 | * unsigned int css_calc_core_pos_swap_cluster(u_register_t mpidr) |
David Wang | 323ebe8 | 2015-10-22 13:30:50 +0800 | [diff] [blame] | 70 | * Utility function to calculate the core position by |
Soby Mathew | fec4eb7 | 2015-07-01 16:16:20 +0100 | [diff] [blame] | 71 | * swapping the cluster order. This is necessary in order to |
| 72 | * match the format of the boot information passed by the SCP |
Soby Mathew | eb3bbf1 | 2015-06-08 12:32:50 +0100 | [diff] [blame] | 73 | * and read in plat_is_my_cpu_primary below. |
Soby Mathew | fec4eb7 | 2015-07-01 16:16:20 +0100 | [diff] [blame] | 74 | * ----------------------------------------------------------- |
Dan Handley | 9df4804 | 2015-03-19 18:58:55 +0000 | [diff] [blame] | 75 | */ |
David Wang | 323ebe8 | 2015-10-22 13:30:50 +0800 | [diff] [blame] | 76 | func css_calc_core_pos_swap_cluster |
Dan Handley | 9df4804 | 2015-03-19 18:58:55 +0000 | [diff] [blame] | 77 | and x1, x0, #MPIDR_CPU_MASK |
| 78 | and x0, x0, #MPIDR_CLUSTER_MASK |
| 79 | eor x0, x0, #(1 << MPIDR_AFFINITY_BITS) // swap cluster order |
| 80 | add x0, x1, x0, LSR #6 |
| 81 | ret |
David Wang | 323ebe8 | 2015-10-22 13:30:50 +0800 | [diff] [blame] | 82 | endfunc css_calc_core_pos_swap_cluster |
Dan Handley | 9df4804 | 2015-03-19 18:58:55 +0000 | [diff] [blame] | 83 | |
| 84 | /* ----------------------------------------------------- |
Soby Mathew | fec4eb7 | 2015-07-01 16:16:20 +0100 | [diff] [blame] | 85 | * unsigned int plat_is_my_cpu_primary (void); |
Dan Handley | 9df4804 | 2015-03-19 18:58:55 +0000 | [diff] [blame] | 86 | * |
Soby Mathew | fec4eb7 | 2015-07-01 16:16:20 +0100 | [diff] [blame] | 87 | * Find out whether the current cpu is the primary |
Dan Handley | 9df4804 | 2015-03-19 18:58:55 +0000 | [diff] [blame] | 88 | * cpu (applicable ony after a cold boot) |
| 89 | * ----------------------------------------------------- |
| 90 | */ |
Soby Mathew | fec4eb7 | 2015-07-01 16:16:20 +0100 | [diff] [blame] | 91 | func plat_is_my_cpu_primary |
Dan Handley | 9df4804 | 2015-03-19 18:58:55 +0000 | [diff] [blame] | 92 | mov x9, x30 |
Soby Mathew | fec4eb7 | 2015-07-01 16:16:20 +0100 | [diff] [blame] | 93 | bl plat_my_core_pos |
Dan Handley | 9df4804 | 2015-03-19 18:58:55 +0000 | [diff] [blame] | 94 | ldr x1, =SCP_BOOT_CFG_ADDR |
| 95 | ldr x1, [x1] |
Vikram Kanigiri | 7208419 | 2016-02-08 16:29:30 +0000 | [diff] [blame] | 96 | ubfx x1, x1, #PLAT_CSS_PRIMARY_CPU_SHIFT, \ |
| 97 | #PLAT_CSS_PRIMARY_CPU_BIT_WIDTH |
Dan Handley | 9df4804 | 2015-03-19 18:58:55 +0000 | [diff] [blame] | 98 | cmp x0, x1 |
Soby Mathew | eb3bbf1 | 2015-06-08 12:32:50 +0100 | [diff] [blame] | 99 | cset w0, eq |
Dan Handley | 9df4804 | 2015-03-19 18:58:55 +0000 | [diff] [blame] | 100 | ret x9 |
Soby Mathew | fec4eb7 | 2015-07-01 16:16:20 +0100 | [diff] [blame] | 101 | endfunc plat_is_my_cpu_primary |