Abhijeet Dharmapurikar | 4445166 | 2012-08-23 18:58:44 -0700 | [diff] [blame] | 1 | /* Copyright (c) 2012, The Linux Foundation. All rights reserved. |
Jordan Crouse | b3115fe | 2012-02-01 22:11:12 -0700 | [diff] [blame] | 2 | * |
| 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 Crouse | 914de9b | 2012-07-09 13:49:46 -0600 | [diff] [blame] | 16 | #include <mach/kgsl.h> |
Jordan Crouse | b3115fe | 2012-02-01 22:11:12 -0700 | [diff] [blame] | 17 | #include <mach/msm_bus_board.h> |
| 18 | #include <mach/board.h> |
Lucille Sylvester | 6e36241 | 2011-12-09 16:21:42 -0700 | [diff] [blame] | 19 | #include <mach/msm_dcvs.h> |
Jordan Crouse | 4815e9f | 2012-07-09 15:36:37 -0600 | [diff] [blame] | 20 | #include <mach/socinfo.h> |
Jordan Crouse | b3115fe | 2012-02-01 22:11:12 -0700 | [diff] [blame] | 21 | |
| 22 | #include "devices.h" |
| 23 | #include "board-8064.h" |
| 24 | |
Lucille Sylvester | 6e36241 | 2011-12-09 16:21:42 -0700 | [diff] [blame] | 25 | #ifdef CONFIG_MSM_DCVS |
| 26 | static struct msm_dcvs_freq_entry grp3d_freq[] = { |
Abhijeet Dharmapurikar | 4445166 | 2012-08-23 18:58:44 -0700 | [diff] [blame] | 27 | {0, 900, 0, 0, 0}, |
| 28 | {0, 950, 0, 0, 0}, |
| 29 | {0, 950, 0, 0, 0}, |
| 30 | {0, 1200, 1, 100, 100}, |
Lucille Sylvester | 6e36241 | 2011-12-09 16:21:42 -0700 | [diff] [blame] | 31 | }; |
| 32 | |
| 33 | static struct msm_dcvs_core_info grp3d_core_info = { |
Abhijeet Dharmapurikar | 80add42 | 2012-09-13 11:11:54 -0700 | [diff] [blame] | 34 | .freq_tbl = &grp3d_freq[0], |
| 35 | .num_cores = 1, |
| 36 | .sensors = (int[]){0}, |
| 37 | .thermal_poll_ms = 60000, |
| 38 | .core_param = { |
Abhijeet Dharmapurikar | 4445166 | 2012-08-23 18:58:44 -0700 | [diff] [blame] | 39 | .core_type = MSM_DCVS_CORE_TYPE_GPU, |
Lucille Sylvester | 6e36241 | 2011-12-09 16:21:42 -0700 | [diff] [blame] | 40 | }, |
Abhijeet Dharmapurikar | 80add42 | 2012-09-13 11:11:54 -0700 | [diff] [blame] | 41 | .algo_param = { |
Abhijeet Dharmapurikar | 4445166 | 2012-08-23 18:58:44 -0700 | [diff] [blame] | 42 | .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 Muckle | e8c6d61 | 2012-12-06 14:31:00 -0800 | [diff] [blame] | 54 | .ss_no_corr_below_freq = 0, |
Lucille Sylvester | 6e36241 | 2011-12-09 16:21:42 -0700 | [diff] [blame] | 55 | }, |
Abhijeet Dharmapurikar | 4445166 | 2012-08-23 18:58:44 -0700 | [diff] [blame] | 56 | |
Abhijeet Dharmapurikar | 80add42 | 2012-09-13 11:11:54 -0700 | [diff] [blame] | 57 | .energy_coeffs = { |
Abhijeet Dharmapurikar | 4445166 | 2012-08-23 18:58:44 -0700 | [diff] [blame] | 58 | .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 Dharmapurikar | 80add42 | 2012-09-13 11:11:54 -0700 | [diff] [blame] | 68 | .power_param = { |
Abhijeet Dharmapurikar | 4445166 | 2012-08-23 18:58:44 -0700 | [diff] [blame] | 69 | .current_temp = 25, |
| 70 | .num_freq = ARRAY_SIZE(grp3d_freq), |
| 71 | } |
Lucille Sylvester | 6e36241 | 2011-12-09 16:21:42 -0700 | [diff] [blame] | 72 | }; |
| 73 | #endif /* CONFIG_MSM_DCVS */ |
| 74 | |
Jordan Crouse | b3115fe | 2012-02-01 22:11:12 -0700 | [diff] [blame] | 75 | #ifdef CONFIG_MSM_BUS_SCALING |
| 76 | static 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 | |
| 91 | static 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 Sylvester | f6b4ce3 | 2012-05-11 11:10:18 -0600 | [diff] [blame] | 96 | .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 | |
| 106 | static 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 Crouse | b3115fe | 2012-02-01 22:11:12 -0700 | [diff] [blame] | 111 | .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 | |
| 121 | static 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 Sylvester | 2661534 | 2012-06-26 17:55:10 -0600 | [diff] [blame] | 126 | .ib = KGSL_CONVERT_TO_MBPS(2656), |
Jordan Crouse | b3115fe | 2012-02-01 22:11:12 -0700 | [diff] [blame] | 127 | }, |
| 128 | { |
| 129 | .src = MSM_BUS_MASTER_GRAPHICS_3D_PORT1, |
| 130 | .dst = MSM_BUS_SLAVE_EBI_CH0, |
| 131 | .ab = 0, |
Lucille Sylvester | 2661534 | 2012-06-26 17:55:10 -0600 | [diff] [blame] | 132 | .ib = KGSL_CONVERT_TO_MBPS(2656), |
Jordan Crouse | b3115fe | 2012-02-01 22:11:12 -0700 | [diff] [blame] | 133 | }, |
| 134 | }; |
| 135 | |
| 136 | static 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 | |
| 151 | static 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 Sylvester | f6b4ce3 | 2012-05-11 11:10:18 -0600 | [diff] [blame] | 161 | ARRAY_SIZE(grp3d_nominal_low_vectors), |
| 162 | grp3d_nominal_low_vectors, |
| 163 | }, |
| 164 | { |
Jordan Crouse | b3115fe | 2012-02-01 22:11:12 -0700 | [diff] [blame] | 165 | 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 | |
| 174 | static 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 | |
| 181 | static struct resource kgsl_3d0_resources[] = { |
| 182 | { |
| 183 | .name = KGSL_3D0_REG_MEMORY, |
| 184 | .start = 0x04300000, /* GFX3D address */ |
Harsh Vardhan Dwivedi | 623b9a2 | 2012-10-28 20:54:17 -0600 | [diff] [blame] | 185 | .end = 0x0430ffff, |
| 186 | .flags = IORESOURCE_MEM, |
| 187 | }, |
| 188 | { |
| 189 | .name = KGSL_3D0_SHADER_MEMORY, |
| 190 | .start = 0x04310000, /* Shader Mem Address */ |
Jordan Crouse | b3115fe | 2012-02-01 22:11:12 -0700 | [diff] [blame] | 191 | .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 Das | eb6df1d | 2012-05-01 00:55:35 -0600 | [diff] [blame] | 202 | static const struct kgsl_iommu_ctx kgsl_3d0_iommu0_ctxs[] = { |
| 203 | { "gfx3d_user", 0 }, |
| 204 | { "gfx3d_priv", 1 }, |
Jordan Crouse | 46cf4bb | 2012-02-21 08:54:52 -0700 | [diff] [blame] | 205 | }; |
| 206 | |
Shubhraprakash Das | eb6df1d | 2012-05-01 00:55:35 -0600 | [diff] [blame] | 207 | static const struct kgsl_iommu_ctx kgsl_3d0_iommu1_ctxs[] = { |
| 208 | { "gfx3d1_user", 0 }, |
| 209 | { "gfx3d1_priv", 1 }, |
Jordan Crouse | 46cf4bb | 2012-02-21 08:54:52 -0700 | [diff] [blame] | 210 | }; |
| 211 | |
| 212 | static struct kgsl_device_iommu_data kgsl_3d0_iommu_data[] = { |
| 213 | { |
Shubhraprakash Das | eb6df1d | 2012-05-01 00:55:35 -0600 | [diff] [blame] | 214 | .iommu_ctxs = kgsl_3d0_iommu0_ctxs, |
| 215 | .iommu_ctx_count = ARRAY_SIZE(kgsl_3d0_iommu0_ctxs), |
Jordan Crouse | 46cf4bb | 2012-02-21 08:54:52 -0700 | [diff] [blame] | 216 | .physstart = 0x07C00000, |
| 217 | .physend = 0x07C00000 + SZ_1M - 1, |
| 218 | }, |
| 219 | { |
Shubhraprakash Das | eb6df1d | 2012-05-01 00:55:35 -0600 | [diff] [blame] | 220 | .iommu_ctxs = kgsl_3d0_iommu1_ctxs, |
| 221 | .iommu_ctx_count = ARRAY_SIZE(kgsl_3d0_iommu1_ctxs), |
Jordan Crouse | 46cf4bb | 2012-02-21 08:54:52 -0700 | [diff] [blame] | 222 | .physstart = 0x07D00000, |
| 223 | .physend = 0x07D00000 + SZ_1M - 1, |
| 224 | }, |
| 225 | }; |
| 226 | |
Jordan Crouse | b3115fe | 2012-02-01 22:11:12 -0700 | [diff] [blame] | 227 | static struct kgsl_device_platform_data kgsl_3d0_pdata = { |
| 228 | .pwrlevel = { |
| 229 | { |
Tarun Karra | 3c2cc9e | 2012-02-17 14:58:07 -0800 | [diff] [blame] | 230 | .gpu_freq = 400000000, |
Lucille Sylvester | f6b4ce3 | 2012-05-11 11:10:18 -0600 | [diff] [blame] | 231 | .bus_freq = 4, |
Tarun Karra | 3c2cc9e | 2012-02-17 14:58:07 -0800 | [diff] [blame] | 232 | .io_fraction = 0, |
Jordan Crouse | b3115fe | 2012-02-01 22:11:12 -0700 | [diff] [blame] | 233 | }, |
| 234 | { |
Suman Tatiraju | 03a95db | 2012-10-29 18:24:53 -0700 | [diff] [blame] | 235 | .gpu_freq = 320000000, |
Lucille Sylvester | f6b4ce3 | 2012-05-11 11:10:18 -0600 | [diff] [blame] | 236 | .bus_freq = 3, |
Tarun Karra | 3c2cc9e | 2012-02-17 14:58:07 -0800 | [diff] [blame] | 237 | .io_fraction = 33, |
Jordan Crouse | b3115fe | 2012-02-01 22:11:12 -0700 | [diff] [blame] | 238 | }, |
| 239 | { |
Lucille Sylvester | 0c779a9 | 2012-03-30 16:51:27 -0600 | [diff] [blame] | 240 | .gpu_freq = 200000000, |
Lucille Sylvester | f6b4ce3 | 2012-05-11 11:10:18 -0600 | [diff] [blame] | 241 | .bus_freq = 2, |
| 242 | .io_fraction = 100, |
| 243 | }, |
| 244 | { |
| 245 | .gpu_freq = 128000000, |
Tarun Karra | 7185370 | 2012-02-17 15:21:59 -0800 | [diff] [blame] | 246 | .bus_freq = 1, |
Jordan Crouse | b3115fe | 2012-02-01 22:11:12 -0700 | [diff] [blame] | 247 | .io_fraction = 100, |
| 248 | }, |
| 249 | { |
Tarun Karra | 3c2cc9e | 2012-02-17 14:58:07 -0800 | [diff] [blame] | 250 | .gpu_freq = 27000000, |
| 251 | .bus_freq = 0, |
Jordan Crouse | b3115fe | 2012-02-01 22:11:12 -0700 | [diff] [blame] | 252 | }, |
| 253 | }, |
Lucille Sylvester | 37a02d3 | 2012-04-25 17:21:06 -0600 | [diff] [blame] | 254 | .init_level = 1, |
Lucille Sylvester | f6b4ce3 | 2012-05-11 11:10:18 -0600 | [diff] [blame] | 255 | .num_levels = 5, |
Jordan Crouse | b3115fe | 2012-02-01 22:11:12 -0700 | [diff] [blame] | 256 | .set_grp_async = NULL, |
Suman Tatiraju | 3bd641e | 2012-04-11 10:46:11 -0700 | [diff] [blame] | 257 | .idle_timeout = HZ/10, |
Jordan Crouse | b3115fe | 2012-02-01 22:11:12 -0700 | [diff] [blame] | 258 | .nap_allowed = true, |
Lucille Sylvester | a448aeb | 2012-06-12 16:30:29 -0600 | [diff] [blame] | 259 | .strtstp_sleepwake = true, |
Jordan Crouse | b3115fe | 2012-02-01 22:11:12 -0700 | [diff] [blame] | 260 | .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 Crouse | 46cf4bb | 2012-02-21 08:54:52 -0700 | [diff] [blame] | 264 | .iommu_data = kgsl_3d0_iommu_data, |
| 265 | .iommu_count = ARRAY_SIZE(kgsl_3d0_iommu_data), |
Lucille Sylvester | 6e36241 | 2011-12-09 16:21:42 -0700 | [diff] [blame] | 266 | #ifdef CONFIG_MSM_DCVS |
| 267 | .core_info = &grp3d_core_info, |
| 268 | #endif |
Jordan Crouse | b3115fe | 2012-02-01 22:11:12 -0700 | [diff] [blame] | 269 | }; |
| 270 | |
| 271 | struct 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 | |
| 281 | void __init apq8064_init_gpu(void) |
| 282 | { |
Jordan Crouse | 4815e9f | 2012-07-09 15:36:37 -0600 | [diff] [blame] | 283 | unsigned int version = socinfo_get_version(); |
| 284 | |
Rajeev Kulkarni | 868938e | 2012-09-22 13:14:39 -0700 | [diff] [blame] | 285 | if (cpu_is_apq8064ab()) |
| 286 | kgsl_3d0_pdata.pwrlevel[0].gpu_freq = 450000000; |
Rajeev Kulkarni | 1e52ca5 | 2012-09-28 17:53:31 -0700 | [diff] [blame] | 287 | if (SOCINFO_VERSION_MAJOR(version) == 2) { |
| 288 | kgsl_3d0_pdata.chipid = ADRENO_CHIPID(3, 2, 0, 2); |
| 289 | } else { |
Kevin Matlage | b43eaa9 | 2012-10-23 17:10:56 -0600 | [diff] [blame] | 290 | /* 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 Kulkarni | 1e52ca5 | 2012-09-28 17:53:31 -0700 | [diff] [blame] | 293 | if ((SOCINFO_VERSION_MAJOR(version) == 1) && |
Kevin Matlage | b43eaa9 | 2012-10-23 17:10:56 -0600 | [diff] [blame] | 294 | (SOCINFO_VERSION_MINOR(version) >= 1)) |
Rajeev Kulkarni | 1e52ca5 | 2012-09-28 17:53:31 -0700 | [diff] [blame] | 295 | 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 Crouse | 4815e9f | 2012-07-09 15:36:37 -0600 | [diff] [blame] | 299 | |
Jordan Crouse | b3115fe | 2012-02-01 22:11:12 -0700 | [diff] [blame] | 300 | platform_device_register(&device_kgsl_3d0); |
| 301 | } |