Commit 2449d33a authored by Viresh Kumar's avatar Viresh Kumar Committed by Rafael J. Wysocki

cpufreq: SPEAr: Instantiate as platform_driver

As multiplatform build is being adopted by more and more
ARM platforms, initcall function should be used very carefully.
For example, when SPEAr cpufreq driver is enabled on a kernel
booted on a non-SPEAr board, we will get following boot time error:

	spear_cpufreq: Invalid cpufreq_tbl

To eliminate this undesired the effect, the patch changes SPEAr
driver to have it instantiated as a platform_driver. Then it will
only run on platforms that create the platform_device "spear-cpufreq".

This patch also creates platform node for SPEAr13xx boards.
Reported-by: default avatarJosh Cartwright <joshc@codeaurora.org>
Signed-off-by: default avatarViresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
parent 96bbbe4a
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
static void __init spear1310_dt_init(void) static void __init spear1310_dt_init(void)
{ {
of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL); of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL);
platform_device_register_simple("spear-cpufreq", -1, NULL, 0);
} }
static const char * const spear1310_dt_board_compat[] = { static const char * const spear1310_dt_board_compat[] = {
......
...@@ -143,6 +143,7 @@ static void __init spear1340_dt_init(void) ...@@ -143,6 +143,7 @@ static void __init spear1340_dt_init(void)
{ {
of_platform_populate(NULL, of_default_bus_match_table, of_platform_populate(NULL, of_default_bus_match_table,
spear1340_auxdata_lookup, NULL); spear1340_auxdata_lookup, NULL);
platform_device_register_simple("spear-cpufreq", -1, NULL, 0);
} }
static const char * const spear1340_dt_board_compat[] = { static const char * const spear1340_dt_board_compat[] = {
......
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
#include <linux/init.h> #include <linux/init.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/of_device.h> #include <linux/of_device.h>
#include <linux/platform_device.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/types.h> #include <linux/types.h>
...@@ -166,7 +167,7 @@ static struct cpufreq_driver spear_cpufreq_driver = { ...@@ -166,7 +167,7 @@ static struct cpufreq_driver spear_cpufreq_driver = {
.attr = cpufreq_generic_attr, .attr = cpufreq_generic_attr,
}; };
static int spear_cpufreq_driver_init(void) static int spear_cpufreq_probe(struct platform_device *pdev)
{ {
struct device_node *np; struct device_node *np;
const struct property *prop; const struct property *prop;
...@@ -234,7 +235,15 @@ static int spear_cpufreq_driver_init(void) ...@@ -234,7 +235,15 @@ static int spear_cpufreq_driver_init(void)
of_node_put(np); of_node_put(np);
return ret; return ret;
} }
late_initcall(spear_cpufreq_driver_init);
static struct platform_driver spear_cpufreq_platdrv = {
.driver = {
.name = "spear-cpufreq",
.owner = THIS_MODULE,
},
.probe = spear_cpufreq_probe,
};
module_platform_driver(spear_cpufreq_platdrv);
MODULE_AUTHOR("Deepak Sikri <deepak.sikri@st.com>"); MODULE_AUTHOR("Deepak Sikri <deepak.sikri@st.com>");
MODULE_DESCRIPTION("SPEAr CPUFreq driver"); MODULE_DESCRIPTION("SPEAr CPUFreq driver");
......
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