Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

cpufreq: qoriq: convert to a platform driver

The driver has to be manually loaded if it is built as a module. It
is neither exporting MODULE_DEVICE_TABLE nor MODULE_ALIAS. Moreover,
no platform-device is created (and thus no uevent is sent) for the
clockgen nodes it depends on.

Convert the module to a platform driver with its own alias. Moreover,
drop whitelisted SOCs. Platform device will be created only for the
compatible platforms.

Reviewed-by: Yuantian Tang <andy.tang@nxp.com>
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Mian Yousaf Kaukab <ykaukab@suse.de>
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>

authored by

Mian Yousaf Kaukab and committed by
Viresh Kumar
157f5276 2dea6516

+30 -48
+30 -48
drivers/cpufreq/qoriq-cpufreq.c
··· 18 18 #include <linux/of.h> 19 19 #include <linux/slab.h> 20 20 #include <linux/smp.h> 21 + #include <linux/platform_device.h> 21 22 22 23 /** 23 24 * struct cpu_data ··· 29 28 struct clk **pclk; 30 29 struct cpufreq_frequency_table *table; 31 30 }; 32 - 33 - /* 34 - * Don't use cpufreq on this SoC -- used when the SoC would have otherwise 35 - * matched a more generic compatible. 36 - */ 37 - #define SOC_BLACKLIST 1 38 31 39 32 /** 40 33 * struct soc_data - SoC specific data ··· 259 264 .attr = cpufreq_generic_attr, 260 265 }; 261 266 262 - static const struct soc_data blacklist = { 263 - .flags = SOC_BLACKLIST, 264 - }; 265 - 266 - static const struct of_device_id node_matches[] __initconst = { 267 + static const struct of_device_id qoriq_cpufreq_blacklist[] = { 267 268 /* e6500 cannot use cpufreq due to erratum A-008083 */ 268 - { .compatible = "fsl,b4420-clockgen", &blacklist }, 269 - { .compatible = "fsl,b4860-clockgen", &blacklist }, 270 - { .compatible = "fsl,t2080-clockgen", &blacklist }, 271 - { .compatible = "fsl,t4240-clockgen", &blacklist }, 272 - 273 - { .compatible = "fsl,ls1012a-clockgen", }, 274 - { .compatible = "fsl,ls1021a-clockgen", }, 275 - { .compatible = "fsl,ls1028a-clockgen", }, 276 - { .compatible = "fsl,ls1043a-clockgen", }, 277 - { .compatible = "fsl,ls1046a-clockgen", }, 278 - { .compatible = "fsl,ls1088a-clockgen", }, 279 - { .compatible = "fsl,ls2080a-clockgen", }, 280 - { .compatible = "fsl,lx2160a-clockgen", }, 281 - { .compatible = "fsl,p4080-clockgen", }, 282 - { .compatible = "fsl,qoriq-clockgen-1.0", }, 283 - { .compatible = "fsl,qoriq-clockgen-2.0", }, 269 + { .compatible = "fsl,b4420-clockgen", }, 270 + { .compatible = "fsl,b4860-clockgen", }, 271 + { .compatible = "fsl,t2080-clockgen", }, 272 + { .compatible = "fsl,t4240-clockgen", }, 284 273 {} 285 274 }; 286 275 287 - static int __init qoriq_cpufreq_init(void) 276 + static int qoriq_cpufreq_probe(struct platform_device *pdev) 288 277 { 289 278 int ret; 290 - struct device_node *np; 291 - const struct of_device_id *match; 292 - const struct soc_data *data; 279 + struct device_node *np; 293 280 294 - np = of_find_matching_node(NULL, node_matches); 295 - if (!np) 281 + np = of_find_matching_node(NULL, qoriq_cpufreq_blacklist); 282 + if (np) { 283 + dev_info(&pdev->dev, "Disabling due to erratum A-008083"); 296 284 return -ENODEV; 297 - 298 - match = of_match_node(node_matches, np); 299 - data = match->data; 300 - 301 - of_node_put(np); 302 - 303 - if (data && data->flags & SOC_BLACKLIST) 304 - return -ENODEV; 285 + } 305 286 306 287 ret = cpufreq_register_driver(&qoriq_cpufreq_driver); 307 - if (!ret) 308 - pr_info("Freescale QorIQ CPU frequency scaling driver\n"); 288 + if (ret) 289 + return ret; 309 290 310 - return ret; 291 + dev_info(&pdev->dev, "Freescale QorIQ CPU frequency scaling driver\n"); 292 + return 0; 311 293 } 312 - module_init(qoriq_cpufreq_init); 313 294 314 - static void __exit qoriq_cpufreq_exit(void) 295 + static int qoriq_cpufreq_remove(struct platform_device *pdev) 315 296 { 316 297 cpufreq_unregister_driver(&qoriq_cpufreq_driver); 317 - } 318 - module_exit(qoriq_cpufreq_exit); 319 298 299 + return 0; 300 + } 301 + 302 + static struct platform_driver qoriq_cpufreq_platform_driver = { 303 + .driver = { 304 + .name = "qoriq-cpufreq", 305 + }, 306 + .probe = qoriq_cpufreq_probe, 307 + .remove = qoriq_cpufreq_remove, 308 + }; 309 + module_platform_driver(qoriq_cpufreq_platform_driver); 310 + 311 + MODULE_ALIAS("platform:qoriq-cpufreq"); 320 312 MODULE_LICENSE("GPL"); 321 313 MODULE_AUTHOR("Tang Yuantian <Yuantian.Tang@freescale.com>"); 322 314 MODULE_DESCRIPTION("cpufreq driver for Freescale QorIQ series SoCs");