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 "priv.h"
25
26#include <subdev/gpio.h>
27
28int
29gt215_therm_fan_sense(struct nvkm_therm *therm)
30{
31 struct nvkm_device *device = therm->subdev.device;
32 u32 tach = nvkm_rd32(device, 0x00e728) & 0x0000ffff;
33 u32 ctrl = nvkm_rd32(device, 0x00e720);
34 if (ctrl & 0x00000001)
35 return tach * 60 / 2;
36 return -ENODEV;
37}
38
39static void
40gt215_therm_init(struct nvkm_therm *therm)
41{
42 struct nvkm_device *device = therm->subdev.device;
43 struct dcb_gpio_func *tach = &therm->fan->tach;
44
45 g84_sensor_setup(therm);
46
47
48 nvkm_mask(device, 0x00e720, 0x00000003, 0x00000002);
49 if (tach->func != DCB_GPIO_UNUSED) {
50 nvkm_wr32(device, 0x00e724, device->crystal * 1000);
51 nvkm_mask(device, 0x00e720, 0x001f0000, tach->line << 16);
52 nvkm_mask(device, 0x00e720, 0x00000001, 0x00000001);
53 }
54 nvkm_mask(device, 0x00e720, 0x00000002, 0x00000000);
55}
56
57static const struct nvkm_therm_func
58gt215_therm = {
59 .init = gt215_therm_init,
60 .fini = g84_therm_fini,
61 .pwm_ctrl = nv50_fan_pwm_ctrl,
62 .pwm_get = nv50_fan_pwm_get,
63 .pwm_set = nv50_fan_pwm_set,
64 .pwm_clock = nv50_fan_pwm_clock,
65 .temp_get = g84_temp_get,
66 .fan_sense = gt215_therm_fan_sense,
67 .program_alarms = nvkm_therm_program_alarms_polling,
68};
69
70int
71gt215_therm_new(struct nvkm_device *device, enum nvkm_subdev_type type, int inst,
72 struct nvkm_therm **ptherm)
73{
74 return nvkm_therm_new_(>215_therm, device, type, inst, ptherm);
75}
76