| .. | .. |
|---|
| 15 | 15 | #include <linux/device.h> |
|---|
| 16 | 16 | #include <linux/sysfs.h> |
|---|
| 17 | 17 | #include <linux/workqueue.h> |
|---|
| 18 | +#include <linux/android_kabi.h> |
|---|
| 18 | 19 | #include <uapi/linux/thermal.h> |
|---|
| 19 | 20 | |
|---|
| 20 | 21 | #define THERMAL_TRIPS_NONE -1 |
|---|
| .. | .. |
|---|
| 29 | 30 | /* Default weight of a bound cooling device */ |
|---|
| 30 | 31 | #define THERMAL_WEIGHT_DEFAULT 0 |
|---|
| 31 | 32 | |
|---|
| 32 | | -/* Max sensors that can be used for a single virtual thermalzone */ |
|---|
| 33 | | -#define THERMAL_MAX_VIRT_SENSORS 10 |
|---|
| 34 | | - |
|---|
| 35 | 33 | /* use value, which < 0K, to indicate an invalid/uninitialized temperature */ |
|---|
| 36 | 34 | #define THERMAL_TEMP_INVALID -274000 |
|---|
| 37 | | - |
|---|
| 38 | | -/* |
|---|
| 39 | | - * use a high value for low temp tracking zone, |
|---|
| 40 | | - * to indicate an invalid/uninitialized temperature |
|---|
| 41 | | - */ |
|---|
| 42 | | -#define THERMAL_TEMP_INVALID_LOW 274000 |
|---|
| 43 | | - |
|---|
| 44 | | -/* Unit conversion macros */ |
|---|
| 45 | | -#define DECI_KELVIN_TO_CELSIUS(t) ({ \ |
|---|
| 46 | | - long _t = (t); \ |
|---|
| 47 | | - ((_t-2732 >= 0) ? (_t-2732+5)/10 : (_t-2732-5)/10); \ |
|---|
| 48 | | -}) |
|---|
| 49 | | -#define CELSIUS_TO_DECI_KELVIN(t) ((t)*10+2732) |
|---|
| 50 | | -#define DECI_KELVIN_TO_MILLICELSIUS_WITH_OFFSET(t, off) (((t) - (off)) * 100) |
|---|
| 51 | | -#define DECI_KELVIN_TO_MILLICELSIUS(t) DECI_KELVIN_TO_MILLICELSIUS_WITH_OFFSET(t, 2732) |
|---|
| 52 | | -#define MILLICELSIUS_TO_DECI_KELVIN_WITH_OFFSET(t, off) (((t) / 100) + (off)) |
|---|
| 53 | | -#define MILLICELSIUS_TO_DECI_KELVIN(t) MILLICELSIUS_TO_DECI_KELVIN_WITH_OFFSET(t, 2732) |
|---|
| 54 | | - |
|---|
| 55 | | -/* Default Thermal Governor */ |
|---|
| 56 | | -#if defined(CONFIG_THERMAL_DEFAULT_GOV_STEP_WISE) |
|---|
| 57 | | -#define DEFAULT_THERMAL_GOVERNOR "step_wise" |
|---|
| 58 | | -#elif defined(CONFIG_THERMAL_DEFAULT_GOV_FAIR_SHARE) |
|---|
| 59 | | -#define DEFAULT_THERMAL_GOVERNOR "fair_share" |
|---|
| 60 | | -#elif defined(CONFIG_THERMAL_DEFAULT_GOV_USER_SPACE) |
|---|
| 61 | | -#define DEFAULT_THERMAL_GOVERNOR "user_space" |
|---|
| 62 | | -#elif defined(CONFIG_THERMAL_DEFAULT_GOV_POWER_ALLOCATOR) |
|---|
| 63 | | -#define DEFAULT_THERMAL_GOVERNOR "power_allocator" |
|---|
| 64 | | -#endif |
|---|
| 65 | 35 | |
|---|
| 66 | 36 | struct thermal_zone_device; |
|---|
| 67 | 37 | struct thermal_cooling_device; |
|---|
| 68 | 38 | struct thermal_instance; |
|---|
| 69 | | - |
|---|
| 70 | | -enum thermal_device_mode { |
|---|
| 71 | | - THERMAL_DEVICE_DISABLED = 0, |
|---|
| 72 | | - THERMAL_DEVICE_ENABLED, |
|---|
| 73 | | -}; |
|---|
| 74 | | - |
|---|
| 75 | | -enum thermal_trip_type { |
|---|
| 76 | | - THERMAL_TRIP_ACTIVE = 0, |
|---|
| 77 | | - THERMAL_TRIP_PASSIVE, |
|---|
| 78 | | - THERMAL_TRIP_HOT, |
|---|
| 79 | | - THERMAL_TRIP_CRITICAL, |
|---|
| 80 | | - THERMAL_TRIP_CONFIGURABLE_HI, |
|---|
| 81 | | - THERMAL_TRIP_CONFIGURABLE_LOW, |
|---|
| 82 | | - THERMAL_TRIP_CRITICAL_LOW, |
|---|
| 83 | | -}; |
|---|
| 39 | +struct thermal_attr; |
|---|
| 84 | 40 | |
|---|
| 85 | 41 | enum thermal_trend { |
|---|
| 86 | 42 | THERMAL_TREND_STABLE, /* temperature is stable */ |
|---|
| .. | .. |
|---|
| 100 | 56 | THERMAL_DEVICE_UP, /* Thermal device is up after a down event */ |
|---|
| 101 | 57 | THERMAL_DEVICE_POWER_CAPABILITY_CHANGED, /* power capability changed */ |
|---|
| 102 | 58 | THERMAL_TABLE_CHANGED, /* Thermal table(s) changed */ |
|---|
| 59 | + THERMAL_EVENT_KEEP_ALIVE, /* Request for user space handler to respond */ |
|---|
| 103 | 60 | }; |
|---|
| 104 | 61 | |
|---|
| 105 | 62 | struct thermal_zone_device_ops { |
|---|
| .. | .. |
|---|
| 109 | 66 | struct thermal_cooling_device *); |
|---|
| 110 | 67 | int (*get_temp) (struct thermal_zone_device *, int *); |
|---|
| 111 | 68 | int (*set_trips) (struct thermal_zone_device *, int, int); |
|---|
| 112 | | - int (*get_mode) (struct thermal_zone_device *, |
|---|
| 113 | | - enum thermal_device_mode *); |
|---|
| 114 | | - int (*set_mode) (struct thermal_zone_device *, |
|---|
| 69 | + int (*change_mode) (struct thermal_zone_device *, |
|---|
| 115 | 70 | enum thermal_device_mode); |
|---|
| 116 | 71 | int (*get_trip_type) (struct thermal_zone_device *, int, |
|---|
| 117 | 72 | enum thermal_trip_type *); |
|---|
| .. | .. |
|---|
| 125 | 80 | enum thermal_trend *); |
|---|
| 126 | 81 | int (*notify) (struct thermal_zone_device *, int, |
|---|
| 127 | 82 | enum thermal_trip_type); |
|---|
| 128 | | - bool (*is_wakeable)(struct thermal_zone_device *); |
|---|
| 129 | | - int (*set_polling_delay)(struct thermal_zone_device *, int); |
|---|
| 130 | | - int (*set_passive_delay)(struct thermal_zone_device *, int); |
|---|
| 83 | + ANDROID_KABI_RESERVE(1); |
|---|
| 131 | 84 | }; |
|---|
| 132 | 85 | |
|---|
| 133 | 86 | struct thermal_cooling_device_ops { |
|---|
| 134 | 87 | int (*get_max_state) (struct thermal_cooling_device *, unsigned long *); |
|---|
| 135 | 88 | int (*get_cur_state) (struct thermal_cooling_device *, unsigned long *); |
|---|
| 136 | 89 | int (*set_cur_state) (struct thermal_cooling_device *, unsigned long); |
|---|
| 137 | | - int (*set_min_state)(struct thermal_cooling_device *cdev, |
|---|
| 138 | | - unsigned long target); |
|---|
| 139 | | - int (*get_min_state)(struct thermal_cooling_device *cdev, |
|---|
| 140 | | - unsigned long *target); |
|---|
| 141 | | - int (*get_requested_power)(struct thermal_cooling_device *, |
|---|
| 142 | | - struct thermal_zone_device *, u32 *); |
|---|
| 143 | | - int (*state2power)(struct thermal_cooling_device *, |
|---|
| 144 | | - struct thermal_zone_device *, unsigned long, u32 *); |
|---|
| 145 | | - int (*power2state)(struct thermal_cooling_device *, |
|---|
| 146 | | - struct thermal_zone_device *, u32, unsigned long *); |
|---|
| 90 | + int (*get_requested_power)(struct thermal_cooling_device *, u32 *); |
|---|
| 91 | + int (*state2power)(struct thermal_cooling_device *, unsigned long, u32 *); |
|---|
| 92 | + int (*power2state)(struct thermal_cooling_device *, u32, unsigned long *); |
|---|
| 93 | + |
|---|
| 94 | + ANDROID_KABI_RESERVE(1); |
|---|
| 147 | 95 | }; |
|---|
| 148 | 96 | |
|---|
| 149 | 97 | struct thermal_cooling_device { |
|---|
| .. | .. |
|---|
| 158 | 106 | struct mutex lock; /* protect thermal_instances list */ |
|---|
| 159 | 107 | struct list_head thermal_instances; |
|---|
| 160 | 108 | struct list_head node; |
|---|
| 161 | | - unsigned long sysfs_cur_state_req; |
|---|
| 162 | | - unsigned long sysfs_min_state_req; |
|---|
| 163 | | -}; |
|---|
| 164 | 109 | |
|---|
| 165 | | -struct thermal_attr { |
|---|
| 166 | | - struct device_attribute attr; |
|---|
| 167 | | - char name[THERMAL_NAME_LENGTH]; |
|---|
| 110 | + ANDROID_KABI_RESERVE(1); |
|---|
| 168 | 111 | }; |
|---|
| 169 | 112 | |
|---|
| 170 | 113 | /** |
|---|
| .. | .. |
|---|
| 175 | 118 | * @trip_temp_attrs: attributes for trip points for sysfs: trip temperature |
|---|
| 176 | 119 | * @trip_type_attrs: attributes for trip points for sysfs: trip type |
|---|
| 177 | 120 | * @trip_hyst_attrs: attributes for trip points for sysfs: trip hysteresis |
|---|
| 121 | + * @mode: current mode of this thermal zone |
|---|
| 178 | 122 | * @devdata: private pointer for device private data |
|---|
| 179 | 123 | * @trips: number of trip points the thermal zone supports |
|---|
| 180 | 124 | * @trips_disabled; bitmap for disabled trips |
|---|
| .. | .. |
|---|
| 217 | 161 | struct thermal_attr *trip_temp_attrs; |
|---|
| 218 | 162 | struct thermal_attr *trip_type_attrs; |
|---|
| 219 | 163 | struct thermal_attr *trip_hyst_attrs; |
|---|
| 164 | + enum thermal_device_mode mode; |
|---|
| 220 | 165 | void *devdata; |
|---|
| 221 | 166 | int trips; |
|---|
| 222 | 167 | unsigned long trips_disabled; /* bitmap for disabled trips */ |
|---|
| .. | .. |
|---|
| 240 | 185 | struct list_head node; |
|---|
| 241 | 186 | struct delayed_work poll_queue; |
|---|
| 242 | 187 | enum thermal_notify_event notify_event; |
|---|
| 188 | + |
|---|
| 189 | + ANDROID_KABI_RESERVE(1); |
|---|
| 243 | 190 | }; |
|---|
| 244 | 191 | |
|---|
| 245 | 192 | /** |
|---|
| .. | .. |
|---|
| 260 | 207 | void (*unbind_from_tz)(struct thermal_zone_device *tz); |
|---|
| 261 | 208 | int (*throttle)(struct thermal_zone_device *tz, int trip); |
|---|
| 262 | 209 | struct list_head governor_list; |
|---|
| 263 | | - int min_state_throttle; |
|---|
| 210 | + |
|---|
| 211 | + ANDROID_KABI_RESERVE(1); |
|---|
| 264 | 212 | }; |
|---|
| 265 | 213 | |
|---|
| 266 | 214 | /* Structure that holds binding parameters for a zone */ |
|---|
| .. | .. |
|---|
| 273 | 221 | * platform characterization. This value is relative to the |
|---|
| 274 | 222 | * rest of the weights so a cooling device whose weight is |
|---|
| 275 | 223 | * double that of another cooling device is twice as |
|---|
| 276 | | - * effective. See Documentation/thermal/sysfs-api.txt for more |
|---|
| 224 | + * effective. See Documentation/driver-api/thermal/sysfs-api.rst for more |
|---|
| 277 | 225 | * information. |
|---|
| 278 | 226 | */ |
|---|
| 279 | 227 | int weight; |
|---|
| .. | .. |
|---|
| 281 | 229 | /* |
|---|
| 282 | 230 | * This is a bit mask that gives the binding relation between this |
|---|
| 283 | 231 | * thermal zone and cdev, for a particular trip point. |
|---|
| 284 | | - * See Documentation/thermal/sysfs-api.txt for more information. |
|---|
| 232 | + * See Documentation/driver-api/thermal/sysfs-api.rst for more information. |
|---|
| 285 | 233 | */ |
|---|
| 286 | 234 | int trip_mask; |
|---|
| 287 | 235 | |
|---|
| .. | .. |
|---|
| 296 | 244 | unsigned long *binding_limits; |
|---|
| 297 | 245 | int (*match) (struct thermal_zone_device *tz, |
|---|
| 298 | 246 | struct thermal_cooling_device *cdev); |
|---|
| 247 | + |
|---|
| 248 | + ANDROID_KABI_RESERVE(1); |
|---|
| 299 | 249 | }; |
|---|
| 300 | 250 | |
|---|
| 301 | 251 | /* Structure to define Thermal Zone parameters */ |
|---|
| .. | .. |
|---|
| 324 | 274 | */ |
|---|
| 325 | 275 | s32 k_po; |
|---|
| 326 | 276 | |
|---|
| 327 | | - bool is_k_po_available; |
|---|
| 328 | | - |
|---|
| 329 | 277 | /* |
|---|
| 330 | 278 | * Proportional parameter of the PID controller when |
|---|
| 331 | 279 | * undershooting |
|---|
| 332 | 280 | */ |
|---|
| 333 | 281 | s32 k_pu; |
|---|
| 334 | 282 | |
|---|
| 335 | | - bool is_k_pu_available; |
|---|
| 336 | | - |
|---|
| 337 | 283 | /* Integral parameter of the PID controller */ |
|---|
| 338 | 284 | s32 k_i; |
|---|
| 339 | | - |
|---|
| 340 | | - bool is_k_i_available; |
|---|
| 341 | 285 | |
|---|
| 342 | 286 | /* Derivative parameter of the PID controller */ |
|---|
| 343 | 287 | s32 k_d; |
|---|
| .. | .. |
|---|
| 356 | 300 | */ |
|---|
| 357 | 301 | int offset; |
|---|
| 358 | 302 | |
|---|
| 359 | | - /* |
|---|
| 360 | | - * @tracks_low: Indicates that the thermal zone params are for |
|---|
| 361 | | - * temperatures falling below the thresholds. |
|---|
| 362 | | - */ |
|---|
| 363 | | - bool tracks_low; |
|---|
| 364 | | -}; |
|---|
| 365 | | - |
|---|
| 366 | | -struct thermal_genl_event { |
|---|
| 367 | | - u32 orig; |
|---|
| 368 | | - enum events event; |
|---|
| 303 | + ANDROID_KABI_RESERVE(1); |
|---|
| 369 | 304 | }; |
|---|
| 370 | 305 | |
|---|
| 371 | 306 | /** |
|---|
| .. | .. |
|---|
| 383 | 318 | * temperature. |
|---|
| 384 | 319 | * @set_trip_temp: a pointer to a function that sets the trip temperature on |
|---|
| 385 | 320 | * hardware. |
|---|
| 386 | | - * @get_trip_temp: a pointer to a function that gets the trip temperature on |
|---|
| 387 | | - * hardware. |
|---|
| 388 | 321 | */ |
|---|
| 389 | 322 | struct thermal_zone_of_device_ops { |
|---|
| 390 | 323 | int (*get_temp)(void *, int *); |
|---|
| .. | .. |
|---|
| 392 | 325 | int (*set_trips)(void *, int, int); |
|---|
| 393 | 326 | int (*set_emul_temp)(void *, int); |
|---|
| 394 | 327 | int (*set_trip_temp)(void *, int, int); |
|---|
| 395 | | - int (*get_trip_temp)(void *, int, int *); |
|---|
| 396 | | -}; |
|---|
| 397 | 328 | |
|---|
| 398 | | -/** |
|---|
| 399 | | - * struct thermal_trip - representation of a point in temperature domain |
|---|
| 400 | | - * @np: pointer to struct device_node that this trip point was created from |
|---|
| 401 | | - * @temperature: temperature value in miliCelsius |
|---|
| 402 | | - * @hysteresis: relative hysteresis in miliCelsius |
|---|
| 403 | | - * @type: trip point type |
|---|
| 404 | | - */ |
|---|
| 405 | | - |
|---|
| 406 | | -struct thermal_trip { |
|---|
| 407 | | - struct device_node *np; |
|---|
| 408 | | - int temperature; |
|---|
| 409 | | - int hysteresis; |
|---|
| 410 | | - enum thermal_trip_type type; |
|---|
| 411 | | -}; |
|---|
| 412 | | - |
|---|
| 413 | | -/* Different aggregation logic supported for virtual sensors */ |
|---|
| 414 | | -enum aggregation_logic { |
|---|
| 415 | | - VIRT_WEIGHTED_AVG, |
|---|
| 416 | | - VIRT_MAXIMUM, |
|---|
| 417 | | - VIRT_MINIMUM, |
|---|
| 418 | | - VIRT_COUNT_THRESHOLD, |
|---|
| 419 | | - VIRT_AGGREGATION_NR, |
|---|
| 420 | | -}; |
|---|
| 421 | | - |
|---|
| 422 | | -/* |
|---|
| 423 | | - * struct virtual_sensor_data - Data structure used to provide |
|---|
| 424 | | - * information about the virtual zone. |
|---|
| 425 | | - * @virt_zone_name - Virtual thermal zone name |
|---|
| 426 | | - * @num_sensors - Number of sensors this virtual zone uses to compute |
|---|
| 427 | | - * temperature |
|---|
| 428 | | - * @sensor_names - Array of sensor names |
|---|
| 429 | | - * @logic - Temperature aggregation logic to be used |
|---|
| 430 | | - * @coefficients - Coefficients to be used for weighted average logic |
|---|
| 431 | | - * @coefficient_ct - number of coefficients provided as input |
|---|
| 432 | | - * @avg_offset - offset value to be used for the weighted aggregation logic |
|---|
| 433 | | - * @avg_denominator - denominator value to be used for the weighted aggregation |
|---|
| 434 | | - * logic |
|---|
| 435 | | - */ |
|---|
| 436 | | -struct virtual_sensor_data { |
|---|
| 437 | | - int num_sensors; |
|---|
| 438 | | - char virt_zone_name[THERMAL_NAME_LENGTH]; |
|---|
| 439 | | - char *sensor_names[THERMAL_MAX_VIRT_SENSORS]; |
|---|
| 440 | | - enum aggregation_logic logic; |
|---|
| 441 | | - int coefficients[THERMAL_MAX_VIRT_SENSORS]; |
|---|
| 442 | | - int coefficient_ct; |
|---|
| 443 | | - int avg_offset; |
|---|
| 444 | | - int avg_denominator; |
|---|
| 329 | + ANDROID_KABI_RESERVE(1); |
|---|
| 445 | 330 | }; |
|---|
| 446 | 331 | |
|---|
| 447 | 332 | /* Function declarations */ |
|---|
| 448 | 333 | #ifdef CONFIG_THERMAL_OF |
|---|
| 334 | +int thermal_zone_of_get_sensor_id(struct device_node *tz_np, |
|---|
| 335 | + struct device_node *sensor_np, |
|---|
| 336 | + u32 *id); |
|---|
| 449 | 337 | struct thermal_zone_device * |
|---|
| 450 | 338 | thermal_zone_of_sensor_register(struct device *dev, int id, void *data, |
|---|
| 451 | 339 | const struct thermal_zone_of_device_ops *ops); |
|---|
| .. | .. |
|---|
| 456 | 344 | const struct thermal_zone_of_device_ops *ops); |
|---|
| 457 | 345 | void devm_thermal_zone_of_sensor_unregister(struct device *dev, |
|---|
| 458 | 346 | struct thermal_zone_device *tz); |
|---|
| 459 | | -struct thermal_zone_device *devm_thermal_of_virtual_sensor_register( |
|---|
| 460 | | - struct device *dev, |
|---|
| 461 | | - const struct virtual_sensor_data *sensor_data); |
|---|
| 462 | 347 | #else |
|---|
| 348 | + |
|---|
| 349 | +static inline int thermal_zone_of_get_sensor_id(struct device_node *tz_np, |
|---|
| 350 | + struct device_node *sensor_np, |
|---|
| 351 | + u32 *id) |
|---|
| 352 | +{ |
|---|
| 353 | + return -ENOENT; |
|---|
| 354 | +} |
|---|
| 463 | 355 | static inline struct thermal_zone_device * |
|---|
| 464 | 356 | thermal_zone_of_sensor_register(struct device *dev, int id, void *data, |
|---|
| 465 | 357 | const struct thermal_zone_of_device_ops *ops) |
|---|
| .. | .. |
|---|
| 486 | 378 | { |
|---|
| 487 | 379 | } |
|---|
| 488 | 380 | |
|---|
| 489 | | -static inline |
|---|
| 490 | | -struct thermal_zone_device *devm_thermal_of_virtual_sensor_register( |
|---|
| 491 | | - struct device *dev, |
|---|
| 492 | | - const struct virtual_sensor_data *sensor_data) |
|---|
| 493 | | -{ |
|---|
| 494 | | - return ERR_PTR(-ENODEV); |
|---|
| 495 | | -} |
|---|
| 496 | | - |
|---|
| 497 | 381 | #endif |
|---|
| 498 | 382 | |
|---|
| 499 | | -#if IS_ENABLED(CONFIG_THERMAL) |
|---|
| 500 | | -static inline bool cdev_is_power_actor(struct thermal_cooling_device *cdev) |
|---|
| 501 | | -{ |
|---|
| 502 | | - return cdev->ops->get_requested_power && cdev->ops->state2power && |
|---|
| 503 | | - cdev->ops->power2state; |
|---|
| 504 | | -} |
|---|
| 505 | | - |
|---|
| 506 | | -int power_actor_get_max_power(struct thermal_cooling_device *, |
|---|
| 507 | | - struct thermal_zone_device *tz, u32 *max_power); |
|---|
| 508 | | -int power_actor_get_min_power(struct thermal_cooling_device *, |
|---|
| 509 | | - struct thermal_zone_device *tz, u32 *min_power); |
|---|
| 510 | | -int power_actor_set_power(struct thermal_cooling_device *, |
|---|
| 511 | | - struct thermal_instance *, u32); |
|---|
| 383 | +#ifdef CONFIG_THERMAL |
|---|
| 512 | 384 | struct thermal_zone_device *thermal_zone_device_register(const char *, int, int, |
|---|
| 513 | 385 | void *, struct thermal_zone_device_ops *, |
|---|
| 514 | 386 | struct thermal_zone_params *, int, int); |
|---|
| .. | .. |
|---|
| 522 | 394 | struct thermal_cooling_device *); |
|---|
| 523 | 395 | void thermal_zone_device_update(struct thermal_zone_device *, |
|---|
| 524 | 396 | enum thermal_notify_event); |
|---|
| 525 | | -void thermal_zone_device_update_temp(struct thermal_zone_device *tz, |
|---|
| 526 | | - enum thermal_notify_event event, int temp); |
|---|
| 527 | | -void thermal_zone_set_trips(struct thermal_zone_device *); |
|---|
| 528 | 397 | |
|---|
| 529 | 398 | struct thermal_cooling_device *thermal_cooling_device_register(const char *, |
|---|
| 530 | 399 | void *, const struct thermal_cooling_device_ops *); |
|---|
| 531 | 400 | struct thermal_cooling_device * |
|---|
| 532 | 401 | thermal_of_cooling_device_register(struct device_node *np, const char *, void *, |
|---|
| 533 | 402 | const struct thermal_cooling_device_ops *); |
|---|
| 403 | +struct thermal_cooling_device * |
|---|
| 404 | +devm_thermal_of_cooling_device_register(struct device *dev, |
|---|
| 405 | + struct device_node *np, |
|---|
| 406 | + char *type, void *devdata, |
|---|
| 407 | + const struct thermal_cooling_device_ops *ops); |
|---|
| 534 | 408 | void thermal_cooling_device_unregister(struct thermal_cooling_device *); |
|---|
| 535 | 409 | struct thermal_zone_device *thermal_zone_get_zone_by_name(const char *name); |
|---|
| 536 | | -struct thermal_cooling_device *thermal_zone_get_cdev_by_name(const char *name); |
|---|
| 537 | 410 | int thermal_zone_get_temp(struct thermal_zone_device *tz, int *temp); |
|---|
| 538 | 411 | int thermal_zone_get_slope(struct thermal_zone_device *tz); |
|---|
| 539 | 412 | int thermal_zone_get_offset(struct thermal_zone_device *tz); |
|---|
| 540 | 413 | |
|---|
| 541 | | -int get_tz_trend(struct thermal_zone_device *, int); |
|---|
| 542 | | -struct thermal_instance *get_thermal_instance(struct thermal_zone_device *, |
|---|
| 543 | | - struct thermal_cooling_device *, int); |
|---|
| 544 | 414 | void thermal_cdev_update(struct thermal_cooling_device *); |
|---|
| 545 | 415 | void thermal_notify_framework(struct thermal_zone_device *, int); |
|---|
| 416 | +int thermal_zone_device_enable(struct thermal_zone_device *tz); |
|---|
| 417 | +int thermal_zone_device_disable(struct thermal_zone_device *tz); |
|---|
| 418 | +int thermal_zone_device_is_enabled(struct thermal_zone_device *tz); |
|---|
| 546 | 419 | #else |
|---|
| 547 | | -static inline bool cdev_is_power_actor(struct thermal_cooling_device *cdev) |
|---|
| 548 | | -{ return false; } |
|---|
| 549 | | -static inline int power_actor_get_max_power(struct thermal_cooling_device *cdev, |
|---|
| 550 | | - struct thermal_zone_device *tz, u32 *max_power) |
|---|
| 551 | | -{ return 0; } |
|---|
| 552 | | -static inline int power_actor_get_min_power(struct thermal_cooling_device *cdev, |
|---|
| 553 | | - struct thermal_zone_device *tz, |
|---|
| 554 | | - u32 *min_power) |
|---|
| 555 | | -{ return -ENODEV; } |
|---|
| 556 | | -static inline int power_actor_set_power(struct thermal_cooling_device *cdev, |
|---|
| 557 | | - struct thermal_instance *tz, u32 power) |
|---|
| 558 | | -{ return 0; } |
|---|
| 559 | 420 | static inline struct thermal_zone_device *thermal_zone_device_register( |
|---|
| 560 | 421 | const char *type, int trips, int mask, void *devdata, |
|---|
| 561 | 422 | struct thermal_zone_device_ops *ops, |
|---|
| .. | .. |
|---|
| 565 | 426 | static inline void thermal_zone_device_unregister( |
|---|
| 566 | 427 | struct thermal_zone_device *tz) |
|---|
| 567 | 428 | { } |
|---|
| 568 | | -static inline int thermal_zone_bind_cooling_device( |
|---|
| 569 | | - struct thermal_zone_device *tz, int trip, |
|---|
| 570 | | - struct thermal_cooling_device *cdev, |
|---|
| 571 | | - unsigned long upper, unsigned long lower, |
|---|
| 572 | | - unsigned int weight) |
|---|
| 573 | | -{ return -ENODEV; } |
|---|
| 574 | | -static inline int thermal_zone_unbind_cooling_device( |
|---|
| 575 | | - struct thermal_zone_device *tz, int trip, |
|---|
| 576 | | - struct thermal_cooling_device *cdev) |
|---|
| 577 | | -{ return -ENODEV; } |
|---|
| 578 | | -static inline void thermal_zone_device_update(struct thermal_zone_device *tz, |
|---|
| 579 | | - enum thermal_notify_event event) |
|---|
| 580 | | -{ } |
|---|
| 581 | | -static inline void thermal_zone_device_update_temp( |
|---|
| 582 | | - struct thermal_zone_device *tz, enum thermal_notify_event event, |
|---|
| 583 | | - int temp) |
|---|
| 584 | | -{ } |
|---|
| 585 | | -static inline void thermal_zone_set_trips(struct thermal_zone_device *tz) |
|---|
| 586 | | -{ } |
|---|
| 587 | 429 | static inline struct thermal_cooling_device * |
|---|
| 588 | | -thermal_cooling_device_register(char *type, void *devdata, |
|---|
| 430 | +thermal_cooling_device_register(const char *type, void *devdata, |
|---|
| 589 | 431 | const struct thermal_cooling_device_ops *ops) |
|---|
| 590 | 432 | { return ERR_PTR(-ENODEV); } |
|---|
| 591 | 433 | static inline struct thermal_cooling_device * |
|---|
| 592 | 434 | thermal_of_cooling_device_register(struct device_node *np, |
|---|
| 593 | | - char *type, void *devdata, const struct thermal_cooling_device_ops *ops) |
|---|
| 435 | + const char *type, void *devdata, |
|---|
| 436 | + const struct thermal_cooling_device_ops *ops) |
|---|
| 594 | 437 | { return ERR_PTR(-ENODEV); } |
|---|
| 438 | +static inline struct thermal_cooling_device * |
|---|
| 439 | +devm_thermal_of_cooling_device_register(struct device *dev, |
|---|
| 440 | + struct device_node *np, |
|---|
| 441 | + char *type, void *devdata, |
|---|
| 442 | + const struct thermal_cooling_device_ops *ops) |
|---|
| 443 | +{ |
|---|
| 444 | + return ERR_PTR(-ENODEV); |
|---|
| 445 | +} |
|---|
| 595 | 446 | static inline void thermal_cooling_device_unregister( |
|---|
| 596 | 447 | struct thermal_cooling_device *cdev) |
|---|
| 597 | 448 | { } |
|---|
| 598 | 449 | static inline struct thermal_zone_device *thermal_zone_get_zone_by_name( |
|---|
| 599 | | - const char *name) |
|---|
| 600 | | -{ return ERR_PTR(-ENODEV); } |
|---|
| 601 | | -static inline struct thermal_cooling_device *thermal_zone_get_cdev_by_name( |
|---|
| 602 | 450 | const char *name) |
|---|
| 603 | 451 | { return ERR_PTR(-ENODEV); } |
|---|
| 604 | 452 | static inline int thermal_zone_get_temp( |
|---|
| .. | .. |
|---|
| 610 | 458 | static inline int thermal_zone_get_offset( |
|---|
| 611 | 459 | struct thermal_zone_device *tz) |
|---|
| 612 | 460 | { return -ENODEV; } |
|---|
| 613 | | -static inline int get_tz_trend(struct thermal_zone_device *tz, int trip) |
|---|
| 614 | | -{ return -ENODEV; } |
|---|
| 615 | | -static inline struct thermal_instance * |
|---|
| 616 | | -get_thermal_instance(struct thermal_zone_device *tz, |
|---|
| 617 | | - struct thermal_cooling_device *cdev, int trip) |
|---|
| 618 | | -{ return ERR_PTR(-ENODEV); } |
|---|
| 461 | + |
|---|
| 619 | 462 | static inline void thermal_cdev_update(struct thermal_cooling_device *cdev) |
|---|
| 620 | 463 | { } |
|---|
| 621 | 464 | static inline void thermal_notify_framework(struct thermal_zone_device *tz, |
|---|
| 622 | 465 | int trip) |
|---|
| 623 | 466 | { } |
|---|
| 624 | | -#endif /* CONFIG_THERMAL */ |
|---|
| 625 | 467 | |
|---|
| 626 | | -#if defined(CONFIG_NET) && IS_ENABLED(CONFIG_THERMAL) |
|---|
| 627 | | -extern int thermal_generate_netlink_event(struct thermal_zone_device *tz, |
|---|
| 628 | | - enum events event); |
|---|
| 629 | | -#else |
|---|
| 630 | | -static inline int thermal_generate_netlink_event(struct thermal_zone_device *tz, |
|---|
| 631 | | - enum events event) |
|---|
| 632 | | -{ |
|---|
| 633 | | - return 0; |
|---|
| 634 | | -} |
|---|
| 635 | | -#endif |
|---|
| 468 | +static inline int thermal_zone_device_enable(struct thermal_zone_device *tz) |
|---|
| 469 | +{ return -ENODEV; } |
|---|
| 470 | + |
|---|
| 471 | +static inline int thermal_zone_device_disable(struct thermal_zone_device *tz) |
|---|
| 472 | +{ return -ENODEV; } |
|---|
| 473 | + |
|---|
| 474 | +static inline int |
|---|
| 475 | +thermal_zone_device_is_enabled(struct thermal_zone_device *tz) |
|---|
| 476 | +{ return -ENODEV; } |
|---|
| 477 | +#endif /* CONFIG_THERMAL */ |
|---|
| 636 | 478 | |
|---|
| 637 | 479 | #endif /* __THERMAL_H__ */ |
|---|