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