Commit 69a07f18 authored by Rafael J. Wysocki's avatar Rafael J. Wysocki
Browse files

Merge back cpufreq changes for v4.12.

parents 2f0ba790 19678ffb
Loading
Loading
Loading
Loading
+1 −0
Original line number Original line Diff line number Diff line
@@ -3450,6 +3450,7 @@ T: git git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm.git
T:	git git://git.linaro.org/people/vireshk/linux.git (For ARM Updates)
T:	git git://git.linaro.org/people/vireshk/linux.git (For ARM Updates)
B:	https://bugzilla.kernel.org
B:	https://bugzilla.kernel.org
F:	Documentation/cpu-freq/
F:	Documentation/cpu-freq/
F:	Documentation/devicetree/bindings/cpufreq/
F:	drivers/cpufreq/
F:	drivers/cpufreq/
F:	include/linux/cpufreq.h
F:	include/linux/cpufreq.h
F:	tools/testing/selftests/cpufreq/
F:	tools/testing/selftests/cpufreq/
+0 −5
Original line number Original line Diff line number Diff line
@@ -1170,11 +1170,6 @@
			status = "disabled";
			status = "disabled";
		};
		};


		cpufreq-cooling {
			compatible = "stericsson,db8500-cpufreq-cooling";
			status = "disabled";
		};

		mcde@a0350000 {
		mcde@a0350000 {
			compatible = "stericsson,mcde";
			compatible = "stericsson,mcde";
			reg = <0xa0350000 0x1000>, /* MCDE */
			reg = <0xa0350000 0x1000>, /* MCDE */
+20 −0
Original line number Original line Diff line number Diff line
@@ -11,6 +11,7 @@
#include <linux/module.h>
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/kernel.h>
#include <linux/cpufreq.h>
#include <linux/cpufreq.h>
#include <linux/cpu_cooling.h>
#include <linux/delay.h>
#include <linux/delay.h>
#include <linux/slab.h>
#include <linux/slab.h>
#include <linux/platform_device.h>
#include <linux/platform_device.h>
@@ -18,6 +19,7 @@


static struct cpufreq_frequency_table *freq_table;
static struct cpufreq_frequency_table *freq_table;
static struct clk *armss_clk;
static struct clk *armss_clk;
static struct thermal_cooling_device *cdev;


static int dbx500_cpufreq_target(struct cpufreq_policy *policy,
static int dbx500_cpufreq_target(struct cpufreq_policy *policy,
				unsigned int index)
				unsigned int index)
@@ -32,6 +34,22 @@ static int dbx500_cpufreq_init(struct cpufreq_policy *policy)
	return cpufreq_generic_init(policy, freq_table, 20 * 1000);
	return cpufreq_generic_init(policy, freq_table, 20 * 1000);
}
}


static int dbx500_cpufreq_exit(struct cpufreq_policy *policy)
{
	if (!IS_ERR(cdev))
		cpufreq_cooling_unregister(cdev);
	return 0;
}

static void dbx500_cpufreq_ready(struct cpufreq_policy *policy)
{
	cdev = cpufreq_cooling_register(policy->cpus);
	if (IS_ERR(cdev))
		pr_err("Failed to register cooling device %ld\n", PTR_ERR(cdev));
	else
		pr_info("Cooling device registered: %s\n", cdev->type);
}

static struct cpufreq_driver dbx500_cpufreq_driver = {
static struct cpufreq_driver dbx500_cpufreq_driver = {
	.flags  = CPUFREQ_STICKY | CPUFREQ_CONST_LOOPS |
	.flags  = CPUFREQ_STICKY | CPUFREQ_CONST_LOOPS |
			CPUFREQ_NEED_INITIAL_FREQ_CHECK,
			CPUFREQ_NEED_INITIAL_FREQ_CHECK,
@@ -39,6 +57,8 @@ static struct cpufreq_driver dbx500_cpufreq_driver = {
	.target_index = dbx500_cpufreq_target,
	.target_index = dbx500_cpufreq_target,
	.get    = cpufreq_generic_get,
	.get    = cpufreq_generic_get,
	.init   = dbx500_cpufreq_init,
	.init   = dbx500_cpufreq_init,
	.exit  = dbx500_cpufreq_exit,
	.ready  = dbx500_cpufreq_ready,
	.name   = "DBX500",
	.name   = "DBX500",
	.attr   = cpufreq_generic_attr,
	.attr   = cpufreq_generic_attr,
};
};
+21 −2
Original line number Original line Diff line number Diff line
@@ -573,14 +573,33 @@ static struct platform_driver mt8173_cpufreq_platdrv = {
	.probe		= mt8173_cpufreq_probe,
	.probe		= mt8173_cpufreq_probe,
};
};


static int mt8173_cpufreq_driver_init(void)
/* List of machines supported by this driver */
static const struct of_device_id mt8173_cpufreq_machines[] __initconst = {
	{ .compatible = "mediatek,mt817x", },
	{ .compatible = "mediatek,mt8173", },
	{ .compatible = "mediatek,mt8176", },

	{ }
};

static int __init mt8173_cpufreq_driver_init(void)
{
{
	struct device_node *np;
	const struct of_device_id *match;
	struct platform_device *pdev;
	struct platform_device *pdev;
	int err;
	int err;


	if (!of_machine_is_compatible("mediatek,mt8173"))
	np = of_find_node_by_path("/");
	if (!np)
		return -ENODEV;
		return -ENODEV;


	match = of_match_node(mt8173_cpufreq_machines, np);
	of_node_put(np);
	if (!match) {
		pr_warn("Machine is not compatible with mt8173-cpufreq\n");
		return -ENODEV;
	}

	err = platform_driver_register(&mt8173_cpufreq_platdrv);
	err = platform_driver_register(&mt8173_cpufreq_platdrv);
	if (err)
	if (err)
		return err;
		return err;
+17 −7
Original line number Original line Diff line number Diff line
@@ -52,19 +52,29 @@ static u32 get_bus_freq(void)
{
{
	struct device_node *soc;
	struct device_node *soc;
	u32 sysfreq;
	u32 sysfreq;
	struct clk *pltclk;
	int ret;


	/* get platform freq by searching bus-frequency property */
	soc = of_find_node_by_type(NULL, "soc");
	soc = of_find_node_by_type(NULL, "soc");
	if (!soc)
	if (soc) {
		return 0;
		ret = of_property_read_u32(soc, "bus-frequency", &sysfreq);

	if (of_property_read_u32(soc, "bus-frequency", &sysfreq))
		sysfreq = 0;

		of_node_put(soc);
		of_node_put(soc);

		if (!ret)
			return sysfreq;
			return sysfreq;
	}
	}


	/* get platform freq by its clock name */
	pltclk = clk_get(NULL, "cg-pll0-div1");
	if (IS_ERR(pltclk)) {
		pr_err("%s: can't get bus frequency %ld\n",
		       __func__, PTR_ERR(pltclk));
		return PTR_ERR(pltclk);
	}

	return clk_get_rate(pltclk);
}

static struct clk *cpu_to_clk(int cpu)
static struct clk *cpu_to_clk(int cpu)
{
{
	struct device_node *np;
	struct device_node *np;
Loading