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