summaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorLakshmanan M <lm@nvidia.com>2016-10-21 07:27:15 -0400
committerDeepak Nibade <dnibade@nvidia.com>2016-12-27 04:56:51 -0500
commit58b85dd106f35d16ff568f8836dcbc7a019854b4 (patch)
treea87c10e83f020bd9f414fa4dd0bea74d961034b3 /drivers
parent2f4405ddcb1cd7bb939d3b22ab72789afb435da6 (diff)
gpu: nvgpu: Add thermal module support
The following CL contains the following VBIOS thermal table parsing and PMU interface support. 1) Thermal device table 2) Thermal channel table JIRA DNVGPU-130 Change-Id: Ie3abab4bf099a022b1b59db96811c2ed44079519 Signed-off-by: Lakshmanan M <lm@nvidia.com> Reviewed-on: http://git-master/r/1240630 (cherry picked from commit 814962a4be0a8cd0cddc7bc5211c62308ab1fea2) Reviewed-on: http://git-master/r/1246210 GVS: Gerrit_Virtual_Submit Reviewed-by: Terje Bergstrom <tbergstrom@nvidia.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/gpu/nvgpu/Makefile.nvgpu-t18x6
-rw-r--r--drivers/gpu/nvgpu/include/bios.h54
-rw-r--r--drivers/gpu/nvgpu/pstate/pstate.c9
-rw-r--r--drivers/gpu/nvgpu/therm/thrm.c45
-rw-r--r--drivers/gpu/nvgpu/therm/thrm.h29
-rw-r--r--drivers/gpu/nvgpu/therm/thrmchannel.c247
-rw-r--r--drivers/gpu/nvgpu/therm/thrmchannel.h42
-rw-r--r--drivers/gpu/nvgpu/therm/thrmdev.c193
-rw-r--r--drivers/gpu/nvgpu/therm/thrmdev.h31
-rw-r--r--drivers/gpu/nvgpu/therm/thrmpmu.c51
-rw-r--r--drivers/gpu/nvgpu/therm/thrmpmu.h20
11 files changed, 726 insertions, 1 deletions
diff --git a/drivers/gpu/nvgpu/Makefile.nvgpu-t18x b/drivers/gpu/nvgpu/Makefile.nvgpu-t18x
index ea770e43..91243de0 100644
--- a/drivers/gpu/nvgpu/Makefile.nvgpu-t18x
+++ b/drivers/gpu/nvgpu/Makefile.nvgpu-t18x
@@ -54,7 +54,11 @@ nvgpu-y += \
54 $(nvgpu-t18x)/volt/volt_rail.o \ 54 $(nvgpu-t18x)/volt/volt_rail.o \
55 $(nvgpu-t18x)/volt/volt_dev.o \ 55 $(nvgpu-t18x)/volt/volt_dev.o \
56 $(nvgpu-t18x)/volt/volt_policy.o \ 56 $(nvgpu-t18x)/volt/volt_policy.o \
57 $(nvgpu-t18x)/volt/volt_pmu.o 57 $(nvgpu-t18x)/volt/volt_pmu.o \
58 $(nvgpu-t18x)/therm/thrm.o \
59 $(nvgpu-t18x)/therm/thrmdev.o \
60 $(nvgpu-t18x)/therm/thrmchannel.o \
61 $(nvgpu-t18x)/therm/thrmpmu.o
58 62
59nvgpu-$(CONFIG_TEGRA_GK20A) += $(nvgpu-t18x)/gp10b/platform_gp10b_tegra.o 63nvgpu-$(CONFIG_TEGRA_GK20A) += $(nvgpu-t18x)/gp10b/platform_gp10b_tegra.o
60 64
diff --git a/drivers/gpu/nvgpu/include/bios.h b/drivers/gpu/nvgpu/include/bios.h
index fb1e1f46..02991db9 100644
--- a/drivers/gpu/nvgpu/include/bios.h
+++ b/drivers/gpu/nvgpu/include/bios.h
@@ -788,4 +788,58 @@ struct vbios_voltage_policy_table_1x_entry {
788#define NV_VBIOS_VPT_ENTRY_PARAM1_SR_SETTLE_TIME_INTERMEDIATE_SHIFT \ 788#define NV_VBIOS_VPT_ENTRY_PARAM1_SR_SETTLE_TIME_INTERMEDIATE_SHIFT \
789 0 789 0
790 790
791#define VBIOS_THERM_DEVICE_VERSION_1X 0x10
792
793#define VBIOS_THERM_DEVICE_1X_HEADER_SIZE_04 0x00000004
794
795struct therm_device_1x_header {
796 u8 version;
797 u8 header_size;
798 u8 table_entry_size;
799 u8 num_table_entries;
800} ;
801
802struct therm_device_1x_entry {
803 u8 class_id;
804 u8 param0;
805 u8 flags;
806} ;
807
808#define NV_VBIOS_THERM_DEVICE_1X_ENTRY_CLASS_GPU 0x01
809
810#define NV_VBIOS_THERM_DEVICE_1X_ENTRY_PARAM0_I2C_DEVICE_INDEX_MASK 0xFF
811#define NV_VBIOS_THERM_DEVICE_1X_ENTRY_PARAM0_I2C_DEVICE_INDEX_SHIFT 0
812
813#define VBIOS_THERM_CHANNEL_VERSION_1X 0x10
814
815#define VBIOS_THERM_CHANNEL_1X_HEADER_SIZE_09 0x00000009
816
817struct therm_channel_1x_header {
818 u8 version;
819 u8 header_size;
820 u8 table_entry_size;
821 u8 num_table_entries;
822 u8 gpu_avg_pri_ch_idx;
823 u8 gpu_max_pri_ch_idx;
824 u8 board_pri_ch_idx;
825 u8 mem_pri_ch_idx;
826 u8 pwr_supply_pri_ch_idx;
827};
828
829struct therm_channel_1x_entry {
830 u8 class_id;
831 u8 param0;
832 u8 param1;
833 u8 param2;
834 u8 flags;
835};
836
837#define NV_VBIOS_THERM_CHANNEL_1X_ENTRY_CLASS_DEVICE 0x01
838
839#define NV_VBIOS_THERM_CHANNEL_1X_ENTRY_PARAM0_DEVICE_INDEX_MASK 0xFF
840#define NV_VBIOS_THERM_CHANNEL_1X_ENTRY_PARAM0_DEVICE_INDEX_SHIFT 0
841
842#define NV_VBIOS_THERM_CHANNEL_1X_ENTRY_PARAM1_DEVICE_PROVIDER_INDEX_MASK 0xFF
843#define NV_VBIOS_THERM_CHANNEL_1X_ENTRY_PARAM1_DEVICE_PROVIDER_INDEX_SHIFT 0
844
791#endif 845#endif
diff --git a/drivers/gpu/nvgpu/pstate/pstate.c b/drivers/gpu/nvgpu/pstate/pstate.c
index a4787f35..e9b9775e 100644
--- a/drivers/gpu/nvgpu/pstate/pstate.c
+++ b/drivers/gpu/nvgpu/pstate/pstate.c
@@ -19,6 +19,7 @@
19#include "pmgr/pmgr.h" 19#include "pmgr/pmgr.h"
20#include "include/bios.h" 20#include "include/bios.h"
21#include "pstate/pstate.h" 21#include "pstate/pstate.h"
22#include "therm/thrm.h"
22 23
23static int pstate_sw_setup(struct gk20a *g); 24static int pstate_sw_setup(struct gk20a *g);
24 25
@@ -49,6 +50,10 @@ int gk20a_init_pstate_support(struct gk20a *g)
49 if (err) 50 if (err)
50 return err; 51 return err;
51 52
53 err = therm_domain_sw_setup(g);
54 if (err)
55 return err;
56
52 err = vfe_var_sw_setup(g); 57 err = vfe_var_sw_setup(g);
53 if (err) 58 if (err)
54 return err; 59 return err;
@@ -104,6 +109,10 @@ int gk20a_init_pstate_pmu_support(struct gk20a *g)
104 return err; 109 return err;
105 } 110 }
106 111
112 err = therm_domain_pmu_setup(g);
113 if (err)
114 return err;
115
107 err = vfe_var_pmu_setup(g); 116 err = vfe_var_pmu_setup(g);
108 if (err) 117 if (err)
109 return err; 118 return err;
diff --git a/drivers/gpu/nvgpu/therm/thrm.c b/drivers/gpu/nvgpu/therm/thrm.c
new file mode 100644
index 00000000..731cf89e
--- /dev/null
+++ b/drivers/gpu/nvgpu/therm/thrm.c
@@ -0,0 +1,45 @@
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 "gk20a/gk20a.h"
15#include "thrm.h"
16#include "thrmpmu.h"
17
18u32 therm_domain_sw_setup(struct gk20a *g)
19{
20 u32 status;
21
22 status = therm_device_sw_setup(g);
23 if (status) {
24 gk20a_err(dev_from_gk20a(g),
25 "error creating boardobjgrp for therm devices, status - 0x%x",
26 status);
27 goto exit;
28 }
29
30 status = therm_channel_sw_setup(g);
31 if (status) {
32 gk20a_err(dev_from_gk20a(g),
33 "error creating boardobjgrp for therm channel, status - 0x%x",
34 status);
35 goto exit;
36 }
37
38exit:
39 return status;
40}
41
42u32 therm_domain_pmu_setup(struct gk20a *g)
43{
44 return therm_send_pmgr_tables_to_pmu(g);
45}
diff --git a/drivers/gpu/nvgpu/therm/thrm.h b/drivers/gpu/nvgpu/therm/thrm.h
new file mode 100644
index 00000000..1db93b49
--- /dev/null
+++ b/drivers/gpu/nvgpu/therm/thrm.h
@@ -0,0 +1,29 @@
1/*
2 * general thermal table 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#ifndef _THRM_H_
16#define _THRM_H_
17
18#include "thrmdev.h"
19#include "thrmchannel.h"
20
21struct therm_pmupstate {
22 struct therm_devices therm_deviceobjs;
23 struct therm_channels therm_channelobjs;
24};
25
26u32 therm_domain_sw_setup(struct gk20a *g);
27u32 therm_domain_pmu_setup(struct gk20a *g);
28
29#endif
diff --git a/drivers/gpu/nvgpu/therm/thrmchannel.c b/drivers/gpu/nvgpu/therm/thrmchannel.c
new file mode 100644
index 00000000..015e065b
--- /dev/null
+++ b/drivers/gpu/nvgpu/therm/thrmchannel.c
@@ -0,0 +1,247 @@
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 "gk20a/gk20a.h"
15#include "thrmchannel.h"
16#include "include/bios.h"
17#include "boardobj/boardobjgrp.h"
18#include "boardobj/boardobjgrp_e32.h"
19#include "pmuif/gpmuifboardobj.h"
20#include "pmuif/gpmuifthermsensor.h"
21#include "gm206/bios_gm206.h"
22#include "gk20a/pmu_gk20a.h"
23
24static u32 _therm_channel_pmudatainit_device(struct gk20a *g,
25 struct boardobj *board_obj_ptr,
26 struct nv_pmu_boardobj *ppmudata)
27{
28 u32 status = 0;
29 struct therm_channel *pchannel;
30 struct therm_channel_device *ptherm_channel;
31 struct nv_pmu_therm_therm_channel_device_boardobj_set *pset;
32
33 status = boardobj_pmudatainit_super(g, board_obj_ptr, ppmudata);
34 if (status) {
35 gk20a_err(dev_from_gk20a(g),
36 "error updating pmu boardobjgrp for therm channel 0x%x",
37 status);
38 status = -ENOMEM;
39 goto done;
40 }
41
42 pchannel = (struct therm_channel *)board_obj_ptr;
43 pset = (struct nv_pmu_therm_therm_channel_device_boardobj_set *)ppmudata;
44 ptherm_channel = (struct therm_channel_device *)board_obj_ptr;
45
46 pset->super.scaling = pchannel->scaling;
47 pset->super.offset = pchannel->offset;
48 pset->super.temp_min = pchannel->temp_min;
49 pset->super.temp_max = pchannel->temp_max;
50
51 pset->therm_dev_idx = ptherm_channel->therm_dev_idx;
52 pset->therm_dev_prov_idx = ptherm_channel->therm_dev_prov_idx;
53
54done:
55 return status;
56}
57static struct boardobj *construct_channel_device(struct gk20a *g,
58 void *pargs, u16 pargs_size, u8 type)
59{
60 struct boardobj *board_obj_ptr = NULL;
61 struct therm_channel *pchannel;
62 struct therm_channel_device *pchannel_device;
63 u32 status;
64 struct therm_channel_device *therm_device = (struct therm_channel_device*)pargs;
65
66 status = boardobj_construct_super(g, &board_obj_ptr,
67 pargs_size, pargs);
68 if (status)
69 return NULL;
70
71 /* Set Super class interfaces */
72 board_obj_ptr->pmudatainit = _therm_channel_pmudatainit_device;
73
74 pchannel = (struct therm_channel *)board_obj_ptr;
75 pchannel_device = (struct therm_channel_device *)board_obj_ptr;
76
77 pchannel->temp_min = 0;
78 pchannel->temp_max = 0;
79
80 pchannel->scaling = (1 << 8);
81 pchannel->offset = 0;
82
83 pchannel_device->therm_dev_idx = therm_device->therm_dev_idx;
84 pchannel_device->therm_dev_prov_idx = therm_device->therm_dev_prov_idx;
85
86 gk20a_dbg_info(" Done");
87
88 return board_obj_ptr;
89}
90
91static u32 _therm_channel_pmudata_instget(struct gk20a *g,
92 struct nv_pmu_boardobjgrp *pmuboardobjgrp,
93 struct nv_pmu_boardobj **ppboardobjpmudata,
94 u8 idx)
95{
96 struct nv_pmu_therm_therm_channel_boardobj_grp_set *pgrp_set =
97 (struct nv_pmu_therm_therm_channel_boardobj_grp_set *)
98 pmuboardobjgrp;
99
100 gk20a_dbg_info("");
101
102 /*check whether pmuboardobjgrp has a valid boardobj in index*/
103 if (((u32)BIT(idx) &
104 pgrp_set->hdr.data.super.obj_mask.super.data[0]) == 0)
105 return -EINVAL;
106
107 *ppboardobjpmudata = (struct nv_pmu_boardobj *)
108 &pgrp_set->objects[idx].data.board_obj;
109
110 gk20a_dbg_info(" Done");
111
112 return 0;
113}
114
115static u32 devinit_get_therm_channel_table(struct gk20a *g,
116 struct therm_channels *pthermchannelobjs)
117{
118 u32 status = 0;
119 u8 *therm_channel_table_ptr = NULL;
120 u8 *curr_therm_channel_table_ptr = NULL;
121 struct boardobj *boardobj;
122 struct therm_channel_1x_header therm_channel_table_header = { 0 };
123 struct therm_channel_1x_entry *therm_channel_table_entry = NULL;
124 u32 index;
125 u32 obj_index = 0;
126 u16 therm_channel_size = 0;
127 union {
128 struct boardobj boardobj;
129 struct therm_channel therm_channel;
130 struct therm_channel_device device;
131 } therm_channel_data;
132
133 gk20a_dbg_info("");
134
135 if (g->ops.bios.get_perf_table_ptrs) {
136 therm_channel_table_ptr = (u8 *)g->ops.bios.get_perf_table_ptrs(g,
137 g->bios.perf_token, THERMAL_CHANNEL_TABLE);
138 if (therm_channel_table_ptr == NULL) {
139 status = -EINVAL;
140 goto done;
141 }
142 }
143
144 memcpy(&therm_channel_table_header, therm_channel_table_ptr,
145 VBIOS_THERM_CHANNEL_1X_HEADER_SIZE_09);
146
147 if (therm_channel_table_header.version !=
148 VBIOS_THERM_CHANNEL_VERSION_1X) {
149 status = -EINVAL;
150 goto done;
151 }
152
153 if (therm_channel_table_header.header_size <
154 VBIOS_THERM_CHANNEL_1X_HEADER_SIZE_09) {
155 status = -EINVAL;
156 goto done;
157 }
158
159 curr_therm_channel_table_ptr = (therm_channel_table_ptr +
160 VBIOS_THERM_CHANNEL_1X_HEADER_SIZE_09);
161
162 for (index = 0; index < therm_channel_table_header.num_table_entries;
163 index++) {
164 therm_channel_table_entry = (struct therm_channel_1x_entry *)
165 (curr_therm_channel_table_ptr +
166 (therm_channel_table_header.table_entry_size * index));
167
168 if (therm_channel_table_entry->class_id !=
169 NV_VBIOS_THERM_CHANNEL_1X_ENTRY_CLASS_DEVICE) {
170 continue;
171 }
172
173 therm_channel_data.device.therm_dev_idx = therm_channel_table_entry->param0;
174 therm_channel_data.device.therm_dev_prov_idx = therm_channel_table_entry->param1;
175
176 therm_channel_size = sizeof(struct therm_channel_device);
177 therm_channel_data.boardobj.type = CTRL_THERMAL_THERM_CHANNEL_CLASS_DEVICE;
178
179 boardobj = construct_channel_device(g, &therm_channel_data,
180 therm_channel_size, therm_channel_data.boardobj.type);
181
182 if (!boardobj) {
183 gk20a_err(dev_from_gk20a(g),
184 "unable to create thermal device for %d type %d",
185 index, therm_channel_data.boardobj.type);
186 status = -EINVAL;
187 goto done;
188 }
189
190 status = boardobjgrp_objinsert(&pthermchannelobjs->super.super,
191 boardobj, obj_index);
192
193 if (status) {
194 gk20a_err(dev_from_gk20a(g),
195 "unable to insert thermal device boardobj for %d", index);
196 status = -EINVAL;
197 goto done;
198 }
199
200 ++obj_index;
201 }
202
203done:
204 gk20a_dbg_info(" done status %x", status);
205 return status;
206}
207
208u32 therm_channel_sw_setup(struct gk20a *g)
209{
210 u32 status;
211 struct boardobjgrp *pboardobjgrp = NULL;
212 struct therm_channels *pthermchannelobjs;
213
214 /* Construct the Super Class and override the Interfaces */
215 status = boardobjgrpconstruct_e32(&g->therm_pmu.therm_channelobjs.super);
216 if (status) {
217 gk20a_err(dev_from_gk20a(g),
218 "error creating boardobjgrp for therm devices, status - 0x%x",
219 status);
220 goto done;
221 }
222
223 pboardobjgrp = &g->therm_pmu.therm_channelobjs.super.super;
224 pthermchannelobjs = &(g->therm_pmu.therm_channelobjs);
225
226 /* Override the Interfaces */
227 pboardobjgrp->pmudatainstget = _therm_channel_pmudata_instget;
228
229 status = devinit_get_therm_channel_table(g, pthermchannelobjs);
230 if (status)
231 goto done;
232
233 BOARDOBJGRP_PMU_CONSTRUCT(pboardobjgrp, THERM, THERM_CHANNEL);
234
235 status = BOARDOBJGRP_PMU_CMD_GRP_SET_CONSTRUCT(g, pboardobjgrp,
236 therm, THERM, therm_channel, THERM_CHANNEL);
237 if (status) {
238 gk20a_err(dev_from_gk20a(g),
239 "error constructing PMU_BOARDOBJ_CMD_GRP_SET interface - 0x%x",
240 status);
241 goto done;
242 }
243
244done:
245 gk20a_dbg_info(" done status %x", status);
246 return status;
247}
diff --git a/drivers/gpu/nvgpu/therm/thrmchannel.h b/drivers/gpu/nvgpu/therm/thrmchannel.h
new file mode 100644
index 00000000..4b9d19da
--- /dev/null
+++ b/drivers/gpu/nvgpu/therm/thrmchannel.h
@@ -0,0 +1,42 @@
1/*
2 * general thermal device 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#ifndef _THRMCHANNEL_H_
16#define _THRMCHANNEL_H_
17
18#include "boardobj/boardobj.h"
19#include "boardobj/boardobjgrp.h"
20#include "ctrl/ctrltherm.h"
21
22struct therm_channel {
23 struct boardobj super;
24 s16 scaling;
25 s16 offset;
26 s32 temp_min;
27 s32 temp_max;
28};
29
30struct therm_channels {
31 struct boardobjgrp_e32 super;
32};
33
34struct therm_channel_device {
35 struct therm_channel super;
36 u8 therm_dev_idx;
37 u8 therm_dev_prov_idx;
38};
39
40u32 therm_channel_sw_setup(struct gk20a *g);
41
42#endif
diff --git a/drivers/gpu/nvgpu/therm/thrmdev.c b/drivers/gpu/nvgpu/therm/thrmdev.c
new file mode 100644
index 00000000..83ac9739
--- /dev/null
+++ b/drivers/gpu/nvgpu/therm/thrmdev.c
@@ -0,0 +1,193 @@
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 "gk20a/gk20a.h"
15#include "thrmdev.h"
16#include "include/bios.h"
17#include "boardobj/boardobjgrp.h"
18#include "boardobj/boardobjgrp_e32.h"
19#include "pmuif/gpmuifboardobj.h"
20#include "pmuif/gpmuifthermsensor.h"
21#include "gm206/bios_gm206.h"
22#include "gk20a/pmu_gk20a.h"
23#include "ctrl/ctrltherm.h"
24
25static struct boardobj *construct_therm_device(struct gk20a *g,
26 void *pargs, u16 pargs_size, u8 type)
27{
28 struct boardobj *board_obj_ptr = NULL;
29 u32 status;
30
31 status = boardobj_construct_super(g, &board_obj_ptr,
32 pargs_size, pargs);
33 if (status)
34 return NULL;
35
36 gk20a_dbg_info(" Done");
37
38 return board_obj_ptr;
39}
40
41static u32 _therm_device_pmudata_instget(struct gk20a *g,
42 struct nv_pmu_boardobjgrp *pmuboardobjgrp,
43 struct nv_pmu_boardobj **ppboardobjpmudata,
44 u8 idx)
45{
46 struct nv_pmu_therm_therm_device_boardobj_grp_set *pgrp_set =
47 (struct nv_pmu_therm_therm_device_boardobj_grp_set *)
48 pmuboardobjgrp;
49
50 gk20a_dbg_info("");
51
52 /*check whether pmuboardobjgrp has a valid boardobj in index*/
53 if (((u32)BIT(idx) &
54 pgrp_set->hdr.data.super.obj_mask.super.data[0]) == 0)
55 return -EINVAL;
56
57 *ppboardobjpmudata = (struct nv_pmu_boardobj *)
58 &pgrp_set->objects[idx].data;
59
60 gk20a_dbg_info(" Done");
61
62 return 0;
63}
64
65static u32 devinit_get_therm_device_table(struct gk20a *g,
66 struct therm_devices *pthermdeviceobjs)
67{
68 u32 status = 0;
69 u8 *therm_device_table_ptr = NULL;
70 u8 *curr_therm_device_table_ptr = NULL;
71 struct boardobj *boardobj;
72 struct therm_device_1x_header therm_device_table_header = { 0 };
73 struct therm_device_1x_entry *therm_device_table_entry = NULL;
74 u32 index;
75 u32 obj_index = 0;
76 u16 therm_device_size = 0;
77 union {
78 struct boardobj boardobj;
79 struct therm_device therm_device;
80 } therm_device_data;
81
82 gk20a_dbg_info("");
83
84 if (g->ops.bios.get_perf_table_ptrs) {
85 therm_device_table_ptr = (u8 *)g->ops.bios.get_perf_table_ptrs(g,
86 g->bios.perf_token, THERMAL_DEVICE_TABLE);
87 if (therm_device_table_ptr == NULL) {
88 status = -EINVAL;
89 goto done;
90 }
91 }
92
93 memcpy(&therm_device_table_header, therm_device_table_ptr,
94 VBIOS_THERM_DEVICE_1X_HEADER_SIZE_04);
95
96 if (therm_device_table_header.version !=
97 VBIOS_THERM_DEVICE_VERSION_1X) {
98 status = -EINVAL;
99 goto done;
100 }
101
102 if (therm_device_table_header.header_size <
103 VBIOS_THERM_DEVICE_1X_HEADER_SIZE_04) {
104 status = -EINVAL;
105 goto done;
106 }
107
108 curr_therm_device_table_ptr = (therm_device_table_ptr +
109 VBIOS_THERM_DEVICE_1X_HEADER_SIZE_04);
110
111 for (index = 0; index < therm_device_table_header.num_table_entries;
112 index++) {
113 therm_device_table_entry = (struct therm_device_1x_entry *)
114 (curr_therm_device_table_ptr +
115 (therm_device_table_header.table_entry_size * index));
116
117 if (therm_device_table_entry->class_id !=
118 NV_VBIOS_THERM_DEVICE_1X_ENTRY_CLASS_GPU) {
119 continue;
120 }
121
122 therm_device_size = sizeof(struct therm_device);
123 therm_device_data.boardobj.type = CTRL_THERMAL_THERM_DEVICE_CLASS_GPU;
124
125 boardobj = construct_therm_device(g, &therm_device_data,
126 therm_device_size, therm_device_data.boardobj.type);
127
128 if (!boardobj) {
129 gk20a_err(dev_from_gk20a(g),
130 "unable to create thermal device for %d type %d",
131 index, therm_device_data.boardobj.type);
132 status = -EINVAL;
133 goto done;
134 }
135
136 status = boardobjgrp_objinsert(&pthermdeviceobjs->super.super,
137 boardobj, obj_index);
138
139 if (status) {
140 gk20a_err(dev_from_gk20a(g),
141 "unable to insert thermal device boardobj for %d", index);
142 status = -EINVAL;
143 goto done;
144 }
145
146 ++obj_index;
147 }
148
149done:
150 gk20a_dbg_info(" done status %x", status);
151 return status;
152}
153
154u32 therm_device_sw_setup(struct gk20a *g)
155{
156 u32 status;
157 struct boardobjgrp *pboardobjgrp = NULL;
158 struct therm_devices *pthermdeviceobjs;
159
160 /* Construct the Super Class and override the Interfaces */
161 status = boardobjgrpconstruct_e32(&g->therm_pmu.therm_deviceobjs.super);
162 if (status) {
163 gk20a_err(dev_from_gk20a(g),
164 "error creating boardobjgrp for therm devices, status - 0x%x",
165 status);
166 goto done;
167 }
168
169 pboardobjgrp = &g->therm_pmu.therm_deviceobjs.super.super;
170 pthermdeviceobjs = &(g->therm_pmu.therm_deviceobjs);
171
172 /* Override the Interfaces */
173 pboardobjgrp->pmudatainstget = _therm_device_pmudata_instget;
174
175 status = devinit_get_therm_device_table(g, pthermdeviceobjs);
176 if (status)
177 goto done;
178
179 BOARDOBJGRP_PMU_CONSTRUCT(pboardobjgrp, THERM, THERM_DEVICE);
180
181 status = BOARDOBJGRP_PMU_CMD_GRP_SET_CONSTRUCT(g, pboardobjgrp,
182 therm, THERM, therm_device, THERM_DEVICE);
183 if (status) {
184 gk20a_err(dev_from_gk20a(g),
185 "error constructing PMU_BOARDOBJ_CMD_GRP_SET interface - 0x%x",
186 status);
187 goto done;
188 }
189
190done:
191 gk20a_dbg_info(" done status %x", status);
192 return status;
193}
diff --git a/drivers/gpu/nvgpu/therm/thrmdev.h b/drivers/gpu/nvgpu/therm/thrmdev.h
new file mode 100644
index 00000000..35be47c0
--- /dev/null
+++ b/drivers/gpu/nvgpu/therm/thrmdev.h
@@ -0,0 +1,31 @@
1/*
2 * general thermal device 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#ifndef _THRMDEV_H_
16#define _THRMDEV_H_
17
18#include "boardobj/boardobj.h"
19#include "boardobj/boardobjgrp.h"
20
21struct therm_devices {
22 struct boardobjgrp_e32 super;
23};
24
25struct therm_device {
26 struct therm_devices super;
27};
28
29u32 therm_device_sw_setup(struct gk20a *g);
30
31#endif
diff --git a/drivers/gpu/nvgpu/therm/thrmpmu.c b/drivers/gpu/nvgpu/therm/thrmpmu.c
new file mode 100644
index 00000000..0ff7090b
--- /dev/null
+++ b/drivers/gpu/nvgpu/therm/thrmpmu.c
@@ -0,0 +1,51 @@
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 "gk20a/gk20a.h"
15#include "include/bios.h"
16#include "boardobj/boardobjgrp.h"
17#include "boardobj/boardobjgrp_e32.h"
18#include "pmuif/gpmuifboardobj.h"
19#include "thrmpmu.h"
20
21u32 therm_send_pmgr_tables_to_pmu(struct gk20a *g)
22{
23 u32 status = 0;
24 struct boardobjgrp *pboardobjgrp = NULL;
25
26 if (!BOARDOBJGRP_IS_EMPTY(&g->therm_pmu.therm_deviceobjs.super.super)) {
27 pboardobjgrp = &g->therm_pmu.therm_deviceobjs.super.super;
28 status = pboardobjgrp->pmuinithandle(g, pboardobjgrp);
29 if (status) {
30 gk20a_err(dev_from_gk20a(g),
31 "therm_send_pmgr_tables_to_pmu - therm_device failed %x",
32 status);
33 goto exit;
34 }
35 }
36
37 if (!BOARDOBJGRP_IS_EMPTY(
38 &g->therm_pmu.therm_channelobjs.super.super)) {
39 pboardobjgrp = &g->therm_pmu.therm_channelobjs.super.super;
40 status = pboardobjgrp->pmuinithandle(g, pboardobjgrp);
41 if (status) {
42 gk20a_err(dev_from_gk20a(g),
43 "therm_send_pmgr_tables_to_pmu - therm_channel failed %x",
44 status);
45 goto exit;
46 }
47 }
48
49exit:
50 return status;
51}
diff --git a/drivers/gpu/nvgpu/therm/thrmpmu.h b/drivers/gpu/nvgpu/therm/thrmpmu.h
new file mode 100644
index 00000000..007af720
--- /dev/null
+++ b/drivers/gpu/nvgpu/therm/thrmpmu.h
@@ -0,0 +1,20 @@
1/*
2 * general thermal pmu 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#ifndef _THRMPMU_H_
16#define _THRMPMU_H_
17
18u32 therm_send_pmgr_tables_to_pmu(struct gk20a *g);
19
20#endif