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 | |
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')
-rw-r--r-- | drivers/gpu/nvgpu/gp106/hal_gp106.c | 3 | ||||
-rw-r--r-- | drivers/gpu/nvgpu/gp106/hw_therm_gp106.h | 97 | ||||
-rw-r--r-- | drivers/gpu/nvgpu/gp106/therm_gp106.c | 62 | ||||
-rw-r--r-- | drivers/gpu/nvgpu/gp106/therm_gp106.h | 22 |
4 files changed, 183 insertions, 1 deletions
diff --git a/drivers/gpu/nvgpu/gp106/hal_gp106.c b/drivers/gpu/nvgpu/gp106/hal_gp106.c index eb5c4eba..d07da835 100644 --- a/drivers/gpu/nvgpu/gp106/hal_gp106.c +++ b/drivers/gpu/nvgpu/gp106/hal_gp106.c | |||
@@ -28,7 +28,7 @@ | |||
28 | #include "gp106/fifo_gp106.h" | 28 | #include "gp106/fifo_gp106.h" |
29 | #include "gp10b/regops_gp10b.h" | 29 | #include "gp10b/regops_gp10b.h" |
30 | #include "gp10b/cde_gp10b.h" | 30 | #include "gp10b/cde_gp10b.h" |
31 | #include "gp10b/therm_gp10b.h" | 31 | #include "gp106/therm_gp106.h" |
32 | 32 | ||
33 | #include "gm206/bios_gm206.h" | 33 | #include "gm206/bios_gm206.h" |
34 | 34 | ||
@@ -209,6 +209,7 @@ int gp106_init_hal(struct gk20a *g) | |||
209 | gk20a_init_css_ops(gops); | 209 | gk20a_init_css_ops(gops); |
210 | #endif | 210 | #endif |
211 | gm206_init_bios(gops); | 211 | gm206_init_bios(gops); |
212 | gp106_init_therm_ops(gops); | ||
212 | gops->name = "gp10x"; | 213 | gops->name = "gp10x"; |
213 | gops->get_litter_value = gp106_get_litter_value; | 214 | gops->get_litter_value = gp106_get_litter_value; |
214 | gops->chip_init_gpu_characteristics = gk20a_init_gpu_characteristics; | 215 | gops->chip_init_gpu_characteristics = gk20a_init_gpu_characteristics; |
diff --git a/drivers/gpu/nvgpu/gp106/hw_therm_gp106.h b/drivers/gpu/nvgpu/gp106/hw_therm_gp106.h new file mode 100644 index 00000000..ecc50980 --- /dev/null +++ b/drivers/gpu/nvgpu/gp106/hw_therm_gp106.h | |||
@@ -0,0 +1,97 @@ | |||
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 | * You should have received a copy of the GNU General Public License | ||
14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
15 | */ | ||
16 | /* | ||
17 | * Function naming determines intended use: | ||
18 | * | ||
19 | * <x>_r(void) : Returns the offset for register <x>. | ||
20 | * | ||
21 | * <x>_o(void) : Returns the offset for element <x>. | ||
22 | * | ||
23 | * <x>_w(void) : Returns the word offset for word (4 byte) element <x>. | ||
24 | * | ||
25 | * <x>_<y>_s(void) : Returns size of field <y> of register <x> in bits. | ||
26 | * | ||
27 | * <x>_<y>_f(u32 v) : Returns a value based on 'v' which has been shifted | ||
28 | * and masked to place it at field <y> of register <x>. This value | ||
29 | * can be |'d with others to produce a full register value for | ||
30 | * register <x>. | ||
31 | * | ||
32 | * <x>_<y>_m(void) : Returns a mask for field <y> of register <x>. This | ||
33 | * value can be ~'d and then &'d to clear the value of field <y> for | ||
34 | * register <x>. | ||
35 | * | ||
36 | * <x>_<y>_<z>_f(void) : Returns the constant value <z> after being shifted | ||
37 | * to place it at field <y> of register <x>. This value can be |'d | ||
38 | * with others to produce a full register value for <x>. | ||
39 | * | ||
40 | * <x>_<y>_v(u32 r) : Returns the value of field <y> from a full register | ||
41 | * <x> value 'r' after being shifted to place its LSB at bit 0. | ||
42 | * This value is suitable for direct comparison with other unshifted | ||
43 | * values appropriate for use in field <y> of register <x>. | ||
44 | * | ||
45 | * <x>_<y>_<z>_v(void) : Returns the constant value for <z> defined for | ||
46 | * field <y> of register <x>. This value is suitable for direct | ||
47 | * comparison with unshifted values appropriate for use in field <y> | ||
48 | * of register <x>. | ||
49 | */ | ||
50 | #ifndef _hw_therm_gp106_h_ | ||
51 | #define _hw_therm_gp106_h_ | ||
52 | |||
53 | static inline u32 therm_temp_sensor_tsense_r(void) | ||
54 | { | ||
55 | return 0x00020460; | ||
56 | } | ||
57 | static inline u32 therm_temp_sensor_tsense_fixed_point_f(u32 v) | ||
58 | { | ||
59 | return (v & 0x3fff) << 3; | ||
60 | } | ||
61 | static inline u32 therm_temp_sensor_tsense_fixed_point_m(void) | ||
62 | { | ||
63 | return 0x3fff << 3; | ||
64 | } | ||
65 | static inline u32 therm_temp_sensor_tsense_fixed_point_v(u32 r) | ||
66 | { | ||
67 | return (r >> 3) & 0x3fff; | ||
68 | } | ||
69 | static inline u32 therm_temp_sensor_tsense_fixed_point_min_v(void) | ||
70 | { | ||
71 | return 0x00003b00; | ||
72 | } | ||
73 | static inline u32 therm_temp_sensor_tsense_fixed_point_max_v(void) | ||
74 | { | ||
75 | return 0x000010e0; | ||
76 | } | ||
77 | static inline u32 therm_temp_sensor_tsense_state_f(u32 v) | ||
78 | { | ||
79 | return (v & 0x3) << 29; | ||
80 | } | ||
81 | static inline u32 therm_temp_sensor_tsense_state_m(void) | ||
82 | { | ||
83 | return 0x3 << 29; | ||
84 | } | ||
85 | static inline u32 therm_temp_sensor_tsense_state_v(u32 r) | ||
86 | { | ||
87 | return (r >> 29) & 0x3; | ||
88 | } | ||
89 | static inline u32 therm_temp_sensor_tsense_state_valid_v(void) | ||
90 | { | ||
91 | return 0x00000001; | ||
92 | } | ||
93 | static inline u32 therm_temp_sensor_tsense_state_shadow_v(void) | ||
94 | { | ||
95 | return 0x00000002; | ||
96 | } | ||
97 | #endif | ||
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 | } | ||
diff --git a/drivers/gpu/nvgpu/gp106/therm_gp106.h b/drivers/gpu/nvgpu/gp106/therm_gp106.h new file mode 100644 index 00000000..6db17c47 --- /dev/null +++ b/drivers/gpu/nvgpu/gp106/therm_gp106.h | |||
@@ -0,0 +1,22 @@ | |||
1 | /* | ||
2 | * general thermal control structures & definitions | ||
3 | * | ||
4 | * Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved. | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or modify it | ||
7 | * under the terms and conditions of the GNU General Public License, | ||
8 | * version 2, as published by the Free Software Foundation. | ||
9 | * | ||
10 | * This program is distributed in the hope it will be useful, but WITHOUT | ||
11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
12 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | ||
13 | * more details. | ||
14 | */ | ||
15 | |||
16 | #ifndef NVGPU_THERM_GP106_H | ||
17 | #define NVGPU_THERM_GP106_H | ||
18 | |||
19 | #include "gk20a/gk20a.h" | ||
20 | |||
21 | void gp106_init_therm_ops(struct gpu_ops *gops); | ||
22 | #endif | ||