xref: /rk3399_ARM-atf/plat/arm/board/juno/juno_security.c (revision 85135283f380ed377a33d89f77a3f41fce43b29d)
1*85135283SDan Handley /*
2*85135283SDan Handley  * Copyright (c) 2014-2015, ARM Limited and Contributors. All rights reserved.
3*85135283SDan Handley  *
4*85135283SDan Handley  * Redistribution and use in source and binary forms, with or without
5*85135283SDan Handley  * modification, are permitted provided that the following conditions are met:
6*85135283SDan Handley  *
7*85135283SDan Handley  * Redistributions of source code must retain the above copyright notice, this
8*85135283SDan Handley  * list of conditions and the following disclaimer.
9*85135283SDan Handley  *
10*85135283SDan Handley  * Redistributions in binary form must reproduce the above copyright notice,
11*85135283SDan Handley  * this list of conditions and the following disclaimer in the documentation
12*85135283SDan Handley  * and/or other materials provided with the distribution.
13*85135283SDan Handley  *
14*85135283SDan Handley  * Neither the name of ARM nor the names of its contributors may be used
15*85135283SDan Handley  * to endorse or promote products derived from this software without specific
16*85135283SDan Handley  * prior written permission.
17*85135283SDan Handley  *
18*85135283SDan Handley  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19*85135283SDan Handley  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20*85135283SDan Handley  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21*85135283SDan Handley  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
22*85135283SDan Handley  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23*85135283SDan Handley  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24*85135283SDan Handley  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25*85135283SDan Handley  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26*85135283SDan Handley  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27*85135283SDan Handley  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28*85135283SDan Handley  * POSSIBILITY OF SUCH DAMAGE.
29*85135283SDan Handley  */
30*85135283SDan Handley 
31*85135283SDan Handley #include <mmio.h>
32*85135283SDan Handley #include <plat_arm.h>
33*85135283SDan Handley #include <soc_css.h>
34*85135283SDan Handley #include "juno_def.h"
35*85135283SDan Handley 
36*85135283SDan Handley 
37*85135283SDan Handley /*******************************************************************************
38*85135283SDan Handley  * Set up the MMU-401 SSD tables. The power-on configuration has all stream IDs
39*85135283SDan Handley  * assigned to Non-Secure except some for the DMA-330. Assign those back to the
40*85135283SDan Handley  * Non-Secure world as well, otherwise EL1 may end up erroneously generating
41*85135283SDan Handley  * (untranslated) Secure transactions if it turns the SMMU on.
42*85135283SDan Handley  ******************************************************************************/
43*85135283SDan Handley static void init_mmu401(void)
44*85135283SDan Handley {
45*85135283SDan Handley 	uint32_t reg = mmio_read_32(MMU401_DMA330_BASE + MMU401_SSD_OFFSET);
46*85135283SDan Handley 	reg |= 0x1FF;
47*85135283SDan Handley 	mmio_write_32(MMU401_DMA330_BASE + MMU401_SSD_OFFSET, reg);
48*85135283SDan Handley }
49*85135283SDan Handley 
50*85135283SDan Handley /*******************************************************************************
51*85135283SDan Handley  * Initialize the secure environment.
52*85135283SDan Handley  ******************************************************************************/
53*85135283SDan Handley void plat_arm_security_setup(void)
54*85135283SDan Handley {
55*85135283SDan Handley 	/* Initialize the TrustZone Controller */
56*85135283SDan Handley 	arm_tzc_setup();
57*85135283SDan Handley 	/* Do ARM CSS SoC security setup */
58*85135283SDan Handley 	soc_css_security_setup();
59*85135283SDan Handley 	/* Initialize the SMMU SSD tables*/
60*85135283SDan Handley 	init_mmu401();
61*85135283SDan Handley }
62