Yatharth Kochar | a4c219a | 2016-07-12 15:47:03 +0100 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2016, 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 <assert_macros.S> |
| 34 | #include <cortex_a32.h> |
| 35 | #include <cpu_macros.S> |
| 36 | |
| 37 | |
| 38 | /* --------------------------------------------- |
| 39 | * Disable intra-cluster coherency |
| 40 | * Clobbers: r0-r1 |
| 41 | * --------------------------------------------- |
| 42 | */ |
| 43 | func cortex_a32_disable_smp |
| 44 | ldcopr16 r0, r1, CORTEX_A32_CPUECTLR_EL1 |
| 45 | bic r0, r0, #CORTEX_A32_CPUECTLR_SMPEN_BIT |
| 46 | stcopr16 r0, r1, CORTEX_A32_CPUECTLR_EL1 |
| 47 | isb |
| 48 | dsb sy |
| 49 | bx lr |
| 50 | endfunc cortex_a32_disable_smp |
| 51 | |
| 52 | /* ------------------------------------------------- |
| 53 | * The CPU Ops reset function for Cortex-A32. |
| 54 | * Clobbers: r0-r1 |
| 55 | * ------------------------------------------------- |
| 56 | */ |
| 57 | func cortex_a32_reset_func |
| 58 | /* --------------------------------------------- |
| 59 | * Enable the SMP bit. |
| 60 | * --------------------------------------------- |
| 61 | */ |
| 62 | ldcopr16 r0, r1, CORTEX_A32_CPUECTLR_EL1 |
| 63 | orr r0, r0, #CORTEX_A32_CPUECTLR_SMPEN_BIT |
| 64 | stcopr16 r0, r1, CORTEX_A32_CPUECTLR_EL1 |
| 65 | isb |
| 66 | bx lr |
| 67 | endfunc cortex_a32_reset_func |
| 68 | |
| 69 | /* ---------------------------------------------------- |
| 70 | * The CPU Ops core power down function for Cortex-A32. |
| 71 | * Clobbers: r0-r3 |
| 72 | * ---------------------------------------------------- |
| 73 | */ |
| 74 | func cortex_a32_core_pwr_dwn |
| 75 | push {lr} |
| 76 | |
| 77 | /* Assert if cache is enabled */ |
| 78 | #if ASM_ASSERTION |
| 79 | ldcopr r0, SCTLR |
| 80 | tst r0, #SCTLR_C_BIT |
| 81 | ASM_ASSERT(eq) |
| 82 | #endif |
| 83 | |
| 84 | /* --------------------------------------------- |
| 85 | * Flush L1 caches. |
| 86 | * --------------------------------------------- |
| 87 | */ |
| 88 | mov r0, #DC_OP_CISW |
| 89 | bl dcsw_op_level1 |
| 90 | |
| 91 | /* --------------------------------------------- |
| 92 | * Come out of intra cluster coherency |
| 93 | * --------------------------------------------- |
| 94 | */ |
| 95 | pop {lr} |
| 96 | b cortex_a32_disable_smp |
| 97 | endfunc cortex_a32_core_pwr_dwn |
| 98 | |
| 99 | /* ------------------------------------------------------- |
| 100 | * The CPU Ops cluster power down function for Cortex-A32. |
| 101 | * Clobbers: r0-r3 |
| 102 | * ------------------------------------------------------- |
| 103 | */ |
| 104 | func cortex_a32_cluster_pwr_dwn |
| 105 | push {lr} |
| 106 | |
| 107 | /* Assert if cache is enabled */ |
| 108 | #if ASM_ASSERTION |
| 109 | ldcopr r0, SCTLR |
| 110 | tst r0, #SCTLR_C_BIT |
| 111 | ASM_ASSERT(eq) |
| 112 | #endif |
| 113 | |
| 114 | /* --------------------------------------------- |
| 115 | * Flush L1 cache. |
| 116 | * --------------------------------------------- |
| 117 | */ |
| 118 | mov r0, #DC_OP_CISW |
| 119 | bl dcsw_op_level1 |
| 120 | |
| 121 | /* --------------------------------------------- |
| 122 | * Disable the optional ACP. |
| 123 | * --------------------------------------------- |
| 124 | */ |
| 125 | bl plat_disable_acp |
| 126 | |
| 127 | /* --------------------------------------------- |
| 128 | * Flush L2 cache. |
| 129 | * --------------------------------------------- |
| 130 | */ |
| 131 | mov r0, #DC_OP_CISW |
| 132 | bl dcsw_op_level2 |
| 133 | |
| 134 | /* --------------------------------------------- |
| 135 | * Come out of intra cluster coherency |
| 136 | * --------------------------------------------- |
| 137 | */ |
| 138 | pop {lr} |
| 139 | b cortex_a32_disable_smp |
| 140 | endfunc cortex_a32_cluster_pwr_dwn |
| 141 | |
| 142 | declare_cpu_ops cortex_a32, CORTEX_A32_MIDR |