mirror of
git://nv-tegra.nvidia.com/linux-hwpm.git
synced 2025-12-22 17:30:40 +03:00
tegra: hwpm: move linux specific code to os folder
To make HWPM driver OS agnostic, remove linux specific includes from common and chip specific files. - Move IP register list related logic to os linux folder. - tegra_hwpm_get_floorsweep_info() and tegra_hwpm_get_resource_info() refer to linux specific UAPI structures. Relocate these functions to os folder. - Use tegra_hwpm_ip_ops structure in HWPM driver internal logic. Move or rewrite functions using tegra_soc_hwpm_ip_ops. Jira THWPM-59 Change-Id: I1dd1e088d59fdc44923d2b6502bb0cf350ce57a6 Signed-off-by: Vedashree Vidwans <vvidwans@nvidia.com> Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2729471 Reviewed-by: Seema Khowala <seemaj@nvidia.com> GVS: Gerrit_Virtual_Submit <buildbot_gerritrpt@nvidia.com>
This commit is contained in:
committed by
mobile promotions
parent
8f3cb60584
commit
378bd9bb1c
@@ -15,9 +15,12 @@
|
||||
#include <soc/tegra/fuse.h>
|
||||
#include <uapi/linux/tegra-soc-hwpm-uapi.h>
|
||||
|
||||
#include <tegra_hwpm_kmem.h>
|
||||
#include <tegra_hwpm_log.h>
|
||||
#include <tegra_hwpm_io.h>
|
||||
#include <tegra_hwpm.h>
|
||||
#include <os/linux/ip_utils.h>
|
||||
#include <os/linux/driver.h>
|
||||
|
||||
struct platform_device *tegra_soc_hwpm_pdev;
|
||||
struct hwpm_ip_register_list *ip_register_list_head;
|
||||
@@ -82,6 +85,7 @@ static int tegra_hwpm_note_ip_register(
|
||||
void tegra_soc_hwpm_ip_register(struct tegra_soc_hwpm_ip_ops *hwpm_ip_ops)
|
||||
{
|
||||
struct tegra_soc_hwpm *hwpm = NULL;
|
||||
struct tegra_hwpm_ip_ops ip_ops;
|
||||
int ret = 0;
|
||||
|
||||
if (hwpm_ip_ops == NULL) {
|
||||
@@ -109,8 +113,13 @@ void tegra_soc_hwpm_ip_register(struct tegra_soc_hwpm_ip_ops *hwpm_ip_ops)
|
||||
tegra_hwpm_dbg(hwpm, hwpm_info | hwpm_dbg_ip_register,
|
||||
"Register IP 0x%llx", hwpm_ip_ops->ip_base_address);
|
||||
|
||||
ip_ops.ip_dev = hwpm_ip_ops->ip_dev;
|
||||
ip_ops.hwpm_ip_pm = hwpm_ip_ops->hwpm_ip_pm;
|
||||
ip_ops.hwpm_ip_reg_op = hwpm_ip_ops->hwpm_ip_reg_op;
|
||||
|
||||
ret = hwpm->active_chip->extract_ip_ops(hwpm,
|
||||
hwpm_ip_ops, REGISTER_IP);
|
||||
hwpm_ip_ops->resource_enum,
|
||||
hwpm_ip_ops->ip_base_address, &ip_ops, REGISTER_IP);
|
||||
if (ret < 0) {
|
||||
tegra_hwpm_err(hwpm, "Failed to set IP ops for IP %d",
|
||||
hwpm_ip_ops->resource_enum);
|
||||
@@ -121,6 +130,7 @@ void tegra_soc_hwpm_ip_register(struct tegra_soc_hwpm_ip_ops *hwpm_ip_ops)
|
||||
void tegra_soc_hwpm_ip_unregister(struct tegra_soc_hwpm_ip_ops *hwpm_ip_ops)
|
||||
{
|
||||
struct tegra_soc_hwpm *hwpm = NULL;
|
||||
struct tegra_hwpm_ip_ops ip_ops;
|
||||
int ret = 0;
|
||||
|
||||
if (hwpm_ip_ops == NULL) {
|
||||
@@ -141,11 +151,109 @@ void tegra_soc_hwpm_ip_unregister(struct tegra_soc_hwpm_ip_ops *hwpm_ip_ops)
|
||||
tegra_hwpm_dbg(hwpm, hwpm_info | hwpm_dbg_ip_register,
|
||||
"Unregister IP 0x%llx", hwpm_ip_ops->ip_base_address);
|
||||
|
||||
ip_ops.ip_dev = hwpm_ip_ops->ip_dev;
|
||||
ip_ops.hwpm_ip_pm = hwpm_ip_ops->hwpm_ip_pm;
|
||||
ip_ops.hwpm_ip_reg_op = hwpm_ip_ops->hwpm_ip_reg_op;
|
||||
|
||||
ret = hwpm->active_chip->extract_ip_ops(hwpm,
|
||||
hwpm_ip_ops, UNREGISTER_IP);
|
||||
hwpm_ip_ops->resource_enum,
|
||||
hwpm_ip_ops->ip_base_address, &ip_ops, UNREGISTER_IP);
|
||||
if (ret < 0) {
|
||||
tegra_hwpm_err(hwpm, "Failed to reset IP ops for IP %d",
|
||||
hwpm_ip_ops->resource_enum);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int tegra_hwpm_complete_ip_register_impl(struct tegra_soc_hwpm *hwpm)
|
||||
{
|
||||
int ret = 0;
|
||||
struct hwpm_ip_register_list *node = ip_register_list_head;
|
||||
struct tegra_hwpm_ip_ops ip_ops;
|
||||
|
||||
tegra_hwpm_fn(hwpm, " ");
|
||||
|
||||
while (node != NULL) {
|
||||
ip_ops.ip_dev = node->ip_ops.ip_dev;
|
||||
ip_ops.hwpm_ip_pm = node->ip_ops.hwpm_ip_pm;
|
||||
ip_ops.hwpm_ip_reg_op = node->ip_ops.hwpm_ip_reg_op;
|
||||
|
||||
ret = hwpm->active_chip->extract_ip_ops(hwpm,
|
||||
node->ip_ops.resource_enum,
|
||||
node->ip_ops.ip_base_address, &ip_ops, true);
|
||||
if (ret != 0) {
|
||||
tegra_hwpm_err(hwpm,
|
||||
"Resource enum %d extract IP ops failed",
|
||||
node->ip_ops.resource_enum);
|
||||
return ret;
|
||||
}
|
||||
node = node->next;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int tegra_hwpm_get_floorsweep_info(struct tegra_soc_hwpm *hwpm,
|
||||
struct tegra_soc_hwpm_ip_floorsweep_info *fs_info)
|
||||
{
|
||||
int ret = 0;
|
||||
u32 i = 0U;
|
||||
|
||||
tegra_hwpm_fn(hwpm, " ");
|
||||
|
||||
for (i = 0U; i < fs_info->num_queries; i++) {
|
||||
ret = hwpm->active_chip->get_fs_info(
|
||||
hwpm, (u32)fs_info->ip_fsinfo[i].ip,
|
||||
&fs_info->ip_fsinfo[i].ip_inst_mask,
|
||||
&fs_info->ip_fsinfo[i].status);
|
||||
if (ret < 0) {
|
||||
/* Print error for debug purpose. */
|
||||
tegra_hwpm_err(hwpm, "Failed to get fs_info");
|
||||
}
|
||||
|
||||
tegra_hwpm_dbg(hwpm, hwpm_info | hwpm_dbg_floorsweep_info,
|
||||
"Query %d: ip %d: ip_status: %d inst_mask 0x%llx",
|
||||
i, fs_info->ip_fsinfo[i].ip,
|
||||
fs_info->ip_fsinfo[i].status,
|
||||
fs_info->ip_fsinfo[i].ip_inst_mask);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int tegra_hwpm_get_resource_info(struct tegra_soc_hwpm *hwpm,
|
||||
struct tegra_soc_hwpm_resource_info *rsrc_info)
|
||||
{
|
||||
int ret = 0;
|
||||
u32 i = 0U;
|
||||
|
||||
tegra_hwpm_fn(hwpm, " ");
|
||||
|
||||
for (i = 0U; i < rsrc_info->num_queries; i++) {
|
||||
ret = hwpm->active_chip->get_resource_info(
|
||||
hwpm, (u32)rsrc_info->resource_info[i].resource,
|
||||
&rsrc_info->resource_info[i].status);
|
||||
if (ret < 0) {
|
||||
/* Print error for debug purpose. */
|
||||
tegra_hwpm_err(hwpm, "Failed to get rsrc_info");
|
||||
}
|
||||
|
||||
tegra_hwpm_dbg(hwpm, hwpm_info | hwpm_dbg_resource_info,
|
||||
"Query %d: resource %d: status: %d",
|
||||
i, rsrc_info->resource_info[i].resource,
|
||||
rsrc_info->resource_info[i].status);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
void tegra_hwpm_release_ip_register_node(struct tegra_soc_hwpm *hwpm)
|
||||
{
|
||||
struct hwpm_ip_register_list *node = ip_register_list_head;
|
||||
struct hwpm_ip_register_list *tmp_node = NULL;
|
||||
|
||||
tegra_hwpm_fn(hwpm, " ");
|
||||
|
||||
while (node != NULL) {
|
||||
tmp_node = node;
|
||||
node = tmp_node->next;
|
||||
tegra_hwpm_kfree(hwpm, tmp_node);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user