tegra: hwpm: add wrapper for soc functions

Currently, linux specific SOC functions below are used in HWPM driver.
- find type of platform/config
- read fuse registers
- read device info
In order to make HWPM OS agnostic, add wrappers for SOC functions and/or
move code to os folder.

Jira THWPM-59

Change-Id: I8a7e824f3cffe7ae5c7e977b4b6690eb180958e4
Signed-off-by: Vedashree Vidwans <vvidwans@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2743372
Reviewed-by: Seema Khowala <seemaj@nvidia.com>
GVS: Gerrit_Virtual_Submit <buildbot_gerritrpt@nvidia.com>
This commit is contained in:
Vedashree Vidwans
2022-07-11 16:06:58 -07:00
committed by mobile promotions
parent 74dee85a03
commit ed6dd8af44
9 changed files with 199 additions and 42 deletions

57
os/linux/soc_utils.c Normal file
View File

@@ -0,0 +1,57 @@
/*
* Copyright (c) 2022, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*/
#include <soc/tegra/fuse.h>
#include <tegra_hwpm.h>
#include <tegra_hwpm_soc.h>
bool tegra_hwpm_is_platform_simulation_impl(void)
{
return tegra_platform_is_vdk();
}
bool tegra_hwpm_is_platform_vsp_impl(void)
{
return tegra_platform_is_vsp();
}
bool tegra_hwpm_is_platform_silicon_impl(void)
{
return tegra_platform_is_silicon();
}
bool tegra_hwpm_is_hypervisor_mode_impl(void)
{
return is_tegra_hypervisor_mode();
}
int tegra_hwpm_fuse_readl_impl(struct tegra_soc_hwpm *hwpm,
u64 reg_offset, u32 *val)
{
u32 fuse_val = 0U;
int err = 0;
err = tegra_fuse_readl(reg_offset, &fuse_val);
if (err != 0) {
return err;
}
*val = fuse_val;
return 0;
}
int tegra_hwpm_fuse_readl_prod_mode_impl(struct tegra_soc_hwpm *hwpm, u32 *val)
{
return tegra_hwpm_fuse_readl(hwpm, TEGRA_FUSE_PRODUCTION_MODE, val);
}