1871d78edSAlexandre Courbot /*
2871d78edSAlexandre Courbot * Copyright (c) 2014-2015, NVIDIA CORPORATION. All rights reserved.
3871d78edSAlexandre Courbot *
45b8031ccSTom Rini * SPDX-License-Identifier: GPL-2.0
5871d78edSAlexandre Courbot */
6871d78edSAlexandre Courbot
7871d78edSAlexandre Courbot /* Tegra vpr routines */
8871d78edSAlexandre Courbot
9871d78edSAlexandre Courbot #include <common.h>
10871d78edSAlexandre Courbot #include <asm/io.h>
11871d78edSAlexandre Courbot #include <asm/arch/tegra.h>
12871d78edSAlexandre Courbot #include <asm/arch/mc.h>
13871d78edSAlexandre Courbot
14871d78edSAlexandre Courbot #include <fdt_support.h>
15871d78edSAlexandre Courbot
16871d78edSAlexandre Courbot static bool _configured;
17871d78edSAlexandre Courbot
tegra_gpu_config(void)18eca676bdSAlexandre Courbot void tegra_gpu_config(void)
19871d78edSAlexandre Courbot {
20871d78edSAlexandre Courbot struct mc_ctlr *mc = (struct mc_ctlr *)NV_PA_MC_BASE;
21871d78edSAlexandre Courbot
22871d78edSAlexandre Courbot /* Turn VPR off */
23871d78edSAlexandre Courbot writel(0, &mc->mc_video_protect_size_mb);
24871d78edSAlexandre Courbot writel(TEGRA_MC_VIDEO_PROTECT_REG_WRITE_ACCESS_DISABLED,
25871d78edSAlexandre Courbot &mc->mc_video_protect_reg_ctrl);
26871d78edSAlexandre Courbot /* read back to ensure the write went through */
27871d78edSAlexandre Courbot readl(&mc->mc_video_protect_reg_ctrl);
28871d78edSAlexandre Courbot
29871d78edSAlexandre Courbot debug("configured VPR\n");
30871d78edSAlexandre Courbot
31871d78edSAlexandre Courbot _configured = true;
32871d78edSAlexandre Courbot }
33871d78edSAlexandre Courbot
34a38a3c4aSAlexandre Courbot #if defined(CONFIG_OF_LIBFDT)
35a38a3c4aSAlexandre Courbot
tegra_gpu_enable_node(void * blob,const char * compat)36*d9b6f58eSStephen Warren int tegra_gpu_enable_node(void *blob, const char *compat)
37a38a3c4aSAlexandre Courbot {
38a38a3c4aSAlexandre Courbot int offset;
39a38a3c4aSAlexandre Courbot
40*d9b6f58eSStephen Warren if (!_configured)
41*d9b6f58eSStephen Warren return 0;
42*d9b6f58eSStephen Warren
43*d9b6f58eSStephen Warren offset = fdt_node_offset_by_compatible(blob, -1, compat);
44*d9b6f58eSStephen Warren while (offset != -FDT_ERR_NOTFOUND) {
45a38a3c4aSAlexandre Courbot fdt_status_okay(blob, offset);
46*d9b6f58eSStephen Warren offset = fdt_node_offset_by_compatible(blob, offset, compat);
47a38a3c4aSAlexandre Courbot }
48a38a3c4aSAlexandre Courbot
49a38a3c4aSAlexandre Courbot return 0;
50a38a3c4aSAlexandre Courbot }
51a38a3c4aSAlexandre Courbot
52a38a3c4aSAlexandre Courbot #endif
53