Unverified Commit c40c88f8 authored by Antonio Niño Díaz's avatar Antonio Niño Díaz Committed by GitHub
Browse files

Merge pull request #1764 from vwadekar/tf2.0-tegra-downstream-rebase-1.7.19

Tf2.0 tegra downstream rebase 1.7.19
parents fbf35335 650d9c52
...@@ -82,6 +82,8 @@ uint64\_t tzdram\_base; ...@@ -82,6 +82,8 @@ uint64\_t tzdram\_base;
int uart\_id; int uart\_id;
/* L2 ECC parity protection disable flag \*/ /* L2 ECC parity protection disable flag \*/
int l2\_ecc\_parity\_prot\_dis; int l2\_ecc\_parity\_prot\_dis;
/* SHMEM base address for storing the boot logs \*/
uint64\_t boot\_profiler\_shmem\_base;
} plat\_params\_from\_bl2\_t; } plat\_params\_from\_bl2\_t;
Power Management Power Management
......
...@@ -18,11 +18,16 @@ ...@@ -18,11 +18,16 @@
/******************************************************************************* /*******************************************************************************
* Implementation defined ACTLR_EL3 bit definitions * Implementation defined ACTLR_EL3 bit definitions
******************************************************************************/ ******************************************************************************/
#define ACTLR_EL3_L2ACTLR_BIT (1 << 6) #define ACTLR_EL3_L2ACTLR_BIT (U(1) << 6)
#define ACTLR_EL3_L2ECTLR_BIT (1 << 5) #define ACTLR_EL3_L2ECTLR_BIT (U(1) << 5)
#define ACTLR_EL3_L2CTLR_BIT (1 << 4) #define ACTLR_EL3_L2CTLR_BIT (U(1) << 4)
#define ACTLR_EL3_CPUECTLR_BIT (1 << 1) #define ACTLR_EL3_CPUECTLR_BIT (U(1) << 1)
#define ACTLR_EL3_CPUACTLR_BIT (1 << 0) #define ACTLR_EL3_CPUACTLR_BIT (U(1) << 0)
#define ACTLR_EL3_ENABLE_ALL_MASK (ACTLR_EL3_L2ACTLR_BIT | \
ACTLR_EL3_L2ECTLR_BIT | \
ACTLR_EL3_L2CTLR_BIT | \
ACTLR_EL3_CPUECTLR_BIT | \
ACTLR_EL3_CPUACTLR_BIT)
#define ACTLR_EL3_ENABLE_ALL_ACCESS (ACTLR_EL3_L2ACTLR_BIT | \ #define ACTLR_EL3_ENABLE_ALL_ACCESS (ACTLR_EL3_L2ACTLR_BIT | \
ACTLR_EL3_L2ECTLR_BIT | \ ACTLR_EL3_L2ECTLR_BIT | \
ACTLR_EL3_L2CTLR_BIT | \ ACTLR_EL3_L2CTLR_BIT | \
...@@ -87,8 +92,17 @@ ...@@ -87,8 +92,17 @@
* Enable L2 and CPU ECTLR RW access from non-secure world * Enable L2 and CPU ECTLR RW access from non-secure world
* ------------------------------------------------------- * -------------------------------------------------------
*/ */
mov x0, #ACTLR_EL3_ENABLE_ALL_ACCESS mrs x0, actlr_el3
mov x1, #ACTLR_EL3_ENABLE_ALL_MASK
bic x0, x0, x1
mov x1, #ACTLR_EL3_ENABLE_ALL_ACCESS
orr x0, x0, x1
msr actlr_el3, x0 msr actlr_el3, x0
mrs x0, actlr_el2
mov x1, #ACTLR_EL3_ENABLE_ALL_MASK
bic x0, x0, x1
mov x1, #ACTLR_EL3_ENABLE_ALL_ACCESS
orr x0, x0, x1
msr actlr_el2, x0 msr actlr_el2, x0
isb isb
...@@ -130,17 +144,20 @@ func plat_is_my_cpu_primary ...@@ -130,17 +144,20 @@ func plat_is_my_cpu_primary
ret ret
endfunc plat_is_my_cpu_primary endfunc plat_is_my_cpu_primary
/* ----------------------------------------------------- /* ----------------------------------------------------------
* unsigned int plat_my_core_pos(void); * unsigned int plat_my_core_pos(void);
* *
* result: CorePos = CoreId + (ClusterId << 2) * result: CorePos = CoreId + (ClusterId * cpus per cluster)
* ----------------------------------------------------- * ----------------------------------------------------------
*/ */
func plat_my_core_pos func plat_my_core_pos
mrs x0, mpidr_el1 mrs x0, mpidr_el1
and x1, x0, #MPIDR_CPU_MASK and x1, x0, #MPIDR_CPU_MASK
and x0, x0, #MPIDR_CLUSTER_MASK and x0, x0, #MPIDR_CLUSTER_MASK
add x0, x1, x0, LSR #6 lsr x0, x0, #MPIDR_AFFINITY_BITS
mov x2, #PLATFORM_MAX_CPUS_PER_CLUSTER
mul x0, x0, x2
add x0, x1, x0
ret ret
endfunc plat_my_core_pos endfunc plat_my_core_pos
...@@ -162,14 +179,17 @@ endfunc plat_get_my_entrypoint ...@@ -162,14 +179,17 @@ endfunc plat_get_my_entrypoint
/* ----------------------------------------------------- /* -----------------------------------------------------
* int platform_get_core_pos(int mpidr); * int platform_get_core_pos(int mpidr);
* *
* With this function: CorePos = (ClusterId * 4) + * result: CorePos = (ClusterId * cpus per cluster) +
* CoreId * CoreId
* ----------------------------------------------------- * -----------------------------------------------------
*/ */
func platform_get_core_pos func platform_get_core_pos
and x1, x0, #MPIDR_CPU_MASK and x1, x0, #MPIDR_CPU_MASK
and x0, x0, #MPIDR_CLUSTER_MASK and x0, x0, #MPIDR_CLUSTER_MASK
add x0, x1, x0, LSR #6 lsr x0, x0, #MPIDR_AFFINITY_BITS
mov x2, #PLATFORM_MAX_CPUS_PER_CLUSTER
mul x0, x0, x2
add x0, x1, x0
ret ret
endfunc platform_get_core_pos endfunc platform_get_core_pos
...@@ -400,31 +420,6 @@ restore_oslock: ...@@ -400,31 +420,6 @@ restore_oslock:
mov x0, #1 mov x0, #1
msr oslar_el1, x0 msr oslar_el1, x0
cpu_init_common
/* ---------------------------------------------------------------------
* The initial state of the Architectural feature trap register
* (CPTR_EL3) is unknown and it must be set to a known state. All
* feature traps are disabled. Some bits in this register are marked as
* Reserved and should not be modified.
*
* CPTR_EL3.TCPAC: This causes a direct access to the CPACR_EL1 from EL1
* or the CPTR_EL2 from EL2 to trap to EL3 unless it is trapped at EL2.
* CPTR_EL3.TTA: This causes access to the Trace functionality to trap
* to EL3 when executed from EL0, EL1, EL2, or EL3. If system register
* access to trace functionality is not supported, this bit is RES0.
* CPTR_EL3.TFP: This causes instructions that access the registers
* associated with Floating Point and Advanced SIMD execution to trap
* to EL3 when executed from any exception level, unless trapped to EL1
* or EL2.
* ---------------------------------------------------------------------
*/
mrs x1, cptr_el3
bic w1, w1, #TCPAC_BIT
bic w1, w1, #TTA_BIT
bic w1, w1, #TFP_BIT
msr cptr_el3, x1
/* -------------------------------------------------- /* --------------------------------------------------
* Get secure world's entry point and jump to it * Get secure world's entry point and jump to it
* -------------------------------------------------- * --------------------------------------------------
......
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
#include <string.h> #include <string.h>
#include <tegra_def.h> #include <tegra_def.h>
#define BPMP_TIMEOUT_10US 10 #define BPMP_TIMEOUT 2
static uint32_t channel_base[NR_CHANNELS]; static uint32_t channel_base[NR_CHANNELS];
static uint32_t bpmp_init_state = BPMP_INIT_PENDING; static uint32_t bpmp_init_state = BPMP_INIT_PENDING;
...@@ -58,15 +58,15 @@ int32_t tegra_bpmp_send_receive_atomic(int mrq, const void *ob_data, int ob_sz, ...@@ -58,15 +58,15 @@ int32_t tegra_bpmp_send_receive_atomic(int mrq, const void *ob_data, int ob_sz,
if (bpmp_init_state == BPMP_INIT_COMPLETE) { if (bpmp_init_state == BPMP_INIT_COMPLETE) {
/* loop until BPMP is free */ /* loop until BPMP is free */
for (timeout = 0; timeout < BPMP_TIMEOUT_10US; timeout++) { for (timeout = 0; timeout < BPMP_TIMEOUT; timeout++) {
if (master_free(ch) == true) { if (master_free(ch) == true) {
break; break;
} }
udelay(1); mdelay(1);
} }
if (timeout != BPMP_TIMEOUT_10US) { if (timeout != BPMP_TIMEOUT) {
/* generate the command struct */ /* generate the command struct */
p->code = mrq; p->code = mrq;
...@@ -76,18 +76,18 @@ int32_t tegra_bpmp_send_receive_atomic(int mrq, const void *ob_data, int ob_sz, ...@@ -76,18 +76,18 @@ int32_t tegra_bpmp_send_receive_atomic(int mrq, const void *ob_data, int ob_sz,
/* signal command ready to the BPMP */ /* signal command ready to the BPMP */
signal_slave(ch); signal_slave(ch);
mmio_write_32(TEGRA_PRI_ICTLR_BASE + CPU_IEP_FIR_SET, mmio_write_32(TEGRA_PRI_ICTLR_BASE + CPU_IEP_FIR_SET,
(1UL << INT_SHR_SEM_OUTBOX_FULL)); (1U << INT_SHR_SEM_OUTBOX_FULL));
/* loop until the command is executed */ /* loop until the command is executed */
for (timeout = 0; timeout < BPMP_TIMEOUT_10US; timeout++) { for (timeout = 0; timeout < BPMP_TIMEOUT; timeout++) {
if (master_acked(ch) == true) { if (master_acked(ch) == true) {
break; break;
} }
udelay(1); mdelay(1);
} }
if (timeout != BPMP_TIMEOUT_10US) { if (timeout != BPMP_TIMEOUT) {
/* get the command response */ /* get the command response */
(void)memcpy(ib_data, (const void *)p->data, (void)memcpy(ib_data, (const void *)p->data,
...@@ -106,8 +106,8 @@ int32_t tegra_bpmp_send_receive_atomic(int mrq, const void *ob_data, int ob_sz, ...@@ -106,8 +106,8 @@ int32_t tegra_bpmp_send_receive_atomic(int mrq, const void *ob_data, int ob_sz,
ret = -EINVAL; ret = -EINVAL;
} }
if (timeout == BPMP_TIMEOUT_10US) { if (timeout == BPMP_TIMEOUT) {
ERROR("Timed out waiting for bpmp's response"); ERROR("Timed out waiting for bpmp's response\n");
} }
return ret; return ret;
...@@ -154,7 +154,7 @@ int tegra_bpmp_init(void) ...@@ -154,7 +154,7 @@ int tegra_bpmp_init(void)
channel_base[ch] = mmio_read_32(base); channel_base[ch] = mmio_read_32(base);
/* increment result register offset */ /* increment result register offset */
base += 4UL; base += 4U;
} }
/* mark state as "initialized" */ /* mark state as "initialized" */
......
/*
* Copyright (c) 2017, ARM Limited and Contributors. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
#include <arch_helpers.h>
#include <common/debug.h>
#include <delay_timer.h>
#include <errno.h>
#include <gpcdma.h>
#include <mmio.h>
#include <platform_def.h>
#include <stdbool.h>
#include <tegra_def.h>
#include <utils_def.h>
/* DMA channel registers */
#define DMA_CH_CSR U(0x0)
#define DMA_CH_CSR_WEIGHT_SHIFT U(10)
#define DMA_CH_CSR_XFER_MODE_SHIFT U(21)
#define DMA_CH_CSR_DMA_MODE_MEM2MEM U(4)
#define DMA_CH_CSR_DMA_MODE_FIXEDPATTERN U(6)
#define DMA_CH_CSR_IRQ_MASK_ENABLE (U(1) << 15)
#define DMA_CH_CSR_RUN_ONCE (U(1) << 27)
#define DMA_CH_CSR_ENABLE (U(1) << 31)
#define DMA_CH_STAT U(0x4)
#define DMA_CH_STAT_BUSY (U(1) << 31)
#define DMA_CH_SRC_PTR U(0xC)
#define DMA_CH_DST_PTR U(0x10)
#define DMA_CH_HI_ADR_PTR U(0x14)
#define DMA_CH_HI_ADR_PTR_SRC_MASK U(0xFF)
#define DMA_CH_HI_ADR_PTR_DST_SHIFT U(16)
#define DMA_CH_HI_ADR_PTR_DST_MASK U(0xFF)
#define DMA_CH_MC_SEQ U(0x18)
#define DMA_CH_MC_SEQ_REQ_CNT_SHIFT U(25)
#define DMA_CH_MC_SEQ_REQ_CNT_VAL U(0x10)
#define DMA_CH_MC_SEQ_BURST_SHIFT U(23)
#define DMA_CH_MC_SEQ_BURST_16_WORDS U(0x3)
#define DMA_CH_WORD_COUNT U(0x20)
#define DMA_CH_FIXED_PATTERN U(0x34)
#define DMA_CH_TZ U(0x38)
#define DMA_CH_TZ_ACCESS_ENABLE U(0)
#define DMA_CH_TZ_ACCESS_DISABLE U(3)
#define MAX_TRANSFER_SIZE (1U*1024U*1024U*1024U) /* 1GB */
#define GPCDMA_TIMEOUT_MS U(100)
#define GPCDMA_RESET_BIT (U(1) << 1)
static bool init_done;
static void tegra_gpcdma_write32(uint32_t offset, uint32_t val)
{
mmio_write_32(TEGRA_GPCDMA_BASE + offset, val);
}
static uint32_t tegra_gpcdma_read32(uint32_t offset)
{
return mmio_read_32(TEGRA_GPCDMA_BASE + offset);
}
static void tegra_gpcdma_init(void)
{
/* assert reset for DMA engine */
mmio_write_32(TEGRA_CAR_RESET_BASE + TEGRA_GPCDMA_RST_SET_REG_OFFSET,
GPCDMA_RESET_BIT);
udelay(2);
/* de-assert reset for DMA engine */
mmio_write_32(TEGRA_CAR_RESET_BASE + TEGRA_GPCDMA_RST_CLR_REG_OFFSET,
GPCDMA_RESET_BIT);
}
static void tegra_gpcdma_memcpy_priv(uint64_t dst_addr, uint64_t src_addr,
uint32_t num_bytes, uint32_t mode)
{
uint32_t val, timeout = 0;
int32_t ret = 0;
/* sanity check byte count */
if ((num_bytes > MAX_TRANSFER_SIZE) || ((num_bytes & 0x3U) != U(0))) {
ret = -EINVAL;
}
/* initialise GPCDMA block */
if (!init_done) {
tegra_gpcdma_init();
init_done = true;
}
/* make sure channel isn't busy */
val = tegra_gpcdma_read32(DMA_CH_STAT);
if ((val & DMA_CH_STAT_BUSY) == DMA_CH_STAT_BUSY) {
ERROR("DMA channel is busy\n");
ret = -EBUSY;
}
if (ret == 0) {
/* disable any DMA transfers */
tegra_gpcdma_write32(DMA_CH_CSR, 0);
/* enable DMA access to TZDRAM */
tegra_gpcdma_write32(DMA_CH_TZ, DMA_CH_TZ_ACCESS_ENABLE);
/* configure MC sequencer */
val = (DMA_CH_MC_SEQ_REQ_CNT_VAL << DMA_CH_MC_SEQ_REQ_CNT_SHIFT) |
(DMA_CH_MC_SEQ_BURST_16_WORDS << DMA_CH_MC_SEQ_BURST_SHIFT);
tegra_gpcdma_write32(DMA_CH_MC_SEQ, val);
/* reset fixed pattern */
tegra_gpcdma_write32(DMA_CH_FIXED_PATTERN, 0);
/* populate src and dst address registers */
tegra_gpcdma_write32(DMA_CH_SRC_PTR, (uint32_t)src_addr);
tegra_gpcdma_write32(DMA_CH_DST_PTR, (uint32_t)dst_addr);
val = (uint32_t)((src_addr >> 32) & DMA_CH_HI_ADR_PTR_SRC_MASK);
val |= (uint32_t)(((dst_addr >> 32) & DMA_CH_HI_ADR_PTR_DST_MASK) <<
DMA_CH_HI_ADR_PTR_DST_SHIFT);
tegra_gpcdma_write32(DMA_CH_HI_ADR_PTR, val);
/* transfer size (in words) */
tegra_gpcdma_write32(DMA_CH_WORD_COUNT, ((num_bytes >> 2) - 1U));
/* populate value for CSR */
val = (mode << DMA_CH_CSR_XFER_MODE_SHIFT) |
DMA_CH_CSR_RUN_ONCE | (U(1) << DMA_CH_CSR_WEIGHT_SHIFT) |
DMA_CH_CSR_IRQ_MASK_ENABLE;
tegra_gpcdma_write32(DMA_CH_CSR, val);
/* enable transfer */
val = tegra_gpcdma_read32(DMA_CH_CSR);
val |= DMA_CH_CSR_ENABLE;
tegra_gpcdma_write32(DMA_CH_CSR, val);
/* wait till transfer completes */
do {
/* read the status */
val = tegra_gpcdma_read32(DMA_CH_STAT);
if ((val & DMA_CH_STAT_BUSY) != DMA_CH_STAT_BUSY) {
break;
}
mdelay(1);
timeout++;
} while (timeout < GPCDMA_TIMEOUT_MS);
/* flag timeout error */
if (timeout == GPCDMA_TIMEOUT_MS) {
ERROR("DMA transfer timed out\n");
}
dsbsy();
/* disable DMA access to TZDRAM */
tegra_gpcdma_write32(DMA_CH_TZ, DMA_CH_TZ_ACCESS_DISABLE);
isb();
}
}
/*******************************************************************************
* Memcpy using GPCDMA block (Mem2Mem copy)
******************************************************************************/
void tegra_gpcdma_memcpy(uint64_t dst_addr, uint64_t src_addr,
uint32_t num_bytes)
{
tegra_gpcdma_memcpy_priv(dst_addr, src_addr, num_bytes,
DMA_CH_CSR_DMA_MODE_MEM2MEM);
}
/*******************************************************************************
* Memset using GPCDMA block (Fixed pattern write)
******************************************************************************/
void tegra_gpcdma_zeromem(uint64_t dst_addr, uint32_t num_bytes)
{
tegra_gpcdma_memcpy_priv(dst_addr, 0, num_bytes,
DMA_CH_CSR_DMA_MODE_FIXEDPATTERN);
}
...@@ -109,13 +109,16 @@ void tegra_memctrl_tzram_setup(uint64_t phys_base, uint32_t size_in_bytes) ...@@ -109,13 +109,16 @@ void tegra_memctrl_tzram_setup(uint64_t phys_base, uint32_t size_in_bytes)
static void tegra_clear_videomem(uintptr_t non_overlap_area_start, static void tegra_clear_videomem(uintptr_t non_overlap_area_start,
unsigned long long non_overlap_area_size) unsigned long long non_overlap_area_size)
{ {
int ret;
/* /*
* Map the NS memory first, clean it and then unmap it. * Map the NS memory first, clean it and then unmap it.
*/ */
mmap_add_dynamic_region(non_overlap_area_start, /* PA */ ret = mmap_add_dynamic_region(non_overlap_area_start, /* PA */
non_overlap_area_start, /* VA */ non_overlap_area_start, /* VA */
non_overlap_area_size, /* size */ non_overlap_area_size, /* size */
MT_NS | MT_RW | MT_EXECUTE_NEVER); /* attrs */ MT_NS | MT_RW | MT_EXECUTE_NEVER); /* attrs */
assert(ret == 0);
zeromem((void *)non_overlap_area_start, non_overlap_area_size); zeromem((void *)non_overlap_area_start, non_overlap_area_size);
flush_dcache_range(non_overlap_area_start, non_overlap_area_size); flush_dcache_range(non_overlap_area_start, non_overlap_area_size);
...@@ -206,3 +209,16 @@ void tegra_memctrl_disable_ahb_redirection(void) ...@@ -206,3 +209,16 @@ void tegra_memctrl_disable_ahb_redirection(void)
/* lock the aperture registers */ /* lock the aperture registers */
tegra_mc_write_32(MC_IRAM_REG_CTRL, MC_DISABLE_IRAM_CFG_WRITES); tegra_mc_write_32(MC_IRAM_REG_CTRL, MC_DISABLE_IRAM_CFG_WRITES);
} }
void tegra_memctrl_clear_pending_interrupts(void)
{
uint32_t mcerr;
/* check if there are any pending interrupts */
mcerr = mmio_read_32(TEGRA_MC_BASE + MC_INTSTATUS);
if (mcerr != (uint32_t)0U) { /* should not see error here */
WARN("MC_INTSTATUS = 0x%x (should be zero)\n", mcerr);
mmio_write_32((TEGRA_MC_BASE + MC_INTSTATUS), mcerr);
}
}
...@@ -287,13 +287,13 @@ static void tegra_memctrl_reconfig_mss_clients(void) ...@@ -287,13 +287,13 @@ static void tegra_memctrl_reconfig_mss_clients(void)
static void tegra_memctrl_set_overrides(void) static void tegra_memctrl_set_overrides(void)
{ {
tegra_mc_settings_t *plat_mc_settings = tegra_get_mc_settings(); const tegra_mc_settings_t *plat_mc_settings = tegra_get_mc_settings();
const mc_txn_override_cfg_t *mc_txn_override_cfgs; const mc_txn_override_cfg_t *mc_txn_override_cfgs;
uint32_t num_txn_override_cfgs; uint32_t num_txn_override_cfgs;
uint32_t i, val; uint32_t i, val;
/* Get the settings from the platform */ /* Get the settings from the platform */
assert(plat_mc_settings); assert(plat_mc_settings != NULL);
mc_txn_override_cfgs = plat_mc_settings->txn_override_cfg; mc_txn_override_cfgs = plat_mc_settings->txn_override_cfg;
num_txn_override_cfgs = plat_mc_settings->num_txn_override_cfgs; num_txn_override_cfgs = plat_mc_settings->num_txn_override_cfgs;
...@@ -302,24 +302,24 @@ static void tegra_memctrl_set_overrides(void) ...@@ -302,24 +302,24 @@ static void tegra_memctrl_set_overrides(void)
*/ */
if ((tegra_chipid_is_t186()) && if ((tegra_chipid_is_t186()) &&
(!tegra_platform_is_silicon() || (!tegra_platform_is_silicon() ||
(tegra_platform_is_silicon() && (tegra_get_chipid_minor() == 1)))) { (tegra_platform_is_silicon() && (tegra_get_chipid_minor() == 1U)))) {
/* /*
* GPU and NVENC settings for Tegra186 simulation and * GPU and NVENC settings for Tegra186 simulation and
* Silicon rev. A01 * Silicon rev. A01
*/ */
val = tegra_mc_read_32(MC_TXN_OVERRIDE_CONFIG_GPUSWR); val = tegra_mc_read_32(MC_TXN_OVERRIDE_CONFIG_GPUSWR);
val &= ~MC_TXN_OVERRIDE_CGID_TAG_MASK; val &= (uint32_t)~MC_TXN_OVERRIDE_CGID_TAG_MASK;
tegra_mc_write_32(MC_TXN_OVERRIDE_CONFIG_GPUSWR, tegra_mc_write_32(MC_TXN_OVERRIDE_CONFIG_GPUSWR,
val | MC_TXN_OVERRIDE_CGID_TAG_ZERO); val | MC_TXN_OVERRIDE_CGID_TAG_ZERO);
val = tegra_mc_read_32(MC_TXN_OVERRIDE_CONFIG_GPUSWR2); val = tegra_mc_read_32(MC_TXN_OVERRIDE_CONFIG_GPUSWR2);
val &= ~MC_TXN_OVERRIDE_CGID_TAG_MASK; val &= (uint32_t)~MC_TXN_OVERRIDE_CGID_TAG_MASK;
tegra_mc_write_32(MC_TXN_OVERRIDE_CONFIG_GPUSWR2, tegra_mc_write_32(MC_TXN_OVERRIDE_CONFIG_GPUSWR2,
val | MC_TXN_OVERRIDE_CGID_TAG_ZERO); val | MC_TXN_OVERRIDE_CGID_TAG_ZERO);
val = tegra_mc_read_32(MC_TXN_OVERRIDE_CONFIG_NVENCSWR); val = tegra_mc_read_32(MC_TXN_OVERRIDE_CONFIG_NVENCSWR);
val &= ~MC_TXN_OVERRIDE_CGID_TAG_MASK; val &= (uint32_t)~MC_TXN_OVERRIDE_CGID_TAG_MASK;
tegra_mc_write_32(MC_TXN_OVERRIDE_CONFIG_NVENCSWR, tegra_mc_write_32(MC_TXN_OVERRIDE_CONFIG_NVENCSWR,
val | MC_TXN_OVERRIDE_CGID_TAG_CLIENT_AXI_ID); val | MC_TXN_OVERRIDE_CGID_TAG_CLIENT_AXI_ID);
...@@ -330,7 +330,7 @@ static void tegra_memctrl_set_overrides(void) ...@@ -330,7 +330,7 @@ static void tegra_memctrl_set_overrides(void)
*/ */
for (i = 0; i < num_txn_override_cfgs; i++) { for (i = 0; i < num_txn_override_cfgs; i++) {
val = tegra_mc_read_32(mc_txn_override_cfgs[i].offset); val = tegra_mc_read_32(mc_txn_override_cfgs[i].offset);
val &= ~MC_TXN_OVERRIDE_CGID_TAG_MASK; val &= (uint32_t)~MC_TXN_OVERRIDE_CGID_TAG_MASK;
tegra_mc_write_32(mc_txn_override_cfgs[i].offset, tegra_mc_write_32(mc_txn_override_cfgs[i].offset,
val | mc_txn_override_cfgs[i].cgid_tag); val | mc_txn_override_cfgs[i].cgid_tag);
} }
...@@ -347,7 +347,7 @@ void tegra_memctrl_setup(void) ...@@ -347,7 +347,7 @@ void tegra_memctrl_setup(void)
uint32_t num_streamid_override_regs; uint32_t num_streamid_override_regs;
const mc_streamid_security_cfg_t *mc_streamid_sec_cfgs; const mc_streamid_security_cfg_t *mc_streamid_sec_cfgs;
uint32_t num_streamid_sec_cfgs; uint32_t num_streamid_sec_cfgs;
tegra_mc_settings_t *plat_mc_settings = tegra_get_mc_settings(); const tegra_mc_settings_t *plat_mc_settings = tegra_get_mc_settings();
uint32_t i; uint32_t i;
INFO("Tegra Memory Controller (v2)\n"); INFO("Tegra Memory Controller (v2)\n");
...@@ -357,7 +357,7 @@ void tegra_memctrl_setup(void) ...@@ -357,7 +357,7 @@ void tegra_memctrl_setup(void)
tegra_smmu_init(); tegra_smmu_init();
#endif #endif
/* Get the settings from the platform */ /* Get the settings from the platform */
assert(plat_mc_settings); assert(plat_mc_settings != NULL);
mc_streamid_override_regs = plat_mc_settings->streamid_override_cfg; mc_streamid_override_regs = plat_mc_settings->streamid_override_cfg;
num_streamid_override_regs = plat_mc_settings->num_streamid_override_cfgs; num_streamid_override_regs = plat_mc_settings->num_streamid_override_cfgs;
mc_streamid_sec_cfgs = plat_mc_settings->streamid_security_cfg; mc_streamid_sec_cfgs = plat_mc_settings->streamid_security_cfg;
...@@ -421,7 +421,7 @@ void tegra_memctrl_restore_settings(void) ...@@ -421,7 +421,7 @@ void tegra_memctrl_restore_settings(void)
tegra_memctrl_set_overrides(); tegra_memctrl_set_overrides();
/* video memory carveout region */ /* video memory carveout region */
if (video_mem_base) { if (video_mem_base != 0ULL) {
tegra_mc_write_32(MC_VIDEO_PROTECT_BASE_LO, tegra_mc_write_32(MC_VIDEO_PROTECT_BASE_LO,
(uint32_t)video_mem_base); (uint32_t)video_mem_base);
tegra_mc_write_32(MC_VIDEO_PROTECT_BASE_HI, tegra_mc_write_32(MC_VIDEO_PROTECT_BASE_HI,
...@@ -444,6 +444,8 @@ void tegra_memctrl_restore_settings(void) ...@@ -444,6 +444,8 @@ void tegra_memctrl_restore_settings(void)
*/ */
void tegra_memctrl_tzdram_setup(uint64_t phys_base, uint32_t size_in_bytes) void tegra_memctrl_tzdram_setup(uint64_t phys_base, uint32_t size_in_bytes)
{ {
uint32_t val;
/* /*
* Setup the Memory controller to allow only secure accesses to * Setup the Memory controller to allow only secure accesses to
* the TZDRAM carveout * the TZDRAM carveout
...@@ -458,15 +460,20 @@ void tegra_memctrl_tzdram_setup(uint64_t phys_base, uint32_t size_in_bytes) ...@@ -458,15 +460,20 @@ void tegra_memctrl_tzdram_setup(uint64_t phys_base, uint32_t size_in_bytes)
* When TZ encryption enabled, * When TZ encryption enabled,
* We need setup TZDRAM before CPU to access TZ Carveout, * We need setup TZDRAM before CPU to access TZ Carveout,
* otherwise CPU will fetch non-decrypted data. * otherwise CPU will fetch non-decrypted data.
* So save TZDRAM setting for retore by SC7 resume FW. * So save TZDRAM setting for restore by SC7 resume FW.
* Scratch registers map:
* RSV55_0 = CFG1[12:0] | CFG0[31:20]
* RSV55_1 = CFG3[1:0]
*/ */
mmio_write_32(TEGRA_SCRATCH_BASE + SECURE_SCRATCH_RSV55_LO, val = tegra_mc_read_32(MC_SECURITY_CFG1_0) & MC_SECURITY_SIZE_MB_MASK;
tegra_mc_read_32(MC_SECURITY_CFG0_0)); mmio_write_32(TEGRA_SCRATCH_BASE + SECURE_SCRATCH_RSV54_HI, val);
mmio_write_32(TEGRA_SCRATCH_BASE + SECURE_SCRATCH_RSV55_HI,
tegra_mc_read_32(MC_SECURITY_CFG3_0)); val |= tegra_mc_read_32(MC_SECURITY_CFG0_0) & MC_SECURITY_BOM_MASK;
mmio_write_32(TEGRA_SCRATCH_BASE + SECURE_SCRATCH_RSV54_HI, mmio_write_32(TEGRA_SCRATCH_BASE + SECURE_SCRATCH_RSV55_LO, val);
tegra_mc_read_32(MC_SECURITY_CFG1_0));
val = tegra_mc_read_32(MC_SECURITY_CFG3_0) & MC_SECURITY_BOM_HI_MASK;
mmio_write_32(TEGRA_SCRATCH_BASE + SECURE_SCRATCH_RSV55_HI, val);
/* /*
* MCE propagates the security configuration values across the * MCE propagates the security configuration values across the
...@@ -525,7 +532,7 @@ void tegra_memctrl_tzram_setup(uint64_t phys_base, uint32_t size_in_bytes) ...@@ -525,7 +532,7 @@ void tegra_memctrl_tzram_setup(uint64_t phys_base, uint32_t size_in_bytes)
* at all. * at all.
*/ */
val = tegra_mc_read_32(MC_TZRAM_CARVEOUT_CFG); val = tegra_mc_read_32(MC_TZRAM_CARVEOUT_CFG);
val &= ~MC_GSC_ENABLE_TZ_LOCK_BIT; val &= (uint32_t)~MC_GSC_ENABLE_TZ_LOCK_BIT;
val |= MC_GSC_LOCK_CFG_SETTINGS_BIT; val |= MC_GSC_LOCK_CFG_SETTINGS_BIT;
tegra_mc_write_32(MC_TZRAM_CARVEOUT_CFG, val); tegra_mc_write_32(MC_TZRAM_CARVEOUT_CFG, val);
...@@ -600,18 +607,21 @@ static void tegra_unlock_videomem_nonoverlap(void) ...@@ -600,18 +607,21 @@ static void tegra_unlock_videomem_nonoverlap(void)
static void tegra_clear_videomem(uintptr_t non_overlap_area_start, static void tegra_clear_videomem(uintptr_t non_overlap_area_start,
unsigned long long non_overlap_area_size) unsigned long long non_overlap_area_size)
{ {
int ret;
/* /*
* Map the NS memory first, clean it and then unmap it. * Map the NS memory first, clean it and then unmap it.
*/ */
mmap_add_dynamic_region(non_overlap_area_start, /* PA */ ret = mmap_add_dynamic_region(non_overlap_area_start, /* PA */
non_overlap_area_start, /* VA */ non_overlap_area_start, /* VA */
non_overlap_area_size, /* size */ non_overlap_area_size, /* size */
MT_NS | MT_RW | MT_EXECUTE_NEVER); /* attrs */ MT_NS | MT_RW | MT_EXECUTE_NEVER); /* attrs */
assert(ret == 0);
zero_normalmem((void *)non_overlap_area_start, non_overlap_area_size); zero_normalmem((void *)non_overlap_area_start, non_overlap_area_size);
flush_dcache_range(non_overlap_area_start, non_overlap_area_size); flush_dcache_range(non_overlap_area_start, non_overlap_area_size);
mmap_remove_dynamic_region(non_overlap_area_start, (void)mmap_remove_dynamic_region(non_overlap_area_start,
non_overlap_area_size); non_overlap_area_size);
} }
...@@ -658,17 +668,19 @@ void tegra_memctrl_videomem_setup(uint64_t phys_base, uint32_t size_in_bytes) ...@@ -658,17 +668,19 @@ void tegra_memctrl_videomem_setup(uint64_t phys_base, uint32_t size_in_bytes)
*/ */
INFO("Cleaning previous Video Memory Carveout\n"); INFO("Cleaning previous Video Memory Carveout\n");
if (phys_base > vmem_end_old || video_mem_base > vmem_end_new) { if ((phys_base > vmem_end_old) || (video_mem_base > vmem_end_new)) {
tegra_clear_videomem(video_mem_base, tegra_clear_videomem(video_mem_base,
(uint64_t)video_mem_size_mb << 20); (uint32_t)video_mem_size_mb << 20U);
} else { } else {
if (video_mem_base < phys_base) { if (video_mem_base < phys_base) {
non_overlap_area_size = phys_base - video_mem_base; non_overlap_area_size = phys_base - video_mem_base;
tegra_clear_videomem(video_mem_base, non_overlap_area_size); tegra_clear_videomem(video_mem_base,
(uint32_t)non_overlap_area_size);
} }
if (vmem_end_old > vmem_end_new) { if (vmem_end_old > vmem_end_new) {
non_overlap_area_size = vmem_end_old - vmem_end_new; non_overlap_area_size = vmem_end_old - vmem_end_new;
tegra_clear_videomem(vmem_end_new, non_overlap_area_size); tegra_clear_videomem(vmem_end_new,
(uint32_t)non_overlap_area_size);
} }
} }
...@@ -700,3 +712,8 @@ void tegra_memctrl_disable_ahb_redirection(void) ...@@ -700,3 +712,8 @@ void tegra_memctrl_disable_ahb_redirection(void)
{ {
; /* do nothing */ ; /* do nothing */
} }
void tegra_memctrl_clear_pending_interrupts(void)
{
; /* do nothing */
}
...@@ -19,47 +19,55 @@ extern void memcpy16(void *dest, const void *src, unsigned int length); ...@@ -19,47 +19,55 @@ extern void memcpy16(void *dest, const void *src, unsigned int length);
/* SMMU IDs currently supported by the driver */ /* SMMU IDs currently supported by the driver */
enum { enum {
TEGRA_SMMU0, TEGRA_SMMU0 = 0U,
TEGRA_SMMU1, TEGRA_SMMU1,
TEGRA_SMMU2 TEGRA_SMMU2
}; };
static uint32_t tegra_smmu_read_32(uint32_t smmu_id, uint32_t off) static uint32_t tegra_smmu_read_32(uint32_t smmu_id, uint32_t off)
{ {
uint32_t ret = 0U;
#if defined(TEGRA_SMMU0_BASE) #if defined(TEGRA_SMMU0_BASE)
if (smmu_id == TEGRA_SMMU0) if (smmu_id == TEGRA_SMMU0) {
return mmio_read_32(TEGRA_SMMU0_BASE + off); ret = mmio_read_32(TEGRA_SMMU0_BASE + (uint64_t)off);
}
#endif #endif
#if defined(TEGRA_SMMU1_BASE) #if defined(TEGRA_SMMU1_BASE)
if (smmu_id == TEGRA_SMMU1) if (smmu_id == TEGRA_SMMU1) {
return mmio_read_32(TEGRA_SMMU1_BASE + off); ret = mmio_read_32(TEGRA_SMMU1_BASE + (uint64_t)off);
}
#endif #endif
#if defined(TEGRA_SMMU2_BASE) #if defined(TEGRA_SMMU2_BASE)
if (smmu_id == TEGRA_SMMU2) if (smmu_id == TEGRA_SMMU2) {
return mmio_read_32(TEGRA_SMMU2_BASE + off); ret = mmio_read_32(TEGRA_SMMU2_BASE + (uint64_t)off);
}
#endif #endif
return 0; return ret;
} }
static void tegra_smmu_write_32(uint32_t smmu_id, static void tegra_smmu_write_32(uint32_t smmu_id,
uint32_t off, uint32_t val) uint32_t off, uint32_t val)
{ {
#if defined(TEGRA_SMMU0_BASE) #if defined(TEGRA_SMMU0_BASE)
if (smmu_id == TEGRA_SMMU0) if (smmu_id == TEGRA_SMMU0) {
mmio_write_32(TEGRA_SMMU0_BASE + off, val); mmio_write_32(TEGRA_SMMU0_BASE + (uint64_t)off, val);
}
#endif #endif
#if defined(TEGRA_SMMU1_BASE) #if defined(TEGRA_SMMU1_BASE)
if (smmu_id == TEGRA_SMMU1) if (smmu_id == TEGRA_SMMU1) {
mmio_write_32(TEGRA_SMMU1_BASE + off, val); mmio_write_32(TEGRA_SMMU1_BASE + (uint64_t)off, val);
}
#endif #endif
#if defined(TEGRA_SMMU2_BASE) #if defined(TEGRA_SMMU2_BASE)
if (smmu_id == TEGRA_SMMU2) if (smmu_id == TEGRA_SMMU2) {
mmio_write_32(TEGRA_SMMU2_BASE + off, val); mmio_write_32(TEGRA_SMMU2_BASE + (uint64_t)off, val);
}
#endif #endif
} }
...@@ -70,23 +78,23 @@ void tegra_smmu_save_context(uint64_t smmu_ctx_addr) ...@@ -70,23 +78,23 @@ void tegra_smmu_save_context(uint64_t smmu_ctx_addr)
{ {
uint32_t i, num_entries = 0; uint32_t i, num_entries = 0;
smmu_regs_t *smmu_ctx_regs; smmu_regs_t *smmu_ctx_regs;
plat_params_from_bl2_t *params_from_bl2 = bl31_get_plat_params(); const plat_params_from_bl2_t *params_from_bl2 = bl31_get_plat_params();
uint64_t tzdram_base = params_from_bl2->tzdram_base; uint64_t tzdram_base = params_from_bl2->tzdram_base;
uint64_t tzdram_end = tzdram_base + params_from_bl2->tzdram_size; uint64_t tzdram_end = tzdram_base + params_from_bl2->tzdram_size;
uint32_t reg_id1, pgshift, cb_size; uint32_t reg_id1, pgshift, cb_size;
/* sanity check SMMU settings c*/ /* sanity check SMMU settings c*/
reg_id1 = mmio_read_32((TEGRA_SMMU0_BASE + SMMU_GNSR0_IDR1)); reg_id1 = mmio_read_32((TEGRA_SMMU0_BASE + SMMU_GNSR0_IDR1));
pgshift = (reg_id1 & ID1_PAGESIZE) ? 16 : 12; pgshift = ((reg_id1 & ID1_PAGESIZE) != 0U) ? 16U : 12U;
cb_size = (2 << pgshift) * \ cb_size = ((uint32_t)2 << pgshift) * \
(1 << (((reg_id1 >> ID1_NUMPAGENDXB_SHIFT) & ID1_NUMPAGENDXB_MASK) + 1)); ((uint32_t)1 << (((reg_id1 >> ID1_NUMPAGENDXB_SHIFT) & ID1_NUMPAGENDXB_MASK) + 1U));
assert(!((pgshift != PGSHIFT) || (cb_size != CB_SIZE))); assert(!((pgshift != PGSHIFT) || (cb_size != CB_SIZE)));
assert((smmu_ctx_addr >= tzdram_base) && (smmu_ctx_addr <= tzdram_end)); assert((smmu_ctx_addr >= tzdram_base) && (smmu_ctx_addr <= tzdram_end));
/* get SMMU context table */ /* get SMMU context table */
smmu_ctx_regs = plat_get_smmu_ctx(); smmu_ctx_regs = plat_get_smmu_ctx();
assert(smmu_ctx_regs); assert(smmu_ctx_regs != NULL);
/* /*
* smmu_ctx_regs[0].val contains the size of the context table minus * smmu_ctx_regs[0].val contains the size of the context table minus
...@@ -98,18 +106,20 @@ void tegra_smmu_save_context(uint64_t smmu_ctx_addr) ...@@ -98,18 +106,20 @@ void tegra_smmu_save_context(uint64_t smmu_ctx_addr)
} }
/* panic if the sizes do not match */ /* panic if the sizes do not match */
if (num_entries != smmu_ctx_regs[0].val) if (num_entries != smmu_ctx_regs[0].val) {
panic(); panic();
}
/* save SMMU register values */ /* save SMMU register values */
for (i = 1; i < num_entries; i++) for (i = 1U; i < num_entries; i++) {
smmu_ctx_regs[i].val = mmio_read_32(smmu_ctx_regs[i].reg); smmu_ctx_regs[i].val = mmio_read_32(smmu_ctx_regs[i].reg);
}
/* increment by 1 to take care of the last entry */ /* increment by 1 to take care of the last entry */
num_entries++; num_entries++;
/* Save SMMU config settings */ /* Save SMMU config settings */
memcpy16((void *)(uintptr_t)smmu_ctx_addr, (void *)smmu_ctx_regs, (void)memcpy16((uint8_t *)smmu_ctx_addr, (uint8_t *)smmu_ctx_regs,
(sizeof(smmu_regs_t) * num_entries)); (sizeof(smmu_regs_t) * num_entries));
/* save the SMMU table address */ /* save the SMMU table address */
...@@ -128,17 +138,18 @@ void tegra_smmu_save_context(uint64_t smmu_ctx_addr) ...@@ -128,17 +138,18 @@ void tegra_smmu_save_context(uint64_t smmu_ctx_addr)
void tegra_smmu_init(void) void tegra_smmu_init(void)
{ {
uint32_t val, cb_idx, smmu_id, ctx_base; uint32_t val, cb_idx, smmu_id, ctx_base;
uint32_t smmu_counter = plat_get_num_smmu_devices();
for (smmu_id = 0; smmu_id < NUM_SMMU_DEVICES; smmu_id++) { for (smmu_id = 0U; smmu_id < smmu_counter; smmu_id++) {
/* Program the SMMU pagesize and reset CACHE_LOCK bit */ /* Program the SMMU pagesize and reset CACHE_LOCK bit */
val = tegra_smmu_read_32(smmu_id, SMMU_GSR0_SECURE_ACR); val = tegra_smmu_read_32(smmu_id, SMMU_GSR0_SECURE_ACR);
val |= SMMU_GSR0_PGSIZE_64K; val |= SMMU_GSR0_PGSIZE_64K;
val &= ~SMMU_ACR_CACHE_LOCK_ENABLE_BIT; val &= (uint32_t)~SMMU_ACR_CACHE_LOCK_ENABLE_BIT;
tegra_smmu_write_32(smmu_id, SMMU_GSR0_SECURE_ACR, val); tegra_smmu_write_32(smmu_id, SMMU_GSR0_SECURE_ACR, val);
/* reset CACHE LOCK bit for NS Aux. Config. Register */ /* reset CACHE LOCK bit for NS Aux. Config. Register */
val = tegra_smmu_read_32(smmu_id, SMMU_GNSR_ACR); val = tegra_smmu_read_32(smmu_id, SMMU_GNSR_ACR);
val &= ~SMMU_ACR_CACHE_LOCK_ENABLE_BIT; val &= (uint32_t)~SMMU_ACR_CACHE_LOCK_ENABLE_BIT;
tegra_smmu_write_32(smmu_id, SMMU_GNSR_ACR, val); tegra_smmu_write_32(smmu_id, SMMU_GNSR_ACR, val);
/* disable TCU prefetch for all contexts */ /* disable TCU prefetch for all contexts */
...@@ -147,19 +158,19 @@ void tegra_smmu_init(void) ...@@ -147,19 +158,19 @@ void tegra_smmu_init(void)
for (cb_idx = 0; cb_idx < SMMU_CONTEXT_BANK_MAX_IDX; cb_idx++) { for (cb_idx = 0; cb_idx < SMMU_CONTEXT_BANK_MAX_IDX; cb_idx++) {
val = tegra_smmu_read_32(smmu_id, val = tegra_smmu_read_32(smmu_id,
ctx_base + (SMMU_GSR0_PGSIZE_64K * cb_idx)); ctx_base + (SMMU_GSR0_PGSIZE_64K * cb_idx));
val &= ~SMMU_CBn_ACTLR_CPRE_BIT; val &= (uint32_t)~SMMU_CBn_ACTLR_CPRE_BIT;
tegra_smmu_write_32(smmu_id, ctx_base + tegra_smmu_write_32(smmu_id, ctx_base +
(SMMU_GSR0_PGSIZE_64K * cb_idx), val); (SMMU_GSR0_PGSIZE_64K * cb_idx), val);
} }
/* set CACHE LOCK bit for NS Aux. Config. Register */ /* set CACHE LOCK bit for NS Aux. Config. Register */
val = tegra_smmu_read_32(smmu_id, SMMU_GNSR_ACR); val = tegra_smmu_read_32(smmu_id, SMMU_GNSR_ACR);
val |= SMMU_ACR_CACHE_LOCK_ENABLE_BIT; val |= (uint32_t)SMMU_ACR_CACHE_LOCK_ENABLE_BIT;
tegra_smmu_write_32(smmu_id, SMMU_GNSR_ACR, val); tegra_smmu_write_32(smmu_id, SMMU_GNSR_ACR, val);
/* set CACHE LOCK bit for S Aux. Config. Register */ /* set CACHE LOCK bit for S Aux. Config. Register */
val = tegra_smmu_read_32(smmu_id, SMMU_GSR0_SECURE_ACR); val = tegra_smmu_read_32(smmu_id, SMMU_GSR0_SECURE_ACR);
val |= SMMU_ACR_CACHE_LOCK_ENABLE_BIT; val |= (uint32_t)SMMU_ACR_CACHE_LOCK_ENABLE_BIT;
tegra_smmu_write_32(smmu_id, SMMU_GSR0_SECURE_ACR, val); tegra_smmu_write_32(smmu_id, SMMU_GSR0_SECURE_ACR, val);
} }
} }
/*
* Copyright (c) 2017, ARM Limited and Contributors. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
/*******************************************************************************
* The profiler stores the timestamps captured during cold boot to the shared
* memory for the non-secure world. The non-secure world driver parses the
* shared memory block and writes the contents to a file on the device, which
* can be later extracted for analysis.
*
* Profiler memory map
*
* TOP --------------------------- ---
* Trusted OS timestamps 3KB
* --------------------------- ---
* Trusted Firmware timestamps 1KB
* BASE --------------------------- ---
*
******************************************************************************/
#include <arch.h>
#include <arch_helpers.h>
#include <assert.h>
#include <mmio.h>
#include <profiler.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdint.h>
#include <string.h>
#include <utils_def.h>
#include <xlat_tables_v2.h>
static uint64_t shmem_base_addr;
#define MAX_PROFILER_RECORDS U(16)
#define TAG_LEN_BYTES U(56)
/*******************************************************************************
* Profiler entry format
******************************************************************************/
typedef struct {
/* text explaining the timestamp location in code */
uint8_t tag[TAG_LEN_BYTES];
/* timestamp value */
uint64_t timestamp;
} profiler_rec_t;
static profiler_rec_t *head, *cur, *tail;
static uint32_t tmr;
static bool is_shmem_buf_mapped;
/*******************************************************************************
* Initialise the profiling library
******************************************************************************/
void boot_profiler_init(uint64_t shmem_base, uint32_t tmr_base)
{
uint64_t shmem_end_base;
assert(shmem_base != ULL(0));
assert(tmr_base != U(0));
/* store the buffer address */
shmem_base_addr = shmem_base;
/* calculate the base address of the last record */
shmem_end_base = shmem_base + (sizeof(profiler_rec_t) *
(MAX_PROFILER_RECORDS - U(1)));
/* calculate the head, tail and cur values */
head = (profiler_rec_t *)shmem_base;
tail = (profiler_rec_t *)shmem_end_base;
cur = head;
/* timer used to get the current timestamp */
tmr = tmr_base;
}
/*******************************************************************************
* Add tag and timestamp to profiler
******************************************************************************/
void boot_profiler_add_record(const char *str)
{
unsigned int len;
/* calculate the length of the tag */
if (((unsigned int)strlen(str) + U(1)) > TAG_LEN_BYTES) {
len = TAG_LEN_BYTES;
} else {
len = (unsigned int)strlen(str) + U(1);
}
if (head != NULL) {
/*
* The profiler runs with/without MMU enabled. Check
* if MMU is enabled and memmap the shmem buffer, in
* case it is.
*/
if ((!is_shmem_buf_mapped) &&
((read_sctlr_el3() & SCTLR_M_BIT) != U(0))) {
(void)mmap_add_dynamic_region(shmem_base_addr,
shmem_base_addr,
PROFILER_SIZE_BYTES,
(MT_NS | MT_RW | MT_EXECUTE_NEVER));
is_shmem_buf_mapped = true;
}
/* write the tag and timestamp to buffer */
(void)snprintf((char *)cur->tag, len, "%s", str);
cur->timestamp = mmio_read_32(tmr);
/* start from head if we reached the end */
if (cur == tail) {
cur = head;
} else {
cur++;
}
}
}
/*******************************************************************************
* Deinint the profiler
******************************************************************************/
void boot_profiler_deinit(void)
{
if (shmem_base_addr != ULL(0)) {
/* clean up resources */
cur = NULL;
head = NULL;
tail = NULL;
/* flush the shmem for it to be visible to the NS world */
flush_dcache_range(shmem_base_addr, PROFILER_SIZE_BYTES);
/* unmap the shmem buffer */
if (is_shmem_buf_mapped) {
(void)mmap_remove_dynamic_region(shmem_base_addr,
PROFILER_SIZE_BYTES);
}
}
}
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
#include <plat/common/platform.h> #include <plat/common/platform.h>
#include <memctrl.h> #include <memctrl.h>
#include <profiler.h>
#include <tegra_def.h> #include <tegra_def.h>
#include <tegra_platform.h> #include <tegra_platform.h>
#include <tegra_private.h> #include <tegra_private.h>
...@@ -40,20 +41,19 @@ extern void memcpy16(void *dest, const void *src, unsigned int length); ...@@ -40,20 +41,19 @@ extern void memcpy16(void *dest, const void *src, unsigned int length);
* of trusted SRAM * of trusted SRAM
******************************************************************************/ ******************************************************************************/
IMPORT_SYM(unsigned long, __RW_START__, BL31_RW_START); IMPORT_SYM(uint64_t, __RW_START__, BL31_RW_START);
IMPORT_SYM(unsigned long, __RW_END__, BL31_RW_END); IMPORT_SYM(uint64_t, __RW_END__, BL31_RW_END);
IMPORT_SYM(unsigned long, __RODATA_START__, BL31_RODATA_BASE); IMPORT_SYM(uint64_t, __RODATA_START__, BL31_RODATA_BASE);
IMPORT_SYM(unsigned long, __RODATA_END__, BL31_RODATA_END); IMPORT_SYM(uint64_t, __RODATA_END__, BL31_RODATA_END);
IMPORT_SYM(unsigned long, __TEXT_START__, TEXT_START); IMPORT_SYM(uint64_t, __TEXT_START__, TEXT_START);
IMPORT_SYM(unsigned long, __TEXT_END__, TEXT_END); IMPORT_SYM(uint64_t, __TEXT_END__, TEXT_END);
extern uint64_t tegra_bl31_phys_base; extern uint64_t tegra_bl31_phys_base;
extern uint64_t tegra_console_base; extern uint64_t tegra_console_base;
static entry_point_info_t bl33_image_ep_info, bl32_image_ep_info; static entry_point_info_t bl33_image_ep_info, bl32_image_ep_info;
static plat_params_from_bl2_t plat_bl31_params_from_bl2 = { static plat_params_from_bl2_t plat_bl31_params_from_bl2 = {
.tzdram_size = (uint64_t)TZDRAM_SIZE .tzdram_size = TZDRAM_SIZE
}; };
static unsigned long bl32_mem_size; static unsigned long bl32_mem_size;
static unsigned long bl32_boot_params; static unsigned long bl32_boot_params;
...@@ -93,14 +93,16 @@ plat_params_from_bl2_t *plat_get_bl31_plat_params(void) ...@@ -93,14 +93,16 @@ plat_params_from_bl2_t *plat_get_bl31_plat_params(void)
******************************************************************************/ ******************************************************************************/
entry_point_info_t *bl31_plat_get_next_image_ep_info(uint32_t type) entry_point_info_t *bl31_plat_get_next_image_ep_info(uint32_t type)
{ {
if (type == NON_SECURE) entry_point_info_t *ep = NULL;
return &bl33_image_ep_info;
/* return BL32 entry point info if it is valid */ /* return BL32 entry point info if it is valid */
if (type == SECURE && bl32_image_ep_info.pc) if (type == NON_SECURE) {
return &bl32_image_ep_info; ep = &bl33_image_ep_info;
} else if ((type == SECURE) && (bl32_image_ep_info.pc != 0U)) {
ep = &bl32_image_ep_info;
}
return NULL; return ep;
} }
/******************************************************************************* /*******************************************************************************
...@@ -124,6 +126,7 @@ void bl31_early_platform_setup2(u_register_t arg0, u_register_t arg1, ...@@ -124,6 +126,7 @@ void bl31_early_platform_setup2(u_register_t arg0, u_register_t arg1,
image_info_t bl32_img_info = { {0} }; image_info_t bl32_img_info = { {0} };
uint64_t tzdram_start, tzdram_end, bl32_start, bl32_end; uint64_t tzdram_start, tzdram_end, bl32_start, bl32_end;
uint32_t console_clock; uint32_t console_clock;
int32_t ret;
/* /*
* For RESET_TO_BL31 systems, BL31 is the first bootloader to run so * For RESET_TO_BL31 systems, BL31 is the first bootloader to run so
...@@ -131,20 +134,22 @@ void bl31_early_platform_setup2(u_register_t arg0, u_register_t arg1, ...@@ -131,20 +134,22 @@ void bl31_early_platform_setup2(u_register_t arg0, u_register_t arg1,
* might use custom ways to get arguments, so provide handlers which * might use custom ways to get arguments, so provide handlers which
* they can override. * they can override.
*/ */
if (arg_from_bl2 == NULL) if (arg_from_bl2 == NULL) {
arg_from_bl2 = plat_get_bl31_params(); arg_from_bl2 = plat_get_bl31_params();
if (plat_params == NULL) }
if (plat_params == NULL) {
plat_params = plat_get_bl31_plat_params(); plat_params = plat_get_bl31_plat_params();
}
/* /*
* Copy BL3-3, BL3-2 entry point information. * Copy BL3-3, BL3-2 entry point information.
* They are stored in Secure RAM, in BL2's address space. * They are stored in Secure RAM, in BL2's address space.
*/ */
assert(arg_from_bl2); assert(arg_from_bl2 != NULL);
assert(arg_from_bl2->bl33_ep_info); assert(arg_from_bl2->bl33_ep_info != NULL);
bl33_image_ep_info = *arg_from_bl2->bl33_ep_info; bl33_image_ep_info = *arg_from_bl2->bl33_ep_info;
if (arg_from_bl2->bl32_ep_info) { if (arg_from_bl2->bl32_ep_info != NULL) {
bl32_image_ep_info = *arg_from_bl2->bl32_ep_info; bl32_image_ep_info = *arg_from_bl2->bl32_ep_info;
bl32_mem_size = arg_from_bl2->bl32_ep_info->args.arg0; bl32_mem_size = arg_from_bl2->bl32_ep_info->args.arg0;
bl32_boot_params = arg_from_bl2->bl32_ep_info->args.arg2; bl32_boot_params = arg_from_bl2->bl32_ep_info->args.arg2;
...@@ -153,7 +158,7 @@ void bl31_early_platform_setup2(u_register_t arg0, u_register_t arg1, ...@@ -153,7 +158,7 @@ void bl31_early_platform_setup2(u_register_t arg0, u_register_t arg1,
/* /*
* Parse platform specific parameters - TZDRAM aperture base and size * Parse platform specific parameters - TZDRAM aperture base and size
*/ */
assert(plat_params); assert(plat_params != NULL);
plat_bl31_params_from_bl2.tzdram_base = plat_params->tzdram_base; plat_bl31_params_from_bl2.tzdram_base = plat_params->tzdram_base;
plat_bl31_params_from_bl2.tzdram_size = plat_params->tzdram_size; plat_bl31_params_from_bl2.tzdram_size = plat_params->tzdram_size;
plat_bl31_params_from_bl2.uart_id = plat_params->uart_id; plat_bl31_params_from_bl2.uart_id = plat_params->uart_id;
...@@ -163,14 +168,15 @@ void bl31_early_platform_setup2(u_register_t arg0, u_register_t arg1, ...@@ -163,14 +168,15 @@ void bl31_early_platform_setup2(u_register_t arg0, u_register_t arg1,
* It is very important that we run either from TZDRAM or TZSRAM base. * It is very important that we run either from TZDRAM or TZSRAM base.
* Add an explicit check here. * Add an explicit check here.
*/ */
if ((plat_bl31_params_from_bl2.tzdram_base != BL31_BASE) && if ((plat_bl31_params_from_bl2.tzdram_base != (uint64_t)BL31_BASE) &&
(TEGRA_TZRAM_BASE != BL31_BASE)) (TEGRA_TZRAM_BASE != BL31_BASE)) {
panic(); panic();
}
/* /*
* Reference clock used by the FPGAs is a lot slower. * Reference clock used by the FPGAs is a lot slower.
*/ */
if (tegra_platform_is_fpga() == 1U) { if (tegra_platform_is_fpga()) {
console_clock = TEGRA_BOOT_UART_CLK_13_MHZ; console_clock = TEGRA_BOOT_UART_CLK_13_MHZ;
} else { } else {
console_clock = TEGRA_BOOT_UART_CLK_408_MHZ; console_clock = TEGRA_BOOT_UART_CLK_408_MHZ;
...@@ -182,14 +188,40 @@ void bl31_early_platform_setup2(u_register_t arg0, u_register_t arg1, ...@@ -182,14 +188,40 @@ void bl31_early_platform_setup2(u_register_t arg0, u_register_t arg1,
*/ */
tegra_console_base = plat_get_console_from_id(plat_params->uart_id); tegra_console_base = plat_get_console_from_id(plat_params->uart_id);
if (tegra_console_base != (uint64_t)0) { if (tegra_console_base != 0U) {
/* /*
* Configure the UART port to be used as the console * Configure the UART port to be used as the console
*/ */
console_init(tegra_console_base, console_clock, (void)console_init(tegra_console_base, console_clock,
TEGRA_CONSOLE_BAUDRATE); TEGRA_CONSOLE_BAUDRATE);
} }
/*
* The previous bootloader passes the base address of the shared memory
* location to store the boot profiler logs. Sanity check the
* address and initilise the profiler library, if it looks ok.
*/
if (plat_params->boot_profiler_shmem_base != 0ULL) {
ret = bl31_check_ns_address(plat_params->boot_profiler_shmem_base,
PROFILER_SIZE_BYTES);
if (ret == (int32_t)0) {
/* store the membase for the profiler lib */
plat_bl31_params_from_bl2.boot_profiler_shmem_base =
plat_params->boot_profiler_shmem_base;
/* initialise the profiler library */
boot_profiler_init(plat_params->boot_profiler_shmem_base,
TEGRA_TMRUS_BASE);
}
}
/*
* Add timestamp for platform early setup entry.
*/
boot_profiler_add_record("[TF] early setup entry");
/* /*
* Initialize delay timer * Initialize delay timer
*/ */
...@@ -199,14 +231,14 @@ void bl31_early_platform_setup2(u_register_t arg0, u_register_t arg1, ...@@ -199,14 +231,14 @@ void bl31_early_platform_setup2(u_register_t arg0, u_register_t arg1,
* Do initial security configuration to allow DRAM/device access. * Do initial security configuration to allow DRAM/device access.
*/ */
tegra_memctrl_tzdram_setup(plat_bl31_params_from_bl2.tzdram_base, tegra_memctrl_tzdram_setup(plat_bl31_params_from_bl2.tzdram_base,
plat_bl31_params_from_bl2.tzdram_size); (uint32_t)plat_bl31_params_from_bl2.tzdram_size);
/* /*
* The previous bootloader might not have placed the BL32 image * The previous bootloader might not have placed the BL32 image
* inside the TZDRAM. We check the BL32 image info to find out * inside the TZDRAM. We check the BL32 image info to find out
* the base/PC values and relocate the image if necessary. * the base/PC values and relocate the image if necessary.
*/ */
if (arg_from_bl2->bl32_image_info) { if (arg_from_bl2->bl32_image_info != NULL) {
bl32_img_info = *arg_from_bl2->bl32_image_info; bl32_img_info = *arg_from_bl2->bl32_image_info;
...@@ -223,11 +255,11 @@ void bl31_early_platform_setup2(u_register_t arg0, u_register_t arg1, ...@@ -223,11 +255,11 @@ void bl31_early_platform_setup2(u_register_t arg0, u_register_t arg1,
assert(bl32_image_ep_info.pc < tzdram_end); assert(bl32_image_ep_info.pc < tzdram_end);
/* relocate BL32 */ /* relocate BL32 */
if (bl32_start >= tzdram_end || bl32_end <= tzdram_start) { if ((bl32_start >= tzdram_end) || (bl32_end <= tzdram_start)) {
INFO("Relocate BL32 to TZDRAM\n"); INFO("Relocate BL32 to TZDRAM\n");
memcpy16((void *)(uintptr_t)bl32_image_ep_info.pc, (void)memcpy16((void *)(uintptr_t)bl32_image_ep_info.pc,
(void *)(uintptr_t)bl32_start, (void *)(uintptr_t)bl32_start,
bl32_img_info.image_size); bl32_img_info.image_size);
...@@ -240,6 +272,11 @@ void bl31_early_platform_setup2(u_register_t arg0, u_register_t arg1, ...@@ -240,6 +272,11 @@ void bl31_early_platform_setup2(u_register_t arg0, u_register_t arg1,
/* Early platform setup for Tegra SoCs */ /* Early platform setup for Tegra SoCs */
plat_early_platform_setup(); plat_early_platform_setup();
/*
* Add timestamp for platform early setup exit.
*/
boot_profiler_add_record("[TF] early setup exit");
INFO("BL3-1: Boot CPU: %s Processor [%lx]\n", INFO("BL3-1: Boot CPU: %s Processor [%lx]\n",
(((read_midr() >> MIDR_IMPL_SHIFT) & MIDR_IMPL_MASK) (((read_midr() >> MIDR_IMPL_SHIFT) & MIDR_IMPL_MASK)
== DENVER_IMPL) ? "Denver" : "ARM", read_mpidr()); == DENVER_IMPL) ? "Denver" : "ARM", read_mpidr());
...@@ -256,6 +293,9 @@ void plat_trusty_set_boot_args(aapcs64_params_t *args) ...@@ -256,6 +293,9 @@ void plat_trusty_set_boot_args(aapcs64_params_t *args)
if (args->arg4 != 0U) { if (args->arg4 != 0U) {
args->arg2 = args->arg4; args->arg2 = args->arg4;
} }
/* Profiler Carveout Base */
args->arg3 = args->arg5;
} }
#endif #endif
...@@ -264,7 +304,10 @@ void plat_trusty_set_boot_args(aapcs64_params_t *args) ...@@ -264,7 +304,10 @@ void plat_trusty_set_boot_args(aapcs64_params_t *args)
******************************************************************************/ ******************************************************************************/
void bl31_platform_setup(void) void bl31_platform_setup(void)
{ {
uint32_t tmp_reg; /*
* Add timestamp for platform setup entry.
*/
boot_profiler_add_record("[TF] plat setup entry");
/* Initialize the gic cpu and distributor interfaces */ /* Initialize the gic cpu and distributor interfaces */
plat_gic_setup(); plat_gic_setup();
...@@ -285,9 +328,10 @@ void bl31_platform_setup(void) ...@@ -285,9 +328,10 @@ void bl31_platform_setup(void)
*/ */
tegra_memctrl_tzram_setup(TEGRA_TZRAM_BASE, TEGRA_TZRAM_SIZE); tegra_memctrl_tzram_setup(TEGRA_TZRAM_BASE, TEGRA_TZRAM_SIZE);
/* Set the next EL to be AArch64 */ /*
tmp_reg = SCR_RES1_BITS | SCR_RW_BIT; * Add timestamp for platform setup exit.
write_scr(tmp_reg); */
boot_profiler_add_record("[TF] plat setup exit");
INFO("BL3-1: Tegra platform setup complete\n"); INFO("BL3-1: Tegra platform setup complete\n");
} }
...@@ -297,6 +341,15 @@ void bl31_platform_setup(void) ...@@ -297,6 +341,15 @@ void bl31_platform_setup(void)
******************************************************************************/ ******************************************************************************/
void bl31_plat_runtime_setup(void) void bl31_plat_runtime_setup(void)
{ {
/*
* During cold boot, it is observed that the arbitration
* bit is set in the Memory controller leading to false
* error interrupts in the non-secure world. To avoid
* this, clean the interrupt status register before
* booting into the non-secure world
*/
tegra_memctrl_clear_pending_interrupts();
/* /*
* During boot, USB3 and flash media (SDMMC/SATA) devices need * During boot, USB3 and flash media (SDMMC/SATA) devices need
* access to IRAM. Because these clients connect to the MC and * access to IRAM. Because these clients connect to the MC and
...@@ -307,6 +360,12 @@ void bl31_plat_runtime_setup(void) ...@@ -307,6 +360,12 @@ void bl31_plat_runtime_setup(void)
* disabled before we jump to the non-secure world. * disabled before we jump to the non-secure world.
*/ */
tegra_memctrl_disable_ahb_redirection(); tegra_memctrl_disable_ahb_redirection();
/*
* Add final timestamp before exiting BL31.
*/
boot_profiler_add_record("[TF] bl31 exit");
boot_profiler_deinit();
} }
/******************************************************************************* /*******************************************************************************
...@@ -315,17 +374,22 @@ void bl31_plat_runtime_setup(void) ...@@ -315,17 +374,22 @@ void bl31_plat_runtime_setup(void)
******************************************************************************/ ******************************************************************************/
void bl31_plat_arch_setup(void) void bl31_plat_arch_setup(void)
{ {
unsigned long rw_start = BL31_RW_START; uint64_t rw_start = BL31_RW_START;
unsigned long rw_size = BL31_RW_END - BL31_RW_START; uint64_t rw_size = BL31_RW_END - BL31_RW_START;
unsigned long rodata_start = BL31_RODATA_BASE; uint64_t rodata_start = BL31_RODATA_BASE;
unsigned long rodata_size = BL31_RODATA_END - BL31_RODATA_BASE; uint64_t rodata_size = BL31_RODATA_END - BL31_RODATA_BASE;
unsigned long code_base = TEXT_START; uint64_t code_base = TEXT_START;
unsigned long code_size = TEXT_END - TEXT_START; uint64_t code_size = TEXT_END - TEXT_START;
const mmap_region_t *plat_mmio_map = NULL; const mmap_region_t *plat_mmio_map = NULL;
#if USE_COHERENT_MEM #if USE_COHERENT_MEM
unsigned long coh_start, coh_size; uint32_t coh_start, coh_size;
#endif #endif
plat_params_from_bl2_t *params_from_bl2 = bl31_get_plat_params(); const plat_params_from_bl2_t *params_from_bl2 = bl31_get_plat_params();
/*
* Add timestamp for arch setup entry.
*/
boot_profiler_add_record("[TF] arch setup entry");
/* add memory regions */ /* add memory regions */
mmap_add_region(rw_start, rw_start, mmap_add_region(rw_start, rw_start,
...@@ -352,21 +416,22 @@ void bl31_plat_arch_setup(void) ...@@ -352,21 +416,22 @@ void bl31_plat_arch_setup(void)
mmap_add_region(coh_start, coh_start, mmap_add_region(coh_start, coh_start,
coh_size, coh_size,
MT_DEVICE | MT_RW | MT_SECURE); (uint8_t)MT_DEVICE | (uint8_t)MT_RW | (uint8_t)MT_SECURE);
#endif #endif
/* map on-chip free running uS timer */ /* map on-chip free running uS timer */
mmap_add_region(page_align((uint64_t)TEGRA_TMRUS_BASE, 0), mmap_add_region(page_align(TEGRA_TMRUS_BASE, 0),
page_align((uint64_t)TEGRA_TMRUS_BASE, 0), page_align(TEGRA_TMRUS_BASE, 0),
(uint64_t)TEGRA_TMRUS_SIZE, TEGRA_TMRUS_SIZE,
MT_DEVICE | MT_RO | MT_SECURE); (uint8_t)MT_DEVICE | (uint8_t)MT_RO | (uint8_t)MT_SECURE);
/* add MMIO space */ /* add MMIO space */
plat_mmio_map = plat_get_mmio_map(); plat_mmio_map = plat_get_mmio_map();
if (plat_mmio_map) if (plat_mmio_map != NULL) {
mmap_add(plat_mmio_map); mmap_add(plat_mmio_map);
else } else {
WARN("MMIO map not available\n"); WARN("MMIO map not available\n");
}
/* set up translation tables */ /* set up translation tables */
init_xlat_tables(); init_xlat_tables();
...@@ -374,33 +439,41 @@ void bl31_plat_arch_setup(void) ...@@ -374,33 +439,41 @@ void bl31_plat_arch_setup(void)
/* enable the MMU */ /* enable the MMU */
enable_mmu_el3(0); enable_mmu_el3(0);
/*
* Add timestamp for arch setup exit.
*/
boot_profiler_add_record("[TF] arch setup exit");
INFO("BL3-1: Tegra: MMU enabled\n"); INFO("BL3-1: Tegra: MMU enabled\n");
} }
/******************************************************************************* /*******************************************************************************
* Check if the given NS DRAM range is valid * Check if the given NS DRAM range is valid
******************************************************************************/ ******************************************************************************/
int bl31_check_ns_address(uint64_t base, uint64_t size_in_bytes) int32_t bl31_check_ns_address(uint64_t base, uint64_t size_in_bytes)
{ {
uint64_t end = base + size_in_bytes; uint64_t end = base + size_in_bytes - U(1);
int32_t ret = 0;
/* /*
* Check if the NS DRAM address is valid * Check if the NS DRAM address is valid
*/ */
if ((base < TEGRA_DRAM_BASE) || (end > TEGRA_DRAM_END)) { if ((base < TEGRA_DRAM_BASE) || (base >= TEGRA_DRAM_END) ||
(end > TEGRA_DRAM_END)) {
ERROR("NS address is out-of-bounds!\n"); ERROR("NS address is out-of-bounds!\n");
return -EFAULT; ret = -EFAULT;
} }
/* /*
* TZDRAM aperture contains the BL31 and BL32 images, so we need * TZDRAM aperture contains the BL31 and BL32 images, so we need
* to check if the NS DRAM range overlaps the TZDRAM aperture. * to check if the NS DRAM range overlaps the TZDRAM aperture.
*/ */
if ((base < TZDRAM_END) && (end > tegra_bl31_phys_base)) { if ((base < (uint64_t)TZDRAM_END) && (end > tegra_bl31_phys_base)) {
ERROR("NS address overlaps TZDRAM!\n"); ERROR("NS address overlaps TZDRAM!\n");
return -ENOTSUP; ret = -ENOTSUP;
} }
/* valid NS address */ /* valid NS address */
return 0; return ret;
} }
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
# #
PLAT_INCLUDES := -Iplat/nvidia/tegra/include/drivers \ PLAT_INCLUDES := -Iplat/nvidia/tegra/include/drivers \
-Iplat/nvidia/tegra/include/lib \
-Iplat/nvidia/tegra/include \ -Iplat/nvidia/tegra/include \
-Iplat/nvidia/tegra/include/${TARGET_SOC} -Iplat/nvidia/tegra/include/${TARGET_SOC}
...@@ -25,6 +26,7 @@ BL31_SOURCES += drivers/console/aarch64/console.S \ ...@@ -25,6 +26,7 @@ BL31_SOURCES += drivers/console/aarch64/console.S \
${TEGRA_GICv2_SOURCES} \ ${TEGRA_GICv2_SOURCES} \
${COMMON_DIR}/aarch64/tegra_helpers.S \ ${COMMON_DIR}/aarch64/tegra_helpers.S \
${COMMON_DIR}/drivers/pmc/pmc.c \ ${COMMON_DIR}/drivers/pmc/pmc.c \
${COMMON_DIR}/lib/debug/profiler.c \
${COMMON_DIR}/tegra_bl31_setup.c \ ${COMMON_DIR}/tegra_bl31_setup.c \
${COMMON_DIR}/tegra_delay_timer.c \ ${COMMON_DIR}/tegra_delay_timer.c \
${COMMON_DIR}/tegra_fiq_glue.c \ ${COMMON_DIR}/tegra_fiq_glue.c \
......
...@@ -65,7 +65,7 @@ static uint64_t tegra_fiq_interrupt_handler(uint32_t id, ...@@ -65,7 +65,7 @@ static uint64_t tegra_fiq_interrupt_handler(uint32_t id,
* Set the new ELR to continue execution in the NS world using the * Set the new ELR to continue execution in the NS world using the
* FIQ handler registered earlier. * FIQ handler registered earlier.
*/ */
assert(ns_fiq_handler_addr); assert(ns_fiq_handler_addr != 0ULL);
write_ctx_reg((el3state_ctx), (uint32_t)(CTX_ELR_EL3), (ns_fiq_handler_addr)); write_ctx_reg((el3state_ctx), (uint32_t)(CTX_ELR_EL3), (ns_fiq_handler_addr));
/* /*
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
* Tegra platforms * Tegra platforms
******************************************************************************/ ******************************************************************************/
typedef enum tegra_platform { typedef enum tegra_platform {
TEGRA_PLATFORM_SILICON = 0, TEGRA_PLATFORM_SILICON = 0U,
TEGRA_PLATFORM_QT, TEGRA_PLATFORM_QT,
TEGRA_PLATFORM_FPGA, TEGRA_PLATFORM_FPGA,
TEGRA_PLATFORM_EMULATION, TEGRA_PLATFORM_EMULATION,
...@@ -83,7 +83,7 @@ bool tegra_chipid_is_t132(void) ...@@ -83,7 +83,7 @@ bool tegra_chipid_is_t132(void)
{ {
uint32_t chip_id = ((tegra_get_chipid() >> CHIP_ID_SHIFT) & CHIP_ID_MASK); uint32_t chip_id = ((tegra_get_chipid() >> CHIP_ID_SHIFT) & CHIP_ID_MASK);
return (chip_id == (uint32_t)TEGRA_CHIPID_TEGRA13); return (chip_id == TEGRA_CHIPID_TEGRA13);
} }
bool tegra_chipid_is_t186(void) bool tegra_chipid_is_t186(void)
...@@ -97,12 +97,12 @@ bool tegra_chipid_is_t210(void) ...@@ -97,12 +97,12 @@ bool tegra_chipid_is_t210(void)
{ {
uint32_t chip_id = (tegra_get_chipid() >> CHIP_ID_SHIFT) & CHIP_ID_MASK; uint32_t chip_id = (tegra_get_chipid() >> CHIP_ID_SHIFT) & CHIP_ID_MASK;
return (chip_id == (uint32_t)TEGRA_CHIPID_TEGRA21); return (chip_id == TEGRA_CHIPID_TEGRA21);
} }
bool tegra_chipid_is_t210_b01(void) bool tegra_chipid_is_t210_b01(void)
{ {
return (tegra_chipid_is_t210() && (tegra_get_chipid_major() == 0x2UL)); return (tegra_chipid_is_t210() && (tegra_get_chipid_major() == 0x2U));
} }
/* /*
......
...@@ -50,37 +50,42 @@ uint8_t tegra_fake_system_suspend; ...@@ -50,37 +50,42 @@ uint8_t tegra_fake_system_suspend;
#pragma weak tegra_soc_prepare_system_off #pragma weak tegra_soc_prepare_system_off
#pragma weak tegra_soc_get_target_pwr_state #pragma weak tegra_soc_get_target_pwr_state
int tegra_soc_pwr_domain_suspend_pwrdown_early(const psci_power_state_t *target_state) int32_t tegra_soc_pwr_domain_suspend_pwrdown_early(const psci_power_state_t *target_state)
{ {
return PSCI_E_NOT_SUPPORTED; return PSCI_E_NOT_SUPPORTED;
} }
int tegra_soc_pwr_domain_suspend(const psci_power_state_t *target_state) int32_t tegra_soc_pwr_domain_suspend(const psci_power_state_t *target_state)
{ {
(void)target_state;
return PSCI_E_NOT_SUPPORTED; return PSCI_E_NOT_SUPPORTED;
} }
int tegra_soc_pwr_domain_on(u_register_t mpidr) int32_t tegra_soc_pwr_domain_on(u_register_t mpidr)
{ {
(void)mpidr;
return PSCI_E_SUCCESS; return PSCI_E_SUCCESS;
} }
int tegra_soc_pwr_domain_off(const psci_power_state_t *target_state) int32_t tegra_soc_pwr_domain_off(const psci_power_state_t *target_state)
{ {
(void)target_state;
return PSCI_E_SUCCESS; return PSCI_E_SUCCESS;
} }
int tegra_soc_pwr_domain_on_finish(const psci_power_state_t *target_state) int32_t tegra_soc_pwr_domain_on_finish(const psci_power_state_t *target_state)
{ {
(void)target_state;
return PSCI_E_SUCCESS; return PSCI_E_SUCCESS;
} }
int tegra_soc_pwr_domain_power_down_wfi(const psci_power_state_t *target_state) int32_t tegra_soc_pwr_domain_power_down_wfi(const psci_power_state_t *target_state)
{ {
(void)target_state;
return PSCI_E_SUCCESS; return PSCI_E_SUCCESS;
} }
int tegra_soc_prepare_system_reset(void) int32_t tegra_soc_prepare_system_reset(void)
{ {
return PSCI_E_SUCCESS; return PSCI_E_SUCCESS;
} }
...@@ -91,19 +96,26 @@ __dead2 void tegra_soc_prepare_system_off(void) ...@@ -91,19 +96,26 @@ __dead2 void tegra_soc_prepare_system_off(void)
panic(); panic();
} }
plat_local_state_t tegra_soc_get_target_pwr_state(unsigned int lvl, plat_local_state_t tegra_soc_get_target_pwr_state(uint32_t lvl,
const plat_local_state_t *states, const plat_local_state_t *states,
unsigned int ncpu) uint32_t ncpu)
{ {
plat_local_state_t target = PLAT_MAX_OFF_STATE, temp; plat_local_state_t target = PLAT_MAX_OFF_STATE, temp;
uint32_t num_cpu = ncpu;
const plat_local_state_t *local_state = states;
(void)lvl;
assert(ncpu); assert(ncpu != 0U);
do { do {
temp = *states++; temp = *local_state;
if ((temp < target)) if ((temp < target)) {
target = temp; target = temp;
} while (--ncpu); }
--num_cpu;
local_state++;
} while (num_cpu != 0U);
return target; return target;
} }
...@@ -117,8 +129,9 @@ plat_local_state_t tegra_soc_get_target_pwr_state(unsigned int lvl, ...@@ -117,8 +129,9 @@ plat_local_state_t tegra_soc_get_target_pwr_state(unsigned int lvl,
void tegra_get_sys_suspend_power_state(psci_power_state_t *req_state) void tegra_get_sys_suspend_power_state(psci_power_state_t *req_state)
{ {
/* all affinities use system suspend state id */ /* all affinities use system suspend state id */
for (uint32_t i = MPIDR_AFFLVL0; i <= PLAT_MAX_PWR_LVL; i++) for (uint32_t i = MPIDR_AFFLVL0; i <= PLAT_MAX_PWR_LVL; i++) {
req_state->pwr_domain_state[i] = PSTATE_ID_SOC_POWERDN; req_state->pwr_domain_state[i] = PSTATE_ID_SOC_POWERDN;
}
} }
/******************************************************************************* /*******************************************************************************
...@@ -126,6 +139,8 @@ void tegra_get_sys_suspend_power_state(psci_power_state_t *req_state) ...@@ -126,6 +139,8 @@ void tegra_get_sys_suspend_power_state(psci_power_state_t *req_state)
******************************************************************************/ ******************************************************************************/
void tegra_cpu_standby(plat_local_state_t cpu_state) void tegra_cpu_standby(plat_local_state_t cpu_state)
{ {
(void)cpu_state;
/* /*
* Enter standby state * Enter standby state
* dsb is good practice before using wfi to enter low power states * dsb is good practice before using wfi to enter low power states
...@@ -138,7 +153,7 @@ void tegra_cpu_standby(plat_local_state_t cpu_state) ...@@ -138,7 +153,7 @@ void tegra_cpu_standby(plat_local_state_t cpu_state)
* Handler called when an affinity instance is about to be turned on. The * Handler called when an affinity instance is about to be turned on. The
* level and mpidr determine the affinity instance. * level and mpidr determine the affinity instance.
******************************************************************************/ ******************************************************************************/
int tegra_pwr_domain_on(u_register_t mpidr) int32_t tegra_pwr_domain_on(u_register_t mpidr)
{ {
return tegra_soc_pwr_domain_on(mpidr); return tegra_soc_pwr_domain_on(mpidr);
} }
...@@ -149,7 +164,7 @@ int tegra_pwr_domain_on(u_register_t mpidr) ...@@ -149,7 +164,7 @@ int tegra_pwr_domain_on(u_register_t mpidr)
******************************************************************************/ ******************************************************************************/
void tegra_pwr_domain_off(const psci_power_state_t *target_state) void tegra_pwr_domain_off(const psci_power_state_t *target_state)
{ {
tegra_soc_pwr_domain_off(target_state); (void)tegra_soc_pwr_domain_off(target_state);
} }
/******************************************************************************* /*******************************************************************************
...@@ -169,12 +184,13 @@ void tegra_pwr_domain_suspend_pwrdown_early(const psci_power_state_t *target_sta ...@@ -169,12 +184,13 @@ void tegra_pwr_domain_suspend_pwrdown_early(const psci_power_state_t *target_sta
******************************************************************************/ ******************************************************************************/
void tegra_pwr_domain_suspend(const psci_power_state_t *target_state) void tegra_pwr_domain_suspend(const psci_power_state_t *target_state)
{ {
tegra_soc_pwr_domain_suspend(target_state); (void)tegra_soc_pwr_domain_suspend(target_state);
/* Disable console if we are entering deep sleep. */ /* Disable console if we are entering deep sleep. */
if (target_state->pwr_domain_state[PLAT_MAX_PWR_LVL] == if (target_state->pwr_domain_state[PLAT_MAX_PWR_LVL] ==
PSTATE_ID_SOC_POWERDN) PSTATE_ID_SOC_POWERDN) {
console_uninit(); (void)console_uninit();
}
/* disable GICC */ /* disable GICC */
tegra_gic_cpuif_deactivate(); tegra_gic_cpuif_deactivate();
...@@ -191,7 +207,7 @@ __dead2 void tegra_pwr_domain_power_down_wfi(const psci_power_state_t ...@@ -191,7 +207,7 @@ __dead2 void tegra_pwr_domain_power_down_wfi(const psci_power_state_t
uint64_t rmr_el3 = 0; uint64_t rmr_el3 = 0;
/* call the chip's power down handler */ /* call the chip's power down handler */
tegra_soc_pwr_domain_power_down_wfi(target_state); (void)tegra_soc_pwr_domain_power_down_wfi(target_state);
/* /*
* If we are in fake system suspend mode, ensure we start doing * If we are in fake system suspend mode, ensure we start doing
...@@ -222,7 +238,7 @@ __dead2 void tegra_pwr_domain_power_down_wfi(const psci_power_state_t ...@@ -222,7 +238,7 @@ __dead2 void tegra_pwr_domain_power_down_wfi(const psci_power_state_t
******************************************************************************/ ******************************************************************************/
void tegra_pwr_domain_on_finish(const psci_power_state_t *target_state) void tegra_pwr_domain_on_finish(const psci_power_state_t *target_state)
{ {
plat_params_from_bl2_t *plat_params; const plat_params_from_bl2_t *plat_params;
uint32_t console_clock; uint32_t console_clock;
/* /*
...@@ -239,15 +255,15 @@ void tegra_pwr_domain_on_finish(const psci_power_state_t *target_state) ...@@ -239,15 +255,15 @@ void tegra_pwr_domain_on_finish(const psci_power_state_t *target_state)
/* /*
* Reference clock used by the FPGAs is a lot slower. * Reference clock used by the FPGAs is a lot slower.
*/ */
if (tegra_platform_is_fpga() == 1U) { if (tegra_platform_is_fpga()) {
console_clock = TEGRA_BOOT_UART_CLK_13_MHZ; console_clock = TEGRA_BOOT_UART_CLK_13_MHZ;
} else { } else {
console_clock = TEGRA_BOOT_UART_CLK_408_MHZ; console_clock = TEGRA_BOOT_UART_CLK_408_MHZ;
} }
/* Initialize the runtime console */ /* Initialize the runtime console */
if (tegra_console_base != (uint64_t)0) { if (tegra_console_base != 0ULL) {
console_init(tegra_console_base, console_clock, (void)console_init(tegra_console_base, console_clock,
TEGRA_CONSOLE_BAUDRATE); TEGRA_CONSOLE_BAUDRATE);
} }
...@@ -262,7 +278,7 @@ void tegra_pwr_domain_on_finish(const psci_power_state_t *target_state) ...@@ -262,7 +278,7 @@ void tegra_pwr_domain_on_finish(const psci_power_state_t *target_state)
*/ */
plat_params = bl31_get_plat_params(); plat_params = bl31_get_plat_params();
tegra_memctrl_tzdram_setup(plat_params->tzdram_base, tegra_memctrl_tzdram_setup(plat_params->tzdram_base,
plat_params->tzdram_size); (uint32_t)plat_params->tzdram_size);
/* /*
* Set up the TZRAM memory aperture to allow only secure world * Set up the TZRAM memory aperture to allow only secure world
...@@ -274,7 +290,7 @@ void tegra_pwr_domain_on_finish(const psci_power_state_t *target_state) ...@@ -274,7 +290,7 @@ void tegra_pwr_domain_on_finish(const psci_power_state_t *target_state)
/* /*
* Reset hardware settings. * Reset hardware settings.
*/ */
tegra_soc_pwr_domain_on_finish(target_state); (void)tegra_soc_pwr_domain_on_finish(target_state);
} }
/******************************************************************************* /*******************************************************************************
...@@ -305,7 +321,7 @@ __dead2 void tegra_system_reset(void) ...@@ -305,7 +321,7 @@ __dead2 void tegra_system_reset(void)
INFO("Restarting system...\n"); INFO("Restarting system...\n");
/* per-SoC system reset handler */ /* per-SoC system reset handler */
tegra_soc_prepare_system_reset(); (void)tegra_soc_prepare_system_reset();
/* /*
* Program the PMC in order to restart the system. * Program the PMC in order to restart the system.
...@@ -316,10 +332,10 @@ __dead2 void tegra_system_reset(void) ...@@ -316,10 +332,10 @@ __dead2 void tegra_system_reset(void)
/******************************************************************************* /*******************************************************************************
* Handler called to check the validity of the power state parameter. * Handler called to check the validity of the power state parameter.
******************************************************************************/ ******************************************************************************/
int32_t tegra_validate_power_state(unsigned int power_state, int32_t tegra_validate_power_state(uint32_t power_state,
psci_power_state_t *req_state) psci_power_state_t *req_state)
{ {
assert(req_state); assert(req_state != NULL);
return tegra_soc_validate_power_state(power_state, req_state); return tegra_soc_validate_power_state(power_state, req_state);
} }
...@@ -327,16 +343,19 @@ int32_t tegra_validate_power_state(unsigned int power_state, ...@@ -327,16 +343,19 @@ int32_t tegra_validate_power_state(unsigned int power_state,
/******************************************************************************* /*******************************************************************************
* Platform handler called to check the validity of the non secure entrypoint. * Platform handler called to check the validity of the non secure entrypoint.
******************************************************************************/ ******************************************************************************/
int tegra_validate_ns_entrypoint(uintptr_t entrypoint) int32_t tegra_validate_ns_entrypoint(uintptr_t entrypoint)
{ {
int32_t ret = PSCI_E_INVALID_ADDRESS;
/* /*
* Check if the non secure entrypoint lies within the non * Check if the non secure entrypoint lies within the non
* secure DRAM. * secure DRAM.
*/ */
if ((entrypoint >= TEGRA_DRAM_BASE) && (entrypoint <= TEGRA_DRAM_END)) if ((entrypoint >= TEGRA_DRAM_BASE) && (entrypoint <= TEGRA_DRAM_END)) {
return PSCI_E_SUCCESS; ret = PSCI_E_SUCCESS;
}
return PSCI_E_INVALID_ADDRESS; return ret;
} }
/******************************************************************************* /*******************************************************************************
...@@ -376,7 +395,7 @@ int plat_setup_psci_ops(uintptr_t sec_entrypoint, ...@@ -376,7 +395,7 @@ int plat_setup_psci_ops(uintptr_t sec_entrypoint,
/* /*
* Reset hardware settings. * Reset hardware settings.
*/ */
tegra_soc_pwr_domain_on_finish(&target_state); (void)tegra_soc_pwr_domain_on_finish(&target_state);
/* /*
* Initialize PSCI ops struct * Initialize PSCI ops struct
......
...@@ -69,7 +69,7 @@ uintptr_t tegra_sip_handler(uint32_t smc_fid, ...@@ -69,7 +69,7 @@ uintptr_t tegra_sip_handler(uint32_t smc_fid,
void *handle, void *handle,
u_register_t flags) u_register_t flags)
{ {
uint32_t regval; uint32_t regval, local_x2_32 = (uint32_t)x2;
int32_t err; int32_t err;
/* Check if this is a SoC specific SiP */ /* Check if this is a SoC specific SiP */
...@@ -84,14 +84,11 @@ uintptr_t tegra_sip_handler(uint32_t smc_fid, ...@@ -84,14 +84,11 @@ uintptr_t tegra_sip_handler(uint32_t smc_fid,
case TEGRA_SIP_NEW_VIDEOMEM_REGION: case TEGRA_SIP_NEW_VIDEOMEM_REGION:
/* clean up the high bits */
x2 = (uint32_t)x2;
/* /*
* Check if Video Memory overlaps TZDRAM (contains bl31/bl32) * Check if Video Memory overlaps TZDRAM (contains bl31/bl32)
* or falls outside of the valid DRAM range * or falls outside of the valid DRAM range
*/ */
err = bl31_check_ns_address(x1, x2); err = bl31_check_ns_address(x1, local_x2_32);
if (err != 0) { if (err != 0) {
SMC_RET1(handle, (uint64_t)err); SMC_RET1(handle, (uint64_t)err);
} }
...@@ -99,9 +96,9 @@ uintptr_t tegra_sip_handler(uint32_t smc_fid, ...@@ -99,9 +96,9 @@ uintptr_t tegra_sip_handler(uint32_t smc_fid,
/* /*
* Check if Video Memory is aligned to 1MB. * Check if Video Memory is aligned to 1MB.
*/ */
if (((x1 & 0xFFFFFU) != 0U) || ((x2 & 0xFFFFFU) != 0U)) { if (((x1 & 0xFFFFFU) != 0U) || ((local_x2_32 & 0xFFFFFU) != 0U)) {
ERROR("Unaligned Video Memory base address!\n"); ERROR("Unaligned Video Memory base address!\n");
SMC_RET1(handle, -ENOTSUP); SMC_RET1(handle, (uint64_t)-ENOTSUP);
} }
/* /*
...@@ -111,13 +108,13 @@ uintptr_t tegra_sip_handler(uint32_t smc_fid, ...@@ -111,13 +108,13 @@ uintptr_t tegra_sip_handler(uint32_t smc_fid,
*/ */
regval = mmio_read_32(TEGRA_CAR_RESET_BASE + regval = mmio_read_32(TEGRA_CAR_RESET_BASE +
TEGRA_GPU_RESET_REG_OFFSET); TEGRA_GPU_RESET_REG_OFFSET);
if ((regval & GPU_RESET_BIT) == 0UL) { if ((regval & GPU_RESET_BIT) == 0U) {
ERROR("GPU not in reset! Video Memory setup failed\n"); ERROR("GPU not in reset! Video Memory setup failed\n");
SMC_RET1(handle, -ENOTSUP); SMC_RET1(handle, (uint64_t)-ENOTSUP);
} }
/* new video memory carveout settings */ /* new video memory carveout settings */
tegra_memctrl_videomem_setup(x1, (uint32_t)x2); tegra_memctrl_videomem_setup(x1, local_x2_32);
SMC_RET1(handle, 0); SMC_RET1(handle, 0);
......
...@@ -23,10 +23,14 @@ int32_t plat_core_pos_by_mpidr(u_register_t mpidr) ...@@ -23,10 +23,14 @@ int32_t plat_core_pos_by_mpidr(u_register_t mpidr)
u_register_t cluster_id, cpu_id; u_register_t cluster_id, cpu_id;
int32_t result; int32_t result;
cluster_id = (mpidr >> (u_register_t)MPIDR_AFF1_SHIFT) & (u_register_t)MPIDR_AFFLVL_MASK; cluster_id = (mpidr >> (u_register_t)MPIDR_AFF1_SHIFT) &
cpu_id = (mpidr >> (u_register_t)MPIDR_AFF0_SHIFT) & (u_register_t)MPIDR_AFFLVL_MASK; (u_register_t)MPIDR_AFFLVL_MASK;
cpu_id = (mpidr >> (u_register_t)MPIDR_AFF0_SHIFT) &
result = (int32_t)cpu_id + ((int32_t)cluster_id * 4); (u_register_t)MPIDR_AFFLVL_MASK;
/* CorePos = CoreId + (ClusterId * cpus per cluster) */
result = (int32_t)cpu_id + ((int32_t)cluster_id *
PLATFORM_MAX_CPUS_PER_CLUSTER);
if (cluster_id >= (u_register_t)PLATFORM_CLUSTER_COUNT) { if (cluster_id >= (u_register_t)PLATFORM_CLUSTER_COUNT) {
result = PSCI_E_NOT_PRESENT; result = PSCI_E_NOT_PRESENT;
......
...@@ -10,25 +10,25 @@ ...@@ -10,25 +10,25 @@
#include <stdint.h> #include <stdint.h>
/* macro to enable clock to the Atomics block */ /* macro to enable clock to the Atomics block */
#define CAR_ENABLE_ATOMICS (1UL << 16) #define CAR_ENABLE_ATOMICS (1U << 16)
/* command to get the channel base addresses from bpmp */ /* command to get the channel base addresses from bpmp */
#define ATOMIC_CMD_GET 4UL #define ATOMIC_CMD_GET 4U
/* Hardware IRQ # used to signal bpmp of an incoming command */ /* Hardware IRQ # used to signal bpmp of an incoming command */
#define INT_SHR_SEM_OUTBOX_FULL 6UL #define INT_SHR_SEM_OUTBOX_FULL 6U
/* macros to decode the bpmp's state */ /* macros to decode the bpmp's state */
#define CH_MASK(ch) (0x3UL << ((ch) * 2UL)) #define CH_MASK(ch) ((uint32_t)0x3 << ((ch) * 2U))
#define MA_FREE(ch) (0x2UL << ((ch) * 2UL)) #define MA_FREE(ch) ((uint32_t)0x2 << ((ch) * 2U))
#define MA_ACKD(ch) (0x3UL << ((ch) * 2UL)) #define MA_ACKD(ch) ((uint32_t)0x3 << ((ch) * 2U))
/* response from bpmp to indicate it has powered up */ /* response from bpmp to indicate it has powered up */
#define SIGN_OF_LIFE 0xAAAAAAAAUL #define SIGN_OF_LIFE 0xAAAAAAAAU
/* flags to indicate bpmp driver's state */ /* flags to indicate bpmp driver's state */
#define BPMP_INIT_COMPLETE 0xBEEFF00DUL #define BPMP_INIT_COMPLETE 0xBEEFF00DU
#define BPMP_INIT_PENDING 0xDEADBEEFUL #define BPMP_INIT_PENDING 0xDEADBEEFU
/* requests serviced by the bpmp */ /* requests serviced by the bpmp */
#define MRQ_PING 0 #define MRQ_PING 0
...@@ -64,14 +64,14 @@ ...@@ -64,14 +64,14 @@
#define TEGRA_PM_SC7 23 #define TEGRA_PM_SC7 23
/* flag to indicate if entry into a CCx power state is allowed */ /* flag to indicate if entry into a CCx power state is allowed */
#define BPMP_CCx_ALLOWED 0UL #define BPMP_CCx_ALLOWED 0U
/* number of communication channels to interact with the bpmp */ /* number of communication channels to interact with the bpmp */
#define NR_CHANNELS 4U #define NR_CHANNELS 4U
/* flag to ask bpmp to acknowledge command packet */ /* flag to ask bpmp to acknowledge command packet */
#define NO_ACK (0UL << 0UL) #define NO_ACK (0U << 0U)
#define DO_ACK (1UL << 0UL) #define DO_ACK (1U << 0U)
/* size of the command/response data */ /* size of the command/response data */
#define MSG_DATA_MAX_SZ 120U #define MSG_DATA_MAX_SZ 120U
......
/*
* Copyright (c) 2017, ARM Limited and Contributors. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
#ifndef __GPCDMA_H__
#define __GPCDMA_H__
#include <stdint.h>
void tegra_gpcdma_memcpy(uint64_t dst_addr, uint64_t src_addr,
uint32_t num_bytes);
void tegra_gpcdma_zeromem(uint64_t dst_addr, uint32_t num_bytes);
#endif /* __GPCDMA_H__ */
...@@ -13,5 +13,6 @@ void tegra_memctrl_tzdram_setup(uint64_t phys_base, uint32_t size_in_bytes); ...@@ -13,5 +13,6 @@ void tegra_memctrl_tzdram_setup(uint64_t phys_base, uint32_t size_in_bytes);
void tegra_memctrl_tzram_setup(uint64_t phys_base, uint32_t size_in_bytes); void tegra_memctrl_tzram_setup(uint64_t phys_base, uint32_t size_in_bytes);
void tegra_memctrl_videomem_setup(uint64_t phys_base, uint32_t size_in_bytes); void tegra_memctrl_videomem_setup(uint64_t phys_base, uint32_t size_in_bytes);
void tegra_memctrl_disable_ahb_redirection(void); void tegra_memctrl_disable_ahb_redirection(void);
void tegra_memctrl_clear_pending_interrupts(void);
#endif /* MEMCTRL_H */ #endif /* MEMCTRL_H */
...@@ -17,177 +17,177 @@ ...@@ -17,177 +17,177 @@
* StreamID to indicate no SMMU translations (requests to be steered on the * StreamID to indicate no SMMU translations (requests to be steered on the
* SMMU bypass path) * SMMU bypass path)
******************************************************************************/ ******************************************************************************/
#define MC_STREAM_ID_MAX 0x7F #define MC_STREAM_ID_MAX 0x7FU
/******************************************************************************* /*******************************************************************************
* Stream ID Override Config registers * Stream ID Override Config registers
******************************************************************************/ ******************************************************************************/
#define MC_STREAMID_OVERRIDE_CFG_PTCR 0x000 #define MC_STREAMID_OVERRIDE_CFG_PTCR 0x000U
#define MC_STREAMID_OVERRIDE_CFG_AFIR 0x070 #define MC_STREAMID_OVERRIDE_CFG_AFIR 0x070U
#define MC_STREAMID_OVERRIDE_CFG_HDAR 0x0A8 #define MC_STREAMID_OVERRIDE_CFG_HDAR 0x0A8U
#define MC_STREAMID_OVERRIDE_CFG_HOST1XDMAR 0x0B0 #define MC_STREAMID_OVERRIDE_CFG_HOST1XDMAR 0x0B0U
#define MC_STREAMID_OVERRIDE_CFG_NVENCSRD 0x0E0 #define MC_STREAMID_OVERRIDE_CFG_NVENCSRD 0x0E0U
#define MC_STREAMID_OVERRIDE_CFG_SATAR 0x0F8 #define MC_STREAMID_OVERRIDE_CFG_SATAR 0x0F8U
#define MC_STREAMID_OVERRIDE_CFG_MPCORER 0x138 #define MC_STREAMID_OVERRIDE_CFG_MPCORER 0x138U
#define MC_STREAMID_OVERRIDE_CFG_NVENCSWR 0x158 #define MC_STREAMID_OVERRIDE_CFG_NVENCSWR 0x158U
#define MC_STREAMID_OVERRIDE_CFG_AFIW 0x188 #define MC_STREAMID_OVERRIDE_CFG_AFIW 0x188U
#define MC_STREAMID_OVERRIDE_CFG_HDAW 0x1A8 #define MC_STREAMID_OVERRIDE_CFG_HDAW 0x1A8U
#define MC_STREAMID_OVERRIDE_CFG_MPCOREW 0x1C8 #define MC_STREAMID_OVERRIDE_CFG_MPCOREW 0x1C8U
#define MC_STREAMID_OVERRIDE_CFG_SATAW 0x1E8 #define MC_STREAMID_OVERRIDE_CFG_SATAW 0x1E8U
#define MC_STREAMID_OVERRIDE_CFG_ISPRA 0x220 #define MC_STREAMID_OVERRIDE_CFG_ISPRA 0x220U
#define MC_STREAMID_OVERRIDE_CFG_ISPWA 0x230 #define MC_STREAMID_OVERRIDE_CFG_ISPWA 0x230U
#define MC_STREAMID_OVERRIDE_CFG_ISPWB 0x238 #define MC_STREAMID_OVERRIDE_CFG_ISPWB 0x238U
#define MC_STREAMID_OVERRIDE_CFG_XUSB_HOSTR 0x250 #define MC_STREAMID_OVERRIDE_CFG_XUSB_HOSTR 0x250U
#define MC_STREAMID_OVERRIDE_CFG_XUSB_HOSTW 0x258 #define MC_STREAMID_OVERRIDE_CFG_XUSB_HOSTW 0x258U
#define MC_STREAMID_OVERRIDE_CFG_XUSB_DEVR 0x260 #define MC_STREAMID_OVERRIDE_CFG_XUSB_DEVR 0x260U
#define MC_STREAMID_OVERRIDE_CFG_XUSB_DEVW 0x268 #define MC_STREAMID_OVERRIDE_CFG_XUSB_DEVW 0x268U
#define MC_STREAMID_OVERRIDE_CFG_TSECSRD 0x2A0 #define MC_STREAMID_OVERRIDE_CFG_TSECSRD 0x2A0U
#define MC_STREAMID_OVERRIDE_CFG_TSECSWR 0x2A8 #define MC_STREAMID_OVERRIDE_CFG_TSECSWR 0x2A8U
#define MC_STREAMID_OVERRIDE_CFG_GPUSRD 0x2C0 #define MC_STREAMID_OVERRIDE_CFG_GPUSRD 0x2C0U
#define MC_STREAMID_OVERRIDE_CFG_GPUSWR 0x2C8 #define MC_STREAMID_OVERRIDE_CFG_GPUSWR 0x2C8U
#define MC_STREAMID_OVERRIDE_CFG_SDMMCRA 0x300 #define MC_STREAMID_OVERRIDE_CFG_SDMMCRA 0x300U
#define MC_STREAMID_OVERRIDE_CFG_SDMMCRAA 0x308 #define MC_STREAMID_OVERRIDE_CFG_SDMMCRAA 0x308U
#define MC_STREAMID_OVERRIDE_CFG_SDMMCR 0x310 #define MC_STREAMID_OVERRIDE_CFG_SDMMCR 0x310U
#define MC_STREAMID_OVERRIDE_CFG_SDMMCRAB 0x318 #define MC_STREAMID_OVERRIDE_CFG_SDMMCRAB 0x318U
#define MC_STREAMID_OVERRIDE_CFG_SDMMCWA 0x320 #define MC_STREAMID_OVERRIDE_CFG_SDMMCWA 0x320U
#define MC_STREAMID_OVERRIDE_CFG_SDMMCWAA 0x328 #define MC_STREAMID_OVERRIDE_CFG_SDMMCWAA 0x328U
#define MC_STREAMID_OVERRIDE_CFG_SDMMCW 0x330 #define MC_STREAMID_OVERRIDE_CFG_SDMMCW 0x330U
#define MC_STREAMID_OVERRIDE_CFG_SDMMCWAB 0x338 #define MC_STREAMID_OVERRIDE_CFG_SDMMCWAB 0x338U
#define MC_STREAMID_OVERRIDE_CFG_VICSRD 0x360 #define MC_STREAMID_OVERRIDE_CFG_VICSRD 0x360U
#define MC_STREAMID_OVERRIDE_CFG_VICSWR 0x368 #define MC_STREAMID_OVERRIDE_CFG_VICSWR 0x368U
#define MC_STREAMID_OVERRIDE_CFG_VIW 0x390 #define MC_STREAMID_OVERRIDE_CFG_VIW 0x390U
#define MC_STREAMID_OVERRIDE_CFG_NVDECSRD 0x3C0 #define MC_STREAMID_OVERRIDE_CFG_NVDECSRD 0x3C0U
#define MC_STREAMID_OVERRIDE_CFG_NVDECSWR 0x3C8 #define MC_STREAMID_OVERRIDE_CFG_NVDECSWR 0x3C8U
#define MC_STREAMID_OVERRIDE_CFG_APER 0x3D0 #define MC_STREAMID_OVERRIDE_CFG_APER 0x3D0U
#define MC_STREAMID_OVERRIDE_CFG_APEW 0x3D8 #define MC_STREAMID_OVERRIDE_CFG_APEW 0x3D8U
#define MC_STREAMID_OVERRIDE_CFG_NVJPGSRD 0x3F0 #define MC_STREAMID_OVERRIDE_CFG_NVJPGSRD 0x3F0U
#define MC_STREAMID_OVERRIDE_CFG_NVJPGSWR 0x3F8 #define MC_STREAMID_OVERRIDE_CFG_NVJPGSWR 0x3F8U
#define MC_STREAMID_OVERRIDE_CFG_SESRD 0x400 #define MC_STREAMID_OVERRIDE_CFG_SESRD 0x400U
#define MC_STREAMID_OVERRIDE_CFG_SESWR 0x408 #define MC_STREAMID_OVERRIDE_CFG_SESWR 0x408U
#define MC_STREAMID_OVERRIDE_CFG_ETRR 0x420 #define MC_STREAMID_OVERRIDE_CFG_ETRR 0x420U
#define MC_STREAMID_OVERRIDE_CFG_ETRW 0x428 #define MC_STREAMID_OVERRIDE_CFG_ETRW 0x428U
#define MC_STREAMID_OVERRIDE_CFG_TSECSRDB 0x430 #define MC_STREAMID_OVERRIDE_CFG_TSECSRDB 0x430U
#define MC_STREAMID_OVERRIDE_CFG_TSECSWRB 0x438 #define MC_STREAMID_OVERRIDE_CFG_TSECSWRB 0x438U
#define MC_STREAMID_OVERRIDE_CFG_GPUSRD2 0x440 #define MC_STREAMID_OVERRIDE_CFG_GPUSRD2 0x440U
#define MC_STREAMID_OVERRIDE_CFG_GPUSWR2 0x448 #define MC_STREAMID_OVERRIDE_CFG_GPUSWR2 0x448U
#define MC_STREAMID_OVERRIDE_CFG_AXISR 0x460 #define MC_STREAMID_OVERRIDE_CFG_AXISR 0x460U
#define MC_STREAMID_OVERRIDE_CFG_AXISW 0x468 #define MC_STREAMID_OVERRIDE_CFG_AXISW 0x468U
#define MC_STREAMID_OVERRIDE_CFG_EQOSR 0x470 #define MC_STREAMID_OVERRIDE_CFG_EQOSR 0x470U
#define MC_STREAMID_OVERRIDE_CFG_EQOSW 0x478 #define MC_STREAMID_OVERRIDE_CFG_EQOSW 0x478U
#define MC_STREAMID_OVERRIDE_CFG_UFSHCR 0x480 #define MC_STREAMID_OVERRIDE_CFG_UFSHCR 0x480U
#define MC_STREAMID_OVERRIDE_CFG_UFSHCW 0x488 #define MC_STREAMID_OVERRIDE_CFG_UFSHCW 0x488U
#define MC_STREAMID_OVERRIDE_CFG_NVDISPLAYR 0x490 #define MC_STREAMID_OVERRIDE_CFG_NVDISPLAYR 0x490U
#define MC_STREAMID_OVERRIDE_CFG_BPMPR 0x498 #define MC_STREAMID_OVERRIDE_CFG_BPMPR 0x498U
#define MC_STREAMID_OVERRIDE_CFG_BPMPW 0x4A0 #define MC_STREAMID_OVERRIDE_CFG_BPMPW 0x4A0U
#define MC_STREAMID_OVERRIDE_CFG_BPMPDMAR 0x4A8 #define MC_STREAMID_OVERRIDE_CFG_BPMPDMAR 0x4A8U
#define MC_STREAMID_OVERRIDE_CFG_BPMPDMAW 0x4B0 #define MC_STREAMID_OVERRIDE_CFG_BPMPDMAW 0x4B0U
#define MC_STREAMID_OVERRIDE_CFG_AONR 0x4B8 #define MC_STREAMID_OVERRIDE_CFG_AONR 0x4B8U
#define MC_STREAMID_OVERRIDE_CFG_AONW 0x4C0 #define MC_STREAMID_OVERRIDE_CFG_AONW 0x4C0U
#define MC_STREAMID_OVERRIDE_CFG_AONDMAR 0x4C8 #define MC_STREAMID_OVERRIDE_CFG_AONDMAR 0x4C8U
#define MC_STREAMID_OVERRIDE_CFG_AONDMAW 0x4D0 #define MC_STREAMID_OVERRIDE_CFG_AONDMAW 0x4D0U
#define MC_STREAMID_OVERRIDE_CFG_SCER 0x4D8 #define MC_STREAMID_OVERRIDE_CFG_SCER 0x4D8U
#define MC_STREAMID_OVERRIDE_CFG_SCEW 0x4E0 #define MC_STREAMID_OVERRIDE_CFG_SCEW 0x4E0U
#define MC_STREAMID_OVERRIDE_CFG_SCEDMAR 0x4E8 #define MC_STREAMID_OVERRIDE_CFG_SCEDMAR 0x4E8U
#define MC_STREAMID_OVERRIDE_CFG_SCEDMAW 0x4F0 #define MC_STREAMID_OVERRIDE_CFG_SCEDMAW 0x4F0U
#define MC_STREAMID_OVERRIDE_CFG_APEDMAR 0x4F8 #define MC_STREAMID_OVERRIDE_CFG_APEDMAR 0x4F8U
#define MC_STREAMID_OVERRIDE_CFG_APEDMAW 0x500 #define MC_STREAMID_OVERRIDE_CFG_APEDMAW 0x500U
#define MC_STREAMID_OVERRIDE_CFG_NVDISPLAYR1 0x508 #define MC_STREAMID_OVERRIDE_CFG_NVDISPLAYR1 0x508U
#define MC_STREAMID_OVERRIDE_CFG_VICSRD1 0x510 #define MC_STREAMID_OVERRIDE_CFG_VICSRD1 0x510U
#define MC_STREAMID_OVERRIDE_CFG_NVDECSRD1 0x518 #define MC_STREAMID_OVERRIDE_CFG_NVDECSRD1 0x518U
/******************************************************************************* /*******************************************************************************
* Macro to calculate Security cfg register addr from StreamID Override register * Macro to calculate Security cfg register addr from StreamID Override register
******************************************************************************/ ******************************************************************************/
#define MC_STREAMID_OVERRIDE_TO_SECURITY_CFG(addr) (addr + sizeof(uint32_t)) #define MC_STREAMID_OVERRIDE_TO_SECURITY_CFG(addr) ((addr) + (uint32_t)sizeof(uint32_t))
#define MC_TXN_OVERRIDE_CONFIG_COH_PATH_NO_OVERRIDE_SO_DEV (0UL << 4) #define MC_TXN_OVERRIDE_CONFIG_COH_PATH_NO_OVERRIDE_SO_DEV (0U << 4)
#define MC_TXN_OVERRIDE_CONFIG_COH_PATH_FORCE_NON_COHERENT_SO_DEV (1UL << 4) #define MC_TXN_OVERRIDE_CONFIG_COH_PATH_FORCE_NON_COHERENT_SO_DEV (1U << 4)
#define MC_TXN_OVERRIDE_CONFIG_COH_PATH_FORCE_COHERENT_SO_DEV (2UL << 4) #define MC_TXN_OVERRIDE_CONFIG_COH_PATH_FORCE_COHERENT_SO_DEV (2U << 4)
#define MC_TXN_OVERRIDE_CONFIG_COH_PATH_FORCE_COHERENT_SNOOP_SO_DEV (3UL << 4) #define MC_TXN_OVERRIDE_CONFIG_COH_PATH_FORCE_COHERENT_SNOOP_SO_DEV (3U << 4)
#define MC_TXN_OVERRIDE_CONFIG_COH_PATH_NO_OVERRIDE_NORMAL (0UL << 8) #define MC_TXN_OVERRIDE_CONFIG_COH_PATH_NO_OVERRIDE_NORMAL (0U << 8)
#define MC_TXN_OVERRIDE_CONFIG_COH_PATH_FORCE_NON_COHERENT_NORMAL (1UL << 8) #define MC_TXN_OVERRIDE_CONFIG_COH_PATH_FORCE_NON_COHERENT_NORMAL (1U << 8)
#define MC_TXN_OVERRIDE_CONFIG_COH_PATH_FORCE_COHERENT_NORMAL (2UL << 8) #define MC_TXN_OVERRIDE_CONFIG_COH_PATH_FORCE_COHERENT_NORMAL (2U << 8)
#define MC_TXN_OVERRIDE_CONFIG_COH_PATH_FORCE_COHERENT_SNOOP_NORMAL (3UL << 8) #define MC_TXN_OVERRIDE_CONFIG_COH_PATH_FORCE_COHERENT_SNOOP_NORMAL (3U << 8)
#define MC_TXN_OVERRIDE_CONFIG_CGID_SO_DEV_ZERO (0UL << 12) #define MC_TXN_OVERRIDE_CONFIG_CGID_SO_DEV_ZERO (0U << 12)
#define MC_TXN_OVERRIDE_CONFIG_CGID_SO_DEV_CLIENT_AXI_ID (1UL << 12) #define MC_TXN_OVERRIDE_CONFIG_CGID_SO_DEV_CLIENT_AXI_ID (1U << 12)
/******************************************************************************* /*******************************************************************************
* Memory Controller transaction override config registers * Memory Controller transaction override config registers
******************************************************************************/ ******************************************************************************/
#define MC_TXN_OVERRIDE_CONFIG_HDAR 0x10a8 #define MC_TXN_OVERRIDE_CONFIG_HDAR 0x10a8U
#define MC_TXN_OVERRIDE_CONFIG_BPMPW 0x14a0 #define MC_TXN_OVERRIDE_CONFIG_BPMPW 0x14a0U
#define MC_TXN_OVERRIDE_CONFIG_PTCR 0x1000 #define MC_TXN_OVERRIDE_CONFIG_PTCR 0x1000U
#define MC_TXN_OVERRIDE_CONFIG_NVDISPLAYR 0x1490 #define MC_TXN_OVERRIDE_CONFIG_NVDISPLAYR 0x1490U
#define MC_TXN_OVERRIDE_CONFIG_EQOSW 0x1478 #define MC_TXN_OVERRIDE_CONFIG_EQOSW 0x1478U
#define MC_TXN_OVERRIDE_CONFIG_NVJPGSWR 0x13f8 #define MC_TXN_OVERRIDE_CONFIG_NVJPGSWR 0x13f8U
#define MC_TXN_OVERRIDE_CONFIG_ISPRA 0x1220 #define MC_TXN_OVERRIDE_CONFIG_ISPRA 0x1220U
#define MC_TXN_OVERRIDE_CONFIG_SDMMCWAA 0x1328 #define MC_TXN_OVERRIDE_CONFIG_SDMMCWAA 0x1328U
#define MC_TXN_OVERRIDE_CONFIG_VICSRD 0x1360 #define MC_TXN_OVERRIDE_CONFIG_VICSRD 0x1360U
#define MC_TXN_OVERRIDE_CONFIG_MPCOREW 0x11c8 #define MC_TXN_OVERRIDE_CONFIG_MPCOREW 0x11c8U
#define MC_TXN_OVERRIDE_CONFIG_GPUSRD 0x12c0 #define MC_TXN_OVERRIDE_CONFIG_GPUSRD 0x12c0U
#define MC_TXN_OVERRIDE_CONFIG_AXISR 0x1460 #define MC_TXN_OVERRIDE_CONFIG_AXISR 0x1460U
#define MC_TXN_OVERRIDE_CONFIG_SCEDMAW 0x14f0 #define MC_TXN_OVERRIDE_CONFIG_SCEDMAW 0x14f0U
#define MC_TXN_OVERRIDE_CONFIG_SDMMCW 0x1330 #define MC_TXN_OVERRIDE_CONFIG_SDMMCW 0x1330U
#define MC_TXN_OVERRIDE_CONFIG_EQOSR 0x1470 #define MC_TXN_OVERRIDE_CONFIG_EQOSR 0x1470U
#define MC_TXN_OVERRIDE_CONFIG_APEDMAR 0x14f8 #define MC_TXN_OVERRIDE_CONFIG_APEDMAR 0x14f8U
#define MC_TXN_OVERRIDE_CONFIG_NVENCSRD 0x10e0 #define MC_TXN_OVERRIDE_CONFIG_NVENCSRD 0x10e0U
#define MC_TXN_OVERRIDE_CONFIG_SDMMCRAB 0x1318 #define MC_TXN_OVERRIDE_CONFIG_SDMMCRAB 0x1318U
#define MC_TXN_OVERRIDE_CONFIG_VICSRD1 0x1510 #define MC_TXN_OVERRIDE_CONFIG_VICSRD1 0x1510U
#define MC_TXN_OVERRIDE_CONFIG_BPMPDMAR 0x14a8 #define MC_TXN_OVERRIDE_CONFIG_BPMPDMAR 0x14a8U
#define MC_TXN_OVERRIDE_CONFIG_VIW 0x1390 #define MC_TXN_OVERRIDE_CONFIG_VIW 0x1390U
#define MC_TXN_OVERRIDE_CONFIG_SDMMCRAA 0x1308 #define MC_TXN_OVERRIDE_CONFIG_SDMMCRAA 0x1308U
#define MC_TXN_OVERRIDE_CONFIG_AXISW 0x1468 #define MC_TXN_OVERRIDE_CONFIG_AXISW 0x1468U
#define MC_TXN_OVERRIDE_CONFIG_XUSB_DEVR 0x1260 #define MC_TXN_OVERRIDE_CONFIG_XUSB_DEVR 0x1260U
#define MC_TXN_OVERRIDE_CONFIG_UFSHCR 0x1480 #define MC_TXN_OVERRIDE_CONFIG_UFSHCR 0x1480U
#define MC_TXN_OVERRIDE_CONFIG_TSECSWR 0x12a8 #define MC_TXN_OVERRIDE_CONFIG_TSECSWR 0x12a8U
#define MC_TXN_OVERRIDE_CONFIG_GPUSWR 0x12c8 #define MC_TXN_OVERRIDE_CONFIG_GPUSWR 0x12c8U
#define MC_TXN_OVERRIDE_CONFIG_SATAR 0x10f8 #define MC_TXN_OVERRIDE_CONFIG_SATAR 0x10f8U
#define MC_TXN_OVERRIDE_CONFIG_XUSB_HOSTW 0x1258 #define MC_TXN_OVERRIDE_CONFIG_XUSB_HOSTW 0x1258U
#define MC_TXN_OVERRIDE_CONFIG_TSECSWRB 0x1438 #define MC_TXN_OVERRIDE_CONFIG_TSECSWRB 0x1438U
#define MC_TXN_OVERRIDE_CONFIG_GPUSRD2 0x1440 #define MC_TXN_OVERRIDE_CONFIG_GPUSRD2 0x1440U
#define MC_TXN_OVERRIDE_CONFIG_SCEDMAR 0x14e8 #define MC_TXN_OVERRIDE_CONFIG_SCEDMAR 0x14e8U
#define MC_TXN_OVERRIDE_CONFIG_GPUSWR2 0x1448 #define MC_TXN_OVERRIDE_CONFIG_GPUSWR2 0x1448U
#define MC_TXN_OVERRIDE_CONFIG_AONDMAW 0x14d0 #define MC_TXN_OVERRIDE_CONFIG_AONDMAW 0x14d0U
#define MC_TXN_OVERRIDE_CONFIG_APEDMAW 0x1500 #define MC_TXN_OVERRIDE_CONFIG_APEDMAW 0x1500U
#define MC_TXN_OVERRIDE_CONFIG_AONW 0x14c0 #define MC_TXN_OVERRIDE_CONFIG_AONW 0x14c0U
#define MC_TXN_OVERRIDE_CONFIG_HOST1XDMAR 0x10b0 #define MC_TXN_OVERRIDE_CONFIG_HOST1XDMAR 0x10b0U
#define MC_TXN_OVERRIDE_CONFIG_ETRR 0x1420 #define MC_TXN_OVERRIDE_CONFIG_ETRR 0x1420U
#define MC_TXN_OVERRIDE_CONFIG_SESWR 0x1408 #define MC_TXN_OVERRIDE_CONFIG_SESWR 0x1408U
#define MC_TXN_OVERRIDE_CONFIG_NVJPGSRD 0x13f0 #define MC_TXN_OVERRIDE_CONFIG_NVJPGSRD 0x13f0U
#define MC_TXN_OVERRIDE_CONFIG_NVDECSRD 0x13c0 #define MC_TXN_OVERRIDE_CONFIG_NVDECSRD 0x13c0U
#define MC_TXN_OVERRIDE_CONFIG_TSECSRDB 0x1430 #define MC_TXN_OVERRIDE_CONFIG_TSECSRDB 0x1430U
#define MC_TXN_OVERRIDE_CONFIG_BPMPDMAW 0x14b0 #define MC_TXN_OVERRIDE_CONFIG_BPMPDMAW 0x14b0U
#define MC_TXN_OVERRIDE_CONFIG_APER 0x13d0 #define MC_TXN_OVERRIDE_CONFIG_APER 0x13d0U
#define MC_TXN_OVERRIDE_CONFIG_NVDECSRD1 0x1518 #define MC_TXN_OVERRIDE_CONFIG_NVDECSRD1 0x1518U
#define MC_TXN_OVERRIDE_CONFIG_XUSB_HOSTR 0x1250 #define MC_TXN_OVERRIDE_CONFIG_XUSB_HOSTR 0x1250U
#define MC_TXN_OVERRIDE_CONFIG_ISPWA 0x1230 #define MC_TXN_OVERRIDE_CONFIG_ISPWA 0x1230U
#define MC_TXN_OVERRIDE_CONFIG_SESRD 0x1400 #define MC_TXN_OVERRIDE_CONFIG_SESRD 0x1400U
#define MC_TXN_OVERRIDE_CONFIG_SCER 0x14d8 #define MC_TXN_OVERRIDE_CONFIG_SCER 0x14d8U
#define MC_TXN_OVERRIDE_CONFIG_AONR 0x14b8 #define MC_TXN_OVERRIDE_CONFIG_AONR 0x14b8U
#define MC_TXN_OVERRIDE_CONFIG_MPCORER 0x1138 #define MC_TXN_OVERRIDE_CONFIG_MPCORER 0x1138U
#define MC_TXN_OVERRIDE_CONFIG_SDMMCWA 0x1320 #define MC_TXN_OVERRIDE_CONFIG_SDMMCWA 0x1320U
#define MC_TXN_OVERRIDE_CONFIG_HDAW 0x11a8 #define MC_TXN_OVERRIDE_CONFIG_HDAW 0x11a8U
#define MC_TXN_OVERRIDE_CONFIG_NVDECSWR 0x13c8 #define MC_TXN_OVERRIDE_CONFIG_NVDECSWR 0x13c8U
#define MC_TXN_OVERRIDE_CONFIG_UFSHCW 0x1488 #define MC_TXN_OVERRIDE_CONFIG_UFSHCW 0x1488U
#define MC_TXN_OVERRIDE_CONFIG_AONDMAR 0x14c8 #define MC_TXN_OVERRIDE_CONFIG_AONDMAR 0x14c8U
#define MC_TXN_OVERRIDE_CONFIG_SATAW 0x11e8 #define MC_TXN_OVERRIDE_CONFIG_SATAW 0x11e8U
#define MC_TXN_OVERRIDE_CONFIG_ETRW 0x1428 #define MC_TXN_OVERRIDE_CONFIG_ETRW 0x1428U
#define MC_TXN_OVERRIDE_CONFIG_VICSWR 0x1368 #define MC_TXN_OVERRIDE_CONFIG_VICSWR 0x1368U
#define MC_TXN_OVERRIDE_CONFIG_NVENCSWR 0x1158 #define MC_TXN_OVERRIDE_CONFIG_NVENCSWR 0x1158U
#define MC_TXN_OVERRIDE_CONFIG_AFIR 0x1070 #define MC_TXN_OVERRIDE_CONFIG_AFIR 0x1070U
#define MC_TXN_OVERRIDE_CONFIG_SDMMCWAB 0x1338 #define MC_TXN_OVERRIDE_CONFIG_SDMMCWAB 0x1338U
#define MC_TXN_OVERRIDE_CONFIG_SDMMCRA 0x1300 #define MC_TXN_OVERRIDE_CONFIG_SDMMCRA 0x1300U
#define MC_TXN_OVERRIDE_CONFIG_NVDISPLAYR1 0x1508 #define MC_TXN_OVERRIDE_CONFIG_NVDISPLAYR1 0x1508U
#define MC_TXN_OVERRIDE_CONFIG_ISPWB 0x1238 #define MC_TXN_OVERRIDE_CONFIG_ISPWB 0x1238U
#define MC_TXN_OVERRIDE_CONFIG_BPMPR 0x1498 #define MC_TXN_OVERRIDE_CONFIG_BPMPR 0x1498U
#define MC_TXN_OVERRIDE_CONFIG_APEW 0x13d8 #define MC_TXN_OVERRIDE_CONFIG_APEW 0x13d8U
#define MC_TXN_OVERRIDE_CONFIG_SDMMCR 0x1310 #define MC_TXN_OVERRIDE_CONFIG_SDMMCR 0x1310U
#define MC_TXN_OVERRIDE_CONFIG_XUSB_DEVW 0x1268 #define MC_TXN_OVERRIDE_CONFIG_XUSB_DEVW 0x1268U
#define MC_TXN_OVERRIDE_CONFIG_TSECSRD 0x12a0 #define MC_TXN_OVERRIDE_CONFIG_TSECSRD 0x12a0U
#define MC_TXN_OVERRIDE_CONFIG_AFIW 0x1188 #define MC_TXN_OVERRIDE_CONFIG_AFIW 0x1188U
#define MC_TXN_OVERRIDE_CONFIG_SCEW 0x14e0 #define MC_TXN_OVERRIDE_CONFIG_SCEW 0x14e0U
/******************************************************************************* /*******************************************************************************
* Structure to hold the transaction override settings to use to override * Structure to hold the transaction override settings to use to override
...@@ -223,12 +223,12 @@ typedef struct mc_streamid_security_cfg { ...@@ -223,12 +223,12 @@ typedef struct mc_streamid_security_cfg {
int override_client_ns_flag; int override_client_ns_flag;
} mc_streamid_security_cfg_t; } mc_streamid_security_cfg_t;
#define OVERRIDE_DISABLE 1 #define OVERRIDE_DISABLE 1U
#define OVERRIDE_ENABLE 0 #define OVERRIDE_ENABLE 0U
#define CLIENT_FLAG_SECURE 0 #define CLIENT_FLAG_SECURE 0U
#define CLIENT_FLAG_NON_SECURE 1 #define CLIENT_FLAG_NON_SECURE 1U
#define CLIENT_INPUTS_OVERRIDE 1 #define CLIENT_INPUTS_OVERRIDE 1U
#define CLIENT_INPUTS_NO_OVERRIDE 0 #define CLIENT_INPUTS_NO_OVERRIDE 0U
#define mc_make_sec_cfg(off, ns, ovrrd, access) \ #define mc_make_sec_cfg(off, ns, ovrrd, access) \
{ \ { \
...@@ -257,70 +257,70 @@ typedef struct tegra_mc_settings { ...@@ -257,70 +257,70 @@ typedef struct tegra_mc_settings {
/******************************************************************************* /*******************************************************************************
* Memory Controller SMMU Bypass config register * Memory Controller SMMU Bypass config register
******************************************************************************/ ******************************************************************************/
#define MC_SMMU_BYPASS_CONFIG 0x1820 #define MC_SMMU_BYPASS_CONFIG 0x1820U
#define MC_SMMU_BYPASS_CTRL_MASK 0x3 #define MC_SMMU_BYPASS_CTRL_MASK 0x3U
#define MC_SMMU_BYPASS_CTRL_SHIFT 0 #define MC_SMMU_BYPASS_CTRL_SHIFT 0U
#define MC_SMMU_CTRL_TBU_BYPASS_ALL (0 << MC_SMMU_BYPASS_CTRL_SHIFT) #define MC_SMMU_CTRL_TBU_BYPASS_ALL (0U << MC_SMMU_BYPASS_CTRL_SHIFT)
#define MC_SMMU_CTRL_TBU_RSVD (1 << MC_SMMU_BYPASS_CTRL_SHIFT) #define MC_SMMU_CTRL_TBU_RSVD (1U << MC_SMMU_BYPASS_CTRL_SHIFT)
#define MC_SMMU_CTRL_TBU_BYPASS_SPL_STREAMID (2 << MC_SMMU_BYPASS_CTRL_SHIFT) #define MC_SMMU_CTRL_TBU_BYPASS_SPL_STREAMID (2U << MC_SMMU_BYPASS_CTRL_SHIFT)
#define MC_SMMU_CTRL_TBU_BYPASS_NONE (3 << MC_SMMU_BYPASS_CTRL_SHIFT) #define MC_SMMU_CTRL_TBU_BYPASS_NONE (3U << MC_SMMU_BYPASS_CTRL_SHIFT)
#define MC_SMMU_BYPASS_CONFIG_WRITE_ACCESS_BIT (1 << 31) #define MC_SMMU_BYPASS_CONFIG_WRITE_ACCESS_BIT (1U << 31)
#define MC_SMMU_BYPASS_CONFIG_SETTINGS (MC_SMMU_BYPASS_CONFIG_WRITE_ACCESS_BIT | \ #define MC_SMMU_BYPASS_CONFIG_SETTINGS (MC_SMMU_BYPASS_CONFIG_WRITE_ACCESS_BIT | \
MC_SMMU_CTRL_TBU_BYPASS_SPL_STREAMID) MC_SMMU_CTRL_TBU_BYPASS_SPL_STREAMID)
#define MC_TXN_OVERRIDE_CONFIG_AXID_OVERRIDE_CGID (1 << 0) #define MC_TXN_OVERRIDE_CONFIG_AXID_OVERRIDE_CGID (1U << 0)
#define MC_TXN_OVERRIDE_CONFIG_COH_PATH_OVERRIDE_SO_DEV (2 << 4) #define MC_TXN_OVERRIDE_CONFIG_COH_PATH_OVERRIDE_SO_DEV (2U << 4)
#define MC_TXN_OVERRIDE_CONFIG_AXID_OVERRIDE_SO_DEV_CGID_SO_DEV_CLIENT (1 << 12) #define MC_TXN_OVERRIDE_CONFIG_AXID_OVERRIDE_SO_DEV_CGID_SO_DEV_CLIENT (1U << 12)
/******************************************************************************* /*******************************************************************************
* Non-SO_DEV transactions override values for CGID_TAG bitfield for the * Non-SO_DEV transactions override values for CGID_TAG bitfield for the
* MC_TXN_OVERRIDE_CONFIG_{module} registers * MC_TXN_OVERRIDE_CONFIG_{module} registers
******************************************************************************/ ******************************************************************************/
#define MC_TXN_OVERRIDE_CGID_TAG_DEFAULT 0 #define MC_TXN_OVERRIDE_CGID_TAG_DEFAULT 0U
#define MC_TXN_OVERRIDE_CGID_TAG_CLIENT_AXI_ID 1 #define MC_TXN_OVERRIDE_CGID_TAG_CLIENT_AXI_ID 1U
#define MC_TXN_OVERRIDE_CGID_TAG_ZERO 2 #define MC_TXN_OVERRIDE_CGID_TAG_ZERO 2U
#define MC_TXN_OVERRIDE_CGID_TAG_ADR 3 #define MC_TXN_OVERRIDE_CGID_TAG_ADR 3U
#define MC_TXN_OVERRIDE_CGID_TAG_MASK 3 #define MC_TXN_OVERRIDE_CGID_TAG_MASK 3U
/******************************************************************************* /*******************************************************************************
* Memory Controller Reset Control registers * Memory Controller Reset Control registers
******************************************************************************/ ******************************************************************************/
#define MC_CLIENT_HOTRESET_CTRL0 0x200 #define MC_CLIENT_HOTRESET_CTRL0 0x200U
#define MC_CLIENT_HOTRESET_CTRL0_RESET_VAL 0 #define MC_CLIENT_HOTRESET_CTRL0_RESET_VAL 0U
#define MC_CLIENT_HOTRESET_CTRL0_AFI_FLUSH_ENB (1 << 0) #define MC_CLIENT_HOTRESET_CTRL0_AFI_FLUSH_ENB (1U << 0)
#define MC_CLIENT_HOTRESET_CTRL0_HC_FLUSH_ENB (1 << 6) #define MC_CLIENT_HOTRESET_CTRL0_HC_FLUSH_ENB (1U << 6)
#define MC_CLIENT_HOTRESET_CTRL0_HDA_FLUSH_ENB (1 << 7) #define MC_CLIENT_HOTRESET_CTRL0_HDA_FLUSH_ENB (1U << 7)
#define MC_CLIENT_HOTRESET_CTRL0_ISP2_FLUSH_ENB (1 << 8) #define MC_CLIENT_HOTRESET_CTRL0_ISP2_FLUSH_ENB (1U << 8)
#define MC_CLIENT_HOTRESET_CTRL0_MPCORE_FLUSH_ENB (1 << 9) #define MC_CLIENT_HOTRESET_CTRL0_MPCORE_FLUSH_ENB (1U << 9)
#define MC_CLIENT_HOTRESET_CTRL0_NVENC_FLUSH_ENB (1 << 11) #define MC_CLIENT_HOTRESET_CTRL0_NVENC_FLUSH_ENB (1U << 11)
#define MC_CLIENT_HOTRESET_CTRL0_SATA_FLUSH_ENB (1 << 15) #define MC_CLIENT_HOTRESET_CTRL0_SATA_FLUSH_ENB (1U << 15)
#define MC_CLIENT_HOTRESET_CTRL0_VI_FLUSH_ENB (1 << 17) #define MC_CLIENT_HOTRESET_CTRL0_VI_FLUSH_ENB (1U << 17)
#define MC_CLIENT_HOTRESET_CTRL0_VIC_FLUSH_ENB (1 << 18) #define MC_CLIENT_HOTRESET_CTRL0_VIC_FLUSH_ENB (1U << 18)
#define MC_CLIENT_HOTRESET_CTRL0_XUSB_HOST_FLUSH_ENB (1 << 19) #define MC_CLIENT_HOTRESET_CTRL0_XUSB_HOST_FLUSH_ENB (1U << 19)
#define MC_CLIENT_HOTRESET_CTRL0_XUSB_DEV_FLUSH_ENB (1 << 20) #define MC_CLIENT_HOTRESET_CTRL0_XUSB_DEV_FLUSH_ENB (1U << 20)
#define MC_CLIENT_HOTRESET_CTRL0_TSEC_FLUSH_ENB (1 << 22) #define MC_CLIENT_HOTRESET_CTRL0_TSEC_FLUSH_ENB (1U << 22)
#define MC_CLIENT_HOTRESET_CTRL0_SDMMC1A_FLUSH_ENB (1 << 29) #define MC_CLIENT_HOTRESET_CTRL0_SDMMC1A_FLUSH_ENB (1U << 29)
#define MC_CLIENT_HOTRESET_CTRL0_SDMMC2A_FLUSH_ENB (1 << 30) #define MC_CLIENT_HOTRESET_CTRL0_SDMMC2A_FLUSH_ENB (1U << 30)
#define MC_CLIENT_HOTRESET_CTRL0_SDMMC3A_FLUSH_ENB (1 << 31) #define MC_CLIENT_HOTRESET_CTRL0_SDMMC3A_FLUSH_ENB (1U << 31)
#define MC_CLIENT_HOTRESET_STATUS0 0x204 #define MC_CLIENT_HOTRESET_STATUS0 0x204U
#define MC_CLIENT_HOTRESET_CTRL1 0x970 #define MC_CLIENT_HOTRESET_CTRL1 0x970U
#define MC_CLIENT_HOTRESET_CTRL1_RESET_VAL 0 #define MC_CLIENT_HOTRESET_CTRL1_RESET_VAL 0U
#define MC_CLIENT_HOTRESET_CTRL1_SDMMC4A_FLUSH_ENB (1 << 0) #define MC_CLIENT_HOTRESET_CTRL1_SDMMC4A_FLUSH_ENB (1U << 0)
#define MC_CLIENT_HOTRESET_CTRL1_GPU_FLUSH_ENB (1 << 2) #define MC_CLIENT_HOTRESET_CTRL1_GPU_FLUSH_ENB (1U << 2)
#define MC_CLIENT_HOTRESET_CTRL1_NVDEC_FLUSH_ENB (1 << 5) #define MC_CLIENT_HOTRESET_CTRL1_NVDEC_FLUSH_ENB (1U << 5)
#define MC_CLIENT_HOTRESET_CTRL1_APE_FLUSH_ENB (1 << 6) #define MC_CLIENT_HOTRESET_CTRL1_APE_FLUSH_ENB (1U << 6)
#define MC_CLIENT_HOTRESET_CTRL1_SE_FLUSH_ENB (1 << 7) #define MC_CLIENT_HOTRESET_CTRL1_SE_FLUSH_ENB (1U << 7)
#define MC_CLIENT_HOTRESET_CTRL1_NVJPG_FLUSH_ENB (1 << 8) #define MC_CLIENT_HOTRESET_CTRL1_NVJPG_FLUSH_ENB (1U << 8)
#define MC_CLIENT_HOTRESET_CTRL1_ETR_FLUSH_ENB (1 << 12) #define MC_CLIENT_HOTRESET_CTRL1_ETR_FLUSH_ENB (1U << 12)
#define MC_CLIENT_HOTRESET_CTRL1_TSECB_FLUSH_ENB (1 << 13) #define MC_CLIENT_HOTRESET_CTRL1_TSECB_FLUSH_ENB (1U << 13)
#define MC_CLIENT_HOTRESET_CTRL1_AXIS_FLUSH_ENB (1 << 18) #define MC_CLIENT_HOTRESET_CTRL1_AXIS_FLUSH_ENB (1U << 18)
#define MC_CLIENT_HOTRESET_CTRL1_EQOS_FLUSH_ENB (1 << 19) #define MC_CLIENT_HOTRESET_CTRL1_EQOS_FLUSH_ENB (1U << 19)
#define MC_CLIENT_HOTRESET_CTRL1_UFSHC_FLUSH_ENB (1 << 20) #define MC_CLIENT_HOTRESET_CTRL1_UFSHC_FLUSH_ENB (1U << 20)
#define MC_CLIENT_HOTRESET_CTRL1_NVDISPLAY_FLUSH_ENB (1 << 21) #define MC_CLIENT_HOTRESET_CTRL1_NVDISPLAY_FLUSH_ENB (1U << 21)
#define MC_CLIENT_HOTRESET_CTRL1_BPMP_FLUSH_ENB (1 << 22) #define MC_CLIENT_HOTRESET_CTRL1_BPMP_FLUSH_ENB (1U << 22)
#define MC_CLIENT_HOTRESET_CTRL1_AON_FLUSH_ENB (1 << 23) #define MC_CLIENT_HOTRESET_CTRL1_AON_FLUSH_ENB (1U << 23)
#define MC_CLIENT_HOTRESET_CTRL1_SCE_FLUSH_ENB (1 << 24) #define MC_CLIENT_HOTRESET_CTRL1_SCE_FLUSH_ENB (1U << 24)
#define MC_CLIENT_HOTRESET_STATUS1 0x974 #define MC_CLIENT_HOTRESET_STATUS1 0x974U
/******************************************************************************* /*******************************************************************************
* Memory Controller's PCFIFO client configuration registers * Memory Controller's PCFIFO client configuration registers
...@@ -396,7 +396,7 @@ static inline void tegra_mc_streamid_write_32(uint32_t off, uint32_t val) ...@@ -396,7 +396,7 @@ static inline void tegra_mc_streamid_write_32(uint32_t off, uint32_t val)
} }
#define mc_set_pcfifo_unordered_boot_so_mss(id, client) \ #define mc_set_pcfifo_unordered_boot_so_mss(id, client) \
(~MC_PCFIFO_CLIENT_CONFIG##id##_PCFIFO_##client##_MASK | \ ((uint32_t)~MC_PCFIFO_CLIENT_CONFIG##id##_PCFIFO_##client##_MASK | \
MC_PCFIFO_CLIENT_CONFIG##id##_PCFIFO_##client##_UNORDERED) MC_PCFIFO_CLIENT_CONFIG##id##_PCFIFO_##client##_UNORDERED)
#define mc_set_pcfifo_ordered_boot_so_mss(id, client) \ #define mc_set_pcfifo_ordered_boot_so_mss(id, client) \
...@@ -406,8 +406,8 @@ static inline void tegra_mc_streamid_write_32(uint32_t off, uint32_t val) ...@@ -406,8 +406,8 @@ static inline void tegra_mc_streamid_write_32(uint32_t off, uint32_t val)
{ \ { \
mmio_write_32(TEGRA_TSA_BASE + TSA_CONFIG_STATIC0_CSW_##client, \ mmio_write_32(TEGRA_TSA_BASE + TSA_CONFIG_STATIC0_CSW_##client, \
(TSA_CONFIG_STATIC0_CSW_##client##_RESET & \ (TSA_CONFIG_STATIC0_CSW_##client##_RESET & \
~TSA_CONFIG_CSW_MEMTYPE_OVERRIDE_MASK) | \ (uint32_t)~TSA_CONFIG_CSW_MEMTYPE_OVERRIDE_MASK) | \
TSA_CONFIG_CSW_MEMTYPE_OVERRIDE_PASTHRU); \ (uint32_t)TSA_CONFIG_CSW_MEMTYPE_OVERRIDE_PASTHRU); \
} }
#define mc_set_txn_override(client, normal_axi_id, so_dev_axi_id, normal_override, so_dev_override) \ #define mc_set_txn_override(client, normal_axi_id, so_dev_axi_id, normal_override, so_dev_override) \
......
...@@ -38,8 +38,16 @@ typedef struct tegra_se_dev { ...@@ -38,8 +38,16 @@ typedef struct tegra_se_dev {
tegra_se_io_lst_t *src_ll_buf; tegra_se_io_lst_t *src_ll_buf;
/* pointer to destination linked list buffer */ /* pointer to destination linked list buffer */
tegra_se_io_lst_t *dst_ll_buf; tegra_se_io_lst_t *dst_ll_buf;
/* LP context buffer pointer */
uint32_t *ctx_save_buf;
} tegra_se_dev_t; } tegra_se_dev_t;
/* PKA1 device structure */
typedef struct tegra_pka_dev {
/* PKA1 base address */
uint64_t pka_base;
} tegra_pka_dev_t;
/******************************************************************************* /*******************************************************************************
* Public interface * Public interface
******************************************************************************/ ******************************************************************************/
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment