xref: /optee_os/core/arch/arm/plat-rockchip/platform.c (revision 5b25c76ac40f830867e3d60800120ffd7874e8dc)
1 // SPDX-License-Identifier: BSD-2-Clause
2 /*
3  * Copyright (C) 2017, Fuzhou Rockchip Electronics Co., Ltd.
4  */
5 
6 #include <initcall.h>
7 #include <io.h>
8 #include <mm/core_memprot.h>
9 #include <platform.h>
10 #include <platform_config.h>
11 #include <stdint.h>
12 
13 int __weak platform_secure_init(void)
14 {
15 	return 0;
16 }
17 
18 int __weak platform_secure_ddr_region(int rgn, paddr_t st, size_t sz)
19 {
20 	MSG("Not protecting region %d: 0x%lx-0x%lx\n", rgn, st, st + sz);
21 
22 	return 0;
23 }
24 
25 static TEE_Result platform_init(void)
26 {
27 	int ret = 0;
28 
29 	platform_secure_init();
30 
31 	/*
32 	 * Rockchip SoCs can protect multiple memory regions (mostly 8).
33 	 * Region 0 is assigned for Trusted-Firmware memory, so use
34 	 * regions 1 for OP-TEE memory, which leaves on all known SoCs
35 	 * at least 6 more regions available for other purposes.
36 	 */
37 	ret = platform_secure_ddr_region(1, CFG_TZDRAM_START, CFG_TZDRAM_SIZE);
38 	if (ret < 0)
39 		return TEE_ERROR_GENERIC;
40 
41 	return TEE_SUCCESS;
42 }
43 
44 service_init(platform_init);
45