aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/msm/adreno/adreno_device.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/gpu/drm/msm/adreno/adreno_device.c')
-rw-r--r--drivers/gpu/drm/msm/adreno/adreno_device.c169
1 files changed, 169 insertions, 0 deletions
diff --git a/drivers/gpu/drm/msm/adreno/adreno_device.c b/drivers/gpu/drm/msm/adreno/adreno_device.c
new file mode 100644
index 000000000000..124e23d63018
--- /dev/null
+++ b/drivers/gpu/drm/msm/adreno/adreno_device.c
@@ -0,0 +1,169 @@
1/*
2 * Copyright (C) 2013-2014 Red Hat
3 * Author: Rob Clark <robdclark@gmail.com>
4 *
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 as published by
7 * the Free Software Foundation.
8 *
9 * This program is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12 * more details.
13 *
14 * You should have received a copy of the GNU General Public License along with
15 * this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18#include "adreno_gpu.h"
19
20#if defined(CONFIG_MSM_BUS_SCALING) && !defined(CONFIG_OF)
21# include <mach/kgsl.h>
22#endif
23
24static void set_gpu_pdev(struct drm_device *dev,
25 struct platform_device *pdev)
26{
27 struct msm_drm_private *priv = dev->dev_private;
28 priv->gpu_pdev = pdev;
29}
30
31static int adreno_bind(struct device *dev, struct device *master, void *data)
32{
33 static struct adreno_platform_config config = {};
34#ifdef CONFIG_OF
35 struct device_node *child, *node = dev->of_node;
36 u32 val;
37 int ret;
38
39 ret = of_property_read_u32(node, "qcom,chipid", &val);
40 if (ret) {
41 dev_err(dev, "could not find chipid: %d\n", ret);
42 return ret;
43 }
44
45 config.rev = ADRENO_REV((val >> 24) & 0xff,
46 (val >> 16) & 0xff, (val >> 8) & 0xff, val & 0xff);
47
48 /* find clock rates: */
49 config.fast_rate = 0;
50 config.slow_rate = ~0;
51 for_each_child_of_node(node, child) {
52 if (of_device_is_compatible(child, "qcom,gpu-pwrlevels")) {
53 struct device_node *pwrlvl;
54 for_each_child_of_node(child, pwrlvl) {
55 ret = of_property_read_u32(pwrlvl, "qcom,gpu-freq", &val);
56 if (ret) {
57 dev_err(dev, "could not find gpu-freq: %d\n", ret);
58 return ret;
59 }
60 config.fast_rate = max(config.fast_rate, val);
61 config.slow_rate = min(config.slow_rate, val);
62 }
63 }
64 }
65
66 if (!config.fast_rate) {
67 dev_err(dev, "could not find clk rates\n");
68 return -ENXIO;
69 }
70
71#else
72 struct kgsl_device_platform_data *pdata = dev->platform_data;
73 uint32_t version = socinfo_get_version();
74 if (cpu_is_apq8064ab()) {
75 config.fast_rate = 450000000;
76 config.slow_rate = 27000000;
77 config.bus_freq = 4;
78 config.rev = ADRENO_REV(3, 2, 1, 0);
79 } else if (cpu_is_apq8064()) {
80 config.fast_rate = 400000000;
81 config.slow_rate = 27000000;
82 config.bus_freq = 4;
83
84 if (SOCINFO_VERSION_MAJOR(version) == 2)
85 config.rev = ADRENO_REV(3, 2, 0, 2);
86 else if ((SOCINFO_VERSION_MAJOR(version) == 1) &&
87 (SOCINFO_VERSION_MINOR(version) == 1))
88 config.rev = ADRENO_REV(3, 2, 0, 1);
89 else
90 config.rev = ADRENO_REV(3, 2, 0, 0);
91
92 } else if (cpu_is_msm8960ab()) {
93 config.fast_rate = 400000000;
94 config.slow_rate = 320000000;
95 config.bus_freq = 4;
96
97 if (SOCINFO_VERSION_MINOR(version) == 0)
98 config.rev = ADRENO_REV(3, 2, 1, 0);
99 else
100 config.rev = ADRENO_REV(3, 2, 1, 1);
101
102 } else if (cpu_is_msm8930()) {
103 config.fast_rate = 400000000;
104 config.slow_rate = 27000000;
105 config.bus_freq = 3;
106
107 if ((SOCINFO_VERSION_MAJOR(version) == 1) &&
108 (SOCINFO_VERSION_MINOR(version) == 2))
109 config.rev = ADRENO_REV(3, 0, 5, 2);
110 else
111 config.rev = ADRENO_REV(3, 0, 5, 0);
112
113 }
114# ifdef CONFIG_MSM_BUS_SCALING
115 config.bus_scale_table = pdata->bus_scale_table;
116# endif
117#endif
118 dev->platform_data = &config;
119 set_gpu_pdev(dev_get_drvdata(master), to_platform_device(dev));
120 return 0;
121}
122
123static void adreno_unbind(struct device *dev, struct device *master,
124 void *data)
125{
126 set_gpu_pdev(dev_get_drvdata(master), NULL);
127}
128
129static const struct component_ops a3xx_ops = {
130 .bind = adreno_bind,
131 .unbind = adreno_unbind,
132};
133
134static int adreno_probe(struct platform_device *pdev)
135{
136 return component_add(&pdev->dev, &a3xx_ops);
137}
138
139static int adreno_remove(struct platform_device *pdev)
140{
141 component_del(&pdev->dev, &a3xx_ops);
142 return 0;
143}
144
145static const struct of_device_id dt_match[] = {
146 { .compatible = "qcom,adreno-3xx" },
147 /* for backwards compat w/ downstream kgsl DT files: */
148 { .compatible = "qcom,kgsl-3d0" },
149 {}
150};
151
152static struct platform_driver adreno_driver = {
153 .probe = adreno_probe,
154 .remove = adreno_remove,
155 .driver = {
156 .name = "adreno",
157 .of_match_table = dt_match,
158 },
159};
160
161void __init adreno_register(void)
162{
163 platform_driver_register(&adreno_driver);
164}
165
166void __exit adreno_unregister(void)
167{
168 platform_driver_unregister(&adreno_driver);
169}