mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-08 03:40:35 +09:00
MALI: bifrost: Add support to only calculate dynamic power
Signed-off-by: Finley Xiao <finley.xiao@rock-chips.com> Change-Id: I62047acb6a57652c9473d117651f4bf75fcbbb28
This commit is contained in:
@@ -670,14 +670,11 @@ static unsigned long kbase_devfreq_get_static_power(struct devfreq *devfreq,
|
||||
return rockchip_ipa_get_static_power(kbdev->model_data, voltage);
|
||||
}
|
||||
|
||||
static struct devfreq_cooling_power kbase_cooling_power = {
|
||||
.get_static_power = &kbase_devfreq_get_static_power,
|
||||
};
|
||||
|
||||
int kbase_devfreq_init(struct kbase_device *kbdev)
|
||||
{
|
||||
struct devfreq_cooling_power *kbase_dcp = &kbase_cooling_power;
|
||||
struct devfreq_cooling_power *kbase_dcp = &kbdev->dfc_power;
|
||||
struct device_node *np = kbdev->dev->of_node;
|
||||
struct device_node *model_node;
|
||||
struct devfreq_dev_profile *dp;
|
||||
int err;
|
||||
struct dev_pm_opp *opp;
|
||||
@@ -776,26 +773,33 @@ int kbase_devfreq_init(struct kbase_device *kbdev)
|
||||
mali_mdevp.is_checked = true;
|
||||
}
|
||||
#if IS_ENABLED(CONFIG_DEVFREQ_THERMAL)
|
||||
if (of_find_compatible_node(kbdev->dev->of_node, NULL,
|
||||
"simple-power-model")) {
|
||||
of_property_read_u32(kbdev->dev->of_node,
|
||||
"dynamic-power-coefficient",
|
||||
(u32 *)&kbase_dcp->dyn_power_coeff);
|
||||
kbdev->model_data = rockchip_ipa_power_model_init(kbdev->dev,
|
||||
"gpu_leakage");
|
||||
of_property_read_u32(kbdev->dev->of_node, "dynamic-power-coefficient",
|
||||
(u32 *)&kbase_dcp->dyn_power_coeff);
|
||||
model_node = of_get_compatible_child(kbdev->dev->of_node,
|
||||
"simple-power-model");
|
||||
if (model_node) {
|
||||
of_node_put(model_node);
|
||||
kbdev->model_data =
|
||||
rockchip_ipa_power_model_init(kbdev->dev,
|
||||
"gpu_leakage");
|
||||
if (IS_ERR_OR_NULL(kbdev->model_data)) {
|
||||
kbdev->model_data = NULL;
|
||||
dev_err(kbdev->dev, "failed to initialize power model\n");
|
||||
} else if (kbdev->model_data->dynamic_coefficient) {
|
||||
kbase_dcp->dyn_power_coeff =
|
||||
kbdev->model_data->dynamic_coefficient;
|
||||
}
|
||||
if (!kbase_dcp->dyn_power_coeff) {
|
||||
err = -EINVAL;
|
||||
dev_err(kbdev->dev, "failed to get dynamic-coefficient\n");
|
||||
goto ipa_init_failed;
|
||||
if (kbase_dcp->dyn_power_coeff)
|
||||
dev_info(kbdev->dev,
|
||||
"only calculate dynamic power\n");
|
||||
else
|
||||
dev_err(kbdev->dev,
|
||||
"failed to initialize power model\n");
|
||||
} else {
|
||||
kbase_dcp->get_static_power =
|
||||
kbase_devfreq_get_static_power;
|
||||
if (kbdev->model_data->dynamic_coefficient)
|
||||
kbase_dcp->dyn_power_coeff =
|
||||
kbdev->model_data->dynamic_coefficient;
|
||||
}
|
||||
}
|
||||
|
||||
if (kbase_dcp->dyn_power_coeff) {
|
||||
kbdev->devfreq_cooling =
|
||||
of_devfreq_cooling_register_power(kbdev->dev->of_node,
|
||||
kbdev->devfreq,
|
||||
@@ -803,7 +807,7 @@ int kbase_devfreq_init(struct kbase_device *kbdev)
|
||||
if (IS_ERR(kbdev->devfreq_cooling)) {
|
||||
err = PTR_ERR(kbdev->devfreq_cooling);
|
||||
dev_err(kbdev->dev, "failed to register cooling device\n");
|
||||
goto cooling_reg_failed;
|
||||
goto ipa_init_failed;
|
||||
}
|
||||
} else {
|
||||
err = kbase_ipa_init(kbdev);
|
||||
|
||||
@@ -4821,7 +4821,8 @@ int kbase_device_debugfs_init(struct kbase_device *kbdev)
|
||||
|
||||
#ifdef CONFIG_MALI_BIFROST_DEVFREQ
|
||||
#if IS_ENABLED(CONFIG_DEVFREQ_THERMAL)
|
||||
if (kbdev->devfreq && !kbdev->model_data)
|
||||
if (kbdev->devfreq && !kbdev->model_data &&
|
||||
!kbdev->dfc_power.dyn_power_coeff)
|
||||
kbase_ipa_debugfs_init(kbdev);
|
||||
#endif /* CONFIG_DEVFREQ_THERMAL */
|
||||
#endif /* CONFIG_MALI_BIFROST_DEVFREQ */
|
||||
|
||||
@@ -63,6 +63,10 @@
|
||||
#include <linux/devfreq.h>
|
||||
#endif /* CONFIG_MALI_BIFROST_DEVFREQ */
|
||||
|
||||
#if IS_ENABLED(CONFIG_DEVFREQ_THERMAL)
|
||||
#include <linux/devfreq_cooling.h>
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_MALI_ARBITER_SUPPORT
|
||||
#include <arbiter/mali_kbase_arbiter_defs.h>
|
||||
#endif /* CONFIG_MALI_ARBITER_SUPPORT */
|
||||
@@ -1077,6 +1081,7 @@ struct kbase_device {
|
||||
struct kbase_devfreq_queue_info devfreq_queue;
|
||||
|
||||
#if IS_ENABLED(CONFIG_DEVFREQ_THERMAL)
|
||||
struct devfreq_cooling_power dfc_power;
|
||||
struct thermal_cooling_device *devfreq_cooling;
|
||||
bool ipa_protection_mode_switched;
|
||||
struct {
|
||||
|
||||
Reference in New Issue
Block a user