Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 1 | /* |
Sandrine Bailleux | acde8b0 | 2015-05-19 11:54:45 +0100 | [diff] [blame] | 2 | * Copyright (c) 2013-2015, ARM Limited and Contributors. All rights reserved. |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 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> |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 32 | #include <asm_macros.S> |
Sandrine Bailleux | acde8b0 | 2015-05-19 11:54:45 +0100 | [diff] [blame] | 33 | #include <el3_common_macros.S> |
Dan Handley | 2bd4ef2 | 2014-04-09 13:14:54 +0100 | [diff] [blame] | 34 | #include <psci.h> |
Achin Gupta | e1aa516 | 2014-06-26 09:58:52 +0100 | [diff] [blame] | 35 | #include <xlat_tables.h> |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 36 | |
Soby Mathew | 981487a | 2015-07-13 14:10:57 +0100 | [diff] [blame] | 37 | .globl psci_entrypoint |
Achin Gupta | 42c5280 | 2014-05-09 19:32:25 +0100 | [diff] [blame] | 38 | .globl psci_power_down_wfi |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 39 | |
Soby Mathew | 981487a | 2015-07-13 14:10:57 +0100 | [diff] [blame] | 40 | /* -------------------------------------------------------------------- |
| 41 | * This CPU has been physically powered up. It is either resuming from |
| 42 | * suspend or has simply been turned on. In both cases, call the power |
| 43 | * on finisher. |
| 44 | * -------------------------------------------------------------------- |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 45 | */ |
Soby Mathew | 981487a | 2015-07-13 14:10:57 +0100 | [diff] [blame] | 46 | func psci_entrypoint |
Sandrine Bailleux | acde8b0 | 2015-05-19 11:54:45 +0100 | [diff] [blame] | 47 | /* |
| 48 | * On the warm boot path, most of the EL3 initialisations performed by |
| 49 | * 'el3_entrypoint_common' must be skipped: |
| 50 | * |
Juan Castillo | 7d19941 | 2015-12-14 09:35:25 +0000 | [diff] [blame] | 51 | * - Only when the platform bypasses the BL1/BL31 entrypoint by |
Sandrine Bailleux | 449dbd5 | 2015-06-02 17:19:43 +0100 | [diff] [blame] | 52 | * programming the reset address do we need to set the CPU endianness. |
| 53 | * In other cases, we assume this has been taken care by the |
| 54 | * entrypoint code. |
| 55 | * |
Sandrine Bailleux | acde8b0 | 2015-05-19 11:54:45 +0100 | [diff] [blame] | 56 | * - No need to determine the type of boot, we know it is a warm boot. |
| 57 | * |
| 58 | * - Do not try to distinguish between primary and secondary CPUs, this |
| 59 | * notion only exists for a cold boot. |
| 60 | * |
| 61 | * - No need to initialise the memory or the C runtime environment, |
| 62 | * it has been done once and for all on the cold boot path. |
Achin Gupta | e1aa516 | 2014-06-26 09:58:52 +0100 | [diff] [blame] | 63 | */ |
Sandrine Bailleux | acde8b0 | 2015-05-19 11:54:45 +0100 | [diff] [blame] | 64 | el3_entrypoint_common \ |
Sandrine Bailleux | 449dbd5 | 2015-06-02 17:19:43 +0100 | [diff] [blame] | 65 | _set_endian=PROGRAMMABLE_RESET_ADDRESS \ |
Sandrine Bailleux | acde8b0 | 2015-05-19 11:54:45 +0100 | [diff] [blame] | 66 | _warm_boot_mailbox=0 \ |
| 67 | _secondary_cold_boot=0 \ |
| 68 | _init_memory=0 \ |
| 69 | _init_c_runtime=0 \ |
| 70 | _exception_vectors=runtime_exceptions |
Achin Gupta | e1aa516 | 2014-06-26 09:58:52 +0100 | [diff] [blame] | 71 | |
| 72 | /* -------------------------------------------- |
| 73 | * Enable the MMU with the DCache disabled. It |
| 74 | * is safe to use stacks allocated in normal |
| 75 | * memory as a result. All memory accesses are |
| 76 | * marked nGnRnE when the MMU is disabled. So |
| 77 | * all the stack writes will make it to memory. |
| 78 | * All memory accesses are marked Non-cacheable |
| 79 | * when the MMU is enabled but D$ is disabled. |
| 80 | * So used stack memory is guaranteed to be |
| 81 | * visible immediately after the MMU is enabled |
| 82 | * Enabling the DCache at the same time as the |
| 83 | * MMU can lead to speculatively fetched and |
| 84 | * possibly stale stack memory being read from |
| 85 | * other caches. This can lead to coherency |
| 86 | * issues. |
| 87 | * -------------------------------------------- |
| 88 | */ |
| 89 | mov x0, #DISABLE_DCACHE |
| 90 | bl bl31_plat_enable_mmu |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 91 | |
Soby Mathew | 981487a | 2015-07-13 14:10:57 +0100 | [diff] [blame] | 92 | bl psci_power_up_finish |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 93 | |
Jeenu Viswambharan | caa8493 | 2014-02-06 10:36:15 +0000 | [diff] [blame] | 94 | b el3_exit |
Soby Mathew | 981487a | 2015-07-13 14:10:57 +0100 | [diff] [blame] | 95 | endfunc psci_entrypoint |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 96 | |
Achin Gupta | 42c5280 | 2014-05-09 19:32:25 +0100 | [diff] [blame] | 97 | /* -------------------------------------------- |
| 98 | * This function is called to indicate to the |
| 99 | * power controller that it is safe to power |
| 100 | * down this cpu. It should not exit the wfi |
| 101 | * and will be released from reset upon power |
| 102 | * up. 'wfi_spill' is used to catch erroneous |
| 103 | * exits from wfi. |
| 104 | * -------------------------------------------- |
| 105 | */ |
| 106 | func psci_power_down_wfi |
Andrew Thoelke | 42e75a7 | 2014-04-28 12:28:39 +0100 | [diff] [blame] | 107 | dsb sy // ensure write buffer empty |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 108 | wfi |
Soby Mathew | 6a81641 | 2016-04-27 14:46:28 +0100 | [diff] [blame] | 109 | bl plat_panic_handler |
Kévin Petit | a877c25 | 2015-03-24 14:03:57 +0000 | [diff] [blame] | 110 | endfunc psci_power_down_wfi |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 111 | |