Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 1 | /* |
Boyan Karatotev | 0d02082 | 2024-11-19 11:27:01 +0000 | [diff] [blame] | 2 | * Copyright (c) 2014-2025, Arm Limited and Contributors. All rights reserved. |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 3 | * |
dp-arm | 82cb2c1 | 2017-05-03 09:38:09 +0100 | [diff] [blame] | 4 | * SPDX-License-Identifier: BSD-3-Clause |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 5 | */ |
Soby Mathew | add4035 | 2014-08-14 12:49:05 +0100 | [diff] [blame] | 6 | #include <aem_generic.h> |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 7 | #include <arch.h> |
Andrew Thoelke | 0a30cf5 | 2014-03-18 13:46:55 +0000 | [diff] [blame] | 8 | #include <asm_macros.S> |
Soby Mathew | 9b47684 | 2014-08-14 11:33:56 +0100 | [diff] [blame] | 9 | #include <cpu_macros.S> |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 10 | |
Boyan Karatotev | 89dba82 | 2025-01-22 13:54:43 +0000 | [diff] [blame] | 11 | cpu_reset_prologue aem_generic |
| 12 | |
Soby Mathew | add4035 | 2014-08-14 12:49:05 +0100 | [diff] [blame] | 13 | func aem_generic_core_pwr_dwn |
| 14 | /* --------------------------------------------- |
| 15 | * Disable the Data Cache. |
| 16 | * --------------------------------------------- |
| 17 | */ |
| 18 | mrs x1, sctlr_el3 |
| 19 | bic x1, x1, #SCTLR_C_BIT |
| 20 | msr sctlr_el3, x1 |
| 21 | isb |
Soby Mathew | 9b47684 | 2014-08-14 11:33:56 +0100 | [diff] [blame] | 22 | |
Soby Mathew | add4035 | 2014-08-14 12:49:05 +0100 | [diff] [blame] | 23 | /* --------------------------------------------- |
Alexei Fedorov | ef430ff | 2019-07-29 17:22:53 +0100 | [diff] [blame] | 24 | * AEM model supports L3 caches in which case L2 |
| 25 | * will be private per core caches and flush |
| 26 | * from L1 to L2 is not sufficient. |
Soby Mathew | add4035 | 2014-08-14 12:49:05 +0100 | [diff] [blame] | 27 | * --------------------------------------------- |
| 28 | */ |
Alexei Fedorov | ef430ff | 2019-07-29 17:22:53 +0100 | [diff] [blame] | 29 | mrs x1, clidr_el1 |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 30 | |
Alexei Fedorov | ef430ff | 2019-07-29 17:22:53 +0100 | [diff] [blame] | 31 | /* --------------------------------------------- |
| 32 | * Check if L3 cache is implemented. |
| 33 | * --------------------------------------------- |
| 34 | */ |
| 35 | tst x1, ((1 << CLIDR_FIELD_WIDTH) - 1) << CTYPE_SHIFT(3) |
| 36 | |
| 37 | /* --------------------------------------------- |
| 38 | * There is no L3 cache, flush L1 to L2 only. |
| 39 | * --------------------------------------------- |
| 40 | */ |
| 41 | mov x0, #DCCISW |
| 42 | b.eq dcsw_op_level1 |
| 43 | |
| 44 | mov x18, x30 |
| 45 | |
| 46 | /* --------------------------------------------- |
| 47 | * Flush L1 cache to L2. |
| 48 | * --------------------------------------------- |
| 49 | */ |
| 50 | bl dcsw_op_level1 |
| 51 | mov x30, x18 |
| 52 | |
| 53 | /* --------------------------------------------- |
| 54 | * Flush L2 cache to L3. |
| 55 | * --------------------------------------------- |
| 56 | */ |
| 57 | mov x0, #DCCISW |
| 58 | b dcsw_op_level2 |
| 59 | endfunc aem_generic_core_pwr_dwn |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 60 | |
Soby Mathew | add4035 | 2014-08-14 12:49:05 +0100 | [diff] [blame] | 61 | func aem_generic_cluster_pwr_dwn |
| 62 | /* --------------------------------------------- |
| 63 | * Disable the Data Cache. |
| 64 | * --------------------------------------------- |
| 65 | */ |
| 66 | mrs x1, sctlr_el3 |
| 67 | bic x1, x1, #SCTLR_C_BIT |
| 68 | msr sctlr_el3, x1 |
| 69 | isb |
| 70 | |
| 71 | /* --------------------------------------------- |
Alexei Fedorov | ef430ff | 2019-07-29 17:22:53 +0100 | [diff] [blame] | 72 | * Flush all caches to PoC. |
Soby Mathew | add4035 | 2014-08-14 12:49:05 +0100 | [diff] [blame] | 73 | * --------------------------------------------- |
| 74 | */ |
| 75 | mov x0, #DCCISW |
| 76 | b dcsw_op_all |
Kévin Petit | 8b77962 | 2015-03-24 14:03:57 +0000 | [diff] [blame] | 77 | endfunc aem_generic_cluster_pwr_dwn |
Soby Mathew | add4035 | 2014-08-14 12:49:05 +0100 | [diff] [blame] | 78 | |
Boyan Karatotev | 0d02082 | 2024-11-19 11:27:01 +0000 | [diff] [blame] | 79 | cpu_reset_func_start aem_generic |
| 80 | cpu_reset_func_end aem_generic |
| 81 | |
Soby Mathew | d3f70af | 2014-08-14 13:36:41 +0100 | [diff] [blame] | 82 | /* --------------------------------------------- |
| 83 | * This function provides cpu specific |
| 84 | * register information for crash reporting. |
| 85 | * It needs to return with x6 pointing to |
| 86 | * a list of register names in ascii and |
| 87 | * x8 - x15 having values of registers to be |
| 88 | * reported. |
| 89 | * --------------------------------------------- |
| 90 | */ |
Soby Mathew | 6fa11a5 | 2015-04-13 16:57:12 +0100 | [diff] [blame] | 91 | .section .rodata.aem_generic_regs, "aS" |
| 92 | aem_generic_regs: /* The ascii list of register names to be reported */ |
| 93 | .asciz "" /* no registers to report */ |
| 94 | |
Soby Mathew | d3f70af | 2014-08-14 13:36:41 +0100 | [diff] [blame] | 95 | func aem_generic_cpu_reg_dump |
Soby Mathew | 6fa11a5 | 2015-04-13 16:57:12 +0100 | [diff] [blame] | 96 | adr x6, aem_generic_regs |
Soby Mathew | d3f70af | 2014-08-14 13:36:41 +0100 | [diff] [blame] | 97 | ret |
Kévin Petit | 8b77962 | 2015-03-24 14:03:57 +0000 | [diff] [blame] | 98 | endfunc aem_generic_cpu_reg_dump |
Soby Mathew | d3f70af | 2014-08-14 13:36:41 +0100 | [diff] [blame] | 99 | |
Soby Mathew | add4035 | 2014-08-14 12:49:05 +0100 | [diff] [blame] | 100 | |
| 101 | /* cpu_ops for Base AEM FVP */ |
Boyan Karatotev | 0d02082 | 2024-11-19 11:27:01 +0000 | [diff] [blame] | 102 | declare_cpu_ops aem_generic, BASE_AEM_MIDR, aem_generic_reset_func, \ |
Jeenu Viswambharan | 5dd9dbb | 2016-11-18 12:58:28 +0000 | [diff] [blame] | 103 | aem_generic_core_pwr_dwn, \ |
| 104 | aem_generic_cluster_pwr_dwn |
Soby Mathew | 9b47684 | 2014-08-14 11:33:56 +0100 | [diff] [blame] | 105 | |
Soby Mathew | add4035 | 2014-08-14 12:49:05 +0100 | [diff] [blame] | 106 | /* cpu_ops for Foundation FVP */ |
Boyan Karatotev | 0d02082 | 2024-11-19 11:27:01 +0000 | [diff] [blame] | 107 | declare_cpu_ops aem_generic, FOUNDATION_AEM_MIDR, aem_generic_reset_func, \ |
Jeenu Viswambharan | 5dd9dbb | 2016-11-18 12:58:28 +0000 | [diff] [blame] | 108 | aem_generic_core_pwr_dwn, \ |
| 109 | aem_generic_cluster_pwr_dwn |