soc: rockchip: ipa: Add support to be build as module

Signed-off-by: Finley Xiao <finley.xiao@rock-chips.com>
Change-Id: I71caeb44f4d31da03e3a5ca56c2a24edc6486ebd
This commit is contained in:
Finley Xiao 2020-07-12 10:57:14 +08:00 committed by Tao Huang
parent b3fc2ac3b2
commit d4f55632eb
5 changed files with 64 additions and 44 deletions

View File

@ -41,7 +41,7 @@ config ROCKCHIP_HW_DECOMPRESS
LZ4, GZIP, ZLIB.
config ROCKCHIP_IPA
bool "Rockchip IPA support"
tristate "Rockchip IPA support"
depends on THERMAL && OF
default y
help

View File

@ -4,12 +4,16 @@
*/
#include <linux/kernel.h>
#include <linux/of.h>
#include <linux/module.h>
#include <linux/slab.h>
#include <linux/thermal.h>
#include <soc/rockchip/rockchip_ipa.h>
#include <soc/rockchip/rockchip_opp_select.h>
#include <trace/events/thermal.h>
#define CREATE_TRACE_POINTS
#include <trace/events/thermal_ipa_power.h>
#define FALLBACK_STATIC_TEMPERATURE 55000
static void calculate_static_coefficient(struct ipa_power_model_data *data)
@ -205,14 +209,18 @@ rockchip_ipa_get_static_power(struct ipa_power_model_data *data,
power_big = (u64)static_power * (u64)volt_scaling_factor;
static_power = div_u64(power_big, 1000000);
trace_thermal_power_get_static_power(data->leakage,
data->static_coefficient,
temp,
temp_scaling_factor,
(u32)voltage_mv,
volt_scaling_factor,
static_power);
trace_thermal_ipa_get_static_power(data->leakage,
data->static_coefficient,
temp,
temp_scaling_factor,
(u32)voltage_mv,
volt_scaling_factor,
static_power);
return static_power;
}
EXPORT_SYMBOL(rockchip_ipa_get_static_power);
MODULE_DESCRIPTION("Rockchip IPA driver");
MODULE_AUTHOR("Finley Xiao <finley.xiao@rock-chips.com>");
MODULE_LICENSE("GPL");

View File

@ -16,7 +16,7 @@ struct ipa_power_model_data {
s32 ls[3]; /* leakage scaling factor */
};
#ifdef CONFIG_ROCKCHIP_IPA
#if IS_ENABLED(CONFIG_ROCKCHIP_IPA)
struct ipa_power_model_data *rockchip_ipa_power_model_init(struct device *dev,
char *lkg_name);
unsigned long

View File

@ -91,41 +91,6 @@ TRACE_EVENT(thermal_zone_trip,
show_tzt_type(__entry->trip_type))
);
#ifdef CONFIG_ROCKCHIP_IPA
TRACE_EVENT(thermal_power_get_static_power,
TP_PROTO(u32 leakage, u32 coefficient, s32 temp,
u32 temp_scaling_factor, u32 volt, u32 volt_scaling_factor,
u32 static_power),
TP_ARGS(leakage, coefficient, temp, temp_scaling_factor, volt,
volt_scaling_factor, static_power),
TP_STRUCT__entry(
__field(u32, leakage)
__field(u32, coefficient)
__field(s32, temp)
__field(u32, temp_scaling_factor)
__field(u32, volt)
__field(u32, volt_scaling_factor)
__field(u32, static_power)
),
TP_fast_assign(
__entry->leakage = leakage;
__entry->coefficient = coefficient;
__entry->temp = temp;
__entry->temp_scaling_factor = temp_scaling_factor;
__entry->volt = volt;
__entry->volt_scaling_factor = volt_scaling_factor;
__entry->static_power = static_power;
),
TP_printk("lkg=%u c=%u t=%d ts=%u v=%u vs=%u static_power=%u",
__entry->leakage, __entry->coefficient, __entry->temp,
__entry->temp_scaling_factor, __entry->volt,
__entry->volt_scaling_factor, __entry->static_power)
);
#endif /* CONFIG_ROCKCHIP_IPA */
#ifdef CONFIG_CPU_THERMAL
TRACE_EVENT(thermal_power_cpu_get_power,
TP_PROTO(const struct cpumask *cpus, unsigned long freq, u32 *load,

View File

@ -0,0 +1,47 @@
/* SPDX-License-Identifier: GPL-2.0 */
#undef TRACE_SYSTEM
#define TRACE_SYSTEM thermal_ipa_power
#if !defined(_TRACE_THERMAL_IPA_POWER_H) || defined(TRACE_HEADER_MULTI_READ)
#define _TRACE_THERMAL_IPA_POWER_H
#include <linux/tracepoint.h>
TRACE_EVENT(thermal_ipa_get_static_power,
TP_PROTO(u32 leakage, u32 coefficient, s32 temp,
u32 temp_scaling_factor, u32 volt, u32 volt_scaling_factor,
u32 static_power),
TP_ARGS(leakage, coefficient, temp, temp_scaling_factor, volt,
volt_scaling_factor, static_power),
TP_STRUCT__entry(
__field(u32, leakage)
__field(u32, coefficient)
__field(s32, temp)
__field(u32, temp_scaling_factor)
__field(u32, volt)
__field(u32, volt_scaling_factor)
__field(u32, static_power)
),
TP_fast_assign(
__entry->leakage = leakage;
__entry->coefficient = coefficient;
__entry->temp = temp;
__entry->temp_scaling_factor = temp_scaling_factor;
__entry->volt = volt;
__entry->volt_scaling_factor = volt_scaling_factor;
__entry->static_power = static_power;
),
TP_printk("lkg=%u c=%u t=%d ts=%u v=%u vs=%u static_power=%u",
__entry->leakage, __entry->coefficient, __entry->temp,
__entry->temp_scaling_factor, __entry->volt,
__entry->volt_scaling_factor, __entry->static_power)
);
#endif /* _TRACE_THERMAL_IPA_POWER_H */
/* This part must be outside protection */
#include <trace/define_trace.h>