1 /*
2  * Copyright (c) 2017-2020, ARM Limited and Contributors. All rights reserved.
3  *
4  * SPDX-License-Identifier: BSD-3-Clause
5  */
6 
7 /* SDEI configuration for ARM platforms */
8 
9 #include <bl31/ehf.h>
10 #include <common/debug.h>
11 #include <services/sdei.h>
12 
13 #if SDEI_IN_FCONF
14 #include <plat/arm/common/fconf_sdei_getter.h>
15 #endif
16 #include <plat/common/platform.h>
17 #include <platform_def.h>
18 
19 
20 #if SDEI_IN_FCONF
21 /* Private event mappings */
22 static sdei_ev_map_t arm_sdei_private[PLAT_SDEI_DP_EVENT_MAX_CNT + 1] = { 0 };
23 
24 /* Shared event mappings */
25 static sdei_ev_map_t arm_sdei_shared[PLAT_SDEI_DS_EVENT_MAX_CNT] = { 0 };
26 
plat_sdei_setup(void)27 void plat_sdei_setup(void)
28 {
29 	uint32_t i;
30 
31 	arm_sdei_private[0] = (sdei_ev_map_t)SDEI_DEFINE_EVENT_0(ARM_SDEI_SGI);
32 
33 	for (i = 0; i < FCONF_GET_PROPERTY(sdei, dyn_config, private_ev_cnt); i++) {
34 		arm_sdei_private[i + 1] = (sdei_ev_map_t)SDEI_PRIVATE_EVENT(
35 			FCONF_GET_PROPERTY(sdei, dyn_config, private_ev_nums[i]),
36 			FCONF_GET_PROPERTY(sdei, dyn_config, private_ev_intrs[i]),
37 			FCONF_GET_PROPERTY(sdei, dyn_config, private_ev_flags[i]));
38 	}
39 
40 	for (i = 0; i < FCONF_GET_PROPERTY(sdei, dyn_config, shared_ev_cnt); i++) {
41 		arm_sdei_shared[i] = (sdei_ev_map_t)SDEI_SHARED_EVENT( \
42 			FCONF_GET_PROPERTY(sdei, dyn_config, shared_ev_nums[i]),
43 			FCONF_GET_PROPERTY(sdei, dyn_config, shared_ev_intrs[i]),
44 			FCONF_GET_PROPERTY(sdei, dyn_config, shared_ev_flags[i]));
45 	}
46 	INFO("FCONF: SDEI platform setup\n");
47 }
48 #else
49 /* Private event mappings */
50 static sdei_ev_map_t arm_sdei_private[] = {
51 	PLAT_ARM_PRIVATE_SDEI_EVENTS
52 };
53 
54 /* Shared event mappings */
55 static sdei_ev_map_t arm_sdei_shared[] = {
56 	PLAT_ARM_SHARED_SDEI_EVENTS
57 };
58 
plat_sdei_setup(void)59 void plat_sdei_setup(void)
60 {
61 	INFO("SDEI platform setup\n");
62 }
63 #endif /* SDEI_IN_FCONF */
64 
65 /* Export ARM SDEI events */
66 REGISTER_SDEI_MAP(arm_sdei_private, arm_sdei_shared);
67