mirror of
git://nv-tegra.nvidia.com/linux-hwpm.git
synced 2025-12-24 02:07:34 +03:00
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>
98 lines
2.4 KiB
C
98 lines
2.4 KiB
C
/*
|
|
* Copyright (c) 2021-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 <tegra_hwpm_log.h>
|
|
#include <tegra_hwpm_io.h>
|
|
#include <tegra_hwpm.h>
|
|
|
|
#include <hal/t234/t234_internal.h>
|
|
|
|
#include <hal/t234/hw/t234_pmasys_soc_hwpm.h>
|
|
#include <hal/t234/hw/t234_pmmsys_soc_hwpm.h>
|
|
|
|
int t234_hwpm_perfmon_enable(struct tegra_soc_hwpm *hwpm,
|
|
struct hwpm_ip_aperture *perfmon)
|
|
{
|
|
int err = 0;
|
|
u32 reg_val;
|
|
|
|
tegra_hwpm_fn(hwpm, " ");
|
|
|
|
/* Enable */
|
|
tegra_hwpm_dbg(hwpm, hwpm_dbg_bind,
|
|
"Enabling PERFMON(0x%llx - 0x%llx)",
|
|
perfmon->start_abs_pa, perfmon->end_abs_pa);
|
|
|
|
err = tegra_hwpm_readl(hwpm, perfmon,
|
|
pmmsys_sys0_enginestatus_r(0), ®_val);
|
|
if (err != 0) {
|
|
tegra_hwpm_err(hwpm, "hwpm read failed");
|
|
return err;
|
|
}
|
|
reg_val = set_field(reg_val, pmmsys_sys0_enginestatus_enable_m(),
|
|
pmmsys_sys0_enginestatus_enable_out_f());
|
|
err = tegra_hwpm_writel(hwpm, perfmon,
|
|
pmmsys_sys0_enginestatus_r(0), reg_val);
|
|
if (err != 0) {
|
|
tegra_hwpm_err(hwpm, "hwpm write failed");
|
|
return err;
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
|
|
int t234_hwpm_perfmux_disable(struct tegra_soc_hwpm *hwpm,
|
|
struct hwpm_ip_aperture *perfmux)
|
|
{
|
|
tegra_hwpm_fn(hwpm, " ");
|
|
|
|
return 0;
|
|
}
|
|
|
|
int t234_hwpm_perfmon_disable(struct tegra_soc_hwpm *hwpm,
|
|
struct hwpm_ip_aperture *perfmon)
|
|
{
|
|
int err = 0;
|
|
u32 reg_val;
|
|
|
|
tegra_hwpm_fn(hwpm, " ");
|
|
|
|
if (perfmon->element_type == HWPM_ELEMENT_PERFMUX) {
|
|
/*
|
|
* Since HWPM elements use perfmon functions,
|
|
* skip disabling HWPM PERFMUX elements
|
|
*/
|
|
return 0;
|
|
}
|
|
|
|
/* Disable */
|
|
tegra_hwpm_dbg(hwpm, hwpm_dbg_release_resource,
|
|
"Disabling PERFMON(0x%llx - 0x%llx)",
|
|
perfmon->start_abs_pa, perfmon->end_abs_pa);
|
|
|
|
err = tegra_hwpm_readl(hwpm, perfmon, pmmsys_control_r(0), ®_val);
|
|
if (err != 0) {
|
|
tegra_hwpm_err(hwpm, "hwpm read failed");
|
|
return err;
|
|
}
|
|
reg_val = set_field(reg_val, pmmsys_control_mode_m(),
|
|
pmmsys_control_mode_disable_f());
|
|
err = tegra_hwpm_writel(hwpm, perfmon, pmmsys_control_r(0), reg_val);
|
|
if (err != 0) {
|
|
tegra_hwpm_err(hwpm, "hwpm write failed");
|
|
return err;
|
|
}
|
|
|
|
return 0;
|
|
}
|