3 * (C) COPYRIGHT 2014 ARM Limited. All rights reserved.
5 * This program is free software and is provided to you under the terms of the
6 * GNU General Public License version 2 as published by the Free Software
7 * Foundation, and any use by you of this program is subject to the terms
10 * A copy of the licence is included with the program, and can also be obtained
11 * from Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
12 * Boston, MA 02110-1301, USA.
18 #include <linux/module.h>
19 #include <linux/of_platform.h>
20 #include <linux/platform_device.h>
21 #include <linux/scpi_protocol.h>
22 #include <linux/version.h>
23 #if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 13, 0)
24 #include <linux/pm_opp.h>
25 #else /* Linux >= 3.13 */
26 /* In 3.13 the OPP include header file, types, and functions were all
27 * renamed. Use the old filename for the include, and define the new names to
28 * the old, when an old kernel is detected.
30 #include <linux/opp.h>
31 #define dev_pm_opp_add opp_add
32 #endif /* Linux >= 3.13 */
35 static int init_juno_opps_from_scpi(struct device *dev)
37 struct scpi_opp *sopp;
40 /* Hard coded for Juno. 2 is GPU domain */
41 sopp = scpi_dvfs_get_opps(2);
42 if (IS_ERR_OR_NULL(sopp))
45 for (i = 0; i < sopp->count; i++) {
46 struct scpi_opp_entry *e = &sopp->opp[i];
48 dev_info(dev, "Mali OPP from SCPI: %u Hz @ %u mV\n",
49 e->freq_hz, e->volt_mv);
51 dev_pm_opp_add(dev, e->freq_hz, e->volt_mv * 1000);
57 static int juno_setup_opps(void)
59 struct device_node *np;
60 struct platform_device *pdev;
63 np = of_find_node_by_name(NULL, "gpu");
65 pr_err("Failed to find DT entry for Mali\n");
69 pdev = of_find_device_by_node(np);
71 pr_err("Failed to find device for Mali\n");
76 err = init_juno_opps_from_scpi(&pdev->dev);
83 module_init(juno_setup_opps);
84 MODULE_LICENSE("GPL");