blob: 5e093602e8fcd51a67664fe42eea31024e646025 [file] [log] [blame]
Lina Iyer7e3c0382018-05-07 11:52:29 -06001/* SPDX-License-Identifier: GPL-2.0 */
Zhang Rui203d3d42008-01-17 15:51:08 +08002/*
3 * thermal.h ($Revision: 0 $)
4 *
5 * Copyright (C) 2008 Intel Corp
6 * Copyright (C) 2008 Zhang Rui <[email protected]>
7 * Copyright (C) 2008 Sujith Thomas <[email protected]>
Zhang Rui203d3d42008-01-17 15:51:08 +08008 */
9
10#ifndef __THERMAL_H__
11#define __THERMAL_H__
12
Eduardo Valentina116b5d2013-09-26 15:55:01 -040013#include <linux/of.h>
Zhang Rui203d3d42008-01-17 15:51:08 +080014#include <linux/idr.h>
15#include <linux/device.h>
Eduardo Valentin4d0fe742016-11-07 21:08:52 -080016#include <linux/sysfs.h>
Matthew Garrettb1569e92008-12-03 17:55:32 +000017#include <linux/workqueue.h>
Florian Fainelliaf6c9f12014-11-19 18:11:00 -080018#include <uapi/linux/thermal.h>
Zhang Rui203d3d42008-01-17 15:51:08 +080019
Zhang Rui57df81062013-02-08 14:52:06 +080020/* invalid cooling state */
21#define THERMAL_CSTATE_INVALID -1UL
22
Durgadoss R23064082012-09-18 11:04:52 +053023/* No upper/lower limit requirement */
Punit Agrawala940cb32014-12-09 12:22:01 +000024#define THERMAL_NO_LIMIT ((u32)~0)
Durgadoss R23064082012-09-18 11:04:52 +053025
Kapileshwar Singh6cd9e9f2015-02-18 16:04:21 +000026/* Default weight of a bound cooling device */
27#define THERMAL_WEIGHT_DEFAULT 0
28
Zhang Ruibb431ba2015-10-30 16:31:47 +080029/* use value, which < 0K, to indicate an invalid/uninitialized temperature */
30#define THERMAL_TEMP_INVALID -274000
31
Zhang Rui203d3d42008-01-17 15:51:08 +080032struct thermal_zone_device;
33struct thermal_cooling_device;
Javi Merino35b11d22015-02-26 19:00:28 +000034struct thermal_instance;
Daniel Lezcanoc68df442020-04-02 16:27:40 +020035struct thermal_attr;
Zhang Rui203d3d42008-01-17 15:51:08 +080036
Zhang Rui601f3d42012-06-27 09:54:33 +080037enum thermal_trend {
38 THERMAL_TREND_STABLE, /* temperature is stable */
39 THERMAL_TREND_RAISING, /* temperature is raising */
40 THERMAL_TREND_DROPPING, /* temperature is dropping */
Zhang Rui601f3d42012-06-27 09:54:33 +080041};
42
Srinivas Pandruvada0e70f462016-08-26 16:21:16 -070043/* Thermal notification reason */
44enum thermal_notify_event {
45 THERMAL_EVENT_UNSPECIFIED, /* Unspecified event */
46 THERMAL_EVENT_TEMP_SAMPLE, /* New Temperature sample */
47 THERMAL_TRIP_VIOLATED, /* TRIP Point violation */
48 THERMAL_TRIP_CHANGED, /* TRIP Point temperature changed */
49 THERMAL_DEVICE_DOWN, /* Thermal device is down */
50 THERMAL_DEVICE_UP, /* Thermal device is up after a down event */
51 THERMAL_DEVICE_POWER_CAPABILITY_CHANGED, /* power capability changed */
Brian Bian38e44da2017-08-09 11:45:40 -070052 THERMAL_TABLE_CHANGED, /* Thermal table(s) changed */
Srinivas Pandruvada88052312020-09-15 15:36:49 -070053 THERMAL_EVENT_KEEP_ALIVE, /* Request for user space handler to respond */
Srinivas Pandruvada0e70f462016-08-26 16:21:16 -070054};
55
Zhang Rui203d3d42008-01-17 15:51:08 +080056struct thermal_zone_device_ops {
57 int (*bind) (struct thermal_zone_device *,
58 struct thermal_cooling_device *);
59 int (*unbind) (struct thermal_zone_device *,
60 struct thermal_cooling_device *);
Sascha Hauer17e8351a2015-07-24 08:12:54 +020061 int (*get_temp) (struct thermal_zone_device *, int *);
Sascha Hauer060c0342016-06-22 16:42:01 +080062 int (*set_trips) (struct thermal_zone_device *, int, int);
Andrzej Pietrasiewiczf5e50bf42020-06-29 14:29:25 +020063 int (*change_mode) (struct thermal_zone_device *,
Matthew Garrett6503e5d2008-11-27 17:48:13 +000064 enum thermal_device_mode);
65 int (*get_trip_type) (struct thermal_zone_device *, int,
66 enum thermal_trip_type *);
Sascha Hauer17e8351a2015-07-24 08:12:54 +020067 int (*get_trip_temp) (struct thermal_zone_device *, int, int *);
68 int (*set_trip_temp) (struct thermal_zone_device *, int, int);
69 int (*get_trip_hyst) (struct thermal_zone_device *, int, int *);
70 int (*set_trip_hyst) (struct thermal_zone_device *, int, int);
71 int (*get_crit_temp) (struct thermal_zone_device *, int *);
72 int (*set_emul_temp) (struct thermal_zone_device *, int);
Zhang Rui601f3d42012-06-27 09:54:33 +080073 int (*get_trend) (struct thermal_zone_device *, int,
74 enum thermal_trend *);
Daniel Lezcanod7203ee2020-12-10 13:15:11 +010075 void (*hot)(struct thermal_zone_device *);
76 void (*critical)(struct thermal_zone_device *);
Zhang Rui203d3d42008-01-17 15:51:08 +080077};
78
Daniel Lezcano646274d2022-07-22 22:00:01 +020079/**
80 * struct thermal_trip - representation of a point in temperature domain
81 * @temperature: temperature value in miliCelsius
82 * @hysteresis: relative hysteresis in miliCelsius
83 * @type: trip point type
84 */
85struct thermal_trip {
86 int temperature;
87 int hysteresis;
88 enum thermal_trip_type type;
89};
90
Zhang Rui203d3d42008-01-17 15:51:08 +080091struct thermal_cooling_device_ops {
Matthew Garrett6503e5d2008-11-27 17:48:13 +000092 int (*get_max_state) (struct thermal_cooling_device *, unsigned long *);
93 int (*get_cur_state) (struct thermal_cooling_device *, unsigned long *);
94 int (*set_cur_state) (struct thermal_cooling_device *, unsigned long);
zhuguangqingecd1d2a2020-09-14 15:11:01 +080095 int (*get_requested_power)(struct thermal_cooling_device *, u32 *);
96 int (*state2power)(struct thermal_cooling_device *, unsigned long, u32 *);
97 int (*power2state)(struct thermal_cooling_device *, u32, unsigned long *);
Zhang Rui203d3d42008-01-17 15:51:08 +080098};
99
Zhang Rui203d3d42008-01-17 15:51:08 +0800100struct thermal_cooling_device {
101 int id;
Daniel Lezcano58483762021-03-14 12:13:29 +0100102 char *type;
Viresh Kumar80bb3b92022-10-17 15:33:01 +0530103 unsigned long max_state;
Zhang Rui203d3d42008-01-17 15:51:08 +0800104 struct device device;
Eduardo Valentin4e5e4702013-07-03 15:35:39 -0400105 struct device_node *np;
Zhang Rui203d3d42008-01-17 15:51:08 +0800106 void *devdata;
Viresh Kumar8ea22952018-04-02 16:26:25 +0530107 void *stats;
Alan Cox5b275ce2010-11-11 15:27:29 +0000108 const struct thermal_cooling_device_ops *ops;
Zhang Ruice119f82012-06-27 14:13:04 +0800109 bool updated; /* true if the cooling device does not need update */
Zhang Ruif4a821c2012-07-24 16:56:21 +0800110 struct mutex lock; /* protect thermal_instances list */
Zhang Ruib5e4ae62012-06-27 14:11:52 +0800111 struct list_head thermal_instances;
Zhang Rui203d3d42008-01-17 15:51:08 +0800112 struct list_head node;
113};
114
Javi Merinoc708a982014-06-25 11:00:12 +0100115/**
116 * struct thermal_zone_device - structure for a thermal zone
117 * @id: unique id number for each thermal zone
118 * @type: the thermal zone device type
119 * @device: &struct device for this thermal zone
120 * @trip_temp_attrs: attributes for trip points for sysfs: trip temperature
121 * @trip_type_attrs: attributes for trip points for sysfs: trip type
122 * @trip_hyst_attrs: attributes for trip points for sysfs: trip hysteresis
Andrzej Pietrasiewiczcbba1d72020-06-29 14:29:17 +0200123 * @mode: current mode of this thermal zone
Javi Merinoc708a982014-06-25 11:00:12 +0100124 * @devdata: private pointer for device private data
Daniel Lezcanofae11de2022-07-22 22:00:05 +0200125 * @trips: an array of struct thermal_trip
Daniel Lezcanoe5bfcd32022-07-22 22:00:04 +0200126 * @num_trips: number of trip points the thermal zone supports
Zhang Rui81ad4272016-03-18 10:03:24 +0800127 * @trips_disabled; bitmap for disabled trips
Daniel Lezcano17d399c2020-12-16 23:03:35 +0100128 * @passive_delay_jiffies: number of jiffies to wait between polls when
129 * performing passive cooling.
Daniel Lezcano17d399c2020-12-16 23:03:35 +0100130 * @polling_delay_jiffies: number of jiffies to wait between polls when
131 * checking whether trip points have been crossed (0 for
132 * interrupt driven systems)
Javi Merinoc708a982014-06-25 11:00:12 +0100133 * @temperature: current temperature. This is only for core code,
134 * drivers should use thermal_zone_get_temp() to get the
135 * current temperature
136 * @last_temperature: previous temperature read
137 * @emul_temperature: emulated temperature when using CONFIG_THERMAL_EMULATION
138 * @passive: 1 if you've crossed a passive trip point, 0 otherwise.
Sascha Hauer060c0342016-06-22 16:42:01 +0800139 * @prev_low_trip: the low current temperature if you've crossed a passive
140 trip point.
141 * @prev_high_trip: the above current temperature if you've crossed a
142 passive trip point.
Chen Yu4511f712015-10-30 16:32:10 +0800143 * @need_update: if equals 1, thermal_zone_device_update needs to be invoked.
Javi Merinoc708a982014-06-25 11:00:12 +0100144 * @ops: operations this &thermal_zone_device supports
145 * @tzp: thermal zone parameters
146 * @governor: pointer to the governor for this thermal zone
Javi Merinoe33df1d2015-02-26 19:00:27 +0000147 * @governor_data: private pointer for governor data
Javi Merinoc708a982014-06-25 11:00:12 +0100148 * @thermal_instances: list of &struct thermal_instance of this thermal zone
Matthew Wilcoxb31ef822016-12-21 09:47:03 -0800149 * @ida: &struct ida to generate unique id for this zone's cooling
Javi Merinoc708a982014-06-25 11:00:12 +0100150 * devices
151 * @lock: lock to protect thermal_instances list
152 * @node: node in thermal_tz_list (in thermal_core.c)
153 * @poll_queue: delayed work for polling
Srinivas Pandruvada0e70f462016-08-26 16:21:16 -0700154 * @notify_event: Last notification event
Javi Merinoc708a982014-06-25 11:00:12 +0100155 */
Zhang Rui203d3d42008-01-17 15:51:08 +0800156struct thermal_zone_device {
157 int id;
158 char type[THERMAL_NAME_LENGTH];
159 struct device device;
Eduardo Valentin4d0fe742016-11-07 21:08:52 -0800160 struct attribute_group trips_attribute_group;
Durgadoss Rc56f5c02012-07-25 10:10:58 +0800161 struct thermal_attr *trip_temp_attrs;
162 struct thermal_attr *trip_type_attrs;
Durgadoss R27365a62012-07-25 10:10:59 +0800163 struct thermal_attr *trip_hyst_attrs;
Andrzej Pietrasiewiczcbba1d72020-06-29 14:29:17 +0200164 enum thermal_device_mode mode;
Zhang Rui203d3d42008-01-17 15:51:08 +0800165 void *devdata;
Daniel Lezcanofae11de2022-07-22 22:00:05 +0200166 struct thermal_trip *trips;
Daniel Lezcanoe5bfcd32022-07-22 22:00:04 +0200167 int num_trips;
Zhang Rui81ad4272016-03-18 10:03:24 +0800168 unsigned long trips_disabled; /* bitmap for disabled trips */
Daniel Lezcano17d399c2020-12-16 23:03:35 +0100169 unsigned long passive_delay_jiffies;
170 unsigned long polling_delay_jiffies;
Zhang Rui601f3d42012-06-27 09:54:33 +0800171 int temperature;
Matthew Garrettb1569e92008-12-03 17:55:32 +0000172 int last_temperature;
Amit Daniel Kachhape6e238c2013-02-04 00:30:15 +0000173 int emul_temperature;
Zhang Rui908b9fb2012-06-27 14:14:05 +0800174 int passive;
Sascha Hauer060c0342016-06-22 16:42:01 +0800175 int prev_low_trip;
176 int prev_high_trip;
Chen Yu4511f712015-10-30 16:32:10 +0800177 atomic_t need_update;
Eduardo Valentin4e5e4702013-07-03 15:35:39 -0400178 struct thermal_zone_device_ops *ops;
Javi Merino6b775e82015-03-02 17:17:19 +0000179 struct thermal_zone_params *tzp;
Durgadoss Ra4a15482012-09-18 11:04:57 +0530180 struct thermal_governor *governor;
Javi Merinoe33df1d2015-02-26 19:00:27 +0000181 void *governor_data;
Zhang Rui2d374132012-06-27 10:09:00 +0800182 struct list_head thermal_instances;
Matthew Wilcoxb31ef822016-12-21 09:47:03 -0800183 struct ida ida;
Javi Merinoc708a982014-06-25 11:00:12 +0100184 struct mutex lock;
Zhang Rui203d3d42008-01-17 15:51:08 +0800185 struct list_head node;
Matthew Garrettb1569e92008-12-03 17:55:32 +0000186 struct delayed_work poll_queue;
Srinivas Pandruvada0e70f462016-08-26 16:21:16 -0700187 enum thermal_notify_event notify_event;
Zhang Rui203d3d42008-01-17 15:51:08 +0800188};
R.Durgadoss4cb18722010-10-27 03:33:29 +0530189
Javi Merinoc708a982014-06-25 11:00:12 +0100190/**
191 * struct thermal_governor - structure that holds thermal governor information
192 * @name: name of the governor
Javi Merinoe33df1d2015-02-26 19:00:27 +0000193 * @bind_to_tz: callback called when binding to a thermal zone. If it
194 * returns 0, the governor is bound to the thermal zone,
195 * otherwise it fails.
196 * @unbind_from_tz: callback called when a governor is unbound from a
197 * thermal zone.
Javi Merinoc708a982014-06-25 11:00:12 +0100198 * @throttle: callback called for every trip point even if temperature is
199 * below the trip point temperature
200 * @governor_list: node in thermal_governor_list (in thermal_core.c)
201 */
Durgadoss Ra4a15482012-09-18 11:04:57 +0530202struct thermal_governor {
203 char name[THERMAL_NAME_LENGTH];
Javi Merinoe33df1d2015-02-26 19:00:27 +0000204 int (*bind_to_tz)(struct thermal_zone_device *tz);
205 void (*unbind_from_tz)(struct thermal_zone_device *tz);
Durgadoss Ra4a15482012-09-18 11:04:57 +0530206 int (*throttle)(struct thermal_zone_device *tz, int trip);
207 struct list_head governor_list;
Durgadoss Ra4a15482012-09-18 11:04:57 +0530208};
209
Durgadoss Ref873942012-09-18 11:04:55 +0530210/* Structure that holds binding parameters for a zone */
211struct thermal_bind_params {
212 struct thermal_cooling_device *cdev;
213
214 /*
215 * This is a measure of 'how effectively these devices can
Javi Merinobcdcbbc2015-02-18 16:04:25 +0000216 * cool 'this' thermal zone. It shall be determined by
217 * platform characterization. This value is relative to the
218 * rest of the weights so a cooling device whose weight is
219 * double that of another cooling device is twice as
Mauro Carvalho Chehabeaf7b462019-07-26 09:51:12 -0300220 * effective. See Documentation/driver-api/thermal/sysfs-api.rst for more
Javi Merinobcdcbbc2015-02-18 16:04:25 +0000221 * information.
Durgadoss Ref873942012-09-18 11:04:55 +0530222 */
223 int weight;
224
225 /*
226 * This is a bit mask that gives the binding relation between this
227 * thermal zone and cdev, for a particular trip point.
Mauro Carvalho Chehabeaf7b462019-07-26 09:51:12 -0300228 * See Documentation/driver-api/thermal/sysfs-api.rst for more information.
Durgadoss Ref873942012-09-18 11:04:55 +0530229 */
230 int trip_mask;
Eduardo Valentina8892d832013-07-16 15:26:28 -0400231
232 /*
233 * This is an array of cooling state limits. Must have exactly
234 * 2 * thermal_zone.number_of_trip_points. It is an array consisting
235 * of tuples <lower-state upper-state> of state limits. Each trip
236 * will be associated with one state limit tuple when binding.
237 * A NULL pointer means <THERMAL_NO_LIMITS THERMAL_NO_LIMITS>
238 * on all trips.
239 */
240 unsigned long *binding_limits;
Durgadoss Ref873942012-09-18 11:04:55 +0530241 int (*match) (struct thermal_zone_device *tz,
242 struct thermal_cooling_device *cdev);
243};
244
245/* Structure to define Thermal Zone parameters */
246struct thermal_zone_params {
Durgadoss Ra4a15482012-09-18 11:04:57 +0530247 char governor_name[THERMAL_NAME_LENGTH];
Eduardo Valentinccba4ff2013-08-15 11:34:17 -0400248
249 /*
250 * a boolean to indicate if the thermal to hwmon sysfs interface
251 * is required. when no_hwmon == false, a hwmon sysfs interface
252 * will be created. when no_hwmon == true, nothing will be done
253 */
254 bool no_hwmon;
255
Durgadoss Ref873942012-09-18 11:04:55 +0530256 int num_tbps; /* Number of tbp entries */
257 struct thermal_bind_params *tbp;
Javi Merino6b775e82015-03-02 17:17:19 +0000258
259 /*
260 * Sustainable power (heat) that this thermal zone can dissipate in
261 * mW
262 */
263 u32 sustainable_power;
264
265 /*
266 * Proportional parameter of the PID controller when
267 * overshooting (i.e., when temperature is below the target)
268 */
269 s32 k_po;
270
271 /*
272 * Proportional parameter of the PID controller when
273 * undershooting
274 */
275 s32 k_pu;
276
277 /* Integral parameter of the PID controller */
278 s32 k_i;
279
280 /* Derivative parameter of the PID controller */
281 s32 k_d;
282
283 /* threshold below which the error is no longer accumulated */
284 s32 integral_cutoff;
Eduardo Valentin9d0be7f2015-05-11 19:34:23 -0700285
286 /*
287 * @slope: slope of a linear temperature adjustment curve.
288 * Used by thermal zone drivers.
289 */
290 int slope;
291 /*
292 * @offset: offset of a linear temperature adjustment curve.
293 * Used by thermal zone drivers (default 0).
294 */
295 int offset;
Durgadoss Ref873942012-09-18 11:04:55 +0530296};
297
Durgadoss R23064082012-09-18 11:04:52 +0530298/* Function declarations */
Eduardo Valentin4e5e4702013-07-03 15:35:39 -0400299#ifdef CONFIG_THERMAL_OF
Daniel Lezcano3fd6d6e2022-08-05 00:43:17 +0200300struct thermal_zone_device *thermal_of_zone_register(struct device_node *sensor, int id, void *data,
301 const struct thermal_zone_device_ops *ops);
302
303struct thermal_zone_device *devm_thermal_of_zone_register(struct device *dev, int id, void *data,
304 const struct thermal_zone_device_ops *ops);
305
306void thermal_of_zone_unregister(struct thermal_zone_device *tz);
307
308void devm_thermal_of_zone_unregister(struct device *dev, struct thermal_zone_device *tz);
309
Daniel Lezcanof59ac192022-08-05 00:43:49 +0200310void thermal_of_zone_unregister(struct thermal_zone_device *tz);
311
Eduardo Valentin4e5e4702013-07-03 15:35:39 -0400312#else
Daniel Lezcanof59ac192022-08-05 00:43:49 +0200313static inline
314struct thermal_zone_device *thermal_of_zone_register(struct device_node *sensor, int id, void *data,
315 const struct thermal_zone_device_ops *ops)
Anson Huang34471ab2020-02-22 08:08:49 +0800316{
Daniel Lezcanof59ac192022-08-05 00:43:49 +0200317 return ERR_PTR(-ENOTSUPP);
Eduardo Valentin4e5e4702013-07-03 15:35:39 -0400318}
319
320static inline
Daniel Lezcanof59ac192022-08-05 00:43:49 +0200321struct thermal_zone_device *devm_thermal_of_zone_register(struct device *dev, int id, void *data,
322 const struct thermal_zone_device_ops *ops)
Eduardo Valentin4e5e4702013-07-03 15:35:39 -0400323{
Daniel Lezcanof59ac192022-08-05 00:43:49 +0200324 return ERR_PTR(-ENOTSUPP);
Laxman Dewangane498b492016-03-09 18:40:06 +0530325}
326
Daniel Lezcano3fd6d6e2022-08-05 00:43:17 +0200327static inline void thermal_of_zone_unregister(struct thermal_zone_device *tz)
328{
329}
330
Daniel Lezcanof59ac192022-08-05 00:43:49 +0200331static inline void devm_thermal_of_zone_unregister(struct device *dev,
332 struct thermal_zone_device *tz)
Daniel Lezcano3fd6d6e2022-08-05 00:43:17 +0200333{
334}
Eduardo Valentin4e5e4702013-07-03 15:35:39 -0400335#endif
Nishanth Menon12ca7182015-02-13 19:28:02 -0600336
Daniel Lezcano60518262020-04-02 16:27:45 +0200337#ifdef CONFIG_THERMAL
Anton Vorontsov4b1bf582012-07-31 04:39:30 -0700338struct thermal_zone_device *thermal_zone_device_register(const char *, int, int,
Eduardo Valentin4e5e4702013-07-03 15:35:39 -0400339 void *, struct thermal_zone_device_ops *,
Javi Merino6b775e82015-03-02 17:17:19 +0000340 struct thermal_zone_params *, int, int);
Daniel Lezcanofae11de2022-07-22 22:00:05 +0200341
Zhang Rui203d3d42008-01-17 15:51:08 +0800342void thermal_zone_device_unregister(struct thermal_zone_device *);
343
Daniel Lezcanofae11de2022-07-22 22:00:05 +0200344struct thermal_zone_device *
345thermal_zone_device_register_with_trips(const char *, struct thermal_trip *, int, int,
346 void *, struct thermal_zone_device_ops *,
347 struct thermal_zone_params *, int, int);
348
Zhang Rui203d3d42008-01-17 15:51:08 +0800349int thermal_zone_bind_cooling_device(struct thermal_zone_device *, int,
Zhang Rui9d998422012-06-26 16:35:57 +0800350 struct thermal_cooling_device *,
Kapileshwar Singh6cd9e9f2015-02-18 16:04:21 +0000351 unsigned long, unsigned long,
352 unsigned int);
Zhang Rui203d3d42008-01-17 15:51:08 +0800353int thermal_zone_unbind_cooling_device(struct thermal_zone_device *, int,
354 struct thermal_cooling_device *);
Srinivas Pandruvada0e70f462016-08-26 16:21:16 -0700355void thermal_zone_device_update(struct thermal_zone_device *,
356 enum thermal_notify_event);
Durgadoss R23064082012-09-18 11:04:52 +0530357
Jean-Francois Dagenaisf991de52019-04-18 12:36:39 -0400358struct thermal_cooling_device *thermal_cooling_device_register(const char *,
359 void *, const struct thermal_cooling_device_ops *);
Eduardo Valentina116b5d2013-09-26 15:55:01 -0400360struct thermal_cooling_device *
Jean-Francois Dagenaisf991de52019-04-18 12:36:39 -0400361thermal_of_cooling_device_register(struct device_node *np, const char *, void *,
Eduardo Valentina116b5d2013-09-26 15:55:01 -0400362 const struct thermal_cooling_device_ops *);
Guenter Roeckb4ab114cc2019-04-18 12:58:15 -0700363struct thermal_cooling_device *
364devm_thermal_of_cooling_device_register(struct device *dev,
365 struct device_node *np,
366 char *type, void *devdata,
367 const struct thermal_cooling_device_ops *ops);
Zhang Rui203d3d42008-01-17 15:51:08 +0800368void thermal_cooling_device_unregister(struct thermal_cooling_device *);
Eduardo Valentin63c4d912013-04-05 12:32:28 +0000369struct thermal_zone_device *thermal_zone_get_zone_by_name(const char *name);
Sascha Hauer17e8351a2015-07-24 08:12:54 +0200370int thermal_zone_get_temp(struct thermal_zone_device *tz, int *temp);
Rajendra Nayak4a7069a2016-05-05 14:21:42 +0530371int thermal_zone_get_slope(struct thermal_zone_device *tz);
372int thermal_zone_get_offset(struct thermal_zone_device *tz);
Rafael J. Wysockiaf062162011-03-01 01:12:19 +0100373
Andrzej Pietrasiewiczac5d9ec2020-06-29 14:29:20 +0200374int thermal_zone_device_enable(struct thermal_zone_device *tz);
375int thermal_zone_device_disable(struct thermal_zone_device *tz);
Daniel Lezcanod7203ee2020-12-10 13:15:11 +0100376void thermal_zone_device_critical(struct thermal_zone_device *tz);
Nishanth Menon12ca7182015-02-13 19:28:02 -0600377#else
378static inline struct thermal_zone_device *thermal_zone_device_register(
379 const char *type, int trips, int mask, void *devdata,
380 struct thermal_zone_device_ops *ops,
Arvind Yadav023b7b02017-08-31 11:30:45 +0530381 struct thermal_zone_params *tzp,
Nishanth Menon12ca7182015-02-13 19:28:02 -0600382 int passive_delay, int polling_delay)
383{ return ERR_PTR(-ENODEV); }
384static inline void thermal_zone_device_unregister(
385 struct thermal_zone_device *tz)
386{ }
Nishanth Menon12ca7182015-02-13 19:28:02 -0600387static inline struct thermal_cooling_device *
Arnd Bergmannfb836102021-07-22 11:06:44 +0200388thermal_cooling_device_register(const char *type, void *devdata,
Nishanth Menon12ca7182015-02-13 19:28:02 -0600389 const struct thermal_cooling_device_ops *ops)
390{ return ERR_PTR(-ENODEV); }
391static inline struct thermal_cooling_device *
392thermal_of_cooling_device_register(struct device_node *np,
Arnd Bergmannfb836102021-07-22 11:06:44 +0200393 const char *type, void *devdata,
394 const struct thermal_cooling_device_ops *ops)
Nishanth Menon12ca7182015-02-13 19:28:02 -0600395{ return ERR_PTR(-ENODEV); }
Guenter Roeckb4ab114cc2019-04-18 12:58:15 -0700396static inline struct thermal_cooling_device *
397devm_thermal_of_cooling_device_register(struct device *dev,
398 struct device_node *np,
399 char *type, void *devdata,
400 const struct thermal_cooling_device_ops *ops)
401{
402 return ERR_PTR(-ENODEV);
403}
Nishanth Menon12ca7182015-02-13 19:28:02 -0600404static inline void thermal_cooling_device_unregister(
405 struct thermal_cooling_device *cdev)
406{ }
407static inline struct thermal_zone_device *thermal_zone_get_zone_by_name(
408 const char *name)
409{ return ERR_PTR(-ENODEV); }
410static inline int thermal_zone_get_temp(
Sascha Hauer17e8351a2015-07-24 08:12:54 +0200411 struct thermal_zone_device *tz, int *temp)
Nishanth Menon12ca7182015-02-13 19:28:02 -0600412{ return -ENODEV; }
Rajendra Nayak4a7069a2016-05-05 14:21:42 +0530413static inline int thermal_zone_get_slope(
414 struct thermal_zone_device *tz)
415{ return -ENODEV; }
416static inline int thermal_zone_get_offset(
417 struct thermal_zone_device *tz)
418{ return -ENODEV; }
Daniel Lezcanof0129c22020-04-02 16:27:43 +0200419
Andrzej Pietrasiewiczac5d9ec2020-06-29 14:29:20 +0200420static inline int thermal_zone_device_enable(struct thermal_zone_device *tz)
421{ return -ENODEV; }
422
423static inline int thermal_zone_device_disable(struct thermal_zone_device *tz)
424{ return -ENODEV; }
Nishanth Menon12ca7182015-02-13 19:28:02 -0600425#endif /* CONFIG_THERMAL */
Durgadoss Ra4a15482012-09-18 11:04:57 +0530426
Len Browna0dd25b2008-02-09 04:01:48 -0500427#endif /* __THERMAL_H__ */