blob: 9002da65bc82a74f409c8044d8444644e15c2bd2 [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
Soby Mathewadd40352014-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
Soby Mathew9b476842014-08-14 11:33:56 +010020
Soby Mathewadd40352014-08-14 12:49:05 +010021 /* ---------------------------------------------
Alexei Fedorovef430ff2019-07-29 17:22:53 +010022 * 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.
Soby Mathewadd40352014-08-14 12:49:05 +010025 * ---------------------------------------------
26 */
Alexei Fedorovef430ff2019-07-29 17:22:53 +010027 mrs x1, clidr_el1
Achin Gupta4f6ad662013-10-25 09:08:21 +010028
Alexei Fedorovef430ff2019-07-29 17:22:53 +010029 /* ---------------------------------------------
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 */
39 mov x0, #DCCISW
40 b.eq dcsw_op_level1
41
42 mov x18, x30
43
44 /* ---------------------------------------------
45 * Flush L1 cache to L2.
46 * ---------------------------------------------
47 */
48 bl dcsw_op_level1
49 mov x30, x18
50
51 /* ---------------------------------------------
52 * Flush L2 cache to L3.
53 * ---------------------------------------------
54 */
55 mov x0, #DCCISW
56 b dcsw_op_level2
57endfunc aem_generic_core_pwr_dwn
Achin Gupta4f6ad662013-10-25 09:08:21 +010058
Soby Mathewadd40352014-08-14 12:49:05 +010059func 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 Fedorovef430ff2019-07-29 17:22:53 +010070 * Flush all caches to PoC.
Soby Mathewadd40352014-08-14 12:49:05 +010071 * ---------------------------------------------
72 */
73 mov x0, #DCCISW
74 b dcsw_op_all
Kévin Petit8b779622015-03-24 14:03:57 +000075endfunc aem_generic_cluster_pwr_dwn
Soby Mathewadd40352014-08-14 12:49:05 +010076
Boyan Karatotev0d020822024-11-19 11:27:01 +000077cpu_reset_func_start aem_generic
78cpu_reset_func_end aem_generic
79
Soby Mathewd3f70af2014-08-14 13:36:41 +010080 /* ---------------------------------------------
81 * This function provides cpu specific
82 * register information for crash reporting.
83 * It needs to return with x6 pointing to
84 * a list of register names in ascii and
85 * x8 - x15 having values of registers to be
86 * reported.
87 * ---------------------------------------------
88 */
Soby Mathew6fa11a52015-04-13 16:57:12 +010089.section .rodata.aem_generic_regs, "aS"
90aem_generic_regs: /* The ascii list of register names to be reported */
91 .asciz "" /* no registers to report */
92
Soby Mathewd3f70af2014-08-14 13:36:41 +010093func aem_generic_cpu_reg_dump
Soby Mathew6fa11a52015-04-13 16:57:12 +010094 adr x6, aem_generic_regs
Soby Mathewd3f70af2014-08-14 13:36:41 +010095 ret
Kévin Petit8b779622015-03-24 14:03:57 +000096endfunc aem_generic_cpu_reg_dump
Soby Mathewd3f70af2014-08-14 13:36:41 +010097
Soby Mathewadd40352014-08-14 12:49:05 +010098
99/* cpu_ops for Base AEM FVP */
Boyan Karatotev0d020822024-11-19 11:27:01 +0000100declare_cpu_ops aem_generic, BASE_AEM_MIDR, aem_generic_reset_func, \
Jeenu Viswambharan5dd9dbb2016-11-18 12:58:28 +0000101 aem_generic_core_pwr_dwn, \
102 aem_generic_cluster_pwr_dwn
Soby Mathew9b476842014-08-14 11:33:56 +0100103
Soby Mathewadd40352014-08-14 12:49:05 +0100104/* cpu_ops for Foundation FVP */
Boyan Karatotev0d020822024-11-19 11:27:01 +0000105declare_cpu_ops aem_generic, FOUNDATION_AEM_MIDR, aem_generic_reset_func, \
Jeenu Viswambharan5dd9dbb2016-11-18 12:58:28 +0000106 aem_generic_core_pwr_dwn, \
107 aem_generic_cluster_pwr_dwn