Skip to content

Commit 157f527

Browse files
Mian Yousaf Kaukabvireshk
authored andcommitted
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 <[email protected]> Acked-by: Viresh Kumar <[email protected]> Signed-off-by: Mian Yousaf Kaukab <[email protected]> Signed-off-by: Viresh Kumar <[email protected]>
1 parent 2dea651 commit 157f527

File tree

1 file changed

+29
-47
lines changed

1 file changed

+29
-47
lines changed

drivers/cpufreq/qoriq-cpufreq.c

Lines changed: 29 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include <linux/of.h>
1919
#include <linux/slab.h>
2020
#include <linux/smp.h>
21+
#include <linux/platform_device.h>
2122

2223
/**
2324
* struct cpu_data
@@ -29,12 +30,6 @@ struct cpu_data {
2930
struct cpufreq_frequency_table *table;
3031
};
3132

32-
/*
33-
* Don't use cpufreq on this SoC -- used when the SoC would have otherwise
34-
* matched a more generic compatible.
35-
*/
36-
#define SOC_BLACKLIST 1
37-
3833
/**
3934
* struct soc_data - SoC specific data
4035
* @flags: SOC_xxx
@@ -264,64 +259,51 @@ static struct cpufreq_driver qoriq_cpufreq_driver = {
264259
.attr = cpufreq_generic_attr,
265260
};
266261

267-
static const struct soc_data blacklist = {
268-
.flags = SOC_BLACKLIST,
269-
};
270-
271-
static const struct of_device_id node_matches[] __initconst = {
262+
static const struct of_device_id qoriq_cpufreq_blacklist[] = {
272263
/* e6500 cannot use cpufreq due to erratum A-008083 */
273-
{ .compatible = "fsl,b4420-clockgen", &blacklist },
274-
{ .compatible = "fsl,b4860-clockgen", &blacklist },
275-
{ .compatible = "fsl,t2080-clockgen", &blacklist },
276-
{ .compatible = "fsl,t4240-clockgen", &blacklist },
277-
278-
{ .compatible = "fsl,ls1012a-clockgen", },
279-
{ .compatible = "fsl,ls1021a-clockgen", },
280-
{ .compatible = "fsl,ls1028a-clockgen", },
281-
{ .compatible = "fsl,ls1043a-clockgen", },
282-
{ .compatible = "fsl,ls1046a-clockgen", },
283-
{ .compatible = "fsl,ls1088a-clockgen", },
284-
{ .compatible = "fsl,ls2080a-clockgen", },
285-
{ .compatible = "fsl,lx2160a-clockgen", },
286-
{ .compatible = "fsl,p4080-clockgen", },
287-
{ .compatible = "fsl,qoriq-clockgen-1.0", },
288-
{ .compatible = "fsl,qoriq-clockgen-2.0", },
264+
{ .compatible = "fsl,b4420-clockgen", },
265+
{ .compatible = "fsl,b4860-clockgen", },
266+
{ .compatible = "fsl,t2080-clockgen", },
267+
{ .compatible = "fsl,t4240-clockgen", },
289268
{}
290269
};
291270

292-
static int __init qoriq_cpufreq_init(void)
271+
static int qoriq_cpufreq_probe(struct platform_device *pdev)
293272
{
294273
int ret;
295-
struct device_node *np;
296-
const struct of_device_id *match;
297-
const struct soc_data *data;
298-
299-
np = of_find_matching_node(NULL, node_matches);
300-
if (!np)
301-
return -ENODEV;
302-
303-
match = of_match_node(node_matches, np);
304-
data = match->data;
305-
306-
of_node_put(np);
274+
struct device_node *np;
307275

308-
if (data && data->flags & SOC_BLACKLIST)
276+
np = of_find_matching_node(NULL, qoriq_cpufreq_blacklist);
277+
if (np) {
278+
dev_info(&pdev->dev, "Disabling due to erratum A-008083");
309279
return -ENODEV;
280+
}
310281

311282
ret = cpufreq_register_driver(&qoriq_cpufreq_driver);
312-
if (!ret)
313-
pr_info("Freescale QorIQ CPU frequency scaling driver\n");
283+
if (ret)
284+
return ret;
314285

315-
return ret;
286+
dev_info(&pdev->dev, "Freescale QorIQ CPU frequency scaling driver\n");
287+
return 0;
316288
}
317-
module_init(qoriq_cpufreq_init);
318289

319-
static void __exit qoriq_cpufreq_exit(void)
290+
static int qoriq_cpufreq_remove(struct platform_device *pdev)
320291
{
321292
cpufreq_unregister_driver(&qoriq_cpufreq_driver);
293+
294+
return 0;
322295
}
323-
module_exit(qoriq_cpufreq_exit);
324296

297+
static struct platform_driver qoriq_cpufreq_platform_driver = {
298+
.driver = {
299+
.name = "qoriq-cpufreq",
300+
},
301+
.probe = qoriq_cpufreq_probe,
302+
.remove = qoriq_cpufreq_remove,
303+
};
304+
module_platform_driver(qoriq_cpufreq_platform_driver);
305+
306+
MODULE_ALIAS("platform:qoriq-cpufreq");
325307
MODULE_LICENSE("GPL");
326308
MODULE_AUTHOR("Tang Yuantian <[email protected]>");
327309
MODULE_DESCRIPTION("cpufreq driver for Freescale QorIQ series SoCs");

0 commit comments

Comments
 (0)