2016-03-03 21:09:08 +00:00
|
|
|
/*
|
2017-01-02 14:12:31 +00:00
|
|
|
* Copyright (c) 2016-2017, ARM Limited and Contributors. All rights reserved.
|
2018-08-03 11:18:15 +01:00
|
|
|
* Copyright (c) 2020, NVIDIA Corporation. All rights reserved.
|
2016-03-03 21:09:08 +00:00
|
|
|
*
|
2017-05-03 09:38:09 +01:00
|
|
|
* SPDX-License-Identifier: BSD-3-Clause
|
2016-03-03 21:09:08 +00:00
|
|
|
*/
|
|
|
|
|
2018-11-08 10:20:19 +00:00
|
|
|
#ifndef SMMU_H
|
|
|
|
#define SMMU_H
|
2016-03-03 21:09:08 +00:00
|
|
|
|
2018-12-14 00:18:21 +00:00
|
|
|
#include <lib/mmio.h>
|
|
|
|
|
2017-01-02 14:12:31 +00:00
|
|
|
#include <memctrl_v2.h>
|
2016-03-03 21:09:08 +00:00
|
|
|
#include <tegra_def.h>
|
|
|
|
|
2017-03-13 07:34:08 +00:00
|
|
|
#define SMMU_CBn_ACTLR (0x4U)
|
2016-03-03 21:09:08 +00:00
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
* SMMU Global Secure Aux. Configuration Register
|
|
|
|
******************************************************************************/
|
2017-03-13 07:34:08 +00:00
|
|
|
#define SMMU_GSR0_SECURE_ACR 0x10U
|
|
|
|
#define SMMU_GNSR_ACR (SMMU_GSR0_SECURE_ACR + 0x400U)
|
|
|
|
#define SMMU_GSR0_PGSIZE_SHIFT 16U
|
|
|
|
#define SMMU_GSR0_PGSIZE_4K (0U << SMMU_GSR0_PGSIZE_SHIFT)
|
|
|
|
#define SMMU_GSR0_PGSIZE_64K (1U << SMMU_GSR0_PGSIZE_SHIFT)
|
2018-12-10 21:20:49 +00:00
|
|
|
#define SMMU_ACR_CACHE_LOCK_ENABLE_BIT (1ULL << 26U)
|
|
|
|
#define SMMU_GSR0_PER (0x20200U)
|
2016-04-21 01:14:15 +01:00
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
* SMMU Global Aux. Control Register
|
|
|
|
******************************************************************************/
|
2017-07-26 10:16:54 +01:00
|
|
|
#define SMMU_CBn_ACTLR_CPRE_BIT (1ULL << 1U)
|
2016-03-03 21:09:08 +00:00
|
|
|
|
2018-12-10 21:20:49 +00:00
|
|
|
/* SMMU IDs currently supported by the driver */
|
|
|
|
enum {
|
|
|
|
TEGRA_SMMU0 = 0U,
|
|
|
|
TEGRA_SMMU1 = 1U,
|
|
|
|
TEGRA_SMMU2 = 2U
|
|
|
|
};
|
|
|
|
|
|
|
|
static inline uint32_t tegra_smmu_read_32(uint32_t smmu_id, uint32_t off)
|
|
|
|
{
|
|
|
|
uint32_t ret = 0U;
|
|
|
|
|
|
|
|
#if defined(TEGRA_SMMU0_BASE)
|
|
|
|
if (smmu_id == TEGRA_SMMU0) {
|
|
|
|
ret = mmio_read_32(TEGRA_SMMU0_BASE + (uint64_t)off);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(TEGRA_SMMU1_BASE)
|
|
|
|
if (smmu_id == TEGRA_SMMU1) {
|
|
|
|
ret = mmio_read_32(TEGRA_SMMU1_BASE + (uint64_t)off);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(TEGRA_SMMU2_BASE)
|
|
|
|
if (smmu_id == TEGRA_SMMU2) {
|
|
|
|
ret = mmio_read_32(TEGRA_SMMU2_BASE + (uint64_t)off);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void tegra_smmu_write_32(uint32_t smmu_id,
|
|
|
|
uint32_t off, uint32_t val)
|
|
|
|
{
|
|
|
|
#if defined(TEGRA_SMMU0_BASE)
|
|
|
|
if (smmu_id == TEGRA_SMMU0) {
|
|
|
|
mmio_write_32(TEGRA_SMMU0_BASE + (uint64_t)off, val);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(TEGRA_SMMU1_BASE)
|
|
|
|
if (smmu_id == TEGRA_SMMU1) {
|
|
|
|
mmio_write_32(TEGRA_SMMU1_BASE + (uint64_t)off, val);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(TEGRA_SMMU2_BASE)
|
|
|
|
if (smmu_id == TEGRA_SMMU2) {
|
|
|
|
mmio_write_32(TEGRA_SMMU2_BASE + (uint64_t)off, val);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2016-03-03 21:09:08 +00:00
|
|
|
void tegra_smmu_init(void);
|
2019-09-26 16:26:41 +01:00
|
|
|
void tegra_smmu_verify(void);
|
2017-07-25 04:29:46 +01:00
|
|
|
uint32_t plat_get_num_smmu_devices(void);
|
2016-03-03 21:09:08 +00:00
|
|
|
|
2018-11-08 10:20:19 +00:00
|
|
|
#endif /* SMMU_H */
|