dma-buf: add release callback support
[firefly-linux-kernel-4.4.55.git] / include / linux / thermal.h
index 613c29bd6baf4763e57530b794df843d9cea61ee..328d6c0a907397960a15b6bd70fac769ee23bb93 100644 (file)
@@ -43,6 +43,9 @@
 /* Default weight of a bound cooling device */
 #define THERMAL_WEIGHT_DEFAULT 0
 
+/* use value, which < 0K, to indicate an invalid/uninitialized temperature */
+#define THERMAL_TEMP_INVALID   -274000
+
 /* Unit conversion macros */
 #define DECI_KELVIN_TO_CELSIUS(t)      ({                      \
        long _t = (t);                                          \
@@ -95,6 +98,7 @@ struct thermal_zone_device_ops {
        int (*unbind) (struct thermal_zone_device *,
                       struct thermal_cooling_device *);
        int (*get_temp) (struct thermal_zone_device *, int *);
+       int (*set_trips) (struct thermal_zone_device *, int, int);
        int (*get_mode) (struct thermal_zone_device *,
                         enum thermal_device_mode *);
        int (*set_mode) (struct thermal_zone_device *,
@@ -153,6 +157,7 @@ struct thermal_attr {
  * @trip_hyst_attrs:   attributes for trip points for sysfs: trip hysteresis
  * @devdata:   private pointer for device private data
  * @trips:     number of trip points the thermal zone supports
+ * @trips_disabled;    bitmap for disabled trips
  * @passive_delay:     number of milliseconds to wait between polls when
  *                     performing passive cooling.
  * @polling_delay:     number of milliseconds to wait between polls when
@@ -167,6 +172,7 @@ struct thermal_attr {
  * @forced_passive:    If > 0, temperature at which to switch on all ACPI
  *                     processor cooling devices.  Currently only used by the
  *                     step-wise governor.
+ * @need_update:       if equals 1, thermal_zone_device_update needs to be invoked.
  * @ops:       operations this &thermal_zone_device supports
  * @tzp:       thermal zone parameters
  * @governor:  pointer to the governor for this thermal zone
@@ -187,13 +193,17 @@ struct thermal_zone_device {
        struct thermal_attr *trip_hyst_attrs;
        void *devdata;
        int trips;
+       unsigned long trips_disabled;   /* bitmap for disabled trips */
        int passive_delay;
        int polling_delay;
        int temperature;
        int last_temperature;
        int emul_temperature;
        int passive;
+       int prev_low_trip;
+       int prev_high_trip;
        unsigned int forced_passive;
+       atomic_t need_update;
        struct thermal_zone_device_ops *ops;
        struct thermal_zone_params *tzp;
        struct thermal_governor *governor;
@@ -326,13 +336,18 @@ struct thermal_genl_event {
  *
  * Optional:
  * @get_trend: a pointer to a function that reads the sensor temperature trend.
+ * @@set_trips: a pointer to a function that sets a temperature window. When this
+ *              window is left the driver must inform the thermal core via
+ *              thermal_zone_device_update.
  * @set_emul_temp: a pointer to a function that sets sensor emulated
  *                temperature.
  */
 struct thermal_zone_of_device_ops {
        int (*get_temp)(void *, int *);
-       int (*get_trend)(void *, long *);
+       int (*get_trend)(void *, int, enum thermal_trend *);
+       int (*set_trips)(void *, int, int);
        int (*set_emul_temp)(void *, int);
+       int (*set_trip_temp)(void *, int, int);
 };
 
 /**
@@ -345,8 +360,8 @@ struct thermal_zone_of_device_ops {
 
 struct thermal_trip {
        struct device_node *np;
-       unsigned long int temperature;
-       unsigned long int hysteresis;
+       int temperature;
+       int hysteresis;
        enum thermal_trip_type type;
 };
 
@@ -357,6 +372,11 @@ thermal_zone_of_sensor_register(struct device *dev, int id, void *data,
                                const struct thermal_zone_of_device_ops *ops);
 void thermal_zone_of_sensor_unregister(struct device *dev,
                                       struct thermal_zone_device *tz);
+struct thermal_zone_device *devm_thermal_zone_of_sensor_register(
+               struct device *dev, int id, void *data,
+               const struct thermal_zone_of_device_ops *ops);
+void devm_thermal_zone_of_sensor_unregister(struct device *dev,
+                                           struct thermal_zone_device *tz);
 #else
 static inline struct thermal_zone_device *
 thermal_zone_of_sensor_register(struct device *dev, int id, void *data,
@@ -371,6 +391,19 @@ void thermal_zone_of_sensor_unregister(struct device *dev,
 {
 }
 
+static inline struct thermal_zone_device *devm_thermal_zone_of_sensor_register(
+               struct device *dev, int id, void *data,
+               const struct thermal_zone_of_device_ops *ops)
+{
+       return ERR_PTR(-ENODEV);
+}
+
+static inline
+void devm_thermal_zone_of_sensor_unregister(struct device *dev,
+                                           struct thermal_zone_device *tz)
+{
+}
+
 #endif
 
 #if IS_ENABLED(CONFIG_THERMAL)