blob: 0ba2e55d2f3224dc2935dc4e29be6ee9c63e9167 [file] [log] [blame]
Varun Wadekar96b6cd22020-03-16 17:40:59 -07001/*
2 * Copyright (c) 2020, NVIDIA Corporation. All rights reserved.
3 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
7#include <arch.h>
8#include <debug.h>
9#include <mmio.h>
10#include <platform.h>
11#include <stddef.h>
12
13#include <utils_def.h>
14
15/*******************************************************************************
16 * Memory Controller SMMU Bypass config register
17 ******************************************************************************/
18#define MC_SMMU_BYPASS_CONFIG U(0x1820)
19
20/*******************************************************************************
21 * Secure Scratch 73 to save base address of SMMU register context
22 ******************************************************************************/
23#define SCRATCH_SECURE_RSV73_SCRATCH U(0x2ac)
24
25typedef struct mc_regs {
26 uint32_t reg;
27 uint32_t val;
28} mc_regs_t;
29
30#define mc_smmu_bypass_cfg \
31 { \
32 .reg = TEGRA194_MC_BASE + MC_SMMU_BYPASS_CONFIG, \
33 .val = 0x00000000U, \
34 }
35
36#define START_OF_TABLE \
37 { \
38 .reg = 0xCAFE05C7U, \
39 .val = 0x00000000U, \
40 }
41
42#define END_OF_TABLE \
43 { \
44 .reg = 0xFFFFFFFFU, \
45 .val = 0xFFFFFFFFU, \
46 }
47
48/*******************************************************************************
49 * Array to hold MC context for Tegra194
50 ******************************************************************************/
51static __attribute__((aligned(16))) mc_regs_t tegra194_mc_context[] = {
52 START_OF_TABLE,
53 mc_smmu_bypass_cfg, /* TBU settings */
54 END_OF_TABLE,
55};
56
57void tegra194_pwr_mgmt_setup(void)
58{
59 /* index of END_OF_TABLE */
60 tegra194_mc_context[0].val = ARRAY_SIZE(tegra194_mc_context) - 1U;
61
62 /* save SMMU context for SC7-RF to restore */
63 mmio_write_32(TEGRA194_SCRATCH_BASE + SCRATCH_SECURE_RSV73_SCRATCH,
64 ((uintptr_t)tegra194_mc_context) >> 12);
65}