185135283SDan Handley /* 285135283SDan Handley * Copyright (c) 2014-2015, ARM Limited and Contributors. All rights reserved. 385135283SDan Handley * 485135283SDan Handley * Redistribution and use in source and binary forms, with or without 585135283SDan Handley * modification, are permitted provided that the following conditions are met: 685135283SDan Handley * 785135283SDan Handley * Redistributions of source code must retain the above copyright notice, this 885135283SDan Handley * list of conditions and the following disclaimer. 985135283SDan Handley * 1085135283SDan Handley * Redistributions in binary form must reproduce the above copyright notice, 1185135283SDan Handley * this list of conditions and the following disclaimer in the documentation 1285135283SDan Handley * and/or other materials provided with the distribution. 1385135283SDan Handley * 1485135283SDan Handley * Neither the name of ARM nor the names of its contributors may be used 1585135283SDan Handley * to endorse or promote products derived from this software without specific 1685135283SDan Handley * prior written permission. 1785135283SDan Handley * 1885135283SDan Handley * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 1985135283SDan Handley * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 2085135283SDan Handley * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 2185135283SDan Handley * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 2285135283SDan Handley * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 2385135283SDan Handley * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 2485135283SDan Handley * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 2585135283SDan Handley * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 2685135283SDan Handley * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 2785135283SDan Handley * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 2885135283SDan Handley * POSSIBILITY OF SUCH DAMAGE. 2985135283SDan Handley */ 3085135283SDan Handley 3185135283SDan Handley #include <mmio.h> 32883852caSVikram Kanigiri #include <nic_400.h> 3385135283SDan Handley #include <plat_arm.h> 3485135283SDan Handley #include <soc_css.h> 3585135283SDan Handley #include "juno_def.h" 3685135283SDan Handley 3785135283SDan Handley 3885135283SDan Handley /******************************************************************************* 3985135283SDan Handley * Set up the MMU-401 SSD tables. The power-on configuration has all stream IDs 4085135283SDan Handley * assigned to Non-Secure except some for the DMA-330. Assign those back to the 4185135283SDan Handley * Non-Secure world as well, otherwise EL1 may end up erroneously generating 4285135283SDan Handley * (untranslated) Secure transactions if it turns the SMMU on. 4385135283SDan Handley ******************************************************************************/ 4485135283SDan Handley static void init_mmu401(void) 4585135283SDan Handley { 4685135283SDan Handley uint32_t reg = mmio_read_32(MMU401_DMA330_BASE + MMU401_SSD_OFFSET); 4785135283SDan Handley reg |= 0x1FF; 4885135283SDan Handley mmio_write_32(MMU401_DMA330_BASE + MMU401_SSD_OFFSET, reg); 4985135283SDan Handley } 5085135283SDan Handley 5185135283SDan Handley /******************************************************************************* 52883852caSVikram Kanigiri * Program CSS-NIC400 to allow non-secure access to some CSS regions. 53883852caSVikram Kanigiri ******************************************************************************/ 54883852caSVikram Kanigiri static void css_init_nic400(void) 55883852caSVikram Kanigiri { 56883852caSVikram Kanigiri /* Note: This is the NIC-400 device on the CSS */ 57883852caSVikram Kanigiri mmio_write_32(PLAT_SOC_CSS_NIC400_BASE + 58883852caSVikram Kanigiri NIC400_ADDR_CTRL_SECURITY_REG(CSS_NIC400_SLAVE_BOOTSECURE), 59883852caSVikram Kanigiri ~0); 60883852caSVikram Kanigiri } 61883852caSVikram Kanigiri 62883852caSVikram Kanigiri /******************************************************************************* 63*09fad498Sdp-arm * Initialize debug configuration. 64*09fad498Sdp-arm ******************************************************************************/ 65*09fad498Sdp-arm static void init_debug_cfg(void) 66*09fad498Sdp-arm { 67*09fad498Sdp-arm #if !DEBUG 68*09fad498Sdp-arm /* Set internal drive selection for SPIDEN. */ 69*09fad498Sdp-arm mmio_write_32(SSC_REG_BASE + SSC_DBGCFG_SET, 70*09fad498Sdp-arm 1U << SPIDEN_SEL_SET_SHIFT); 71*09fad498Sdp-arm 72*09fad498Sdp-arm /* Drive SPIDEN LOW to disable invasive debug of secure state. */ 73*09fad498Sdp-arm mmio_write_32(SSC_REG_BASE + SSC_DBGCFG_CLR, 74*09fad498Sdp-arm 1U << SPIDEN_INT_CLR_SHIFT); 75*09fad498Sdp-arm #endif 76*09fad498Sdp-arm } 77*09fad498Sdp-arm 78*09fad498Sdp-arm /******************************************************************************* 7985135283SDan Handley * Initialize the secure environment. 8085135283SDan Handley ******************************************************************************/ 8185135283SDan Handley void plat_arm_security_setup(void) 8285135283SDan Handley { 83*09fad498Sdp-arm /* Initialize debug configuration */ 84*09fad498Sdp-arm init_debug_cfg(); 8585135283SDan Handley /* Initialize the TrustZone Controller */ 8657f78201SSoby Mathew arm_tzc400_setup(); 87883852caSVikram Kanigiri /* Do ARM CSS internal NIC setup */ 88883852caSVikram Kanigiri css_init_nic400(); 8985135283SDan Handley /* Do ARM CSS SoC security setup */ 9085135283SDan Handley soc_css_security_setup(); 9185135283SDan Handley /* Initialize the SMMU SSD tables */ 9285135283SDan Handley init_mmu401(); 9385135283SDan Handley } 94