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