aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDave Gerlach <d-gerlach@ti.com>2018-11-13 14:30:40 -0500
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2018-11-19 05:26:06 -0500
commitd98ccfc3948ab63152494bb6b9c17e15295c0310 (patch)
tree0aed914a6aadd78846703dd236baa8f6bb75a20d
parent9ff01193a20d391e8dbce4403dd5ef87c7eaaca6 (diff)
cpufreq: ti-cpufreq: Only register platform_device when supported
Currently the ti-cpufreq driver blindly registers a 'ti-cpufreq' to force the driver to probe on any platforms where the driver is built in. However, this should only happen on platforms that actually can make use of the driver. There is already functionality in place to match the SoC compatible so let's factor this out into a separate call and make sure we find a match before creating the ti-cpufreq platform device. Reviewed-by: Johan Hovold <johan@kernel.org> Signed-off-by: Dave Gerlach <d-gerlach@ti.com> Acked-by: Viresh Kumar <viresh.kumar@linaro.org> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
-rw-r--r--drivers/cpufreq/ti-cpufreq.c26
1 files changed, 21 insertions, 5 deletions
diff --git a/drivers/cpufreq/ti-cpufreq.c b/drivers/cpufreq/ti-cpufreq.c
index 3f0e2a14895a..22b53bf26817 100644
--- a/drivers/cpufreq/ti-cpufreq.c
+++ b/drivers/cpufreq/ti-cpufreq.c
@@ -201,19 +201,28 @@ static const struct of_device_id ti_cpufreq_of_match[] = {
201 {}, 201 {},
202}; 202};
203 203
204static const struct of_device_id *ti_cpufreq_match_node(void)
205{
206 struct device_node *np;
207 const struct of_device_id *match;
208
209 np = of_find_node_by_path("/");
210 match = of_match_node(ti_cpufreq_of_match, np);
211 of_node_put(np);
212
213 return match;
214}
215
204static int ti_cpufreq_probe(struct platform_device *pdev) 216static int ti_cpufreq_probe(struct platform_device *pdev)
205{ 217{
206 u32 version[VERSION_COUNT]; 218 u32 version[VERSION_COUNT];
207 struct device_node *np;
208 const struct of_device_id *match; 219 const struct of_device_id *match;
209 struct opp_table *ti_opp_table; 220 struct opp_table *ti_opp_table;
210 struct ti_cpufreq_data *opp_data; 221 struct ti_cpufreq_data *opp_data;
211 const char * const reg_names[] = {"vdd", "vbb"}; 222 const char * const reg_names[] = {"vdd", "vbb"};
212 int ret; 223 int ret;
213 224
214 np = of_find_node_by_path("/"); 225 match = dev_get_platdata(&pdev->dev);
215 match = of_match_node(ti_cpufreq_of_match, np);
216 of_node_put(np);
217 if (!match) 226 if (!match)
218 return -ENODEV; 227 return -ENODEV;
219 228
@@ -290,7 +299,14 @@ fail_put_node:
290 299
291static int ti_cpufreq_init(void) 300static int ti_cpufreq_init(void)
292{ 301{
293 platform_device_register_simple("ti-cpufreq", -1, NULL, 0); 302 const struct of_device_id *match;
303
304 /* Check to ensure we are on a compatible platform */
305 match = ti_cpufreq_match_node();
306 if (match)
307 platform_device_register_data(NULL, "ti-cpufreq", -1, match,
308 sizeof(*match));
309
294 return 0; 310 return 0;
295} 311}
296module_init(ti_cpufreq_init); 312module_init(ti_cpufreq_init);