hc
2024-05-10 37f49e37ab4cb5d0bc4c60eb5c6d4dd57db767bb
kernel/include/linux/thermal.h
....@@ -15,6 +15,7 @@
1515 #include <linux/device.h>
1616 #include <linux/sysfs.h>
1717 #include <linux/workqueue.h>
18
+#include <linux/android_kabi.h>
1819 #include <uapi/linux/thermal.h>
1920
2021 #define THERMAL_TRIPS_NONE -1
....@@ -29,58 +30,13 @@
2930 /* Default weight of a bound cooling device */
3031 #define THERMAL_WEIGHT_DEFAULT 0
3132
32
-/* Max sensors that can be used for a single virtual thermalzone */
33
-#define THERMAL_MAX_VIRT_SENSORS 10
34
-
3533 /* use value, which < 0K, to indicate an invalid/uninitialized temperature */
3634 #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
6535
6636 struct thermal_zone_device;
6737 struct thermal_cooling_device;
6838 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;
8440
8541 enum thermal_trend {
8642 THERMAL_TREND_STABLE, /* temperature is stable */
....@@ -100,6 +56,7 @@
10056 THERMAL_DEVICE_UP, /* Thermal device is up after a down event */
10157 THERMAL_DEVICE_POWER_CAPABILITY_CHANGED, /* power capability changed */
10258 THERMAL_TABLE_CHANGED, /* Thermal table(s) changed */
59
+ THERMAL_EVENT_KEEP_ALIVE, /* Request for user space handler to respond */
10360 };
10461
10562 struct thermal_zone_device_ops {
....@@ -109,9 +66,7 @@
10966 struct thermal_cooling_device *);
11067 int (*get_temp) (struct thermal_zone_device *, int *);
11168 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 *,
11570 enum thermal_device_mode);
11671 int (*get_trip_type) (struct thermal_zone_device *, int,
11772 enum thermal_trip_type *);
....@@ -125,25 +80,18 @@
12580 enum thermal_trend *);
12681 int (*notify) (struct thermal_zone_device *, int,
12782 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);
13184 };
13285
13386 struct thermal_cooling_device_ops {
13487 int (*get_max_state) (struct thermal_cooling_device *, unsigned long *);
13588 int (*get_cur_state) (struct thermal_cooling_device *, unsigned long *);
13689 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);
14795 };
14896
14997 struct thermal_cooling_device {
....@@ -158,13 +106,8 @@
158106 struct mutex lock; /* protect thermal_instances list */
159107 struct list_head thermal_instances;
160108 struct list_head node;
161
- unsigned long sysfs_cur_state_req;
162
- unsigned long sysfs_min_state_req;
163
-};
164109
165
-struct thermal_attr {
166
- struct device_attribute attr;
167
- char name[THERMAL_NAME_LENGTH];
110
+ ANDROID_KABI_RESERVE(1);
168111 };
169112
170113 /**
....@@ -175,6 +118,7 @@
175118 * @trip_temp_attrs: attributes for trip points for sysfs: trip temperature
176119 * @trip_type_attrs: attributes for trip points for sysfs: trip type
177120 * @trip_hyst_attrs: attributes for trip points for sysfs: trip hysteresis
121
+ * @mode: current mode of this thermal zone
178122 * @devdata: private pointer for device private data
179123 * @trips: number of trip points the thermal zone supports
180124 * @trips_disabled; bitmap for disabled trips
....@@ -217,6 +161,7 @@
217161 struct thermal_attr *trip_temp_attrs;
218162 struct thermal_attr *trip_type_attrs;
219163 struct thermal_attr *trip_hyst_attrs;
164
+ enum thermal_device_mode mode;
220165 void *devdata;
221166 int trips;
222167 unsigned long trips_disabled; /* bitmap for disabled trips */
....@@ -240,6 +185,8 @@
240185 struct list_head node;
241186 struct delayed_work poll_queue;
242187 enum thermal_notify_event notify_event;
188
+
189
+ ANDROID_KABI_RESERVE(1);
243190 };
244191
245192 /**
....@@ -260,7 +207,8 @@
260207 void (*unbind_from_tz)(struct thermal_zone_device *tz);
261208 int (*throttle)(struct thermal_zone_device *tz, int trip);
262209 struct list_head governor_list;
263
- int min_state_throttle;
210
+
211
+ ANDROID_KABI_RESERVE(1);
264212 };
265213
266214 /* Structure that holds binding parameters for a zone */
....@@ -273,7 +221,7 @@
273221 * platform characterization. This value is relative to the
274222 * rest of the weights so a cooling device whose weight is
275223 * 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
277225 * information.
278226 */
279227 int weight;
....@@ -281,7 +229,7 @@
281229 /*
282230 * This is a bit mask that gives the binding relation between this
283231 * 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.
285233 */
286234 int trip_mask;
287235
....@@ -296,6 +244,8 @@
296244 unsigned long *binding_limits;
297245 int (*match) (struct thermal_zone_device *tz,
298246 struct thermal_cooling_device *cdev);
247
+
248
+ ANDROID_KABI_RESERVE(1);
299249 };
300250
301251 /* Structure to define Thermal Zone parameters */
....@@ -324,20 +274,14 @@
324274 */
325275 s32 k_po;
326276
327
- bool is_k_po_available;
328
-
329277 /*
330278 * Proportional parameter of the PID controller when
331279 * undershooting
332280 */
333281 s32 k_pu;
334282
335
- bool is_k_pu_available;
336
-
337283 /* Integral parameter of the PID controller */
338284 s32 k_i;
339
-
340
- bool is_k_i_available;
341285
342286 /* Derivative parameter of the PID controller */
343287 s32 k_d;
....@@ -356,16 +300,7 @@
356300 */
357301 int offset;
358302
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);
369304 };
370305
371306 /**
....@@ -383,8 +318,6 @@
383318 * temperature.
384319 * @set_trip_temp: a pointer to a function that sets the trip temperature on
385320 * hardware.
386
- * @get_trip_temp: a pointer to a function that gets the trip temperature on
387
- * hardware.
388321 */
389322 struct thermal_zone_of_device_ops {
390323 int (*get_temp)(void *, int *);
....@@ -392,60 +325,15 @@
392325 int (*set_trips)(void *, int, int);
393326 int (*set_emul_temp)(void *, int);
394327 int (*set_trip_temp)(void *, int, int);
395
- int (*get_trip_temp)(void *, int, int *);
396
-};
397328
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);
445330 };
446331
447332 /* Function declarations */
448333 #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);
449337 struct thermal_zone_device *
450338 thermal_zone_of_sensor_register(struct device *dev, int id, void *data,
451339 const struct thermal_zone_of_device_ops *ops);
....@@ -456,10 +344,14 @@
456344 const struct thermal_zone_of_device_ops *ops);
457345 void devm_thermal_zone_of_sensor_unregister(struct device *dev,
458346 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);
462347 #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
+}
463355 static inline struct thermal_zone_device *
464356 thermal_zone_of_sensor_register(struct device *dev, int id, void *data,
465357 const struct thermal_zone_of_device_ops *ops)
....@@ -486,29 +378,9 @@
486378 {
487379 }
488380
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
-
497381 #endif
498382
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
512384 struct thermal_zone_device *thermal_zone_device_register(const char *, int, int,
513385 void *, struct thermal_zone_device_ops *,
514386 struct thermal_zone_params *, int, int);
....@@ -522,40 +394,29 @@
522394 struct thermal_cooling_device *);
523395 void thermal_zone_device_update(struct thermal_zone_device *,
524396 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 *);
528397
529398 struct thermal_cooling_device *thermal_cooling_device_register(const char *,
530399 void *, const struct thermal_cooling_device_ops *);
531400 struct thermal_cooling_device *
532401 thermal_of_cooling_device_register(struct device_node *np, const char *, void *,
533402 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);
534408 void thermal_cooling_device_unregister(struct thermal_cooling_device *);
535409 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);
537410 int thermal_zone_get_temp(struct thermal_zone_device *tz, int *temp);
538411 int thermal_zone_get_slope(struct thermal_zone_device *tz);
539412 int thermal_zone_get_offset(struct thermal_zone_device *tz);
540413
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);
544414 void thermal_cdev_update(struct thermal_cooling_device *);
545415 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);
546419 #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; }
559420 static inline struct thermal_zone_device *thermal_zone_device_register(
560421 const char *type, int trips, int mask, void *devdata,
561422 struct thermal_zone_device_ops *ops,
....@@ -565,40 +426,27 @@
565426 static inline void thermal_zone_device_unregister(
566427 struct thermal_zone_device *tz)
567428 { }
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
-{ }
587429 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,
589431 const struct thermal_cooling_device_ops *ops)
590432 { return ERR_PTR(-ENODEV); }
591433 static inline struct thermal_cooling_device *
592434 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)
594437 { 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
+}
595446 static inline void thermal_cooling_device_unregister(
596447 struct thermal_cooling_device *cdev)
597448 { }
598449 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(
602450 const char *name)
603451 { return ERR_PTR(-ENODEV); }
604452 static inline int thermal_zone_get_temp(
....@@ -610,28 +458,22 @@
610458 static inline int thermal_zone_get_offset(
611459 struct thermal_zone_device *tz)
612460 { 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
+
619462 static inline void thermal_cdev_update(struct thermal_cooling_device *cdev)
620463 { }
621464 static inline void thermal_notify_framework(struct thermal_zone_device *tz,
622465 int trip)
623466 { }
624
-#endif /* CONFIG_THERMAL */
625467
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 */
636478
637479 #endif /* __THERMAL_H__ */