blob: d5634cff8c7f5bca16117c624685a49ac85aa851 [file] [log] [blame]
Achin Gupta4f6ad662013-10-25 09:08:21 +01001/*
Ryan Everett3f588c42024-05-14 14:47:09 +01002 * Copyright (c) 2014-2024, Arm Limited and Contributors. All rights reserved.
Achin Gupta4f6ad662013-10-25 09:08:21 +01003 *
dp-armfa3cf0b2017-05-03 09:38:09 +01004 * SPDX-License-Identifier: BSD-3-Clause
Achin Gupta4f6ad662013-10-25 09:08:21 +01005 */
Soby Mathew8e2f2872014-08-14 12:49:05 +01006#include <aem_generic.h>
Achin Gupta4f6ad662013-10-25 09:08:21 +01007#include <arch.h>
Andrew Thoelke38bde412014-03-18 13:46:55 +00008#include <asm_macros.S>
Soby Mathewc704cbc2014-08-14 11:33:56 +01009#include <cpu_macros.S>
10
Soby Mathew8e2f2872014-08-14 12:49:05 +010011func 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 Gupta4f6ad662013-10-25 09:08:21 +010020
Alexei Fedorova95a5892019-07-29 17:22:53 +010021 /* ---------------------------------------------
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 Mathew8e2f2872014-08-14 12:49:05 +010039 mov x0, #DCCISW
Alexei Fedorova95a5892019-07-29 17:22:53 +010040 b.eq dcsw_op_level1
41
42 mov x18, x30
Achin Gupta4f6ad662013-10-25 09:08:21 +010043
Soby Mathew8e2f2872014-08-14 12:49:05 +010044 /* ---------------------------------------------
Alexei Fedorova95a5892019-07-29 17:22:53 +010045 * Flush L1 cache to L2.
Soby Mathew8e2f2872014-08-14 12:49:05 +010046 * ---------------------------------------------
47 */
Alexei Fedorova95a5892019-07-29 17:22:53 +010048 bl dcsw_op_level1
49 mov x30, x18
Achin Gupta4f6ad662013-10-25 09:08:21 +010050
Alexei Fedorova95a5892019-07-29 17:22:53 +010051 /* ---------------------------------------------
52 * Flush L2 cache to L3.
53 * ---------------------------------------------
54 */
55 mov x0, #DCCISW
56 b dcsw_op_level2
57endfunc aem_generic_core_pwr_dwn
Soby Mathew8e2f2872014-08-14 12:49:05 +010058
59func 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 Fedorova95a5892019-07-29 17:22:53 +010070 * Flush all caches to PoC.
Soby Mathew8e2f2872014-08-14 12:49:05 +010071 * ---------------------------------------------
72 */
73 mov x0, #DCCISW
74 b dcsw_op_all
Kévin Petita877c252015-03-24 14:03:57 +000075endfunc aem_generic_cluster_pwr_dwn
Soby Mathew8e2f2872014-08-14 12:49:05 +010076
Soby Mathew38b4bc92014-08-14 13:36:41 +010077 /* ---------------------------------------------
78 * This function provides cpu specific
79 * register information for crash reporting.
80 * It needs to return with x6 pointing to
81 * a list of register names in ascii and
82 * x8 - x15 having values of registers to be
83 * reported.
84 * ---------------------------------------------
85 */
Soby Mathewe364a8a2015-04-13 16:57:12 +010086.section .rodata.aem_generic_regs, "aS"
87aem_generic_regs: /* The ascii list of register names to be reported */
88 .asciz "" /* no registers to report */
89
Soby Mathew38b4bc92014-08-14 13:36:41 +010090func aem_generic_cpu_reg_dump
Soby Mathewe364a8a2015-04-13 16:57:12 +010091 adr x6, aem_generic_regs
Soby Mathew38b4bc92014-08-14 13:36:41 +010092 ret
Kévin Petita877c252015-03-24 14:03:57 +000093endfunc aem_generic_cpu_reg_dump
Soby Mathew38b4bc92014-08-14 13:36:41 +010094
Soby Mathew8e2f2872014-08-14 12:49:05 +010095
96/* cpu_ops for Base AEM FVP */
Jeenu Viswambharanee5eb802016-11-18 12:58:28 +000097declare_cpu_ops aem_generic, BASE_AEM_MIDR, CPU_NO_RESET_FUNC, \
98 aem_generic_core_pwr_dwn, \
99 aem_generic_cluster_pwr_dwn
Soby Mathewc704cbc2014-08-14 11:33:56 +0100100
Soby Mathew8e2f2872014-08-14 12:49:05 +0100101/* cpu_ops for Foundation FVP */
Jeenu Viswambharanee5eb802016-11-18 12:58:28 +0000102declare_cpu_ops aem_generic, FOUNDATION_AEM_MIDR, CPU_NO_RESET_FUNC, \
103 aem_generic_core_pwr_dwn, \
104 aem_generic_cluster_pwr_dwn