Commit 49ded525 authored by Nishanth Menon's avatar Nishanth Menon Committed by Rafael J. Wysocki

cpufreq: OMAP: instantiate omap-cpufreq as a platform_driver

As multi-platform build is being adopted by more and more ARM platforms,
initcall function should be used very carefully.  For example, when
CONFIG_ARM_OMAP2PLUS_CPUFREQ is built in the kernel, omap_cpufreq_init()
will be called on all the platforms to initialize omap-cpufreq driver.

Further, on OMAP, we now use Soc generic cpufreq-cpu0 driver using device
tree entries.  To allow cpufreq-cpu0 and omap-cpufreq drivers to co-exist
for OMAP in a single image, we need to ensure the following:
 1. With device tree boot, we use cpufreq-cpu0
 2. With non device tree boot, we use omap-cpufreq

In the case of (1), we will have cpu OPPs and regulator registered
as part of the device tree nodes, to ensure that omap-cpufreq
and cpufreq-cpu0 don't conflict in managing the frequency of the
same CPU, we should not permit omap-cpufreq to be probed.

In the case of (2), we will not have the cpufreq-cpu0 device, hence
only omap-cpufreq will be active.

To eliminate this undesired these effects, we change omap-cpufreq
driver to have it instantiated as a platform_driver and register
"omap-cpufreq" device only when booted without device tree nodes on
OMAP platforms.

This allows the following:
 a) Will only run on platforms that create the platform_device
    "omap-cpufreq".
 b) Since the platform_device is registered only when device tree nodes
    are *not* populated, omap-cpufreq driver does not conflict with
    the usage of cpufreq-cpu0 driver which is used on OMAP platforms when
    device tree nodes are present.

Inspired by commit 5553f9e2
(cpufreq: instantiate cpufreq-cpu0 as a platform_driver)

[robherring2@gmail.com: reported conflict of omap-cpufreq vs other
driver in an non-device tree supported boot]
Reported-by: default avatarRob Herring <robherring2@gmail.com>
Signed-off-by: default avatarNishanth Menon <nm@ti.com>
Acked-by: default avatarViresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: default avatarKevin Hilman <khilman@linaro.org>
Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
parent 64649dcd
...@@ -265,6 +265,12 @@ static void __init omap4_init_voltages(void) ...@@ -265,6 +265,12 @@ static void __init omap4_init_voltages(void)
omap2_set_init_voltage("iva", "dpll_iva_m5x2_ck", "iva"); omap2_set_init_voltage("iva", "dpll_iva_m5x2_ck", "iva");
} }
static inline void omap_init_cpufreq(void)
{
struct platform_device_info devinfo = { .name = "omap-cpufreq", };
platform_device_register_full(&devinfo);
}
static int __init omap2_common_pm_init(void) static int __init omap2_common_pm_init(void)
{ {
if (!of_have_populated_dt()) if (!of_have_populated_dt())
...@@ -294,6 +300,9 @@ int __init omap2_common_pm_late_init(void) ...@@ -294,6 +300,9 @@ int __init omap2_common_pm_late_init(void)
/* Smartreflex device init */ /* Smartreflex device init */
omap_devinit_smartreflex(); omap_devinit_smartreflex();
/* cpufreq dummy device instantiation */
omap_init_cpufreq();
} }
#ifdef CONFIG_SUSPEND #ifdef CONFIG_SUSPEND
......
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
#include <linux/opp.h> #include <linux/opp.h>
#include <linux/cpu.h> #include <linux/cpu.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/platform_device.h>
#include <linux/regulator/consumer.h> #include <linux/regulator/consumer.h>
#include <asm/smp_plat.h> #include <asm/smp_plat.h>
...@@ -243,7 +244,7 @@ static struct cpufreq_driver omap_driver = { ...@@ -243,7 +244,7 @@ static struct cpufreq_driver omap_driver = {
.attr = omap_cpufreq_attr, .attr = omap_cpufreq_attr,
}; };
static int __init omap_cpufreq_init(void) static int omap_cpufreq_probe(struct platform_device *pdev)
{ {
mpu_dev = get_cpu_device(0); mpu_dev = get_cpu_device(0);
if (!mpu_dev) { if (!mpu_dev) {
...@@ -271,12 +272,20 @@ static int __init omap_cpufreq_init(void) ...@@ -271,12 +272,20 @@ static int __init omap_cpufreq_init(void)
return cpufreq_register_driver(&omap_driver); return cpufreq_register_driver(&omap_driver);
} }
static void __exit omap_cpufreq_exit(void) static int omap_cpufreq_remove(struct platform_device *pdev)
{ {
cpufreq_unregister_driver(&omap_driver); return cpufreq_unregister_driver(&omap_driver);
} }
static struct platform_driver omap_cpufreq_platdrv = {
.driver = {
.name = "omap-cpufreq",
.owner = THIS_MODULE,
},
.probe = omap_cpufreq_probe,
.remove = omap_cpufreq_remove,
};
module_platform_driver(omap_cpufreq_platdrv);
MODULE_DESCRIPTION("cpufreq driver for OMAP SoCs"); MODULE_DESCRIPTION("cpufreq driver for OMAP SoCs");
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
module_init(omap_cpufreq_init);
module_exit(omap_cpufreq_exit);
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment