mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-06 19:08:57 +09:00
video: rockchip: mpp: rkvdec: remove old power model
Signed-off-by: Finley Xiao <finley.xiao@rock-chips.com> Change-Id: I1b6307901c0e37f4ff46d63bd23baf0bb17a528f
This commit is contained in:
@@ -12,7 +12,6 @@
|
||||
#include <linux/clk.h>
|
||||
#include <linux/delay.h>
|
||||
#include <linux/devfreq.h>
|
||||
#include <linux/devfreq_cooling.h>
|
||||
#include <linux/gfp.h>
|
||||
#include <linux/interrupt.h>
|
||||
#include <linux/iopoll.h>
|
||||
@@ -182,7 +181,6 @@ struct rkvdec_dev {
|
||||
struct devfreq *devfreq;
|
||||
struct devfreq *parent_devfreq;
|
||||
struct notifier_block devfreq_nb;
|
||||
struct thermal_cooling_device *devfreq_cooling;
|
||||
struct thermal_zone_device *thermal_zone;
|
||||
u32 static_power_coeff;
|
||||
s32 ts[4];
|
||||
@@ -418,106 +416,9 @@ static struct devfreq_dev_profile devfreq_profile = {
|
||||
.target = devfreq_target,
|
||||
.get_cur_freq = devfreq_get_cur_freq,
|
||||
.get_dev_status = devfreq_get_dev_status,
|
||||
.is_cooling_device = true,
|
||||
};
|
||||
|
||||
static unsigned long
|
||||
model_static_power(struct devfreq *devfreq,
|
||||
unsigned long voltage)
|
||||
{
|
||||
struct device *dev = devfreq->dev.parent;
|
||||
struct rkvdec_dev *dec = dev_get_drvdata(dev);
|
||||
struct thermal_zone_device *tz = dec->thermal_zone;
|
||||
|
||||
int temperature;
|
||||
unsigned long temp;
|
||||
unsigned long temp_squared, temp_cubed, temp_scaling_factor;
|
||||
const unsigned long voltage_cubed = (voltage * voltage * voltage) >> 10;
|
||||
|
||||
if (!IS_ERR_OR_NULL(tz) && tz->ops->get_temp) {
|
||||
int ret;
|
||||
|
||||
ret = tz->ops->get_temp(tz, &temperature);
|
||||
if (ret) {
|
||||
dev_warn_ratelimited(dev, "ddr thermal zone failed\n");
|
||||
temperature = FALLBACK_STATIC_TEMPERATURE;
|
||||
}
|
||||
} else {
|
||||
temperature = FALLBACK_STATIC_TEMPERATURE;
|
||||
}
|
||||
|
||||
/*
|
||||
* Calculate the temperature scaling factor. To be applied to the
|
||||
* voltage scaled power.
|
||||
*/
|
||||
temp = temperature / 1000;
|
||||
temp_squared = temp * temp;
|
||||
temp_cubed = temp_squared * temp;
|
||||
temp_scaling_factor = (dec->ts[3] * temp_cubed)
|
||||
+ (dec->ts[2] * temp_squared) + (dec->ts[1] * temp) + dec->ts[0];
|
||||
|
||||
return (((dec->static_power_coeff * voltage_cubed) >> 20)
|
||||
* temp_scaling_factor) / 1000000;
|
||||
}
|
||||
|
||||
static struct devfreq_cooling_power cooling_power_data = {
|
||||
.get_static_power = model_static_power,
|
||||
.dyn_power_coeff = 120,
|
||||
};
|
||||
|
||||
static int power_model_simple_init(struct mpp_dev *mpp)
|
||||
{
|
||||
struct rkvdec_dev *dec = to_rkvdec_dev(mpp);
|
||||
struct device_node *np = mpp->dev->of_node;
|
||||
|
||||
u32 temp;
|
||||
const char *tz_name;
|
||||
struct device_node *power_model_node;
|
||||
|
||||
power_model_node = of_get_child_by_name(np, "vcodec_power_model");
|
||||
if (!power_model_node) {
|
||||
dev_err(mpp->dev, "could not find power_model node\n");
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
if (of_property_read_string(power_model_node,
|
||||
"thermal-zone",
|
||||
&tz_name)) {
|
||||
dev_err(mpp->dev, "ts in power_model not available\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
dec->thermal_zone = thermal_zone_get_zone_by_name(tz_name);
|
||||
if (IS_ERR(dec->thermal_zone)) {
|
||||
pr_warn("Error getting ddr thermal zone, not yet ready?\n");
|
||||
dec->thermal_zone = NULL;
|
||||
return -EPROBE_DEFER;
|
||||
}
|
||||
|
||||
if (of_property_read_u32(power_model_node,
|
||||
"static-power-coefficient",
|
||||
&dec->static_power_coeff)) {
|
||||
dev_err(mpp->dev, "static-power-coefficient not available\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
if (of_property_read_u32(power_model_node,
|
||||
"dynamic-power-coefficient",
|
||||
&temp)) {
|
||||
dev_err(mpp->dev, "dynamic-power-coefficient not available\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
cooling_power_data.dyn_power_coeff = (unsigned long)temp;
|
||||
|
||||
if (of_property_read_u32_array(power_model_node,
|
||||
"ts",
|
||||
(u32 *)dec->ts,
|
||||
4)) {
|
||||
dev_err(mpp->dev, "ts in power_model not available\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int devfreq_notifier_call(struct notifier_block *nb,
|
||||
unsigned long event,
|
||||
void *data)
|
||||
@@ -1370,38 +1271,25 @@ static int rkvdec_devfreq_init(struct mpp_dev *mpp)
|
||||
"rkvdec_leakage", "vcodec");
|
||||
if (ret) {
|
||||
dev_err(mpp->dev, "Failed to init_opp_table\n");
|
||||
goto done;
|
||||
return ret;
|
||||
}
|
||||
dec->devfreq = devm_devfreq_add_device(mpp->dev, &devfreq_profile,
|
||||
"userspace", NULL);
|
||||
if (IS_ERR(dec->devfreq)) {
|
||||
ret = PTR_ERR(dec->devfreq);
|
||||
goto done;
|
||||
return ret;
|
||||
}
|
||||
|
||||
stat = &dec->devfreq->last_status;
|
||||
stat->current_frequency = clk_get_rate(dec->aclk_info.clk);
|
||||
|
||||
ret = devfreq_register_opp_notifier(mpp->dev, dec->devfreq);
|
||||
if (ret)
|
||||
goto done;
|
||||
|
||||
/* power simplle init */
|
||||
ret = power_model_simple_init(mpp);
|
||||
if (!ret && dec->devfreq) {
|
||||
dec->devfreq_cooling =
|
||||
of_devfreq_cooling_register_power(mpp->dev->of_node,
|
||||
dec->devfreq,
|
||||
&cooling_power_data);
|
||||
if (IS_ERR_OR_NULL(dec->devfreq_cooling)) {
|
||||
ret = -ENXIO;
|
||||
dev_err(mpp->dev, "Failed to register cooling\n");
|
||||
goto done;
|
||||
}
|
||||
if (ret < 0) {
|
||||
dev_err(mpp->dev, "failed to register opp notifier\n");
|
||||
return ret;
|
||||
}
|
||||
|
||||
done:
|
||||
return ret;
|
||||
return 0;
|
||||
}
|
||||
#else
|
||||
static inline int rkvdec_devfreq_remove(struct mpp_dev *mpp)
|
||||
|
||||
Reference in New Issue
Block a user