License cleanup: add SPDX GPL-2.0 license identifier to files with no license
[linux-block.git] / drivers / gpu / drm / nouveau / include / nvkm / subdev / therm.h
CommitLineData
b2441318 1/* SPDX-License-Identifier: GPL-2.0 */
e1404611
BS
2#ifndef __NVKM_THERM_H__
3#define __NVKM_THERM_H__
aa1b9b48
MP
4#include <core/subdev.h>
5
57113c01
BS
6#include <subdev/bios.h>
7#include <subdev/bios/therm.h>
8#include <subdev/timer.h>
9
10enum nvkm_therm_thrs_direction {
11 NVKM_THERM_THRS_FALLING = 0,
12 NVKM_THERM_THRS_RISING = 1
13};
14
15enum nvkm_therm_thrs_state {
16 NVKM_THERM_THRS_LOWER = 0,
17 NVKM_THERM_THRS_HIGHER = 1
18};
19
20enum 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
e1404611
BS
28enum nvkm_therm_fan_mode {
29 NVKM_THERM_CTRL_NONE = 0,
30 NVKM_THERM_CTRL_MANUAL = 1,
31 NVKM_THERM_CTRL_AUTO = 2,
aa1b9b48
MP
32};
33
e1404611
BS
34enum 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,
aa1b9b48 38
e1404611
BS
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,
aa1b9b48
MP
47};
48
e1404611 49struct nvkm_therm {
57113c01 50 const struct nvkm_therm_func *func;
da06b46b 51 struct nvkm_subdev subdev;
aa1b9b48 52
57113c01
BS
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;
9c3bd3a5 82
e1404611
BS
83 int (*fan_get)(struct nvkm_therm *);
84 int (*fan_set)(struct nvkm_therm *, int);
aa1b9b48 85
e1404611
BS
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);
aa1b9b48
MP
88};
89
57113c01
BS
90int nvkm_therm_temp_get(struct nvkm_therm *);
91int nvkm_therm_fan_sense(struct nvkm_therm *);
92int nvkm_therm_cstate(struct nvkm_therm *, int, int);
93
94int nv40_therm_new(struct nvkm_device *, int, struct nvkm_therm **);
95int nv50_therm_new(struct nvkm_device *, int, struct nvkm_therm **);
96int g84_therm_new(struct nvkm_device *, int, struct nvkm_therm **);
97int gt215_therm_new(struct nvkm_device *, int, struct nvkm_therm **);
98int gf119_therm_new(struct nvkm_device *, int, struct nvkm_therm **);
99int gm107_therm_new(struct nvkm_device *, int, struct nvkm_therm **);
9d60b9c9 100int gm200_therm_new(struct nvkm_device *, int, struct nvkm_therm **);
aa1b9b48 101#endif