18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci *  thermal.h  ($Revision: 0 $)
48c2ecf20Sopenharmony_ci *
58c2ecf20Sopenharmony_ci *  Copyright (C) 2008  Intel Corp
68c2ecf20Sopenharmony_ci *  Copyright (C) 2008  Zhang Rui <rui.zhang@intel.com>
78c2ecf20Sopenharmony_ci *  Copyright (C) 2008  Sujith Thomas <sujith.thomas@intel.com>
88c2ecf20Sopenharmony_ci */
98c2ecf20Sopenharmony_ci
108c2ecf20Sopenharmony_ci#ifndef __THERMAL_H__
118c2ecf20Sopenharmony_ci#define __THERMAL_H__
128c2ecf20Sopenharmony_ci
138c2ecf20Sopenharmony_ci#include <linux/of.h>
148c2ecf20Sopenharmony_ci#include <linux/idr.h>
158c2ecf20Sopenharmony_ci#include <linux/device.h>
168c2ecf20Sopenharmony_ci#include <linux/sysfs.h>
178c2ecf20Sopenharmony_ci#include <linux/workqueue.h>
188c2ecf20Sopenharmony_ci#include <uapi/linux/thermal.h>
198c2ecf20Sopenharmony_ci
208c2ecf20Sopenharmony_ci#define THERMAL_TRIPS_NONE	-1
218c2ecf20Sopenharmony_ci#define THERMAL_MAX_TRIPS	12
228c2ecf20Sopenharmony_ci
238c2ecf20Sopenharmony_ci/* invalid cooling state */
248c2ecf20Sopenharmony_ci#define THERMAL_CSTATE_INVALID -1UL
258c2ecf20Sopenharmony_ci
268c2ecf20Sopenharmony_ci/* No upper/lower limit requirement */
278c2ecf20Sopenharmony_ci#define THERMAL_NO_LIMIT	((u32)~0)
288c2ecf20Sopenharmony_ci
298c2ecf20Sopenharmony_ci/* Default weight of a bound cooling device */
308c2ecf20Sopenharmony_ci#define THERMAL_WEIGHT_DEFAULT 0
318c2ecf20Sopenharmony_ci
328c2ecf20Sopenharmony_ci/* use value, which < 0K, to indicate an invalid/uninitialized temperature */
338c2ecf20Sopenharmony_ci#define THERMAL_TEMP_INVALID	-274000
348c2ecf20Sopenharmony_ci
358c2ecf20Sopenharmony_cistruct thermal_zone_device;
368c2ecf20Sopenharmony_cistruct thermal_cooling_device;
378c2ecf20Sopenharmony_cistruct thermal_instance;
388c2ecf20Sopenharmony_cistruct thermal_attr;
398c2ecf20Sopenharmony_ci
408c2ecf20Sopenharmony_cienum thermal_trend {
418c2ecf20Sopenharmony_ci	THERMAL_TREND_STABLE, /* temperature is stable */
428c2ecf20Sopenharmony_ci	THERMAL_TREND_RAISING, /* temperature is raising */
438c2ecf20Sopenharmony_ci	THERMAL_TREND_DROPPING, /* temperature is dropping */
448c2ecf20Sopenharmony_ci	THERMAL_TREND_RAISE_FULL, /* apply highest cooling action */
458c2ecf20Sopenharmony_ci	THERMAL_TREND_DROP_FULL, /* apply lowest cooling action */
468c2ecf20Sopenharmony_ci};
478c2ecf20Sopenharmony_ci
488c2ecf20Sopenharmony_ci/* Thermal notification reason */
498c2ecf20Sopenharmony_cienum thermal_notify_event {
508c2ecf20Sopenharmony_ci	THERMAL_EVENT_UNSPECIFIED, /* Unspecified event */
518c2ecf20Sopenharmony_ci	THERMAL_EVENT_TEMP_SAMPLE, /* New Temperature sample */
528c2ecf20Sopenharmony_ci	THERMAL_TRIP_VIOLATED, /* TRIP Point violation */
538c2ecf20Sopenharmony_ci	THERMAL_TRIP_CHANGED, /* TRIP Point temperature changed */
548c2ecf20Sopenharmony_ci	THERMAL_DEVICE_DOWN, /* Thermal device is down */
558c2ecf20Sopenharmony_ci	THERMAL_DEVICE_UP, /* Thermal device is up after a down event */
568c2ecf20Sopenharmony_ci	THERMAL_DEVICE_POWER_CAPABILITY_CHANGED, /* power capability changed */
578c2ecf20Sopenharmony_ci	THERMAL_TABLE_CHANGED, /* Thermal table(s) changed */
588c2ecf20Sopenharmony_ci	THERMAL_EVENT_KEEP_ALIVE, /* Request for user space handler to respond */
598c2ecf20Sopenharmony_ci};
608c2ecf20Sopenharmony_ci
618c2ecf20Sopenharmony_cistruct thermal_zone_device_ops {
628c2ecf20Sopenharmony_ci	int (*bind) (struct thermal_zone_device *,
638c2ecf20Sopenharmony_ci		     struct thermal_cooling_device *);
648c2ecf20Sopenharmony_ci	int (*unbind) (struct thermal_zone_device *,
658c2ecf20Sopenharmony_ci		       struct thermal_cooling_device *);
668c2ecf20Sopenharmony_ci	int (*get_temp) (struct thermal_zone_device *, int *);
678c2ecf20Sopenharmony_ci	int (*set_trips) (struct thermal_zone_device *, int, int);
688c2ecf20Sopenharmony_ci	int (*change_mode) (struct thermal_zone_device *,
698c2ecf20Sopenharmony_ci		enum thermal_device_mode);
708c2ecf20Sopenharmony_ci	int (*get_trip_type) (struct thermal_zone_device *, int,
718c2ecf20Sopenharmony_ci		enum thermal_trip_type *);
728c2ecf20Sopenharmony_ci	int (*get_trip_temp) (struct thermal_zone_device *, int, int *);
738c2ecf20Sopenharmony_ci	int (*set_trip_temp) (struct thermal_zone_device *, int, int);
748c2ecf20Sopenharmony_ci	int (*get_trip_hyst) (struct thermal_zone_device *, int, int *);
758c2ecf20Sopenharmony_ci	int (*set_trip_hyst) (struct thermal_zone_device *, int, int);
768c2ecf20Sopenharmony_ci	int (*get_crit_temp) (struct thermal_zone_device *, int *);
778c2ecf20Sopenharmony_ci	int (*set_emul_temp) (struct thermal_zone_device *, int);
788c2ecf20Sopenharmony_ci	int (*get_trend) (struct thermal_zone_device *, int,
798c2ecf20Sopenharmony_ci			  enum thermal_trend *);
808c2ecf20Sopenharmony_ci	int (*notify) (struct thermal_zone_device *, int,
818c2ecf20Sopenharmony_ci		       enum thermal_trip_type);
828c2ecf20Sopenharmony_ci};
838c2ecf20Sopenharmony_ci
848c2ecf20Sopenharmony_cistruct thermal_cooling_device_ops {
858c2ecf20Sopenharmony_ci	int (*get_max_state) (struct thermal_cooling_device *, unsigned long *);
868c2ecf20Sopenharmony_ci	int (*get_cur_state) (struct thermal_cooling_device *, unsigned long *);
878c2ecf20Sopenharmony_ci	int (*set_cur_state) (struct thermal_cooling_device *, unsigned long);
888c2ecf20Sopenharmony_ci	int (*get_requested_power)(struct thermal_cooling_device *, u32 *);
898c2ecf20Sopenharmony_ci	int (*state2power)(struct thermal_cooling_device *, unsigned long, u32 *);
908c2ecf20Sopenharmony_ci	int (*power2state)(struct thermal_cooling_device *, u32, unsigned long *);
918c2ecf20Sopenharmony_ci};
928c2ecf20Sopenharmony_ci
938c2ecf20Sopenharmony_cistruct thermal_cooling_device {
948c2ecf20Sopenharmony_ci	int id;
958c2ecf20Sopenharmony_ci	char *type;
968c2ecf20Sopenharmony_ci	struct device device;
978c2ecf20Sopenharmony_ci	struct device_node *np;
988c2ecf20Sopenharmony_ci	void *devdata;
998c2ecf20Sopenharmony_ci	void *stats;
1008c2ecf20Sopenharmony_ci	const struct thermal_cooling_device_ops *ops;
1018c2ecf20Sopenharmony_ci	bool updated; /* true if the cooling device does not need update */
1028c2ecf20Sopenharmony_ci	struct mutex lock; /* protect thermal_instances list */
1038c2ecf20Sopenharmony_ci	struct list_head thermal_instances;
1048c2ecf20Sopenharmony_ci	struct list_head node;
1058c2ecf20Sopenharmony_ci};
1068c2ecf20Sopenharmony_ci
1078c2ecf20Sopenharmony_ci/**
1088c2ecf20Sopenharmony_ci * struct thermal_zone_device - structure for a thermal zone
1098c2ecf20Sopenharmony_ci * @id:		unique id number for each thermal zone
1108c2ecf20Sopenharmony_ci * @type:	the thermal zone device type
1118c2ecf20Sopenharmony_ci * @device:	&struct device for this thermal zone
1128c2ecf20Sopenharmony_ci * @trip_temp_attrs:	attributes for trip points for sysfs: trip temperature
1138c2ecf20Sopenharmony_ci * @trip_type_attrs:	attributes for trip points for sysfs: trip type
1148c2ecf20Sopenharmony_ci * @trip_hyst_attrs:	attributes for trip points for sysfs: trip hysteresis
1158c2ecf20Sopenharmony_ci * @mode:		current mode of this thermal zone
1168c2ecf20Sopenharmony_ci * @devdata:	private pointer for device private data
1178c2ecf20Sopenharmony_ci * @trips:	number of trip points the thermal zone supports
1188c2ecf20Sopenharmony_ci * @trips_disabled;	bitmap for disabled trips
1198c2ecf20Sopenharmony_ci * @passive_delay:	number of milliseconds to wait between polls when
1208c2ecf20Sopenharmony_ci *			performing passive cooling.
1218c2ecf20Sopenharmony_ci * @polling_delay:	number of milliseconds to wait between polls when
1228c2ecf20Sopenharmony_ci *			checking whether trip points have been crossed (0 for
1238c2ecf20Sopenharmony_ci *			interrupt driven systems)
1248c2ecf20Sopenharmony_ci * @temperature:	current temperature.  This is only for core code,
1258c2ecf20Sopenharmony_ci *			drivers should use thermal_zone_get_temp() to get the
1268c2ecf20Sopenharmony_ci *			current temperature
1278c2ecf20Sopenharmony_ci * @last_temperature:	previous temperature read
1288c2ecf20Sopenharmony_ci * @emul_temperature:	emulated temperature when using CONFIG_THERMAL_EMULATION
1298c2ecf20Sopenharmony_ci * @passive:		1 if you've crossed a passive trip point, 0 otherwise.
1308c2ecf20Sopenharmony_ci * @prev_low_trip:	the low current temperature if you've crossed a passive
1318c2ecf20Sopenharmony_ci			trip point.
1328c2ecf20Sopenharmony_ci * @prev_high_trip:	the above current temperature if you've crossed a
1338c2ecf20Sopenharmony_ci			passive trip point.
1348c2ecf20Sopenharmony_ci * @forced_passive:	If > 0, temperature at which to switch on all ACPI
1358c2ecf20Sopenharmony_ci *			processor cooling devices.  Currently only used by the
1368c2ecf20Sopenharmony_ci *			step-wise governor.
1378c2ecf20Sopenharmony_ci * @need_update:	if equals 1, thermal_zone_device_update needs to be invoked.
1388c2ecf20Sopenharmony_ci * @ops:	operations this &thermal_zone_device supports
1398c2ecf20Sopenharmony_ci * @tzp:	thermal zone parameters
1408c2ecf20Sopenharmony_ci * @governor:	pointer to the governor for this thermal zone
1418c2ecf20Sopenharmony_ci * @governor_data:	private pointer for governor data
1428c2ecf20Sopenharmony_ci * @thermal_instances:	list of &struct thermal_instance of this thermal zone
1438c2ecf20Sopenharmony_ci * @ida:	&struct ida to generate unique id for this zone's cooling
1448c2ecf20Sopenharmony_ci *		devices
1458c2ecf20Sopenharmony_ci * @lock:	lock to protect thermal_instances list
1468c2ecf20Sopenharmony_ci * @node:	node in thermal_tz_list (in thermal_core.c)
1478c2ecf20Sopenharmony_ci * @poll_queue:	delayed work for polling
1488c2ecf20Sopenharmony_ci * @notify_event: Last notification event
1498c2ecf20Sopenharmony_ci */
1508c2ecf20Sopenharmony_cistruct thermal_zone_device {
1518c2ecf20Sopenharmony_ci	int id;
1528c2ecf20Sopenharmony_ci	char type[THERMAL_NAME_LENGTH];
1538c2ecf20Sopenharmony_ci	struct device device;
1548c2ecf20Sopenharmony_ci	struct attribute_group trips_attribute_group;
1558c2ecf20Sopenharmony_ci	struct thermal_attr *trip_temp_attrs;
1568c2ecf20Sopenharmony_ci	struct thermal_attr *trip_type_attrs;
1578c2ecf20Sopenharmony_ci	struct thermal_attr *trip_hyst_attrs;
1588c2ecf20Sopenharmony_ci	enum thermal_device_mode mode;
1598c2ecf20Sopenharmony_ci	void *devdata;
1608c2ecf20Sopenharmony_ci	int trips;
1618c2ecf20Sopenharmony_ci	unsigned long trips_disabled;	/* bitmap for disabled trips */
1628c2ecf20Sopenharmony_ci	int passive_delay;
1638c2ecf20Sopenharmony_ci	int polling_delay;
1648c2ecf20Sopenharmony_ci	int temperature;
1658c2ecf20Sopenharmony_ci	int last_temperature;
1668c2ecf20Sopenharmony_ci	int emul_temperature;
1678c2ecf20Sopenharmony_ci	int passive;
1688c2ecf20Sopenharmony_ci	int prev_low_trip;
1698c2ecf20Sopenharmony_ci	int prev_high_trip;
1708c2ecf20Sopenharmony_ci	unsigned int forced_passive;
1718c2ecf20Sopenharmony_ci	atomic_t need_update;
1728c2ecf20Sopenharmony_ci	struct thermal_zone_device_ops *ops;
1738c2ecf20Sopenharmony_ci	struct thermal_zone_params *tzp;
1748c2ecf20Sopenharmony_ci	struct thermal_governor *governor;
1758c2ecf20Sopenharmony_ci	void *governor_data;
1768c2ecf20Sopenharmony_ci	struct list_head thermal_instances;
1778c2ecf20Sopenharmony_ci	struct ida ida;
1788c2ecf20Sopenharmony_ci	struct mutex lock;
1798c2ecf20Sopenharmony_ci	struct list_head node;
1808c2ecf20Sopenharmony_ci	struct delayed_work poll_queue;
1818c2ecf20Sopenharmony_ci	enum thermal_notify_event notify_event;
1828c2ecf20Sopenharmony_ci};
1838c2ecf20Sopenharmony_ci
1848c2ecf20Sopenharmony_ci/**
1858c2ecf20Sopenharmony_ci * struct thermal_governor - structure that holds thermal governor information
1868c2ecf20Sopenharmony_ci * @name:	name of the governor
1878c2ecf20Sopenharmony_ci * @bind_to_tz: callback called when binding to a thermal zone.  If it
1888c2ecf20Sopenharmony_ci *		returns 0, the governor is bound to the thermal zone,
1898c2ecf20Sopenharmony_ci *		otherwise it fails.
1908c2ecf20Sopenharmony_ci * @unbind_from_tz:	callback called when a governor is unbound from a
1918c2ecf20Sopenharmony_ci *			thermal zone.
1928c2ecf20Sopenharmony_ci * @throttle:	callback called for every trip point even if temperature is
1938c2ecf20Sopenharmony_ci *		below the trip point temperature
1948c2ecf20Sopenharmony_ci * @governor_list:	node in thermal_governor_list (in thermal_core.c)
1958c2ecf20Sopenharmony_ci */
1968c2ecf20Sopenharmony_cistruct thermal_governor {
1978c2ecf20Sopenharmony_ci	char name[THERMAL_NAME_LENGTH];
1988c2ecf20Sopenharmony_ci	int (*bind_to_tz)(struct thermal_zone_device *tz);
1998c2ecf20Sopenharmony_ci	void (*unbind_from_tz)(struct thermal_zone_device *tz);
2008c2ecf20Sopenharmony_ci	int (*throttle)(struct thermal_zone_device *tz, int trip);
2018c2ecf20Sopenharmony_ci	struct list_head	governor_list;
2028c2ecf20Sopenharmony_ci};
2038c2ecf20Sopenharmony_ci
2048c2ecf20Sopenharmony_ci/* Structure that holds binding parameters for a zone */
2058c2ecf20Sopenharmony_cistruct thermal_bind_params {
2068c2ecf20Sopenharmony_ci	struct thermal_cooling_device *cdev;
2078c2ecf20Sopenharmony_ci
2088c2ecf20Sopenharmony_ci	/*
2098c2ecf20Sopenharmony_ci	 * This is a measure of 'how effectively these devices can
2108c2ecf20Sopenharmony_ci	 * cool 'this' thermal zone. It shall be determined by
2118c2ecf20Sopenharmony_ci	 * platform characterization. This value is relative to the
2128c2ecf20Sopenharmony_ci	 * rest of the weights so a cooling device whose weight is
2138c2ecf20Sopenharmony_ci	 * double that of another cooling device is twice as
2148c2ecf20Sopenharmony_ci	 * effective. See Documentation/driver-api/thermal/sysfs-api.rst for more
2158c2ecf20Sopenharmony_ci	 * information.
2168c2ecf20Sopenharmony_ci	 */
2178c2ecf20Sopenharmony_ci	int weight;
2188c2ecf20Sopenharmony_ci
2198c2ecf20Sopenharmony_ci	/*
2208c2ecf20Sopenharmony_ci	 * This is a bit mask that gives the binding relation between this
2218c2ecf20Sopenharmony_ci	 * thermal zone and cdev, for a particular trip point.
2228c2ecf20Sopenharmony_ci	 * See Documentation/driver-api/thermal/sysfs-api.rst for more information.
2238c2ecf20Sopenharmony_ci	 */
2248c2ecf20Sopenharmony_ci	int trip_mask;
2258c2ecf20Sopenharmony_ci
2268c2ecf20Sopenharmony_ci	/*
2278c2ecf20Sopenharmony_ci	 * This is an array of cooling state limits. Must have exactly
2288c2ecf20Sopenharmony_ci	 * 2 * thermal_zone.number_of_trip_points. It is an array consisting
2298c2ecf20Sopenharmony_ci	 * of tuples <lower-state upper-state> of state limits. Each trip
2308c2ecf20Sopenharmony_ci	 * will be associated with one state limit tuple when binding.
2318c2ecf20Sopenharmony_ci	 * A NULL pointer means <THERMAL_NO_LIMITS THERMAL_NO_LIMITS>
2328c2ecf20Sopenharmony_ci	 * on all trips.
2338c2ecf20Sopenharmony_ci	 */
2348c2ecf20Sopenharmony_ci	unsigned long *binding_limits;
2358c2ecf20Sopenharmony_ci	int (*match) (struct thermal_zone_device *tz,
2368c2ecf20Sopenharmony_ci			struct thermal_cooling_device *cdev);
2378c2ecf20Sopenharmony_ci};
2388c2ecf20Sopenharmony_ci
2398c2ecf20Sopenharmony_ci/* Structure to define Thermal Zone parameters */
2408c2ecf20Sopenharmony_cistruct thermal_zone_params {
2418c2ecf20Sopenharmony_ci	char governor_name[THERMAL_NAME_LENGTH];
2428c2ecf20Sopenharmony_ci
2438c2ecf20Sopenharmony_ci	/*
2448c2ecf20Sopenharmony_ci	 * a boolean to indicate if the thermal to hwmon sysfs interface
2458c2ecf20Sopenharmony_ci	 * is required. when no_hwmon == false, a hwmon sysfs interface
2468c2ecf20Sopenharmony_ci	 * will be created. when no_hwmon == true, nothing will be done
2478c2ecf20Sopenharmony_ci	 */
2488c2ecf20Sopenharmony_ci	bool no_hwmon;
2498c2ecf20Sopenharmony_ci
2508c2ecf20Sopenharmony_ci	int num_tbps;	/* Number of tbp entries */
2518c2ecf20Sopenharmony_ci	struct thermal_bind_params *tbp;
2528c2ecf20Sopenharmony_ci
2538c2ecf20Sopenharmony_ci	/*
2548c2ecf20Sopenharmony_ci	 * Sustainable power (heat) that this thermal zone can dissipate in
2558c2ecf20Sopenharmony_ci	 * mW
2568c2ecf20Sopenharmony_ci	 */
2578c2ecf20Sopenharmony_ci	u32 sustainable_power;
2588c2ecf20Sopenharmony_ci
2598c2ecf20Sopenharmony_ci	/*
2608c2ecf20Sopenharmony_ci	 * Proportional parameter of the PID controller when
2618c2ecf20Sopenharmony_ci	 * overshooting (i.e., when temperature is below the target)
2628c2ecf20Sopenharmony_ci	 */
2638c2ecf20Sopenharmony_ci	s32 k_po;
2648c2ecf20Sopenharmony_ci
2658c2ecf20Sopenharmony_ci	/*
2668c2ecf20Sopenharmony_ci	 * Proportional parameter of the PID controller when
2678c2ecf20Sopenharmony_ci	 * undershooting
2688c2ecf20Sopenharmony_ci	 */
2698c2ecf20Sopenharmony_ci	s32 k_pu;
2708c2ecf20Sopenharmony_ci
2718c2ecf20Sopenharmony_ci	/* Integral parameter of the PID controller */
2728c2ecf20Sopenharmony_ci	s32 k_i;
2738c2ecf20Sopenharmony_ci
2748c2ecf20Sopenharmony_ci	/* Derivative parameter of the PID controller */
2758c2ecf20Sopenharmony_ci	s32 k_d;
2768c2ecf20Sopenharmony_ci
2778c2ecf20Sopenharmony_ci	/* threshold below which the error is no longer accumulated */
2788c2ecf20Sopenharmony_ci	s32 integral_cutoff;
2798c2ecf20Sopenharmony_ci
2808c2ecf20Sopenharmony_ci	/*
2818c2ecf20Sopenharmony_ci	 * @slope:	slope of a linear temperature adjustment curve.
2828c2ecf20Sopenharmony_ci	 * 		Used by thermal zone drivers.
2838c2ecf20Sopenharmony_ci	 */
2848c2ecf20Sopenharmony_ci	int slope;
2858c2ecf20Sopenharmony_ci	/*
2868c2ecf20Sopenharmony_ci	 * @offset:	offset of a linear temperature adjustment curve.
2878c2ecf20Sopenharmony_ci	 * 		Used by thermal zone drivers (default 0).
2888c2ecf20Sopenharmony_ci	 */
2898c2ecf20Sopenharmony_ci	int offset;
2908c2ecf20Sopenharmony_ci};
2918c2ecf20Sopenharmony_ci
2928c2ecf20Sopenharmony_ci/**
2938c2ecf20Sopenharmony_ci * struct thermal_zone_of_device_ops - scallbacks for handling DT based zones
2948c2ecf20Sopenharmony_ci *
2958c2ecf20Sopenharmony_ci * Mandatory:
2968c2ecf20Sopenharmony_ci * @get_temp: a pointer to a function that reads the sensor temperature.
2978c2ecf20Sopenharmony_ci *
2988c2ecf20Sopenharmony_ci * Optional:
2998c2ecf20Sopenharmony_ci * @get_trend: a pointer to a function that reads the sensor temperature trend.
3008c2ecf20Sopenharmony_ci * @set_trips: a pointer to a function that sets a temperature window. When
3018c2ecf20Sopenharmony_ci *	       this window is left the driver must inform the thermal core via
3028c2ecf20Sopenharmony_ci *	       thermal_zone_device_update.
3038c2ecf20Sopenharmony_ci * @set_emul_temp: a pointer to a function that sets sensor emulated
3048c2ecf20Sopenharmony_ci *		   temperature.
3058c2ecf20Sopenharmony_ci * @set_trip_temp: a pointer to a function that sets the trip temperature on
3068c2ecf20Sopenharmony_ci *		   hardware.
3078c2ecf20Sopenharmony_ci */
3088c2ecf20Sopenharmony_cistruct thermal_zone_of_device_ops {
3098c2ecf20Sopenharmony_ci	int (*get_temp)(void *, int *);
3108c2ecf20Sopenharmony_ci	int (*get_trend)(void *, int, enum thermal_trend *);
3118c2ecf20Sopenharmony_ci	int (*set_trips)(void *, int, int);
3128c2ecf20Sopenharmony_ci	int (*set_emul_temp)(void *, int);
3138c2ecf20Sopenharmony_ci	int (*set_trip_temp)(void *, int, int);
3148c2ecf20Sopenharmony_ci};
3158c2ecf20Sopenharmony_ci
3168c2ecf20Sopenharmony_ci/* Function declarations */
3178c2ecf20Sopenharmony_ci#ifdef CONFIG_THERMAL_OF
3188c2ecf20Sopenharmony_ciint thermal_zone_of_get_sensor_id(struct device_node *tz_np,
3198c2ecf20Sopenharmony_ci				  struct device_node *sensor_np,
3208c2ecf20Sopenharmony_ci				  u32 *id);
3218c2ecf20Sopenharmony_cistruct thermal_zone_device *
3228c2ecf20Sopenharmony_cithermal_zone_of_sensor_register(struct device *dev, int id, void *data,
3238c2ecf20Sopenharmony_ci				const struct thermal_zone_of_device_ops *ops);
3248c2ecf20Sopenharmony_civoid thermal_zone_of_sensor_unregister(struct device *dev,
3258c2ecf20Sopenharmony_ci				       struct thermal_zone_device *tz);
3268c2ecf20Sopenharmony_cistruct thermal_zone_device *devm_thermal_zone_of_sensor_register(
3278c2ecf20Sopenharmony_ci		struct device *dev, int id, void *data,
3288c2ecf20Sopenharmony_ci		const struct thermal_zone_of_device_ops *ops);
3298c2ecf20Sopenharmony_civoid devm_thermal_zone_of_sensor_unregister(struct device *dev,
3308c2ecf20Sopenharmony_ci					    struct thermal_zone_device *tz);
3318c2ecf20Sopenharmony_ci#else
3328c2ecf20Sopenharmony_ci
3338c2ecf20Sopenharmony_cistatic inline int thermal_zone_of_get_sensor_id(struct device_node *tz_np,
3348c2ecf20Sopenharmony_ci					 struct device_node *sensor_np,
3358c2ecf20Sopenharmony_ci					 u32 *id)
3368c2ecf20Sopenharmony_ci{
3378c2ecf20Sopenharmony_ci	return -ENOENT;
3388c2ecf20Sopenharmony_ci}
3398c2ecf20Sopenharmony_cistatic inline struct thermal_zone_device *
3408c2ecf20Sopenharmony_cithermal_zone_of_sensor_register(struct device *dev, int id, void *data,
3418c2ecf20Sopenharmony_ci				const struct thermal_zone_of_device_ops *ops)
3428c2ecf20Sopenharmony_ci{
3438c2ecf20Sopenharmony_ci	return ERR_PTR(-ENODEV);
3448c2ecf20Sopenharmony_ci}
3458c2ecf20Sopenharmony_ci
3468c2ecf20Sopenharmony_cistatic inline
3478c2ecf20Sopenharmony_civoid thermal_zone_of_sensor_unregister(struct device *dev,
3488c2ecf20Sopenharmony_ci				       struct thermal_zone_device *tz)
3498c2ecf20Sopenharmony_ci{
3508c2ecf20Sopenharmony_ci}
3518c2ecf20Sopenharmony_ci
3528c2ecf20Sopenharmony_cistatic inline struct thermal_zone_device *devm_thermal_zone_of_sensor_register(
3538c2ecf20Sopenharmony_ci		struct device *dev, int id, void *data,
3548c2ecf20Sopenharmony_ci		const struct thermal_zone_of_device_ops *ops)
3558c2ecf20Sopenharmony_ci{
3568c2ecf20Sopenharmony_ci	return ERR_PTR(-ENODEV);
3578c2ecf20Sopenharmony_ci}
3588c2ecf20Sopenharmony_ci
3598c2ecf20Sopenharmony_cistatic inline
3608c2ecf20Sopenharmony_civoid devm_thermal_zone_of_sensor_unregister(struct device *dev,
3618c2ecf20Sopenharmony_ci					    struct thermal_zone_device *tz)
3628c2ecf20Sopenharmony_ci{
3638c2ecf20Sopenharmony_ci}
3648c2ecf20Sopenharmony_ci
3658c2ecf20Sopenharmony_ci#endif
3668c2ecf20Sopenharmony_ci
3678c2ecf20Sopenharmony_ci#ifdef CONFIG_THERMAL
3688c2ecf20Sopenharmony_cistruct thermal_zone_device *thermal_zone_device_register(const char *, int, int,
3698c2ecf20Sopenharmony_ci		void *, struct thermal_zone_device_ops *,
3708c2ecf20Sopenharmony_ci		struct thermal_zone_params *, int, int);
3718c2ecf20Sopenharmony_civoid thermal_zone_device_unregister(struct thermal_zone_device *);
3728c2ecf20Sopenharmony_ci
3738c2ecf20Sopenharmony_ciint thermal_zone_bind_cooling_device(struct thermal_zone_device *, int,
3748c2ecf20Sopenharmony_ci				     struct thermal_cooling_device *,
3758c2ecf20Sopenharmony_ci				     unsigned long, unsigned long,
3768c2ecf20Sopenharmony_ci				     unsigned int);
3778c2ecf20Sopenharmony_ciint thermal_zone_unbind_cooling_device(struct thermal_zone_device *, int,
3788c2ecf20Sopenharmony_ci				       struct thermal_cooling_device *);
3798c2ecf20Sopenharmony_civoid thermal_zone_device_update(struct thermal_zone_device *,
3808c2ecf20Sopenharmony_ci				enum thermal_notify_event);
3818c2ecf20Sopenharmony_ci
3828c2ecf20Sopenharmony_cistruct thermal_cooling_device *thermal_cooling_device_register(const char *,
3838c2ecf20Sopenharmony_ci		void *, const struct thermal_cooling_device_ops *);
3848c2ecf20Sopenharmony_cistruct thermal_cooling_device *
3858c2ecf20Sopenharmony_cithermal_of_cooling_device_register(struct device_node *np, const char *, void *,
3868c2ecf20Sopenharmony_ci				   const struct thermal_cooling_device_ops *);
3878c2ecf20Sopenharmony_cistruct thermal_cooling_device *
3888c2ecf20Sopenharmony_cidevm_thermal_of_cooling_device_register(struct device *dev,
3898c2ecf20Sopenharmony_ci				struct device_node *np,
3908c2ecf20Sopenharmony_ci				char *type, void *devdata,
3918c2ecf20Sopenharmony_ci				const struct thermal_cooling_device_ops *ops);
3928c2ecf20Sopenharmony_civoid thermal_cooling_device_unregister(struct thermal_cooling_device *);
3938c2ecf20Sopenharmony_cistruct thermal_zone_device *thermal_zone_get_zone_by_name(const char *name);
3948c2ecf20Sopenharmony_ciint thermal_zone_get_temp(struct thermal_zone_device *tz, int *temp);
3958c2ecf20Sopenharmony_ciint thermal_zone_get_slope(struct thermal_zone_device *tz);
3968c2ecf20Sopenharmony_ciint thermal_zone_get_offset(struct thermal_zone_device *tz);
3978c2ecf20Sopenharmony_ci
3988c2ecf20Sopenharmony_civoid thermal_cdev_update(struct thermal_cooling_device *);
3998c2ecf20Sopenharmony_civoid thermal_notify_framework(struct thermal_zone_device *, int);
4008c2ecf20Sopenharmony_ciint thermal_zone_device_enable(struct thermal_zone_device *tz);
4018c2ecf20Sopenharmony_ciint thermal_zone_device_disable(struct thermal_zone_device *tz);
4028c2ecf20Sopenharmony_ci#else
4038c2ecf20Sopenharmony_cistatic inline struct thermal_zone_device *thermal_zone_device_register(
4048c2ecf20Sopenharmony_ci	const char *type, int trips, int mask, void *devdata,
4058c2ecf20Sopenharmony_ci	struct thermal_zone_device_ops *ops,
4068c2ecf20Sopenharmony_ci	struct thermal_zone_params *tzp,
4078c2ecf20Sopenharmony_ci	int passive_delay, int polling_delay)
4088c2ecf20Sopenharmony_ci{ return ERR_PTR(-ENODEV); }
4098c2ecf20Sopenharmony_cistatic inline void thermal_zone_device_unregister(
4108c2ecf20Sopenharmony_ci	struct thermal_zone_device *tz)
4118c2ecf20Sopenharmony_ci{ }
4128c2ecf20Sopenharmony_cistatic inline struct thermal_cooling_device *
4138c2ecf20Sopenharmony_cithermal_cooling_device_register(const char *type, void *devdata,
4148c2ecf20Sopenharmony_ci	const struct thermal_cooling_device_ops *ops)
4158c2ecf20Sopenharmony_ci{ return ERR_PTR(-ENODEV); }
4168c2ecf20Sopenharmony_cistatic inline struct thermal_cooling_device *
4178c2ecf20Sopenharmony_cithermal_of_cooling_device_register(struct device_node *np,
4188c2ecf20Sopenharmony_ci	const char *type, void *devdata,
4198c2ecf20Sopenharmony_ci	const struct thermal_cooling_device_ops *ops)
4208c2ecf20Sopenharmony_ci{ return ERR_PTR(-ENODEV); }
4218c2ecf20Sopenharmony_cistatic inline struct thermal_cooling_device *
4228c2ecf20Sopenharmony_cidevm_thermal_of_cooling_device_register(struct device *dev,
4238c2ecf20Sopenharmony_ci				struct device_node *np,
4248c2ecf20Sopenharmony_ci				char *type, void *devdata,
4258c2ecf20Sopenharmony_ci				const struct thermal_cooling_device_ops *ops)
4268c2ecf20Sopenharmony_ci{
4278c2ecf20Sopenharmony_ci	return ERR_PTR(-ENODEV);
4288c2ecf20Sopenharmony_ci}
4298c2ecf20Sopenharmony_cistatic inline void thermal_cooling_device_unregister(
4308c2ecf20Sopenharmony_ci	struct thermal_cooling_device *cdev)
4318c2ecf20Sopenharmony_ci{ }
4328c2ecf20Sopenharmony_cistatic inline struct thermal_zone_device *thermal_zone_get_zone_by_name(
4338c2ecf20Sopenharmony_ci		const char *name)
4348c2ecf20Sopenharmony_ci{ return ERR_PTR(-ENODEV); }
4358c2ecf20Sopenharmony_cistatic inline int thermal_zone_get_temp(
4368c2ecf20Sopenharmony_ci		struct thermal_zone_device *tz, int *temp)
4378c2ecf20Sopenharmony_ci{ return -ENODEV; }
4388c2ecf20Sopenharmony_cistatic inline int thermal_zone_get_slope(
4398c2ecf20Sopenharmony_ci		struct thermal_zone_device *tz)
4408c2ecf20Sopenharmony_ci{ return -ENODEV; }
4418c2ecf20Sopenharmony_cistatic inline int thermal_zone_get_offset(
4428c2ecf20Sopenharmony_ci		struct thermal_zone_device *tz)
4438c2ecf20Sopenharmony_ci{ return -ENODEV; }
4448c2ecf20Sopenharmony_ci
4458c2ecf20Sopenharmony_cistatic inline void thermal_cdev_update(struct thermal_cooling_device *cdev)
4468c2ecf20Sopenharmony_ci{ }
4478c2ecf20Sopenharmony_cistatic inline void thermal_notify_framework(struct thermal_zone_device *tz,
4488c2ecf20Sopenharmony_ci	int trip)
4498c2ecf20Sopenharmony_ci{ }
4508c2ecf20Sopenharmony_ci
4518c2ecf20Sopenharmony_cistatic inline int thermal_zone_device_enable(struct thermal_zone_device *tz)
4528c2ecf20Sopenharmony_ci{ return -ENODEV; }
4538c2ecf20Sopenharmony_ci
4548c2ecf20Sopenharmony_cistatic inline int thermal_zone_device_disable(struct thermal_zone_device *tz)
4558c2ecf20Sopenharmony_ci{ return -ENODEV; }
4568c2ecf20Sopenharmony_ci#endif /* CONFIG_THERMAL */
4578c2ecf20Sopenharmony_ci
4588c2ecf20Sopenharmony_ci#endif /* __THERMAL_H__ */
459