Correct .gbs.conf settings
[platform/adaptation/renesas_rcar/renesas_kernel.git] / drivers / cpufreq / dbx500-cpufreq.c
1 /*
2  * Copyright (C) STMicroelectronics 2009
3  * Copyright (C) ST-Ericsson SA 2010-2012
4  *
5  * License Terms: GNU General Public License v2
6  * Author: Sundar Iyer <sundar.iyer@stericsson.com>
7  * Author: Martin Persson <martin.persson@stericsson.com>
8  * Author: Jonas Aaberg <jonas.aberg@stericsson.com>
9  */
10
11 #include <linux/module.h>
12 #include <linux/kernel.h>
13 #include <linux/cpufreq.h>
14 #include <linux/delay.h>
15 #include <linux/slab.h>
16 #include <linux/platform_device.h>
17 #include <linux/clk.h>
18
19 static struct cpufreq_frequency_table *freq_table;
20 static struct clk *armss_clk;
21
22 static int dbx500_cpufreq_target(struct cpufreq_policy *policy,
23                                 unsigned int index)
24 {
25         /* update armss clk frequency */
26         return clk_set_rate(armss_clk, freq_table[index].frequency * 1000);
27 }
28
29 static int dbx500_cpufreq_init(struct cpufreq_policy *policy)
30 {
31         policy->clk = armss_clk;
32         return cpufreq_generic_init(policy, freq_table, 20 * 1000);
33 }
34
35 static struct cpufreq_driver dbx500_cpufreq_driver = {
36         .flags  = CPUFREQ_STICKY | CPUFREQ_CONST_LOOPS |
37                         CPUFREQ_NEED_INITIAL_FREQ_CHECK,
38         .verify = cpufreq_generic_frequency_table_verify,
39         .target_index = dbx500_cpufreq_target,
40         .get    = cpufreq_generic_get,
41         .init   = dbx500_cpufreq_init,
42         .name   = "DBX500",
43         .attr   = cpufreq_generic_attr,
44 };
45
46 static int dbx500_cpufreq_probe(struct platform_device *pdev)
47 {
48         int i = 0;
49
50         freq_table = dev_get_platdata(&pdev->dev);
51         if (!freq_table) {
52                 pr_err("dbx500-cpufreq: Failed to fetch cpufreq table\n");
53                 return -ENODEV;
54         }
55
56         armss_clk = clk_get(&pdev->dev, "armss");
57         if (IS_ERR(armss_clk)) {
58                 pr_err("dbx500-cpufreq: Failed to get armss clk\n");
59                 return PTR_ERR(armss_clk);
60         }
61
62         pr_info("dbx500-cpufreq: Available frequencies:\n");
63         while (freq_table[i].frequency != CPUFREQ_TABLE_END) {
64                 pr_info("  %d Mhz\n", freq_table[i].frequency/1000);
65                 i++;
66         }
67
68         return cpufreq_register_driver(&dbx500_cpufreq_driver);
69 }
70
71 static struct platform_driver dbx500_cpufreq_plat_driver = {
72         .driver = {
73                 .name = "cpufreq-ux500",
74                 .owner = THIS_MODULE,
75         },
76         .probe = dbx500_cpufreq_probe,
77 };
78
79 static int __init dbx500_cpufreq_register(void)
80 {
81         return platform_driver_register(&dbx500_cpufreq_plat_driver);
82 }
83 device_initcall(dbx500_cpufreq_register);
84
85 MODULE_LICENSE("GPL v2");
86 MODULE_DESCRIPTION("cpufreq driver for DBX500");