blob: 13ffade0408e041568c965d3c735c6fb60e69965 [file] [log] [blame]
Tom Rini83d290c2018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0
Bryan Wudf3443d2014-06-24 11:45:29 +09002/*
Alexandre Courbot871d78e2015-07-09 16:33:00 +09003 * Copyright (c) 2014-2015, NVIDIA CORPORATION. All rights reserved.
Bryan Wudf3443d2014-06-24 11:45:29 +09004 */
5
6/* Tegra vpr routines */
7
8#include <common.h>
Simon Glassf7ae49f2020-05-10 11:40:05 -06009#include <log.h>
Bryan Wudf3443d2014-06-24 11:45:29 +090010#include <asm/io.h>
11#include <asm/arch/tegra.h>
12#include <asm/arch/mc.h>
Stephen Warren3d186cf2018-07-31 12:39:07 -060013#include <asm/arch-tegra/ap.h>
Bryan Wudf3443d2014-06-24 11:45:29 +090014
Alexandre Courbot871d78e2015-07-09 16:33:00 +090015#include <fdt_support.h>
16
17static bool _configured;
18
Alexandre Courboteca676b2015-10-19 13:57:03 +090019void tegra_gpu_config(void)
Bryan Wudf3443d2014-06-24 11:45:29 +090020{
21 struct mc_ctlr *mc = (struct mc_ctlr *)NV_PA_MC_BASE;
22
Stephen Warren3d186cf2018-07-31 12:39:07 -060023#if defined(CONFIG_TEGRA_SUPPORT_NON_SECURE)
24 if (!tegra_cpu_is_non_secure())
25#endif
26 {
27 /* Turn VPR off */
28 writel(0, &mc->mc_video_protect_size_mb);
29 writel(TEGRA_MC_VIDEO_PROTECT_REG_WRITE_ACCESS_DISABLED,
30 &mc->mc_video_protect_reg_ctrl);
31 /* read back to ensure the write went through */
32 readl(&mc->mc_video_protect_reg_ctrl);
33 }
Alexandre Courbot871d78e2015-07-09 16:33:00 +090034
35 debug("configured VPR\n");
36
37 _configured = true;
38}
39
Alexandre Courbota38a3c42015-07-09 16:33:01 +090040#if defined(CONFIG_OF_LIBFDT)
41
Stephen Warrend9b6f582016-04-12 11:17:39 -060042int tegra_gpu_enable_node(void *blob, const char *compat)
Alexandre Courbota38a3c42015-07-09 16:33:01 +090043{
44 int offset;
45
Stephen Warrend9b6f582016-04-12 11:17:39 -060046 if (!_configured)
47 return 0;
48
49 offset = fdt_node_offset_by_compatible(blob, -1, compat);
50 while (offset != -FDT_ERR_NOTFOUND) {
51 fdt_status_okay(blob, offset);
52 offset = fdt_node_offset_by_compatible(blob, offset, compat);
Alexandre Courbota38a3c42015-07-09 16:33:01 +090053 }
54
55 return 0;
56}
57
58#endif