xref: /rk3399_ARM-atf/plat/renesas/rcar_gen4/include/rcar_private.h (revision 63900851d7d6009950b2fdb53e9456cc0a0bc025)
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 /* lock for SCMI */
64 #define RCAR_SCMI_INSTANTIATE_LOCK	spinlock_t rcar_scmi_lock
65 #define RCAR_SCMI_LOCK_GET_INSTANCE	(&rcar_scmi_lock)
66 
67 /*
68  * Function and variable prototypes
69  */
70 void rcar_configure_mmu_el3(uintptr_t total_base,
71 			    size_t total_size,
72 			    uintptr_t ro_start,
73 			    uintptr_t ro_limit
74 			    );
75 
76 
77 void plat_invalidate_icache(void);
78 
79 void rcar_console_boot_init(void);
80 void rcar_console_runtime_init(void);
81 
82 #if (SET_SCMI_PARAM == 1)
83 void __init plat_rcar_scmi_setup(void);
84 void rcar_scmi_sys_shutdown(void);
85 void rcar_scmi_sys_reboot(void);
86 void rcar_scmi_sys_suspend(void);
87 const plat_psci_ops_t *plat_rcar_psci_override_pm_ops(plat_psci_ops_t *ops);
88 #else
89 static inline void plat_rcar_scmi_setup(void) { }
90 
91 static inline void rcar_scmi_sys_shutdown(void) { }
92 
93 static inline void rcar_scmi_sys_reboot(void)
94 {
95 	mmio_write_32(RCAR_SRESCR, 0x5AA50000U | BIT(15));
96 }
97 
98 static inline void rcar_scmi_sys_suspend(void)
99 {
100 	while true;
101 }
102 
103 static inline const plat_psci_ops_t *plat_rcar_psci_override_pm_ops(plat_psci_ops_t *ops)
104 {
105 	return ops;
106 }
107 #endif /* SET_SCMI_PARAM == 1 */
108 
109 int32_t rcar_cluster_pos_by_mpidr(u_register_t mpidr);
110 
111 #endif /* RCAR_PRIVATE_H */
112