diff options
author | Lakshmanan M <lm@nvidia.com> | 2016-09-02 07:12:04 -0400 |
---|---|---|
committer | Deepak Nibade <dnibade@nvidia.com> | 2016-12-27 04:56:49 -0500 |
commit | 49c3fb25822565a9078961cdef1222aaa8c7e89a (patch) | |
tree | 9643be9d86f5bc7a85d49a7193d2653a2f7a2dcd /drivers/gpu/nvgpu/gp106/therm_gp106.c | |
parent | cb80abb2d2bee2f9feb987b83e8b106acdf14373 (diff) |
gpu: nvgpu: gp10x: Add debugfs entry for temperature reading
Added current temperature reading support for gp10x.
JIRA DNVGPU-48
Change-Id: I45959da28bbd207dcf899a9eb37900c69895cfc1
Signed-off-by: Lakshmanan M <lm@nvidia.com>
Reviewed-on: http://git-master/r/1213717
(cherry picked from commit 805245889d1df8aefce277cff9ea31ea5fb4706b)
Reviewed-on: http://git-master/r/1234092
GVS: Gerrit_Virtual_Submit
Reviewed-by: Terje Bergstrom <tbergstrom@nvidia.com>
Tested-by: Terje Bergstrom <tbergstrom@nvidia.com>
Diffstat (limited to 'drivers/gpu/nvgpu/gp106/therm_gp106.c')
-rw-r--r-- | drivers/gpu/nvgpu/gp106/therm_gp106.c | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/drivers/gpu/nvgpu/gp106/therm_gp106.c b/drivers/gpu/nvgpu/gp106/therm_gp106.c new file mode 100644 index 00000000..153e953d --- /dev/null +++ b/drivers/gpu/nvgpu/gp106/therm_gp106.c | |||
@@ -0,0 +1,62 @@ | |||
1 | /* | ||
2 | * Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved. | ||
3 | * | ||
4 | * This program is free software; you can redistribute it and/or modify it | ||
5 | * under the terms and conditions of the GNU General Public License, | ||
6 | * version 2, as published by the Free Software Foundation. | ||
7 | * | ||
8 | * This program is distributed in the hope it will be useful, but WITHOUT | ||
9 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
10 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | ||
11 | * more details. | ||
12 | */ | ||
13 | |||
14 | #include "therm_gp106.h" | ||
15 | #include <linux/debugfs.h> | ||
16 | #include "hw_therm_gp106.h" | ||
17 | |||
18 | #ifdef CONFIG_DEBUG_FS | ||
19 | static int therm_get_internal_sensor_curr_temp(void *data, u64 *val) | ||
20 | { | ||
21 | struct gk20a *g = (struct gk20a *)data; | ||
22 | int err = 0; | ||
23 | u32 readval; | ||
24 | |||
25 | readval = gk20a_readl(g, therm_temp_sensor_tsense_r()); | ||
26 | |||
27 | if (!(therm_temp_sensor_tsense_state_v(readval) & | ||
28 | therm_temp_sensor_tsense_state_valid_v())) { | ||
29 | gk20a_err(dev_from_gk20a(g), | ||
30 | "Attempt to read temperature while sensor is OFF!\n"); | ||
31 | err = -EINVAL; | ||
32 | } else if (therm_temp_sensor_tsense_state_v(readval) & | ||
33 | therm_temp_sensor_tsense_state_shadow_v()) { | ||
34 | gk20a_err(dev_from_gk20a(g), | ||
35 | "Reading temperature from SHADOWed sensor!\n"); | ||
36 | } | ||
37 | |||
38 | // Convert from F9.5 -> F27.5 -> F24.8. | ||
39 | readval &= therm_temp_sensor_tsense_fixed_point_m(); | ||
40 | |||
41 | *val = readval; | ||
42 | |||
43 | return err; | ||
44 | } | ||
45 | DEFINE_SIMPLE_ATTRIBUTE(therm_ctrl_fops, therm_get_internal_sensor_curr_temp, NULL, "%llu\n"); | ||
46 | |||
47 | static void gp106_therm_debugfs_init(struct gk20a *g) { | ||
48 | struct gk20a_platform *platform = dev_get_drvdata(g->dev); | ||
49 | struct dentry *dbgentry; | ||
50 | |||
51 | dbgentry = debugfs_create_file( | ||
52 | "temp", S_IRUGO, platform->debugfs, g, &therm_ctrl_fops); | ||
53 | if (!dbgentry) | ||
54 | gk20a_err(dev_from_gk20a(g), "debugfs entry create failed for therm_curr_temp"); | ||
55 | } | ||
56 | #endif | ||
57 | |||
58 | void gp106_init_therm_ops(struct gpu_ops *gops) { | ||
59 | #ifdef CONFIG_DEBUG_FS | ||
60 | gops->therm.therm_debugfs_init = gp106_therm_debugfs_init; | ||
61 | #endif | ||
62 | } | ||