diff options
author | Nishanth Menon <nm@ti.com> | 2013-04-09 19:22:01 -0400 |
---|---|---|
committer | Rafael J. Wysocki <rafael.j.wysocki@intel.com> | 2013-04-10 07:41:00 -0400 |
commit | 49ded525d4486dc97fc965858bf3ddf245463670 (patch) | |
tree | 9c3a586f60a8cc6782ccdd23d4337fcb516caff2 /drivers/cpufreq/omap-cpufreq.c | |
parent | 64649dcdf6c42d990cb44cceb0112ebd606ef435 (diff) |
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 5553f9e26f6f49a93ba732fd222eac6973a4cf35
(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: Rob Herring <robherring2@gmail.com>
Signed-off-by: Nishanth Menon <nm@ti.com>
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Kevin Hilman <khilman@linaro.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Diffstat (limited to 'drivers/cpufreq/omap-cpufreq.c')
-rw-r--r-- | drivers/cpufreq/omap-cpufreq.c | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/drivers/cpufreq/omap-cpufreq.c b/drivers/cpufreq/omap-cpufreq.c index ad7549c13ed2..0279d18a57f9 100644 --- a/drivers/cpufreq/omap-cpufreq.c +++ b/drivers/cpufreq/omap-cpufreq.c | |||
@@ -25,6 +25,7 @@ | |||
25 | #include <linux/opp.h> | 25 | #include <linux/opp.h> |
26 | #include <linux/cpu.h> | 26 | #include <linux/cpu.h> |
27 | #include <linux/module.h> | 27 | #include <linux/module.h> |
28 | #include <linux/platform_device.h> | ||
28 | #include <linux/regulator/consumer.h> | 29 | #include <linux/regulator/consumer.h> |
29 | 30 | ||
30 | #include <asm/smp_plat.h> | 31 | #include <asm/smp_plat.h> |
@@ -243,7 +244,7 @@ static struct cpufreq_driver omap_driver = { | |||
243 | .attr = omap_cpufreq_attr, | 244 | .attr = omap_cpufreq_attr, |
244 | }; | 245 | }; |
245 | 246 | ||
246 | static int __init omap_cpufreq_init(void) | 247 | static int omap_cpufreq_probe(struct platform_device *pdev) |
247 | { | 248 | { |
248 | mpu_dev = get_cpu_device(0); | 249 | mpu_dev = get_cpu_device(0); |
249 | if (!mpu_dev) { | 250 | if (!mpu_dev) { |
@@ -271,12 +272,20 @@ static int __init omap_cpufreq_init(void) | |||
271 | return cpufreq_register_driver(&omap_driver); | 272 | return cpufreq_register_driver(&omap_driver); |
272 | } | 273 | } |
273 | 274 | ||
274 | static void __exit omap_cpufreq_exit(void) | 275 | static int omap_cpufreq_remove(struct platform_device *pdev) |
275 | { | 276 | { |
276 | cpufreq_unregister_driver(&omap_driver); | 277 | return cpufreq_unregister_driver(&omap_driver); |
277 | } | 278 | } |
278 | 279 | ||
280 | static struct platform_driver omap_cpufreq_platdrv = { | ||
281 | .driver = { | ||
282 | .name = "omap-cpufreq", | ||
283 | .owner = THIS_MODULE, | ||
284 | }, | ||
285 | .probe = omap_cpufreq_probe, | ||
286 | .remove = omap_cpufreq_remove, | ||
287 | }; | ||
288 | module_platform_driver(omap_cpufreq_platdrv); | ||
289 | |||
279 | MODULE_DESCRIPTION("cpufreq driver for OMAP SoCs"); | 290 | MODULE_DESCRIPTION("cpufreq driver for OMAP SoCs"); |
280 | MODULE_LICENSE("GPL"); | 291 | MODULE_LICENSE("GPL"); |
281 | module_init(omap_cpufreq_init); | ||
282 | module_exit(omap_cpufreq_exit); | ||