diff --git a/drivers/memory/tegra/tegra186.c b/drivers/memory/tegra/tegra186.c index 1b3183951bfe..67950d68c5ca 100644 --- a/drivers/memory/tegra/tegra186.c +++ b/drivers/memory/tegra/tegra186.c @@ -12,6 +12,7 @@ #include #include +#include #if defined(CONFIG_ARCH_TEGRA_186_SOC) #include @@ -121,6 +122,11 @@ static int tegra186_mc_probe_device(struct tegra_mc *mc, struct device *dev) if (!tegra_dev_iommu_get_stream_id(dev, &sid)) return 0; + if (tegra_is_hypervisor_mode() == true) { + pr_debug("MC register access not allowed in Guest Linux\n"); + return 0; + } + while (!of_parse_phandle_with_args(dev->of_node, "interconnects", "#interconnect-cells", index, &args)) { if (args.np == mc->dev->of_node && args.args_count != 0) { diff --git a/drivers/soc/tegra/Kconfig b/drivers/soc/tegra/Kconfig index f16beeabaa92..78a382a96795 100644 --- a/drivers/soc/tegra/Kconfig +++ b/drivers/soc/tegra/Kconfig @@ -170,3 +170,10 @@ config SOC_TEGRA_CBB Support for handling error from Tegra Control Backbone(CBB). This driver handles the errors from CBB and prints debug information about the failed transactions. + +config SOC_TEGRA_PLATFORM_HELPER + def_bool y + help + This config enables support of the platform helpers APIs which can + be used by the out-tree. If this config is y then the helper APIs + are available else not. diff --git a/include/soc/tegra/tegra-platform-helper.h b/include/soc/tegra/tegra-platform-helper.h new file mode 100644 index 000000000000..40911433a26c --- /dev/null +++ b/include/soc/tegra/tegra-platform-helper.h @@ -0,0 +1,19 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* + * Copyright (c) 2023, NVIDIA CORPORATION. All rights reserved. + */ + +#ifndef TEGRA_PLATFORM_HELPER_H +#define TEGRA_PLATFORM_HELPER_H + +static inline bool tegra_is_hypervisor_mode(void) +{ +#ifdef CONFIG_OF + return of_property_read_bool(of_chosen, + "nvidia,tegra-hypervisor-mode"); +#else + return false; +#endif +} + +#endif /* TEGRA_PLATFORM_HELPER_H */