1#ifndef __NVKM_THERM_H__
2#define __NVKM_THERM_H__
3#include <core/subdev.h>
4
5#include <subdev/bios.h>
6#include <subdev/bios/therm.h>
7#include <subdev/timer.h>
8
9enum nvkm_therm_thrs_direction {
10 NVKM_THERM_THRS_FALLING = 0,
11 NVKM_THERM_THRS_RISING = 1
12};
13
14enum nvkm_therm_thrs_state {
15 NVKM_THERM_THRS_LOWER = 0,
16 NVKM_THERM_THRS_HIGHER = 1
17};
18
19enum nvkm_therm_thrs {
20 NVKM_THERM_THRS_FANBOOST = 0,
21 NVKM_THERM_THRS_DOWNCLOCK = 1,
22 NVKM_THERM_THRS_CRITICAL = 2,
23 NVKM_THERM_THRS_SHUTDOWN = 3,
24 NVKM_THERM_THRS_NR
25};
26
27enum nvkm_therm_fan_mode {
28 NVKM_THERM_CTRL_NONE = 0,
29 NVKM_THERM_CTRL_MANUAL = 1,
30 NVKM_THERM_CTRL_AUTO = 2,
31};
32
33enum nvkm_therm_attr_type {
34 NVKM_THERM_ATTR_FAN_MIN_DUTY = 0,
35 NVKM_THERM_ATTR_FAN_MAX_DUTY = 1,
36 NVKM_THERM_ATTR_FAN_MODE = 2,
37
38 NVKM_THERM_ATTR_THRS_FAN_BOOST = 10,
39 NVKM_THERM_ATTR_THRS_FAN_BOOST_HYST = 11,
40 NVKM_THERM_ATTR_THRS_DOWN_CLK = 12,
41 NVKM_THERM_ATTR_THRS_DOWN_CLK_HYST = 13,
42 NVKM_THERM_ATTR_THRS_CRITICAL = 14,
43 NVKM_THERM_ATTR_THRS_CRITICAL_HYST = 15,
44 NVKM_THERM_ATTR_THRS_SHUTDOWN = 16,
45 NVKM_THERM_ATTR_THRS_SHUTDOWN_HYST = 17,
46};
47
48struct nvkm_therm {
49 const struct nvkm_therm_func *func;
50 struct nvkm_subdev subdev;
51
52
53 struct nvkm_alarm alarm;
54 spinlock_t lock;
55 struct nvbios_therm_trip_point *last_trip;
56 int mode;
57 int cstate;
58 int suspend;
59
60
61 struct nvbios_therm_sensor bios_sensor;
62
63
64 struct nvkm_fan *fan;
65
66
67 struct {
68 spinlock_t alarm_program_lock;
69 struct nvkm_alarm therm_poll_alarm;
70 enum nvkm_therm_thrs_state alarm_state[NVKM_THERM_THRS_NR];
71 } sensor;
72
73
74 struct {
75 void (*downclock)(struct nvkm_therm *, bool active);
76 void (*pause)(struct nvkm_therm *, bool active);
77 } emergency;
78
79
80 struct i2c_client *ic;
81
82 int (*fan_get)(struct nvkm_therm *);
83 int (*fan_set)(struct nvkm_therm *, int);
84
85 int (*attr_get)(struct nvkm_therm *, enum nvkm_therm_attr_type);
86 int (*attr_set)(struct nvkm_therm *, enum nvkm_therm_attr_type, int);
87};
88
89int nvkm_therm_temp_get(struct nvkm_therm *);
90int nvkm_therm_fan_sense(struct nvkm_therm *);
91int nvkm_therm_cstate(struct nvkm_therm *, int, int);
92
93int nv40_therm_new(struct nvkm_device *, int, struct nvkm_therm **);
94int nv50_therm_new(struct nvkm_device *, int, struct nvkm_therm **);
95int g84_therm_new(struct nvkm_device *, int, struct nvkm_therm **);
96int gt215_therm_new(struct nvkm_device *, int, struct nvkm_therm **);
97int gf119_therm_new(struct nvkm_device *, int, struct nvkm_therm **);
98int gm107_therm_new(struct nvkm_device *, int, struct nvkm_therm **);
99#endif
100