1 /*
2  * Copyright (c) 2022, Arm Limited. All rights reserved.
3  *
4  * SPDX-License-Identifier: BSD-3-Clause
5  */
6 
7 #include <stdbool.h>
8 #include <stddef.h>
9 
10 #include <drivers/arm/smmu_v3.h>
11 #include <lib/utils_def.h>
12 #include <plat/arm/common/arm_config.h>
13 #include <plat/common/platform.h>
14 
15 #include <platform_def.h>
16 
17 /**
18  * Array mentioning number of SMMUs supported by FVP
19  */
20 static const uintptr_t fvp_smmus[] = {
21 	PLAT_FVP_SMMUV3_BASE,
22 };
23 
plat_has_non_host_platforms(void)24 bool plat_has_non_host_platforms(void)
25 {
26 	/* FVP base platforms typically have GPU, as per FVP Reference guide */
27 	return true;
28 }
29 
plat_has_unmanaged_dma_peripherals(void)30 bool plat_has_unmanaged_dma_peripherals(void)
31 {
32 	/*
33 	 * FVP Reference guide does not show devices that are described as
34 	 * DMA-capable but not managed by an SMMU in the FVP documentation.
35 	 * However, the SMMU seems to have only been introduced in the RevC
36 	 * revision.
37 	 */
38 	return (arm_config.flags & ARM_CONFIG_FVP_HAS_SMMUV3) == 0;
39 }
40 
plat_get_total_smmus(void)41 unsigned int plat_get_total_smmus(void)
42 {
43 	if ((arm_config.flags & ARM_CONFIG_FVP_HAS_SMMUV3) != 0U) {
44 		return ARRAY_SIZE(fvp_smmus);
45 	} else {
46 		return 0;
47 	}
48 }
49 
plat_enumerate_smmus(const uintptr_t ** smmus_out,size_t * smmu_count_out)50 void plat_enumerate_smmus(const uintptr_t **smmus_out,
51 			  size_t *smmu_count_out)
52 {
53 	if ((arm_config.flags & ARM_CONFIG_FVP_HAS_SMMUV3) != 0U) {
54 		*smmus_out = fvp_smmus;
55 		*smmu_count_out = ARRAY_SIZE(fvp_smmus);
56 	} else {
57 		*smmus_out = NULL;
58 		*smmu_count_out = 0;
59 	}
60 }
61 
62 /* DRTM DMA Protection Features */
63 static const plat_drtm_dma_prot_features_t dma_prot_features = {
64 	.max_num_mem_prot_regions = 0, /* No protection regions are present */
65 	.dma_protection_support = 0x1 /* Complete DMA protection only */
66 };
67 
plat_drtm_get_dma_prot_features(void)68 const plat_drtm_dma_prot_features_t *plat_drtm_get_dma_prot_features(void)
69 {
70 	return &dma_prot_features;
71 }
72 
plat_drtm_dma_prot_get_max_table_bytes(void)73 uint64_t plat_drtm_dma_prot_get_max_table_bytes(void)
74 {
75 	return 0U;
76 }
77