0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024 #include "priv.h"
0025
0026 #include <subdev/gpio.h>
0027
0028 int
0029 gt215_therm_fan_sense(struct nvkm_therm *therm)
0030 {
0031 struct nvkm_device *device = therm->subdev.device;
0032 u32 tach = nvkm_rd32(device, 0x00e728) & 0x0000ffff;
0033 u32 ctrl = nvkm_rd32(device, 0x00e720);
0034 if (ctrl & 0x00000001)
0035 return tach * 60 / 2;
0036 return -ENODEV;
0037 }
0038
0039 static void
0040 gt215_therm_init(struct nvkm_therm *therm)
0041 {
0042 struct nvkm_device *device = therm->subdev.device;
0043 struct dcb_gpio_func *tach = &therm->fan->tach;
0044
0045 g84_sensor_setup(therm);
0046
0047
0048 nvkm_mask(device, 0x00e720, 0x00000003, 0x00000002);
0049 if (tach->func != DCB_GPIO_UNUSED) {
0050 nvkm_wr32(device, 0x00e724, device->crystal * 1000);
0051 nvkm_mask(device, 0x00e720, 0x001f0000, tach->line << 16);
0052 nvkm_mask(device, 0x00e720, 0x00000001, 0x00000001);
0053 }
0054 nvkm_mask(device, 0x00e720, 0x00000002, 0x00000000);
0055 }
0056
0057 static const struct nvkm_therm_func
0058 gt215_therm = {
0059 .init = gt215_therm_init,
0060 .fini = g84_therm_fini,
0061 .pwm_ctrl = nv50_fan_pwm_ctrl,
0062 .pwm_get = nv50_fan_pwm_get,
0063 .pwm_set = nv50_fan_pwm_set,
0064 .pwm_clock = nv50_fan_pwm_clock,
0065 .temp_get = g84_temp_get,
0066 .fan_sense = gt215_therm_fan_sense,
0067 .program_alarms = nvkm_therm_program_alarms_polling,
0068 };
0069
0070 int
0071 gt215_therm_new(struct nvkm_device *device, enum nvkm_subdev_type type, int inst,
0072 struct nvkm_therm **ptherm)
0073 {
0074 return nvkm_therm_new_(>215_therm, device, type, inst, ptherm);
0075 }