xref: /rk3399_ARM-atf/lib/cpus/aarch64/generic.S (revision af61b50c1077b6d936c8ed741c1d0b8e43eb2b19)
1/*
2 * Copyright (c) 2020-2025, Arm Limited. All rights reserved.
3 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
7#include <arch.h>
8#include <asm_macros.S>
9#include <common/bl_common.h>
10#include <generic.h>
11#include <cpu_macros.S>
12#include <plat_macros.S>
13
14cpu_reset_prologue generic
15
16	/* ---------------------------------------------
17	 * Disable L1 data cache and unified L2 cache
18	 * ---------------------------------------------
19	 */
20func generic_disable_dcache
21	mrs	x1, sctlr_el3
22	bic	x1, x1, #SCTLR_C_BIT
23	msr	sctlr_el3, x1
24	isb
25	ret
26endfunc generic_disable_dcache
27
28func generic_core_pwr_dwn
29	mov	x18, x30
30
31	/* ---------------------------------------------
32	 * Turn off caches.
33	 * ---------------------------------------------
34	 */
35	bl	generic_disable_dcache
36
37	/* ---------------------------------------------
38	 * Flush L1 caches.
39	 * ---------------------------------------------
40	 */
41	mov	x0, #DCCISW
42	bl	dcsw_op_level1
43
44	ret	x18
45endfunc generic_core_pwr_dwn
46
47func generic_cluster_pwr_dwn
48	mov	x18, x30
49
50	/* ---------------------------------------------
51	 * Turn off caches.
52	 * ---------------------------------------------
53	 */
54	bl	generic_disable_dcache
55
56	/* ---------------------------------------------
57	 * Flush L1 caches.
58	 * ---------------------------------------------
59	 */
60	mov	x0, #DCCISW
61	bl	dcsw_op_level1
62
63	/* ---------------------------------------------
64	 * Disable the optional ACP.
65	 * ---------------------------------------------
66	 */
67	bl	plat_disable_acp
68
69	/* ---------------------------------------------
70	 * Flush L2 caches.
71	 * ---------------------------------------------
72	 */
73	mov	x0, #DCCISW
74	bl	dcsw_op_level2
75
76	ret	x18
77
78endfunc generic_cluster_pwr_dwn
79
80/* ---------------------------------------------
81 * Unimplemented functions.
82 * ---------------------------------------------
83 */
84.equ	generic_cpu_reg_dump,		0
85
86cpu_reset_func_start generic
87cpu_reset_func_end generic
88
89declare_cpu_ops generic, AARCH64_GENERIC_MIDR, \
90	generic_reset_func, \
91	generic_core_pwr_dwn, \
92	generic_cluster_pwr_dwn
93