xref: /linux/drivers/gpu/drm/nouveau/include/nvkm/subdev/therm.h (revision 93d90ad708b8da6efc0e487b66111aa9db7f70c7)
1 #ifndef __NOUVEAU_THERM_H__
2 #define __NOUVEAU_THERM_H__
3 
4 #include <core/device.h>
5 #include <core/subdev.h>
6 
7 enum nouveau_therm_fan_mode {
8 	NOUVEAU_THERM_CTRL_NONE = 0,
9 	NOUVEAU_THERM_CTRL_MANUAL = 1,
10 	NOUVEAU_THERM_CTRL_AUTO = 2,
11 };
12 
13 enum nouveau_therm_attr_type {
14 	NOUVEAU_THERM_ATTR_FAN_MIN_DUTY = 0,
15 	NOUVEAU_THERM_ATTR_FAN_MAX_DUTY = 1,
16 	NOUVEAU_THERM_ATTR_FAN_MODE = 2,
17 
18 	NOUVEAU_THERM_ATTR_THRS_FAN_BOOST = 10,
19 	NOUVEAU_THERM_ATTR_THRS_FAN_BOOST_HYST = 11,
20 	NOUVEAU_THERM_ATTR_THRS_DOWN_CLK = 12,
21 	NOUVEAU_THERM_ATTR_THRS_DOWN_CLK_HYST = 13,
22 	NOUVEAU_THERM_ATTR_THRS_CRITICAL = 14,
23 	NOUVEAU_THERM_ATTR_THRS_CRITICAL_HYST = 15,
24 	NOUVEAU_THERM_ATTR_THRS_SHUTDOWN = 16,
25 	NOUVEAU_THERM_ATTR_THRS_SHUTDOWN_HYST = 17,
26 };
27 
28 struct nouveau_therm {
29 	struct nouveau_subdev base;
30 
31 	int (*pwm_ctrl)(struct nouveau_therm *, int line, bool);
32 	int (*pwm_get)(struct nouveau_therm *, int line, u32 *, u32 *);
33 	int (*pwm_set)(struct nouveau_therm *, int line, u32, u32);
34 	int (*pwm_clock)(struct nouveau_therm *, int line);
35 
36 	int (*fan_get)(struct nouveau_therm *);
37 	int (*fan_set)(struct nouveau_therm *, int);
38 	int (*fan_sense)(struct nouveau_therm *);
39 
40 	int (*temp_get)(struct nouveau_therm *);
41 
42 	int (*attr_get)(struct nouveau_therm *, enum nouveau_therm_attr_type);
43 	int (*attr_set)(struct nouveau_therm *,
44 			enum nouveau_therm_attr_type, int);
45 };
46 
47 static inline struct nouveau_therm *
48 nouveau_therm(void *obj)
49 {
50 	return (void *)nouveau_subdev(obj, NVDEV_SUBDEV_THERM);
51 }
52 
53 #define nouveau_therm_create(p,e,o,d)                                          \
54 	nouveau_therm_create_((p), (e), (o), sizeof(**d), (void **)d)
55 #define nouveau_therm_destroy(p) ({                                            \
56 	struct nouveau_therm *therm = (p);                                     \
57         _nouveau_therm_dtor(nv_object(therm));                                 \
58 })
59 #define nouveau_therm_init(p) ({                                               \
60 	struct nouveau_therm *therm = (p);                                     \
61         _nouveau_therm_init(nv_object(therm));                                 \
62 })
63 #define nouveau_therm_fini(p,s) ({                                             \
64 	struct nouveau_therm *therm = (p);                                     \
65         _nouveau_therm_init(nv_object(therm), (s));                            \
66 })
67 
68 int  nouveau_therm_create_(struct nouveau_object *, struct nouveau_object *,
69 			   struct nouveau_oclass *, int, void **);
70 void _nouveau_therm_dtor(struct nouveau_object *);
71 int  _nouveau_therm_init(struct nouveau_object *);
72 int  _nouveau_therm_fini(struct nouveau_object *, bool);
73 
74 int  nouveau_therm_cstate(struct nouveau_therm *, int, int);
75 
76 extern struct nouveau_oclass nv40_therm_oclass;
77 extern struct nouveau_oclass nv50_therm_oclass;
78 extern struct nouveau_oclass nv84_therm_oclass;
79 extern struct nouveau_oclass nva3_therm_oclass;
80 extern struct nouveau_oclass nvd0_therm_oclass;
81 extern struct nouveau_oclass gm107_therm_oclass;
82 
83 #endif
84