Varun Wadekar | cd5a2f5 | 2015-09-20 15:08:22 +0530 | [diff] [blame] | 1 | /* |
Manish V Badarkhe | 07538b5 | 2020-10-07 16:04:06 +0100 | [diff] [blame] | 2 | * Copyright (c) 2015-2020, ARM Limited and Contributors. All rights reserved. |
Varun Wadekar | d4a698f | 2019-08-26 10:20:53 -0700 | [diff] [blame] | 3 | * Copyright (c) 2020, NVIDIA CORPORATION. All rights reserved. |
Varun Wadekar | cd5a2f5 | 2015-09-20 15:08:22 +0530 | [diff] [blame] | 4 | * |
dp-arm | fa3cf0b | 2017-05-03 09:38:09 +0100 | [diff] [blame] | 5 | * SPDX-License-Identifier: BSD-3-Clause |
Varun Wadekar | cd5a2f5 | 2015-09-20 15:08:22 +0530 | [diff] [blame] | 6 | */ |
| 7 | |
Antonio Nino Diaz | 5eb8837 | 2018-11-08 10:20:19 +0000 | [diff] [blame] | 8 | #ifndef MEMCTRL_V2_H |
| 9 | #define MEMCTRL_V2_H |
Varun Wadekar | cd5a2f5 | 2015-09-20 15:08:22 +0530 | [diff] [blame] | 10 | |
Varun Wadekar | d4a698f | 2019-08-26 10:20:53 -0700 | [diff] [blame] | 11 | #include <arch.h> |
Varun Wadekar | cd5a2f5 | 2015-09-20 15:08:22 +0530 | [diff] [blame] | 12 | |
Varun Wadekar | d4a698f | 2019-08-26 10:20:53 -0700 | [diff] [blame] | 13 | #include <tegra_def.h> |
Puneet Saxena | cf8c0e2 | 2017-08-04 17:19:55 +0530 | [diff] [blame] | 14 | |
| 15 | /******************************************************************************* |
| 16 | * Memory Controller SMMU Bypass config register |
| 17 | ******************************************************************************/ |
| 18 | #define MC_SMMU_BYPASS_CONFIG 0x1820U |
| 19 | #define MC_SMMU_BYPASS_CTRL_MASK 0x3U |
| 20 | #define MC_SMMU_BYPASS_CTRL_SHIFT 0U |
| 21 | #define MC_SMMU_CTRL_TBU_BYPASS_ALL (0U << MC_SMMU_BYPASS_CTRL_SHIFT) |
| 22 | #define MC_SMMU_CTRL_TBU_RSVD (1U << MC_SMMU_BYPASS_CTRL_SHIFT) |
| 23 | #define MC_SMMU_CTRL_TBU_BYPASS_SPL_STREAMID (2U << MC_SMMU_BYPASS_CTRL_SHIFT) |
| 24 | #define MC_SMMU_CTRL_TBU_BYPASS_NONE (3U << MC_SMMU_BYPASS_CTRL_SHIFT) |
| 25 | #define MC_SMMU_BYPASS_CONFIG_WRITE_ACCESS_BIT (1U << 31) |
| 26 | #define MC_SMMU_BYPASS_CONFIG_SETTINGS (MC_SMMU_BYPASS_CONFIG_WRITE_ACCESS_BIT | \ |
| 27 | MC_SMMU_CTRL_TBU_BYPASS_SPL_STREAMID) |
Varun Wadekar | cd5a2f5 | 2015-09-20 15:08:22 +0530 | [diff] [blame] | 28 | |
Manish V Badarkhe | 07538b5 | 2020-10-07 16:04:06 +0100 | [diff] [blame] | 29 | #ifndef __ASSEMBLER__ |
Pritesh Raithatha | 9eb5db5 | 2017-01-02 19:42:31 +0530 | [diff] [blame] | 30 | |
Anthony Zhou | 9de77f6 | 2019-11-13 18:36:07 +0800 | [diff] [blame] | 31 | #include <assert.h> |
| 32 | |
Pritesh Raithatha | 75c9443 | 2018-08-03 15:48:15 +0530 | [diff] [blame] | 33 | typedef struct mc_regs { |
| 34 | uint32_t reg; |
| 35 | uint32_t val; |
| 36 | } mc_regs_t; |
| 37 | |
Pritesh Raithatha | 75c9443 | 2018-08-03 15:48:15 +0530 | [diff] [blame] | 38 | #define mc_smmu_bypass_cfg \ |
| 39 | { \ |
| 40 | .reg = TEGRA_MC_BASE + MC_SMMU_BYPASS_CONFIG, \ |
| 41 | .val = 0x00000000U, \ |
| 42 | } |
| 43 | |
| 44 | #define _START_OF_TABLE_ \ |
| 45 | { \ |
| 46 | .reg = 0xCAFE05C7U, \ |
| 47 | .val = 0x00000000U, \ |
| 48 | } |
| 49 | |
| 50 | #define _END_OF_TABLE_ \ |
| 51 | { \ |
| 52 | .reg = 0xFFFFFFFFU, \ |
| 53 | .val = 0xFFFFFFFFU, \ |
| 54 | } |
| 55 | |
Manish V Badarkhe | 07538b5 | 2020-10-07 16:04:06 +0100 | [diff] [blame] | 56 | #endif /* __ASSEMBLER__ */ |
Varun Wadekar | d4a698f | 2019-08-26 10:20:53 -0700 | [diff] [blame] | 57 | |
Manish V Badarkhe | 07538b5 | 2020-10-07 16:04:06 +0100 | [diff] [blame] | 58 | #ifndef __ASSEMBLER__ |
Varun Wadekar | d4a698f | 2019-08-26 10:20:53 -0700 | [diff] [blame] | 59 | |
| 60 | #include <lib/mmio.h> |
Varun Wadekar | cd5a2f5 | 2015-09-20 15:08:22 +0530 | [diff] [blame] | 61 | |
Varun Wadekar | cd5a2f5 | 2015-09-20 15:08:22 +0530 | [diff] [blame] | 62 | static inline uint32_t tegra_mc_read_32(uint32_t off) |
| 63 | { |
| 64 | return mmio_read_32(TEGRA_MC_BASE + off); |
| 65 | } |
| 66 | |
| 67 | static inline void tegra_mc_write_32(uint32_t off, uint32_t val) |
| 68 | { |
| 69 | mmio_write_32(TEGRA_MC_BASE + off, val); |
| 70 | } |
| 71 | |
Varun Wadekar | 82b0b18 | 2019-09-26 08:26:41 -0700 | [diff] [blame] | 72 | #if defined(TEGRA_MC_STREAMID_BASE) |
Varun Wadekar | cd5a2f5 | 2015-09-20 15:08:22 +0530 | [diff] [blame] | 73 | static inline uint32_t tegra_mc_streamid_read_32(uint32_t off) |
| 74 | { |
| 75 | return mmio_read_32(TEGRA_MC_STREAMID_BASE + off); |
| 76 | } |
| 77 | |
| 78 | static inline void tegra_mc_streamid_write_32(uint32_t off, uint32_t val) |
| 79 | { |
| 80 | mmio_write_32(TEGRA_MC_STREAMID_BASE + off, val); |
Anthony Zhou | 9de77f6 | 2019-11-13 18:36:07 +0800 | [diff] [blame] | 81 | assert(mmio_read_32(TEGRA_MC_STREAMID_BASE + off) == val); |
Varun Wadekar | cd5a2f5 | 2015-09-20 15:08:22 +0530 | [diff] [blame] | 82 | } |
Varun Wadekar | 82b0b18 | 2019-09-26 08:26:41 -0700 | [diff] [blame] | 83 | #endif |
Varun Wadekar | cd5a2f5 | 2015-09-20 15:08:22 +0530 | [diff] [blame] | 84 | |
Varun Wadekar | d4a698f | 2019-08-26 10:20:53 -0700 | [diff] [blame] | 85 | void plat_memctrl_setup(void); |
Varun Wadekar | a0f2697 | 2016-03-11 17:18:51 -0800 | [diff] [blame] | 86 | |
Varun Wadekar | d4a698f | 2019-08-26 10:20:53 -0700 | [diff] [blame] | 87 | void plat_memctrl_restore(void); |
| 88 | mc_regs_t *plat_memctrl_get_sys_suspend_ctx(void); |
Pritesh Raithatha | 9eb5db5 | 2017-01-02 19:42:31 +0530 | [diff] [blame] | 89 | |
Varun Wadekar | f3cd509 | 2017-10-30 14:35:17 -0700 | [diff] [blame] | 90 | /******************************************************************************* |
Pritesh Raithatha | 75c9443 | 2018-08-03 15:48:15 +0530 | [diff] [blame] | 91 | * Handler to save MC settings before "System Suspend" to TZDRAM |
| 92 | * |
| 93 | * Implemented by Tegra common memctrl_v2 driver under common/drivers/memctrl |
| 94 | ******************************************************************************/ |
| 95 | void tegra_mc_save_context(uint64_t mc_ctx_addr); |
| 96 | |
| 97 | /******************************************************************************* |
Varun Wadekar | f3cd509 | 2017-10-30 14:35:17 -0700 | [diff] [blame] | 98 | * Handler to program the scratch registers with TZDRAM settings for the |
| 99 | * resume firmware. |
| 100 | * |
| 101 | * Implemented by SoCs under tegra/soc/txxx |
| 102 | ******************************************************************************/ |
| 103 | void plat_memctrl_tzdram_setup(uint64_t phys_base, uint64_t size_in_bytes); |
| 104 | |
Julius Werner | 53456fc | 2019-07-09 13:49:11 -0700 | [diff] [blame] | 105 | #endif /* __ASSEMBLER__ */ |
Varun Wadekar | a0f2697 | 2016-03-11 17:18:51 -0800 | [diff] [blame] | 106 | |
Antonio Nino Diaz | 5eb8837 | 2018-11-08 10:20:19 +0000 | [diff] [blame] | 107 | #endif /* MEMCTRL_V2_H */ |