gpu: nvgpu: Debugfs for Volt

Changes:
1. Reading operating voltage and minimum voltage of chip.
2. Added nvgpu_volt_init_debugfs for creating the debugfs interface.
3. Command for reading current voltage:
   cat /sys/kernel/debug/gpu_pci/volt/current_voltage
4. Command for reading minimum voltage:
   cat /sys/kernel/debug/gpu_pci/volt/minimum_voltage

Jira NVGPU-1731

Change-Id: I76d42fc376235f37c44d259398bd6f125a90413b
Signed-off-by: rmylavarapu <rmylavarapu@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/1986403
GVS: Gerrit_Virtual_Submit
Reviewed-by: Vijayakumar Subbu <vsubbu@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
This commit is contained in:
rmylavarapu
2019-01-03 09:19:51 +05:30
committed by mobile promotions
parent 9467646a87
commit d174860854
6 changed files with 129 additions and 2 deletions

View File

@@ -0,0 +1,80 @@
/*
* Copyright (c) 2019, NVIDIA Corporation. 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.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <linux/debugfs.h>
#include "os_linux.h"
#include <nvgpu/pmu/volt.h>
#include <common/pmu/volt/volt_rail.h>
static int get_curr_voltage(void *data, u64 *val)
{
struct gk20a *g = (struct gk20a *)data;
u32 readval;
int err;
if (!g->ops.pmu_ver.volt.volt_get_voltage)
return -EINVAL;
err = g->ops.pmu_ver.volt.volt_get_voltage(g,
CTRL_VOLT_DOMAIN_LOGIC, &readval);
if (!err)
*val = readval;
return err;
}
DEFINE_SIMPLE_ATTRIBUTE(curr_volt_ctrl_fops, get_curr_voltage, NULL, "%llu\n");
static int get_min_voltage(void *data, u64 *val)
{
struct gk20a *g = (struct gk20a *)data;
u32 readval;
int err;
if (!g->ops.pmu_ver.volt.volt_get_vmin)
return -EINVAL;
err = g->ops.pmu_ver.volt.volt_get_vmin(g, &readval);
if (!err)
*val = readval;
return err;
}
DEFINE_SIMPLE_ATTRIBUTE(min_volt_ctrl_fops, get_min_voltage, NULL, "%llu\n");
int nvgpu_volt_init_debugfs(struct gk20a *g)
{
struct nvgpu_os_linux *l = nvgpu_os_linux_from_gk20a(g);
struct dentry *dbgentry, *volt_root;
volt_root = debugfs_create_dir("volt", l->debugfs);
dbgentry = debugfs_create_file(
"current_voltage", S_IRUGO, volt_root, g, &curr_volt_ctrl_fops);
if (!dbgentry) {
pr_err("%s: Failed to make debugfs node\n", __func__);
return -ENOMEM;
}
dbgentry = debugfs_create_file("minimum_voltage",
S_IRUGO, volt_root, g, &min_volt_ctrl_fops);
if (!dbgentry) {
pr_err("%s: Failed to make debugfs node\n", __func__);
return -ENOMEM;
}
return 0;
}