arm-trusted-firmware/plat/layerscape/common/ls_tzc380.c
Antonio Nino Diaz 09d40e0e08 Sanitise includes across codebase
Enforce full include path for includes. Deprecate old paths.

The following folders inside include/lib have been left unchanged:

- include/lib/cpus/${ARCH}
- include/lib/el3_runtime/${ARCH}

The reason for this change is that having a global namespace for
includes isn't a good idea. It defeats one of the advantages of having
folders and it introduces problems that are sometimes subtle (because
you may not know the header you are actually including if there are two
of them).

For example, this patch had to be created because two headers were
called the same way: e0ea0928d5 ("Fix gpio includes of mt8173 platform
to avoid collision."). More recently, this patch has had similar
problems: 46f9b2c3a2 ("drivers: add tzc380 support").

This problem was introduced in commit 4ecca33988 ("Move include and
source files to logical locations"). At that time, there weren't too
many headers so it wasn't a real issue. However, time has shown that
this creates problems.

Platforms that want to preserve the way they include headers may add the
removed paths to PLAT_INCLUDES, but this is discouraged.

Change-Id: I39dc53ed98f9e297a5966e723d1936d6ccf2fc8f
Signed-off-by: Antonio Nino Diaz <antonio.ninodiaz@arm.com>
2019-01-04 10:43:17 +00:00

78 lines
1.9 KiB
C

/*
* Copyright (c) 2018, ARM Limited and Contributors. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
#include <endian.h>
#include <platform_def.h>
#include <common/debug.h>
#include <lib/mmio.h>
#include "soc_tzasc.h"
int tzc380_set_region(unsigned int tzasc_base, unsigned int region_id,
unsigned int enabled, unsigned int low_addr,
unsigned int high_addr, unsigned int size,
unsigned int security, unsigned int subreg_disable_mask)
{
unsigned int reg;
unsigned int reg_base;
unsigned int attr_value;
reg_base = (tzasc_base + TZASC_REGIONS_REG + (region_id << 4));
if (region_id == 0) {
reg = (reg_base + TZASC_REGION_ATTR_OFFSET);
mmio_write_32((uintptr_t)reg, ((security & 0xF) << 28));
} else {
reg = reg_base + TZASC_REGION_LOWADDR_OFFSET;
mmio_write_32((uintptr_t)reg,
(low_addr & TZASC_REGION_LOWADDR_MASK));
reg = reg_base + TZASC_REGION_HIGHADDR_OFFSET;
mmio_write_32((uintptr_t)reg, high_addr);
reg = reg_base + TZASC_REGION_ATTR_OFFSET;
attr_value = ((security & 0xF) << 28) |
((subreg_disable_mask & 0xFF) << 8) |
((size & 0x3F) << 1) | (enabled & 0x1);
mmio_write_32((uintptr_t)reg, attr_value);
}
return 0;
}
int tzc380_setup(void)
{
int reg_id = 0;
INFO("Configuring TZASC-380\n");
/*
* Configure CCI control override register to terminate all barrier
* transactions
*/
mmio_write_32(PLAT_LS1043_CCI_BASE, CCI_TERMINATE_BARRIER_TX);
/* Configure CSU secure access register to disable TZASC bypass mux */
mmio_write_32((uintptr_t)(CONFIG_SYS_FSL_CSU_ADDR +
CSU_SEC_ACCESS_REG_OFFSET),
bswap32(TZASC_BYPASS_MUX_DISABLE));
for (reg_id = 0; reg_id < MAX_NUM_TZC_REGION; reg_id++) {
tzc380_set_region(CONFIG_SYS_FSL_TZASC_ADDR,
reg_id,
tzc380_reg_list[reg_id].enabled,
tzc380_reg_list[reg_id].low_addr,
tzc380_reg_list[reg_id].high_addr,
tzc380_reg_list[reg_id].size,
tzc380_reg_list[reg_id].secure,
tzc380_reg_list[reg_id].sub_mask);
}
return 0;
}