Soby Mathew | 991d42c | 2015-06-29 16:30:12 +0100 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2013-2015, ARM Limited and Contributors. All rights reserved. |
| 3 | * |
| 4 | * Redistribution and use in source and binary forms, with or without |
| 5 | * modification, are permitted provided that the following conditions are met: |
| 6 | * |
| 7 | * Redistributions of source code must retain the above copyright notice, this |
| 8 | * list of conditions and the following disclaimer. |
| 9 | * |
| 10 | * Redistributions in binary form must reproduce the above copyright notice, |
| 11 | * this list of conditions and the following disclaimer in the documentation |
| 12 | * and/or other materials provided with the distribution. |
| 13 | * |
| 14 | * Neither the name of ARM nor the names of its contributors may be used |
| 15 | * to endorse or promote products derived from this software without specific |
| 16 | * prior written permission. |
| 17 | * |
| 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
| 19 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 20 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
| 21 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE |
| 22 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
| 23 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
| 24 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
| 25 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
| 26 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
| 27 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
| 28 | * POSSIBILITY OF SUCH DAMAGE. |
| 29 | */ |
| 30 | |
| 31 | #include <arch.h> |
| 32 | #include <asm_macros.S> |
| 33 | #include <el3_common_macros.S> |
| 34 | #include <psci.h> |
| 35 | #include <xlat_tables.h> |
| 36 | |
Soby Mathew | 3a9e8bf | 2015-05-05 16:33:16 +0100 | [diff] [blame] | 37 | .globl psci_cpu_on_finish_entry |
| 38 | .globl psci_cpu_suspend_finish_entry |
Soby Mathew | 991d42c | 2015-06-29 16:30:12 +0100 | [diff] [blame] | 39 | .globl psci_power_down_wfi |
| 40 | |
| 41 | /* ----------------------------------------------------- |
| 42 | * This cpu has been physically powered up. Depending |
| 43 | * upon whether it was resumed from suspend or simply |
| 44 | * turned on, call the common power on finisher with |
| 45 | * the handlers (chosen depending upon original state). |
| 46 | * ----------------------------------------------------- |
| 47 | */ |
Soby Mathew | 3a9e8bf | 2015-05-05 16:33:16 +0100 | [diff] [blame] | 48 | func psci_cpu_on_finish_entry |
| 49 | adr x23, psci_cpu_on_finish |
| 50 | b psci_power_up_entry |
Soby Mathew | 991d42c | 2015-06-29 16:30:12 +0100 | [diff] [blame] | 51 | |
Soby Mathew | 3a9e8bf | 2015-05-05 16:33:16 +0100 | [diff] [blame] | 52 | psci_cpu_suspend_finish_entry: |
| 53 | adr x23, psci_cpu_suspend_finish |
Soby Mathew | 991d42c | 2015-06-29 16:30:12 +0100 | [diff] [blame] | 54 | |
Soby Mathew | 3a9e8bf | 2015-05-05 16:33:16 +0100 | [diff] [blame] | 55 | psci_power_up_entry: |
Soby Mathew | 991d42c | 2015-06-29 16:30:12 +0100 | [diff] [blame] | 56 | /* |
| 57 | * On the warm boot path, most of the EL3 initialisations performed by |
| 58 | * 'el3_entrypoint_common' must be skipped: |
| 59 | * |
| 60 | * - Only when the platform bypasses the BL1/BL3-1 entrypoint by |
| 61 | * programming the reset address do we need to set the CPU endianness. |
| 62 | * In other cases, we assume this has been taken care by the |
| 63 | * entrypoint code. |
| 64 | * |
| 65 | * - No need to determine the type of boot, we know it is a warm boot. |
| 66 | * |
| 67 | * - Do not try to distinguish between primary and secondary CPUs, this |
| 68 | * notion only exists for a cold boot. |
| 69 | * |
| 70 | * - No need to initialise the memory or the C runtime environment, |
| 71 | * it has been done once and for all on the cold boot path. |
| 72 | */ |
| 73 | el3_entrypoint_common \ |
| 74 | _set_endian=PROGRAMMABLE_RESET_ADDRESS \ |
| 75 | _warm_boot_mailbox=0 \ |
| 76 | _secondary_cold_boot=0 \ |
| 77 | _init_memory=0 \ |
| 78 | _init_c_runtime=0 \ |
| 79 | _exception_vectors=runtime_exceptions |
| 80 | |
| 81 | /* -------------------------------------------- |
| 82 | * Enable the MMU with the DCache disabled. It |
| 83 | * is safe to use stacks allocated in normal |
| 84 | * memory as a result. All memory accesses are |
| 85 | * marked nGnRnE when the MMU is disabled. So |
| 86 | * all the stack writes will make it to memory. |
| 87 | * All memory accesses are marked Non-cacheable |
| 88 | * when the MMU is enabled but D$ is disabled. |
| 89 | * So used stack memory is guaranteed to be |
| 90 | * visible immediately after the MMU is enabled |
| 91 | * Enabling the DCache at the same time as the |
| 92 | * MMU can lead to speculatively fetched and |
| 93 | * possibly stale stack memory being read from |
| 94 | * other caches. This can lead to coherency |
| 95 | * issues. |
| 96 | * -------------------------------------------- |
| 97 | */ |
| 98 | mov x0, #DISABLE_DCACHE |
| 99 | bl bl31_plat_enable_mmu |
| 100 | |
Soby Mathew | 3a9e8bf | 2015-05-05 16:33:16 +0100 | [diff] [blame] | 101 | bl get_power_on_target_pwrlvl |
Soby Mathew | 6b8b302 | 2015-06-30 11:00:24 +0100 | [diff] [blame] | 102 | mov x1, x23 |
Soby Mathew | 3a9e8bf | 2015-05-05 16:33:16 +0100 | [diff] [blame] | 103 | bl psci_power_up_finish |
Soby Mathew | 991d42c | 2015-06-29 16:30:12 +0100 | [diff] [blame] | 104 | |
| 105 | b el3_exit |
Soby Mathew | 3a9e8bf | 2015-05-05 16:33:16 +0100 | [diff] [blame] | 106 | endfunc psci_cpu_on_finish_entry |
Soby Mathew | 991d42c | 2015-06-29 16:30:12 +0100 | [diff] [blame] | 107 | |
| 108 | /* -------------------------------------------- |
| 109 | * This function is called to indicate to the |
| 110 | * power controller that it is safe to power |
| 111 | * down this cpu. It should not exit the wfi |
| 112 | * and will be released from reset upon power |
| 113 | * up. 'wfi_spill' is used to catch erroneous |
| 114 | * exits from wfi. |
| 115 | * -------------------------------------------- |
| 116 | */ |
| 117 | func psci_power_down_wfi |
| 118 | dsb sy // ensure write buffer empty |
| 119 | wfi |
| 120 | wfi_spill: |
| 121 | b wfi_spill |
| 122 | endfunc psci_power_down_wfi |
| 123 | |