blob: 9843943f570a17d77345746e880ae1b2289b456e [file] [log] [blame]
Achin Gupta4f6ad662013-10-25 09:08:21 +01001/*
Boyan Karatotev0d020822024-11-19 11:27:01 +00002 * Copyright (c) 2014-2025, Arm Limited and Contributors. All rights reserved.
Achin Gupta4f6ad662013-10-25 09:08:21 +01003 *
dp-arm82cb2c12017-05-03 09:38:09 +01004 * SPDX-License-Identifier: BSD-3-Clause
Achin Gupta4f6ad662013-10-25 09:08:21 +01005 */
Soby Mathewadd40352014-08-14 12:49:05 +01006#include <aem_generic.h>
Achin Gupta4f6ad662013-10-25 09:08:21 +01007#include <arch.h>
Andrew Thoelke0a30cf52014-03-18 13:46:55 +00008#include <asm_macros.S>
Soby Mathew9b476842014-08-14 11:33:56 +01009#include <cpu_macros.S>
Achin Gupta4f6ad662013-10-25 09:08:21 +010010
Boyan Karatotev89dba822025-01-22 13:54:43 +000011cpu_reset_prologue aem_generic
12
Soby Mathewadd40352014-08-14 12:49:05 +010013func 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 Mathew9b476842014-08-14 11:33:56 +010022
Soby Mathewadd40352014-08-14 12:49:05 +010023 /* ---------------------------------------------
Alexei Fedorovef430ff2019-07-29 17:22:53 +010024 * 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 Mathewadd40352014-08-14 12:49:05 +010027 * ---------------------------------------------
28 */
Alexei Fedorovef430ff2019-07-29 17:22:53 +010029 mrs x1, clidr_el1
Achin Gupta4f6ad662013-10-25 09:08:21 +010030
Alexei Fedorovef430ff2019-07-29 17:22:53 +010031 /* ---------------------------------------------
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
59endfunc aem_generic_core_pwr_dwn
Achin Gupta4f6ad662013-10-25 09:08:21 +010060
Soby Mathewadd40352014-08-14 12:49:05 +010061func 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 Fedorovef430ff2019-07-29 17:22:53 +010072 * Flush all caches to PoC.
Soby Mathewadd40352014-08-14 12:49:05 +010073 * ---------------------------------------------
74 */
75 mov x0, #DCCISW
76 b dcsw_op_all
Kévin Petit8b779622015-03-24 14:03:57 +000077endfunc aem_generic_cluster_pwr_dwn
Soby Mathewadd40352014-08-14 12:49:05 +010078
Boyan Karatotev0d020822024-11-19 11:27:01 +000079cpu_reset_func_start aem_generic
80cpu_reset_func_end aem_generic
81
Soby Mathewd3f70af2014-08-14 13:36:41 +010082 /* ---------------------------------------------
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 Mathew6fa11a52015-04-13 16:57:12 +010091.section .rodata.aem_generic_regs, "aS"
92aem_generic_regs: /* The ascii list of register names to be reported */
93 .asciz "" /* no registers to report */
94
Soby Mathewd3f70af2014-08-14 13:36:41 +010095func aem_generic_cpu_reg_dump
Soby Mathew6fa11a52015-04-13 16:57:12 +010096 adr x6, aem_generic_regs
Soby Mathewd3f70af2014-08-14 13:36:41 +010097 ret
Kévin Petit8b779622015-03-24 14:03:57 +000098endfunc aem_generic_cpu_reg_dump
Soby Mathewd3f70af2014-08-14 13:36:41 +010099
Soby Mathewadd40352014-08-14 12:49:05 +0100100
101/* cpu_ops for Base AEM FVP */
Boyan Karatotev0d020822024-11-19 11:27:01 +0000102declare_cpu_ops aem_generic, BASE_AEM_MIDR, aem_generic_reset_func, \
Jeenu Viswambharan5dd9dbb2016-11-18 12:58:28 +0000103 aem_generic_core_pwr_dwn, \
104 aem_generic_cluster_pwr_dwn
Soby Mathew9b476842014-08-14 11:33:56 +0100105
Soby Mathewadd40352014-08-14 12:49:05 +0100106/* cpu_ops for Foundation FVP */
Boyan Karatotev0d020822024-11-19 11:27:01 +0000107declare_cpu_ops aem_generic, FOUNDATION_AEM_MIDR, aem_generic_reset_func, \
Jeenu Viswambharan5dd9dbb2016-11-18 12:58:28 +0000108 aem_generic_core_pwr_dwn, \
109 aem_generic_cluster_pwr_dwn