Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 /*
0003  * devfreq_cooling: Thermal cooling device implementation for devices using
0004  *                  devfreq
0005  *
0006  * Copyright (C) 2014-2015 ARM Limited
0007  *
0008  */
0009 
0010 #ifndef __DEVFREQ_COOLING_H__
0011 #define __DEVFREQ_COOLING_H__
0012 
0013 #include <linux/devfreq.h>
0014 #include <linux/thermal.h>
0015 
0016 
0017 /**
0018  * struct devfreq_cooling_power - Devfreq cooling power ops
0019  * @get_real_power: When this is set, the framework uses it to ask the
0020  *          device driver for the actual power.
0021  *          Some devices have more sophisticated methods
0022  *          (like power counters) to approximate the actual power
0023  *          that they use.
0024  *          This function provides more accurate data to the
0025  *          thermal governor. When the driver does not provide
0026  *          such function, framework just uses pre-calculated
0027  *          table and scale the power by 'utilization'
0028  *          (based on 'busy_time' and 'total_time' taken from
0029  *          devfreq 'last_status').
0030  *          The value returned by this function must be lower
0031  *          or equal than the maximum power value
0032  *          for the current state
0033  *          (which can be found in power_table[state]).
0034  *          When this interface is used, the power_table holds
0035  *          max total (static + dynamic) power value for each OPP.
0036  */
0037 struct devfreq_cooling_power {
0038     int (*get_real_power)(struct devfreq *df, u32 *power,
0039                   unsigned long freq, unsigned long voltage);
0040 };
0041 
0042 #ifdef CONFIG_DEVFREQ_THERMAL
0043 
0044 struct thermal_cooling_device *
0045 of_devfreq_cooling_register_power(struct device_node *np, struct devfreq *df,
0046                   struct devfreq_cooling_power *dfc_power);
0047 struct thermal_cooling_device *
0048 of_devfreq_cooling_register(struct device_node *np, struct devfreq *df);
0049 struct thermal_cooling_device *devfreq_cooling_register(struct devfreq *df);
0050 void devfreq_cooling_unregister(struct thermal_cooling_device *dfc);
0051 struct thermal_cooling_device *
0052 devfreq_cooling_em_register(struct devfreq *df,
0053                 struct devfreq_cooling_power *dfc_power);
0054 
0055 #else /* !CONFIG_DEVFREQ_THERMAL */
0056 
0057 static inline struct thermal_cooling_device *
0058 of_devfreq_cooling_register_power(struct device_node *np, struct devfreq *df,
0059                   struct devfreq_cooling_power *dfc_power)
0060 {
0061     return ERR_PTR(-EINVAL);
0062 }
0063 
0064 static inline struct thermal_cooling_device *
0065 of_devfreq_cooling_register(struct device_node *np, struct devfreq *df)
0066 {
0067     return ERR_PTR(-EINVAL);
0068 }
0069 
0070 static inline struct thermal_cooling_device *
0071 devfreq_cooling_register(struct devfreq *df)
0072 {
0073     return ERR_PTR(-EINVAL);
0074 }
0075 
0076 static inline struct thermal_cooling_device *
0077 devfreq_cooling_em_register(struct devfreq *df,
0078                 struct devfreq_cooling_power *dfc_power)
0079 {
0080     return ERR_PTR(-EINVAL);
0081 }
0082 
0083 static inline void
0084 devfreq_cooling_unregister(struct thermal_cooling_device *dfc)
0085 {
0086 }
0087 
0088 #endif /* CONFIG_DEVFREQ_THERMAL */
0089 #endif /* __DEVFREQ_COOLING_H__ */