2020-07-30 16:51:17 +00:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0 */
|
2015-09-10 17:09:30 +00:00
|
|
|
/*
|
|
|
|
* devfreq_cooling: Thermal cooling device implementation for devices using
|
|
|
|
* devfreq
|
|
|
|
*
|
|
|
|
* Copyright (C) 2014-2015 ARM Limited
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __DEVFREQ_COOLING_H__
|
|
|
|
#define __DEVFREQ_COOLING_H__
|
|
|
|
|
|
|
|
#include <linux/devfreq.h>
|
|
|
|
#include <linux/thermal.h>
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* struct devfreq_cooling_power - Devfreq cooling power ops
|
2017-05-04 11:34:32 +00:00
|
|
|
* @get_real_power: When this is set, the framework uses it to ask the
|
|
|
|
* device driver for the actual power.
|
|
|
|
* Some devices have more sophisticated methods
|
|
|
|
* (like power counters) to approximate the actual power
|
|
|
|
* that they use.
|
|
|
|
* This function provides more accurate data to the
|
|
|
|
* thermal governor. When the driver does not provide
|
|
|
|
* such function, framework just uses pre-calculated
|
|
|
|
* table and scale the power by 'utilization'
|
|
|
|
* (based on 'busy_time' and 'total_time' taken from
|
|
|
|
* devfreq 'last_status').
|
|
|
|
* The value returned by this function must be lower
|
|
|
|
* or equal than the maximum power value
|
|
|
|
* for the current state
|
|
|
|
* (which can be found in power_table[state]).
|
|
|
|
* When this interface is used, the power_table holds
|
|
|
|
* max total (static + dynamic) power value for each OPP.
|
2015-09-10 17:09:30 +00:00
|
|
|
*/
|
|
|
|
struct devfreq_cooling_power {
|
2017-05-04 11:34:32 +00:00
|
|
|
int (*get_real_power)(struct devfreq *df, u32 *power,
|
|
|
|
unsigned long freq, unsigned long voltage);
|
2015-09-10 17:09:30 +00:00
|
|
|
};
|
|
|
|
|
2016-09-15 14:44:22 +00:00
|
|
|
#ifdef CONFIG_DEVFREQ_THERMAL
|
|
|
|
|
2015-11-02 19:03:03 +00:00
|
|
|
struct thermal_cooling_device *
|
2015-09-10 17:09:30 +00:00
|
|
|
of_devfreq_cooling_register_power(struct device_node *np, struct devfreq *df,
|
|
|
|
struct devfreq_cooling_power *dfc_power);
|
2015-11-02 19:03:03 +00:00
|
|
|
struct thermal_cooling_device *
|
2015-09-10 17:09:30 +00:00
|
|
|
of_devfreq_cooling_register(struct device_node *np, struct devfreq *df);
|
2015-11-02 19:03:03 +00:00
|
|
|
struct thermal_cooling_device *devfreq_cooling_register(struct devfreq *df);
|
|
|
|
void devfreq_cooling_unregister(struct thermal_cooling_device *dfc);
|
2020-12-10 14:30:12 +00:00
|
|
|
struct thermal_cooling_device *
|
|
|
|
devfreq_cooling_em_register(struct devfreq *df,
|
|
|
|
struct devfreq_cooling_power *dfc_power);
|
2015-09-10 17:09:30 +00:00
|
|
|
|
|
|
|
#else /* !CONFIG_DEVFREQ_THERMAL */
|
|
|
|
|
2020-04-03 20:51:33 +00:00
|
|
|
static inline struct thermal_cooling_device *
|
2015-09-10 17:09:30 +00:00
|
|
|
of_devfreq_cooling_register_power(struct device_node *np, struct devfreq *df,
|
|
|
|
struct devfreq_cooling_power *dfc_power)
|
|
|
|
{
|
|
|
|
return ERR_PTR(-EINVAL);
|
|
|
|
}
|
|
|
|
|
2015-11-02 19:03:03 +00:00
|
|
|
static inline struct thermal_cooling_device *
|
2015-09-10 17:09:30 +00:00
|
|
|
of_devfreq_cooling_register(struct device_node *np, struct devfreq *df)
|
|
|
|
{
|
|
|
|
return ERR_PTR(-EINVAL);
|
|
|
|
}
|
|
|
|
|
2015-11-02 19:03:03 +00:00
|
|
|
static inline struct thermal_cooling_device *
|
2015-09-10 17:09:30 +00:00
|
|
|
devfreq_cooling_register(struct devfreq *df)
|
|
|
|
{
|
|
|
|
return ERR_PTR(-EINVAL);
|
|
|
|
}
|
|
|
|
|
2020-12-10 14:30:12 +00:00
|
|
|
static inline struct thermal_cooling_device *
|
|
|
|
devfreq_cooling_em_register(struct devfreq *df,
|
|
|
|
struct devfreq_cooling_power *dfc_power)
|
|
|
|
{
|
|
|
|
return ERR_PTR(-EINVAL);
|
|
|
|
}
|
|
|
|
|
2015-09-10 17:09:30 +00:00
|
|
|
static inline void
|
2015-11-02 19:03:03 +00:00
|
|
|
devfreq_cooling_unregister(struct thermal_cooling_device *dfc)
|
2015-09-10 17:09:30 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* CONFIG_DEVFREQ_THERMAL */
|
|
|
|
#endif /* __DEVFREQ_COOLING_H__ */
|