blob: 2d91cb290ea1385c3301c41b8ad24ddac3d081f6 [file] [log] [blame]
Varun Wadekarcd5a2f52015-09-20 15:08:22 +05301/*
Harvey Hsiehb9b374f2016-11-15 22:04:51 +08002 * Copyright (c) 2015-2017, ARM Limited and Contributors. All rights reserved.
Varun Wadekard292e5d2018-05-17 10:42:18 -07003 * Copyright (c) 2019-2020, NVIDIA Corporation. All rights reserved.
Varun Wadekarcd5a2f52015-09-20 15:08:22 +05304 *
dp-armfa3cf0b2017-05-03 09:38:09 +01005 * SPDX-License-Identifier: BSD-3-Clause
Varun Wadekarcd5a2f52015-09-20 15:08:22 +05306 */
7
Varun Wadekarcd5a2f52015-09-20 15:08:22 +05308#include <assert.h>
Antonio Nino Diaze0f90632018-12-14 00:18:21 +00009#include <string.h>
10
11#include <arch_helpers.h>
12#include <common/bl_common.h>
13#include <common/debug.h>
14#include <lib/mmio.h>
15#include <lib/utils.h>
16#include <lib/xlat_tables/xlat_tables_v2.h>
17
Varun Wadekarcd5a2f52015-09-20 15:08:22 +053018#include <mce.h>
19#include <memctrl.h>
20#include <memctrl_v2.h>
Varun Wadekar87e44ff2016-03-03 13:22:39 -080021#include <smmu.h>
Varun Wadekarcd5a2f52015-09-20 15:08:22 +053022#include <tegra_def.h>
Varun Wadekare81177d2016-07-18 17:43:41 -070023#include <tegra_platform.h>
Pritesh Raithatha75c94432018-08-03 15:48:15 +053024#include <tegra_private.h>
Varun Wadekarcd5a2f52015-09-20 15:08:22 +053025
26/* Video Memory base and size (live values) */
27static uint64_t video_mem_base;
Varun Wadekar7058aee2016-04-25 09:01:46 -070028static uint64_t video_mem_size_mb;
Varun Wadekarcd5a2f52015-09-20 15:08:22 +053029
Varun Wadekarcd5a2f52015-09-20 15:08:22 +053030/*
Varun Wadekar87e44ff2016-03-03 13:22:39 -080031 * Init Memory controller during boot.
Varun Wadekarcd5a2f52015-09-20 15:08:22 +053032 */
33void tegra_memctrl_setup(void)
34{
35 uint32_t val;
Pritesh Raithatha9eb5db52017-01-02 19:42:31 +053036 const uint32_t *mc_streamid_override_regs;
37 uint32_t num_streamid_override_regs;
38 const mc_streamid_security_cfg_t *mc_streamid_sec_cfgs;
39 uint32_t num_streamid_sec_cfgs;
Anthony Zhou0844b972017-06-28 16:35:54 +080040 const tegra_mc_settings_t *plat_mc_settings = tegra_get_mc_settings();
Varun Wadekarad45ef72017-04-03 13:44:57 -070041 uint32_t i;
Varun Wadekarcd5a2f52015-09-20 15:08:22 +053042
43 INFO("Tegra Memory Controller (v2)\n");
44
45 /* Program the SMMU pagesize */
Varun Wadekar87e44ff2016-03-03 13:22:39 -080046 tegra_smmu_init();
Varun Wadekarcba05292017-11-29 17:14:24 -080047
Pritesh Raithatha9eb5db52017-01-02 19:42:31 +053048 /* Get the settings from the platform */
Anthony Zhou4408e882017-07-07 14:29:51 +080049 assert(plat_mc_settings != NULL);
Pritesh Raithatha9eb5db52017-01-02 19:42:31 +053050 mc_streamid_override_regs = plat_mc_settings->streamid_override_cfg;
51 num_streamid_override_regs = plat_mc_settings->num_streamid_override_cfgs;
52 mc_streamid_sec_cfgs = plat_mc_settings->streamid_security_cfg;
53 num_streamid_sec_cfgs = plat_mc_settings->num_streamid_security_cfgs;
Varun Wadekarcd5a2f52015-09-20 15:08:22 +053054
55 /* Program all the Stream ID overrides */
Pritesh Raithatha9eb5db52017-01-02 19:42:31 +053056 for (i = 0; i < num_streamid_override_regs; i++)
57 tegra_mc_streamid_write_32(mc_streamid_override_regs[i],
Varun Wadekarcd5a2f52015-09-20 15:08:22 +053058 MC_STREAM_ID_MAX);
59
60 /* Program the security config settings for all Stream IDs */
Pritesh Raithatha9eb5db52017-01-02 19:42:31 +053061 for (i = 0; i < num_streamid_sec_cfgs; i++) {
62 val = mc_streamid_sec_cfgs[i].override_enable << 16 |
63 mc_streamid_sec_cfgs[i].override_client_inputs << 8 |
64 mc_streamid_sec_cfgs[i].override_client_ns_flag << 0;
65 tegra_mc_streamid_write_32(mc_streamid_sec_cfgs[i].offset, val);
Varun Wadekarcd5a2f52015-09-20 15:08:22 +053066 }
67
68 /*
69 * All requests at boot time, and certain requests during
70 * normal run time, are physically addressed and must bypass
71 * the SMMU. The client hub logic implements a hardware bypass
72 * path around the Translation Buffer Units (TBU). During
73 * boot-time, the SMMU_BYPASS_CTRL register (which defaults to
74 * TBU_BYPASS mode) will be used to steer all requests around
75 * the uninitialized TBUs. During normal operation, this register
76 * is locked into TBU_BYPASS_SID config, which routes requests
77 * with special StreamID 0x7f on the bypass path and all others
78 * through the selected TBU. This is done to disable SMMU Bypass
79 * mode, as it could be used to circumvent SMMU security checks.
80 */
81 tegra_mc_write_32(MC_SMMU_BYPASS_CONFIG,
Pritesh Raithatha9eb5db52017-01-02 19:42:31 +053082 MC_SMMU_BYPASS_CONFIG_SETTINGS);
Varun Wadekarcd5a2f52015-09-20 15:08:22 +053083
Varun Wadekarc9ac3e42016-02-17 15:07:49 -080084 /*
Varun Wadekara0f26972016-03-11 17:18:51 -080085 * Re-configure MSS to allow ROC to deal with ordering of the
86 * Memory Controller traffic. This is needed as the Memory Controller
87 * boots with MSS having all control, but ROC provides a performance
88 * boost as compared to MSS.
89 */
Puneet Saxenacf8c0e22017-08-04 17:19:55 +053090 if (plat_mc_settings->reconfig_mss_clients != NULL) {
91 plat_mc_settings->reconfig_mss_clients();
92 }
Varun Wadekara0f26972016-03-11 17:18:51 -080093
Varun Wadekarad45ef72017-04-03 13:44:57 -070094 /* Program overrides for MC transactions */
Puneet Saxenacf8c0e22017-08-04 17:19:55 +053095 if (plat_mc_settings->set_txn_overrides != NULL) {
96 plat_mc_settings->set_txn_overrides();
97 }
Varun Wadekar87e44ff2016-03-03 13:22:39 -080098}
Varun Wadekarc9ac3e42016-02-17 15:07:49 -080099
Varun Wadekar87e44ff2016-03-03 13:22:39 -0800100/*
101 * Restore Memory Controller settings after "System Suspend"
102 */
103void tegra_memctrl_restore_settings(void)
104{
Puneet Saxenacf8c0e22017-08-04 17:19:55 +0530105 const tegra_mc_settings_t *plat_mc_settings = tegra_get_mc_settings();
106
107 assert(plat_mc_settings != NULL);
108
Varun Wadekara0f26972016-03-11 17:18:51 -0800109 /*
110 * Re-configure MSS to allow ROC to deal with ordering of the
111 * Memory Controller traffic. This is needed as the Memory Controller
112 * resets during System Suspend with MSS having all control, but ROC
113 * provides a performance boost as compared to MSS.
114 */
Puneet Saxenacf8c0e22017-08-04 17:19:55 +0530115 if (plat_mc_settings->reconfig_mss_clients != NULL) {
116 plat_mc_settings->reconfig_mss_clients();
117 }
Varun Wadekara0f26972016-03-11 17:18:51 -0800118
Varun Wadekarad45ef72017-04-03 13:44:57 -0700119 /* Program overrides for MC transactions */
Puneet Saxenacf8c0e22017-08-04 17:19:55 +0530120 if (plat_mc_settings->set_txn_overrides != NULL) {
121 plat_mc_settings->set_txn_overrides();
122 }
Varun Wadekarad45ef72017-04-03 13:44:57 -0700123
Varun Wadekarcd5a2f52015-09-20 15:08:22 +0530124 /* video memory carveout region */
Anthony Zhou0e07e452017-07-26 17:16:54 +0800125 if (video_mem_base != 0ULL) {
Varun Wadekarcd5a2f52015-09-20 15:08:22 +0530126 tegra_mc_write_32(MC_VIDEO_PROTECT_BASE_LO,
127 (uint32_t)video_mem_base);
128 tegra_mc_write_32(MC_VIDEO_PROTECT_BASE_HI,
129 (uint32_t)(video_mem_base >> 32));
Varun Wadekar7058aee2016-04-25 09:01:46 -0700130 tegra_mc_write_32(MC_VIDEO_PROTECT_SIZE_MB, video_mem_size_mb);
Varun Wadekarcd5a2f52015-09-20 15:08:22 +0530131
132 /*
Varun Wadekar153982c2016-12-21 14:50:18 -0800133 * MCE propagates the VideoMem configuration values across the
Varun Wadekarcd5a2f52015-09-20 15:08:22 +0530134 * CCPLEX.
135 */
136 mce_update_gsc_videomem();
137 }
138}
139
140/*
141 * Secure the BL31 DRAM aperture.
142 *
143 * phys_base = physical base of TZDRAM aperture
144 * size_in_bytes = size of aperture in bytes
145 */
146void tegra_memctrl_tzdram_setup(uint64_t phys_base, uint32_t size_in_bytes)
147{
148 /*
Varun Wadekarf3cd5092017-10-30 14:35:17 -0700149 * Perform platform specific steps.
Harvey Hsiehc95802d2016-07-29 20:10:59 +0800150 */
Varun Wadekarf3cd5092017-10-30 14:35:17 -0700151 plat_memctrl_tzdram_setup(phys_base, size_in_bytes);
Varun Wadekarcd5a2f52015-09-20 15:08:22 +0530152}
153
154/*
Varun Wadekar13e7dc42015-12-30 15:15:08 -0800155 * Secure the BL31 TZRAM aperture.
156 *
157 * phys_base = physical base of TZRAM aperture
158 * size_in_bytes = size of aperture in bytes
159 */
160void tegra_memctrl_tzram_setup(uint64_t phys_base, uint32_t size_in_bytes)
161{
Varun Wadekare6d43222016-05-25 16:35:04 -0700162 uint32_t index;
163 uint32_t total_128kb_blocks = size_in_bytes >> 17;
Varun Wadekar153982c2016-12-21 14:50:18 -0800164 uint32_t residual_4kb_blocks = (size_in_bytes & (uint32_t)0x1FFFF) >> 12;
Varun Wadekar13e7dc42015-12-30 15:15:08 -0800165 uint32_t val;
166
Varun Wadekar153982c2016-12-21 14:50:18 -0800167 INFO("Configuring TrustZone SRAM Memory Carveout\n");
168
Varun Wadekar13e7dc42015-12-30 15:15:08 -0800169 /*
Varun Wadekare6d43222016-05-25 16:35:04 -0700170 * Reset the access configuration registers to restrict access
171 * to the TZRAM aperture
Varun Wadekar13e7dc42015-12-30 15:15:08 -0800172 */
Steven Kaob688d382017-09-06 13:32:21 +0800173 for (index = MC_TZRAM_CLIENT_ACCESS0_CFG0;
Varun Wadekar153982c2016-12-21 14:50:18 -0800174 index < ((uint32_t)MC_TZRAM_CARVEOUT_CFG + (uint32_t)MC_GSC_CONFIG_REGS_SIZE);
175 index += 4U) {
Varun Wadekare6d43222016-05-25 16:35:04 -0700176 tegra_mc_write_32(index, 0);
Varun Wadekar153982c2016-12-21 14:50:18 -0800177 }
Varun Wadekar13e7dc42015-12-30 15:15:08 -0800178
179 /*
Steven Kaob688d382017-09-06 13:32:21 +0800180 * Enable CPU access configuration registers to access the TZRAM aperture
181 */
182 if (!tegra_chipid_is_t186()) {
183 val = tegra_mc_read_32(MC_TZRAM_CLIENT_ACCESS1_CFG0);
184 val |= TZRAM_ALLOW_MPCORER | TZRAM_ALLOW_MPCOREW;
185 tegra_mc_write_32(MC_TZRAM_CLIENT_ACCESS1_CFG0, val);
186 }
187
188 /*
Varun Wadekare6d43222016-05-25 16:35:04 -0700189 * Set the TZRAM base. TZRAM base must be 4k aligned, at least.
190 */
Varun Wadekar153982c2016-12-21 14:50:18 -0800191 assert((phys_base & (uint64_t)0xFFF) == 0U);
Varun Wadekare6d43222016-05-25 16:35:04 -0700192 tegra_mc_write_32(MC_TZRAM_BASE_LO, (uint32_t)phys_base);
193 tegra_mc_write_32(MC_TZRAM_BASE_HI,
Varun Wadekar153982c2016-12-21 14:50:18 -0800194 (uint32_t)(phys_base >> 32) & MC_GSC_BASE_HI_MASK);
Varun Wadekar13e7dc42015-12-30 15:15:08 -0800195
Varun Wadekare6d43222016-05-25 16:35:04 -0700196 /*
197 * Set the TZRAM size
198 *
199 * total size = (number of 128KB blocks) + (number of remaining 4KB
200 * blocks)
201 *
202 */
Varun Wadekar153982c2016-12-21 14:50:18 -0800203 val = (residual_4kb_blocks << MC_GSC_SIZE_RANGE_4KB_SHIFT) |
Varun Wadekare6d43222016-05-25 16:35:04 -0700204 total_128kb_blocks;
205 tegra_mc_write_32(MC_TZRAM_SIZE, val);
Varun Wadekar13e7dc42015-12-30 15:15:08 -0800206
Varun Wadekare6d43222016-05-25 16:35:04 -0700207 /*
208 * Lock the configuration settings by disabling TZ-only lock
209 * and locking the configuration against any future changes
210 * at all.
211 */
212 val = tegra_mc_read_32(MC_TZRAM_CARVEOUT_CFG);
Anthony Zhou0844b972017-06-28 16:35:54 +0800213 val &= (uint32_t)~MC_GSC_ENABLE_TZ_LOCK_BIT;
Varun Wadekar153982c2016-12-21 14:50:18 -0800214 val |= MC_GSC_LOCK_CFG_SETTINGS_BIT;
Steven Kaob688d382017-09-06 13:32:21 +0800215 if (!tegra_chipid_is_t186()) {
216 val |= MC_GSC_ENABLE_CPU_SECURE_BIT;
217 }
Varun Wadekare6d43222016-05-25 16:35:04 -0700218 tegra_mc_write_32(MC_TZRAM_CARVEOUT_CFG, val);
Varun Wadekar13e7dc42015-12-30 15:15:08 -0800219
220 /*
Varun Wadekar153982c2016-12-21 14:50:18 -0800221 * MCE propagates the security configuration values across the
Varun Wadekar13e7dc42015-12-30 15:15:08 -0800222 * CCPLEX.
223 */
224 mce_update_gsc_tzram();
225}
226
Pritesh Raithatha75c94432018-08-03 15:48:15 +0530227/*
228 * Save MC settings before "System Suspend" to TZDRAM
229 */
230void tegra_mc_save_context(uint64_t mc_ctx_addr)
231{
232 const tegra_mc_settings_t *plat_mc_settings = tegra_get_mc_settings();
233 uint32_t i, num_entries = 0;
234 mc_regs_t *mc_ctx_regs;
235 const plat_params_from_bl2_t *params_from_bl2 = bl31_get_plat_params();
236 uint64_t tzdram_base = params_from_bl2->tzdram_base;
237 uint64_t tzdram_end = tzdram_base + params_from_bl2->tzdram_size;
238
239 assert((mc_ctx_addr >= tzdram_base) && (mc_ctx_addr <= tzdram_end));
240
241 /* get MC context table */
242 mc_ctx_regs = plat_mc_settings->get_mc_system_suspend_ctx();
243 assert(mc_ctx_regs != NULL);
244
245 /*
246 * mc_ctx_regs[0].val contains the size of the context table minus
247 * the last entry. Sanity check the table size before we start with
248 * the context save operation.
249 */
250 while (mc_ctx_regs[num_entries].reg != 0xFFFFFFFFU) {
251 num_entries++;
252 }
253
254 /* panic if the sizes do not match */
255 if (num_entries != mc_ctx_regs[0].val) {
256 ERROR("MC context size mismatch!");
257 panic();
258 }
259
260 /* save MC register values */
261 for (i = 1U; i < num_entries; i++) {
262 mc_ctx_regs[i].val = mmio_read_32(mc_ctx_regs[i].reg);
263 }
264
265 /* increment by 1 to take care of the last entry */
266 num_entries++;
267
268 /* Save MC config settings */
269 (void)memcpy((void *)mc_ctx_addr, mc_ctx_regs,
270 sizeof(mc_regs_t) * num_entries);
271
272 /* save the MC table address */
273 mmio_write_32(TEGRA_SCRATCH_BASE + SCRATCH_MC_TABLE_ADDR_LO,
274 (uint32_t)mc_ctx_addr);
275 mmio_write_32(TEGRA_SCRATCH_BASE + SCRATCH_MC_TABLE_ADDR_HI,
276 (uint32_t)(mc_ctx_addr >> 32));
277}
278
Varun Wadekar153982c2016-12-21 14:50:18 -0800279static void tegra_lock_videomem_nonoverlap(uint64_t phys_base,
280 uint64_t size_in_bytes)
281{
282 uint32_t index;
283 uint64_t total_128kb_blocks = size_in_bytes >> 17;
284 uint64_t residual_4kb_blocks = (size_in_bytes & (uint32_t)0x1FFFF) >> 12;
285 uint64_t val;
286
287 /*
288 * Reset the access configuration registers to restrict access to
289 * old Videomem aperture
290 */
291 for (index = MC_VIDEO_PROTECT_CLEAR_ACCESS_CFG0;
292 index < ((uint32_t)MC_VIDEO_PROTECT_CLEAR_ACCESS_CFG0 + (uint32_t)MC_GSC_CONFIG_REGS_SIZE);
293 index += 4U) {
294 tegra_mc_write_32(index, 0);
295 }
296
297 /*
298 * Set the base. It must be 4k aligned, at least.
299 */
300 assert((phys_base & (uint64_t)0xFFF) == 0U);
301 tegra_mc_write_32(MC_VIDEO_PROTECT_CLEAR_BASE_LO, (uint32_t)phys_base);
302 tegra_mc_write_32(MC_VIDEO_PROTECT_CLEAR_BASE_HI,
303 (uint32_t)(phys_base >> 32) & (uint32_t)MC_GSC_BASE_HI_MASK);
304
305 /*
306 * Set the aperture size
307 *
308 * total size = (number of 128KB blocks) + (number of remaining 4KB
309 * blocks)
310 *
311 */
312 val = (uint32_t)((residual_4kb_blocks << MC_GSC_SIZE_RANGE_4KB_SHIFT) |
313 total_128kb_blocks);
314 tegra_mc_write_32(MC_VIDEO_PROTECT_CLEAR_SIZE, (uint32_t)val);
315
316 /*
317 * Lock the configuration settings by enabling TZ-only lock and
318 * locking the configuration against any future changes from NS
319 * world.
320 */
321 tegra_mc_write_32(MC_VIDEO_PROTECT_CLEAR_CFG,
322 (uint32_t)MC_GSC_ENABLE_TZ_LOCK_BIT);
323
324 /*
325 * MCE propagates the GSC configuration values across the
326 * CCPLEX.
327 */
328}
329
330static void tegra_unlock_videomem_nonoverlap(void)
331{
332 /* Clear the base */
333 tegra_mc_write_32(MC_VIDEO_PROTECT_CLEAR_BASE_LO, 0);
334 tegra_mc_write_32(MC_VIDEO_PROTECT_CLEAR_BASE_HI, 0);
335
336 /* Clear the size */
337 tegra_mc_write_32(MC_VIDEO_PROTECT_CLEAR_SIZE, 0);
338}
339
340static void tegra_clear_videomem(uintptr_t non_overlap_area_start,
341 unsigned long long non_overlap_area_size)
342{
Varun Wadekar117a2e02017-08-03 11:40:34 -0700343 int ret;
344
Varun Wadekar153982c2016-12-21 14:50:18 -0800345 /*
346 * Map the NS memory first, clean it and then unmap it.
347 */
Varun Wadekar117a2e02017-08-03 11:40:34 -0700348 ret = mmap_add_dynamic_region(non_overlap_area_start, /* PA */
Varun Wadekar153982c2016-12-21 14:50:18 -0800349 non_overlap_area_start, /* VA */
350 non_overlap_area_size, /* size */
Ken Chang9dfb91e2018-12-28 08:44:12 +0800351 MT_NS | MT_RW | MT_EXECUTE_NEVER |
352 MT_NON_CACHEABLE); /* attrs */
Varun Wadekar117a2e02017-08-03 11:40:34 -0700353 assert(ret == 0);
Varun Wadekar153982c2016-12-21 14:50:18 -0800354
355 zero_normalmem((void *)non_overlap_area_start, non_overlap_area_size);
356 flush_dcache_range(non_overlap_area_start, non_overlap_area_size);
357
Anthony Zhou0844b972017-06-28 16:35:54 +0800358 (void)mmap_remove_dynamic_region(non_overlap_area_start,
Varun Wadekar153982c2016-12-21 14:50:18 -0800359 non_overlap_area_size);
360}
361
Varun Wadekar13e7dc42015-12-30 15:15:08 -0800362/*
Varun Wadekarcd5a2f52015-09-20 15:08:22 +0530363 * Program the Video Memory carveout region
364 *
365 * phys_base = physical base of aperture
366 * size_in_bytes = size of aperture in bytes
367 */
368void tegra_memctrl_videomem_setup(uint64_t phys_base, uint32_t size_in_bytes)
369{
Varun Wadekar153982c2016-12-21 14:50:18 -0800370 uintptr_t vmem_end_old = video_mem_base + (video_mem_size_mb << 20);
371 uintptr_t vmem_end_new = phys_base + size_in_bytes;
Varun Wadekar153982c2016-12-21 14:50:18 -0800372 unsigned long long non_overlap_area_size;
Varun Wadekare60f1bf2016-02-17 10:10:50 -0800373
374 /*
Varun Wadekarcd5a2f52015-09-20 15:08:22 +0530375 * Setup the Memory controller to restrict CPU accesses to the Video
376 * Memory region
377 */
378 INFO("Configuring Video Memory Carveout\n");
379
Varun Wadekar153982c2016-12-21 14:50:18 -0800380 /*
381 * Configure Memory Controller directly for the first time.
382 */
383 if (video_mem_base == 0U)
384 goto done;
385
386 /*
387 * Lock the non overlapping memory being cleared so that other masters
388 * do not accidently write to it. The memory would be unlocked once
389 * the non overlapping region is cleared and the new memory
390 * settings take effect.
391 */
392 tegra_lock_videomem_nonoverlap(video_mem_base,
393 video_mem_size_mb << 20);
394
395 /*
396 * Clear the old regions now being exposed. The following cases
397 * can occur -
398 *
399 * 1. clear whole old region (no overlap with new region)
400 * 2. clear old sub-region below new base
401 * 3. clear old sub-region above new end
402 */
403 INFO("Cleaning previous Video Memory Carveout\n");
404
Anthony Zhou0844b972017-06-28 16:35:54 +0800405 if ((phys_base > vmem_end_old) || (video_mem_base > vmem_end_new)) {
Varun Wadekar153982c2016-12-21 14:50:18 -0800406 tegra_clear_videomem(video_mem_base,
Varun Wadekar8b1c0042019-09-05 08:17:02 -0700407 video_mem_size_mb << 20U);
Varun Wadekar153982c2016-12-21 14:50:18 -0800408 } else {
409 if (video_mem_base < phys_base) {
410 non_overlap_area_size = phys_base - video_mem_base;
Varun Wadekar8b1c0042019-09-05 08:17:02 -0700411 tegra_clear_videomem(video_mem_base, non_overlap_area_size);
Varun Wadekar153982c2016-12-21 14:50:18 -0800412 }
413 if (vmem_end_old > vmem_end_new) {
414 non_overlap_area_size = vmem_end_old - vmem_end_new;
Varun Wadekar8b1c0042019-09-05 08:17:02 -0700415 tegra_clear_videomem(vmem_end_new, non_overlap_area_size);
Varun Wadekar153982c2016-12-21 14:50:18 -0800416 }
417 }
418
419done:
420 /* program the Videomem aperture */
Varun Wadekarcd5a2f52015-09-20 15:08:22 +0530421 tegra_mc_write_32(MC_VIDEO_PROTECT_BASE_LO, (uint32_t)phys_base);
422 tegra_mc_write_32(MC_VIDEO_PROTECT_BASE_HI,
423 (uint32_t)(phys_base >> 32));
Varun Wadekar7058aee2016-04-25 09:01:46 -0700424 tegra_mc_write_32(MC_VIDEO_PROTECT_SIZE_MB, size_in_bytes >> 20);
Varun Wadekarcd5a2f52015-09-20 15:08:22 +0530425
Varun Wadekar153982c2016-12-21 14:50:18 -0800426 /* unlock the previous locked nonoverlapping aperture */
427 tegra_unlock_videomem_nonoverlap();
428
Varun Wadekarcd5a2f52015-09-20 15:08:22 +0530429 /* store new values */
430 video_mem_base = phys_base;
Varun Wadekar7058aee2016-04-25 09:01:46 -0700431 video_mem_size_mb = size_in_bytes >> 20;
Varun Wadekarcd5a2f52015-09-20 15:08:22 +0530432
433 /*
Varun Wadekar153982c2016-12-21 14:50:18 -0800434 * MCE propagates the VideoMem configuration values across the
Varun Wadekarcd5a2f52015-09-20 15:08:22 +0530435 * CCPLEX.
436 */
437 mce_update_gsc_videomem();
438}
Varun Wadekarc92050b2017-03-29 14:57:29 -0700439
440/*
441 * This feature exists only for v1 of the Tegra Memory Controller.
442 */
443void tegra_memctrl_disable_ahb_redirection(void)
444{
445 ; /* do nothing */
446}
Harvey Hsieh359be952017-08-21 15:01:53 +0800447
448void tegra_memctrl_clear_pending_interrupts(void)
449{
450 ; /* do nothing */
451}