Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) ===================================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) Generic Thermal Sysfs driver How To
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3) ===================================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5) Written by Sujith Thomas <sujith.thomas@intel.com>, Zhang Rui <rui.zhang@intel.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7) Updated: 2 January 2008
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9) Copyright (c)  2008 Intel Corporation
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) 0. Introduction
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) ===============
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) The generic thermal sysfs provides a set of interfaces for thermal zone
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) devices (sensors) and thermal cooling devices (fan, processor...) to register
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) with the thermal management solution and to be a part of it.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) This how-to focuses on enabling new thermal zone and cooling devices to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) participate in thermal management.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) This solution is platform independent and any type of thermal zone devices
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) and cooling devices should be able to make use of the infrastructure.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) The main task of the thermal sysfs driver is to expose thermal zone attributes
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) as well as cooling device attributes to the user space.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) An intelligent thermal management application can make decisions based on
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) inputs from thermal zone attributes (the current temperature and trip point
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) temperature) and throttle appropriate devices.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) - `[0-*]`	denotes any positive number starting from 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) - `[1-*]`	denotes any positive number starting from 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) 1. thermal sysfs driver interface functions
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) ===========================================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) 1.1 thermal zone device interface
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) ---------------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39)     ::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) 	struct thermal_zone_device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) 	*thermal_zone_device_register(char *type,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) 				      int trips, int mask, void *devdata,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) 				      struct thermal_zone_device_ops *ops,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) 				      const struct thermal_zone_params *tzp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) 				      int passive_delay, int polling_delay))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48)     This interface function adds a new thermal zone device (sensor) to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49)     /sys/class/thermal folder as `thermal_zone[0-*]`. It tries to bind all the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50)     thermal cooling devices registered at the same time.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52)     type:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) 	the thermal zone type.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54)     trips:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) 	the total number of trip points this thermal zone supports.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56)     mask:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) 	Bit string: If 'n'th bit is set, then trip point 'n' is writeable.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58)     devdata:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) 	device private data
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60)     ops:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) 	thermal zone device call-backs.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) 	.bind:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) 		bind the thermal zone device with a thermal cooling device.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) 	.unbind:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) 		unbind the thermal zone device with a thermal cooling device.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) 	.get_temp:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) 		get the current temperature of the thermal zone.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) 	.set_trips:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) 		    set the trip points window. Whenever the current temperature
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) 		    is updated, the trip points immediately below and above the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) 		    current temperature are found.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) 	.get_mode:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) 		   get the current mode (enabled/disabled) of the thermal zone.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) 			- "enabled" means the kernel thermal management is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) 			  enabled.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) 			- "disabled" will prevent kernel thermal driver action
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) 			  upon trip points so that user applications can take
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) 			  charge of thermal management.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) 	.set_mode:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) 		set the mode (enabled/disabled) of the thermal zone.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) 	.get_trip_type:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) 		get the type of certain trip point.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) 	.get_trip_temp:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) 			get the temperature above which the certain trip point
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) 			will be fired.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) 	.set_emul_temp:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) 			set the emulation temperature which helps in debugging
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) 			different threshold temperature points.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91)     tzp:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) 	thermal zone platform parameters.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93)     passive_delay:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) 	number of milliseconds to wait between polls when
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) 	performing passive cooling.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96)     polling_delay:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) 	number of milliseconds to wait between polls when checking
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) 	whether trip points have been crossed (0 for interrupt driven systems).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100)     ::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) 	void thermal_zone_device_unregister(struct thermal_zone_device *tz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104)     This interface function removes the thermal zone device.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105)     It deletes the corresponding entry from /sys/class/thermal folder and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106)     unbinds all the thermal cooling devices it uses.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) 	::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) 	   struct thermal_zone_device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) 	   *thermal_zone_of_sensor_register(struct device *dev, int sensor_id,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) 				void *data,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) 				const struct thermal_zone_of_device_ops *ops)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) 	This interface adds a new sensor to a DT thermal zone.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) 	This function will search the list of thermal zones described in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) 	device tree and look for the zone that refer to the sensor device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) 	pointed by dev->of_node as temperature providers. For the zone
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) 	pointing to the sensor node, the sensor will be added to the DT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) 	thermal zone device.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) 	The parameters for this interface are:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) 	dev:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) 			Device node of sensor containing valid node pointer in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) 			dev->of_node.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) 	sensor_id:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) 			a sensor identifier, in case the sensor IP has more
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) 			than one sensors
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) 	data:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) 			a private pointer (owned by the caller) that will be
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) 			passed back, when a temperature reading is needed.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) 	ops:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) 			`struct thermal_zone_of_device_ops *`.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) 			==============  =======================================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) 			get_temp	a pointer to a function that reads the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) 					sensor temperature. This is mandatory
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) 					callback provided by sensor driver.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) 			set_trips	a pointer to a function that sets a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) 					temperature window. When this window is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) 					left the driver must inform the thermal
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) 					core via thermal_zone_device_update.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) 			get_trend 	a pointer to a function that reads the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) 					sensor temperature trend.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) 			set_emul_temp	a pointer to a function that sets
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) 					sensor emulated temperature.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) 			==============  =======================================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) 	The thermal zone temperature is provided by the get_temp() function
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) 	pointer of thermal_zone_of_device_ops. When called, it will
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) 	have the private pointer @data back.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) 	It returns error pointer if fails otherwise valid thermal zone device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) 	handle. Caller should check the return handle with IS_ERR() for finding
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) 	whether success or not.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) 	::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) 	    void thermal_zone_of_sensor_unregister(struct device *dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) 						   struct thermal_zone_device *tzd)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) 	This interface unregisters a sensor from a DT thermal zone which was
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) 	successfully added by interface thermal_zone_of_sensor_register().
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) 	This function removes the sensor callbacks and private data from the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) 	thermal zone device registered with thermal_zone_of_sensor_register()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) 	interface. It will also silent the zone by remove the .get_temp() and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) 	get_trend() thermal zone device callbacks.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) 	::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) 	  struct thermal_zone_device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) 	  *devm_thermal_zone_of_sensor_register(struct device *dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) 				int sensor_id,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) 				void *data,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) 				const struct thermal_zone_of_device_ops *ops)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) 	This interface is resource managed version of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) 	thermal_zone_of_sensor_register().
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) 	All details of thermal_zone_of_sensor_register() described in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) 	section 1.1.3 is applicable here.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) 	The benefit of using this interface to register sensor is that it
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) 	is not require to explicitly call thermal_zone_of_sensor_unregister()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) 	in error path or during driver unbinding as this is done by driver
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) 	resource manager.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) 	::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) 		void devm_thermal_zone_of_sensor_unregister(struct device *dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) 						struct thermal_zone_device *tzd)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) 	This interface is resource managed version of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) 	thermal_zone_of_sensor_unregister().
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) 	All details of thermal_zone_of_sensor_unregister() described in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) 	section 1.1.4 is applicable here.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) 	Normally this function will not need to be called and the resource
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) 	management code will ensure that the resource is freed.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) 	::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) 		int thermal_zone_get_slope(struct thermal_zone_device *tz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) 	This interface is used to read the slope attribute value
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) 	for the thermal zone device, which might be useful for platform
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) 	drivers for temperature calculations.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) 	::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) 		int thermal_zone_get_offset(struct thermal_zone_device *tz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) 	This interface is used to read the offset attribute value
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) 	for the thermal zone device, which might be useful for platform
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) 	drivers for temperature calculations.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) 1.2 thermal cooling device interface
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) ------------------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221)     ::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) 	struct thermal_cooling_device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) 	*thermal_cooling_device_register(char *name,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) 			void *devdata, struct thermal_cooling_device_ops *)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227)     This interface function adds a new thermal cooling device (fan/processor/...)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228)     to /sys/class/thermal/ folder as `cooling_device[0-*]`. It tries to bind itself
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229)     to all the thermal zone devices registered at the same time.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231)     name:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) 	the cooling device name.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233)     devdata:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) 	device private data.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235)     ops:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) 	thermal cooling devices call-backs.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) 	.get_max_state:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) 		get the Maximum throttle state of the cooling device.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) 	.get_cur_state:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) 		get the Currently requested throttle state of the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) 		cooling device.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) 	.set_cur_state:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) 		set the Current throttle state of the cooling device.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246)     ::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) 	void thermal_cooling_device_unregister(struct thermal_cooling_device *cdev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250)     This interface function removes the thermal cooling device.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251)     It deletes the corresponding entry from /sys/class/thermal folder and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252)     unbinds itself from all the thermal zone devices using it.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) 1.3 interface for binding a thermal zone device with a thermal cooling device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) -----------------------------------------------------------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257)     ::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) 	int thermal_zone_bind_cooling_device(struct thermal_zone_device *tz,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) 		int trip, struct thermal_cooling_device *cdev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) 		unsigned long upper, unsigned long lower, unsigned int weight);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263)     This interface function binds a thermal cooling device to a particular trip
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264)     point of a thermal zone device.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266)     This function is usually called in the thermal zone device .bind callback.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268)     tz:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) 	  the thermal zone device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270)     cdev:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) 	  thermal cooling device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272)     trip:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) 	  indicates which trip point in this thermal zone the cooling device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) 	  is associated with.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275)     upper:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) 	  the Maximum cooling state for this trip point.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) 	  THERMAL_NO_LIMIT means no upper limit,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) 	  and the cooling device can be in max_state.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279)     lower:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) 	  the Minimum cooling state can be used for this trip point.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) 	  THERMAL_NO_LIMIT means no lower limit,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) 	  and the cooling device can be in cooling state 0.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283)     weight:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) 	  the influence of this cooling device in this thermal
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) 	  zone.  See 1.4.1 below for more information.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287)     ::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) 	int thermal_zone_unbind_cooling_device(struct thermal_zone_device *tz,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) 				int trip, struct thermal_cooling_device *cdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292)     This interface function unbinds a thermal cooling device from a particular
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293)     trip point of a thermal zone device. This function is usually called in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294)     the thermal zone device .unbind callback.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296)     tz:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) 	the thermal zone device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298)     cdev:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) 	thermal cooling device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300)     trip:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) 	indicates which trip point in this thermal zone the cooling device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) 	is associated with.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) 1.4 Thermal Zone Parameters
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) ---------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307)     ::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) 	struct thermal_bind_params
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311)     This structure defines the following parameters that are used to bind
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312)     a zone with a cooling device for a particular trip point.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314)     .cdev:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315) 	     The cooling device pointer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316)     .weight:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) 	     The 'influence' of a particular cooling device on this
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) 	     zone. This is relative to the rest of the cooling
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319) 	     devices. For example, if all cooling devices have a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320) 	     weight of 1, then they all contribute the same. You can
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321) 	     use percentages if you want, but it's not mandatory. A
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322) 	     weight of 0 means that this cooling device doesn't
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323) 	     contribute to the cooling of this zone unless all cooling
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324) 	     devices have a weight of 0. If all weights are 0, then
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325) 	     they all contribute the same.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326)     .trip_mask:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) 	       This is a bit mask that gives the binding relation between
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328) 	       this thermal zone and cdev, for a particular trip point.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329) 	       If nth bit is set, then the cdev and thermal zone are bound
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330) 	       for trip point n.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331)     .binding_limits:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332) 		     This is an array of cooling state limits. Must have
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333) 		     exactly 2 * thermal_zone.number_of_trip_points. It is an
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334) 		     array consisting of tuples <lower-state upper-state> of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335) 		     state limits. Each trip will be associated with one state
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336) 		     limit tuple when binding. A NULL pointer means
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337) 		     <THERMAL_NO_LIMITS THERMAL_NO_LIMITS> on all trips.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338) 		     These limits are used when binding a cdev to a trip point.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339)     .match:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340) 	    This call back returns success(0) if the 'tz and cdev' need to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341) 	    be bound, as per platform data.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343)     ::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345) 	struct thermal_zone_params
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347)     This structure defines the platform level parameters for a thermal zone.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348)     This data, for each thermal zone should come from the platform layer.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349)     This is an optional feature where some platforms can choose not to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350)     provide this data.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352)     .governor_name:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353) 	       Name of the thermal governor used for this zone
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354)     .no_hwmon:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355) 	       a boolean to indicate if the thermal to hwmon sysfs interface
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356) 	       is required. when no_hwmon == false, a hwmon sysfs interface
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357) 	       will be created. when no_hwmon == true, nothing will be done.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358) 	       In case the thermal_zone_params is NULL, the hwmon interface
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359) 	       will be created (for backward compatibility).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360)     .num_tbps:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361) 	       Number of thermal_bind_params entries for this zone
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362)     .tbp:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363) 	       thermal_bind_params entries
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365) 2. sysfs attributes structure
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366) =============================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368) ==	================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369) RO	read only value
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370) WO	write only value
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 371) RW	read/write value
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 372) ==	================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 373) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 374) Thermal sysfs attributes will be represented under /sys/class/thermal.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 375) Hwmon sysfs I/F extension is also available under /sys/class/hwmon
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 376) if hwmon is compiled in or built as a module.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 377) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 378) Thermal zone device sys I/F, created once it's registered::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 379) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 380)   /sys/class/thermal/thermal_zone[0-*]:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 381)     |---type:			Type of the thermal zone
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 382)     |---temp:			Current temperature
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 383)     |---mode:			Working mode of the thermal zone
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 384)     |---policy:			Thermal governor used for this zone
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 385)     |---available_policies:	Available thermal governors for this zone
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 386)     |---trip_point_[0-*]_temp:	Trip point temperature
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 387)     |---trip_point_[0-*]_type:	Trip point type
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 388)     |---trip_point_[0-*]_hyst:	Hysteresis value for this trip point
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 389)     |---emul_temp:		Emulated temperature set node
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 390)     |---sustainable_power:      Sustainable dissipatable power
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 391)     |---k_po:                   Proportional term during temperature overshoot
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 392)     |---k_pu:                   Proportional term during temperature undershoot
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 393)     |---k_i:                    PID's integral term in the power allocator gov
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 394)     |---k_d:                    PID's derivative term in the power allocator
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 395)     |---integral_cutoff:        Offset above which errors are accumulated
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 396)     |---slope:                  Slope constant applied as linear extrapolation
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 397)     |---offset:                 Offset constant applied as linear extrapolation
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 398) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 399) Thermal cooling device sys I/F, created once it's registered::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 400) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 401)   /sys/class/thermal/cooling_device[0-*]:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 402)     |---type:			Type of the cooling device(processor/fan/...)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 403)     |---max_state:		Maximum cooling state of the cooling device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 404)     |---cur_state:		Current cooling state of the cooling device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 405)     |---stats:			Directory containing cooling device's statistics
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 406)     |---stats/reset:		Writing any value resets the statistics
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 407)     |---stats/time_in_state_ms:	Time (msec) spent in various cooling states
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 408)     |---stats/total_trans:	Total number of times cooling state is changed
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 409)     |---stats/trans_table:	Cooing state transition table
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 410) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 411) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 412) Then next two dynamic attributes are created/removed in pairs. They represent
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 413) the relationship between a thermal zone and its associated cooling device.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 414) They are created/removed for each successful execution of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 415) thermal_zone_bind_cooling_device/thermal_zone_unbind_cooling_device.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 416) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 417) ::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 418) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 419)   /sys/class/thermal/thermal_zone[0-*]:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 420)     |---cdev[0-*]:		[0-*]th cooling device in current thermal zone
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 421)     |---cdev[0-*]_trip_point:	Trip point that cdev[0-*] is associated with
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 422)     |---cdev[0-*]_weight:       Influence of the cooling device in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 423) 				this thermal zone
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 424) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 425) Besides the thermal zone device sysfs I/F and cooling device sysfs I/F,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 426) the generic thermal driver also creates a hwmon sysfs I/F for each _type_
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 427) of thermal zone device. E.g. the generic thermal driver registers one hwmon
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 428) class device and build the associated hwmon sysfs I/F for all the registered
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 429) ACPI thermal zones.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 430) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 431) ::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 432) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 433)   /sys/class/hwmon/hwmon[0-*]:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 434)     |---name:			The type of the thermal zone devices
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 435)     |---temp[1-*]_input:	The current temperature of thermal zone [1-*]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 436)     |---temp[1-*]_critical:	The critical trip point of thermal zone [1-*]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 437) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 438) Please read Documentation/hwmon/sysfs-interface.rst for additional information.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 439) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 440) Thermal zone attributes
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 441) -----------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 442) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 443) type
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 444) 	Strings which represent the thermal zone type.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 445) 	This is given by thermal zone driver as part of registration.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 446) 	E.g: "acpitz" indicates it's an ACPI thermal device.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 447) 	In order to keep it consistent with hwmon sys attribute; this should
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 448) 	be a short, lowercase string, not containing spaces nor dashes.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 449) 	RO, Required
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 450) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 451) temp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 452) 	Current temperature as reported by thermal zone (sensor).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 453) 	Unit: millidegree Celsius
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 454) 	RO, Required
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 455) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 456) mode
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 457) 	One of the predefined values in [enabled, disabled].
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 458) 	This file gives information about the algorithm that is currently
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 459) 	managing the thermal zone. It can be either default kernel based
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 460) 	algorithm or user space application.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 461) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 462) 	enabled
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 463) 			  enable Kernel Thermal management.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 464) 	disabled
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 465) 			  Preventing kernel thermal zone driver actions upon
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 466) 			  trip points so that user application can take full
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 467) 			  charge of the thermal management.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 468) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 469) 	RW, Optional
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 470) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 471) policy
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 472) 	One of the various thermal governors used for a particular zone.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 473) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 474) 	RW, Required
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 475) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 476) available_policies
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 477) 	Available thermal governors which can be used for a particular zone.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 478) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 479) 	RO, Required
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 480) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 481) `trip_point_[0-*]_temp`
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 482) 	The temperature above which trip point will be fired.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 483) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 484) 	Unit: millidegree Celsius
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 485) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 486) 	RO, Optional
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 487) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 488) `trip_point_[0-*]_type`
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 489) 	Strings which indicate the type of the trip point.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 490) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 491) 	E.g. it can be one of critical, hot, passive, `active[0-*]` for ACPI
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 492) 	thermal zone.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 493) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 494) 	RO, Optional
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 495) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 496) `trip_point_[0-*]_hyst`
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 497) 	The hysteresis value for a trip point, represented as an integer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 498) 	Unit: Celsius
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 499) 	RW, Optional
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 500) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 501) `cdev[0-*]`
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 502) 	Sysfs link to the thermal cooling device node where the sys I/F
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 503) 	for cooling device throttling control represents.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 504) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 505) 	RO, Optional
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 506) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 507) `cdev[0-*]_trip_point`
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 508) 	The trip point in this thermal zone which `cdev[0-*]` is associated
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 509) 	with; -1 means the cooling device is not associated with any trip
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 510) 	point.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 511) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 512) 	RO, Optional
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 513) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 514) `cdev[0-*]_weight`
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 515) 	The influence of `cdev[0-*]` in this thermal zone. This value
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 516) 	is relative to the rest of cooling devices in the thermal
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 517) 	zone. For example, if a cooling device has a weight double
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 518) 	than that of other, it's twice as effective in cooling the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 519) 	thermal zone.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 520) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 521) 	RW, Optional
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 522) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 523) passive
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 524) 	Attribute is only present for zones in which the passive cooling
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 525) 	policy is not supported by native thermal driver. Default is zero
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 526) 	and can be set to a temperature (in millidegrees) to enable a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 527) 	passive trip point for the zone. Activation is done by polling with
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 528) 	an interval of 1 second.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 529) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 530) 	Unit: millidegrees Celsius
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 531) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 532) 	Valid values: 0 (disabled) or greater than 1000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 533) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 534) 	RW, Optional
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 535) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 536) emul_temp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 537) 	Interface to set the emulated temperature method in thermal zone
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 538) 	(sensor). After setting this temperature, the thermal zone may pass
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 539) 	this temperature to platform emulation function if registered or
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 540) 	cache it locally. This is useful in debugging different temperature
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 541) 	threshold and its associated cooling action. This is write only node
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 542) 	and writing 0 on this node should disable emulation.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 543) 	Unit: millidegree Celsius
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 544) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 545) 	WO, Optional
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 546) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 547) 	  WARNING:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 548) 	    Be careful while enabling this option on production systems,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 549) 	    because userland can easily disable the thermal policy by simply
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 550) 	    flooding this sysfs node with low temperature values.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 551) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 552) sustainable_power
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 553) 	An estimate of the sustained power that can be dissipated by
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 554) 	the thermal zone. Used by the power allocator governor. For
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 555) 	more information see Documentation/driver-api/thermal/power_allocator.rst
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 556) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 557) 	Unit: milliwatts
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 558) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 559) 	RW, Optional
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 560) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 561) k_po
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 562) 	The proportional term of the power allocator governor's PID
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 563) 	controller during temperature overshoot. Temperature overshoot
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 564) 	is when the current temperature is above the "desired
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 565) 	temperature" trip point. For more information see
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 566) 	Documentation/driver-api/thermal/power_allocator.rst
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 567) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 568) 	RW, Optional
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 569) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 570) k_pu
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 571) 	The proportional term of the power allocator governor's PID
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 572) 	controller during temperature undershoot. Temperature undershoot
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 573) 	is when the current temperature is below the "desired
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 574) 	temperature" trip point. For more information see
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 575) 	Documentation/driver-api/thermal/power_allocator.rst
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 576) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 577) 	RW, Optional
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 578) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 579) k_i
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 580) 	The integral term of the power allocator governor's PID
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 581) 	controller. This term allows the PID controller to compensate
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 582) 	for long term drift. For more information see
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 583) 	Documentation/driver-api/thermal/power_allocator.rst
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 584) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 585) 	RW, Optional
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 586) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 587) k_d
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 588) 	The derivative term of the power allocator governor's PID
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 589) 	controller. For more information see
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 590) 	Documentation/driver-api/thermal/power_allocator.rst
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 591) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 592) 	RW, Optional
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 593) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 594) integral_cutoff
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 595) 	Temperature offset from the desired temperature trip point
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 596) 	above which the integral term of the power allocator
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 597) 	governor's PID controller starts accumulating errors. For
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 598) 	example, if integral_cutoff is 0, then the integral term only
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 599) 	accumulates error when temperature is above the desired
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 600) 	temperature trip point. For more information see
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 601) 	Documentation/driver-api/thermal/power_allocator.rst
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 602) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 603) 	Unit: millidegree Celsius
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 604) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 605) 	RW, Optional
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 606) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 607) slope
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 608) 	The slope constant used in a linear extrapolation model
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 609) 	to determine a hotspot temperature based off the sensor's
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 610) 	raw readings. It is up to the device driver to determine
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 611) 	the usage of these values.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 612) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 613) 	RW, Optional
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 614) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 615) offset
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 616) 	The offset constant used in a linear extrapolation model
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 617) 	to determine a hotspot temperature based off the sensor's
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 618) 	raw readings. It is up to the device driver to determine
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 619) 	the usage of these values.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 620) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 621) 	RW, Optional
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 622) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 623) Cooling device attributes
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 624) -------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 625) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 626) type
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 627) 	String which represents the type of device, e.g:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 628) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 629) 	- for generic ACPI: should be "Fan", "Processor" or "LCD"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 630) 	- for memory controller device on intel_menlow platform:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 631) 	  should be "Memory controller".
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 632) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 633) 	RO, Required
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 634) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 635) max_state
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 636) 	The maximum permissible cooling state of this cooling device.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 637) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 638) 	RO, Required
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 639) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 640) cur_state
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 641) 	The current cooling state of this cooling device.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 642) 	The value can any integer numbers between 0 and max_state:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 643) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 644) 	- cur_state == 0 means no cooling
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 645) 	- cur_state == max_state means the maximum cooling.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 646) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 647) 	RW, Required
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 648) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 649) stats/reset
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 650) 	Writing any value resets the cooling device's statistics.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 651) 	WO, Required
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 652) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 653) stats/time_in_state_ms:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 654) 	The amount of time spent by the cooling device in various cooling
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 655) 	states. The output will have "<state> <time>" pair in each line, which
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 656) 	will mean this cooling device spent <time> msec of time at <state>.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 657) 	Output will have one line for each of the supported states.  usertime
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 658) 	units here is 10mS (similar to other time exported in /proc).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 659) 	RO, Required
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 660) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 661) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 662) stats/total_trans:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 663) 	A single positive value showing the total number of times the state of a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 664) 	cooling device is changed.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 665) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 666) 	RO, Required
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 667) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 668) stats/trans_table:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 669) 	This gives fine grained information about all the cooling state
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 670) 	transitions. The cat output here is a two dimensional matrix, where an
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 671) 	entry <i,j> (row i, column j) represents the number of transitions from
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 672) 	State_i to State_j. If the transition table is bigger than PAGE_SIZE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 673) 	reading this will return an -EFBIG error.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 674) 	RO, Required
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 675) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 676) 3. A simple implementation
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 677) ==========================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 678) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 679) ACPI thermal zone may support multiple trip points like critical, hot,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 680) passive, active. If an ACPI thermal zone supports critical, passive,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 681) active[0] and active[1] at the same time, it may register itself as a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 682) thermal_zone_device (thermal_zone1) with 4 trip points in all.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 683) It has one processor and one fan, which are both registered as
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 684) thermal_cooling_device. Both are considered to have the same
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 685) effectiveness in cooling the thermal zone.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 686) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 687) If the processor is listed in _PSL method, and the fan is listed in _AL0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 688) method, the sys I/F structure will be built like this::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 689) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 690)  /sys/class/thermal:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 691)   |thermal_zone1:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 692)     |---type:			acpitz
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 693)     |---temp:			37000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 694)     |---mode:			enabled
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 695)     |---policy:			step_wise
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 696)     |---available_policies:	step_wise fair_share
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 697)     |---trip_point_0_temp:	100000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 698)     |---trip_point_0_type:	critical
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 699)     |---trip_point_1_temp:	80000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 700)     |---trip_point_1_type:	passive
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 701)     |---trip_point_2_temp:	70000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 702)     |---trip_point_2_type:	active0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 703)     |---trip_point_3_temp:	60000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 704)     |---trip_point_3_type:	active1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 705)     |---cdev0:			--->/sys/class/thermal/cooling_device0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 706)     |---cdev0_trip_point:	1	/* cdev0 can be used for passive */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 707)     |---cdev0_weight:           1024
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 708)     |---cdev1:			--->/sys/class/thermal/cooling_device3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 709)     |---cdev1_trip_point:	2	/* cdev1 can be used for active[0]*/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 710)     |---cdev1_weight:           1024
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 711) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 712)   |cooling_device0:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 713)     |---type:			Processor
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 714)     |---max_state:		8
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 715)     |---cur_state:		0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 716) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 717)   |cooling_device3:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 718)     |---type:			Fan
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 719)     |---max_state:		2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 720)     |---cur_state:		0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 721) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 722)  /sys/class/hwmon:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 723)   |hwmon0:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 724)     |---name:			acpitz
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 725)     |---temp1_input:		37000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 726)     |---temp1_crit:		100000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 727) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 728) 4. Export Symbol APIs
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 729) =====================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 730) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 731) 4.1. get_tz_trend
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 732) -----------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 733) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 734) This function returns the trend of a thermal zone, i.e the rate of change
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 735) of temperature of the thermal zone. Ideally, the thermal sensor drivers
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 736) are supposed to implement the callback. If they don't, the thermal
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 737) framework calculated the trend by comparing the previous and the current
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 738) temperature values.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 739) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 740) 4.2. get_thermal_instance
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 741) -------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 742) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 743) This function returns the thermal_instance corresponding to a given
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 744) {thermal_zone, cooling_device, trip_point} combination. Returns NULL
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 745) if such an instance does not exist.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 746) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 747) 4.3. thermal_notify_framework
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 748) -----------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 749) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 750) This function handles the trip events from sensor drivers. It starts
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 751) throttling the cooling devices according to the policy configured.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 752) For CRITICAL and HOT trip points, this notifies the respective drivers,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 753) and does actual throttling for other trip points i.e ACTIVE and PASSIVE.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 754) The throttling policy is based on the configured platform data; if no
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 755) platform data is provided, this uses the step_wise throttling policy.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 756) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 757) 4.4. thermal_cdev_update
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 758) ------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 759) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 760) This function serves as an arbitrator to set the state of a cooling
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 761) device. It sets the cooling device to the deepest cooling state if
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 762) possible.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 763) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 764) 5. thermal_emergency_poweroff
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 765) =============================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 766) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 767) On an event of critical trip temperature crossing. Thermal framework
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 768) allows the system to shutdown gracefully by calling orderly_poweroff().
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 769) In the event of a failure of orderly_poweroff() to shut down the system
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 770) we are in danger of keeping the system alive at undesirably high
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 771) temperatures. To mitigate this high risk scenario we program a work
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 772) queue to fire after a pre-determined number of seconds to start
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 773) an emergency shutdown of the device using the kernel_power_off()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 774) function. In case kernel_power_off() fails then finally
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 775) emergency_restart() is called in the worst case.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 776) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 777) The delay should be carefully profiled so as to give adequate time for
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 778) orderly_poweroff(). In case of failure of an orderly_poweroff() the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 779) emergency poweroff kicks in after the delay has elapsed and shuts down
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 780) the system.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 781) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 782) If set to 0 emergency poweroff will not be supported. So a carefully
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 783) profiled non-zero positive value is a must for emergerncy poweroff to be
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 784) triggered.