sphinx.addnodesdocument)}( rawsourcechildren]( translations LanguagesNode)}(hhh](h pending_xref)}(hhh]docutils.nodesTextChinese (Simplified)}parenthsba attributes}(ids]classes]names]dupnames]backrefs] refdomainstdreftypedoc reftarget0/translations/zh_CN/driver-api/thermal/sysfs-apimodnameN classnameN refexplicitutagnamehhh ubh)}(hhh]hChinese (Traditional)}hh2sbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget0/translations/zh_TW/driver-api/thermal/sysfs-apimodnameN classnameN refexplicituh1hhh ubh)}(hhh]hItalian}hhFsbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget0/translations/it_IT/driver-api/thermal/sysfs-apimodnameN classnameN refexplicituh1hhh ubh)}(hhh]hJapanese}hhZsbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget0/translations/ja_JP/driver-api/thermal/sysfs-apimodnameN classnameN refexplicituh1hhh ubh)}(hhh]hKorean}hhnsbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget0/translations/ko_KR/driver-api/thermal/sysfs-apimodnameN classnameN refexplicituh1hhh ubh)}(hhh]hSpanish}hhsbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget0/translations/sp_SP/driver-api/thermal/sysfs-apimodnameN classnameN refexplicituh1hhh ubeh}(h]h ]h"]h$]h&]current_languageEnglishuh1h hh _documenthsourceNlineNubhsection)}(hhh](htitle)}(h#Generic Thermal Sysfs driver How Toh]h#Generic Thermal Sysfs driver How To}(hhhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhhhJ/var/lib/git/docbuild/linux/Documentation/driver-api/thermal/sysfs-api.rsthKubh paragraph)}(hSWritten by Sujith Thomas , Zhang Rui h](hWritten by Sujith Thomas <}(hhhhhNhNubh reference)}(hsujith.thomas@intel.comh]hsujith.thomas@intel.com}(hhhhhNhNubah}(h]h ]h"]h$]h&]refurimailto:sujith.thomas@intel.comuh1hhhubh>, Zhang Rui <}(hhhhhNhNubh)}(hrui.zhang@intel.comh]hrui.zhang@intel.com}(hhhhhNhNubah}(h]h ]h"]h$]h&]refurimailto:rui.zhang@intel.comuh1hhhubh>}(hhhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhKhhhhubh)}(h%Copyright (c) 2008 Intel Corporationh]h%Copyright (c) 2008 Intel Corporation}(hhhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhhhhubh)}(hhh](h)}(h0. Introductionh]h0. Introduction}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhhhhhK ubh)}(hThe generic thermal sysfs provides a set of interfaces for thermal zone devices (sensors) and thermal cooling devices (fan, processor...) to register with the thermal management solution and to be a part of it.h]hThe generic thermal sysfs provides a set of interfaces for thermal zone devices (sensors) and thermal cooling devices (fan, processor...) to register with the thermal management solution and to be a part of it.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK hhhhubh)}(hThis how-to focuses on enabling new thermal zone and cooling devices to participate in thermal management. This solution is platform independent and any type of thermal zone devices and cooling devices should be able to make use of the infrastructure.h]hThis how-to focuses on enabling new thermal zone and cooling devices to participate in thermal management. This solution is platform independent and any type of thermal zone devices and cooling devices should be able to make use of the infrastructure.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhhhhubh)}(hXKThe main task of the thermal sysfs driver is to expose thermal zone attributes as well as cooling device attributes to the user space. An intelligent thermal management application can make decisions based on inputs from thermal zone attributes (the current temperature and trip point temperature) and throttle appropriate devices.h]hXKThe main task of the thermal sysfs driver is to expose thermal zone attributes as well as cooling device attributes to the user space. An intelligent thermal management application can make decisions based on inputs from thermal zone attributes (the current temperature and trip point temperature) and throttle appropriate devices.}(hj,hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhhhhubh bullet_list)}(hhh](h list_item)}(h9`[0-*]` denotes any positive number starting from 0h]h)}(hjCh](htitle_reference)}(h`[0-*]`h]h[0-*]}(hjJhhhNhNubah}(h]h ]h"]h$]h&]uh1jHhjEubh2 denotes any positive number starting from 0}(hjEhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhKhjAubah}(h]h ]h"]h$]h&]uh1j?hj<hhhhhNubj@)}(h:`[1-*]` denotes any positive number starting from 1 h]h)}(h9`[1-*]` denotes any positive number starting from 1h](jI)}(h`[1-*]`h]h[1-*]}(hjphhhNhNubah}(h]h ]h"]h$]h&]uh1jHhjlubh2 denotes any positive number starting from 1}(hjlhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhKhjhubah}(h]h ]h"]h$]h&]uh1j?hj<hhhhhNubeh}(h]h ]h"]h$]h&]bullet-uh1j:hhhKhhhhubeh}(h] introductionah ]h"]0. introductionah$]h&]uh1hhhhhhhhK ubh)}(hhh](h)}(h+1. thermal sysfs driver interface functionsh]h+1. thermal sysfs driver interface functions}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjhhhhhK ubh)}(hhh](h)}(h!1.1 thermal zone device interfaceh]h!1.1 thermal zone device interface}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjhhhhhK#ubh block_quote)}(hX:: struct thermal_zone_device * thermal_zone_device_register_with_trips(const char *type, const struct thermal_trip *trips, int num_trips, void *devdata, const struct thermal_zone_device_ops *ops, const struct thermal_zone_params *tzp, unsigned int passive_delay, unsigned int polling_delay) This interface function adds a new thermal zone device (sensor) to the /sys/class/thermal folder as `thermal_zone[0-*]`. It tries to bind all the thermal cooling devices registered to it at the same time. type: the thermal zone type. trips: the table of trip points for this thermal zone. devdata: device private data ops: thermal zone device call-backs. .should_bind: check whether or not a given cooling device should be bound to a given trip point in this thermal zone. .get_temp: get the current temperature of the thermal zone. .set_trips: set the trip points window. Whenever the current temperature is updated, the trip points immediately below and above the current temperature are found. .change_mode: change the mode (enabled/disabled) of the thermal zone. .set_trip_temp: set the temperature of a given trip point. .get_crit_temp: get the critical temperature for this thermal zone. .set_emul_temp: set the emulation temperature which helps in debugging different threshold temperature points. .get_trend: get the trend of most recent zone temperature changes. .hot: hot trip point crossing handler. .critical: critical trip point crossing handler. tzp: thermal zone platform parameters. passive_delay: number of milliseconds to wait between polls when performing passive cooling. polling_delay: number of milliseconds to wait between polls when checking whether trip points have been crossed (0 for interrupt driven systems). :: void thermal_zone_device_unregister(struct thermal_zone_device *tz) This interface function removes the thermal zone device. It deletes the corresponding entry from /sys/class/thermal folder and unbinds all the thermal cooling devices it uses. :: struct thermal_zone_device *thermal_zone_of_sensor_register(struct device *dev, int sensor_id, void *data, const struct thermal_zone_of_device_ops *ops) This interface adds a new sensor to a DT thermal zone. This function will search the list of thermal zones described in device tree and look for the zone that refer to the sensor device pointed by dev->of_node as temperature providers. For the zone pointing to the sensor node, the sensor will be added to the DT thermal zone device. The parameters for this interface are: dev: Device node of sensor containing valid node pointer in dev->of_node. sensor_id: a sensor identifier, in case the sensor IP has more than one sensors data: a private pointer (owned by the caller) that will be passed back, when a temperature reading is needed. ops: `struct thermal_zone_of_device_ops *`. ============== ======================================= get_temp a pointer to a function that reads the sensor temperature. This is mandatory callback provided by sensor driver. set_trips a pointer to a function that sets a temperature window. When this window is left the driver must inform the thermal core via thermal_zone_device_update. get_trend a pointer to a function that reads the sensor temperature trend. set_emul_temp a pointer to a function that sets sensor emulated temperature. ============== ======================================= The thermal zone temperature is provided by the get_temp() function pointer of thermal_zone_of_device_ops. When called, it will have the private pointer @data back. It returns error pointer if fails otherwise valid thermal zone device handle. Caller should check the return handle with IS_ERR() for finding whether success or not. :: void thermal_zone_of_sensor_unregister(struct device *dev, struct thermal_zone_device *tzd) This interface unregisters a sensor from a DT thermal zone which was successfully added by interface thermal_zone_of_sensor_register(). This function removes the sensor callbacks and private data from the thermal zone device registered with thermal_zone_of_sensor_register() interface. It will also silent the zone by remove the .get_temp() and get_trend() thermal zone device callbacks. :: struct thermal_zone_device *devm_thermal_zone_of_sensor_register(struct device *dev, int sensor_id, void *data, const struct thermal_zone_of_device_ops *ops) This interface is resource managed version of thermal_zone_of_sensor_register(). All details of thermal_zone_of_sensor_register() described in section 1.1.3 is applicable here. The benefit of using this interface to register sensor is that it is not require to explicitly call thermal_zone_of_sensor_unregister() in error path or during driver unbinding as this is done by driver resource manager. :: void devm_thermal_zone_of_sensor_unregister(struct device *dev, struct thermal_zone_device *tzd) This interface is resource managed version of thermal_zone_of_sensor_unregister(). All details of thermal_zone_of_sensor_unregister() described in section 1.1.4 is applicable here. Normally this function will not need to be called and the resource management code will ensure that the resource is freed. :: int thermal_zone_get_slope(struct thermal_zone_device *tz) This interface is used to read the slope attribute value for the thermal zone device, which might be useful for platform drivers for temperature calculations. :: int thermal_zone_get_offset(struct thermal_zone_device *tz) This interface is used to read the offset attribute value for the thermal zone device, which might be useful for platform drivers for temperature calculations. h](h literal_block)}(hXstruct thermal_zone_device * thermal_zone_device_register_with_trips(const char *type, const struct thermal_trip *trips, int num_trips, void *devdata, const struct thermal_zone_device_ops *ops, const struct thermal_zone_params *tzp, unsigned int passive_delay, unsigned int polling_delay)h]hXstruct thermal_zone_device * thermal_zone_device_register_with_trips(const char *type, const struct thermal_trip *trips, int num_trips, void *devdata, const struct thermal_zone_device_ops *ops, const struct thermal_zone_params *tzp, unsigned int passive_delay, unsigned int polling_delay)}hjsbah}(h]h ]h"]h$]h&] xml:spacepreserveuh1jhhhK'hjubh)}(hThis interface function adds a new thermal zone device (sensor) to the /sys/class/thermal folder as `thermal_zone[0-*]`. It tries to bind all the thermal cooling devices registered to it at the same time.h](hdThis interface function adds a new thermal zone device (sensor) to the /sys/class/thermal folder as }(hjhhhNhNubjI)}(h`thermal_zone[0-*]`h]hthermal_zone[0-*]}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jHhjubhU. It tries to bind all the thermal cooling devices registered to it at the same time.}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhK0hjubhdefinition_list)}(hhh](hdefinition_list_item)}(htype: the thermal zone type.h](hterm)}(htype:h]htype:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhhhK4hjubh definition)}(hhh]h)}(hthe thermal zone type.h]hthe thermal zone type.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK5hjubah}(h]h ]h"]h$]h&]uh1jhjubeh}(h]h ]h"]h$]h&]uh1jhhhK4hjubj)}(h6trips: the table of trip points for this thermal zone.h](j)}(htrips:h]htrips:}(hj6hhhNhNubah}(h]h ]h"]h$]h&]uh1jhhhK6hj2ubj)}(hhh]h)}(h/the table of trip points for this thermal zone.h]h/the table of trip points for this thermal zone.}(hjGhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK7hjDubah}(h]h ]h"]h$]h&]uh1jhj2ubeh}(h]h ]h"]h$]h&]uh1jhhhK6hjubj)}(hdevdata: device private datah](j)}(hdevdata:h]hdevdata:}(hjehhhNhNubah}(h]h ]h"]h$]h&]uh1jhhhK8hjaubj)}(hhh]h)}(hdevice private datah]hdevice private data}(hjvhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK9hjsubah}(h]h ]h"]h$]h&]uh1jhjaubeh}(h]h ]h"]h$]h&]uh1jhhhK8hjubj)}(hXops: thermal zone device call-backs. .should_bind: check whether or not a given cooling device should be bound to a given trip point in this thermal zone. .get_temp: get the current temperature of the thermal zone. .set_trips: set the trip points window. Whenever the current temperature is updated, the trip points immediately below and above the current temperature are found. .change_mode: change the mode (enabled/disabled) of the thermal zone. .set_trip_temp: set the temperature of a given trip point. .get_crit_temp: get the critical temperature for this thermal zone. .set_emul_temp: set the emulation temperature which helps in debugging different threshold temperature points. .get_trend: get the trend of most recent zone temperature changes. .hot: hot trip point crossing handler. .critical: critical trip point crossing handler.h](j)}(hops:h]hops:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhhhKShjubj)}(hhh](h)}(hthermal zone device call-backs.h]hthermal zone device call-backs.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK;hjubj)}(hhh](j)}(hu.should_bind: check whether or not a given cooling device should be bound to a given trip point in this thermal zone.h](j)}(h .should_bind:h]h .should_bind:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhhhK>hjubj)}(hhh]h)}(hgcheck whether or not a given cooling device should be bound to a given trip point in this thermal zone.h]hgcheck whether or not a given cooling device should be bound to a given trip point in this thermal zone.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK>hjubah}(h]h ]h"]h$]h&]uh1jhjubeh}(h]h ]h"]h$]h&]uh1jhhhK>hjubj)}(h;.get_temp: get the current temperature of the thermal zone.h](j)}(h .get_temp:h]h .get_temp:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhhhK@hjubj)}(hhh]h)}(h0get the current temperature of the thermal zone.h]h0get the current temperature of the thermal zone.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKAhjubah}(h]h ]h"]h$]h&]uh1jhjubeh}(h]h ]h"]h$]h&]uh1jhhhK@hjubj)}(h.set_trips: set the trip points window. Whenever the current temperature is updated, the trip points immediately below and above the current temperature are found.h](j)}(h .set_trips:h]h .set_trips:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhhhKDhjubj)}(hhh]h)}(hset the trip points window. Whenever the current temperature is updated, the trip points immediately below and above the current temperature are found.h]hset the trip points window. Whenever the current temperature is updated, the trip points immediately below and above the current temperature are found.}(hj)hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKChj&ubah}(h]h ]h"]h$]h&]uh1jhjubeh}(h]h ]h"]h$]h&]uh1jhhhKDhjubj)}(hE.change_mode: change the mode (enabled/disabled) of the thermal zone.h](j)}(h .change_mode:h]h .change_mode:}(hjGhhhNhNubah}(h]h ]h"]h$]h&]uh1jhhhKFhjCubj)}(hhh]h)}(h7change the mode (enabled/disabled) of the thermal zone.h]h7change the mode (enabled/disabled) of the thermal zone.}(hjXhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKGhjUubah}(h]h ]h"]h$]h&]uh1jhjCubeh}(h]h ]h"]h$]h&]uh1jhhhKFhjubj)}(h:.set_trip_temp: set the temperature of a given trip point.h](j)}(h.set_trip_temp:h]h.set_trip_temp:}(hjvhhhNhNubah}(h]h ]h"]h$]h&]uh1jhhhKHhjrubj)}(hhh]h)}(h*set the temperature of a given trip point.h]h*set the temperature of a given trip point.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKIhjubah}(h]h ]h"]h$]h&]uh1jhjrubeh}(h]h ]h"]h$]h&]uh1jhhhKHhjubj)}(hC.get_crit_temp: get the critical temperature for this thermal zone.h](j)}(h.get_crit_temp:h]h.get_crit_temp:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhhhKJhjubj)}(hhh]h)}(h3get the critical temperature for this thermal zone.h]h3get the critical temperature for this thermal zone.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKKhjubah}(h]h ]h"]h$]h&]uh1jhjubeh}(h]h ]h"]h$]h&]uh1jhhhKJhjubj)}(hn.set_emul_temp: set the emulation temperature which helps in debugging different threshold temperature points.h](j)}(h.set_emul_temp:h]h.set_emul_temp:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhhhKMhjubj)}(hhh]h)}(h^set the emulation temperature which helps in debugging different threshold temperature points.h]h^set the emulation temperature which helps in debugging different threshold temperature points.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKMhjubah}(h]h ]h"]h$]h&]uh1jhjubeh}(h]h ]h"]h$]h&]uh1jhhhKMhjubj)}(hB.get_trend: get the trend of most recent zone temperature changes.h](j)}(h .get_trend:h]h .get_trend:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhhhKOhjubj)}(hhh]h)}(h6get the trend of most recent zone temperature changes.h]h6get the trend of most recent zone temperature changes.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKPhjubah}(h]h ]h"]h$]h&]uh1jhjubeh}(h]h ]h"]h$]h&]uh1jhhhKOhjubj)}(h&.hot: hot trip point crossing handler.h](j)}(h.hot:h]h.hot:}(hj2hhhNhNubah}(h]h ]h"]h$]h&]uh1jhhhKQhj.ubj)}(hhh]h)}(h hot trip point crossing handler.h]h hot trip point crossing handler.}(hjChhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKRhj@ubah}(h]h ]h"]h$]h&]uh1jhj.ubeh}(h]h ]h"]h$]h&]uh1jhhhKQhjubj)}(h0.critical: critical trip point crossing handler.h](j)}(h .critical:h]h .critical:}(hjahhhNhNubah}(h]h ]h"]h$]h&]uh1jhhhKShj]ubj)}(hhh]h)}(h%critical trip point crossing handler.h]h%critical trip point crossing handler.}(hjrhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKThjoubah}(h]h ]h"]h$]h&]uh1jhj]ubeh}(h]h ]h"]h$]h&]uh1jhhhKShjubeh}(h]h ]h"]h$]h&]uh1jhjubeh}(h]h ]h"]h$]h&]uh1jhjubeh}(h]h ]h"]h$]h&]uh1jhhhKShjubj)}(h&tzp: thermal zone platform parameters.h](j)}(htzp:h]htzp:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhhhKUhjubj)}(hhh]h)}(h!thermal zone platform parameters.h]h!thermal zone platform parameters.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKVhjubah}(h]h ]h"]h$]h&]uh1jhjubeh}(h]h ]h"]h$]h&]uh1jhhhKUhjubj)}(h\passive_delay: number of milliseconds to wait between polls when performing passive cooling.h](j)}(hpassive_delay:h]hpassive_delay:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhhhKXhjubj)}(hhh]h)}(hMnumber of milliseconds to wait between polls when performing passive cooling.h]hMnumber of milliseconds to wait between polls when performing passive cooling.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKXhjubah}(h]h ]h"]h$]h&]uh1jhjubeh}(h]h ]h"]h$]h&]uh1jhhhKXhjubj)}(hpolling_delay: number of milliseconds to wait between polls when checking whether trip points have been crossed (0 for interrupt driven systems). h](j)}(hpolling_delay:h]hpolling_delay:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhhhK\hjubj)}(hhh]h)}(hnumber of milliseconds to wait between polls when checking whether trip points have been crossed (0 for interrupt driven systems).h]hnumber of milliseconds to wait between polls when checking whether trip points have been crossed (0 for interrupt driven systems).}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK[hjubah}(h]h ]h"]h$]h&]uh1jhjubeh}(h]h ]h"]h$]h&]uh1jhhhK\hjubeh}(h]h ]h"]h$]h&]uh1jhjubj)}(hCvoid thermal_zone_device_unregister(struct thermal_zone_device *tz)h]hCvoid thermal_zone_device_unregister(struct thermal_zone_device *tz)}hj1sbah}(h]h ]h"]h$]h&]jjuh1jhhhK`hjubh)}(hThis interface function removes the thermal zone device. It deletes the corresponding entry from /sys/class/thermal folder and unbinds all the thermal cooling devices it uses.h]hThis interface function removes the thermal zone device. It deletes the corresponding entry from /sys/class/thermal folder and unbinds all the thermal cooling devices it uses.}(hj?hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKbhjubj)}(hX:: struct thermal_zone_device *thermal_zone_of_sensor_register(struct device *dev, int sensor_id, void *data, const struct thermal_zone_of_device_ops *ops) This interface adds a new sensor to a DT thermal zone. This function will search the list of thermal zones described in device tree and look for the zone that refer to the sensor device pointed by dev->of_node as temperature providers. For the zone pointing to the sensor node, the sensor will be added to the DT thermal zone device. The parameters for this interface are: dev: Device node of sensor containing valid node pointer in dev->of_node. sensor_id: a sensor identifier, in case the sensor IP has more than one sensors data: a private pointer (owned by the caller) that will be passed back, when a temperature reading is needed. ops: `struct thermal_zone_of_device_ops *`. ============== ======================================= get_temp a pointer to a function that reads the sensor temperature. This is mandatory callback provided by sensor driver. set_trips a pointer to a function that sets a temperature window. When this window is left the driver must inform the thermal core via thermal_zone_device_update. get_trend a pointer to a function that reads the sensor temperature trend. set_emul_temp a pointer to a function that sets sensor emulated temperature. ============== ======================================= The thermal zone temperature is provided by the get_temp() function pointer of thermal_zone_of_device_ops. When called, it will have the private pointer @data back. It returns error pointer if fails otherwise valid thermal zone device handle. Caller should check the return handle with IS_ERR() for finding whether success or not. :: void thermal_zone_of_sensor_unregister(struct device *dev, struct thermal_zone_device *tzd) This interface unregisters a sensor from a DT thermal zone which was successfully added by interface thermal_zone_of_sensor_register(). This function removes the sensor callbacks and private data from the thermal zone device registered with thermal_zone_of_sensor_register() interface. It will also silent the zone by remove the .get_temp() and get_trend() thermal zone device callbacks. :: struct thermal_zone_device *devm_thermal_zone_of_sensor_register(struct device *dev, int sensor_id, void *data, const struct thermal_zone_of_device_ops *ops) This interface is resource managed version of thermal_zone_of_sensor_register(). All details of thermal_zone_of_sensor_register() described in section 1.1.3 is applicable here. The benefit of using this interface to register sensor is that it is not require to explicitly call thermal_zone_of_sensor_unregister() in error path or during driver unbinding as this is done by driver resource manager. :: void devm_thermal_zone_of_sensor_unregister(struct device *dev, struct thermal_zone_device *tzd) This interface is resource managed version of thermal_zone_of_sensor_unregister(). All details of thermal_zone_of_sensor_unregister() described in section 1.1.4 is applicable here. Normally this function will not need to be called and the resource management code will ensure that the resource is freed. :: int thermal_zone_get_slope(struct thermal_zone_device *tz) This interface is used to read the slope attribute value for the thermal zone device, which might be useful for platform drivers for temperature calculations. :: int thermal_zone_get_offset(struct thermal_zone_device *tz) This interface is used to read the offset attribute value for the thermal zone device, which might be useful for platform drivers for temperature calculations. h](j)}(hstruct thermal_zone_device *thermal_zone_of_sensor_register(struct device *dev, int sensor_id, void *data, const struct thermal_zone_of_device_ops *ops)h]hstruct thermal_zone_device *thermal_zone_of_sensor_register(struct device *dev, int sensor_id, void *data, const struct thermal_zone_of_device_ops *ops)}hjQsbah}(h]h ]h"]h$]h&]jjuh1jhhhKhhjMubh)}(hXMThis interface adds a new sensor to a DT thermal zone. This function will search the list of thermal zones described in device tree and look for the zone that refer to the sensor device pointed by dev->of_node as temperature providers. For the zone pointing to the sensor node, the sensor will be added to the DT thermal zone device.h]hXMThis interface adds a new sensor to a DT thermal zone. This function will search the list of thermal zones described in device tree and look for the zone that refer to the sensor device pointed by dev->of_node as temperature providers. For the zone pointing to the sensor node, the sensor will be added to the DT thermal zone device.}(hj_hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKmhjMubh)}(h&The parameters for this interface are:h]h&The parameters for this interface are:}(hjmhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKthjMubj)}(hhh](j)}(hIdev: Device node of sensor containing valid node pointer in dev->of_node.h](j)}(hdev:h]hdev:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhhhKwhj~ubj)}(hhh]h)}(hDDevice node of sensor containing valid node pointer in dev->of_node.h]hDDevice node of sensor containing valid node pointer in dev->of_node.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKwhjubah}(h]h ]h"]h$]h&]uh1jhj~ubeh}(h]h ]h"]h$]h&]uh1jhhhKwhj{ubj)}(hOsensor_id: a sensor identifier, in case the sensor IP has more than one sensorsh](j)}(h sensor_id:h]h sensor_id:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhhhKzhjubj)}(hhh]h)}(hDa sensor identifier, in case the sensor IP has more than one sensorsh]hDa sensor identifier, in case the sensor IP has more than one sensors}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKzhjubah}(h]h ]h"]h$]h&]uh1jhjubeh}(h]h ]h"]h$]h&]uh1jhhhKzhj{ubj)}(hmdata: a private pointer (owned by the caller) that will be passed back, when a temperature reading is needed.h](j)}(hdata:h]hdata:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhhhK}hjubj)}(hhh]h)}(hga private pointer (owned by the caller) that will be passed back, when a temperature reading is needed.h]hga private pointer (owned by the caller) that will be passed back, when a temperature reading is needed.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK}hjubah}(h]h ]h"]h$]h&]uh1jhjubeh}(h]h ]h"]h$]h&]uh1jhhhK}hj{ubj)}(hXops: `struct thermal_zone_of_device_ops *`. ============== ======================================= get_temp a pointer to a function that reads the sensor temperature. This is mandatory callback provided by sensor driver. set_trips a pointer to a function that sets a temperature window. When this window is left the driver must inform the thermal core via thermal_zone_device_update. get_trend a pointer to a function that reads the sensor temperature trend. set_emul_temp a pointer to a function that sets sensor emulated temperature. ============== ======================================= h](j)}(hops:h]hops:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhhhKhj ubj)}(hhh](h)}(h&`struct thermal_zone_of_device_ops *`.h](jI)}(h%`struct thermal_zone_of_device_ops *`h]h#struct thermal_zone_of_device_ops *}(hj$hhhNhNubah}(h]h ]h"]h$]h&]uh1jHhj ubh.}(hj hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhKhjubhtable)}(hhh]htgroup)}(hhh](hcolspec)}(hhh]h}(h]h ]h"]h$]h&]colwidthKuh1jFhjCubjG)}(hhh]h}(h]h ]h"]h$]h&]colwidthK'uh1jFhjCubhtbody)}(hhh](hrow)}(hhh](hentry)}(hhh]h)}(hget_temph]hget_temp}(hjkhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjhubah}(h]h ]h"]h$]h&]uh1jfhjcubjg)}(hhh]h)}(hpa pointer to a function that reads the sensor temperature. This is mandatory callback provided by sensor driver.h]hpa pointer to a function that reads the sensor temperature. This is mandatory callback provided by sensor driver.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubah}(h]h ]h"]h$]h&]uh1jfhjcubeh}(h]h ]h"]h$]h&]uh1jahj^ubjb)}(hhh](jg)}(hhh]h)}(h set_tripsh]h set_trips}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubah}(h]h ]h"]h$]h&]uh1jfhjubjg)}(hhh]h)}(ha pointer to a function that sets a temperature window. When this window is left the driver must inform the thermal core via thermal_zone_device_update.h]ha pointer to a function that sets a temperature window. When this window is left the driver must inform the thermal core via thermal_zone_device_update.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubah}(h]h ]h"]h$]h&]uh1jfhjubeh}(h]h ]h"]h$]h&]uh1jahj^ubjb)}(hhh](jg)}(hhh]h)}(h get_trendh]h get_trend}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubah}(h]h ]h"]h$]h&]uh1jfhjubjg)}(hhh]h)}(h@a pointer to a function that reads the sensor temperature trend.h]h@a pointer to a function that reads the sensor temperature trend.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubah}(h]h ]h"]h$]h&]uh1jfhjubeh}(h]h ]h"]h$]h&]uh1jahj^ubjb)}(hhh](jg)}(hhh]h)}(h set_emul_temph]h set_emul_temp}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhj ubah}(h]h ]h"]h$]h&]uh1jfhj ubjg)}(hhh]h)}(h>a pointer to a function that sets sensor emulated temperature.h]h>a pointer to a function that sets sensor emulated temperature.}(hj'hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhj$ubah}(h]h ]h"]h$]h&]uh1jfhj ubeh}(h]h ]h"]h$]h&]uh1jahj^ubeh}(h]h ]h"]h$]h&]uh1j\hjCubeh}(h]h ]h"]h$]h&]colsKuh1jAhj>ubah}(h]h ]h"]h$]h&]uh1j<hjubeh}(h]h ]h"]h$]h&]uh1jhj ubeh}(h]h ]h"]h$]h&]uh1jhhhKhj{ubeh}(h]h ]h"]h$]h&]uh1jhjMubh)}(hThe thermal zone temperature is provided by the get_temp() function pointer of thermal_zone_of_device_ops. When called, it will have the private pointer @data back.h]hThe thermal zone temperature is provided by the get_temp() function pointer of thermal_zone_of_device_ops. When called, it will have the private pointer @data back.}(hjfhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjMubh)}(hIt returns error pointer if fails otherwise valid thermal zone device handle. Caller should check the return handle with IS_ERR() for finding whether success or not.h]hIt returns error pointer if fails otherwise valid thermal zone device handle. Caller should check the return handle with IS_ERR() for finding whether success or not.}(hjthhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjMubj)}(hvoid thermal_zone_of_sensor_unregister(struct device *dev, struct thermal_zone_device *tzd)h]hvoid thermal_zone_of_sensor_unregister(struct device *dev, struct thermal_zone_device *tzd)}hjsbah}(h]h ]h"]h$]h&]jjuh1jhhhKhjMubh)}(hXThis interface unregisters a sensor from a DT thermal zone which was successfully added by interface thermal_zone_of_sensor_register(). This function removes the sensor callbacks and private data from the thermal zone device registered with thermal_zone_of_sensor_register() interface. It will also silent the zone by remove the .get_temp() and get_trend() thermal zone device callbacks.h]hXThis interface unregisters a sensor from a DT thermal zone which was successfully added by interface thermal_zone_of_sensor_register(). This function removes the sensor callbacks and private data from the thermal zone device registered with thermal_zone_of_sensor_register() interface. It will also silent the zone by remove the .get_temp() and get_trend() thermal zone device callbacks.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjMubj)}(hstruct thermal_zone_device *devm_thermal_zone_of_sensor_register(struct device *dev, int sensor_id, void *data, const struct thermal_zone_of_device_ops *ops)h]hstruct thermal_zone_device *devm_thermal_zone_of_sensor_register(struct device *dev, int sensor_id, void *data, const struct thermal_zone_of_device_ops *ops)}hjsbah}(h]h ]h"]h$]h&]jjuh1jhhhKhjMubh)}(hPThis interface is resource managed version of thermal_zone_of_sensor_register().h]hPThis interface is resource managed version of thermal_zone_of_sensor_register().}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjMubh)}(h_All details of thermal_zone_of_sensor_register() described in section 1.1.3 is applicable here.h]h_All details of thermal_zone_of_sensor_register() described in section 1.1.3 is applicable here.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjMubh)}(hThe benefit of using this interface to register sensor is that it is not require to explicitly call thermal_zone_of_sensor_unregister() in error path or during driver unbinding as this is done by driver resource manager.h]hThe benefit of using this interface to register sensor is that it is not require to explicitly call thermal_zone_of_sensor_unregister() in error path or during driver unbinding as this is done by driver resource manager.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjMubj)}(hvoid devm_thermal_zone_of_sensor_unregister(struct device *dev, struct thermal_zone_device *tzd)h]hvoid devm_thermal_zone_of_sensor_unregister(struct device *dev, struct thermal_zone_device *tzd)}hjsbah}(h]h ]h"]h$]h&]jjuh1jhhhKhjMubh)}(hX/This interface is resource managed version of thermal_zone_of_sensor_unregister(). All details of thermal_zone_of_sensor_unregister() described in section 1.1.4 is applicable here. Normally this function will not need to be called and the resource management code will ensure that the resource is freed.h]hX/This interface is resource managed version of thermal_zone_of_sensor_unregister(). All details of thermal_zone_of_sensor_unregister() described in section 1.1.4 is applicable here. Normally this function will not need to be called and the resource management code will ensure that the resource is freed.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjMubj)}(h:int thermal_zone_get_slope(struct thermal_zone_device *tz)h]h:int thermal_zone_get_slope(struct thermal_zone_device *tz)}hjsbah}(h]h ]h"]h$]h&]jjuh1jhhhKhjMubh)}(hThis interface is used to read the slope attribute value for the thermal zone device, which might be useful for platform drivers for temperature calculations.h]hThis interface is used to read the slope attribute value for the thermal zone device, which might be useful for platform drivers for temperature calculations.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjMubj)}(h;int thermal_zone_get_offset(struct thermal_zone_device *tz)h]h;int thermal_zone_get_offset(struct thermal_zone_device *tz)}hjsbah}(h]h ]h"]h$]h&]jjuh1jhhhKhjMubh)}(hThis interface is used to read the offset attribute value for the thermal zone device, which might be useful for platform drivers for temperature calculations.h]hThis interface is used to read the offset attribute value for the thermal zone device, which might be useful for platform drivers for temperature calculations.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjMubeh}(h]h ]h"]h$]h&]uh1jhhhKfhjubeh}(h]h ]h"]h$]h&]uh1jhhhK%hjhhubeh}(h]thermal-zone-device-interfaceah ]h"]!1.1 thermal zone device interfaceah$]h&]uh1hhjhhhhhK#ubh)}(hhh](h)}(h$1.2 thermal cooling device interfaceh]h$1.2 thermal cooling device interface}(hjAhhhNhNubah}(h]h ]h"]h$]h&]uh1hhj>hhhhhKubj)}(hX:: struct thermal_cooling_device *thermal_cooling_device_register(char *name, void *devdata, struct thermal_cooling_device_ops *) This interface function adds a new thermal cooling device (fan/processor/...) to /sys/class/thermal/ folder as `cooling_device[0-*]`. It tries to bind itself to all the thermal zone devices registered at the same time. name: the cooling device name. devdata: device private data. ops: thermal cooling devices call-backs. .get_max_state: get the Maximum throttle state of the cooling device. .get_cur_state: get the Currently requested throttle state of the cooling device. .set_cur_state: set the Current throttle state of the cooling device. :: void thermal_cooling_device_unregister(struct thermal_cooling_device *cdev) This interface function removes the thermal cooling device. It deletes the corresponding entry from /sys/class/thermal folder and unbinds itself from all the thermal zone devices using it. h](j)}(hstruct thermal_cooling_device *thermal_cooling_device_register(char *name, void *devdata, struct thermal_cooling_device_ops *)h]hstruct thermal_cooling_device *thermal_cooling_device_register(char *name, void *devdata, struct thermal_cooling_device_ops *)}hjSsbah}(h]h ]h"]h$]h&]jjuh1jhhhKhjOubh)}(hThis interface function adds a new thermal cooling device (fan/processor/...) to /sys/class/thermal/ folder as `cooling_device[0-*]`. It tries to bind itself to all the thermal zone devices registered at the same time.h](hoThis interface function adds a new thermal cooling device (fan/processor/...) to /sys/class/thermal/ folder as }(hjahhhNhNubjI)}(h`cooling_device[0-*]`h]hcooling_device[0-*]}(hjihhhNhNubah}(h]h ]h"]h$]h&]uh1jHhjaubhV. It tries to bind itself to all the thermal zone devices registered at the same time.}(hjahhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhKhjOubj)}(hhh](j)}(hname: the cooling device name.h](j)}(hname:h]hname:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhhhKhjubj)}(hhh]h)}(hthe cooling device name.h]hthe cooling device name.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubah}(h]h ]h"]h$]h&]uh1jhjubeh}(h]h ]h"]h$]h&]uh1jhhhKhjubj)}(hdevdata: device private data.h](j)}(hdevdata:h]hdevdata:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhhhKhjubj)}(hhh]h)}(hdevice private data.h]hdevice private data.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubah}(h]h ]h"]h$]h&]uh1jhjubeh}(h]h ]h"]h$]h&]uh1jhhhKhjubj)}(hX(ops: thermal cooling devices call-backs. .get_max_state: get the Maximum throttle state of the cooling device. .get_cur_state: get the Currently requested throttle state of the cooling device. .set_cur_state: set the Current throttle state of the cooling device. h](j)}(hops:h]hops:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhhhKhjubj)}(hhh](h)}(h#thermal cooling devices call-backs.h]h#thermal cooling devices call-backs.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubj)}(hhh](j)}(hE.get_max_state: get the Maximum throttle state of the cooling device.h](j)}(h.get_max_state:h]h.get_max_state:}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1jhhhKhj ubj)}(hhh]h)}(h5get the Maximum throttle state of the cooling device.h]h5get the Maximum throttle state of the cooling device.}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhj ubah}(h]h ]h"]h$]h&]uh1jhj ubeh}(h]h ]h"]h$]h&]uh1jhhhKhj ubj)}(hQ.get_cur_state: get the Currently requested throttle state of the cooling device.h](j)}(h.get_cur_state:h]h.get_cur_state:}(hj; hhhNhNubah}(h]h ]h"]h$]h&]uh1jhhhKhj7 ubj)}(hhh]h)}(hAget the Currently requested throttle state of the cooling device.h]hAget the Currently requested throttle state of the cooling device.}(hjL hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjI ubah}(h]h ]h"]h$]h&]uh1jhj7 ubeh}(h]h ]h"]h$]h&]uh1jhhhKhj ubj)}(hF.set_cur_state: set the Current throttle state of the cooling device. h](j)}(h.set_cur_state:h]h.set_cur_state:}(hjj hhhNhNubah}(h]h ]h"]h$]h&]uh1jhhhKhjf ubj)}(hhh]h)}(h5set the Current throttle state of the cooling device.h]h5set the Current throttle state of the cooling device.}(hj{ hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjx ubah}(h]h ]h"]h$]h&]uh1jhjf ubeh}(h]h ]h"]h$]h&]uh1jhhhKhj ubeh}(h]h ]h"]h$]h&]uh1jhjubeh}(h]h ]h"]h$]h&]uh1jhjubeh}(h]h ]h"]h$]h&]uh1jhhhKhjubeh}(h]h ]h"]h$]h&]uh1jhjOubj)}(hKvoid thermal_cooling_device_unregister(struct thermal_cooling_device *cdev)h]hKvoid thermal_cooling_device_unregister(struct thermal_cooling_device *cdev)}hj sbah}(h]h ]h"]h$]h&]jjuh1jhhhKhjOubh)}(hThis interface function removes the thermal cooling device. It deletes the corresponding entry from /sys/class/thermal folder and unbinds itself from all the thermal zone devices using it.h]hThis interface function removes the thermal cooling device. It deletes the corresponding entry from /sys/class/thermal folder and unbinds itself from all the thermal zone devices using it.}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjOubeh}(h]h ]h"]h$]h&]uh1jhhhKhj>hhubeh}(h] thermal-cooling-device-interfaceah ]h"]$1.2 thermal cooling device interfaceah$]h&]uh1hhjhhhhhKubh)}(hhh](h)}(h1.4 Thermal Zone Parametersh]h1.4 Thermal Zone Parameters}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhj hhhhhKubj)}(hX:: struct thermal_zone_params This structure defines the platform level parameters for a thermal zone. This data, for each thermal zone should come from the platform layer. This is an optional feature where some platforms can choose not to provide this data. .governor_name: Name of the thermal governor used for this zone .no_hwmon: a boolean to indicate if the thermal to hwmon sysfs interface is required. when no_hwmon == false, a hwmon sysfs interface will be created. when no_hwmon == true, nothing will be done. In case the thermal_zone_params is NULL, the hwmon interface will be created (for backward compatibility). h](j)}(hstruct thermal_zone_paramsh]hstruct thermal_zone_params}hj sbah}(h]h ]h"]h$]h&]jjuh1jhhhKhj ubh)}(hThis structure defines the platform level parameters for a thermal zone. This data, for each thermal zone should come from the platform layer. This is an optional feature where some platforms can choose not to provide this data.h]hThis structure defines the platform level parameters for a thermal zone. This data, for each thermal zone should come from the platform layer. This is an optional feature where some platforms can choose not to provide this data.}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhj ubj)}(hhh](j)}(h?.governor_name: Name of the thermal governor used for this zoneh](j)}(h.governor_name:h]h.governor_name:}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1jhhhMhj ubj)}(hhh]h)}(h/Name of the thermal governor used for this zoneh]h/Name of the thermal governor used for this zone}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj ubah}(h]h ]h"]h$]h&]uh1jhj ubeh}(h]h ]h"]h$]h&]uh1jhhhMhj ubj)}(hX/.no_hwmon: a boolean to indicate if the thermal to hwmon sysfs interface is required. when no_hwmon == false, a hwmon sysfs interface will be created. when no_hwmon == true, nothing will be done. In case the thermal_zone_params is NULL, the hwmon interface will be created (for backward compatibility). h](j)}(h .no_hwmon:h]h .no_hwmon:}(hj> hhhNhNubah}(h]h ]h"]h$]h&]uh1jhhhM hj: ubj)}(hhh]h)}(hX#a boolean to indicate if the thermal to hwmon sysfs interface is required. when no_hwmon == false, a hwmon sysfs interface will be created. when no_hwmon == true, nothing will be done. In case the thermal_zone_params is NULL, the hwmon interface will be created (for backward compatibility).h]hX#a boolean to indicate if the thermal to hwmon sysfs interface is required. when no_hwmon == false, a hwmon sysfs interface will be created. when no_hwmon == true, nothing will be done. In case the thermal_zone_params is NULL, the hwmon interface will be created (for backward compatibility).}(hjO hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjL ubah}(h]h ]h"]h$]h&]uh1jhj: ubeh}(h]h ]h"]h$]h&]uh1jhhhM hj ubeh}(h]h ]h"]h$]h&]uh1jhj ubeh}(h]h ]h"]h$]h&]uh1jhhhKhj hhubeh}(h]thermal-zone-parametersah ]h"]1.4 thermal zone parametersah$]h&]uh1hhjhhhhhKubeh}(h](thermal-sysfs-driver-interface-functionsah ]h"]+1. thermal sysfs driver interface functionsah$]h&]uh1hhhhhhhhK ubh)}(hhh](h)}(h2. sysfs attributes structureh]h2. sysfs attributes structure}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhj hhhhhMubj=)}(hhh]jB)}(hhh](jG)}(hhh]h}(h]h ]h"]h$]h&]colwidthKuh1jFhj ubjG)}(hhh]h}(h]h ]h"]h$]h&]colwidthKuh1jFhj ubj])}(hhh](jb)}(hhh](jg)}(hhh]h)}(hROh]hRO}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj ubah}(h]h ]h"]h$]h&]uh1jfhj ubjg)}(hhh]h)}(hread only valueh]hread only value}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj ubah}(h]h ]h"]h$]h&]uh1jfhj ubeh}(h]h ]h"]h$]h&]uh1jahj ubjb)}(hhh](jg)}(hhh]h)}(hWOh]hWO}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj ubah}(h]h ]h"]h$]h&]uh1jfhj ubjg)}(hhh]h)}(hwrite only valueh]hwrite only value}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj ubah}(h]h ]h"]h$]h&]uh1jfhj ubeh}(h]h ]h"]h$]h&]uh1jahj ubjb)}(hhh](jg)}(hhh]h)}(hRWh]hRW}(hj' hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj$ ubah}(h]h ]h"]h$]h&]uh1jfhj! ubjg)}(hhh]h)}(hread/write valueh]hread/write value}(hj> hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj; ubah}(h]h ]h"]h$]h&]uh1jfhj! ubeh}(h]h ]h"]h$]h&]uh1jahj ubeh}(h]h ]h"]h$]h&]uh1j\hj ubeh}(h]h ]h"]h$]h&]colsKuh1jAhj ubah}(h]h ]h"]h$]h&]uh1j<hj hhhhhNubh)}(hThermal sysfs attributes will be represented under /sys/class/thermal. Hwmon sysfs I/F extension is also available under /sys/class/hwmon if hwmon is compiled in or built as a module.h]hThermal sysfs attributes will be represented under /sys/class/thermal. Hwmon sysfs I/F extension is also available under /sys/class/hwmon if hwmon is compiled in or built as a module.}(hjk hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj hhubh)}(h;Thermal zone device sys I/F, created once it's registered::h]hThermal cooling device sys I/F, created once it's registered::h]h?Thermal cooling device sys I/F, created once it’s registered:}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM/hj hhubj)}(hXp/sys/class/thermal/cooling_device[0-*]: |---type: Type of the cooling device(processor/fan/...) |---max_state: Maximum cooling state of the cooling device |---cur_state: Current cooling state of the cooling device |---stats: Directory containing cooling device's statistics |---stats/reset: Writing any value resets the statistics |---stats/time_in_state_ms: Time (msec) spent in various cooling states |---stats/total_trans: Total number of times cooling state is changed |---stats/trans_table: Cooling state transition tableh]hXp/sys/class/thermal/cooling_device[0-*]: |---type: Type of the cooling device(processor/fan/...) |---max_state: Maximum cooling state of the cooling device |---cur_state: Current cooling state of the cooling device |---stats: Directory containing cooling device's statistics |---stats/reset: Writing any value resets the statistics |---stats/time_in_state_ms: Time (msec) spent in various cooling states |---stats/total_trans: Total number of times cooling state is changed |---stats/trans_table: Cooling state transition table}hj sbah}(h]h ]h"]h$]h&]jjuh1jhhhM1hj hhubh)}(hThen next two dynamic attributes are created/removed in pairs. They represent the relationship between a thermal zone and its associated cooling device.h]hThen next two dynamic attributes are created/removed in pairs. They represent the relationship between a thermal zone and its associated cooling device.}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM<hj hhubj)}(hX./sys/class/thermal/thermal_zone[0-*]: |---cdev[0-*]: [0-*]th cooling device in current thermal zone |---cdev[0-*]_trip_point: Trip point that cdev[0-*] is associated with |---cdev[0-*]_weight: Influence of the cooling device in this thermal zoneh]hX./sys/class/thermal/thermal_zone[0-*]: |---cdev[0-*]: [0-*]th cooling device in current thermal zone |---cdev[0-*]_trip_point: Trip point that cdev[0-*] is associated with |---cdev[0-*]_weight: Influence of the cooling device in this thermal zone}hj sbah}(h]h ]h"]h$]h&]jjuh1jhhhMAhj hhubh)}(hX>Besides the thermal zone device sysfs I/F and cooling device sysfs I/F, the generic thermal driver also creates a hwmon sysfs I/F for each _type_ of thermal zone device. E.g. the generic thermal driver registers one hwmon class device and build the associated hwmon sysfs I/F for all the registered ACPI thermal zones.h]hX>Besides the thermal zone device sysfs I/F and cooling device sysfs I/F, the generic thermal driver also creates a hwmon sysfs I/F for each _type_ of thermal zone device. E.g. the generic thermal driver registers one hwmon class device and build the associated hwmon sysfs I/F for all the registered ACPI thermal zones.}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMGhj hhubh)}(hpPlease read Documentation/ABI/testing/sysfs-class-thermal for thermal zone and cooling device attribute details.h]hpPlease read Documentation/ABI/testing/sysfs-class-thermal for thermal zone and cooling device attribute details.}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMMhj hhubj)}(h/sys/class/hwmon/hwmon[0-*]: |---name: The type of the thermal zone devices |---temp[1-*]_input: The current temperature of thermal zone [1-*] |---temp[1-*]_critical: The critical trip point of thermal zone [1-*]h]h/sys/class/hwmon/hwmon[0-*]: |---name: The type of the thermal zone devices |---temp[1-*]_input: The current temperature of thermal zone [1-*] |---temp[1-*]_critical: The critical trip point of thermal zone [1-*]}hj sbah}(h]h ]h"]h$]h&]jjuh1jhhhMRhj hhubh)}(hOPlease read Documentation/hwmon/sysfs-interface.rst for additional information.h]hOPlease read Documentation/hwmon/sysfs-interface.rst for additional information.}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMWhj hhubeh}(h]sysfs-attributes-structureah ]h"]2. sysfs attributes structureah$]h&]uh1hhhhhhhhMubh)}(hhh](h)}(h3. A simple implementationh]h3. A simple implementation}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhj hhhhhMZubh)}(hXACPI thermal zone may support multiple trip points like critical, hot, passive, active. If an ACPI thermal zone supports critical, passive, active[0] and active[1] at the same time, it may register itself as a thermal_zone_device (thermal_zone1) with 4 trip points in all. It has one processor and one fan, which are both registered as thermal_cooling_device. Both are considered to have the same effectiveness in cooling the thermal zone.h]hXACPI thermal zone may support multiple trip points like critical, hot, passive, active. If an ACPI thermal zone supports critical, passive, active[0] and active[1] at the same time, it may register itself as a thermal_zone_device (thermal_zone1) with 4 trip points in all. It has one processor and one fan, which are both registered as thermal_cooling_device. Both are considered to have the same effectiveness in cooling the thermal zone.}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM\hj hhubh)}(hIf the processor is listed in _PSL method, and the fan is listed in _AL0 method, the sys I/F structure will be built like this::h]hIf the processor is listed in _PSL method, and the fan is listed in _AL0 method, the sys I/F structure will be built like this:}(hj, hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMdhj hhubj)}(hX/sys/class/thermal: |thermal_zone1: |---type: acpitz |---temp: 37000 |---mode: enabled |---policy: step_wise |---available_policies: step_wise fair_share |---trip_point_0_temp: 100000 |---trip_point_0_type: critical |---trip_point_1_temp: 80000 |---trip_point_1_type: passive |---trip_point_2_temp: 70000 |---trip_point_2_type: active0 |---trip_point_3_temp: 60000 |---trip_point_3_type: active1 |---cdev0: --->/sys/class/thermal/cooling_device0 |---cdev0_trip_point: 1 /* cdev0 can be used for passive */ |---cdev0_weight: 1024 |---cdev1: --->/sys/class/thermal/cooling_device3 |---cdev1_trip_point: 2 /* cdev1 can be used for active[0]*/ |---cdev1_weight: 1024 |cooling_device0: |---type: Processor |---max_state: 8 |---cur_state: 0 |cooling_device3: |---type: Fan |---max_state: 2 |---cur_state: 0 /sys/class/hwmon: |hwmon0: |---name: acpitz |---temp1_input: 37000 |---temp1_crit: 100000h]hX/sys/class/thermal: |thermal_zone1: |---type: acpitz |---temp: 37000 |---mode: enabled |---policy: step_wise |---available_policies: step_wise fair_share |---trip_point_0_temp: 100000 |---trip_point_0_type: critical |---trip_point_1_temp: 80000 |---trip_point_1_type: passive |---trip_point_2_temp: 70000 |---trip_point_2_type: active0 |---trip_point_3_temp: 60000 |---trip_point_3_type: active1 |---cdev0: --->/sys/class/thermal/cooling_device0 |---cdev0_trip_point: 1 /* cdev0 can be used for passive */ |---cdev0_weight: 1024 |---cdev1: --->/sys/class/thermal/cooling_device3 |---cdev1_trip_point: 2 /* cdev1 can be used for active[0]*/ |---cdev1_weight: 1024 |cooling_device0: |---type: Processor |---max_state: 8 |---cur_state: 0 |cooling_device3: |---type: Fan |---max_state: 2 |---cur_state: 0 /sys/class/hwmon: |hwmon0: |---name: acpitz |---temp1_input: 37000 |---temp1_crit: 100000}hj: sbah}(h]h ]h"]h$]h&]jjuh1jhhhMghj hhubeh}(h]a-simple-implementationah ]h"]3. a simple implementationah$]h&]uh1hhhhhhhhMZubh)}(hhh](h)}(h4. Export Symbol APIsh]h4. Export Symbol APIs}(hjS hhhNhNubah}(h]h ]h"]h$]h&]uh1hhjP hhhhhMubh)}(hhh](h)}(h4.1. get_tz_trendh]h4.1. get_tz_trend}(hjd hhhNhNubah}(h]h ]h"]h$]h&]uh1hhja hhhhhMubh)}(hX1This function returns the trend of a thermal zone, i.e the rate of change of temperature of the thermal zone. Ideally, the thermal sensor drivers are supposed to implement the callback. If they don't, the thermal framework calculated the trend by comparing the previous and the current temperature values.h]hX3This function returns the trend of a thermal zone, i.e the rate of change of temperature of the thermal zone. Ideally, the thermal sensor drivers are supposed to implement the callback. If they don’t, the thermal framework calculated the trend by comparing the previous and the current temperature values.}(hjr hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhja hhubeh}(h] get-tz-trendah ]h"]4.1. get_tz_trendah$]h&]uh1hhjP hhhhhMubh)}(hhh](h)}(h4.2. thermal_cdev_updateh]h4.2. thermal_cdev_update}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhj hhhhhMubh)}(hThis function serves as an arbitrator to set the state of a cooling device. It sets the cooling device to the deepest cooling state if possible.h]hThis function serves as an arbitrator to set the state of a cooling device. It sets the cooling device to the deepest cooling state if possible.}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj hhubeh}(h]thermal-cdev-updateah ]h"]4.2. thermal_cdev_updateah$]h&]uh1hhjP hhhhhMubeh}(h]export-symbol-apisah ]h"]4. export symbol apisah$]h&]uh1hhhhhhhhMubh)}(hhh](h)}(h5. Critical Eventsh]h5. Critical Events}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhj hhhhhMubh)}(hOn an event of critical trip temperature crossing, the thermal framework will trigger a hardware protection power-off (shutdown) or reboot, depending on configuration.h]hOn an event of critical trip temperature crossing, the thermal framework will trigger a hardware protection power-off (shutdown) or reboot, depending on configuration.}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj hhubh)}(hAt first, the kernel will attempt an orderly power-off or reboot, but accepts a delay after which it proceeds to do a forced power-off or reboot, respectively. If this fails, ``emergency_restart()`` is invoked as last resort.h](hAt first, the kernel will attempt an orderly power-off or reboot, but accepts a delay after which it proceeds to do a forced power-off or reboot, respectively. If this fails, }(hj hhhNhNubhliteral)}(h``emergency_restart()``h]hemergency_restart()}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1j hj ubh is invoked as last resort.}(hj hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMhj hhubh)}(hcThe delay should be carefully profiled so as to give adequate time for orderly power-off or reboot.h]hcThe delay should be carefully profiled so as to give adequate time for orderly power-off or reboot.}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj hhubh)}(hIf the delay is set to 0, the emergency action will not be supported. So a carefully profiled non-zero positive value is a must for the emergency action to be triggered.h]hIf the delay is set to 0, the emergency action will not be supported. So a carefully profiled non-zero positive value is a must for the emergency action to be triggered.}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj hhubeh}(h]critical-eventsah ]h"]5. critical eventsah$]h&]uh1hhhhhhhhMubeh}(h]#generic-thermal-sysfs-driver-how-toah ]h"]#generic thermal sysfs driver how toah$]h&]uh1hhhhhhhhKubeh}(h]h ]h"]h$]h&]sourcehuh1hcurrent_sourceN current_lineNsettingsdocutils.frontendValues)}(hN generatorN datestampN source_linkN source_urlN toc_backlinksjffootnote_backlinksK sectnum_xformKstrip_commentsNstrip_elements_with_classesN strip_classesN report_levelK halt_levelKexit_status_levelKdebugNwarning_streamN tracebackinput_encoding utf-8-siginput_encoding_error_handlerstrictoutput_encodingutf-8output_encoding_error_handlerjF error_encodingutf-8error_encoding_error_handlerbackslashreplace language_codeenrecord_dependenciesNconfigN id_prefixhauto_id_prefixid dump_settingsNdump_internalsNdump_transformsNdump_pseudo_xmlNexpose_internalsNstrict_visitorN_disable_configN_sourceh _destinationN _config_files]7/var/lib/git/docbuild/linux/Documentation/docutils.confafile_insertion_enabled raw_enabledKline_length_limitM'pep_referencesN pep_base_urlhttps://peps.python.org/pep_file_url_templatepep-%04drfc_referencesN rfc_base_url&https://datatracker.ietf.org/doc/html/ tab_widthKtrim_footnote_reference_spacesyntax_highlightlong smart_quotessmartquotes_locales]character_level_inline_markupdoctitle_xform docinfo_xformKsectsubtitle_xform image_loadinglinkembed_stylesheetcloak_email_addressessection_self_linkenvNubreporterNindirect_targets]substitution_defs}substitution_names}refnames}refids}nameids}(j! j jjj j j;j8j j jz jw j j jM jJ j j j j j j j j u nametypes}(j! jj j;j jz j jM j j j j uh}(j hjhj jj8jj j>jw j j j jJ j j jP j ja j j j j u footnote_refs} citation_refs} autofootnotes]autofootnote_refs]symbol_footnotes]symbol_footnote_refs] footnotes] citations]autofootnote_startKsymbol_footnote_startK id_counter collectionsCounter}Rparse_messages]transform_messages] transformerN include_log] decorationNhhub.