mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-30 03:27:44 -04:00
Merge branch 'pm-opp'
* pm-opp: PM / OPP: passing NULL to PTR_ERR() PM / OPP: Move cpu specific code to opp/cpu.c PM / OPP: Move opp core to its own directory PM / OPP: Prefix exported opp routines with dev_pm_opp_ PM / OPP: Rename opp init/free table routines PM / OPP: reuse of_parse_phandle()
This commit is contained in:
commit
394f7164e6
15 changed files with 473 additions and 479 deletions
|
|
@ -1,6 +1,5 @@
|
|||
# CPUfreq core
|
||||
obj-$(CONFIG_CPU_FREQ) += cpufreq.o freq_table.o
|
||||
obj-$(CONFIG_PM_OPP) += cpufreq_opp.o
|
||||
|
||||
# CPUfreq stats
|
||||
obj-$(CONFIG_CPU_FREQ_STAT) += cpufreq_stats.o
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ struct cpufreq_arm_bL_ops {
|
|||
|
||||
/*
|
||||
* This must set opp table for cpu_dev in a similar way as done by
|
||||
* of_init_opp_table().
|
||||
* dev_pm_opp_of_add_table().
|
||||
*/
|
||||
int (*init_opp_table)(struct device *cpu_dev);
|
||||
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@ static int dt_init_opp_table(struct device *cpu_dev)
|
|||
return -ENOENT;
|
||||
}
|
||||
|
||||
ret = of_init_opp_table(cpu_dev);
|
||||
ret = dev_pm_opp_of_add_table(cpu_dev);
|
||||
of_node_put(np);
|
||||
|
||||
return ret;
|
||||
|
|
@ -82,7 +82,7 @@ static struct cpufreq_arm_bL_ops dt_bL_ops = {
|
|||
.name = "dt-bl",
|
||||
.get_transition_latency = dt_get_transition_latency,
|
||||
.init_opp_table = dt_init_opp_table,
|
||||
.free_opp_table = of_free_opp_table,
|
||||
.free_opp_table = dev_pm_opp_of_remove_table,
|
||||
};
|
||||
|
||||
static int generic_bL_probe(struct platform_device *pdev)
|
||||
|
|
|
|||
|
|
@ -216,7 +216,7 @@ static int cpufreq_init(struct cpufreq_policy *policy)
|
|||
}
|
||||
|
||||
/* Get OPP-sharing information from "operating-points-v2" bindings */
|
||||
ret = of_get_cpus_sharing_opps(cpu_dev, policy->cpus);
|
||||
ret = dev_pm_opp_of_get_sharing_cpus(cpu_dev, policy->cpus);
|
||||
if (ret) {
|
||||
/*
|
||||
* operating-points-v2 not supported, fallback to old method of
|
||||
|
|
@ -238,7 +238,7 @@ static int cpufreq_init(struct cpufreq_policy *policy)
|
|||
*
|
||||
* OPPs might be populated at runtime, don't check for error here
|
||||
*/
|
||||
of_cpumask_init_opp_table(policy->cpus);
|
||||
dev_pm_opp_of_cpumask_add_table(policy->cpus);
|
||||
|
||||
/*
|
||||
* But we need OPP table to function so if it is not there let's
|
||||
|
|
@ -261,7 +261,7 @@ static int cpufreq_init(struct cpufreq_policy *policy)
|
|||
* OPP tables are initialized only for policy->cpu, do it for
|
||||
* others as well.
|
||||
*/
|
||||
ret = set_cpus_sharing_opps(cpu_dev, policy->cpus);
|
||||
ret = dev_pm_opp_set_sharing_cpus(cpu_dev, policy->cpus);
|
||||
if (ret)
|
||||
dev_err(cpu_dev, "%s: failed to mark OPPs as shared: %d\n",
|
||||
__func__, ret);
|
||||
|
|
@ -368,7 +368,7 @@ out_free_cpufreq_table:
|
|||
out_free_priv:
|
||||
kfree(priv);
|
||||
out_free_opp:
|
||||
of_cpumask_free_opp_table(policy->cpus);
|
||||
dev_pm_opp_of_cpumask_remove_table(policy->cpus);
|
||||
out_node_put:
|
||||
of_node_put(np);
|
||||
out_put_reg_clk:
|
||||
|
|
@ -385,7 +385,7 @@ static int cpufreq_exit(struct cpufreq_policy *policy)
|
|||
|
||||
cpufreq_cooling_unregister(priv->cdev);
|
||||
dev_pm_opp_free_cpufreq_table(priv->cpu_dev, &policy->freq_table);
|
||||
of_cpumask_free_opp_table(policy->related_cpus);
|
||||
dev_pm_opp_of_cpumask_remove_table(policy->related_cpus);
|
||||
clk_put(policy->clk);
|
||||
if (!IS_ERR(priv->cpu_reg))
|
||||
regulator_put(priv->cpu_reg);
|
||||
|
|
|
|||
|
|
@ -1,114 +0,0 @@
|
|||
/*
|
||||
* Generic OPP helper interface for CPUFreq drivers
|
||||
*
|
||||
* Copyright (C) 2009-2014 Texas Instruments Incorporated.
|
||||
* Nishanth Menon
|
||||
* Romit Dasgupta
|
||||
* Kevin Hilman
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*/
|
||||
#include <linux/cpufreq.h>
|
||||
#include <linux/device.h>
|
||||
#include <linux/err.h>
|
||||
#include <linux/errno.h>
|
||||
#include <linux/export.h>
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/pm_opp.h>
|
||||
#include <linux/rcupdate.h>
|
||||
#include <linux/slab.h>
|
||||
|
||||
/**
|
||||
* dev_pm_opp_init_cpufreq_table() - create a cpufreq table for a device
|
||||
* @dev: device for which we do this operation
|
||||
* @table: Cpufreq table returned back to caller
|
||||
*
|
||||
* Generate a cpufreq table for a provided device- this assumes that the
|
||||
* opp list is already initialized and ready for usage.
|
||||
*
|
||||
* This function allocates required memory for the cpufreq table. It is
|
||||
* expected that the caller does the required maintenance such as freeing
|
||||
* the table as required.
|
||||
*
|
||||
* Returns -EINVAL for bad pointers, -ENODEV if the device is not found, -ENOMEM
|
||||
* if no memory available for the operation (table is not populated), returns 0
|
||||
* if successful and table is populated.
|
||||
*
|
||||
* WARNING: It is important for the callers to ensure refreshing their copy of
|
||||
* the table if any of the mentioned functions have been invoked in the interim.
|
||||
*
|
||||
* Locking: The internal device_opp and opp structures are RCU protected.
|
||||
* Since we just use the regular accessor functions to access the internal data
|
||||
* structures, we use RCU read lock inside this function. As a result, users of
|
||||
* this function DONOT need to use explicit locks for invoking.
|
||||
*/
|
||||
int dev_pm_opp_init_cpufreq_table(struct device *dev,
|
||||
struct cpufreq_frequency_table **table)
|
||||
{
|
||||
struct dev_pm_opp *opp;
|
||||
struct cpufreq_frequency_table *freq_table = NULL;
|
||||
int i, max_opps, ret = 0;
|
||||
unsigned long rate;
|
||||
|
||||
rcu_read_lock();
|
||||
|
||||
max_opps = dev_pm_opp_get_opp_count(dev);
|
||||
if (max_opps <= 0) {
|
||||
ret = max_opps ? max_opps : -ENODATA;
|
||||
goto out;
|
||||
}
|
||||
|
||||
freq_table = kcalloc((max_opps + 1), sizeof(*freq_table), GFP_ATOMIC);
|
||||
if (!freq_table) {
|
||||
ret = -ENOMEM;
|
||||
goto out;
|
||||
}
|
||||
|
||||
for (i = 0, rate = 0; i < max_opps; i++, rate++) {
|
||||
/* find next rate */
|
||||
opp = dev_pm_opp_find_freq_ceil(dev, &rate);
|
||||
if (IS_ERR(opp)) {
|
||||
ret = PTR_ERR(opp);
|
||||
goto out;
|
||||
}
|
||||
freq_table[i].driver_data = i;
|
||||
freq_table[i].frequency = rate / 1000;
|
||||
|
||||
/* Is Boost/turbo opp ? */
|
||||
if (dev_pm_opp_is_turbo(opp))
|
||||
freq_table[i].flags = CPUFREQ_BOOST_FREQ;
|
||||
}
|
||||
|
||||
freq_table[i].driver_data = i;
|
||||
freq_table[i].frequency = CPUFREQ_TABLE_END;
|
||||
|
||||
*table = &freq_table[0];
|
||||
|
||||
out:
|
||||
rcu_read_unlock();
|
||||
if (ret)
|
||||
kfree(freq_table);
|
||||
|
||||
return ret;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(dev_pm_opp_init_cpufreq_table);
|
||||
|
||||
/**
|
||||
* dev_pm_opp_free_cpufreq_table() - free the cpufreq table
|
||||
* @dev: device for which we do this operation
|
||||
* @table: table to free
|
||||
*
|
||||
* Free up the table allocated by dev_pm_opp_init_cpufreq_table
|
||||
*/
|
||||
void dev_pm_opp_free_cpufreq_table(struct device *dev,
|
||||
struct cpufreq_frequency_table **table)
|
||||
{
|
||||
if (!table)
|
||||
return;
|
||||
|
||||
kfree(*table);
|
||||
*table = NULL;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(dev_pm_opp_free_cpufreq_table);
|
||||
|
|
@ -360,7 +360,7 @@ static int exynos_cpufreq_probe(struct platform_device *pdev)
|
|||
goto err_put_node;
|
||||
}
|
||||
|
||||
ret = of_init_opp_table(dvfs_info->dev);
|
||||
ret = dev_pm_opp_of_add_table(dvfs_info->dev);
|
||||
if (ret) {
|
||||
dev_err(dvfs_info->dev, "failed to init OPP table: %d\n", ret);
|
||||
goto err_put_node;
|
||||
|
|
@ -424,7 +424,7 @@ static int exynos_cpufreq_probe(struct platform_device *pdev)
|
|||
err_free_table:
|
||||
dev_pm_opp_free_cpufreq_table(dvfs_info->dev, &dvfs_info->freq_table);
|
||||
err_free_opp:
|
||||
of_free_opp_table(dvfs_info->dev);
|
||||
dev_pm_opp_of_remove_table(dvfs_info->dev);
|
||||
err_put_node:
|
||||
of_node_put(np);
|
||||
dev_err(&pdev->dev, "%s: failed initialization\n", __func__);
|
||||
|
|
@ -435,7 +435,7 @@ static int exynos_cpufreq_remove(struct platform_device *pdev)
|
|||
{
|
||||
cpufreq_unregister_driver(&exynos_driver);
|
||||
dev_pm_opp_free_cpufreq_table(dvfs_info->dev, &dvfs_info->freq_table);
|
||||
of_free_opp_table(dvfs_info->dev);
|
||||
dev_pm_opp_of_remove_table(dvfs_info->dev);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -236,7 +236,7 @@ static int imx6q_cpufreq_probe(struct platform_device *pdev)
|
|||
*/
|
||||
num = dev_pm_opp_get_opp_count(cpu_dev);
|
||||
if (num < 0) {
|
||||
ret = of_init_opp_table(cpu_dev);
|
||||
ret = dev_pm_opp_of_add_table(cpu_dev);
|
||||
if (ret < 0) {
|
||||
dev_err(cpu_dev, "failed to init OPP table: %d\n", ret);
|
||||
goto put_reg;
|
||||
|
|
@ -346,7 +346,7 @@ free_freq_table:
|
|||
dev_pm_opp_free_cpufreq_table(cpu_dev, &freq_table);
|
||||
out_free_opp:
|
||||
if (free_opp)
|
||||
of_free_opp_table(cpu_dev);
|
||||
dev_pm_opp_of_remove_table(cpu_dev);
|
||||
put_reg:
|
||||
if (!IS_ERR(arm_reg))
|
||||
regulator_put(arm_reg);
|
||||
|
|
@ -378,7 +378,7 @@ static int imx6q_cpufreq_remove(struct platform_device *pdev)
|
|||
cpufreq_unregister_driver(&imx6q_cpufreq_driver);
|
||||
dev_pm_opp_free_cpufreq_table(cpu_dev, &freq_table);
|
||||
if (free_opp)
|
||||
of_free_opp_table(cpu_dev);
|
||||
dev_pm_opp_of_remove_table(cpu_dev);
|
||||
regulator_put(arm_reg);
|
||||
if (!IS_ERR(pu_reg))
|
||||
regulator_put(pu_reg);
|
||||
|
|
|
|||
|
|
@ -344,7 +344,7 @@ static int mtk_cpu_dvfs_info_init(struct mtk_cpu_dvfs_info *info, int cpu)
|
|||
/* Both presence and absence of sram regulator are valid cases. */
|
||||
sram_reg = regulator_get_exclusive(cpu_dev, "sram");
|
||||
|
||||
ret = of_init_opp_table(cpu_dev);
|
||||
ret = dev_pm_opp_of_add_table(cpu_dev);
|
||||
if (ret) {
|
||||
pr_warn("no OPP table for cpu%d\n", cpu);
|
||||
goto out_free_resources;
|
||||
|
|
@ -378,7 +378,7 @@ static int mtk_cpu_dvfs_info_init(struct mtk_cpu_dvfs_info *info, int cpu)
|
|||
return 0;
|
||||
|
||||
out_free_opp_table:
|
||||
of_free_opp_table(cpu_dev);
|
||||
dev_pm_opp_of_remove_table(cpu_dev);
|
||||
|
||||
out_free_resources:
|
||||
if (!IS_ERR(proc_reg))
|
||||
|
|
@ -404,7 +404,7 @@ static void mtk_cpu_dvfs_info_release(struct mtk_cpu_dvfs_info *info)
|
|||
if (!IS_ERR(info->inter_clk))
|
||||
clk_put(info->inter_clk);
|
||||
|
||||
of_free_opp_table(info->cpu_dev);
|
||||
dev_pm_opp_of_remove_table(info->cpu_dev);
|
||||
}
|
||||
|
||||
static int mtk_cpufreq_init(struct cpufreq_policy *policy)
|
||||
|
|
|
|||
Loading…
Reference in a new issue