xref: /openbmc/u-boot/arch/arm/mach-exynos/tzpc.c (revision 23ff8633)
1 /*
2  * Lowlevel setup for SMDK5250 board based on S5PC520
3  *
4  * Copyright (C) 2012 Samsung Electronics
5  *
6  * SPDX-License-Identifier:	GPL-2.0+
7  */
8 
9 #include <common.h>
10 #include <asm/arch/tzpc.h>
11 #include <asm/io.h>
12 
13 /* Setting TZPC[TrustZone Protection Controller] */
14 void tzpc_init(void)
15 {
16 	struct exynos_tzpc *tzpc;
17 	unsigned int addr, start = 0, end = 0;
18 
19 	start = samsung_get_base_tzpc();
20 
21 	if (cpu_is_exynos5())
22 		end = start + ((EXYNOS5_NR_TZPC_BANKS - 1) * TZPC_BASE_OFFSET);
23 	else if (cpu_is_exynos4())
24 		end = start + ((EXYNOS4_NR_TZPC_BANKS - 1) * TZPC_BASE_OFFSET);
25 
26 	for (addr = start; addr <= end; addr += TZPC_BASE_OFFSET) {
27 		tzpc = (struct exynos_tzpc *)addr;
28 
29 		if (addr == start)
30 			writel(R0SIZE, &tzpc->r0size);
31 
32 		writel(DECPROTXSET, &tzpc->decprot0set);
33 		writel(DECPROTXSET, &tzpc->decprot1set);
34 
35 		if (cpu_is_exynos5() && (addr == end))
36 			break;
37 
38 		writel(DECPROTXSET, &tzpc->decprot2set);
39 		writel(DECPROTXSET, &tzpc->decprot3set);
40 	}
41 }
42