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, |
| 54 | .ss_iobusy_conv = 100, |
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 */ |
| 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 Das | eb6df1d | 2012-05-01 00:55:35 -0600 | [diff] [blame] | 196 | static const struct kgsl_iommu_ctx kgsl_3d0_iommu0_ctxs[] = { |
| 197 | { "gfx3d_user", 0 }, |
| 198 | { "gfx3d_priv", 1 }, |
Jordan Crouse | 46cf4bb | 2012-02-21 08:54:52 -0700 | [diff] [blame] | 199 | }; |
| 200 | |
Shubhraprakash Das | eb6df1d | 2012-05-01 00:55:35 -0600 | [diff] [blame] | 201 | static const struct kgsl_iommu_ctx kgsl_3d0_iommu1_ctxs[] = { |
| 202 | { "gfx3d1_user", 0 }, |
| 203 | { "gfx3d1_priv", 1 }, |
Jordan Crouse | 46cf4bb | 2012-02-21 08:54:52 -0700 | [diff] [blame] | 204 | }; |
| 205 | |
| 206 | static struct kgsl_device_iommu_data kgsl_3d0_iommu_data[] = { |
| 207 | { |
Shubhraprakash Das | eb6df1d | 2012-05-01 00:55:35 -0600 | [diff] [blame] | 208 | .iommu_ctxs = kgsl_3d0_iommu0_ctxs, |
| 209 | .iommu_ctx_count = ARRAY_SIZE(kgsl_3d0_iommu0_ctxs), |
Jordan Crouse | 46cf4bb | 2012-02-21 08:54:52 -0700 | [diff] [blame] | 210 | .physstart = 0x07C00000, |
| 211 | .physend = 0x07C00000 + SZ_1M - 1, |
| 212 | }, |
| 213 | { |
Shubhraprakash Das | eb6df1d | 2012-05-01 00:55:35 -0600 | [diff] [blame] | 214 | .iommu_ctxs = kgsl_3d0_iommu1_ctxs, |
| 215 | .iommu_ctx_count = ARRAY_SIZE(kgsl_3d0_iommu1_ctxs), |
Jordan Crouse | 46cf4bb | 2012-02-21 08:54:52 -0700 | [diff] [blame] | 216 | .physstart = 0x07D00000, |
| 217 | .physend = 0x07D00000 + SZ_1M - 1, |
| 218 | }, |
| 219 | }; |
| 220 | |
Jordan Crouse | b3115fe | 2012-02-01 22:11:12 -0700 | [diff] [blame] | 221 | static struct kgsl_device_platform_data kgsl_3d0_pdata = { |
| 222 | .pwrlevel = { |
| 223 | { |
Tarun Karra | 3c2cc9e | 2012-02-17 14:58:07 -0800 | [diff] [blame] | 224 | .gpu_freq = 400000000, |
Lucille Sylvester | f6b4ce3 | 2012-05-11 11:10:18 -0600 | [diff] [blame] | 225 | .bus_freq = 4, |
Tarun Karra | 3c2cc9e | 2012-02-17 14:58:07 -0800 | [diff] [blame] | 226 | .io_fraction = 0, |
Jordan Crouse | b3115fe | 2012-02-01 22:11:12 -0700 | [diff] [blame] | 227 | }, |
| 228 | { |
Lucille Sylvester | 0c779a9 | 2012-03-30 16:51:27 -0600 | [diff] [blame] | 229 | .gpu_freq = 325000000, |
Lucille Sylvester | f6b4ce3 | 2012-05-11 11:10:18 -0600 | [diff] [blame] | 230 | .bus_freq = 3, |
Tarun Karra | 3c2cc9e | 2012-02-17 14:58:07 -0800 | [diff] [blame] | 231 | .io_fraction = 33, |
Jordan Crouse | b3115fe | 2012-02-01 22:11:12 -0700 | [diff] [blame] | 232 | }, |
| 233 | { |
Lucille Sylvester | 0c779a9 | 2012-03-30 16:51:27 -0600 | [diff] [blame] | 234 | .gpu_freq = 200000000, |
Lucille Sylvester | f6b4ce3 | 2012-05-11 11:10:18 -0600 | [diff] [blame] | 235 | .bus_freq = 2, |
| 236 | .io_fraction = 100, |
| 237 | }, |
| 238 | { |
| 239 | .gpu_freq = 128000000, |
Tarun Karra | 7185370 | 2012-02-17 15:21:59 -0800 | [diff] [blame] | 240 | .bus_freq = 1, |
Jordan Crouse | b3115fe | 2012-02-01 22:11:12 -0700 | [diff] [blame] | 241 | .io_fraction = 100, |
| 242 | }, |
| 243 | { |
Tarun Karra | 3c2cc9e | 2012-02-17 14:58:07 -0800 | [diff] [blame] | 244 | .gpu_freq = 27000000, |
| 245 | .bus_freq = 0, |
Jordan Crouse | b3115fe | 2012-02-01 22:11:12 -0700 | [diff] [blame] | 246 | }, |
| 247 | }, |
Lucille Sylvester | 37a02d3 | 2012-04-25 17:21:06 -0600 | [diff] [blame] | 248 | .init_level = 1, |
Lucille Sylvester | f6b4ce3 | 2012-05-11 11:10:18 -0600 | [diff] [blame] | 249 | .num_levels = 5, |
Jordan Crouse | b3115fe | 2012-02-01 22:11:12 -0700 | [diff] [blame] | 250 | .set_grp_async = NULL, |
Suman Tatiraju | 3bd641e | 2012-04-11 10:46:11 -0700 | [diff] [blame] | 251 | .idle_timeout = HZ/10, |
Jordan Crouse | b3115fe | 2012-02-01 22:11:12 -0700 | [diff] [blame] | 252 | .nap_allowed = true, |
Lucille Sylvester | a448aeb | 2012-06-12 16:30:29 -0600 | [diff] [blame] | 253 | .strtstp_sleepwake = true, |
Jordan Crouse | b3115fe | 2012-02-01 22:11:12 -0700 | [diff] [blame] | 254 | .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 Crouse | 46cf4bb | 2012-02-21 08:54:52 -0700 | [diff] [blame] | 258 | .iommu_data = kgsl_3d0_iommu_data, |
| 259 | .iommu_count = ARRAY_SIZE(kgsl_3d0_iommu_data), |
Lucille Sylvester | 6e36241 | 2011-12-09 16:21:42 -0700 | [diff] [blame] | 260 | #ifdef CONFIG_MSM_DCVS |
| 261 | .core_info = &grp3d_core_info, |
| 262 | #endif |
Jordan Crouse | b3115fe | 2012-02-01 22:11:12 -0700 | [diff] [blame] | 263 | }; |
| 264 | |
| 265 | struct 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 | |
| 275 | void __init apq8064_init_gpu(void) |
| 276 | { |
Jordan Crouse | 4815e9f | 2012-07-09 15:36:37 -0600 | [diff] [blame] | 277 | 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 Crouse | b3115fe | 2012-02-01 22:11:12 -0700 | [diff] [blame] | 285 | platform_device_register(&device_kgsl_3d0); |
| 286 | } |