blob: 8006ba5de8551bb2c8297d633271a075a492fc92 [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
Durgadoss R23064082012-09-18 11:04:52 +053020#define THERMAL_TRIPS_NONE -1
21#define THERMAL_MAX_TRIPS 12
Durgadoss R23064082012-09-18 11:04:52 +053022
Zhang Rui57df81062013-02-08 14:52:06 +080023/* invalid cooling state */
24#define THERMAL_CSTATE_INVALID -1UL
25
Durgadoss R23064082012-09-18 11:04:52 +053026/* No upper/lower limit requirement */
Punit Agrawala940cb32014-12-09 12:22:01 +000027#define THERMAL_NO_LIMIT ((u32)~0)
Durgadoss R23064082012-09-18 11:04:52 +053028
Kapileshwar Singh6cd9e9f2015-02-18 16:04:21 +000029/* Default weight of a bound cooling device */
30#define THERMAL_WEIGHT_DEFAULT 0
31
Zhang Ruibb431ba2015-10-30 16:31:47 +080032/* use value, which < 0K, to indicate an invalid/uninitialized temperature */
33#define THERMAL_TEMP_INVALID -274000
34
Zhang Rui203d3d42008-01-17 15:51:08 +080035struct thermal_zone_device;
36struct thermal_cooling_device;
Javi Merino35b11d22015-02-26 19:00:28 +000037struct thermal_instance;
Daniel Lezcanoc68df442020-04-02 16:27:40 +020038struct thermal_attr;
Zhang Rui203d3d42008-01-17 15:51:08 +080039
Matthew Garrett6503e5d2008-11-27 17:48:13 +000040enum thermal_device_mode {
41 THERMAL_DEVICE_DISABLED = 0,
42 THERMAL_DEVICE_ENABLED,
43};
44
45enum thermal_trip_type {
46 THERMAL_TRIP_ACTIVE = 0,
47 THERMAL_TRIP_PASSIVE,
48 THERMAL_TRIP_HOT,
49 THERMAL_TRIP_CRITICAL,
50};
51
Zhang Rui601f3d42012-06-27 09:54:33 +080052enum thermal_trend {
53 THERMAL_TREND_STABLE, /* temperature is stable */
54 THERMAL_TREND_RAISING, /* temperature is raising */
55 THERMAL_TREND_DROPPING, /* temperature is dropping */
Zhang Ruid069015e2012-11-19 15:33:51 +080056 THERMAL_TREND_RAISE_FULL, /* apply highest cooling action */
57 THERMAL_TREND_DROP_FULL, /* apply lowest cooling action */
Zhang Rui601f3d42012-06-27 09:54:33 +080058};
59
Srinivas Pandruvada0e70f462016-08-26 16:21:16 -070060/* Thermal notification reason */
61enum thermal_notify_event {
62 THERMAL_EVENT_UNSPECIFIED, /* Unspecified event */
63 THERMAL_EVENT_TEMP_SAMPLE, /* New Temperature sample */
64 THERMAL_TRIP_VIOLATED, /* TRIP Point violation */
65 THERMAL_TRIP_CHANGED, /* TRIP Point temperature changed */
66 THERMAL_DEVICE_DOWN, /* Thermal device is down */
67 THERMAL_DEVICE_UP, /* Thermal device is up after a down event */
68 THERMAL_DEVICE_POWER_CAPABILITY_CHANGED, /* power capability changed */
Brian Bian38e44da2017-08-09 11:45:40 -070069 THERMAL_TABLE_CHANGED, /* Thermal table(s) changed */
Srinivas Pandruvada0e70f462016-08-26 16:21:16 -070070};
71
Zhang Rui203d3d42008-01-17 15:51:08 +080072struct thermal_zone_device_ops {
73 int (*bind) (struct thermal_zone_device *,
74 struct thermal_cooling_device *);
75 int (*unbind) (struct thermal_zone_device *,
76 struct thermal_cooling_device *);
Sascha Hauer17e8351a2015-07-24 08:12:54 +020077 int (*get_temp) (struct thermal_zone_device *, int *);
Sascha Hauer060c0342016-06-22 16:42:01 +080078 int (*set_trips) (struct thermal_zone_device *, int, int);
Matthew Garrett6503e5d2008-11-27 17:48:13 +000079 int (*get_mode) (struct thermal_zone_device *,
80 enum thermal_device_mode *);
81 int (*set_mode) (struct thermal_zone_device *,
82 enum thermal_device_mode);
83 int (*get_trip_type) (struct thermal_zone_device *, int,
84 enum thermal_trip_type *);
Sascha Hauer17e8351a2015-07-24 08:12:54 +020085 int (*get_trip_temp) (struct thermal_zone_device *, int, int *);
86 int (*set_trip_temp) (struct thermal_zone_device *, int, int);
87 int (*get_trip_hyst) (struct thermal_zone_device *, int, int *);
88 int (*set_trip_hyst) (struct thermal_zone_device *, int, int);
89 int (*get_crit_temp) (struct thermal_zone_device *, int *);
90 int (*set_emul_temp) (struct thermal_zone_device *, int);
Zhang Rui601f3d42012-06-27 09:54:33 +080091 int (*get_trend) (struct thermal_zone_device *, int,
92 enum thermal_trend *);
Matthew Garrettb1569e92008-12-03 17:55:32 +000093 int (*notify) (struct thermal_zone_device *, int,
94 enum thermal_trip_type);
Zhang Rui203d3d42008-01-17 15:51:08 +080095};
96
97struct thermal_cooling_device_ops {
Matthew Garrett6503e5d2008-11-27 17:48:13 +000098 int (*get_max_state) (struct thermal_cooling_device *, unsigned long *);
99 int (*get_cur_state) (struct thermal_cooling_device *, unsigned long *);
100 int (*set_cur_state) (struct thermal_cooling_device *, unsigned long);
Javi Merino35b11d22015-02-26 19:00:28 +0000101 int (*get_requested_power)(struct thermal_cooling_device *,
102 struct thermal_zone_device *, u32 *);
103 int (*state2power)(struct thermal_cooling_device *,
104 struct thermal_zone_device *, unsigned long, u32 *);
105 int (*power2state)(struct thermal_cooling_device *,
106 struct thermal_zone_device *, u32, unsigned long *);
Zhang Rui203d3d42008-01-17 15:51:08 +0800107};
108
Zhang Rui203d3d42008-01-17 15:51:08 +0800109struct thermal_cooling_device {
110 int id;
111 char type[THERMAL_NAME_LENGTH];
112 struct device device;
Eduardo Valentin4e5e4702013-07-03 15:35:39 -0400113 struct device_node *np;
Zhang Rui203d3d42008-01-17 15:51:08 +0800114 void *devdata;
Viresh Kumar8ea22952018-04-02 16:26:25 +0530115 void *stats;
Alan Cox5b275ce2010-11-11 15:27:29 +0000116 const struct thermal_cooling_device_ops *ops;
Zhang Ruice119f82012-06-27 14:13:04 +0800117 bool updated; /* true if the cooling device does not need update */
Zhang Ruif4a821c2012-07-24 16:56:21 +0800118 struct mutex lock; /* protect thermal_instances list */
Zhang Ruib5e4ae62012-06-27 14:11:52 +0800119 struct list_head thermal_instances;
Zhang Rui203d3d42008-01-17 15:51:08 +0800120 struct list_head node;
121};
122
Javi Merinoc708a982014-06-25 11:00:12 +0100123/**
124 * struct thermal_zone_device - structure for a thermal zone
125 * @id: unique id number for each thermal zone
126 * @type: the thermal zone device type
127 * @device: &struct device for this thermal zone
128 * @trip_temp_attrs: attributes for trip points for sysfs: trip temperature
129 * @trip_type_attrs: attributes for trip points for sysfs: trip type
130 * @trip_hyst_attrs: attributes for trip points for sysfs: trip hysteresis
131 * @devdata: private pointer for device private data
132 * @trips: number of trip points the thermal zone supports
Zhang Rui81ad4272016-03-18 10:03:24 +0800133 * @trips_disabled; bitmap for disabled trips
Javi Merinoc708a982014-06-25 11:00:12 +0100134 * @passive_delay: number of milliseconds to wait between polls when
Javi Merino6b775e82015-03-02 17:17:19 +0000135 * performing passive cooling.
Javi Merinoc708a982014-06-25 11:00:12 +0100136 * @polling_delay: number of milliseconds to wait between polls when
137 * checking whether trip points have been crossed (0 for
138 * interrupt driven systems)
139 * @temperature: current temperature. This is only for core code,
140 * drivers should use thermal_zone_get_temp() to get the
141 * current temperature
142 * @last_temperature: previous temperature read
143 * @emul_temperature: emulated temperature when using CONFIG_THERMAL_EMULATION
144 * @passive: 1 if you've crossed a passive trip point, 0 otherwise.
Sascha Hauer060c0342016-06-22 16:42:01 +0800145 * @prev_low_trip: the low current temperature if you've crossed a passive
146 trip point.
147 * @prev_high_trip: the above current temperature if you've crossed a
148 passive trip point.
Javi Merinoc708a982014-06-25 11:00:12 +0100149 * @forced_passive: If > 0, temperature at which to switch on all ACPI
150 * processor cooling devices. Currently only used by the
151 * step-wise governor.
Chen Yu4511f712015-10-30 16:32:10 +0800152 * @need_update: if equals 1, thermal_zone_device_update needs to be invoked.
Javi Merinoc708a982014-06-25 11:00:12 +0100153 * @ops: operations this &thermal_zone_device supports
154 * @tzp: thermal zone parameters
155 * @governor: pointer to the governor for this thermal zone
Javi Merinoe33df1d2015-02-26 19:00:27 +0000156 * @governor_data: private pointer for governor data
Javi Merinoc708a982014-06-25 11:00:12 +0100157 * @thermal_instances: list of &struct thermal_instance of this thermal zone
Matthew Wilcoxb31ef822016-12-21 09:47:03 -0800158 * @ida: &struct ida to generate unique id for this zone's cooling
Javi Merinoc708a982014-06-25 11:00:12 +0100159 * devices
160 * @lock: lock to protect thermal_instances list
161 * @node: node in thermal_tz_list (in thermal_core.c)
162 * @poll_queue: delayed work for polling
Srinivas Pandruvada0e70f462016-08-26 16:21:16 -0700163 * @notify_event: Last notification event
Javi Merinoc708a982014-06-25 11:00:12 +0100164 */
Zhang Rui203d3d42008-01-17 15:51:08 +0800165struct thermal_zone_device {
166 int id;
167 char type[THERMAL_NAME_LENGTH];
168 struct device device;
Eduardo Valentin4d0fe742016-11-07 21:08:52 -0800169 struct attribute_group trips_attribute_group;
Durgadoss Rc56f5c02012-07-25 10:10:58 +0800170 struct thermal_attr *trip_temp_attrs;
171 struct thermal_attr *trip_type_attrs;
Durgadoss R27365a62012-07-25 10:10:59 +0800172 struct thermal_attr *trip_hyst_attrs;
Zhang Rui203d3d42008-01-17 15:51:08 +0800173 void *devdata;
174 int trips;
Zhang Rui81ad4272016-03-18 10:03:24 +0800175 unsigned long trips_disabled; /* bitmap for disabled trips */
Matthew Garrettb1569e92008-12-03 17:55:32 +0000176 int passive_delay;
177 int polling_delay;
Zhang Rui601f3d42012-06-27 09:54:33 +0800178 int temperature;
Matthew Garrettb1569e92008-12-03 17:55:32 +0000179 int last_temperature;
Amit Daniel Kachhape6e238c2013-02-04 00:30:15 +0000180 int emul_temperature;
Zhang Rui908b9fb2012-06-27 14:14:05 +0800181 int passive;
Sascha Hauer060c0342016-06-22 16:42:01 +0800182 int prev_low_trip;
183 int prev_high_trip;
Matthew Garrett03a971a2008-12-03 18:00:38 +0000184 unsigned int forced_passive;
Chen Yu4511f712015-10-30 16:32:10 +0800185 atomic_t need_update;
Eduardo Valentin4e5e4702013-07-03 15:35:39 -0400186 struct thermal_zone_device_ops *ops;
Javi Merino6b775e82015-03-02 17:17:19 +0000187 struct thermal_zone_params *tzp;
Durgadoss Ra4a15482012-09-18 11:04:57 +0530188 struct thermal_governor *governor;
Javi Merinoe33df1d2015-02-26 19:00:27 +0000189 void *governor_data;
Zhang Rui2d374132012-06-27 10:09:00 +0800190 struct list_head thermal_instances;
Matthew Wilcoxb31ef822016-12-21 09:47:03 -0800191 struct ida ida;
Javi Merinoc708a982014-06-25 11:00:12 +0100192 struct mutex lock;
Zhang Rui203d3d42008-01-17 15:51:08 +0800193 struct list_head node;
Matthew Garrettb1569e92008-12-03 17:55:32 +0000194 struct delayed_work poll_queue;
Srinivas Pandruvada0e70f462016-08-26 16:21:16 -0700195 enum thermal_notify_event notify_event;
Zhang Rui203d3d42008-01-17 15:51:08 +0800196};
R.Durgadoss4cb18722010-10-27 03:33:29 +0530197
Javi Merinoc708a982014-06-25 11:00:12 +0100198/**
199 * struct thermal_governor - structure that holds thermal governor information
200 * @name: name of the governor
Javi Merinoe33df1d2015-02-26 19:00:27 +0000201 * @bind_to_tz: callback called when binding to a thermal zone. If it
202 * returns 0, the governor is bound to the thermal zone,
203 * otherwise it fails.
204 * @unbind_from_tz: callback called when a governor is unbound from a
205 * thermal zone.
Javi Merinoc708a982014-06-25 11:00:12 +0100206 * @throttle: callback called for every trip point even if temperature is
207 * below the trip point temperature
208 * @governor_list: node in thermal_governor_list (in thermal_core.c)
209 */
Durgadoss Ra4a15482012-09-18 11:04:57 +0530210struct thermal_governor {
211 char name[THERMAL_NAME_LENGTH];
Javi Merinoe33df1d2015-02-26 19:00:27 +0000212 int (*bind_to_tz)(struct thermal_zone_device *tz);
213 void (*unbind_from_tz)(struct thermal_zone_device *tz);
Durgadoss Ra4a15482012-09-18 11:04:57 +0530214 int (*throttle)(struct thermal_zone_device *tz, int trip);
215 struct list_head governor_list;
Durgadoss Ra4a15482012-09-18 11:04:57 +0530216};
217
Durgadoss Ref873942012-09-18 11:04:55 +0530218/* Structure that holds binding parameters for a zone */
219struct thermal_bind_params {
220 struct thermal_cooling_device *cdev;
221
222 /*
223 * This is a measure of 'how effectively these devices can
Javi Merinobcdcbbc2015-02-18 16:04:25 +0000224 * cool 'this' thermal zone. It shall be determined by
225 * platform characterization. This value is relative to the
226 * rest of the weights so a cooling device whose weight is
227 * double that of another cooling device is twice as
Mauro Carvalho Chehabeaf7b462019-07-26 09:51:12 -0300228 * effective. See Documentation/driver-api/thermal/sysfs-api.rst for more
Javi Merinobcdcbbc2015-02-18 16:04:25 +0000229 * information.
Durgadoss Ref873942012-09-18 11:04:55 +0530230 */
231 int weight;
232
233 /*
234 * This is a bit mask that gives the binding relation between this
235 * thermal zone and cdev, for a particular trip point.
Mauro Carvalho Chehabeaf7b462019-07-26 09:51:12 -0300236 * See Documentation/driver-api/thermal/sysfs-api.rst for more information.
Durgadoss Ref873942012-09-18 11:04:55 +0530237 */
238 int trip_mask;
Eduardo Valentina8892d832013-07-16 15:26:28 -0400239
240 /*
241 * This is an array of cooling state limits. Must have exactly
242 * 2 * thermal_zone.number_of_trip_points. It is an array consisting
243 * of tuples <lower-state upper-state> of state limits. Each trip
244 * will be associated with one state limit tuple when binding.
245 * A NULL pointer means <THERMAL_NO_LIMITS THERMAL_NO_LIMITS>
246 * on all trips.
247 */
248 unsigned long *binding_limits;
Durgadoss Ref873942012-09-18 11:04:55 +0530249 int (*match) (struct thermal_zone_device *tz,
250 struct thermal_cooling_device *cdev);
251};
252
253/* Structure to define Thermal Zone parameters */
254struct thermal_zone_params {
Durgadoss Ra4a15482012-09-18 11:04:57 +0530255 char governor_name[THERMAL_NAME_LENGTH];
Eduardo Valentinccba4ff2013-08-15 11:34:17 -0400256
257 /*
258 * a boolean to indicate if the thermal to hwmon sysfs interface
259 * is required. when no_hwmon == false, a hwmon sysfs interface
260 * will be created. when no_hwmon == true, nothing will be done
261 */
262 bool no_hwmon;
263
Durgadoss Ref873942012-09-18 11:04:55 +0530264 int num_tbps; /* Number of tbp entries */
265 struct thermal_bind_params *tbp;
Javi Merino6b775e82015-03-02 17:17:19 +0000266
267 /*
268 * Sustainable power (heat) that this thermal zone can dissipate in
269 * mW
270 */
271 u32 sustainable_power;
272
273 /*
274 * Proportional parameter of the PID controller when
275 * overshooting (i.e., when temperature is below the target)
276 */
277 s32 k_po;
278
279 /*
280 * Proportional parameter of the PID controller when
281 * undershooting
282 */
283 s32 k_pu;
284
285 /* Integral parameter of the PID controller */
286 s32 k_i;
287
288 /* Derivative parameter of the PID controller */
289 s32 k_d;
290
291 /* threshold below which the error is no longer accumulated */
292 s32 integral_cutoff;
Eduardo Valentin9d0be7f2015-05-11 19:34:23 -0700293
294 /*
295 * @slope: slope of a linear temperature adjustment curve.
296 * Used by thermal zone drivers.
297 */
298 int slope;
299 /*
300 * @offset: offset of a linear temperature adjustment curve.
301 * Used by thermal zone drivers (default 0).
302 */
303 int offset;
Durgadoss Ref873942012-09-18 11:04:55 +0530304};
305
R.Durgadoss4cb18722010-10-27 03:33:29 +0530306struct thermal_genl_event {
307 u32 orig;
308 enum events event;
309};
R.Durgadoss4cb18722010-10-27 03:33:29 +0530310
Eduardo Valentin2251aef2014-11-07 21:24:39 -0400311/**
312 * struct thermal_zone_of_device_ops - scallbacks for handling DT based zones
313 *
314 * Mandatory:
315 * @get_temp: a pointer to a function that reads the sensor temperature.
316 *
317 * Optional:
318 * @get_trend: a pointer to a function that reads the sensor temperature trend.
Sascha Hauer826386e2016-06-22 16:42:02 +0800319 * @set_trips: a pointer to a function that sets a temperature window. When
320 * this window is left the driver must inform the thermal core via
321 * thermal_zone_device_update.
Lukasz Majewski184a4bf2014-12-08 18:04:21 +0100322 * @set_emul_temp: a pointer to a function that sets sensor emulated
323 * temperature.
Caesar Wang5a5e78c2016-05-18 23:01:39 +0800324 * @set_trip_temp: a pointer to a function that sets the trip temperature on
325 * hardware.
Eduardo Valentin2251aef2014-11-07 21:24:39 -0400326 */
327struct thermal_zone_of_device_ops {
Sascha Hauer17e8351a2015-07-24 08:12:54 +0200328 int (*get_temp)(void *, int *);
Sascha Hauere78eaf42016-06-22 16:42:03 +0800329 int (*get_trend)(void *, int, enum thermal_trend *);
Sascha Hauer826386e2016-06-22 16:42:02 +0800330 int (*set_trips)(void *, int, int);
Sascha Hauer17e8351a2015-07-24 08:12:54 +0200331 int (*set_emul_temp)(void *, int);
Wei Nic3509522016-03-29 18:29:17 +0800332 int (*set_trip_temp)(void *, int, int);
Eduardo Valentin2251aef2014-11-07 21:24:39 -0400333};
334
Durgadoss R23064082012-09-18 11:04:52 +0530335/* Function declarations */
Eduardo Valentin4e5e4702013-07-03 15:35:39 -0400336#ifdef CONFIG_THERMAL_OF
Anson Huang34471ab2020-02-22 08:08:49 +0800337int thermal_zone_of_get_sensor_id(struct device_node *tz_np,
338 struct device_node *sensor_np,
339 u32 *id);
Eduardo Valentin4e5e4702013-07-03 15:35:39 -0400340struct thermal_zone_device *
Eduardo Valentin2251aef2014-11-07 21:24:39 -0400341thermal_zone_of_sensor_register(struct device *dev, int id, void *data,
342 const struct thermal_zone_of_device_ops *ops);
Eduardo Valentin4e5e4702013-07-03 15:35:39 -0400343void thermal_zone_of_sensor_unregister(struct device *dev,
344 struct thermal_zone_device *tz);
Laxman Dewangane498b492016-03-09 18:40:06 +0530345struct thermal_zone_device *devm_thermal_zone_of_sensor_register(
346 struct device *dev, int id, void *data,
347 const struct thermal_zone_of_device_ops *ops);
348void devm_thermal_zone_of_sensor_unregister(struct device *dev,
349 struct thermal_zone_device *tz);
Eduardo Valentin4e5e4702013-07-03 15:35:39 -0400350#else
Anson Huang34471ab2020-02-22 08:08:49 +0800351
Anson Huang15a26312020-03-03 16:04:43 +0800352static inline int thermal_zone_of_get_sensor_id(struct device_node *tz_np,
Anson Huang34471ab2020-02-22 08:08:49 +0800353 struct device_node *sensor_np,
354 u32 *id)
355{
356 return -ENOENT;
357}
Eduardo Valentin4e5e4702013-07-03 15:35:39 -0400358static inline struct thermal_zone_device *
Eduardo Valentin2251aef2014-11-07 21:24:39 -0400359thermal_zone_of_sensor_register(struct device *dev, int id, void *data,
360 const struct thermal_zone_of_device_ops *ops)
Eduardo Valentin4e5e4702013-07-03 15:35:39 -0400361{
Punit Agrawalcd33dc92015-09-08 14:51:12 +0100362 return ERR_PTR(-ENODEV);
Eduardo Valentin4e5e4702013-07-03 15:35:39 -0400363}
364
365static inline
366void thermal_zone_of_sensor_unregister(struct device *dev,
367 struct thermal_zone_device *tz)
368{
369}
370
Laxman Dewangane498b492016-03-09 18:40:06 +0530371static inline struct thermal_zone_device *devm_thermal_zone_of_sensor_register(
372 struct device *dev, int id, void *data,
373 const struct thermal_zone_of_device_ops *ops)
374{
375 return ERR_PTR(-ENODEV);
376}
377
378static inline
379void devm_thermal_zone_of_sensor_unregister(struct device *dev,
380 struct thermal_zone_device *tz)
381{
382}
383
Eduardo Valentin4e5e4702013-07-03 15:35:39 -0400384#endif
Nishanth Menon12ca7182015-02-13 19:28:02 -0600385
386#if IS_ENABLED(CONFIG_THERMAL)
Anton Vorontsov4b1bf582012-07-31 04:39:30 -0700387struct thermal_zone_device *thermal_zone_device_register(const char *, int, int,
Eduardo Valentin4e5e4702013-07-03 15:35:39 -0400388 void *, struct thermal_zone_device_ops *,
Javi Merino6b775e82015-03-02 17:17:19 +0000389 struct thermal_zone_params *, int, int);
Zhang Rui203d3d42008-01-17 15:51:08 +0800390void thermal_zone_device_unregister(struct thermal_zone_device *);
391
392int thermal_zone_bind_cooling_device(struct thermal_zone_device *, int,
Zhang Rui9d998422012-06-26 16:35:57 +0800393 struct thermal_cooling_device *,
Kapileshwar Singh6cd9e9f2015-02-18 16:04:21 +0000394 unsigned long, unsigned long,
395 unsigned int);
Zhang Rui203d3d42008-01-17 15:51:08 +0800396int thermal_zone_unbind_cooling_device(struct thermal_zone_device *, int,
397 struct thermal_cooling_device *);
Srinivas Pandruvada0e70f462016-08-26 16:21:16 -0700398void thermal_zone_device_update(struct thermal_zone_device *,
399 enum thermal_notify_event);
Durgadoss R23064082012-09-18 11:04:52 +0530400
Jean-Francois Dagenaisf991de52019-04-18 12:36:39 -0400401struct thermal_cooling_device *thermal_cooling_device_register(const char *,
402 void *, const struct thermal_cooling_device_ops *);
Eduardo Valentina116b5d2013-09-26 15:55:01 -0400403struct thermal_cooling_device *
Jean-Francois Dagenaisf991de52019-04-18 12:36:39 -0400404thermal_of_cooling_device_register(struct device_node *np, const char *, void *,
Eduardo Valentina116b5d2013-09-26 15:55:01 -0400405 const struct thermal_cooling_device_ops *);
Guenter Roeckb4ab114cc2019-04-18 12:58:15 -0700406struct thermal_cooling_device *
407devm_thermal_of_cooling_device_register(struct device *dev,
408 struct device_node *np,
409 char *type, void *devdata,
410 const struct thermal_cooling_device_ops *ops);
Zhang Rui203d3d42008-01-17 15:51:08 +0800411void thermal_cooling_device_unregister(struct thermal_cooling_device *);
Eduardo Valentin63c4d912013-04-05 12:32:28 +0000412struct thermal_zone_device *thermal_zone_get_zone_by_name(const char *name);
Sascha Hauer17e8351a2015-07-24 08:12:54 +0200413int thermal_zone_get_temp(struct thermal_zone_device *tz, int *temp);
Rajendra Nayak4a7069a2016-05-05 14:21:42 +0530414int thermal_zone_get_slope(struct thermal_zone_device *tz);
415int thermal_zone_get_offset(struct thermal_zone_device *tz);
Rafael J. Wysockiaf062162011-03-01 01:12:19 +0100416
Durgadoss R9b4298a2012-09-18 11:04:54 +0530417struct thermal_instance *get_thermal_instance(struct thermal_zone_device *,
418 struct thermal_cooling_device *, int);
Durgadoss Rdc765482012-09-18 11:05:00 +0530419void thermal_cdev_update(struct thermal_cooling_device *);
Eduardo Valentin7b73c992013-04-23 21:48:14 +0000420void thermal_notify_framework(struct thermal_zone_device *, int);
Nishanth Menon12ca7182015-02-13 19:28:02 -0600421#else
422static inline struct thermal_zone_device *thermal_zone_device_register(
423 const char *type, int trips, int mask, void *devdata,
424 struct thermal_zone_device_ops *ops,
Arvind Yadav023b7b02017-08-31 11:30:45 +0530425 struct thermal_zone_params *tzp,
Nishanth Menon12ca7182015-02-13 19:28:02 -0600426 int passive_delay, int polling_delay)
427{ return ERR_PTR(-ENODEV); }
428static inline void thermal_zone_device_unregister(
429 struct thermal_zone_device *tz)
430{ }
431static inline int thermal_zone_bind_cooling_device(
432 struct thermal_zone_device *tz, int trip,
433 struct thermal_cooling_device *cdev,
Arnd Bergmannc86b3de2015-11-17 17:48:52 +0100434 unsigned long upper, unsigned long lower,
435 unsigned int weight)
Nishanth Menon12ca7182015-02-13 19:28:02 -0600436{ return -ENODEV; }
437static inline int thermal_zone_unbind_cooling_device(
438 struct thermal_zone_device *tz, int trip,
439 struct thermal_cooling_device *cdev)
440{ return -ENODEV; }
Srinivas Pandruvada0e70f462016-08-26 16:21:16 -0700441static inline void thermal_zone_device_update(struct thermal_zone_device *tz,
442 enum thermal_notify_event event)
Nishanth Menon12ca7182015-02-13 19:28:02 -0600443{ }
444static inline struct thermal_cooling_device *
445thermal_cooling_device_register(char *type, void *devdata,
446 const struct thermal_cooling_device_ops *ops)
447{ return ERR_PTR(-ENODEV); }
448static inline struct thermal_cooling_device *
449thermal_of_cooling_device_register(struct device_node *np,
450 char *type, void *devdata, const struct thermal_cooling_device_ops *ops)
451{ return ERR_PTR(-ENODEV); }
Guenter Roeckb4ab114cc2019-04-18 12:58:15 -0700452static inline struct thermal_cooling_device *
453devm_thermal_of_cooling_device_register(struct device *dev,
454 struct device_node *np,
455 char *type, void *devdata,
456 const struct thermal_cooling_device_ops *ops)
457{
458 return ERR_PTR(-ENODEV);
459}
Nishanth Menon12ca7182015-02-13 19:28:02 -0600460static inline void thermal_cooling_device_unregister(
461 struct thermal_cooling_device *cdev)
462{ }
463static inline struct thermal_zone_device *thermal_zone_get_zone_by_name(
464 const char *name)
465{ return ERR_PTR(-ENODEV); }
466static inline int thermal_zone_get_temp(
Sascha Hauer17e8351a2015-07-24 08:12:54 +0200467 struct thermal_zone_device *tz, int *temp)
Nishanth Menon12ca7182015-02-13 19:28:02 -0600468{ return -ENODEV; }
Rajendra Nayak4a7069a2016-05-05 14:21:42 +0530469static inline int thermal_zone_get_slope(
470 struct thermal_zone_device *tz)
471{ return -ENODEV; }
472static inline int thermal_zone_get_offset(
473 struct thermal_zone_device *tz)
474{ return -ENODEV; }
Daniel Lezcanof0129c22020-04-02 16:27:43 +0200475
Nishanth Menon12ca7182015-02-13 19:28:02 -0600476static inline struct thermal_instance *
477get_thermal_instance(struct thermal_zone_device *tz,
478 struct thermal_cooling_device *cdev, int trip)
479{ return ERR_PTR(-ENODEV); }
480static inline void thermal_cdev_update(struct thermal_cooling_device *cdev)
481{ }
482static inline void thermal_notify_framework(struct thermal_zone_device *tz,
483 int trip)
484{ }
485#endif /* CONFIG_THERMAL */
Durgadoss Ra4a15482012-09-18 11:04:57 +0530486
Len Browna0dd25b2008-02-09 04:01:48 -0500487#endif /* __THERMAL_H__ */