1 #ifndef __NVTHERM_PRIV_H__
2 #define __NVTHERM_PRIV_H__
5 * Copyright 2012 The Nouveau community
7 * Permission is hereby granted, free of charge, to any person obtaining a
8 * copy of this software and associated documentation files (the "Software"),
9 * to deal in the Software without restriction, including without limitation
10 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
11 * and/or sell copies of the Software, and to permit persons to whom the
12 * Software is furnished to do so, subject to the following conditions:
14 * The above copyright notice and this permission notice shall be included in
15 * all copies or substantial portions of the Software.
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
21 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
22 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
23 * OTHER DEALINGS IN THE SOFTWARE.
25 * Authors: Martin Peres
28 #include <subdev/therm.h>
30 #include <subdev/bios/extdev.h>
31 #include <subdev/bios/gpio.h>
32 #include <subdev/bios/perf.h>
33 #include <subdev/bios/therm.h>
34 #include <subdev/timer.h>
37 struct nouveau_therm *parent;
40 struct nvbios_therm_fan bios;
41 struct nvbios_perf_fan perf;
43 struct nouveau_alarm alarm;
47 int (*get)(struct nouveau_therm *therm);
48 int (*set)(struct nouveau_therm *therm, int percent);
50 struct dcb_gpio_func tach;
53 enum nouveau_therm_thrs_direction {
54 NOUVEAU_THERM_THRS_FALLING = 0,
55 NOUVEAU_THERM_THRS_RISING = 1
58 enum nouveau_therm_thrs_state {
59 NOUVEAU_THERM_THRS_LOWER = 0,
60 NOUVEAU_THERM_THRS_HIGHER = 1
63 enum nouveau_therm_thrs {
64 NOUVEAU_THERM_THRS_FANBOOST = 0,
65 NOUVEAU_THERM_THRS_DOWNCLOCK = 1,
66 NOUVEAU_THERM_THRS_CRITICAL = 2,
67 NOUVEAU_THERM_THRS_SHUTDOWN = 3,
71 struct nouveau_therm_priv {
72 struct nouveau_therm base;
74 /* automatic thermal management */
75 struct nouveau_alarm alarm;
77 struct nouveau_therm_trip_point *last_trip;
83 struct nvbios_therm_sensor bios_sensor;
86 struct nouveau_fan *fan;
90 spinlock_t alarm_program_lock;
91 struct nouveau_alarm therm_poll_alarm;
92 enum nouveau_therm_thrs_state alarm_state[NOUVEAU_THERM_THRS_NR];
93 void (*program_alarms)(struct nouveau_therm *);
96 /* what should be done if the card overheats */
98 void (*downclock)(struct nouveau_therm *, bool active);
99 void (*pause)(struct nouveau_therm *, bool active);
103 struct i2c_client *ic;
106 int nouveau_therm_fan_mode(struct nouveau_therm *therm, int mode);
107 int nouveau_therm_attr_get(struct nouveau_therm *therm,
108 enum nouveau_therm_attr_type type);
109 int nouveau_therm_attr_set(struct nouveau_therm *therm,
110 enum nouveau_therm_attr_type type, int value);
112 void nouveau_therm_ic_ctor(struct nouveau_therm *therm);
114 int nouveau_therm_sensor_ctor(struct nouveau_therm *therm);
116 int nouveau_therm_fan_ctor(struct nouveau_therm *therm);
117 int nouveau_therm_fan_init(struct nouveau_therm *therm);
118 int nouveau_therm_fan_fini(struct nouveau_therm *therm, bool suspend);
119 int nouveau_therm_fan_get(struct nouveau_therm *therm);
120 int nouveau_therm_fan_set(struct nouveau_therm *therm, bool now, int percent);
121 int nouveau_therm_fan_user_get(struct nouveau_therm *therm);
122 int nouveau_therm_fan_user_set(struct nouveau_therm *therm, int percent);
124 int nouveau_therm_fan_sense(struct nouveau_therm *therm);
126 int nouveau_therm_preinit(struct nouveau_therm *);
128 int nouveau_therm_sensor_init(struct nouveau_therm *therm);
129 int nouveau_therm_sensor_fini(struct nouveau_therm *therm, bool suspend);
130 void nouveau_therm_sensor_preinit(struct nouveau_therm *);
131 void nouveau_therm_sensor_set_threshold_state(struct nouveau_therm *therm,
132 enum nouveau_therm_thrs thrs,
133 enum nouveau_therm_thrs_state st);
134 enum nouveau_therm_thrs_state
135 nouveau_therm_sensor_get_threshold_state(struct nouveau_therm *therm,
136 enum nouveau_therm_thrs thrs);
137 void nouveau_therm_sensor_event(struct nouveau_therm *therm,
138 enum nouveau_therm_thrs thrs,
139 enum nouveau_therm_thrs_direction dir);
140 void nouveau_therm_program_alarms_polling(struct nouveau_therm *therm);
142 void nv40_therm_intr(struct nouveau_subdev *);
143 int nv50_fan_pwm_ctrl(struct nouveau_therm *, int, bool);
144 int nv50_fan_pwm_get(struct nouveau_therm *, int, u32 *, u32 *);
145 int nv50_fan_pwm_set(struct nouveau_therm *, int, u32, u32);
146 int nv50_fan_pwm_clock(struct nouveau_therm *, int);
147 int nv84_temp_get(struct nouveau_therm *therm);
148 int nv84_therm_fini(struct nouveau_object *object, bool suspend);
150 int nva3_therm_fan_sense(struct nouveau_therm *);
152 int nvd0_therm_init(struct nouveau_object *object);
154 int nouveau_fanpwm_create(struct nouveau_therm *, struct dcb_gpio_func *);
155 int nouveau_fantog_create(struct nouveau_therm *, struct dcb_gpio_func *);
156 int nouveau_fannil_create(struct nouveau_therm *);