From 849c5317e8509b390da626bcb607e66cc5ef847f Mon Sep 17 00:00:00 2001 From: Thomas Fleury Date: Fri, 21 Oct 2016 16:43:39 -0700 Subject: gpu: nvgpu: get voltage, current, power and temperature Add ioctls to retrieve voltage, current, power and temperature. Add flags in GPU characteristics to indicate if feature is supported. Jira DNVGPU-166 Change-Id: Ifaafe2efdb6b09d7b28215b641814f28e894151e Signed-off-by: David Martinez Nieto Reviewed-on: http://git-master/r/1241861 Tested-by: Thomas Fleury GVS: Gerrit_Virtual_Submit Reviewed-by: Terje Bergstrom Reviewed-by: Vijayakumar Subbu Reviewed-on: http://git-master/r/1267122 --- drivers/gpu/nvgpu/pmgr/pmgr.c | 53 +++++++++++++++++++++++++++++++++++-------- 1 file changed, 43 insertions(+), 10 deletions(-) (limited to 'drivers/gpu/nvgpu/pmgr/pmgr.c') diff --git a/drivers/gpu/nvgpu/pmgr/pmgr.c b/drivers/gpu/nvgpu/pmgr/pmgr.c index f625e37d..e101aba8 100644 --- a/drivers/gpu/nvgpu/pmgr/pmgr.c +++ b/drivers/gpu/nvgpu/pmgr/pmgr.c @@ -16,12 +16,10 @@ #include "pmgrpmu.h" #include -#ifdef CONFIG_DEBUG_FS -static int pmgr_pwr_devices_get_current_power(void *data, u64 *val) +int pmgr_pwr_devices_get_power(struct gk20a *g, u32 *val) { struct nv_pmu_pmgr_pwr_devices_query_payload payload; int status; - struct gk20a *g = (struct gk20a *)data; status = pmgr_pmu_pwr_devices_query_blocking(g, 1, &payload); if (status) @@ -34,11 +32,10 @@ static int pmgr_pwr_devices_get_current_power(void *data, u64 *val) return status; } -static int pmgr_pwr_devices_get_current(void *data, u64 *val) +int pmgr_pwr_devices_get_current(struct gk20a *g, u32 *val) { struct nv_pmu_pmgr_pwr_devices_query_payload payload; int status; - struct gk20a *g = (struct gk20a *)data; status = pmgr_pmu_pwr_devices_query_blocking(g, 1, &payload); if (status) @@ -51,11 +48,10 @@ static int pmgr_pwr_devices_get_current(void *data, u64 *val) return status; } -static int pmgr_pwr_devices_get_current_voltage(void *data, u64 *val) +int pmgr_pwr_devices_get_voltage(struct gk20a *g, u32 *val) { struct nv_pmu_pmgr_pwr_devices_query_payload payload; int status; - struct gk20a *g = (struct gk20a *)data; status = pmgr_pmu_pwr_devices_query_blocking(g, 1, &payload); if (status) @@ -68,14 +64,51 @@ static int pmgr_pwr_devices_get_current_voltage(void *data, u64 *val) return status; } +#ifdef CONFIG_DEBUG_FS +int pmgr_pwr_devices_get_power_u64(void *data, u64 *p) +{ + struct gk20a *g = (struct gk20a *)data; + int err; + u32 val; + + err = pmgr_pwr_devices_get_power(g, &val); + *p = val; + + return err; +} + +int pmgr_pwr_devices_get_current_u64(void *data, u64 *p) +{ + struct gk20a *g = (struct gk20a *)data; + int err; + u32 val; + + err = pmgr_pwr_devices_get_current(g, &val); + *p = val; + + return err; +} + +int pmgr_pwr_devices_get_voltage_u64(void *data, u64 *p) +{ + struct gk20a *g = (struct gk20a *)data; + int err; + u32 val; + + err = pmgr_pwr_devices_get_voltage(g, &val); + *p = val; + + return err; +} + DEFINE_SIMPLE_ATTRIBUTE( - pmgr_power_ctrl_fops, pmgr_pwr_devices_get_current_power, NULL, "%llu\n"); + pmgr_power_ctrl_fops, pmgr_pwr_devices_get_power_u64, NULL, "%llu\n"); DEFINE_SIMPLE_ATTRIBUTE( - pmgr_current_ctrl_fops, pmgr_pwr_devices_get_current, NULL, "%llu\n"); + pmgr_current_ctrl_fops, pmgr_pwr_devices_get_current_u64, NULL, "%llu\n"); DEFINE_SIMPLE_ATTRIBUTE( - pmgr_voltage_ctrl_fops, pmgr_pwr_devices_get_current_voltage, NULL, "%llu\n"); + pmgr_voltage_ctrl_fops, pmgr_pwr_devices_get_voltage_u64, NULL, "%llu\n"); static void pmgr_debugfs_init(struct gk20a *g) { struct gk20a_platform *platform = dev_get_drvdata(g->dev); -- cgit v1.2.2