platform/tegra: Add bootloader debug driver

Add bootloader debug driver which provides debug functionality
from user space.

bug 3583607

Change-Id: I8bdd2712e755b370b3e157bcdcd3329122729fea
Signed-off-by: Laxman Dewangan <ldewangan@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/2708549
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
This commit is contained in:
Laxman Dewangan
2022-05-06 05:46:32 +00:00
committed by mobile promotions
parent 0ae00f25ca
commit 7c00563944
4 changed files with 601 additions and 0 deletions

View File

@@ -0,0 +1,142 @@
// SPDX-License-Identifier: GPL-2.0
// Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved.
#include <linux/types.h>
#include <linux/export.h>
#include <linux/init.h>
#include <linux/kernel.h>
#include <linux/errno.h>
#include <linux/memblock.h>
#include <asm/page.h>
phys_addr_t tegra_bl_debug_data_start;
EXPORT_SYMBOL(tegra_bl_debug_data_start);
phys_addr_t tegra_bl_debug_data_size;
EXPORT_SYMBOL(tegra_bl_debug_data_size);
phys_addr_t tegra_bl_prof_start;
EXPORT_SYMBOL(tegra_bl_prof_start);
phys_addr_t tegra_bl_prof_size;
EXPORT_SYMBOL(tegra_bl_prof_size);
phys_addr_t tegra_bl_bcp_start;
EXPORT_SYMBOL(tegra_bl_bcp_start);
phys_addr_t tegra_bl_bcp_size;
EXPORT_SYMBOL(tegra_bl_bcp_size);
#ifndef MODULE
static int __init tegra_bl_prof_arg(char *option)
{
char *p = option;
tegra_bl_prof_size = memparse(p, &p);
if (!p)
return -EINVAL;
if (*p != '@')
return -EINVAL;
tegra_bl_prof_start = memparse(p + 1, &p);
if (!tegra_bl_prof_size || !tegra_bl_prof_start) {
tegra_bl_prof_size = 0;
tegra_bl_prof_start = 0;
return -ENXIO;
}
if (pfn_valid(__phys_to_pfn(tegra_bl_prof_start))) {
if (memblock_reserve(tegra_bl_prof_start, tegra_bl_prof_size)) {
pr_err("Failed to reserve bl_prof_data %08llx@%08llx\n",
(u64)tegra_bl_prof_size,
(u64)tegra_bl_prof_start);
tegra_bl_prof_size = 0;
tegra_bl_prof_start = 0;
return -ENXIO;
}
}
return 0;
}
early_param("bl_prof_dataptr", tegra_bl_prof_arg);
static int __init tegra_bl_debug_data_arg(char *options)
{
char *p = options;
tegra_bl_debug_data_size = memparse(p, &p);
if (!p)
return -EINVAL;
if (*p != '@')
return -EINVAL;
tegra_bl_debug_data_start = memparse(p + 1, &p);
if (!tegra_bl_debug_data_size || !tegra_bl_debug_data_start) {
tegra_bl_debug_data_size = 0;
tegra_bl_debug_data_start = 0;
return -ENXIO;
}
if (pfn_valid(__phys_to_pfn(tegra_bl_debug_data_start))) {
if (memblock_reserve(tegra_bl_debug_data_start,
tegra_bl_debug_data_size)) {
pr_err("Failed to reserve bl_debug_data %08llx@%08llx\n",
(u64)tegra_bl_debug_data_size,
(u64)tegra_bl_debug_data_start);
tegra_bl_debug_data_size = 0;
tegra_bl_debug_data_start = 0;
return -ENXIO;
}
}
return 0;
}
early_param("bl_debug_data", tegra_bl_debug_data_arg);
static int tegra_bl_bcp_arg(char *options)
{
char *p = options;
tegra_bl_bcp_size = memparse(p, &p);
if (!p)
return -EINVAL;
if (*p != '@')
return -EINVAL;
tegra_bl_bcp_start = memparse(p + 1, &p);
if (!tegra_bl_bcp_size || !tegra_bl_bcp_start) {
tegra_bl_bcp_size = 0;
tegra_bl_bcp_start = 0;
return -ENXIO;
}
if (pfn_valid(__phys_to_pfn(tegra_bl_bcp_start))) {
if (memblock_reserve(tegra_bl_bcp_start,
tegra_bl_bcp_size)) {
pr_err("Failed to reserve boot_cfg_data %08llx@%08llx\n",
(u64)tegra_bl_bcp_size,
(u64)tegra_bl_bcp_start);
tegra_bl_bcp_size = 0;
tegra_bl_bcp_start = 0;
return -ENXIO;
}
}
pr_warn("Got boot_cfg_data %08llx@%08llx\n",
(u64)tegra_bl_bcp_size,
(u64)tegra_bl_bcp_start);
return 0;
}
early_param("boot_cfg_dataptr", tegra_bl_bcp_arg);
#else
#endif