remove libdss from Makefile
[GitHub/moto-9609/android_kernel_motorola_exynos9610.git] / include / linux / thermal.h
CommitLineData
203d3d4a
ZR
1/*
2 * thermal.h ($Revision: 0 $)
3 *
4 * Copyright (C) 2008 Intel Corp
5 * Copyright (C) 2008 Zhang Rui <rui.zhang@intel.com>
6 * Copyright (C) 2008 Sujith Thomas <sujith.thomas@intel.com>
7 *
8 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; version 2 of the License.
12 *
13 * This program is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License along
19 * with this program; if not, write to the Free Software Foundation, Inc.,
20 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
21 *
22 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
23 */
24
25#ifndef __THERMAL_H__
26#define __THERMAL_H__
27
a116b5d4 28#include <linux/of.h>
203d3d4a
ZR
29#include <linux/idr.h>
30#include <linux/device.h>
4d0fe749 31#include <linux/sysfs.h>
b1569e99 32#include <linux/workqueue.h>
af6c9f16 33#include <uapi/linux/thermal.h>
203d3d4a 34
23064088
D
35#define THERMAL_TRIPS_NONE -1
36#define THERMAL_MAX_TRIPS 12
23064088 37
57df8106
ZR
38/* invalid cooling state */
39#define THERMAL_CSTATE_INVALID -1UL
40
bd799f71
SK
41/* invalid cooling frequency */
42#define THERMAL_CFREQ_INVALID -1
43
23064088 44/* No upper/lower limit requirement */
a940cb34 45#define THERMAL_NO_LIMIT ((u32)~0)
23064088 46
6cd9e9f6
KS
47/* Default weight of a bound cooling device */
48#define THERMAL_WEIGHT_DEFAULT 0
49
bb431ba2
ZR
50/* use value, which < 0K, to indicate an invalid/uninitialized temperature */
51#define THERMAL_TEMP_INVALID -274000
52
23064088 53/* Unit conversion macros */
e866a2e3
RV
54#define DECI_KELVIN_TO_CELSIUS(t) ({ \
55 long _t = (t); \
56 ((_t-2732 >= 0) ? (_t-2732+5)/10 : (_t-2732-5)/10); \
57})
58#define CELSIUS_TO_DECI_KELVIN(t) ((t)*10+2732)
7b83fd9d
AL
59#define DECI_KELVIN_TO_MILLICELSIUS_WITH_OFFSET(t, off) (((t) - (off)) * 100)
60#define DECI_KELVIN_TO_MILLICELSIUS(t) DECI_KELVIN_TO_MILLICELSIUS_WITH_OFFSET(t, 2732)
77e337c6
AL
61#define MILLICELSIUS_TO_DECI_KELVIN_WITH_OFFSET(t, off) (((t) / 100) + (off))
62#define MILLICELSIUS_TO_DECI_KELVIN(t) MILLICELSIUS_TO_DECI_KELVIN_WITH_OFFSET(t, 2732)
23064088 63
1f53ef17
ZR
64/* Default Thermal Governor */
65#if defined(CONFIG_THERMAL_DEFAULT_GOV_STEP_WISE)
66#define DEFAULT_THERMAL_GOVERNOR "step_wise"
67#elif defined(CONFIG_THERMAL_DEFAULT_GOV_FAIR_SHARE)
68#define DEFAULT_THERMAL_GOVERNOR "fair_share"
69#elif defined(CONFIG_THERMAL_DEFAULT_GOV_USER_SPACE)
70#define DEFAULT_THERMAL_GOVERNOR "user_space"
6b775e87
JM
71#elif defined(CONFIG_THERMAL_DEFAULT_GOV_POWER_ALLOCATOR)
72#define DEFAULT_THERMAL_GOVERNOR "power_allocator"
1f53ef17 73#endif
a4a15485 74
203d3d4a
ZR
75struct thermal_zone_device;
76struct thermal_cooling_device;
35b11d2e 77struct thermal_instance;
203d3d4a 78
6503e5df
MG
79enum thermal_device_mode {
80 THERMAL_DEVICE_DISABLED = 0,
81 THERMAL_DEVICE_ENABLED,
82};
83
84enum thermal_trip_type {
85 THERMAL_TRIP_ACTIVE = 0,
86 THERMAL_TRIP_PASSIVE,
87 THERMAL_TRIP_HOT,
88 THERMAL_TRIP_CRITICAL,
89};
90
601f3d42
ZR
91enum thermal_trend {
92 THERMAL_TREND_STABLE, /* temperature is stable */
93 THERMAL_TREND_RAISING, /* temperature is raising */
94 THERMAL_TREND_DROPPING, /* temperature is dropping */
d069015e
ZR
95 THERMAL_TREND_RAISE_FULL, /* apply highest cooling action */
96 THERMAL_TREND_DROP_FULL, /* apply lowest cooling action */
601f3d42
ZR
97};
98
0e70f466
SP
99/* Thermal notification reason */
100enum thermal_notify_event {
101 THERMAL_EVENT_UNSPECIFIED, /* Unspecified event */
102 THERMAL_EVENT_TEMP_SAMPLE, /* New Temperature sample */
103 THERMAL_TRIP_VIOLATED, /* TRIP Point violation */
104 THERMAL_TRIP_CHANGED, /* TRIP Point temperature changed */
105 THERMAL_DEVICE_DOWN, /* Thermal device is down */
106 THERMAL_DEVICE_UP, /* Thermal device is up after a down event */
107 THERMAL_DEVICE_POWER_CAPABILITY_CHANGED, /* power capability changed */
38e44da5 108 THERMAL_TABLE_CHANGED, /* Thermal table(s) changed */
0e70f466
SP
109};
110
203d3d4a
ZR
111struct thermal_zone_device_ops {
112 int (*bind) (struct thermal_zone_device *,
113 struct thermal_cooling_device *);
114 int (*unbind) (struct thermal_zone_device *,
115 struct thermal_cooling_device *);
17e8351a 116 int (*get_temp) (struct thermal_zone_device *, int *);
060c034a 117 int (*set_trips) (struct thermal_zone_device *, int, int);
6503e5df
MG
118 int (*get_mode) (struct thermal_zone_device *,
119 enum thermal_device_mode *);
120 int (*set_mode) (struct thermal_zone_device *,
121 enum thermal_device_mode);
122 int (*get_trip_type) (struct thermal_zone_device *, int,
123 enum thermal_trip_type *);
17e8351a
SH
124 int (*get_trip_temp) (struct thermal_zone_device *, int, int *);
125 int (*set_trip_temp) (struct thermal_zone_device *, int, int);
126 int (*get_trip_hyst) (struct thermal_zone_device *, int, int *);
127 int (*set_trip_hyst) (struct thermal_zone_device *, int, int);
128 int (*get_crit_temp) (struct thermal_zone_device *, int *);
129 int (*set_emul_temp) (struct thermal_zone_device *, int);
601f3d42
ZR
130 int (*get_trend) (struct thermal_zone_device *, int,
131 enum thermal_trend *);
b1569e99
MG
132 int (*notify) (struct thermal_zone_device *, int,
133 enum thermal_trip_type);
967f5408 134 int (*throttle_hotplug) (struct thermal_zone_device *);
203d3d4a
ZR
135};
136
137struct thermal_cooling_device_ops {
6503e5df
MG
138 int (*get_max_state) (struct thermal_cooling_device *, unsigned long *);
139 int (*get_cur_state) (struct thermal_cooling_device *, unsigned long *);
140 int (*set_cur_state) (struct thermal_cooling_device *, unsigned long);
35b11d2e
JM
141 int (*get_requested_power)(struct thermal_cooling_device *,
142 struct thermal_zone_device *, u32 *);
143 int (*state2power)(struct thermal_cooling_device *,
144 struct thermal_zone_device *, unsigned long, u32 *);
145 int (*power2state)(struct thermal_cooling_device *,
146 struct thermal_zone_device *, u32, unsigned long *);
dba1d356
HG
147 int (*set_cur_temp)(struct thermal_cooling_device *, bool, int);
148 int (*get_cooling_level)(struct thermal_cooling_device *, unsigned long);
203d3d4a
ZR
149};
150
203d3d4a
ZR
151struct thermal_cooling_device {
152 int id;
153 char type[THERMAL_NAME_LENGTH];
154 struct device device;
4e5e4705 155 struct device_node *np;
203d3d4a 156 void *devdata;
5b275ce2 157 const struct thermal_cooling_device_ops *ops;
ce119f83 158 bool updated; /* true if the cooling device does not need update */
f4a821ce 159 struct mutex lock; /* protect thermal_instances list */
b5e4ae62 160 struct list_head thermal_instances;
203d3d4a
ZR
161 struct list_head node;
162};
163
c56f5c03
D
164struct thermal_attr {
165 struct device_attribute attr;
166 char name[THERMAL_NAME_LENGTH];
167};
168
c708a98f
JM
169/**
170 * struct thermal_zone_device - structure for a thermal zone
171 * @id: unique id number for each thermal zone
172 * @type: the thermal zone device type
173 * @device: &struct device for this thermal zone
174 * @trip_temp_attrs: attributes for trip points for sysfs: trip temperature
175 * @trip_type_attrs: attributes for trip points for sysfs: trip type
176 * @trip_hyst_attrs: attributes for trip points for sysfs: trip hysteresis
177 * @devdata: private pointer for device private data
178 * @trips: number of trip points the thermal zone supports
81ad4276 179 * @trips_disabled; bitmap for disabled trips
c708a98f 180 * @passive_delay: number of milliseconds to wait between polls when
6b775e87 181 * performing passive cooling.
c708a98f
JM
182 * @polling_delay: number of milliseconds to wait between polls when
183 * checking whether trip points have been crossed (0 for
184 * interrupt driven systems)
185 * @temperature: current temperature. This is only for core code,
186 * drivers should use thermal_zone_get_temp() to get the
187 * current temperature
188 * @last_temperature: previous temperature read
189 * @emul_temperature: emulated temperature when using CONFIG_THERMAL_EMULATION
190 * @passive: 1 if you've crossed a passive trip point, 0 otherwise.
060c034a
SH
191 * @prev_low_trip: the low current temperature if you've crossed a passive
192 trip point.
193 * @prev_high_trip: the above current temperature if you've crossed a
194 passive trip point.
c708a98f
JM
195 * @forced_passive: If > 0, temperature at which to switch on all ACPI
196 * processor cooling devices. Currently only used by the
197 * step-wise governor.
4511f716 198 * @need_update: if equals 1, thermal_zone_device_update needs to be invoked.
c708a98f
JM
199 * @ops: operations this &thermal_zone_device supports
200 * @tzp: thermal zone parameters
201 * @governor: pointer to the governor for this thermal zone
e33df1d2 202 * @governor_data: private pointer for governor data
c708a98f 203 * @thermal_instances: list of &struct thermal_instance of this thermal zone
b31ef828 204 * @ida: &struct ida to generate unique id for this zone's cooling
c708a98f
JM
205 * devices
206 * @lock: lock to protect thermal_instances list
207 * @node: node in thermal_tz_list (in thermal_core.c)
208 * @poll_queue: delayed work for polling
0e70f466 209 * @notify_event: Last notification event
91a5669d 210 * @cdev_bound: cooling device bind done
c708a98f 211 */
203d3d4a
ZR
212struct thermal_zone_device {
213 int id;
214 char type[THERMAL_NAME_LENGTH];
215 struct device device;
4d0fe749 216 struct attribute_group trips_attribute_group;
c56f5c03
D
217 struct thermal_attr *trip_temp_attrs;
218 struct thermal_attr *trip_type_attrs;
27365a6c 219 struct thermal_attr *trip_hyst_attrs;
203d3d4a
ZR
220 void *devdata;
221 int trips;
81ad4276 222 unsigned long trips_disabled; /* bitmap for disabled trips */
b1569e99
MG
223 int passive_delay;
224 int polling_delay;
601f3d42 225 int temperature;
b1569e99 226 int last_temperature;
e6e238c3 227 int emul_temperature;
908b9fb7 228 int passive;
060c034a
SH
229 int prev_low_trip;
230 int prev_high_trip;
03a971a2 231 unsigned int forced_passive;
4511f716 232 atomic_t need_update;
4e5e4705 233 struct thermal_zone_device_ops *ops;
6b775e87 234 struct thermal_zone_params *tzp;
a4a15485 235 struct thermal_governor *governor;
e33df1d2 236 void *governor_data;
2d374139 237 struct list_head thermal_instances;
b31ef828 238 struct ida ida;
c708a98f 239 struct mutex lock;
203d3d4a 240 struct list_head node;
b1569e99 241 struct delayed_work poll_queue;
0e70f466 242 enum thermal_notify_event notify_event;
91a5669d 243 bool cdev_bound;
203d3d4a 244};
4cb18728 245
c708a98f
JM
246/**
247 * struct thermal_governor - structure that holds thermal governor information
248 * @name: name of the governor
e33df1d2
JM
249 * @bind_to_tz: callback called when binding to a thermal zone. If it
250 * returns 0, the governor is bound to the thermal zone,
251 * otherwise it fails.
252 * @unbind_from_tz: callback called when a governor is unbound from a
253 * thermal zone.
c708a98f
JM
254 * @throttle: callback called for every trip point even if temperature is
255 * below the trip point temperature
256 * @governor_list: node in thermal_governor_list (in thermal_core.c)
257 */
a4a15485
D
258struct thermal_governor {
259 char name[THERMAL_NAME_LENGTH];
e33df1d2
JM
260 int (*bind_to_tz)(struct thermal_zone_device *tz);
261 void (*unbind_from_tz)(struct thermal_zone_device *tz);
a4a15485
D
262 int (*throttle)(struct thermal_zone_device *tz, int trip);
263 struct list_head governor_list;
a4a15485
D
264};
265
ef873947
D
266/* Structure that holds binding parameters for a zone */
267struct thermal_bind_params {
268 struct thermal_cooling_device *cdev;
269
270 /*
271 * This is a measure of 'how effectively these devices can
bcdcbbc7
JM
272 * cool 'this' thermal zone. It shall be determined by
273 * platform characterization. This value is relative to the
274 * rest of the weights so a cooling device whose weight is
275 * double that of another cooling device is twice as
276 * effective. See Documentation/thermal/sysfs-api.txt for more
277 * information.
ef873947
D
278 */
279 int weight;
280
281 /*
282 * This is a bit mask that gives the binding relation between this
283 * thermal zone and cdev, for a particular trip point.
284 * See Documentation/thermal/sysfs-api.txt for more information.
285 */
286 int trip_mask;
a8892d83
EV
287
288 /*
289 * This is an array of cooling state limits. Must have exactly
290 * 2 * thermal_zone.number_of_trip_points. It is an array consisting
291 * of tuples <lower-state upper-state> of state limits. Each trip
292 * will be associated with one state limit tuple when binding.
293 * A NULL pointer means <THERMAL_NO_LIMITS THERMAL_NO_LIMITS>
294 * on all trips.
295 */
296 unsigned long *binding_limits;
ef873947
D
297 int (*match) (struct thermal_zone_device *tz,
298 struct thermal_cooling_device *cdev);
299};
300
301/* Structure to define Thermal Zone parameters */
302struct thermal_zone_params {
a4a15485 303 char governor_name[THERMAL_NAME_LENGTH];
ccba4ffd
EV
304
305 /*
306 * a boolean to indicate if the thermal to hwmon sysfs interface
307 * is required. when no_hwmon == false, a hwmon sysfs interface
308 * will be created. when no_hwmon == true, nothing will be done
309 */
310 bool no_hwmon;
311
ef873947
D
312 int num_tbps; /* Number of tbp entries */
313 struct thermal_bind_params *tbp;
6b775e87
JM
314
315 /*
316 * Sustainable power (heat) that this thermal zone can dissipate in
317 * mW
318 */
319 u32 sustainable_power;
320
321 /*
322 * Proportional parameter of the PID controller when
323 * overshooting (i.e., when temperature is below the target)
324 */
325 s32 k_po;
326
327 /*
328 * Proportional parameter of the PID controller when
329 * undershooting
330 */
331 s32 k_pu;
332
333 /* Integral parameter of the PID controller */
334 s32 k_i;
335
336 /* Derivative parameter of the PID controller */
337 s32 k_d;
338
339 /* threshold below which the error is no longer accumulated */
340 s32 integral_cutoff;
9d0be7f4 341
c7e3357c
HG
342 s32 integral_max;
343
9d0be7f4
EV
344 /*
345 * @slope: slope of a linear temperature adjustment curve.
346 * Used by thermal zone drivers.
347 */
348 int slope;
349 /*
350 * @offset: offset of a linear temperature adjustment curve.
351 * Used by thermal zone drivers (default 0).
352 */
353 int offset;
ef873947
D
354};
355
4cb18728
D
356struct thermal_genl_event {
357 u32 orig;
358 enum events event;
359};
203d3d4a 360
2251aef6
EV
361/**
362 * struct thermal_zone_of_device_ops - scallbacks for handling DT based zones
363 *
364 * Mandatory:
365 * @get_temp: a pointer to a function that reads the sensor temperature.
366 *
367 * Optional:
368 * @get_trend: a pointer to a function that reads the sensor temperature trend.
826386e7
SH
369 * @set_trips: a pointer to a function that sets a temperature window. When
370 * this window is left the driver must inform the thermal core via
371 * thermal_zone_device_update.
184a4bf6
LM
372 * @set_emul_temp: a pointer to a function that sets sensor emulated
373 * temperature.
5a5e78cd
CW
374 * @set_trip_temp: a pointer to a function that sets the trip temperature on
375 * hardware.
2251aef6
EV
376 */
377struct thermal_zone_of_device_ops {
17e8351a 378 int (*get_temp)(void *, int *);
e78eaf45 379 int (*get_trend)(void *, int, enum thermal_trend *);
826386e7 380 int (*set_trips)(void *, int, int);
17e8351a 381 int (*set_emul_temp)(void *, int);
c3509521 382 int (*set_trip_temp)(void *, int, int);
967f5408 383 int (*throttle_cpu_hotplug)(void *, int temp);
2251aef6
EV
384};
385
ad9914ac
LM
386/**
387 * struct thermal_trip - representation of a point in temperature domain
388 * @np: pointer to struct device_node that this trip point was created from
389 * @temperature: temperature value in miliCelsius
390 * @hysteresis: relative hysteresis in miliCelsius
391 * @type: trip point type
392 */
393
394struct thermal_trip {
395 struct device_node *np;
1d0fd42f
WN
396 int temperature;
397 int hysteresis;
ad9914ac
LM
398 enum thermal_trip_type type;
399};
400
3d8d72c3
HG
401/*** Private data structures to represent thermal device tree data ***/
402
403/**
404 * struct __thermal_bind_param - a match between trip and cooling device
405 * @cooling_device: a pointer to identify the referred cooling device
406 * @trip_id: the trip point index
407 * @usage: the percentage (from 0 to 100) of cooling contribution
408 * @min: minimum cooling state used at this trip point
409 * @max: maximum cooling state used at this trip point
dba1d356 410 * @value: cooling value corresponding to max state
3d8d72c3
HG
411 */
412
413struct __thermal_bind_params {
414 struct device_node *cooling_device;
415 unsigned int trip_id;
416 unsigned int usage;
417 unsigned long min;
418 unsigned long max;
dba1d356 419 unsigned long value;
3d8d72c3
HG
420};
421
422/**
423 * struct __thermal_zone - internal representation of a thermal zone
424 * @mode: current thermal zone device mode (enabled/disabled)
425 * @passive_delay: polling interval while passive cooling is activated
426 * @polling_delay: zone polling interval
427 * @slope: slope of the temperature adjustment curve
428 * @offset: offset of the temperature adjustment curve
429 * @ntrips: number of trip points
430 * @trips: an array of trip points (0..ntrips - 1)
431 * @num_tbps: number of thermal bind params
432 * @tbps: an array of thermal bind params (0..num_tbps - 1)
433 * @sensor_data: sensor private data used while reading temperature and trend
434 * @ops: set of callbacks to handle the thermal zone based on DT
435 */
436
437struct __thermal_zone {
438 enum thermal_device_mode mode;
439 int passive_delay;
440 int polling_delay;
441 int slope;
442 int offset;
443
444 /* trip data */
445 int ntrips;
446 struct thermal_trip *trips;
447
448 /* cooling binding data */
449 int num_tbps;
450 struct __thermal_bind_params *tbps;
451
452 /* sensor interface */
453 void *sensor_data;
454 const struct thermal_zone_of_device_ops *ops;
455};
456
23064088 457/* Function declarations */
4e5e4705
EV
458#ifdef CONFIG_THERMAL_OF
459struct thermal_zone_device *
2251aef6
EV
460thermal_zone_of_sensor_register(struct device *dev, int id, void *data,
461 const struct thermal_zone_of_device_ops *ops);
4e5e4705
EV
462void thermal_zone_of_sensor_unregister(struct device *dev,
463 struct thermal_zone_device *tz);
e498b498
LD
464struct thermal_zone_device *devm_thermal_zone_of_sensor_register(
465 struct device *dev, int id, void *data,
466 const struct thermal_zone_of_device_ops *ops);
467void devm_thermal_zone_of_sensor_unregister(struct device *dev,
468 struct thermal_zone_device *tz);
4e5e4705
EV
469#else
470static inline struct thermal_zone_device *
2251aef6
EV
471thermal_zone_of_sensor_register(struct device *dev, int id, void *data,
472 const struct thermal_zone_of_device_ops *ops)
4e5e4705 473{
cd33dc9a 474 return ERR_PTR(-ENODEV);
4e5e4705
EV
475}
476
477static inline
478void thermal_zone_of_sensor_unregister(struct device *dev,
479 struct thermal_zone_device *tz)
480{
481}
482
e498b498
LD
483static inline struct thermal_zone_device *devm_thermal_zone_of_sensor_register(
484 struct device *dev, int id, void *data,
485 const struct thermal_zone_of_device_ops *ops)
486{
487 return ERR_PTR(-ENODEV);
488}
489
490static inline
491void devm_thermal_zone_of_sensor_unregister(struct device *dev,
492 struct thermal_zone_device *tz)
493{
494}
495
4e5e4705 496#endif
12ca7188
NM
497
498#if IS_ENABLED(CONFIG_THERMAL)
35b11d2e
JM
499static inline bool cdev_is_power_actor(struct thermal_cooling_device *cdev)
500{
501 return cdev->ops->get_requested_power && cdev->ops->state2power &&
502 cdev->ops->power2state;
503}
504
505int power_actor_get_max_power(struct thermal_cooling_device *,
506 struct thermal_zone_device *tz, u32 *max_power);
c973c3bc
JM
507int power_actor_get_min_power(struct thermal_cooling_device *,
508 struct thermal_zone_device *tz, u32 *min_power);
35b11d2e
JM
509int power_actor_set_power(struct thermal_cooling_device *,
510 struct thermal_instance *, u32);
4b1bf587 511struct thermal_zone_device *thermal_zone_device_register(const char *, int, int,
4e5e4705 512 void *, struct thermal_zone_device_ops *,
6b775e87 513 struct thermal_zone_params *, int, int);
203d3d4a
ZR
514void thermal_zone_device_unregister(struct thermal_zone_device *);
515
516int thermal_zone_bind_cooling_device(struct thermal_zone_device *, int,
9d99842f 517 struct thermal_cooling_device *,
6cd9e9f6
KS
518 unsigned long, unsigned long,
519 unsigned int);
203d3d4a
ZR
520int thermal_zone_unbind_cooling_device(struct thermal_zone_device *, int,
521 struct thermal_cooling_device *);
0e70f466
SP
522void thermal_zone_device_update(struct thermal_zone_device *,
523 enum thermal_notify_event);
060c034a 524void thermal_zone_set_trips(struct thermal_zone_device *);
23064088 525
203d3d4a 526struct thermal_cooling_device *thermal_cooling_device_register(char *, void *,
5b275ce2 527 const struct thermal_cooling_device_ops *);
a116b5d4
EV
528struct thermal_cooling_device *
529thermal_of_cooling_device_register(struct device_node *np, char *, void *,
530 const struct thermal_cooling_device_ops *);
203d3d4a 531void thermal_cooling_device_unregister(struct thermal_cooling_device *);
63c4d919 532struct thermal_zone_device *thermal_zone_get_zone_by_name(const char *name);
3e36d67e 533struct thermal_zone_device *thermal_zone_get_zone_by_cool_np(struct device_node *cool_np);
17e8351a 534int thermal_zone_get_temp(struct thermal_zone_device *tz, int *temp);
4a7069a3
RN
535int thermal_zone_get_slope(struct thermal_zone_device *tz);
536int thermal_zone_get_offset(struct thermal_zone_device *tz);
af06216a 537
9b4298a0
D
538int get_tz_trend(struct thermal_zone_device *, int);
539struct thermal_instance *get_thermal_instance(struct thermal_zone_device *,
540 struct thermal_cooling_device *, int);
dc765482 541void thermal_cdev_update(struct thermal_cooling_device *);
7b73c993 542void thermal_notify_framework(struct thermal_zone_device *, int);
12ca7188 543#else
35b11d2e
JM
544static inline bool cdev_is_power_actor(struct thermal_cooling_device *cdev)
545{ return false; }
546static inline int power_actor_get_max_power(struct thermal_cooling_device *cdev,
547 struct thermal_zone_device *tz, u32 *max_power)
548{ return 0; }
c973c3bc
JM
549static inline int power_actor_get_min_power(struct thermal_cooling_device *cdev,
550 struct thermal_zone_device *tz,
551 u32 *min_power)
552{ return -ENODEV; }
35b11d2e
JM
553static inline int power_actor_set_power(struct thermal_cooling_device *cdev,
554 struct thermal_instance *tz, u32 power)
555{ return 0; }
12ca7188
NM
556static inline struct thermal_zone_device *thermal_zone_device_register(
557 const char *type, int trips, int mask, void *devdata,
558 struct thermal_zone_device_ops *ops,
559 const struct thermal_zone_params *tzp,
560 int passive_delay, int polling_delay)
561{ return ERR_PTR(-ENODEV); }
562static inline void thermal_zone_device_unregister(
563 struct thermal_zone_device *tz)
564{ }
565static inline int thermal_zone_bind_cooling_device(
566 struct thermal_zone_device *tz, int trip,
567 struct thermal_cooling_device *cdev,
c86b3de8
AB
568 unsigned long upper, unsigned long lower,
569 unsigned int weight)
12ca7188
NM
570{ return -ENODEV; }
571static inline int thermal_zone_unbind_cooling_device(
572 struct thermal_zone_device *tz, int trip,
573 struct thermal_cooling_device *cdev)
574{ return -ENODEV; }
0e70f466
SP
575static inline void thermal_zone_device_update(struct thermal_zone_device *tz,
576 enum thermal_notify_event event)
12ca7188 577{ }
060c034a
SH
578static inline void thermal_zone_set_trips(struct thermal_zone_device *tz)
579{ }
12ca7188
NM
580static inline struct thermal_cooling_device *
581thermal_cooling_device_register(char *type, void *devdata,
582 const struct thermal_cooling_device_ops *ops)
583{ return ERR_PTR(-ENODEV); }
584static inline struct thermal_cooling_device *
585thermal_of_cooling_device_register(struct device_node *np,
586 char *type, void *devdata, const struct thermal_cooling_device_ops *ops)
587{ return ERR_PTR(-ENODEV); }
588static inline void thermal_cooling_device_unregister(
589 struct thermal_cooling_device *cdev)
590{ }
591static inline struct thermal_zone_device *thermal_zone_get_zone_by_name(
592 const char *name)
593{ return ERR_PTR(-ENODEV); }
3e36d67e
HG
594static inline struct thermal_zone_device *thermal_zone_get_zone_by_cool_np(
595 struct device_node *cool_np)
596{ return ERR_PTR(-ENODEV); }
12ca7188 597static inline int thermal_zone_get_temp(
17e8351a 598 struct thermal_zone_device *tz, int *temp)
12ca7188 599{ return -ENODEV; }
4a7069a3
RN
600static inline int thermal_zone_get_slope(
601 struct thermal_zone_device *tz)
602{ return -ENODEV; }
603static inline int thermal_zone_get_offset(
604 struct thermal_zone_device *tz)
605{ return -ENODEV; }
12ca7188
NM
606static inline int get_tz_trend(struct thermal_zone_device *tz, int trip)
607{ return -ENODEV; }
608static inline struct thermal_instance *
609get_thermal_instance(struct thermal_zone_device *tz,
610 struct thermal_cooling_device *cdev, int trip)
611{ return ERR_PTR(-ENODEV); }
612static inline void thermal_cdev_update(struct thermal_cooling_device *cdev)
613{ }
614static inline void thermal_notify_framework(struct thermal_zone_device *tz,
615 int trip)
616{ }
617#endif /* CONFIG_THERMAL */
618
619#if defined(CONFIG_NET) && IS_ENABLED(CONFIG_THERMAL)
8ab3e6a0
EV
620extern int thermal_generate_netlink_event(struct thermal_zone_device *tz,
621 enum events event);
af06216a 622#else
f8b58705 623static inline int thermal_generate_netlink_event(struct thermal_zone_device *tz,
8ab3e6a0 624 enum events event)
af06216a
RW
625{
626 return 0;
627}
628#endif
203d3d4a 629
a0dd25b2 630#endif /* __THERMAL_H__ */