xref: /rk3399_ARM-atf/plat/renesas/rcar_gen4/include/rcar_private.h (revision 70d37dec8366aa8f88df91e568d8250e4089b214)
1 /*
2  * Copyright (c) 2015-2025, Renesas Electronics Corporation. All rights reserved.
3  *
4  * SPDX-License-Identifier: BSD-3-Clause
5  */
6 
7 #ifndef RCAR_PRIVATE_H
8 #define RCAR_PRIVATE_H
9 
10 #include <common/bl_common.h>
11 #include <lib/bakery_lock.h>
12 #include <lib/el3_runtime/cpu_data.h>
13 #include <lib/mmio.h>
14 
15 #include <platform_def.h>
16 
17 /*
18  * This structure represents the superset of information that is passed to
19  * BL31 e.g. while passing control to it from BL2 which is bl31_params
20  * and bl31_plat_params and its elements
21  */
22 typedef struct bl2_to_bl31_params_mem {
23 	image_info_t bl32_image_info;
24 	image_info_t bl33_image_info;
25 	entry_point_info_t bl33_ep_info;
26 	entry_point_info_t bl32_ep_info;
27 } bl2_to_bl31_params_mem_t;
28 
29 #define RCAR_INSTANTIATE_LOCK	DEFINE_BAKERY_LOCK(rcar_lock)
30 /*
31  * Constants to specify how many bakery locks this platform implements. These
32  * are used if the platform chooses not to use coherent memory for bakery lock
33  * data structures.
34  */
35 #define RCAR_MAX_BAKERIES	2
36 
37 /*
38  * Definition of structure which holds platform specific per-cpu data. Currently
39  * it holds only the bakery lock information for each cpu. Constants to
40  * specify how many bakeries this platform implements and bakery ids are
41  * specified in rcar_def.h
42  */
43 typedef struct rcar_cpu_data {
44 	bakery_info_t pcpu_bakery_info[RCAR_MAX_BAKERIES];
45 } rcar_cpu_data_t;
46 
47 /*
48  * Helper macros for bakery lock api when using the above rcar_cpu_data_t for
49  * bakery lock data structures. It assumes that the bakery_info is at the
50  * beginning of the platform specific per-cpu data.
51  */
52 #define rcar_lock_init()	bakery_lock_init(&rcar_lock)
53 #define rcar_lock_get()		bakery_lock_get(&rcar_lock)
54 #define rcar_lock_release()	bakery_lock_release(&rcar_lock)
55 
56 /*
57  * Ensure that the size of the RCAR specific per-cpu data structure and the size
58  * of the memory allocated in generic per-cpu data for the platform are the same
59  */
60 CASSERT(sizeof(rcar_cpu_data_t) == PLAT_PCPU_DATA_SIZE,
61 	rcar_pcpu_data_size_mismatch);
62 
63 /*
64  * Function and variable prototypes
65  */
66 void rcar_configure_mmu_el3(uintptr_t total_base,
67 			    size_t total_size,
68 			    uintptr_t ro_start,
69 			    uintptr_t ro_limit
70 			    );
71 
72 
73 void plat_invalidate_icache(void);
74 
75 void rcar_console_boot_init(void);
76 void rcar_console_runtime_init(void);
77 
78 int32_t rcar_cluster_pos_by_mpidr(u_register_t mpidr);
79 
80 #endif /* RCAR_PRIVATE_H */
81