1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24#include <core/device.h>
25
26#include "priv.h"
27#include "gk104.h"
28
29void
30gk104_clkgate_enable(struct nvkm_therm *base)
31{
32 struct gk104_therm *therm = gk104_therm(base);
33 struct nvkm_device *dev = therm->base.subdev.device;
34 const struct gk104_clkgate_engine_info *order = therm->clkgate_order;
35 int i;
36
37
38 for (i = 0; order[i].type != NVKM_SUBDEV_NR; i++) {
39 if (!nvkm_device_subdev(dev, order[i].type, order[i].inst))
40 continue;
41
42 nvkm_mask(dev, 0x20200 + order[i].offset, 0xff00, 0x4500);
43 }
44
45
46 nvkm_wr32(dev, 0x020288, therm->idle_filter->fecs);
47 nvkm_wr32(dev, 0x02028c, therm->idle_filter->hubmmu);
48
49
50 for (i = 0; order[i].type != NVKM_SUBDEV_NR; i++) {
51 if (!nvkm_device_subdev(dev, order[i].type, order[i].inst))
52 continue;
53
54 nvkm_mask(dev, 0x20200 + order[i].offset, 0x00ff, 0x0045);
55 }
56}
57
58void
59gk104_clkgate_fini(struct nvkm_therm *base, bool suspend)
60{
61 struct gk104_therm *therm = gk104_therm(base);
62 struct nvkm_device *dev = therm->base.subdev.device;
63 const struct gk104_clkgate_engine_info *order = therm->clkgate_order;
64 int i;
65
66
67 for (i = 0; order[i].type != NVKM_SUBDEV_NR; i++) {
68 if (!nvkm_device_subdev(dev, order[i].type, order[i].inst))
69 continue;
70
71 nvkm_mask(dev, 0x20200 + order[i].offset, 0xff, 0x54);
72 }
73}
74
75const struct gk104_clkgate_engine_info gk104_clkgate_engine_info[] = {
76 { NVKM_ENGINE_GR, 0, 0x00 },
77 { NVKM_ENGINE_MSPDEC, 0, 0x04 },
78 { NVKM_ENGINE_MSPPP, 0, 0x08 },
79 { NVKM_ENGINE_MSVLD, 0, 0x0c },
80 { NVKM_ENGINE_CE, 0, 0x10 },
81 { NVKM_ENGINE_CE, 1, 0x14 },
82 { NVKM_ENGINE_MSENC, 0, 0x18 },
83 { NVKM_ENGINE_CE, 2, 0x1c },
84 { NVKM_SUBDEV_NR },
85};
86
87const struct gf100_idle_filter gk104_idle_filter = {
88 .fecs = 0x00001000,
89 .hubmmu = 0x00001000,
90};
91
92static const struct nvkm_therm_func
93gk104_therm_func = {
94 .init = gf119_therm_init,
95 .fini = g84_therm_fini,
96 .pwm_ctrl = gf119_fan_pwm_ctrl,
97 .pwm_get = gf119_fan_pwm_get,
98 .pwm_set = gf119_fan_pwm_set,
99 .pwm_clock = gf119_fan_pwm_clock,
100 .temp_get = g84_temp_get,
101 .fan_sense = gt215_therm_fan_sense,
102 .program_alarms = nvkm_therm_program_alarms_polling,
103 .clkgate_init = gf100_clkgate_init,
104 .clkgate_enable = gk104_clkgate_enable,
105 .clkgate_fini = gk104_clkgate_fini,
106};
107
108static int
109gk104_therm_new_(const struct nvkm_therm_func *func, struct nvkm_device *device,
110 enum nvkm_subdev_type type, int inst,
111 const struct gk104_clkgate_engine_info *clkgate_order,
112 const struct gf100_idle_filter *idle_filter,
113 struct nvkm_therm **ptherm)
114{
115 struct gk104_therm *therm = kzalloc(sizeof(*therm), GFP_KERNEL);
116
117 if (!therm)
118 return -ENOMEM;
119
120 nvkm_therm_ctor(&therm->base, device, type, inst, func);
121 *ptherm = &therm->base;
122 therm->clkgate_order = clkgate_order;
123 therm->idle_filter = idle_filter;
124 return 0;
125}
126
127int
128gk104_therm_new(struct nvkm_device *device, enum nvkm_subdev_type type, int inst, struct nvkm_therm **ptherm)
129{
130 return gk104_therm_new_(&gk104_therm_func, device, type, inst,
131 gk104_clkgate_engine_info, &gk104_idle_filter,
132 ptherm);
133}
134