blob: d47279a764d80ced1f9661e376b4b207311c83f6 [file] [log] [blame]
Achin Gupta4f6ad662013-10-25 09:08:21 +01001/*
Govindraj Rajaeee28e72023-08-01 15:52:40 -05002 * Copyright (c) 2014-2019, 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 Mathew0980dce2018-09-17 04:34:35 +010077#if REPORT_ERRATA
78/*
79 * Errata printing function for AEM. Must follow AAPCS.
80 */
81func aem_generic_errata_report
82 ret
83endfunc aem_generic_errata_report
84#endif
85
Soby Mathew38b4bc92014-08-14 13:36:41 +010086 /* ---------------------------------------------
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 Mathewe364a8a2015-04-13 16:57:12 +010095.section .rodata.aem_generic_regs, "aS"
96aem_generic_regs: /* The ascii list of register names to be reported */
97 .asciz "" /* no registers to report */
98
Soby Mathew38b4bc92014-08-14 13:36:41 +010099func aem_generic_cpu_reg_dump
Soby Mathewe364a8a2015-04-13 16:57:12 +0100100 adr x6, aem_generic_regs
Soby Mathew38b4bc92014-08-14 13:36:41 +0100101 ret
Kévin Petita877c252015-03-24 14:03:57 +0000102endfunc aem_generic_cpu_reg_dump
Soby Mathew38b4bc92014-08-14 13:36:41 +0100103
Soby Mathew8e2f2872014-08-14 12:49:05 +0100104
105/* cpu_ops for Base AEM FVP */
Jeenu Viswambharanee5eb802016-11-18 12:58:28 +0000106declare_cpu_ops aem_generic, BASE_AEM_MIDR, CPU_NO_RESET_FUNC, \
107 aem_generic_core_pwr_dwn, \
108 aem_generic_cluster_pwr_dwn
Soby Mathewc704cbc2014-08-14 11:33:56 +0100109
Soby Mathew8e2f2872014-08-14 12:49:05 +0100110/* cpu_ops for Foundation FVP */
Jeenu Viswambharanee5eb802016-11-18 12:58:28 +0000111declare_cpu_ops aem_generic, FOUNDATION_AEM_MIDR, CPU_NO_RESET_FUNC, \
112 aem_generic_core_pwr_dwn, \
113 aem_generic_cluster_pwr_dwn