blob: ec633a23855f69da169d4ecbf93fffba15dec8f4 [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,
54 .ss_iobusy_conv = 100,
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 */
185 .end = 0x0431ffff,
186 .flags = IORESOURCE_MEM,
187 },
188 {
189 .name = KGSL_3D0_IRQ,
190 .start = GFX3D_IRQ,
191 .end = GFX3D_IRQ,
192 .flags = IORESOURCE_IRQ,
193 },
194};
195
Shubhraprakash Daseb6df1d2012-05-01 00:55:35 -0600196static const struct kgsl_iommu_ctx kgsl_3d0_iommu0_ctxs[] = {
197 { "gfx3d_user", 0 },
198 { "gfx3d_priv", 1 },
Jordan Crouse46cf4bb2012-02-21 08:54:52 -0700199};
200
Shubhraprakash Daseb6df1d2012-05-01 00:55:35 -0600201static const struct kgsl_iommu_ctx kgsl_3d0_iommu1_ctxs[] = {
202 { "gfx3d1_user", 0 },
203 { "gfx3d1_priv", 1 },
Jordan Crouse46cf4bb2012-02-21 08:54:52 -0700204};
205
206static struct kgsl_device_iommu_data kgsl_3d0_iommu_data[] = {
207 {
Shubhraprakash Daseb6df1d2012-05-01 00:55:35 -0600208 .iommu_ctxs = kgsl_3d0_iommu0_ctxs,
209 .iommu_ctx_count = ARRAY_SIZE(kgsl_3d0_iommu0_ctxs),
Jordan Crouse46cf4bb2012-02-21 08:54:52 -0700210 .physstart = 0x07C00000,
211 .physend = 0x07C00000 + SZ_1M - 1,
212 },
213 {
Shubhraprakash Daseb6df1d2012-05-01 00:55:35 -0600214 .iommu_ctxs = kgsl_3d0_iommu1_ctxs,
215 .iommu_ctx_count = ARRAY_SIZE(kgsl_3d0_iommu1_ctxs),
Jordan Crouse46cf4bb2012-02-21 08:54:52 -0700216 .physstart = 0x07D00000,
217 .physend = 0x07D00000 + SZ_1M - 1,
218 },
219};
220
Jordan Crouseb3115fe2012-02-01 22:11:12 -0700221static struct kgsl_device_platform_data kgsl_3d0_pdata = {
222 .pwrlevel = {
223 {
Tarun Karra3c2cc9e2012-02-17 14:58:07 -0800224 .gpu_freq = 400000000,
Lucille Sylvesterf6b4ce32012-05-11 11:10:18 -0600225 .bus_freq = 4,
Tarun Karra3c2cc9e2012-02-17 14:58:07 -0800226 .io_fraction = 0,
Jordan Crouseb3115fe2012-02-01 22:11:12 -0700227 },
228 {
Lucille Sylvester0c779a92012-03-30 16:51:27 -0600229 .gpu_freq = 325000000,
Lucille Sylvesterf6b4ce32012-05-11 11:10:18 -0600230 .bus_freq = 3,
Tarun Karra3c2cc9e2012-02-17 14:58:07 -0800231 .io_fraction = 33,
Jordan Crouseb3115fe2012-02-01 22:11:12 -0700232 },
233 {
Lucille Sylvester0c779a92012-03-30 16:51:27 -0600234 .gpu_freq = 200000000,
Lucille Sylvesterf6b4ce32012-05-11 11:10:18 -0600235 .bus_freq = 2,
236 .io_fraction = 100,
237 },
238 {
239 .gpu_freq = 128000000,
Tarun Karra71853702012-02-17 15:21:59 -0800240 .bus_freq = 1,
Jordan Crouseb3115fe2012-02-01 22:11:12 -0700241 .io_fraction = 100,
242 },
243 {
Tarun Karra3c2cc9e2012-02-17 14:58:07 -0800244 .gpu_freq = 27000000,
245 .bus_freq = 0,
Jordan Crouseb3115fe2012-02-01 22:11:12 -0700246 },
247 },
Lucille Sylvester37a02d32012-04-25 17:21:06 -0600248 .init_level = 1,
Lucille Sylvesterf6b4ce32012-05-11 11:10:18 -0600249 .num_levels = 5,
Jordan Crouseb3115fe2012-02-01 22:11:12 -0700250 .set_grp_async = NULL,
Suman Tatiraju3bd641e2012-04-11 10:46:11 -0700251 .idle_timeout = HZ/10,
Jordan Crouseb3115fe2012-02-01 22:11:12 -0700252 .nap_allowed = true,
Lucille Sylvestera448aeb2012-06-12 16:30:29 -0600253 .strtstp_sleepwake = true,
Jordan Crouseb3115fe2012-02-01 22:11:12 -0700254 .clk_map = KGSL_CLK_CORE | KGSL_CLK_IFACE | KGSL_CLK_MEM_IFACE,
255#ifdef CONFIG_MSM_BUS_SCALING
256 .bus_scale_table = &grp3d_bus_scale_pdata,
257#endif
Jordan Crouse46cf4bb2012-02-21 08:54:52 -0700258 .iommu_data = kgsl_3d0_iommu_data,
259 .iommu_count = ARRAY_SIZE(kgsl_3d0_iommu_data),
Lucille Sylvester6e362412011-12-09 16:21:42 -0700260#ifdef CONFIG_MSM_DCVS
261 .core_info = &grp3d_core_info,
262#endif
Jordan Crouseb3115fe2012-02-01 22:11:12 -0700263};
264
265struct platform_device device_kgsl_3d0 = {
266 .name = "kgsl-3d0",
267 .id = 0,
268 .num_resources = ARRAY_SIZE(kgsl_3d0_resources),
269 .resource = kgsl_3d0_resources,
270 .dev = {
271 .platform_data = &kgsl_3d0_pdata,
272 },
273};
274
275void __init apq8064_init_gpu(void)
276{
Jordan Crouse4815e9f2012-07-09 15:36:37 -0600277 unsigned int version = socinfo_get_version();
278
279 if ((SOCINFO_VERSION_MAJOR(version) == 1) &&
280 (SOCINFO_VERSION_MINOR(version) == 1))
281 kgsl_3d0_pdata.chipid = ADRENO_CHIPID(3, 2, 0, 1);
282 else
283 kgsl_3d0_pdata.chipid = ADRENO_CHIPID(3, 2, 0, 0);
284
Jordan Crouseb3115fe2012-02-01 22:11:12 -0700285 platform_device_register(&device_kgsl_3d0);
286}