blob: b9f32ac367609bed77e2047b8ccb7f509937d95f [file] [log] [blame]
Jiafei Pan46367ad2018-03-02 07:23:30 +00001/*
2 * Copyright (c) 2018, ARM Limited and Contributors. All rights reserved.
3 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
7#include <debug.h>
8#include <mmio.h>
9#include <endian.h>
10#include "platform_def.h"
11#include "soc_tzasc.h"
12
13int tzc380_set_region(unsigned int tzasc_base, unsigned int region_id,
14 unsigned int enabled, unsigned int low_addr,
15 unsigned int high_addr, unsigned int size,
16 unsigned int security, unsigned int subreg_disable_mask)
17{
18 unsigned int reg;
19 unsigned int reg_base;
20 unsigned int attr_value;
21
22 reg_base = (tzasc_base + TZASC_REGIONS_REG + (region_id << 4));
23
24 if (region_id == 0) {
25 reg = (reg_base + TZASC_REGION_ATTR_OFFSET);
26 mmio_write_32((uintptr_t)reg, ((security & 0xF) << 28));
27 } else {
28 reg = reg_base + TZASC_REGION_LOWADDR_OFFSET;
29 mmio_write_32((uintptr_t)reg,
30 (low_addr & TZASC_REGION_LOWADDR_MASK));
31
32 reg = reg_base + TZASC_REGION_HIGHADDR_OFFSET;
33 mmio_write_32((uintptr_t)reg, high_addr);
34
35 reg = reg_base + TZASC_REGION_ATTR_OFFSET;
36 attr_value = ((security & 0xF) << 28) |
37 ((subreg_disable_mask & 0xFF) << 8) |
38 ((size & 0x3F) << 1) | (enabled & 0x1);
39 mmio_write_32((uintptr_t)reg, attr_value);
40
41 }
42 return 0;
43}
44
45int tzc380_setup(void)
46{
47 int reg_id = 0;
48
49 INFO("Configuring TZASC-380\n");
50
51 /*
52 * Configure CCI control override register to terminate all barrier
53 * transactions
54 */
55 mmio_write_32(PLAT_LS1043_CCI_BASE, CCI_TERMINATE_BARRIER_TX);
56
57 /* Configure CSU secure access register to disable TZASC bypass mux */
58 mmio_write_32((uintptr_t)(CONFIG_SYS_FSL_CSU_ADDR +
59 CSU_SEC_ACCESS_REG_OFFSET),
60 bswap32(TZASC_BYPASS_MUX_DISABLE));
61
62 for (reg_id = 0; reg_id < MAX_NUM_TZC_REGION; reg_id++) {
63 tzc380_set_region(CONFIG_SYS_FSL_TZASC_ADDR,
64 reg_id,
65 tzc380_reg_list[reg_id].enabled,
66 tzc380_reg_list[reg_id].low_addr,
67 tzc380_reg_list[reg_id].high_addr,
68 tzc380_reg_list[reg_id].size,
69 tzc380_reg_list[reg_id].secure,
70 tzc380_reg_list[reg_id].sub_mask);
71 }
72
73 return 0;
74}