Varun Wadekar | cd5a2f5 | 2015-09-20 15:08:22 +0530 | [diff] [blame] | 1 | /* |
Harvey Hsieh | b9b374f | 2016-11-15 22:04:51 +0800 | [diff] [blame] | 2 | * Copyright (c) 2015-2017, ARM Limited and Contributors. All rights reserved. |
Varun Wadekar | cd5a2f5 | 2015-09-20 15:08:22 +0530 | [diff] [blame] | 3 | * |
dp-arm | fa3cf0b | 2017-05-03 09:38:09 +0100 | [diff] [blame] | 4 | * SPDX-License-Identifier: BSD-3-Clause |
Varun Wadekar | cd5a2f5 | 2015-09-20 15:08:22 +0530 | [diff] [blame] | 5 | */ |
| 6 | |
Varun Wadekar | cd5a2f5 | 2015-09-20 15:08:22 +0530 | [diff] [blame] | 7 | #include <assert.h> |
Antonio Nino Diaz | e0f9063 | 2018-12-14 00:18:21 +0000 | [diff] [blame] | 8 | #include <string.h> |
| 9 | |
| 10 | #include <arch_helpers.h> |
| 11 | #include <common/bl_common.h> |
| 12 | #include <common/debug.h> |
| 13 | #include <lib/mmio.h> |
| 14 | #include <lib/utils.h> |
| 15 | #include <lib/xlat_tables/xlat_tables_v2.h> |
| 16 | |
Varun Wadekar | cd5a2f5 | 2015-09-20 15:08:22 +0530 | [diff] [blame] | 17 | #include <mce.h> |
| 18 | #include <memctrl.h> |
| 19 | #include <memctrl_v2.h> |
Varun Wadekar | 87e44ff | 2016-03-03 13:22:39 -0800 | [diff] [blame] | 20 | #include <smmu.h> |
Varun Wadekar | cd5a2f5 | 2015-09-20 15:08:22 +0530 | [diff] [blame] | 21 | #include <tegra_def.h> |
Varun Wadekar | e81177d | 2016-07-18 17:43:41 -0700 | [diff] [blame] | 22 | #include <tegra_platform.h> |
Varun Wadekar | cd5a2f5 | 2015-09-20 15:08:22 +0530 | [diff] [blame] | 23 | |
| 24 | /* Video Memory base and size (live values) */ |
| 25 | static uint64_t video_mem_base; |
Varun Wadekar | 7058aee | 2016-04-25 09:01:46 -0700 | [diff] [blame] | 26 | static uint64_t video_mem_size_mb; |
Varun Wadekar | cd5a2f5 | 2015-09-20 15:08:22 +0530 | [diff] [blame] | 27 | |
Varun Wadekar | a0f2697 | 2016-03-11 17:18:51 -0800 | [diff] [blame] | 28 | static void tegra_memctrl_reconfig_mss_clients(void) |
| 29 | { |
| 30 | #if ENABLE_ROC_FOR_ORDERING_CLIENT_REQUESTS |
| 31 | uint32_t val, wdata_0, wdata_1; |
| 32 | |
| 33 | /* |
| 34 | * Assert Memory Controller's HOTRESET_FLUSH_ENABLE signal for |
| 35 | * boot and strongly ordered MSS clients to flush existing memory |
| 36 | * traffic and stall future requests. |
| 37 | */ |
| 38 | val = tegra_mc_read_32(MC_CLIENT_HOTRESET_CTRL0); |
| 39 | assert(val == MC_CLIENT_HOTRESET_CTRL0_RESET_VAL); |
| 40 | |
Varun Wadekar | 4c7fa50 | 2016-12-13 13:13:42 -0800 | [diff] [blame] | 41 | wdata_0 = MC_CLIENT_HOTRESET_CTRL0_HDA_FLUSH_ENB | |
| 42 | #if ENABLE_AFI_DEVICE |
| 43 | MC_CLIENT_HOTRESET_CTRL0_AFI_FLUSH_ENB | |
| 44 | #endif |
Varun Wadekar | a0f2697 | 2016-03-11 17:18:51 -0800 | [diff] [blame] | 45 | MC_CLIENT_HOTRESET_CTRL0_SATA_FLUSH_ENB | |
| 46 | MC_CLIENT_HOTRESET_CTRL0_XUSB_HOST_FLUSH_ENB | |
| 47 | MC_CLIENT_HOTRESET_CTRL0_XUSB_DEV_FLUSH_ENB; |
| 48 | tegra_mc_write_32(MC_CLIENT_HOTRESET_CTRL0, wdata_0); |
| 49 | |
| 50 | /* Wait for HOTRESET STATUS to indicate FLUSH_DONE */ |
| 51 | do { |
| 52 | val = tegra_mc_read_32(MC_CLIENT_HOTRESET_STATUS0); |
| 53 | } while ((val & wdata_0) != wdata_0); |
| 54 | |
| 55 | /* Wait one more time due to SW WAR for known legacy issue */ |
| 56 | do { |
| 57 | val = tegra_mc_read_32(MC_CLIENT_HOTRESET_STATUS0); |
| 58 | } while ((val & wdata_0) != wdata_0); |
| 59 | |
| 60 | val = tegra_mc_read_32(MC_CLIENT_HOTRESET_CTRL1); |
| 61 | assert(val == MC_CLIENT_HOTRESET_CTRL1_RESET_VAL); |
| 62 | |
| 63 | wdata_1 = MC_CLIENT_HOTRESET_CTRL1_SDMMC4A_FLUSH_ENB | |
| 64 | MC_CLIENT_HOTRESET_CTRL1_APE_FLUSH_ENB | |
| 65 | MC_CLIENT_HOTRESET_CTRL1_SE_FLUSH_ENB | |
| 66 | MC_CLIENT_HOTRESET_CTRL1_ETR_FLUSH_ENB | |
| 67 | MC_CLIENT_HOTRESET_CTRL1_AXIS_FLUSH_ENB | |
| 68 | MC_CLIENT_HOTRESET_CTRL1_EQOS_FLUSH_ENB | |
| 69 | MC_CLIENT_HOTRESET_CTRL1_UFSHC_FLUSH_ENB | |
| 70 | MC_CLIENT_HOTRESET_CTRL1_BPMP_FLUSH_ENB | |
| 71 | MC_CLIENT_HOTRESET_CTRL1_AON_FLUSH_ENB | |
| 72 | MC_CLIENT_HOTRESET_CTRL1_SCE_FLUSH_ENB; |
| 73 | tegra_mc_write_32(MC_CLIENT_HOTRESET_CTRL1, wdata_1); |
| 74 | |
| 75 | /* Wait for HOTRESET STATUS to indicate FLUSH_DONE */ |
| 76 | do { |
| 77 | val = tegra_mc_read_32(MC_CLIENT_HOTRESET_STATUS1); |
| 78 | } while ((val & wdata_1) != wdata_1); |
| 79 | |
| 80 | /* Wait one more time due to SW WAR for known legacy issue */ |
| 81 | do { |
| 82 | val = tegra_mc_read_32(MC_CLIENT_HOTRESET_STATUS1); |
| 83 | } while ((val & wdata_1) != wdata_1); |
| 84 | |
| 85 | /* |
| 86 | * Change MEMTYPE_OVERRIDE from SO_DEV -> PASSTHRU for boot and |
| 87 | * strongly ordered MSS clients. ROC needs to be single point |
| 88 | * of control on overriding the memory type. So, remove TSA's |
| 89 | * memtype override. |
| 90 | */ |
Varun Wadekar | 4c7fa50 | 2016-12-13 13:13:42 -0800 | [diff] [blame] | 91 | #if ENABLE_AFI_DEVICE |
Varun Wadekar | a0f2697 | 2016-03-11 17:18:51 -0800 | [diff] [blame] | 92 | mc_set_tsa_passthrough(AFIW); |
Varun Wadekar | 4c7fa50 | 2016-12-13 13:13:42 -0800 | [diff] [blame] | 93 | #endif |
Varun Wadekar | a0f2697 | 2016-03-11 17:18:51 -0800 | [diff] [blame] | 94 | mc_set_tsa_passthrough(HDAW); |
| 95 | mc_set_tsa_passthrough(SATAW); |
| 96 | mc_set_tsa_passthrough(XUSB_HOSTW); |
| 97 | mc_set_tsa_passthrough(XUSB_DEVW); |
| 98 | mc_set_tsa_passthrough(SDMMCWAB); |
| 99 | mc_set_tsa_passthrough(APEDMAW); |
| 100 | mc_set_tsa_passthrough(SESWR); |
| 101 | mc_set_tsa_passthrough(ETRW); |
| 102 | mc_set_tsa_passthrough(AXISW); |
| 103 | mc_set_tsa_passthrough(EQOSW); |
| 104 | mc_set_tsa_passthrough(UFSHCW); |
| 105 | mc_set_tsa_passthrough(BPMPDMAW); |
| 106 | mc_set_tsa_passthrough(AONDMAW); |
| 107 | mc_set_tsa_passthrough(SCEDMAW); |
| 108 | |
| 109 | /* |
| 110 | * Change COH_PATH_OVERRIDE_SO_DEV from NO_OVERRIDE -> FORCE_COHERENT |
| 111 | * for boot and strongly ordered MSS clients. This steers all sodev |
| 112 | * transactions to ROC. |
| 113 | * |
| 114 | * Change AXID_OVERRIDE/AXID_OVERRIDE_SO_DEV only for some clients |
| 115 | * whose AXI IDs we know and trust. |
| 116 | */ |
| 117 | |
Varun Wadekar | 4c7fa50 | 2016-12-13 13:13:42 -0800 | [diff] [blame] | 118 | #if ENABLE_AFI_DEVICE |
Varun Wadekar | a0f2697 | 2016-03-11 17:18:51 -0800 | [diff] [blame] | 119 | /* Match AFIW */ |
| 120 | mc_set_forced_coherent_so_dev_cfg(AFIR); |
Varun Wadekar | 4c7fa50 | 2016-12-13 13:13:42 -0800 | [diff] [blame] | 121 | #endif |
Varun Wadekar | a0f2697 | 2016-03-11 17:18:51 -0800 | [diff] [blame] | 122 | |
| 123 | /* |
| 124 | * See bug 200131110 comment #35 - there are no normal requests |
| 125 | * and AWID for SO/DEV requests is hardcoded in RTL for a |
| 126 | * particular PCIE controller |
| 127 | */ |
Varun Wadekar | 4c7fa50 | 2016-12-13 13:13:42 -0800 | [diff] [blame] | 128 | #if ENABLE_AFI_DEVICE |
Varun Wadekar | a0f2697 | 2016-03-11 17:18:51 -0800 | [diff] [blame] | 129 | mc_set_forced_coherent_so_dev_cfg(AFIW); |
Varun Wadekar | 4c7fa50 | 2016-12-13 13:13:42 -0800 | [diff] [blame] | 130 | #endif |
Varun Wadekar | a0f2697 | 2016-03-11 17:18:51 -0800 | [diff] [blame] | 131 | mc_set_forced_coherent_cfg(HDAR); |
| 132 | mc_set_forced_coherent_cfg(HDAW); |
| 133 | mc_set_forced_coherent_cfg(SATAR); |
| 134 | mc_set_forced_coherent_cfg(SATAW); |
| 135 | mc_set_forced_coherent_cfg(XUSB_HOSTR); |
| 136 | mc_set_forced_coherent_cfg(XUSB_HOSTW); |
| 137 | mc_set_forced_coherent_cfg(XUSB_DEVR); |
| 138 | mc_set_forced_coherent_cfg(XUSB_DEVW); |
| 139 | mc_set_forced_coherent_cfg(SDMMCRAB); |
| 140 | mc_set_forced_coherent_cfg(SDMMCWAB); |
| 141 | |
| 142 | /* Match APEDMAW */ |
| 143 | mc_set_forced_coherent_axid_so_dev_cfg(APEDMAR); |
| 144 | |
| 145 | /* |
| 146 | * See bug 200131110 comment #35 - AWID for normal requests |
| 147 | * is 0x80 and AWID for SO/DEV requests is 0x01 |
| 148 | */ |
| 149 | mc_set_forced_coherent_axid_so_dev_cfg(APEDMAW); |
| 150 | mc_set_forced_coherent_cfg(SESRD); |
| 151 | mc_set_forced_coherent_cfg(SESWR); |
| 152 | mc_set_forced_coherent_cfg(ETRR); |
| 153 | mc_set_forced_coherent_cfg(ETRW); |
| 154 | mc_set_forced_coherent_cfg(AXISR); |
| 155 | mc_set_forced_coherent_cfg(AXISW); |
| 156 | mc_set_forced_coherent_cfg(EQOSR); |
| 157 | mc_set_forced_coherent_cfg(EQOSW); |
| 158 | mc_set_forced_coherent_cfg(UFSHCR); |
| 159 | mc_set_forced_coherent_cfg(UFSHCW); |
| 160 | mc_set_forced_coherent_cfg(BPMPDMAR); |
| 161 | mc_set_forced_coherent_cfg(BPMPDMAW); |
| 162 | mc_set_forced_coherent_cfg(AONDMAR); |
| 163 | mc_set_forced_coherent_cfg(AONDMAW); |
| 164 | mc_set_forced_coherent_cfg(SCEDMAR); |
| 165 | mc_set_forced_coherent_cfg(SCEDMAW); |
| 166 | |
| 167 | /* |
| 168 | * At this point, ordering can occur at ROC. So, remove PCFIFO's |
| 169 | * control over ordering requests. |
| 170 | * |
| 171 | * Change PCFIFO_*_ORDERED_CLIENT from ORDERED -> UNORDERED for |
| 172 | * boot and strongly ordered MSS clients |
| 173 | */ |
| 174 | val = MC_PCFIFO_CLIENT_CONFIG1_RESET_VAL & |
Varun Wadekar | 4c7fa50 | 2016-12-13 13:13:42 -0800 | [diff] [blame] | 175 | #if ENABLE_AFI_DEVICE |
Varun Wadekar | a0f2697 | 2016-03-11 17:18:51 -0800 | [diff] [blame] | 176 | mc_set_pcfifo_unordered_boot_so_mss(1, AFIW) & |
Varun Wadekar | 4c7fa50 | 2016-12-13 13:13:42 -0800 | [diff] [blame] | 177 | #endif |
Varun Wadekar | a0f2697 | 2016-03-11 17:18:51 -0800 | [diff] [blame] | 178 | mc_set_pcfifo_unordered_boot_so_mss(1, HDAW) & |
| 179 | mc_set_pcfifo_unordered_boot_so_mss(1, SATAW); |
| 180 | tegra_mc_write_32(MC_PCFIFO_CLIENT_CONFIG1, val); |
| 181 | |
| 182 | val = MC_PCFIFO_CLIENT_CONFIG2_RESET_VAL & |
| 183 | mc_set_pcfifo_unordered_boot_so_mss(2, XUSB_HOSTW) & |
| 184 | mc_set_pcfifo_unordered_boot_so_mss(2, XUSB_DEVW); |
| 185 | tegra_mc_write_32(MC_PCFIFO_CLIENT_CONFIG2, val); |
| 186 | |
| 187 | val = MC_PCFIFO_CLIENT_CONFIG3_RESET_VAL & |
| 188 | mc_set_pcfifo_unordered_boot_so_mss(3, SDMMCWAB); |
| 189 | tegra_mc_write_32(MC_PCFIFO_CLIENT_CONFIG3, val); |
| 190 | |
| 191 | val = MC_PCFIFO_CLIENT_CONFIG4_RESET_VAL & |
| 192 | mc_set_pcfifo_unordered_boot_so_mss(4, SESWR) & |
| 193 | mc_set_pcfifo_unordered_boot_so_mss(4, ETRW) & |
| 194 | mc_set_pcfifo_unordered_boot_so_mss(4, AXISW) & |
| 195 | mc_set_pcfifo_unordered_boot_so_mss(4, EQOSW) & |
| 196 | mc_set_pcfifo_unordered_boot_so_mss(4, UFSHCW) & |
| 197 | mc_set_pcfifo_unordered_boot_so_mss(4, BPMPDMAW) & |
| 198 | mc_set_pcfifo_unordered_boot_so_mss(4, AONDMAW) & |
| 199 | mc_set_pcfifo_unordered_boot_so_mss(4, SCEDMAW); |
| 200 | tegra_mc_write_32(MC_PCFIFO_CLIENT_CONFIG4, val); |
| 201 | |
| 202 | val = MC_PCFIFO_CLIENT_CONFIG5_RESET_VAL & |
| 203 | mc_set_pcfifo_unordered_boot_so_mss(5, APEDMAW); |
| 204 | tegra_mc_write_32(MC_PCFIFO_CLIENT_CONFIG5, val); |
| 205 | |
| 206 | /* |
| 207 | * At this point, ordering can occur at ROC. SMMU need not |
| 208 | * reorder any requests. |
| 209 | * |
| 210 | * Change SMMU_*_ORDERED_CLIENT from ORDERED -> UNORDERED |
| 211 | * for boot and strongly ordered MSS clients |
| 212 | */ |
| 213 | val = MC_SMMU_CLIENT_CONFIG1_RESET_VAL & |
Varun Wadekar | 4c7fa50 | 2016-12-13 13:13:42 -0800 | [diff] [blame] | 214 | #if ENABLE_AFI_DEVICE |
Varun Wadekar | a0f2697 | 2016-03-11 17:18:51 -0800 | [diff] [blame] | 215 | mc_set_smmu_unordered_boot_so_mss(1, AFIW) & |
Varun Wadekar | 4c7fa50 | 2016-12-13 13:13:42 -0800 | [diff] [blame] | 216 | #endif |
Varun Wadekar | a0f2697 | 2016-03-11 17:18:51 -0800 | [diff] [blame] | 217 | mc_set_smmu_unordered_boot_so_mss(1, HDAW) & |
| 218 | mc_set_smmu_unordered_boot_so_mss(1, SATAW); |
| 219 | tegra_mc_write_32(MC_SMMU_CLIENT_CONFIG1, val); |
| 220 | |
| 221 | val = MC_SMMU_CLIENT_CONFIG2_RESET_VAL & |
| 222 | mc_set_smmu_unordered_boot_so_mss(2, XUSB_HOSTW) & |
| 223 | mc_set_smmu_unordered_boot_so_mss(2, XUSB_DEVW); |
| 224 | tegra_mc_write_32(MC_SMMU_CLIENT_CONFIG2, val); |
| 225 | |
| 226 | val = MC_SMMU_CLIENT_CONFIG3_RESET_VAL & |
| 227 | mc_set_smmu_unordered_boot_so_mss(3, SDMMCWAB); |
| 228 | tegra_mc_write_32(MC_SMMU_CLIENT_CONFIG3, val); |
| 229 | |
| 230 | val = MC_SMMU_CLIENT_CONFIG4_RESET_VAL & |
| 231 | mc_set_smmu_unordered_boot_so_mss(4, SESWR) & |
| 232 | mc_set_smmu_unordered_boot_so_mss(4, ETRW) & |
| 233 | mc_set_smmu_unordered_boot_so_mss(4, AXISW) & |
| 234 | mc_set_smmu_unordered_boot_so_mss(4, EQOSW) & |
| 235 | mc_set_smmu_unordered_boot_so_mss(4, UFSHCW) & |
| 236 | mc_set_smmu_unordered_boot_so_mss(4, BPMPDMAW) & |
| 237 | mc_set_smmu_unordered_boot_so_mss(4, AONDMAW) & |
| 238 | mc_set_smmu_unordered_boot_so_mss(4, SCEDMAW); |
| 239 | tegra_mc_write_32(MC_SMMU_CLIENT_CONFIG4, val); |
| 240 | |
| 241 | val = MC_SMMU_CLIENT_CONFIG5_RESET_VAL & |
| 242 | mc_set_smmu_unordered_boot_so_mss(5, APEDMAW); |
| 243 | tegra_mc_write_32(MC_SMMU_CLIENT_CONFIG5, val); |
| 244 | |
| 245 | /* |
| 246 | * Deassert HOTRESET FLUSH_ENABLE for boot and strongly ordered MSS |
| 247 | * clients to allow memory traffic from all clients to start passing |
| 248 | * through ROC |
| 249 | */ |
| 250 | val = tegra_mc_read_32(MC_CLIENT_HOTRESET_CTRL0); |
| 251 | assert(val == wdata_0); |
| 252 | |
| 253 | wdata_0 = MC_CLIENT_HOTRESET_CTRL0_RESET_VAL; |
| 254 | tegra_mc_write_32(MC_CLIENT_HOTRESET_CTRL0, wdata_0); |
| 255 | |
Varun Wadekar | a0f2697 | 2016-03-11 17:18:51 -0800 | [diff] [blame] | 256 | val = tegra_mc_read_32(MC_CLIENT_HOTRESET_CTRL1); |
| 257 | assert(val == wdata_1); |
| 258 | |
| 259 | wdata_1 = MC_CLIENT_HOTRESET_CTRL1_RESET_VAL; |
| 260 | tegra_mc_write_32(MC_CLIENT_HOTRESET_CTRL1, wdata_1); |
| 261 | |
Varun Wadekar | a0f2697 | 2016-03-11 17:18:51 -0800 | [diff] [blame] | 262 | #endif |
| 263 | } |
| 264 | |
Varun Wadekar | ad45ef7 | 2017-04-03 13:44:57 -0700 | [diff] [blame] | 265 | static void tegra_memctrl_set_overrides(void) |
| 266 | { |
| 267 | tegra_mc_settings_t *plat_mc_settings = tegra_get_mc_settings(); |
| 268 | const mc_txn_override_cfg_t *mc_txn_override_cfgs; |
| 269 | uint32_t num_txn_override_cfgs; |
| 270 | uint32_t i, val; |
| 271 | |
| 272 | /* Get the settings from the platform */ |
| 273 | assert(plat_mc_settings); |
| 274 | mc_txn_override_cfgs = plat_mc_settings->txn_override_cfg; |
| 275 | num_txn_override_cfgs = plat_mc_settings->num_txn_override_cfgs; |
| 276 | |
| 277 | /* |
| 278 | * Set the MC_TXN_OVERRIDE registers for write clients. |
| 279 | */ |
| 280 | if ((tegra_chipid_is_t186()) && |
| 281 | (!tegra_platform_is_silicon() || |
| 282 | (tegra_platform_is_silicon() && (tegra_get_chipid_minor() == 1)))) { |
| 283 | |
| 284 | /* |
| 285 | * GPU and NVENC settings for Tegra186 simulation and |
| 286 | * Silicon rev. A01 |
| 287 | */ |
| 288 | val = tegra_mc_read_32(MC_TXN_OVERRIDE_CONFIG_GPUSWR); |
| 289 | val &= ~MC_TXN_OVERRIDE_CGID_TAG_MASK; |
| 290 | tegra_mc_write_32(MC_TXN_OVERRIDE_CONFIG_GPUSWR, |
| 291 | val | MC_TXN_OVERRIDE_CGID_TAG_ZERO); |
| 292 | |
| 293 | val = tegra_mc_read_32(MC_TXN_OVERRIDE_CONFIG_GPUSWR2); |
| 294 | val &= ~MC_TXN_OVERRIDE_CGID_TAG_MASK; |
| 295 | tegra_mc_write_32(MC_TXN_OVERRIDE_CONFIG_GPUSWR2, |
| 296 | val | MC_TXN_OVERRIDE_CGID_TAG_ZERO); |
| 297 | |
| 298 | val = tegra_mc_read_32(MC_TXN_OVERRIDE_CONFIG_NVENCSWR); |
| 299 | val &= ~MC_TXN_OVERRIDE_CGID_TAG_MASK; |
| 300 | tegra_mc_write_32(MC_TXN_OVERRIDE_CONFIG_NVENCSWR, |
| 301 | val | MC_TXN_OVERRIDE_CGID_TAG_CLIENT_AXI_ID); |
| 302 | |
| 303 | } else { |
| 304 | |
| 305 | /* |
| 306 | * Settings for Tegra186 silicon rev. A02 and onwards. |
| 307 | */ |
| 308 | for (i = 0; i < num_txn_override_cfgs; i++) { |
| 309 | val = tegra_mc_read_32(mc_txn_override_cfgs[i].offset); |
| 310 | val &= ~MC_TXN_OVERRIDE_CGID_TAG_MASK; |
| 311 | tegra_mc_write_32(mc_txn_override_cfgs[i].offset, |
| 312 | val | mc_txn_override_cfgs[i].cgid_tag); |
| 313 | } |
| 314 | } |
| 315 | } |
| 316 | |
Varun Wadekar | cd5a2f5 | 2015-09-20 15:08:22 +0530 | [diff] [blame] | 317 | /* |
Varun Wadekar | 87e44ff | 2016-03-03 13:22:39 -0800 | [diff] [blame] | 318 | * Init Memory controller during boot. |
Varun Wadekar | cd5a2f5 | 2015-09-20 15:08:22 +0530 | [diff] [blame] | 319 | */ |
| 320 | void tegra_memctrl_setup(void) |
| 321 | { |
| 322 | uint32_t val; |
Pritesh Raithatha | 9eb5db5 | 2017-01-02 19:42:31 +0530 | [diff] [blame] | 323 | const uint32_t *mc_streamid_override_regs; |
| 324 | uint32_t num_streamid_override_regs; |
| 325 | const mc_streamid_security_cfg_t *mc_streamid_sec_cfgs; |
| 326 | uint32_t num_streamid_sec_cfgs; |
Pritesh Raithatha | 9eb5db5 | 2017-01-02 19:42:31 +0530 | [diff] [blame] | 327 | tegra_mc_settings_t *plat_mc_settings = tegra_get_mc_settings(); |
Varun Wadekar | ad45ef7 | 2017-04-03 13:44:57 -0700 | [diff] [blame] | 328 | uint32_t i; |
Varun Wadekar | cd5a2f5 | 2015-09-20 15:08:22 +0530 | [diff] [blame] | 329 | |
| 330 | INFO("Tegra Memory Controller (v2)\n"); |
| 331 | |
Varun Wadekar | 6cb25f9 | 2016-12-19 11:17:54 -0800 | [diff] [blame] | 332 | #if ENABLE_SMMU_DEVICE |
Varun Wadekar | cd5a2f5 | 2015-09-20 15:08:22 +0530 | [diff] [blame] | 333 | /* Program the SMMU pagesize */ |
Varun Wadekar | 87e44ff | 2016-03-03 13:22:39 -0800 | [diff] [blame] | 334 | tegra_smmu_init(); |
Varun Wadekar | 6cb25f9 | 2016-12-19 11:17:54 -0800 | [diff] [blame] | 335 | #endif |
Pritesh Raithatha | 9eb5db5 | 2017-01-02 19:42:31 +0530 | [diff] [blame] | 336 | /* Get the settings from the platform */ |
| 337 | assert(plat_mc_settings); |
| 338 | mc_streamid_override_regs = plat_mc_settings->streamid_override_cfg; |
| 339 | num_streamid_override_regs = plat_mc_settings->num_streamid_override_cfgs; |
| 340 | mc_streamid_sec_cfgs = plat_mc_settings->streamid_security_cfg; |
| 341 | num_streamid_sec_cfgs = plat_mc_settings->num_streamid_security_cfgs; |
Varun Wadekar | cd5a2f5 | 2015-09-20 15:08:22 +0530 | [diff] [blame] | 342 | |
| 343 | /* Program all the Stream ID overrides */ |
Pritesh Raithatha | 9eb5db5 | 2017-01-02 19:42:31 +0530 | [diff] [blame] | 344 | for (i = 0; i < num_streamid_override_regs; i++) |
| 345 | tegra_mc_streamid_write_32(mc_streamid_override_regs[i], |
Varun Wadekar | cd5a2f5 | 2015-09-20 15:08:22 +0530 | [diff] [blame] | 346 | MC_STREAM_ID_MAX); |
| 347 | |
| 348 | /* Program the security config settings for all Stream IDs */ |
Pritesh Raithatha | 9eb5db5 | 2017-01-02 19:42:31 +0530 | [diff] [blame] | 349 | for (i = 0; i < num_streamid_sec_cfgs; i++) { |
| 350 | val = mc_streamid_sec_cfgs[i].override_enable << 16 | |
| 351 | mc_streamid_sec_cfgs[i].override_client_inputs << 8 | |
| 352 | mc_streamid_sec_cfgs[i].override_client_ns_flag << 0; |
| 353 | tegra_mc_streamid_write_32(mc_streamid_sec_cfgs[i].offset, val); |
Varun Wadekar | cd5a2f5 | 2015-09-20 15:08:22 +0530 | [diff] [blame] | 354 | } |
| 355 | |
| 356 | /* |
| 357 | * All requests at boot time, and certain requests during |
| 358 | * normal run time, are physically addressed and must bypass |
| 359 | * the SMMU. The client hub logic implements a hardware bypass |
| 360 | * path around the Translation Buffer Units (TBU). During |
| 361 | * boot-time, the SMMU_BYPASS_CTRL register (which defaults to |
| 362 | * TBU_BYPASS mode) will be used to steer all requests around |
| 363 | * the uninitialized TBUs. During normal operation, this register |
| 364 | * is locked into TBU_BYPASS_SID config, which routes requests |
| 365 | * with special StreamID 0x7f on the bypass path and all others |
| 366 | * through the selected TBU. This is done to disable SMMU Bypass |
| 367 | * mode, as it could be used to circumvent SMMU security checks. |
| 368 | */ |
| 369 | tegra_mc_write_32(MC_SMMU_BYPASS_CONFIG, |
Pritesh Raithatha | 9eb5db5 | 2017-01-02 19:42:31 +0530 | [diff] [blame] | 370 | MC_SMMU_BYPASS_CONFIG_SETTINGS); |
Varun Wadekar | cd5a2f5 | 2015-09-20 15:08:22 +0530 | [diff] [blame] | 371 | |
Varun Wadekar | c9ac3e4 | 2016-02-17 15:07:49 -0800 | [diff] [blame] | 372 | /* |
Varun Wadekar | a0f2697 | 2016-03-11 17:18:51 -0800 | [diff] [blame] | 373 | * Re-configure MSS to allow ROC to deal with ordering of the |
| 374 | * Memory Controller traffic. This is needed as the Memory Controller |
| 375 | * boots with MSS having all control, but ROC provides a performance |
| 376 | * boost as compared to MSS. |
| 377 | */ |
| 378 | tegra_memctrl_reconfig_mss_clients(); |
| 379 | |
Varun Wadekar | ad45ef7 | 2017-04-03 13:44:57 -0700 | [diff] [blame] | 380 | /* Program overrides for MC transactions */ |
| 381 | tegra_memctrl_set_overrides(); |
Varun Wadekar | 87e44ff | 2016-03-03 13:22:39 -0800 | [diff] [blame] | 382 | } |
Varun Wadekar | c9ac3e4 | 2016-02-17 15:07:49 -0800 | [diff] [blame] | 383 | |
Varun Wadekar | 87e44ff | 2016-03-03 13:22:39 -0800 | [diff] [blame] | 384 | /* |
| 385 | * Restore Memory Controller settings after "System Suspend" |
| 386 | */ |
| 387 | void tegra_memctrl_restore_settings(void) |
| 388 | { |
Varun Wadekar | a0f2697 | 2016-03-11 17:18:51 -0800 | [diff] [blame] | 389 | /* |
| 390 | * Re-configure MSS to allow ROC to deal with ordering of the |
| 391 | * Memory Controller traffic. This is needed as the Memory Controller |
| 392 | * resets during System Suspend with MSS having all control, but ROC |
| 393 | * provides a performance boost as compared to MSS. |
| 394 | */ |
| 395 | tegra_memctrl_reconfig_mss_clients(); |
| 396 | |
Varun Wadekar | ad45ef7 | 2017-04-03 13:44:57 -0700 | [diff] [blame] | 397 | /* Program overrides for MC transactions */ |
| 398 | tegra_memctrl_set_overrides(); |
| 399 | |
Varun Wadekar | cd5a2f5 | 2015-09-20 15:08:22 +0530 | [diff] [blame] | 400 | /* video memory carveout region */ |
| 401 | if (video_mem_base) { |
| 402 | tegra_mc_write_32(MC_VIDEO_PROTECT_BASE_LO, |
| 403 | (uint32_t)video_mem_base); |
| 404 | tegra_mc_write_32(MC_VIDEO_PROTECT_BASE_HI, |
| 405 | (uint32_t)(video_mem_base >> 32)); |
Varun Wadekar | 7058aee | 2016-04-25 09:01:46 -0700 | [diff] [blame] | 406 | tegra_mc_write_32(MC_VIDEO_PROTECT_SIZE_MB, video_mem_size_mb); |
Varun Wadekar | cd5a2f5 | 2015-09-20 15:08:22 +0530 | [diff] [blame] | 407 | |
| 408 | /* |
Varun Wadekar | 153982c | 2016-12-21 14:50:18 -0800 | [diff] [blame] | 409 | * MCE propagates the VideoMem configuration values across the |
Varun Wadekar | cd5a2f5 | 2015-09-20 15:08:22 +0530 | [diff] [blame] | 410 | * CCPLEX. |
| 411 | */ |
| 412 | mce_update_gsc_videomem(); |
| 413 | } |
| 414 | } |
| 415 | |
| 416 | /* |
| 417 | * Secure the BL31 DRAM aperture. |
| 418 | * |
| 419 | * phys_base = physical base of TZDRAM aperture |
| 420 | * size_in_bytes = size of aperture in bytes |
| 421 | */ |
| 422 | void tegra_memctrl_tzdram_setup(uint64_t phys_base, uint32_t size_in_bytes) |
| 423 | { |
| 424 | /* |
| 425 | * Setup the Memory controller to allow only secure accesses to |
| 426 | * the TZDRAM carveout |
| 427 | */ |
| 428 | INFO("Configuring TrustZone DRAM Memory Carveout\n"); |
| 429 | |
| 430 | tegra_mc_write_32(MC_SECURITY_CFG0_0, (uint32_t)phys_base); |
| 431 | tegra_mc_write_32(MC_SECURITY_CFG3_0, (uint32_t)(phys_base >> 32)); |
| 432 | tegra_mc_write_32(MC_SECURITY_CFG1_0, size_in_bytes >> 20); |
| 433 | |
| 434 | /* |
Harvey Hsieh | c95802d | 2016-07-29 20:10:59 +0800 | [diff] [blame] | 435 | * When TZ encryption enabled, |
| 436 | * We need setup TZDRAM before CPU to access TZ Carveout, |
| 437 | * otherwise CPU will fetch non-decrypted data. |
| 438 | * So save TZDRAM setting for retore by SC7 resume FW. |
| 439 | */ |
| 440 | |
| 441 | mmio_write_32(TEGRA_SCRATCH_BASE + SECURE_SCRATCH_RSV55_LO, |
| 442 | tegra_mc_read_32(MC_SECURITY_CFG0_0)); |
| 443 | mmio_write_32(TEGRA_SCRATCH_BASE + SECURE_SCRATCH_RSV55_HI, |
| 444 | tegra_mc_read_32(MC_SECURITY_CFG3_0)); |
| 445 | mmio_write_32(TEGRA_SCRATCH_BASE + SECURE_SCRATCH_RSV54_HI, |
| 446 | tegra_mc_read_32(MC_SECURITY_CFG1_0)); |
| 447 | |
| 448 | /* |
Varun Wadekar | 153982c | 2016-12-21 14:50:18 -0800 | [diff] [blame] | 449 | * MCE propagates the security configuration values across the |
Varun Wadekar | cd5a2f5 | 2015-09-20 15:08:22 +0530 | [diff] [blame] | 450 | * CCPLEX. |
| 451 | */ |
| 452 | mce_update_gsc_tzdram(); |
| 453 | } |
| 454 | |
| 455 | /* |
Varun Wadekar | 13e7dc4 | 2015-12-30 15:15:08 -0800 | [diff] [blame] | 456 | * Secure the BL31 TZRAM aperture. |
| 457 | * |
| 458 | * phys_base = physical base of TZRAM aperture |
| 459 | * size_in_bytes = size of aperture in bytes |
| 460 | */ |
| 461 | void tegra_memctrl_tzram_setup(uint64_t phys_base, uint32_t size_in_bytes) |
| 462 | { |
Varun Wadekar | e6d4322 | 2016-05-25 16:35:04 -0700 | [diff] [blame] | 463 | uint32_t index; |
| 464 | uint32_t total_128kb_blocks = size_in_bytes >> 17; |
Varun Wadekar | 153982c | 2016-12-21 14:50:18 -0800 | [diff] [blame] | 465 | uint32_t residual_4kb_blocks = (size_in_bytes & (uint32_t)0x1FFFF) >> 12; |
Varun Wadekar | 13e7dc4 | 2015-12-30 15:15:08 -0800 | [diff] [blame] | 466 | uint32_t val; |
| 467 | |
Varun Wadekar | 153982c | 2016-12-21 14:50:18 -0800 | [diff] [blame] | 468 | INFO("Configuring TrustZone SRAM Memory Carveout\n"); |
| 469 | |
Varun Wadekar | 13e7dc4 | 2015-12-30 15:15:08 -0800 | [diff] [blame] | 470 | /* |
Varun Wadekar | e6d4322 | 2016-05-25 16:35:04 -0700 | [diff] [blame] | 471 | * Reset the access configuration registers to restrict access |
| 472 | * to the TZRAM aperture |
Varun Wadekar | 13e7dc4 | 2015-12-30 15:15:08 -0800 | [diff] [blame] | 473 | */ |
Varun Wadekar | 153982c | 2016-12-21 14:50:18 -0800 | [diff] [blame] | 474 | for (index = MC_TZRAM_CLIENT_ACCESS_CFG0; |
| 475 | index < ((uint32_t)MC_TZRAM_CARVEOUT_CFG + (uint32_t)MC_GSC_CONFIG_REGS_SIZE); |
| 476 | index += 4U) { |
Varun Wadekar | e6d4322 | 2016-05-25 16:35:04 -0700 | [diff] [blame] | 477 | tegra_mc_write_32(index, 0); |
Varun Wadekar | 153982c | 2016-12-21 14:50:18 -0800 | [diff] [blame] | 478 | } |
Varun Wadekar | 13e7dc4 | 2015-12-30 15:15:08 -0800 | [diff] [blame] | 479 | |
| 480 | /* |
Varun Wadekar | e6d4322 | 2016-05-25 16:35:04 -0700 | [diff] [blame] | 481 | * Set the TZRAM base. TZRAM base must be 4k aligned, at least. |
| 482 | */ |
Varun Wadekar | 153982c | 2016-12-21 14:50:18 -0800 | [diff] [blame] | 483 | assert((phys_base & (uint64_t)0xFFF) == 0U); |
Varun Wadekar | e6d4322 | 2016-05-25 16:35:04 -0700 | [diff] [blame] | 484 | tegra_mc_write_32(MC_TZRAM_BASE_LO, (uint32_t)phys_base); |
| 485 | tegra_mc_write_32(MC_TZRAM_BASE_HI, |
Varun Wadekar | 153982c | 2016-12-21 14:50:18 -0800 | [diff] [blame] | 486 | (uint32_t)(phys_base >> 32) & MC_GSC_BASE_HI_MASK); |
Varun Wadekar | 13e7dc4 | 2015-12-30 15:15:08 -0800 | [diff] [blame] | 487 | |
Varun Wadekar | e6d4322 | 2016-05-25 16:35:04 -0700 | [diff] [blame] | 488 | /* |
| 489 | * Set the TZRAM size |
| 490 | * |
| 491 | * total size = (number of 128KB blocks) + (number of remaining 4KB |
| 492 | * blocks) |
| 493 | * |
| 494 | */ |
Varun Wadekar | 153982c | 2016-12-21 14:50:18 -0800 | [diff] [blame] | 495 | val = (residual_4kb_blocks << MC_GSC_SIZE_RANGE_4KB_SHIFT) | |
Varun Wadekar | e6d4322 | 2016-05-25 16:35:04 -0700 | [diff] [blame] | 496 | total_128kb_blocks; |
| 497 | tegra_mc_write_32(MC_TZRAM_SIZE, val); |
Varun Wadekar | 13e7dc4 | 2015-12-30 15:15:08 -0800 | [diff] [blame] | 498 | |
Varun Wadekar | e6d4322 | 2016-05-25 16:35:04 -0700 | [diff] [blame] | 499 | /* |
| 500 | * Lock the configuration settings by disabling TZ-only lock |
| 501 | * and locking the configuration against any future changes |
| 502 | * at all. |
| 503 | */ |
| 504 | val = tegra_mc_read_32(MC_TZRAM_CARVEOUT_CFG); |
Varun Wadekar | 153982c | 2016-12-21 14:50:18 -0800 | [diff] [blame] | 505 | val &= ~MC_GSC_ENABLE_TZ_LOCK_BIT; |
| 506 | val |= MC_GSC_LOCK_CFG_SETTINGS_BIT; |
Varun Wadekar | e6d4322 | 2016-05-25 16:35:04 -0700 | [diff] [blame] | 507 | tegra_mc_write_32(MC_TZRAM_CARVEOUT_CFG, val); |
Varun Wadekar | 13e7dc4 | 2015-12-30 15:15:08 -0800 | [diff] [blame] | 508 | |
| 509 | /* |
Varun Wadekar | 153982c | 2016-12-21 14:50:18 -0800 | [diff] [blame] | 510 | * MCE propagates the security configuration values across the |
Varun Wadekar | 13e7dc4 | 2015-12-30 15:15:08 -0800 | [diff] [blame] | 511 | * CCPLEX. |
| 512 | */ |
| 513 | mce_update_gsc_tzram(); |
| 514 | } |
| 515 | |
Varun Wadekar | 153982c | 2016-12-21 14:50:18 -0800 | [diff] [blame] | 516 | static void tegra_lock_videomem_nonoverlap(uint64_t phys_base, |
| 517 | uint64_t size_in_bytes) |
| 518 | { |
| 519 | uint32_t index; |
| 520 | uint64_t total_128kb_blocks = size_in_bytes >> 17; |
| 521 | uint64_t residual_4kb_blocks = (size_in_bytes & (uint32_t)0x1FFFF) >> 12; |
| 522 | uint64_t val; |
| 523 | |
| 524 | /* |
| 525 | * Reset the access configuration registers to restrict access to |
| 526 | * old Videomem aperture |
| 527 | */ |
| 528 | for (index = MC_VIDEO_PROTECT_CLEAR_ACCESS_CFG0; |
| 529 | index < ((uint32_t)MC_VIDEO_PROTECT_CLEAR_ACCESS_CFG0 + (uint32_t)MC_GSC_CONFIG_REGS_SIZE); |
| 530 | index += 4U) { |
| 531 | tegra_mc_write_32(index, 0); |
| 532 | } |
| 533 | |
| 534 | /* |
| 535 | * Set the base. It must be 4k aligned, at least. |
| 536 | */ |
| 537 | assert((phys_base & (uint64_t)0xFFF) == 0U); |
| 538 | tegra_mc_write_32(MC_VIDEO_PROTECT_CLEAR_BASE_LO, (uint32_t)phys_base); |
| 539 | tegra_mc_write_32(MC_VIDEO_PROTECT_CLEAR_BASE_HI, |
| 540 | (uint32_t)(phys_base >> 32) & (uint32_t)MC_GSC_BASE_HI_MASK); |
| 541 | |
| 542 | /* |
| 543 | * Set the aperture size |
| 544 | * |
| 545 | * total size = (number of 128KB blocks) + (number of remaining 4KB |
| 546 | * blocks) |
| 547 | * |
| 548 | */ |
| 549 | val = (uint32_t)((residual_4kb_blocks << MC_GSC_SIZE_RANGE_4KB_SHIFT) | |
| 550 | total_128kb_blocks); |
| 551 | tegra_mc_write_32(MC_VIDEO_PROTECT_CLEAR_SIZE, (uint32_t)val); |
| 552 | |
| 553 | /* |
| 554 | * Lock the configuration settings by enabling TZ-only lock and |
| 555 | * locking the configuration against any future changes from NS |
| 556 | * world. |
| 557 | */ |
| 558 | tegra_mc_write_32(MC_VIDEO_PROTECT_CLEAR_CFG, |
| 559 | (uint32_t)MC_GSC_ENABLE_TZ_LOCK_BIT); |
| 560 | |
| 561 | /* |
| 562 | * MCE propagates the GSC configuration values across the |
| 563 | * CCPLEX. |
| 564 | */ |
| 565 | } |
| 566 | |
| 567 | static void tegra_unlock_videomem_nonoverlap(void) |
| 568 | { |
| 569 | /* Clear the base */ |
| 570 | tegra_mc_write_32(MC_VIDEO_PROTECT_CLEAR_BASE_LO, 0); |
| 571 | tegra_mc_write_32(MC_VIDEO_PROTECT_CLEAR_BASE_HI, 0); |
| 572 | |
| 573 | /* Clear the size */ |
| 574 | tegra_mc_write_32(MC_VIDEO_PROTECT_CLEAR_SIZE, 0); |
| 575 | } |
| 576 | |
| 577 | static void tegra_clear_videomem(uintptr_t non_overlap_area_start, |
| 578 | unsigned long long non_overlap_area_size) |
| 579 | { |
| 580 | /* |
| 581 | * Map the NS memory first, clean it and then unmap it. |
| 582 | */ |
| 583 | mmap_add_dynamic_region(non_overlap_area_start, /* PA */ |
| 584 | non_overlap_area_start, /* VA */ |
| 585 | non_overlap_area_size, /* size */ |
| 586 | MT_NS | MT_RW | MT_EXECUTE_NEVER); /* attrs */ |
| 587 | |
| 588 | zero_normalmem((void *)non_overlap_area_start, non_overlap_area_size); |
| 589 | flush_dcache_range(non_overlap_area_start, non_overlap_area_size); |
| 590 | |
| 591 | mmap_remove_dynamic_region(non_overlap_area_start, |
| 592 | non_overlap_area_size); |
| 593 | } |
| 594 | |
Varun Wadekar | 13e7dc4 | 2015-12-30 15:15:08 -0800 | [diff] [blame] | 595 | /* |
Varun Wadekar | cd5a2f5 | 2015-09-20 15:08:22 +0530 | [diff] [blame] | 596 | * Program the Video Memory carveout region |
| 597 | * |
| 598 | * phys_base = physical base of aperture |
| 599 | * size_in_bytes = size of aperture in bytes |
| 600 | */ |
| 601 | void tegra_memctrl_videomem_setup(uint64_t phys_base, uint32_t size_in_bytes) |
| 602 | { |
Varun Wadekar | 153982c | 2016-12-21 14:50:18 -0800 | [diff] [blame] | 603 | uintptr_t vmem_end_old = video_mem_base + (video_mem_size_mb << 20); |
| 604 | uintptr_t vmem_end_new = phys_base + size_in_bytes; |
Varun Wadekar | 153982c | 2016-12-21 14:50:18 -0800 | [diff] [blame] | 605 | unsigned long long non_overlap_area_size; |
Varun Wadekar | e60f1bf | 2016-02-17 10:10:50 -0800 | [diff] [blame] | 606 | |
| 607 | /* |
Varun Wadekar | cd5a2f5 | 2015-09-20 15:08:22 +0530 | [diff] [blame] | 608 | * Setup the Memory controller to restrict CPU accesses to the Video |
| 609 | * Memory region |
| 610 | */ |
| 611 | INFO("Configuring Video Memory Carveout\n"); |
| 612 | |
Varun Wadekar | 153982c | 2016-12-21 14:50:18 -0800 | [diff] [blame] | 613 | /* |
| 614 | * Configure Memory Controller directly for the first time. |
| 615 | */ |
| 616 | if (video_mem_base == 0U) |
| 617 | goto done; |
| 618 | |
| 619 | /* |
| 620 | * Lock the non overlapping memory being cleared so that other masters |
| 621 | * do not accidently write to it. The memory would be unlocked once |
| 622 | * the non overlapping region is cleared and the new memory |
| 623 | * settings take effect. |
| 624 | */ |
| 625 | tegra_lock_videomem_nonoverlap(video_mem_base, |
| 626 | video_mem_size_mb << 20); |
| 627 | |
| 628 | /* |
| 629 | * Clear the old regions now being exposed. The following cases |
| 630 | * can occur - |
| 631 | * |
| 632 | * 1. clear whole old region (no overlap with new region) |
| 633 | * 2. clear old sub-region below new base |
| 634 | * 3. clear old sub-region above new end |
| 635 | */ |
| 636 | INFO("Cleaning previous Video Memory Carveout\n"); |
| 637 | |
| 638 | if (phys_base > vmem_end_old || video_mem_base > vmem_end_new) { |
| 639 | tegra_clear_videomem(video_mem_base, |
| 640 | (uint64_t)video_mem_size_mb << 20); |
| 641 | } else { |
| 642 | if (video_mem_base < phys_base) { |
| 643 | non_overlap_area_size = phys_base - video_mem_base; |
| 644 | tegra_clear_videomem(video_mem_base, non_overlap_area_size); |
| 645 | } |
| 646 | if (vmem_end_old > vmem_end_new) { |
| 647 | non_overlap_area_size = vmem_end_old - vmem_end_new; |
| 648 | tegra_clear_videomem(vmem_end_new, non_overlap_area_size); |
| 649 | } |
| 650 | } |
| 651 | |
| 652 | done: |
| 653 | /* program the Videomem aperture */ |
Varun Wadekar | cd5a2f5 | 2015-09-20 15:08:22 +0530 | [diff] [blame] | 654 | tegra_mc_write_32(MC_VIDEO_PROTECT_BASE_LO, (uint32_t)phys_base); |
| 655 | tegra_mc_write_32(MC_VIDEO_PROTECT_BASE_HI, |
| 656 | (uint32_t)(phys_base >> 32)); |
Varun Wadekar | 7058aee | 2016-04-25 09:01:46 -0700 | [diff] [blame] | 657 | tegra_mc_write_32(MC_VIDEO_PROTECT_SIZE_MB, size_in_bytes >> 20); |
Varun Wadekar | cd5a2f5 | 2015-09-20 15:08:22 +0530 | [diff] [blame] | 658 | |
Varun Wadekar | 153982c | 2016-12-21 14:50:18 -0800 | [diff] [blame] | 659 | /* unlock the previous locked nonoverlapping aperture */ |
| 660 | tegra_unlock_videomem_nonoverlap(); |
| 661 | |
Varun Wadekar | cd5a2f5 | 2015-09-20 15:08:22 +0530 | [diff] [blame] | 662 | /* store new values */ |
| 663 | video_mem_base = phys_base; |
Varun Wadekar | 7058aee | 2016-04-25 09:01:46 -0700 | [diff] [blame] | 664 | video_mem_size_mb = size_in_bytes >> 20; |
Varun Wadekar | cd5a2f5 | 2015-09-20 15:08:22 +0530 | [diff] [blame] | 665 | |
| 666 | /* |
Varun Wadekar | 153982c | 2016-12-21 14:50:18 -0800 | [diff] [blame] | 667 | * MCE propagates the VideoMem configuration values across the |
Varun Wadekar | cd5a2f5 | 2015-09-20 15:08:22 +0530 | [diff] [blame] | 668 | * CCPLEX. |
| 669 | */ |
| 670 | mce_update_gsc_videomem(); |
| 671 | } |
Varun Wadekar | c92050b | 2017-03-29 14:57:29 -0700 | [diff] [blame] | 672 | |
| 673 | /* |
| 674 | * This feature exists only for v1 of the Tegra Memory Controller. |
| 675 | */ |
| 676 | void tegra_memctrl_disable_ahb_redirection(void) |
| 677 | { |
| 678 | ; /* do nothing */ |
| 679 | } |