blob: 4f6bf61b0ccc4272114b2f0156350515cc39491a [file] [log] [blame]
Dan Handley9df48042015-03-19 18:58:55 +00001/*
Roberto Vargas2b36b152018-02-12 12:36:17 +00002 * Copyright (c) 2015-2018, ARM Limited and Contributors. All rights reserved.
Dan Handley9df48042015-03-19 18:58:55 +00003 *
dp-armfa3cf0b2017-05-03 09:38:09 +01004 * SPDX-License-Identifier: BSD-3-Clause
Dan Handley9df48042015-03-19 18:58:55 +00005 */
6
Dan Handley9df48042015-03-19 18:58:55 +00007#include <platform_def.h>
Antonio Nino Diaze0f90632018-12-14 00:18:21 +00008
9#include <drivers/arm/nic_400.h>
10#include <lib/mmio.h>
Antonio Nino Diazbd7b7402019-01-25 14:30:04 +000011#include <plat/arm/soc/common/soc_css.h>
Dan Handley9df48042015-03-19 18:58:55 +000012
Dan Handley9df48042015-03-19 18:58:55 +000013void soc_css_init_nic400(void)
14{
15 /*
16 * NIC-400 Access Control Initialization
17 *
18 * Define access privileges by setting each corresponding bit to:
19 * 0 = Secure access only
20 * 1 = Non-secure access allowed
21 */
22
23 /*
24 * Allow non-secure access to some SOC regions, excluding UART1, which
Alexei Fedorove9ab9052017-05-25 15:57:18 +010025 * remains secure (unless CSS_NON_SECURE_UART is set).
Dan Handley9df48042015-03-19 18:58:55 +000026 * Note: This is the NIC-400 device on the SOC
27 */
28 mmio_write_32(SOC_CSS_NIC400_BASE +
29 NIC400_ADDR_CTRL_SECURITY_REG(SOC_CSS_NIC400_USB_EHCI), ~0);
30 mmio_write_32(SOC_CSS_NIC400_BASE +
31 NIC400_ADDR_CTRL_SECURITY_REG(SOC_CSS_NIC400_TLX_MASTER), ~0);
32 mmio_write_32(SOC_CSS_NIC400_BASE +
33 NIC400_ADDR_CTRL_SECURITY_REG(SOC_CSS_NIC400_USB_OHCI), ~0);
34 mmio_write_32(SOC_CSS_NIC400_BASE +
35 NIC400_ADDR_CTRL_SECURITY_REG(SOC_CSS_NIC400_PL354_SMC), ~0);
36 mmio_write_32(SOC_CSS_NIC400_BASE +
37 NIC400_ADDR_CTRL_SECURITY_REG(SOC_CSS_NIC400_APB4_BRIDGE), ~0);
Alexei Fedorove9ab9052017-05-25 15:57:18 +010038#if CSS_NON_SECURE_UART
39 /* Configure UART for non-secure access */
40 mmio_write_32(SOC_CSS_NIC400_BASE +
41 NIC400_ADDR_CTRL_SECURITY_REG(SOC_CSS_NIC400_BOOTSEC_BRIDGE), ~0);
42#else
Dan Handley9df48042015-03-19 18:58:55 +000043 mmio_write_32(SOC_CSS_NIC400_BASE +
44 NIC400_ADDR_CTRL_SECURITY_REG(SOC_CSS_NIC400_BOOTSEC_BRIDGE),
45 ~SOC_CSS_NIC400_BOOTSEC_BRIDGE_UART1);
Alexei Fedorove9ab9052017-05-25 15:57:18 +010046#endif /* CSS_NON_SECURE_UART */
Dan Handley9df48042015-03-19 18:58:55 +000047
Dan Handley9df48042015-03-19 18:58:55 +000048}
49
50
51#define PCIE_SECURE_REG 0x3000
52/* Mask uses REG and MEM access bits */
53#define PCIE_SEC_ACCESS_MASK ((1 << 0) | (1 << 1))
54
55void soc_css_init_pcie(void)
56{
57#if !PLAT_juno
58 /*
59 * Do not initialize PCIe in emulator environment.
60 * Platform ID register not supported on Juno
61 */
62 if (BOARD_CSS_GET_PLAT_TYPE(BOARD_CSS_PLAT_ID_REG_ADDR) ==
63 BOARD_CSS_PLAT_TYPE_EMULATOR)
64 return;
65#endif /* PLAT_juno */
66
67 /*
68 * PCIE Root Complex Security settings to enable non-secure
69 * access to config registers.
70 */
71 mmio_write_32(SOC_CSS_PCIE_CONTROL_BASE + PCIE_SECURE_REG,
72 PCIE_SEC_ACCESS_MASK);
73}