Juan Castillo | 6b672f5 | 2014-09-04 14:43:09 +0100 | [diff] [blame] | 1 | /* |
Dan Handley | 7bef800 | 2015-03-19 19:22:44 +0000 | [diff] [blame] | 2 | * Copyright (c) 2014-2015, ARM Limited and Contributors. All rights reserved. |
Juan Castillo | 6b672f5 | 2014-09-04 14:43:09 +0100 | [diff] [blame] | 3 | * |
dp-arm | fa3cf0b | 2017-05-03 09:38:09 +0100 | [diff] [blame] | 4 | * SPDX-License-Identifier: BSD-3-Clause |
Juan Castillo | 6b672f5 | 2014-09-04 14:43:09 +0100 | [diff] [blame] | 5 | */ |
| 6 | |
Robin Murphy | 0f1d666 | 2015-01-09 14:30:58 +0000 | [diff] [blame] | 7 | #include <mmio.h> |
Vikram Kanigiri | af2bc5f | 2015-08-03 23:58:19 +0100 | [diff] [blame] | 8 | #include <nic_400.h> |
Dan Handley | 7bef800 | 2015-03-19 19:22:44 +0000 | [diff] [blame] | 9 | #include <plat_arm.h> |
| 10 | #include <soc_css.h> |
Juan Castillo | 6b672f5 | 2014-09-04 14:43:09 +0100 | [diff] [blame] | 11 | #include "juno_def.h" |
| 12 | |
Juan Castillo | 6b672f5 | 2014-09-04 14:43:09 +0100 | [diff] [blame] | 13 | |
| 14 | /******************************************************************************* |
Robin Murphy | 0f1d666 | 2015-01-09 14:30:58 +0000 | [diff] [blame] | 15 | * Set up the MMU-401 SSD tables. The power-on configuration has all stream IDs |
| 16 | * assigned to Non-Secure except some for the DMA-330. Assign those back to the |
| 17 | * Non-Secure world as well, otherwise EL1 may end up erroneously generating |
| 18 | * (untranslated) Secure transactions if it turns the SMMU on. |
| 19 | ******************************************************************************/ |
| 20 | static void init_mmu401(void) |
| 21 | { |
| 22 | uint32_t reg = mmio_read_32(MMU401_DMA330_BASE + MMU401_SSD_OFFSET); |
| 23 | reg |= 0x1FF; |
| 24 | mmio_write_32(MMU401_DMA330_BASE + MMU401_SSD_OFFSET, reg); |
| 25 | } |
| 26 | |
| 27 | /******************************************************************************* |
Vikram Kanigiri | af2bc5f | 2015-08-03 23:58:19 +0100 | [diff] [blame] | 28 | * Program CSS-NIC400 to allow non-secure access to some CSS regions. |
| 29 | ******************************************************************************/ |
| 30 | static void css_init_nic400(void) |
| 31 | { |
| 32 | /* Note: This is the NIC-400 device on the CSS */ |
| 33 | mmio_write_32(PLAT_SOC_CSS_NIC400_BASE + |
| 34 | NIC400_ADDR_CTRL_SECURITY_REG(CSS_NIC400_SLAVE_BOOTSECURE), |
| 35 | ~0); |
| 36 | } |
| 37 | |
| 38 | /******************************************************************************* |
dp-arm | b71946b | 2017-02-08 12:16:42 +0000 | [diff] [blame] | 39 | * Initialize debug configuration. |
| 40 | ******************************************************************************/ |
| 41 | static void init_debug_cfg(void) |
| 42 | { |
| 43 | #if !DEBUG |
| 44 | /* Set internal drive selection for SPIDEN. */ |
| 45 | mmio_write_32(SSC_REG_BASE + SSC_DBGCFG_SET, |
| 46 | 1U << SPIDEN_SEL_SET_SHIFT); |
| 47 | |
| 48 | /* Drive SPIDEN LOW to disable invasive debug of secure state. */ |
| 49 | mmio_write_32(SSC_REG_BASE + SSC_DBGCFG_CLR, |
| 50 | 1U << SPIDEN_INT_CLR_SHIFT); |
| 51 | #endif |
| 52 | } |
| 53 | |
| 54 | /******************************************************************************* |
Dan Handley | 7bef800 | 2015-03-19 19:22:44 +0000 | [diff] [blame] | 55 | * Initialize the secure environment. |
Juan Castillo | 6b672f5 | 2014-09-04 14:43:09 +0100 | [diff] [blame] | 56 | ******************************************************************************/ |
Dan Handley | 7bef800 | 2015-03-19 19:22:44 +0000 | [diff] [blame] | 57 | void plat_arm_security_setup(void) |
Juan Castillo | 6b672f5 | 2014-09-04 14:43:09 +0100 | [diff] [blame] | 58 | { |
dp-arm | b71946b | 2017-02-08 12:16:42 +0000 | [diff] [blame] | 59 | /* Initialize debug configuration */ |
| 60 | init_debug_cfg(); |
Juan Castillo | 6b672f5 | 2014-09-04 14:43:09 +0100 | [diff] [blame] | 61 | /* Initialize the TrustZone Controller */ |
Soby Mathew | 9c708b5 | 2016-02-26 14:23:19 +0000 | [diff] [blame] | 62 | arm_tzc400_setup(); |
Vikram Kanigiri | af2bc5f | 2015-08-03 23:58:19 +0100 | [diff] [blame] | 63 | /* Do ARM CSS internal NIC setup */ |
| 64 | css_init_nic400(); |
Dan Handley | 7bef800 | 2015-03-19 19:22:44 +0000 | [diff] [blame] | 65 | /* Do ARM CSS SoC security setup */ |
| 66 | soc_css_security_setup(); |
dp-arm | b71946b | 2017-02-08 12:16:42 +0000 | [diff] [blame] | 67 | /* Initialize the SMMU SSD tables */ |
Robin Murphy | 0f1d666 | 2015-01-09 14:30:58 +0000 | [diff] [blame] | 68 | init_mmu401(); |
Juan Castillo | 6b672f5 | 2014-09-04 14:43:09 +0100 | [diff] [blame] | 69 | } |