blob: 6b158839d26ba10f26672c8e414f24d0f7597fe4 [file] [log] [blame]
Abhijeet Dharmapurikar44451662012-08-23 18:58:44 -07001/* Copyright (c) 2012, The Linux Foundation. All rights reserved.
Jordan Crouseb3115fe2012-02-01 22:11:12 -07002 *
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License version 2 and
5 * only version 2 as published by the Free Software Foundation.
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 *
12 */
13
14#include <linux/init.h>
15#include <linux/platform_device.h>
Jordan Crouse914de9b2012-07-09 13:49:46 -060016#include <mach/kgsl.h>
Jordan Crouseb3115fe2012-02-01 22:11:12 -070017#include <mach/msm_bus_board.h>
18#include <mach/board.h>
Lucille Sylvester6e362412011-12-09 16:21:42 -070019#include <mach/msm_dcvs.h>
Jordan Crouse4815e9f2012-07-09 15:36:37 -060020#include <mach/socinfo.h>
Jordan Crouseb3115fe2012-02-01 22:11:12 -070021
22#include "devices.h"
23#include "board-8064.h"
24
Lucille Sylvester6e362412011-12-09 16:21:42 -070025#ifdef CONFIG_MSM_DCVS
26static struct msm_dcvs_freq_entry grp3d_freq[] = {
Abhijeet Dharmapurikar44451662012-08-23 18:58:44 -070027 {0, 900, 0, 0, 0},
28 {0, 950, 0, 0, 0},
29 {0, 950, 0, 0, 0},
30 {0, 1200, 1, 100, 100},
Lucille Sylvester6e362412011-12-09 16:21:42 -070031};
32
33static struct msm_dcvs_core_info grp3d_core_info = {
Abhijeet Dharmapurikar80add422012-09-13 11:11:54 -070034 .freq_tbl = &grp3d_freq[0],
35 .num_cores = 1,
36 .sensors = (int[]){0},
37 .thermal_poll_ms = 60000,
38 .core_param = {
Abhijeet Dharmapurikar44451662012-08-23 18:58:44 -070039 .core_type = MSM_DCVS_CORE_TYPE_GPU,
Lucille Sylvester6e362412011-12-09 16:21:42 -070040 },
Abhijeet Dharmapurikar80add422012-09-13 11:11:54 -070041 .algo_param = {
Abhijeet Dharmapurikar44451662012-08-23 18:58:44 -070042 .disable_pc_threshold = 0,
43 .em_win_size_min_us = 100000,
44 .em_win_size_max_us = 300000,
45 .em_max_util_pct = 97,
46 .group_id = 0,
47 .max_freq_chg_time_us = 100000,
48 .slack_mode_dynamic = 0,
49 .slack_time_min_us = 39000,
50 .slack_time_max_us = 39000,
51 .ss_win_size_min_us = 1000000,
52 .ss_win_size_max_us = 1000000,
53 .ss_util_pct = 95,
Steve Mucklee8c6d612012-12-06 14:31:00 -080054 .ss_no_corr_below_freq = 0,
Lucille Sylvester6e362412011-12-09 16:21:42 -070055 },
Abhijeet Dharmapurikar44451662012-08-23 18:58:44 -070056
Abhijeet Dharmapurikar80add422012-09-13 11:11:54 -070057 .energy_coeffs = {
Abhijeet Dharmapurikar44451662012-08-23 18:58:44 -070058 .leakage_coeff_a = -17720,
59 .leakage_coeff_b = 37,
60 .leakage_coeff_c = 3329,
61 .leakage_coeff_d = -277,
62
63 .active_coeff_a = 2492,
64 .active_coeff_b = 0,
65 .active_coeff_c = 0
66 },
67
Abhijeet Dharmapurikar80add422012-09-13 11:11:54 -070068 .power_param = {
Abhijeet Dharmapurikar44451662012-08-23 18:58:44 -070069 .current_temp = 25,
70 .num_freq = ARRAY_SIZE(grp3d_freq),
71 }
Lucille Sylvester6e362412011-12-09 16:21:42 -070072};
73#endif /* CONFIG_MSM_DCVS */
74
Jordan Crouseb3115fe2012-02-01 22:11:12 -070075#ifdef CONFIG_MSM_BUS_SCALING
76static struct msm_bus_vectors grp3d_init_vectors[] = {
77 {
78 .src = MSM_BUS_MASTER_GRAPHICS_3D,
79 .dst = MSM_BUS_SLAVE_EBI_CH0,
80 .ab = 0,
81 .ib = 0,
82 },
83 {
84 .src = MSM_BUS_MASTER_GRAPHICS_3D_PORT1,
85 .dst = MSM_BUS_SLAVE_EBI_CH0,
86 .ab = 0,
87 .ib = 0,
88 },
89};
90
91static struct msm_bus_vectors grp3d_low_vectors[] = {
92 {
93 .src = MSM_BUS_MASTER_GRAPHICS_3D,
94 .dst = MSM_BUS_SLAVE_EBI_CH0,
95 .ab = 0,
Lucille Sylvesterf6b4ce32012-05-11 11:10:18 -060096 .ib = KGSL_CONVERT_TO_MBPS(1000),
97 },
98 {
99 .src = MSM_BUS_MASTER_GRAPHICS_3D_PORT1,
100 .dst = MSM_BUS_SLAVE_EBI_CH0,
101 .ab = 0,
102 .ib = KGSL_CONVERT_TO_MBPS(1000),
103 },
104};
105
106static struct msm_bus_vectors grp3d_nominal_low_vectors[] = {
107 {
108 .src = MSM_BUS_MASTER_GRAPHICS_3D,
109 .dst = MSM_BUS_SLAVE_EBI_CH0,
110 .ab = 0,
Jordan Crouseb3115fe2012-02-01 22:11:12 -0700111 .ib = KGSL_CONVERT_TO_MBPS(2000),
112 },
113 {
114 .src = MSM_BUS_MASTER_GRAPHICS_3D_PORT1,
115 .dst = MSM_BUS_SLAVE_EBI_CH0,
116 .ab = 0,
117 .ib = KGSL_CONVERT_TO_MBPS(2000),
118 },
119};
120
121static struct msm_bus_vectors grp3d_nominal_high_vectors[] = {
122 {
123 .src = MSM_BUS_MASTER_GRAPHICS_3D,
124 .dst = MSM_BUS_SLAVE_EBI_CH0,
125 .ab = 0,
Lucille Sylvester26615342012-06-26 17:55:10 -0600126 .ib = KGSL_CONVERT_TO_MBPS(2656),
Jordan Crouseb3115fe2012-02-01 22:11:12 -0700127 },
128 {
129 .src = MSM_BUS_MASTER_GRAPHICS_3D_PORT1,
130 .dst = MSM_BUS_SLAVE_EBI_CH0,
131 .ab = 0,
Lucille Sylvester26615342012-06-26 17:55:10 -0600132 .ib = KGSL_CONVERT_TO_MBPS(2656),
Jordan Crouseb3115fe2012-02-01 22:11:12 -0700133 },
134};
135
136static struct msm_bus_vectors grp3d_max_vectors[] = {
137 {
138 .src = MSM_BUS_MASTER_GRAPHICS_3D,
139 .dst = MSM_BUS_SLAVE_EBI_CH0,
140 .ab = 0,
141 .ib = KGSL_CONVERT_TO_MBPS(4264),
142 },
143 {
144 .src = MSM_BUS_MASTER_GRAPHICS_3D_PORT1,
145 .dst = MSM_BUS_SLAVE_EBI_CH0,
146 .ab = 0,
147 .ib = KGSL_CONVERT_TO_MBPS(4264),
148 },
149};
150
151static struct msm_bus_paths grp3d_bus_scale_usecases[] = {
152 {
153 ARRAY_SIZE(grp3d_init_vectors),
154 grp3d_init_vectors,
155 },
156 {
157 ARRAY_SIZE(grp3d_low_vectors),
158 grp3d_low_vectors,
159 },
160 {
Lucille Sylvesterf6b4ce32012-05-11 11:10:18 -0600161 ARRAY_SIZE(grp3d_nominal_low_vectors),
162 grp3d_nominal_low_vectors,
163 },
164 {
Jordan Crouseb3115fe2012-02-01 22:11:12 -0700165 ARRAY_SIZE(grp3d_nominal_high_vectors),
166 grp3d_nominal_high_vectors,
167 },
168 {
169 ARRAY_SIZE(grp3d_max_vectors),
170 grp3d_max_vectors,
171 },
172};
173
174static struct msm_bus_scale_pdata grp3d_bus_scale_pdata = {
175 grp3d_bus_scale_usecases,
176 ARRAY_SIZE(grp3d_bus_scale_usecases),
177 .name = "grp3d",
178};
179#endif
180
181static struct resource kgsl_3d0_resources[] = {
182 {
183 .name = KGSL_3D0_REG_MEMORY,
184 .start = 0x04300000, /* GFX3D address */
Harsh Vardhan Dwivedi623b9a22012-10-28 20:54:17 -0600185 .end = 0x0430ffff,
186 .flags = IORESOURCE_MEM,
187 },
188 {
189 .name = KGSL_3D0_SHADER_MEMORY,
190 .start = 0x04310000, /* Shader Mem Address */
Jordan Crouseb3115fe2012-02-01 22:11:12 -0700191 .end = 0x0431ffff,
192 .flags = IORESOURCE_MEM,
193 },
194 {
195 .name = KGSL_3D0_IRQ,
196 .start = GFX3D_IRQ,
197 .end = GFX3D_IRQ,
198 .flags = IORESOURCE_IRQ,
199 },
200};
201
Shubhraprakash Daseb6df1d2012-05-01 00:55:35 -0600202static const struct kgsl_iommu_ctx kgsl_3d0_iommu0_ctxs[] = {
203 { "gfx3d_user", 0 },
204 { "gfx3d_priv", 1 },
Jordan Crouse46cf4bb2012-02-21 08:54:52 -0700205};
206
Shubhraprakash Daseb6df1d2012-05-01 00:55:35 -0600207static const struct kgsl_iommu_ctx kgsl_3d0_iommu1_ctxs[] = {
208 { "gfx3d1_user", 0 },
209 { "gfx3d1_priv", 1 },
Jordan Crouse46cf4bb2012-02-21 08:54:52 -0700210};
211
212static struct kgsl_device_iommu_data kgsl_3d0_iommu_data[] = {
213 {
Shubhraprakash Daseb6df1d2012-05-01 00:55:35 -0600214 .iommu_ctxs = kgsl_3d0_iommu0_ctxs,
215 .iommu_ctx_count = ARRAY_SIZE(kgsl_3d0_iommu0_ctxs),
Jordan Crouse46cf4bb2012-02-21 08:54:52 -0700216 .physstart = 0x07C00000,
217 .physend = 0x07C00000 + SZ_1M - 1,
218 },
219 {
Shubhraprakash Daseb6df1d2012-05-01 00:55:35 -0600220 .iommu_ctxs = kgsl_3d0_iommu1_ctxs,
221 .iommu_ctx_count = ARRAY_SIZE(kgsl_3d0_iommu1_ctxs),
Jordan Crouse46cf4bb2012-02-21 08:54:52 -0700222 .physstart = 0x07D00000,
223 .physend = 0x07D00000 + SZ_1M - 1,
224 },
225};
226
Jordan Crouseb3115fe2012-02-01 22:11:12 -0700227static struct kgsl_device_platform_data kgsl_3d0_pdata = {
228 .pwrlevel = {
229 {
Tarun Karra3c2cc9e2012-02-17 14:58:07 -0800230 .gpu_freq = 400000000,
Lucille Sylvesterf6b4ce32012-05-11 11:10:18 -0600231 .bus_freq = 4,
Tarun Karra3c2cc9e2012-02-17 14:58:07 -0800232 .io_fraction = 0,
Jordan Crouseb3115fe2012-02-01 22:11:12 -0700233 },
234 {
Suman Tatiraju03a95db2012-10-29 18:24:53 -0700235 .gpu_freq = 320000000,
Lucille Sylvesterf6b4ce32012-05-11 11:10:18 -0600236 .bus_freq = 3,
Tarun Karra3c2cc9e2012-02-17 14:58:07 -0800237 .io_fraction = 33,
Jordan Crouseb3115fe2012-02-01 22:11:12 -0700238 },
239 {
Lucille Sylvester0c779a92012-03-30 16:51:27 -0600240 .gpu_freq = 200000000,
Lucille Sylvesterf6b4ce32012-05-11 11:10:18 -0600241 .bus_freq = 2,
242 .io_fraction = 100,
243 },
244 {
245 .gpu_freq = 128000000,
Tarun Karra71853702012-02-17 15:21:59 -0800246 .bus_freq = 1,
Jordan Crouseb3115fe2012-02-01 22:11:12 -0700247 .io_fraction = 100,
248 },
249 {
Tarun Karra3c2cc9e2012-02-17 14:58:07 -0800250 .gpu_freq = 27000000,
251 .bus_freq = 0,
Jordan Crouseb3115fe2012-02-01 22:11:12 -0700252 },
253 },
Lucille Sylvester37a02d32012-04-25 17:21:06 -0600254 .init_level = 1,
Lucille Sylvesterf6b4ce32012-05-11 11:10:18 -0600255 .num_levels = 5,
Jordan Crouseb3115fe2012-02-01 22:11:12 -0700256 .set_grp_async = NULL,
Suman Tatiraju3bd641e2012-04-11 10:46:11 -0700257 .idle_timeout = HZ/10,
Jordan Crouseb3115fe2012-02-01 22:11:12 -0700258 .nap_allowed = true,
Lucille Sylvestera448aeb2012-06-12 16:30:29 -0600259 .strtstp_sleepwake = true,
Jordan Crouseb3115fe2012-02-01 22:11:12 -0700260 .clk_map = KGSL_CLK_CORE | KGSL_CLK_IFACE | KGSL_CLK_MEM_IFACE,
261#ifdef CONFIG_MSM_BUS_SCALING
262 .bus_scale_table = &grp3d_bus_scale_pdata,
263#endif
Jordan Crouse46cf4bb2012-02-21 08:54:52 -0700264 .iommu_data = kgsl_3d0_iommu_data,
265 .iommu_count = ARRAY_SIZE(kgsl_3d0_iommu_data),
Lucille Sylvester6e362412011-12-09 16:21:42 -0700266#ifdef CONFIG_MSM_DCVS
267 .core_info = &grp3d_core_info,
268#endif
Jordan Crouseb3115fe2012-02-01 22:11:12 -0700269};
270
271struct platform_device device_kgsl_3d0 = {
272 .name = "kgsl-3d0",
273 .id = 0,
274 .num_resources = ARRAY_SIZE(kgsl_3d0_resources),
275 .resource = kgsl_3d0_resources,
276 .dev = {
277 .platform_data = &kgsl_3d0_pdata,
278 },
279};
280
281void __init apq8064_init_gpu(void)
282{
Jordan Crouse4815e9f2012-07-09 15:36:37 -0600283 unsigned int version = socinfo_get_version();
284
Rajeev Kulkarni868938e2012-09-22 13:14:39 -0700285 if (cpu_is_apq8064ab())
286 kgsl_3d0_pdata.pwrlevel[0].gpu_freq = 450000000;
Rajeev Kulkarni1e52ca52012-09-28 17:53:31 -0700287 if (SOCINFO_VERSION_MAJOR(version) == 2) {
288 kgsl_3d0_pdata.chipid = ADRENO_CHIPID(3, 2, 0, 2);
289 } else {
Kevin Matlageb43eaa92012-10-23 17:10:56 -0600290 /* The bootloader has started returning 1.2 for chips that
291 are either 1.1 or 1.2. To handle that and default any
292 future revisions to this path, check for minor version >=1 */
Rajeev Kulkarni1e52ca52012-09-28 17:53:31 -0700293 if ((SOCINFO_VERSION_MAJOR(version) == 1) &&
Kevin Matlageb43eaa92012-10-23 17:10:56 -0600294 (SOCINFO_VERSION_MINOR(version) >= 1))
Rajeev Kulkarni1e52ca52012-09-28 17:53:31 -0700295 kgsl_3d0_pdata.chipid = ADRENO_CHIPID(3, 2, 0, 1);
296 else
297 kgsl_3d0_pdata.chipid = ADRENO_CHIPID(3, 2, 0, 0);
298 }
Jordan Crouse4815e9f2012-07-09 15:36:37 -0600299
Jordan Crouseb3115fe2012-02-01 22:11:12 -0700300 platform_device_register(&device_kgsl_3d0);
301}