Duy Truong | e833aca | 2013-02-12 13:35:08 -0800 | [diff] [blame] | 1 | /* Copyright (c) 2010-2012, The Linux Foundation. All rights reserved. |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -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 | */ |
Steve Muckle | f132c6c | 2012-06-06 18:30:57 -0700 | [diff] [blame] | 13 | |
| 14 | #include <linux/export.h> |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 15 | #include <linux/interrupt.h> |
Steve Muckle | f132c6c | 2012-06-06 18:30:57 -0700 | [diff] [blame] | 16 | #include <asm/page.h> |
Jeremy Gebben | 4f5f0de | 2012-03-01 15:51:37 -0700 | [diff] [blame] | 17 | #include <linux/pm_runtime.h> |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 18 | #include <mach/msm_iomap.h> |
| 19 | #include <mach/msm_bus.h> |
Suman Tatiraju | 2bdd056 | 2012-01-26 14:49:46 -0800 | [diff] [blame] | 20 | #include <linux/ktime.h> |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 21 | |
| 22 | #include "kgsl.h" |
| 23 | #include "kgsl_pwrscale.h" |
| 24 | #include "kgsl_device.h" |
Jeremy Gebben | b50f331 | 2011-12-16 08:58:33 -0700 | [diff] [blame] | 25 | #include "kgsl_trace.h" |
Ranjhith Kalisamy | cb1721c | 2013-05-28 16:59:59 -0600 | [diff] [blame^] | 26 | #include "kgsl_sharedmem.h" |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 27 | |
Jeremy Gebben | b46f415 | 2011-10-14 14:27:00 -0600 | [diff] [blame] | 28 | #define KGSL_PWRFLAGS_POWER_ON 0 |
| 29 | #define KGSL_PWRFLAGS_CLK_ON 1 |
| 30 | #define KGSL_PWRFLAGS_AXI_ON 2 |
| 31 | #define KGSL_PWRFLAGS_IRQ_ON 3 |
| 32 | |
Lucille Sylvester | 1029789 | 2012-02-27 13:54:47 -0700 | [diff] [blame] | 33 | #define GPU_SWFI_LATENCY 3 |
Suman Tatiraju | 7fe62a3 | 2011-07-14 16:40:37 -0700 | [diff] [blame] | 34 | #define UPDATE_BUSY_VAL 1000000 |
| 35 | #define UPDATE_BUSY 50 |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 36 | |
Lucille Sylvester | dce84cd | 2011-10-12 14:15:37 -0600 | [diff] [blame] | 37 | struct clk_pair { |
| 38 | const char *name; |
| 39 | uint map; |
| 40 | }; |
| 41 | |
| 42 | struct clk_pair clks[KGSL_MAX_CLKS] = { |
| 43 | { |
| 44 | .name = "src_clk", |
| 45 | .map = KGSL_CLK_SRC, |
| 46 | }, |
| 47 | { |
| 48 | .name = "core_clk", |
| 49 | .map = KGSL_CLK_CORE, |
| 50 | }, |
| 51 | { |
| 52 | .name = "iface_clk", |
| 53 | .map = KGSL_CLK_IFACE, |
| 54 | }, |
| 55 | { |
| 56 | .name = "mem_clk", |
| 57 | .map = KGSL_CLK_MEM, |
| 58 | }, |
| 59 | { |
| 60 | .name = "mem_iface_clk", |
| 61 | .map = KGSL_CLK_MEM_IFACE, |
| 62 | }, |
| 63 | }; |
| 64 | |
Suman Tatiraju | 2bdd056 | 2012-01-26 14:49:46 -0800 | [diff] [blame] | 65 | /* Update the elapsed time at a particular clock level |
| 66 | * if the device is active(on_time = true).Otherwise |
| 67 | * store it as sleep time. |
| 68 | */ |
| 69 | static void update_clk_statistics(struct kgsl_device *device, |
| 70 | bool on_time) |
| 71 | { |
| 72 | struct kgsl_pwrctrl *pwr = &device->pwrctrl; |
| 73 | struct kgsl_clk_stats *clkstats = &pwr->clk_stats; |
| 74 | ktime_t elapsed; |
| 75 | int elapsed_us; |
| 76 | if (clkstats->start.tv64 == 0) |
| 77 | clkstats->start = ktime_get(); |
| 78 | clkstats->stop = ktime_get(); |
| 79 | elapsed = ktime_sub(clkstats->stop, clkstats->start); |
| 80 | elapsed_us = ktime_to_us(elapsed); |
| 81 | clkstats->elapsed += elapsed_us; |
| 82 | if (on_time) |
| 83 | clkstats->clock_time[pwr->active_pwrlevel] += elapsed_us; |
| 84 | else |
| 85 | clkstats->clock_time[pwr->num_pwrlevels - 1] += elapsed_us; |
| 86 | clkstats->start = ktime_get(); |
| 87 | } |
| 88 | |
Jordan Crouse | 2ddfc8a | 2012-11-27 11:33:06 -0700 | [diff] [blame] | 89 | /* |
| 90 | * Given a requested power level do bounds checking on the constraints and |
| 91 | * return the nearest possible level |
| 92 | */ |
| 93 | |
| 94 | static inline int _adjust_pwrlevel(struct kgsl_pwrctrl *pwr, int level) |
| 95 | { |
Jordan Crouse | 00a01ba | 2012-12-05 15:58:16 -0700 | [diff] [blame] | 96 | int max_pwrlevel = max_t(int, pwr->thermal_pwrlevel, pwr->max_pwrlevel); |
| 97 | int min_pwrlevel = max_t(int, pwr->thermal_pwrlevel, pwr->min_pwrlevel); |
Jordan Crouse | 2ddfc8a | 2012-11-27 11:33:06 -0700 | [diff] [blame] | 98 | |
| 99 | if (level < max_pwrlevel) |
| 100 | return max_pwrlevel; |
| 101 | if (level > min_pwrlevel) |
| 102 | return min_pwrlevel; |
| 103 | |
| 104 | return level; |
| 105 | } |
| 106 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 107 | void kgsl_pwrctrl_pwrlevel_change(struct kgsl_device *device, |
| 108 | unsigned int new_level) |
| 109 | { |
| 110 | struct kgsl_pwrctrl *pwr = &device->pwrctrl; |
Jordan Crouse | 2ddfc8a | 2012-11-27 11:33:06 -0700 | [diff] [blame] | 111 | struct kgsl_pwrlevel *pwrlevel; |
| 112 | int delta; |
Jordan Crouse | 3c337a3 | 2012-12-04 16:16:51 -0700 | [diff] [blame] | 113 | int level; |
Jordan Crouse | a29a2e0 | 2012-08-14 09:09:23 -0600 | [diff] [blame] | 114 | |
Jordan Crouse | 2ddfc8a | 2012-11-27 11:33:06 -0700 | [diff] [blame] | 115 | /* Adjust the power level to the current constraints */ |
| 116 | new_level = _adjust_pwrlevel(pwr, new_level); |
| 117 | |
| 118 | if (new_level == pwr->active_pwrlevel) |
| 119 | return; |
| 120 | |
| 121 | delta = new_level < pwr->active_pwrlevel ? -1 : 1; |
| 122 | |
| 123 | update_clk_statistics(device, true); |
| 124 | |
Jordan Crouse | 3c337a3 | 2012-12-04 16:16:51 -0700 | [diff] [blame] | 125 | level = pwr->active_pwrlevel; |
| 126 | |
| 127 | /* |
| 128 | * Set the active powerlevel first in case the clocks are off - if we |
| 129 | * don't do this then the pwrlevel change won't take effect when the |
| 130 | * clocks come back |
| 131 | */ |
| 132 | |
| 133 | pwr->active_pwrlevel = new_level; |
| 134 | |
Jordan Crouse | 2ddfc8a | 2012-11-27 11:33:06 -0700 | [diff] [blame] | 135 | if (test_bit(KGSL_PWRFLAGS_CLK_ON, &pwr->power_flags) || |
| 136 | (device->state == KGSL_STATE_NAP)) { |
| 137 | |
| 138 | /* |
| 139 | * On some platforms, instability is caused on |
| 140 | * changing clock freq when the core is busy. |
| 141 | * Idle the gpu core before changing the clock freq. |
| 142 | */ |
| 143 | |
| 144 | if (pwr->idle_needed == true) |
| 145 | device->ftbl->idle(device); |
| 146 | |
| 147 | /* |
| 148 | * Don't shift by more than one level at a time to |
| 149 | * avoid glitches. |
| 150 | */ |
| 151 | |
Jordan Crouse | 3c337a3 | 2012-12-04 16:16:51 -0700 | [diff] [blame] | 152 | while (level != new_level) { |
| 153 | level += delta; |
Jordan Crouse | 2ddfc8a | 2012-11-27 11:33:06 -0700 | [diff] [blame] | 154 | |
| 155 | clk_set_rate(pwr->grp_clks[0], |
Jordan Crouse | 3c337a3 | 2012-12-04 16:16:51 -0700 | [diff] [blame] | 156 | pwr->pwrlevels[level].gpu_freq); |
Kedar Joshi | c11d098 | 2012-02-07 10:59:49 +0530 | [diff] [blame] | 157 | } |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 158 | } |
Jordan Crouse | 2ddfc8a | 2012-11-27 11:33:06 -0700 | [diff] [blame] | 159 | |
| 160 | pwrlevel = &pwr->pwrlevels[pwr->active_pwrlevel]; |
| 161 | |
| 162 | if (test_bit(KGSL_PWRFLAGS_AXI_ON, &pwr->power_flags)) { |
| 163 | |
| 164 | if (pwr->pcl) |
| 165 | msm_bus_scale_client_update_request(pwr->pcl, |
| 166 | pwrlevel->bus_freq); |
| 167 | else if (pwr->ebi1_clk) |
| 168 | clk_set_rate(pwr->ebi1_clk, pwrlevel->bus_freq); |
| 169 | } |
| 170 | |
| 171 | trace_kgsl_pwrlevel(device, pwr->active_pwrlevel, pwrlevel->gpu_freq); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 172 | } |
Jordan Crouse | 2ddfc8a | 2012-11-27 11:33:06 -0700 | [diff] [blame] | 173 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 174 | EXPORT_SYMBOL(kgsl_pwrctrl_pwrlevel_change); |
| 175 | |
Jordan Crouse | 2ddfc8a | 2012-11-27 11:33:06 -0700 | [diff] [blame] | 176 | static int kgsl_pwrctrl_thermal_pwrlevel_store(struct device *dev, |
| 177 | struct device_attribute *attr, |
| 178 | const char *buf, size_t count) |
| 179 | { |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 180 | struct kgsl_device *device = kgsl_device_from_dev(dev); |
Jordan Crouse | 6c2992a | 2011-08-08 17:00:06 -0600 | [diff] [blame] | 181 | struct kgsl_pwrctrl *pwr; |
Jordan Crouse | 2ddfc8a | 2012-11-27 11:33:06 -0700 | [diff] [blame] | 182 | int ret, level; |
Jordan Crouse | 6c2992a | 2011-08-08 17:00:06 -0600 | [diff] [blame] | 183 | |
| 184 | if (device == NULL) |
| 185 | return 0; |
Jordan Crouse | 2ddfc8a | 2012-11-27 11:33:06 -0700 | [diff] [blame] | 186 | |
| 187 | pwr = &device->pwrctrl; |
| 188 | |
| 189 | ret = sscanf(buf, "%d", &level); |
| 190 | if (ret != 1) |
| 191 | return count; |
| 192 | |
| 193 | if (level < 0) |
| 194 | return count; |
| 195 | |
| 196 | mutex_lock(&device->mutex); |
| 197 | |
| 198 | if (level > pwr->num_pwrlevels - 2) |
| 199 | level = pwr->num_pwrlevels - 2; |
| 200 | |
| 201 | pwr->thermal_pwrlevel = level; |
| 202 | |
| 203 | /* |
| 204 | * If there is no power policy set the clock to the requested thermal |
| 205 | * level - if thermal now happens to be higher than max, then that will |
| 206 | * be limited by the pwrlevel change function. Otherwise if there is |
| 207 | * a policy only change the active clock if it is higher then the new |
| 208 | * thermal level |
| 209 | */ |
| 210 | |
| 211 | if (device->pwrscale.policy == NULL || |
| 212 | pwr->thermal_pwrlevel > pwr->active_pwrlevel) |
| 213 | kgsl_pwrctrl_pwrlevel_change(device, pwr->thermal_pwrlevel); |
| 214 | |
| 215 | mutex_unlock(&device->mutex); |
| 216 | |
| 217 | return count; |
| 218 | } |
| 219 | |
| 220 | static int kgsl_pwrctrl_thermal_pwrlevel_show(struct device *dev, |
| 221 | struct device_attribute *attr, |
| 222 | char *buf) |
| 223 | { |
| 224 | |
| 225 | struct kgsl_device *device = kgsl_device_from_dev(dev); |
| 226 | struct kgsl_pwrctrl *pwr; |
| 227 | if (device == NULL) |
| 228 | return 0; |
| 229 | pwr = &device->pwrctrl; |
| 230 | return snprintf(buf, PAGE_SIZE, "%d\n", pwr->thermal_pwrlevel); |
| 231 | } |
| 232 | |
| 233 | static int kgsl_pwrctrl_max_pwrlevel_store(struct device *dev, |
| 234 | struct device_attribute *attr, |
| 235 | const char *buf, size_t count) |
| 236 | { |
| 237 | struct kgsl_device *device = kgsl_device_from_dev(dev); |
| 238 | struct kgsl_pwrctrl *pwr; |
| 239 | int ret, level, max_level; |
| 240 | |
| 241 | if (device == NULL) |
| 242 | return 0; |
| 243 | |
| 244 | pwr = &device->pwrctrl; |
| 245 | |
| 246 | ret = sscanf(buf, "%d", &level); |
| 247 | if (ret != 1) |
| 248 | return count; |
| 249 | |
| 250 | /* If the use specifies a negative number, then don't change anything */ |
| 251 | if (level < 0) |
| 252 | return count; |
| 253 | |
| 254 | mutex_lock(&device->mutex); |
| 255 | |
| 256 | /* You can't set a maximum power level lower than the minimum */ |
| 257 | if (level > pwr->min_pwrlevel) |
| 258 | level = pwr->min_pwrlevel; |
| 259 | |
| 260 | pwr->max_pwrlevel = level; |
| 261 | |
| 262 | |
| 263 | max_level = max_t(int, pwr->thermal_pwrlevel, pwr->max_pwrlevel); |
| 264 | |
| 265 | /* |
| 266 | * If there is no policy then move to max by default. Otherwise only |
| 267 | * move max if the current level happens to be higher then the new max |
| 268 | */ |
| 269 | |
| 270 | if (device->pwrscale.policy == NULL || |
| 271 | (max_level > pwr->active_pwrlevel)) |
| 272 | kgsl_pwrctrl_pwrlevel_change(device, max_level); |
| 273 | |
| 274 | mutex_unlock(&device->mutex); |
| 275 | |
| 276 | return count; |
| 277 | } |
| 278 | |
| 279 | static int kgsl_pwrctrl_max_pwrlevel_show(struct device *dev, |
| 280 | struct device_attribute *attr, |
| 281 | char *buf) |
| 282 | { |
| 283 | |
| 284 | struct kgsl_device *device = kgsl_device_from_dev(dev); |
| 285 | struct kgsl_pwrctrl *pwr; |
| 286 | if (device == NULL) |
| 287 | return 0; |
| 288 | pwr = &device->pwrctrl; |
| 289 | return snprintf(buf, PAGE_SIZE, "%d\n", pwr->max_pwrlevel); |
| 290 | } |
| 291 | |
| 292 | static int kgsl_pwrctrl_min_pwrlevel_store(struct device *dev, |
| 293 | struct device_attribute *attr, |
| 294 | const char *buf, size_t count) |
| 295 | { struct kgsl_device *device = kgsl_device_from_dev(dev); |
| 296 | struct kgsl_pwrctrl *pwr; |
| 297 | int ret, level, min_level; |
| 298 | |
| 299 | if (device == NULL) |
| 300 | return 0; |
| 301 | |
| 302 | pwr = &device->pwrctrl; |
| 303 | |
| 304 | ret = sscanf(buf, "%d", &level); |
| 305 | if (ret != 1) |
| 306 | return count; |
| 307 | |
| 308 | /* Don't do anything on obviously incorrect values */ |
| 309 | if (level < 0) |
| 310 | return count; |
| 311 | |
| 312 | mutex_lock(&device->mutex); |
| 313 | if (level > pwr->num_pwrlevels - 2) |
| 314 | level = pwr->num_pwrlevels - 2; |
| 315 | |
| 316 | /* You can't set a minimum power level lower than the maximum */ |
| 317 | if (level < pwr->max_pwrlevel) |
| 318 | level = pwr->max_pwrlevel; |
| 319 | |
| 320 | pwr->min_pwrlevel = level; |
| 321 | |
| 322 | min_level = max_t(int, pwr->thermal_pwrlevel, pwr->min_pwrlevel); |
| 323 | |
| 324 | /* Only move the power level higher if minimum is higher then the |
| 325 | * current level |
| 326 | */ |
| 327 | |
| 328 | if (min_level < pwr->active_pwrlevel) |
| 329 | kgsl_pwrctrl_pwrlevel_change(device, min_level); |
| 330 | |
| 331 | mutex_unlock(&device->mutex); |
| 332 | |
| 333 | return count; |
| 334 | } |
| 335 | |
| 336 | static int kgsl_pwrctrl_min_pwrlevel_show(struct device *dev, |
| 337 | struct device_attribute *attr, |
| 338 | char *buf) |
| 339 | { |
| 340 | struct kgsl_device *device = kgsl_device_from_dev(dev); |
| 341 | struct kgsl_pwrctrl *pwr; |
| 342 | if (device == NULL) |
| 343 | return 0; |
| 344 | pwr = &device->pwrctrl; |
| 345 | return snprintf(buf, PAGE_SIZE, "%d\n", pwr->min_pwrlevel); |
| 346 | } |
| 347 | |
| 348 | static int kgsl_pwrctrl_num_pwrlevels_show(struct device *dev, |
| 349 | struct device_attribute *attr, |
| 350 | char *buf) |
| 351 | { |
| 352 | |
| 353 | struct kgsl_device *device = kgsl_device_from_dev(dev); |
| 354 | struct kgsl_pwrctrl *pwr; |
| 355 | if (device == NULL) |
| 356 | return 0; |
| 357 | pwr = &device->pwrctrl; |
| 358 | return snprintf(buf, PAGE_SIZE, "%d\n", pwr->num_pwrlevels - 1); |
| 359 | } |
| 360 | |
| 361 | /* Given a GPU clock value, return the nearest powerlevel */ |
| 362 | |
| 363 | static int _get_nearest_pwrlevel(struct kgsl_pwrctrl *pwr, unsigned int clock) |
| 364 | { |
| 365 | int i; |
| 366 | |
| 367 | for (i = 0; i < pwr->num_pwrlevels - 1; i++) { |
| 368 | if (abs(pwr->pwrlevels[i].gpu_freq - clock) < 5000000) |
| 369 | return i; |
| 370 | } |
| 371 | |
| 372 | return -ERANGE; |
| 373 | } |
| 374 | |
| 375 | static int kgsl_pwrctrl_max_gpuclk_store(struct device *dev, |
| 376 | struct device_attribute *attr, |
| 377 | const char *buf, size_t count) |
| 378 | { |
| 379 | struct kgsl_device *device = kgsl_device_from_dev(dev); |
| 380 | struct kgsl_pwrctrl *pwr; |
| 381 | unsigned long val; |
| 382 | int ret, level; |
| 383 | |
| 384 | if (device == NULL) |
| 385 | return 0; |
| 386 | |
Jordan Crouse | 6c2992a | 2011-08-08 17:00:06 -0600 | [diff] [blame] | 387 | pwr = &device->pwrctrl; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 388 | |
| 389 | ret = sscanf(buf, "%ld", &val); |
| 390 | if (ret != 1) |
| 391 | return count; |
| 392 | |
| 393 | mutex_lock(&device->mutex); |
Jordan Crouse | 2ddfc8a | 2012-11-27 11:33:06 -0700 | [diff] [blame] | 394 | level = _get_nearest_pwrlevel(pwr, val); |
| 395 | if (level < 0) |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 396 | goto done; |
| 397 | |
Jordan Crouse | 2ddfc8a | 2012-11-27 11:33:06 -0700 | [diff] [blame] | 398 | pwr->thermal_pwrlevel = level; |
| 399 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 400 | /* |
Jordan Crouse | 2ddfc8a | 2012-11-27 11:33:06 -0700 | [diff] [blame] | 401 | * if the thermal limit is lower than the current setting, |
| 402 | * move the speed down immediately |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 403 | */ |
| 404 | |
Jordan Crouse | 2ddfc8a | 2012-11-27 11:33:06 -0700 | [diff] [blame] | 405 | if (pwr->thermal_pwrlevel > pwr->active_pwrlevel) |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 406 | kgsl_pwrctrl_pwrlevel_change(device, pwr->thermal_pwrlevel); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 407 | |
| 408 | done: |
| 409 | mutex_unlock(&device->mutex); |
| 410 | return count; |
| 411 | } |
| 412 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 413 | static int kgsl_pwrctrl_max_gpuclk_show(struct device *dev, |
| 414 | struct device_attribute *attr, |
| 415 | char *buf) |
| 416 | { |
Jordan Crouse | 2ddfc8a | 2012-11-27 11:33:06 -0700 | [diff] [blame] | 417 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 418 | struct kgsl_device *device = kgsl_device_from_dev(dev); |
Jordan Crouse | 6c2992a | 2011-08-08 17:00:06 -0600 | [diff] [blame] | 419 | struct kgsl_pwrctrl *pwr; |
| 420 | if (device == NULL) |
| 421 | return 0; |
| 422 | pwr = &device->pwrctrl; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 423 | return snprintf(buf, PAGE_SIZE, "%d\n", |
| 424 | pwr->pwrlevels[pwr->thermal_pwrlevel].gpu_freq); |
| 425 | } |
| 426 | |
| 427 | static int kgsl_pwrctrl_gpuclk_store(struct device *dev, |
| 428 | struct device_attribute *attr, |
| 429 | const char *buf, size_t count) |
| 430 | { |
Jordan Crouse | 2ddfc8a | 2012-11-27 11:33:06 -0700 | [diff] [blame] | 431 | struct kgsl_device *device = kgsl_device_from_dev(dev); |
| 432 | struct kgsl_pwrctrl *pwr; |
| 433 | unsigned long val; |
| 434 | int ret, level; |
| 435 | |
| 436 | if (device == NULL) |
| 437 | return 0; |
| 438 | |
| 439 | pwr = &device->pwrctrl; |
| 440 | |
| 441 | ret = sscanf(buf, "%ld", &val); |
| 442 | if (ret != 1) |
| 443 | return count; |
| 444 | |
| 445 | mutex_lock(&device->mutex); |
| 446 | level = _get_nearest_pwrlevel(pwr, val); |
| 447 | if (level >= 0) |
| 448 | kgsl_pwrctrl_pwrlevel_change(device, level); |
| 449 | |
| 450 | mutex_unlock(&device->mutex); |
| 451 | return count; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 452 | } |
| 453 | |
| 454 | static int kgsl_pwrctrl_gpuclk_show(struct device *dev, |
| 455 | struct device_attribute *attr, |
| 456 | char *buf) |
| 457 | { |
| 458 | struct kgsl_device *device = kgsl_device_from_dev(dev); |
Jordan Crouse | 6c2992a | 2011-08-08 17:00:06 -0600 | [diff] [blame] | 459 | struct kgsl_pwrctrl *pwr; |
| 460 | if (device == NULL) |
| 461 | return 0; |
| 462 | pwr = &device->pwrctrl; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 463 | return snprintf(buf, PAGE_SIZE, "%d\n", |
| 464 | pwr->pwrlevels[pwr->active_pwrlevel].gpu_freq); |
| 465 | } |
| 466 | |
| 467 | static int kgsl_pwrctrl_pwrnap_store(struct device *dev, |
| 468 | struct device_attribute *attr, |
| 469 | const char *buf, size_t count) |
| 470 | { |
| 471 | char temp[20]; |
| 472 | unsigned long val; |
| 473 | struct kgsl_device *device = kgsl_device_from_dev(dev); |
Jordan Crouse | 6c2992a | 2011-08-08 17:00:06 -0600 | [diff] [blame] | 474 | struct kgsl_pwrctrl *pwr; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 475 | int rc; |
| 476 | |
Jordan Crouse | 6c2992a | 2011-08-08 17:00:06 -0600 | [diff] [blame] | 477 | if (device == NULL) |
| 478 | return 0; |
| 479 | pwr = &device->pwrctrl; |
| 480 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 481 | snprintf(temp, sizeof(temp), "%.*s", |
| 482 | (int)min(count, sizeof(temp) - 1), buf); |
| 483 | rc = strict_strtoul(temp, 0, &val); |
| 484 | if (rc) |
| 485 | return rc; |
| 486 | |
| 487 | mutex_lock(&device->mutex); |
| 488 | |
| 489 | if (val == 1) |
| 490 | pwr->nap_allowed = true; |
| 491 | else if (val == 0) |
| 492 | pwr->nap_allowed = false; |
| 493 | |
| 494 | mutex_unlock(&device->mutex); |
| 495 | |
| 496 | return count; |
| 497 | } |
| 498 | |
| 499 | static int kgsl_pwrctrl_pwrnap_show(struct device *dev, |
| 500 | struct device_attribute *attr, |
| 501 | char *buf) |
| 502 | { |
| 503 | struct kgsl_device *device = kgsl_device_from_dev(dev); |
Jordan Crouse | 6c2992a | 2011-08-08 17:00:06 -0600 | [diff] [blame] | 504 | if (device == NULL) |
| 505 | return 0; |
| 506 | return snprintf(buf, PAGE_SIZE, "%d\n", device->pwrctrl.nap_allowed); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 507 | } |
| 508 | |
| 509 | |
| 510 | static int kgsl_pwrctrl_idle_timer_store(struct device *dev, |
| 511 | struct device_attribute *attr, |
| 512 | const char *buf, size_t count) |
| 513 | { |
| 514 | char temp[20]; |
| 515 | unsigned long val; |
| 516 | struct kgsl_device *device = kgsl_device_from_dev(dev); |
Jordan Crouse | 6c2992a | 2011-08-08 17:00:06 -0600 | [diff] [blame] | 517 | struct kgsl_pwrctrl *pwr; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 518 | const long div = 1000/HZ; |
| 519 | static unsigned int org_interval_timeout = 1; |
| 520 | int rc; |
| 521 | |
Jordan Crouse | 6c2992a | 2011-08-08 17:00:06 -0600 | [diff] [blame] | 522 | if (device == NULL) |
| 523 | return 0; |
| 524 | pwr = &device->pwrctrl; |
| 525 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 526 | snprintf(temp, sizeof(temp), "%.*s", |
| 527 | (int)min(count, sizeof(temp) - 1), buf); |
| 528 | rc = strict_strtoul(temp, 0, &val); |
| 529 | if (rc) |
| 530 | return rc; |
| 531 | |
| 532 | if (org_interval_timeout == 1) |
| 533 | org_interval_timeout = pwr->interval_timeout; |
| 534 | |
| 535 | mutex_lock(&device->mutex); |
| 536 | |
| 537 | /* Let the timeout be requested in ms, but convert to jiffies. */ |
| 538 | val /= div; |
| 539 | if (val >= org_interval_timeout) |
| 540 | pwr->interval_timeout = val; |
| 541 | |
| 542 | mutex_unlock(&device->mutex); |
| 543 | |
| 544 | return count; |
| 545 | } |
| 546 | |
| 547 | static int kgsl_pwrctrl_idle_timer_show(struct device *dev, |
| 548 | struct device_attribute *attr, |
| 549 | char *buf) |
| 550 | { |
| 551 | struct kgsl_device *device = kgsl_device_from_dev(dev); |
Jordan Crouse | 6c2992a | 2011-08-08 17:00:06 -0600 | [diff] [blame] | 552 | if (device == NULL) |
| 553 | return 0; |
| 554 | return snprintf(buf, PAGE_SIZE, "%d\n", |
| 555 | device->pwrctrl.interval_timeout); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 556 | } |
| 557 | |
Suman Tatiraju | 7fe62a3 | 2011-07-14 16:40:37 -0700 | [diff] [blame] | 558 | static int kgsl_pwrctrl_gpubusy_show(struct device *dev, |
| 559 | struct device_attribute *attr, |
| 560 | char *buf) |
| 561 | { |
| 562 | int ret; |
| 563 | struct kgsl_device *device = kgsl_device_from_dev(dev); |
Suman Tatiraju | 2bdd056 | 2012-01-26 14:49:46 -0800 | [diff] [blame] | 564 | struct kgsl_clk_stats *clkstats = &device->pwrctrl.clk_stats; |
| 565 | ret = snprintf(buf, PAGE_SIZE, "%7d %7d\n", |
| 566 | clkstats->on_time_old, clkstats->elapsed_old); |
Suman Tatiraju | 7fe62a3 | 2011-07-14 16:40:37 -0700 | [diff] [blame] | 567 | if (!test_bit(KGSL_PWRFLAGS_AXI_ON, &device->pwrctrl.power_flags)) { |
Suman Tatiraju | 2bdd056 | 2012-01-26 14:49:46 -0800 | [diff] [blame] | 568 | clkstats->on_time_old = 0; |
| 569 | clkstats->elapsed_old = 0; |
Suman Tatiraju | 7fe62a3 | 2011-07-14 16:40:37 -0700 | [diff] [blame] | 570 | } |
| 571 | return ret; |
| 572 | } |
| 573 | |
Suman Tatiraju | 2bdd056 | 2012-01-26 14:49:46 -0800 | [diff] [blame] | 574 | static int kgsl_pwrctrl_gputop_show(struct device *dev, |
| 575 | struct device_attribute *attr, |
| 576 | char *buf) |
| 577 | { |
| 578 | int ret; |
| 579 | struct kgsl_device *device = kgsl_device_from_dev(dev); |
| 580 | struct kgsl_clk_stats *clkstats = &device->pwrctrl.clk_stats; |
| 581 | int i = 0; |
| 582 | char *ptr = buf; |
| 583 | |
| 584 | ret = snprintf(buf, PAGE_SIZE, "%7d %7d ", clkstats->on_time_old, |
| 585 | clkstats->elapsed_old); |
| 586 | for (i = 0, ptr += ret; i < device->pwrctrl.num_pwrlevels; |
| 587 | i++, ptr += ret) |
| 588 | ret = snprintf(ptr, PAGE_SIZE, "%7d ", |
| 589 | clkstats->old_clock_time[i]); |
| 590 | |
| 591 | if (!test_bit(KGSL_PWRFLAGS_AXI_ON, &device->pwrctrl.power_flags)) { |
| 592 | clkstats->on_time_old = 0; |
| 593 | clkstats->elapsed_old = 0; |
| 594 | for (i = 0; i < KGSL_MAX_PWRLEVELS ; i++) |
| 595 | clkstats->old_clock_time[i] = 0; |
| 596 | } |
| 597 | return (unsigned int) (ptr - buf); |
| 598 | } |
| 599 | |
Anshuman Dani | 91ede1e | 2012-08-21 14:44:38 +0530 | [diff] [blame] | 600 | static int kgsl_pwrctrl_gpu_available_frequencies_show( |
| 601 | struct device *dev, |
| 602 | struct device_attribute *attr, |
| 603 | char *buf) |
| 604 | { |
| 605 | struct kgsl_device *device = kgsl_device_from_dev(dev); |
| 606 | struct kgsl_pwrctrl *pwr; |
| 607 | int index, num_chars = 0; |
| 608 | |
| 609 | if (device == NULL) |
| 610 | return 0; |
| 611 | pwr = &device->pwrctrl; |
| 612 | for (index = 0; index < pwr->num_pwrlevels - 1; index++) |
| 613 | num_chars += snprintf(buf + num_chars, PAGE_SIZE, "%d ", |
| 614 | pwr->pwrlevels[index].gpu_freq); |
| 615 | buf[num_chars++] = '\n'; |
| 616 | return num_chars; |
| 617 | } |
| 618 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 619 | DEVICE_ATTR(gpuclk, 0644, kgsl_pwrctrl_gpuclk_show, kgsl_pwrctrl_gpuclk_store); |
| 620 | DEVICE_ATTR(max_gpuclk, 0644, kgsl_pwrctrl_max_gpuclk_show, |
| 621 | kgsl_pwrctrl_max_gpuclk_store); |
Praveena Pachipulusu | 263467d | 2011-12-22 18:07:16 +0530 | [diff] [blame] | 622 | DEVICE_ATTR(pwrnap, 0664, kgsl_pwrctrl_pwrnap_show, kgsl_pwrctrl_pwrnap_store); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 623 | DEVICE_ATTR(idle_timer, 0644, kgsl_pwrctrl_idle_timer_show, |
| 624 | kgsl_pwrctrl_idle_timer_store); |
Suman Tatiraju | 2bdd056 | 2012-01-26 14:49:46 -0800 | [diff] [blame] | 625 | DEVICE_ATTR(gpubusy, 0444, kgsl_pwrctrl_gpubusy_show, |
| 626 | NULL); |
| 627 | DEVICE_ATTR(gputop, 0444, kgsl_pwrctrl_gputop_show, |
Suman Tatiraju | 7fe62a3 | 2011-07-14 16:40:37 -0700 | [diff] [blame] | 628 | NULL); |
Anshuman Dani | 91ede1e | 2012-08-21 14:44:38 +0530 | [diff] [blame] | 629 | DEVICE_ATTR(gpu_available_frequencies, 0444, |
| 630 | kgsl_pwrctrl_gpu_available_frequencies_show, |
| 631 | NULL); |
Jordan Crouse | 2ddfc8a | 2012-11-27 11:33:06 -0700 | [diff] [blame] | 632 | DEVICE_ATTR(max_pwrlevel, 0644, |
| 633 | kgsl_pwrctrl_max_pwrlevel_show, |
| 634 | kgsl_pwrctrl_max_pwrlevel_store); |
| 635 | DEVICE_ATTR(min_pwrlevel, 0644, |
| 636 | kgsl_pwrctrl_min_pwrlevel_show, |
| 637 | kgsl_pwrctrl_min_pwrlevel_store); |
| 638 | DEVICE_ATTR(thermal_pwrlevel, 0644, |
| 639 | kgsl_pwrctrl_thermal_pwrlevel_show, |
| 640 | kgsl_pwrctrl_thermal_pwrlevel_store); |
| 641 | DEVICE_ATTR(num_pwrlevels, 0444, |
| 642 | kgsl_pwrctrl_num_pwrlevels_show, |
| 643 | NULL); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 644 | |
| 645 | static const struct device_attribute *pwrctrl_attr_list[] = { |
| 646 | &dev_attr_gpuclk, |
| 647 | &dev_attr_max_gpuclk, |
| 648 | &dev_attr_pwrnap, |
| 649 | &dev_attr_idle_timer, |
Suman Tatiraju | 7fe62a3 | 2011-07-14 16:40:37 -0700 | [diff] [blame] | 650 | &dev_attr_gpubusy, |
Suman Tatiraju | 2bdd056 | 2012-01-26 14:49:46 -0800 | [diff] [blame] | 651 | &dev_attr_gputop, |
Anshuman Dani | 91ede1e | 2012-08-21 14:44:38 +0530 | [diff] [blame] | 652 | &dev_attr_gpu_available_frequencies, |
Jordan Crouse | 2ddfc8a | 2012-11-27 11:33:06 -0700 | [diff] [blame] | 653 | &dev_attr_max_pwrlevel, |
| 654 | &dev_attr_min_pwrlevel, |
| 655 | &dev_attr_thermal_pwrlevel, |
| 656 | &dev_attr_num_pwrlevels, |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 657 | NULL |
| 658 | }; |
| 659 | |
| 660 | int kgsl_pwrctrl_init_sysfs(struct kgsl_device *device) |
| 661 | { |
| 662 | return kgsl_create_device_sysfs_files(device->dev, pwrctrl_attr_list); |
| 663 | } |
| 664 | |
| 665 | void kgsl_pwrctrl_uninit_sysfs(struct kgsl_device *device) |
| 666 | { |
| 667 | kgsl_remove_device_sysfs_files(device->dev, pwrctrl_attr_list); |
| 668 | } |
| 669 | |
Suman Tatiraju | 2bdd056 | 2012-01-26 14:49:46 -0800 | [diff] [blame] | 670 | static void update_statistics(struct kgsl_device *device) |
| 671 | { |
| 672 | struct kgsl_clk_stats *clkstats = &device->pwrctrl.clk_stats; |
| 673 | unsigned int on_time = 0; |
| 674 | int i; |
| 675 | int num_pwrlevels = device->pwrctrl.num_pwrlevels - 1; |
| 676 | /*PER CLK TIME*/ |
| 677 | for (i = 0; i < num_pwrlevels; i++) { |
| 678 | clkstats->old_clock_time[i] = clkstats->clock_time[i]; |
| 679 | on_time += clkstats->clock_time[i]; |
| 680 | clkstats->clock_time[i] = 0; |
| 681 | } |
| 682 | clkstats->old_clock_time[num_pwrlevels] = |
| 683 | clkstats->clock_time[num_pwrlevels]; |
| 684 | clkstats->clock_time[num_pwrlevels] = 0; |
| 685 | clkstats->on_time_old = on_time; |
| 686 | clkstats->elapsed_old = clkstats->elapsed; |
| 687 | clkstats->elapsed = 0; |
| 688 | } |
| 689 | |
Suman Tatiraju | 7fe62a3 | 2011-07-14 16:40:37 -0700 | [diff] [blame] | 690 | /* Track the amount of time the gpu is on vs the total system time. * |
| 691 | * Regularly update the percentage of busy time displayed by sysfs. */ |
| 692 | static void kgsl_pwrctrl_busy_time(struct kgsl_device *device, bool on_time) |
| 693 | { |
Suman Tatiraju | 2bdd056 | 2012-01-26 14:49:46 -0800 | [diff] [blame] | 694 | struct kgsl_clk_stats *clkstats = &device->pwrctrl.clk_stats; |
| 695 | update_clk_statistics(device, on_time); |
Suman Tatiraju | 7fe62a3 | 2011-07-14 16:40:37 -0700 | [diff] [blame] | 696 | /* Update the output regularly and reset the counters. */ |
Suman Tatiraju | 2bdd056 | 2012-01-26 14:49:46 -0800 | [diff] [blame] | 697 | if ((clkstats->elapsed > UPDATE_BUSY_VAL) || |
Suman Tatiraju | 7fe62a3 | 2011-07-14 16:40:37 -0700 | [diff] [blame] | 698 | !test_bit(KGSL_PWRFLAGS_AXI_ON, &device->pwrctrl.power_flags)) { |
Suman Tatiraju | 2bdd056 | 2012-01-26 14:49:46 -0800 | [diff] [blame] | 699 | update_statistics(device); |
Suman Tatiraju | 7fe62a3 | 2011-07-14 16:40:37 -0700 | [diff] [blame] | 700 | } |
Suman Tatiraju | 7fe62a3 | 2011-07-14 16:40:37 -0700 | [diff] [blame] | 701 | } |
| 702 | |
Lucille Sylvester | e4a7c1a | 2012-04-11 12:17:38 -0600 | [diff] [blame] | 703 | void kgsl_pwrctrl_clk(struct kgsl_device *device, int state, |
| 704 | int requested_state) |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 705 | { |
| 706 | struct kgsl_pwrctrl *pwr = &device->pwrctrl; |
| 707 | int i = 0; |
| 708 | if (state == KGSL_PWRFLAGS_OFF) { |
| 709 | if (test_and_clear_bit(KGSL_PWRFLAGS_CLK_ON, |
| 710 | &pwr->power_flags)) { |
Jeremy Gebben | b50f331 | 2011-12-16 08:58:33 -0700 | [diff] [blame] | 711 | trace_kgsl_clk(device, state); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 712 | for (i = KGSL_MAX_CLKS - 1; i > 0; i--) |
| 713 | if (pwr->grp_clks[i]) |
| 714 | clk_disable(pwr->grp_clks[i]); |
Lucille Sylvester | 5b7e57b | 2012-01-19 17:18:40 -0700 | [diff] [blame] | 715 | /* High latency clock maintenance. */ |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 716 | if ((pwr->pwrlevels[0].gpu_freq > 0) && |
Lucille Sylvester | 5b7e57b | 2012-01-19 17:18:40 -0700 | [diff] [blame] | 717 | (requested_state != KGSL_STATE_NAP)) { |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 718 | clk_set_rate(pwr->grp_clks[0], |
| 719 | pwr->pwrlevels[pwr->num_pwrlevels - 1]. |
| 720 | gpu_freq); |
Lucille Sylvester | 5b7e57b | 2012-01-19 17:18:40 -0700 | [diff] [blame] | 721 | for (i = KGSL_MAX_CLKS - 1; i > 0; i--) |
| 722 | if (pwr->grp_clks[i]) |
| 723 | clk_unprepare(pwr->grp_clks[i]); |
| 724 | } |
Suman Tatiraju | 7fe62a3 | 2011-07-14 16:40:37 -0700 | [diff] [blame] | 725 | kgsl_pwrctrl_busy_time(device, true); |
Suman Tatiraju | 426da0d | 2012-09-11 13:03:28 -0700 | [diff] [blame] | 726 | } else if (requested_state == KGSL_STATE_SLEEP) { |
| 727 | /* High latency clock maintenance. */ |
| 728 | if ((pwr->pwrlevels[0].gpu_freq > 0)) |
| 729 | clk_set_rate(pwr->grp_clks[0], |
| 730 | pwr->pwrlevels[pwr->num_pwrlevels - 1]. |
| 731 | gpu_freq); |
| 732 | for (i = KGSL_MAX_CLKS - 1; i > 0; i--) |
| 733 | if (pwr->grp_clks[i]) |
| 734 | clk_unprepare(pwr->grp_clks[i]); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 735 | } |
| 736 | } else if (state == KGSL_PWRFLAGS_ON) { |
| 737 | if (!test_and_set_bit(KGSL_PWRFLAGS_CLK_ON, |
| 738 | &pwr->power_flags)) { |
Jeremy Gebben | b50f331 | 2011-12-16 08:58:33 -0700 | [diff] [blame] | 739 | trace_kgsl_clk(device, state); |
Lucille Sylvester | 5b7e57b | 2012-01-19 17:18:40 -0700 | [diff] [blame] | 740 | /* High latency clock maintenance. */ |
Ranjhith Kalisamy | c940699 | 2012-08-10 16:40:36 +0530 | [diff] [blame] | 741 | if (device->state != KGSL_STATE_NAP) { |
Lucille Sylvester | 5b7e57b | 2012-01-19 17:18:40 -0700 | [diff] [blame] | 742 | for (i = KGSL_MAX_CLKS - 1; i > 0; i--) |
| 743 | if (pwr->grp_clks[i]) |
| 744 | clk_prepare(pwr->grp_clks[i]); |
Ranjhith Kalisamy | c940699 | 2012-08-10 16:40:36 +0530 | [diff] [blame] | 745 | |
| 746 | if (pwr->pwrlevels[0].gpu_freq > 0) |
| 747 | clk_set_rate(pwr->grp_clks[0], |
| 748 | pwr->pwrlevels |
| 749 | [pwr->active_pwrlevel]. |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 750 | gpu_freq); |
Lucille Sylvester | 5b7e57b | 2012-01-19 17:18:40 -0700 | [diff] [blame] | 751 | } |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 752 | /* as last step, enable grp_clk |
| 753 | this is to let GPU interrupt to come */ |
| 754 | for (i = KGSL_MAX_CLKS - 1; i > 0; i--) |
| 755 | if (pwr->grp_clks[i]) |
| 756 | clk_enable(pwr->grp_clks[i]); |
Suman Tatiraju | 7fe62a3 | 2011-07-14 16:40:37 -0700 | [diff] [blame] | 757 | kgsl_pwrctrl_busy_time(device, false); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 758 | } |
| 759 | } |
| 760 | } |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 761 | |
| 762 | void kgsl_pwrctrl_axi(struct kgsl_device *device, int state) |
| 763 | { |
| 764 | struct kgsl_pwrctrl *pwr = &device->pwrctrl; |
| 765 | |
| 766 | if (state == KGSL_PWRFLAGS_OFF) { |
| 767 | if (test_and_clear_bit(KGSL_PWRFLAGS_AXI_ON, |
| 768 | &pwr->power_flags)) { |
Jeremy Gebben | b50f331 | 2011-12-16 08:58:33 -0700 | [diff] [blame] | 769 | trace_kgsl_bus(device, state); |
Lynus Vaz | 5a641cc | 2011-09-15 14:43:40 +0530 | [diff] [blame] | 770 | if (pwr->ebi1_clk) { |
| 771 | clk_set_rate(pwr->ebi1_clk, 0); |
Lucille Sylvester | 064d598 | 2012-05-08 15:42:43 -0600 | [diff] [blame] | 772 | clk_disable_unprepare(pwr->ebi1_clk); |
Lynus Vaz | 5a641cc | 2011-09-15 14:43:40 +0530 | [diff] [blame] | 773 | } |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 774 | if (pwr->pcl) |
| 775 | msm_bus_scale_client_update_request(pwr->pcl, |
| 776 | 0); |
| 777 | } |
| 778 | } else if (state == KGSL_PWRFLAGS_ON) { |
| 779 | if (!test_and_set_bit(KGSL_PWRFLAGS_AXI_ON, |
| 780 | &pwr->power_flags)) { |
Jeremy Gebben | b50f331 | 2011-12-16 08:58:33 -0700 | [diff] [blame] | 781 | trace_kgsl_bus(device, state); |
Lynus Vaz | 5a641cc | 2011-09-15 14:43:40 +0530 | [diff] [blame] | 782 | if (pwr->ebi1_clk) { |
Lucille Sylvester | 064d598 | 2012-05-08 15:42:43 -0600 | [diff] [blame] | 783 | clk_prepare_enable(pwr->ebi1_clk); |
Lynus Vaz | 5a641cc | 2011-09-15 14:43:40 +0530 | [diff] [blame] | 784 | clk_set_rate(pwr->ebi1_clk, |
| 785 | pwr->pwrlevels[pwr->active_pwrlevel]. |
| 786 | bus_freq); |
| 787 | } |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 788 | if (pwr->pcl) |
| 789 | msm_bus_scale_client_update_request(pwr->pcl, |
| 790 | pwr->pwrlevels[pwr->active_pwrlevel]. |
| 791 | bus_freq); |
| 792 | } |
| 793 | } |
| 794 | } |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 795 | |
| 796 | void kgsl_pwrctrl_pwrrail(struct kgsl_device *device, int state) |
| 797 | { |
| 798 | struct kgsl_pwrctrl *pwr = &device->pwrctrl; |
| 799 | |
| 800 | if (state == KGSL_PWRFLAGS_OFF) { |
| 801 | if (test_and_clear_bit(KGSL_PWRFLAGS_POWER_ON, |
| 802 | &pwr->power_flags)) { |
Jeremy Gebben | b50f331 | 2011-12-16 08:58:33 -0700 | [diff] [blame] | 803 | trace_kgsl_rail(device, state); |
Pu Chen | 1205378 | 2012-07-24 17:04:27 -0700 | [diff] [blame] | 804 | if (pwr->gpu_cx) |
| 805 | regulator_disable(pwr->gpu_cx); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 806 | if (pwr->gpu_reg) |
| 807 | regulator_disable(pwr->gpu_reg); |
| 808 | } |
| 809 | } else if (state == KGSL_PWRFLAGS_ON) { |
| 810 | if (!test_and_set_bit(KGSL_PWRFLAGS_POWER_ON, |
| 811 | &pwr->power_flags)) { |
Jeremy Gebben | b50f331 | 2011-12-16 08:58:33 -0700 | [diff] [blame] | 812 | trace_kgsl_rail(device, state); |
Shubhraprakash Das | e86ba5c | 2012-04-04 18:03:27 -0600 | [diff] [blame] | 813 | if (pwr->gpu_reg) { |
| 814 | int status = regulator_enable(pwr->gpu_reg); |
| 815 | if (status) |
Pu Chen | fe0dd3a | 2012-06-01 14:39:08 -0700 | [diff] [blame] | 816 | KGSL_DRV_ERR(device, |
| 817 | "core regulator_enable " |
| 818 | "failed: %d\n", |
| 819 | status); |
| 820 | } |
Pu Chen | 1205378 | 2012-07-24 17:04:27 -0700 | [diff] [blame] | 821 | if (pwr->gpu_cx) { |
| 822 | int status = regulator_enable(pwr->gpu_cx); |
Pu Chen | fe0dd3a | 2012-06-01 14:39:08 -0700 | [diff] [blame] | 823 | if (status) |
| 824 | KGSL_DRV_ERR(device, |
| 825 | "cx regulator_enable " |
| 826 | "failed: %d\n", |
| 827 | status); |
Shubhraprakash Das | e86ba5c | 2012-04-04 18:03:27 -0600 | [diff] [blame] | 828 | } |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 829 | } |
| 830 | } |
| 831 | } |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 832 | |
| 833 | void kgsl_pwrctrl_irq(struct kgsl_device *device, int state) |
| 834 | { |
| 835 | struct kgsl_pwrctrl *pwr = &device->pwrctrl; |
| 836 | |
| 837 | if (state == KGSL_PWRFLAGS_ON) { |
| 838 | if (!test_and_set_bit(KGSL_PWRFLAGS_IRQ_ON, |
| 839 | &pwr->power_flags)) { |
Jeremy Gebben | b50f331 | 2011-12-16 08:58:33 -0700 | [diff] [blame] | 840 | trace_kgsl_irq(device, state); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 841 | enable_irq(pwr->interrupt_num); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 842 | } |
| 843 | } else if (state == KGSL_PWRFLAGS_OFF) { |
| 844 | if (test_and_clear_bit(KGSL_PWRFLAGS_IRQ_ON, |
| 845 | &pwr->power_flags)) { |
Jeremy Gebben | b50f331 | 2011-12-16 08:58:33 -0700 | [diff] [blame] | 846 | trace_kgsl_irq(device, state); |
Jordan Crouse | b58e61b | 2011-08-08 13:25:36 -0600 | [diff] [blame] | 847 | if (in_interrupt()) |
| 848 | disable_irq_nosync(pwr->interrupt_num); |
| 849 | else |
| 850 | disable_irq(pwr->interrupt_num); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 851 | } |
| 852 | } |
| 853 | } |
| 854 | EXPORT_SYMBOL(kgsl_pwrctrl_irq); |
| 855 | |
| 856 | int kgsl_pwrctrl_init(struct kgsl_device *device) |
| 857 | { |
| 858 | int i, result = 0; |
| 859 | struct clk *clk; |
| 860 | struct platform_device *pdev = |
| 861 | container_of(device->parentdev, struct platform_device, dev); |
| 862 | struct kgsl_pwrctrl *pwr = &device->pwrctrl; |
Lucille Sylvester | dce84cd | 2011-10-12 14:15:37 -0600 | [diff] [blame] | 863 | struct kgsl_device_platform_data *pdata = pdev->dev.platform_data; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 864 | |
| 865 | /*acquire clocks */ |
Lucille Sylvester | dce84cd | 2011-10-12 14:15:37 -0600 | [diff] [blame] | 866 | for (i = 0; i < KGSL_MAX_CLKS; i++) { |
| 867 | if (pdata->clk_map & clks[i].map) { |
| 868 | clk = clk_get(&pdev->dev, clks[i].name); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 869 | if (IS_ERR(clk)) |
| 870 | goto clk_err; |
| 871 | pwr->grp_clks[i] = clk; |
| 872 | } |
| 873 | } |
| 874 | /* Make sure we have a source clk for freq setting */ |
Lucille Sylvester | dce84cd | 2011-10-12 14:15:37 -0600 | [diff] [blame] | 875 | if (pwr->grp_clks[0] == NULL) |
| 876 | pwr->grp_clks[0] = pwr->grp_clks[1]; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 877 | |
| 878 | /* put the AXI bus into asynchronous mode with the graphics cores */ |
Lucille Sylvester | dce84cd | 2011-10-12 14:15:37 -0600 | [diff] [blame] | 879 | if (pdata->set_grp_async != NULL) |
| 880 | pdata->set_grp_async(); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 881 | |
Lucille Sylvester | d260c88 | 2013-05-28 16:59:46 -0600 | [diff] [blame] | 882 | if (pdata->num_levels > KGSL_MAX_PWRLEVELS || |
| 883 | pdata->num_levels < 1) { |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 884 | KGSL_PWR_ERR(device, "invalid power level count: %d\n", |
Lucille Sylvester | dce84cd | 2011-10-12 14:15:37 -0600 | [diff] [blame] | 885 | pdata->num_levels); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 886 | result = -EINVAL; |
| 887 | goto done; |
| 888 | } |
Lucille Sylvester | dce84cd | 2011-10-12 14:15:37 -0600 | [diff] [blame] | 889 | pwr->num_pwrlevels = pdata->num_levels; |
Jordan Crouse | 2ddfc8a | 2012-11-27 11:33:06 -0700 | [diff] [blame] | 890 | |
| 891 | /* Initialize the user and thermal clock constraints */ |
| 892 | |
| 893 | pwr->max_pwrlevel = 0; |
| 894 | pwr->min_pwrlevel = pdata->num_levels - 2; |
| 895 | pwr->thermal_pwrlevel = 0; |
| 896 | |
Lucille Sylvester | dce84cd | 2011-10-12 14:15:37 -0600 | [diff] [blame] | 897 | pwr->active_pwrlevel = pdata->init_level; |
Lucille Sylvester | 67b4c53 | 2012-02-08 11:24:31 -0800 | [diff] [blame] | 898 | pwr->default_pwrlevel = pdata->init_level; |
Lucille Sylvester | dce84cd | 2011-10-12 14:15:37 -0600 | [diff] [blame] | 899 | for (i = 0; i < pdata->num_levels; i++) { |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 900 | pwr->pwrlevels[i].gpu_freq = |
Lucille Sylvester | dce84cd | 2011-10-12 14:15:37 -0600 | [diff] [blame] | 901 | (pdata->pwrlevel[i].gpu_freq > 0) ? |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 902 | clk_round_rate(pwr->grp_clks[0], |
Lucille Sylvester | dce84cd | 2011-10-12 14:15:37 -0600 | [diff] [blame] | 903 | pdata->pwrlevel[i]. |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 904 | gpu_freq) : 0; |
| 905 | pwr->pwrlevels[i].bus_freq = |
Lucille Sylvester | dce84cd | 2011-10-12 14:15:37 -0600 | [diff] [blame] | 906 | pdata->pwrlevel[i].bus_freq; |
Lucille Sylvester | 596d4c2 | 2011-10-19 18:04:01 -0600 | [diff] [blame] | 907 | pwr->pwrlevels[i].io_fraction = |
Lucille Sylvester | dce84cd | 2011-10-12 14:15:37 -0600 | [diff] [blame] | 908 | pdata->pwrlevel[i].io_fraction; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 909 | } |
| 910 | /* Do not set_rate for targets in sync with AXI */ |
| 911 | if (pwr->pwrlevels[0].gpu_freq > 0) |
| 912 | clk_set_rate(pwr->grp_clks[0], pwr-> |
| 913 | pwrlevels[pwr->num_pwrlevels - 1].gpu_freq); |
| 914 | |
Matt Wagantall | d6fbf23 | 2012-05-03 20:09:28 -0700 | [diff] [blame] | 915 | pwr->gpu_reg = regulator_get(&pdev->dev, "vdd"); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 916 | if (IS_ERR(pwr->gpu_reg)) |
| 917 | pwr->gpu_reg = NULL; |
| 918 | |
Pu Chen | fe0dd3a | 2012-06-01 14:39:08 -0700 | [diff] [blame] | 919 | if (pwr->gpu_reg) { |
Pu Chen | 1205378 | 2012-07-24 17:04:27 -0700 | [diff] [blame] | 920 | pwr->gpu_cx = regulator_get(&pdev->dev, "vddcx"); |
| 921 | if (IS_ERR(pwr->gpu_cx)) |
| 922 | pwr->gpu_cx = NULL; |
Pu Chen | fe0dd3a | 2012-06-01 14:39:08 -0700 | [diff] [blame] | 923 | } else |
Pu Chen | 1205378 | 2012-07-24 17:04:27 -0700 | [diff] [blame] | 924 | pwr->gpu_cx = NULL; |
Pu Chen | fe0dd3a | 2012-06-01 14:39:08 -0700 | [diff] [blame] | 925 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 926 | pwr->power_flags = 0; |
| 927 | |
Lucille Sylvester | dce84cd | 2011-10-12 14:15:37 -0600 | [diff] [blame] | 928 | pwr->nap_allowed = pdata->nap_allowed; |
Kedar Joshi | c11d098 | 2012-02-07 10:59:49 +0530 | [diff] [blame] | 929 | pwr->idle_needed = pdata->idle_needed; |
Lucille Sylvester | dce84cd | 2011-10-12 14:15:37 -0600 | [diff] [blame] | 930 | pwr->interval_timeout = pdata->idle_timeout; |
Lynus Vaz | fe4bede | 2012-04-06 11:53:30 -0700 | [diff] [blame] | 931 | pwr->strtstp_sleepwake = pdata->strtstp_sleepwake; |
Matt Wagantall | 9dc0163 | 2011-08-17 18:55:04 -0700 | [diff] [blame] | 932 | pwr->ebi1_clk = clk_get(&pdev->dev, "bus_clk"); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 933 | if (IS_ERR(pwr->ebi1_clk)) |
| 934 | pwr->ebi1_clk = NULL; |
| 935 | else |
| 936 | clk_set_rate(pwr->ebi1_clk, |
| 937 | pwr->pwrlevels[pwr->active_pwrlevel]. |
| 938 | bus_freq); |
Lucille Sylvester | dce84cd | 2011-10-12 14:15:37 -0600 | [diff] [blame] | 939 | if (pdata->bus_scale_table != NULL) { |
| 940 | pwr->pcl = msm_bus_scale_register_client(pdata-> |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 941 | bus_scale_table); |
| 942 | if (!pwr->pcl) { |
| 943 | KGSL_PWR_ERR(device, |
| 944 | "msm_bus_scale_register_client failed: " |
| 945 | "id %d table %p", device->id, |
Lucille Sylvester | dce84cd | 2011-10-12 14:15:37 -0600 | [diff] [blame] | 946 | pdata->bus_scale_table); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 947 | result = -EINVAL; |
| 948 | goto done; |
| 949 | } |
| 950 | } |
| 951 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 952 | |
Jeremy Gebben | 4f5f0de | 2012-03-01 15:51:37 -0700 | [diff] [blame] | 953 | pm_runtime_enable(device->parentdev); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 954 | register_early_suspend(&device->display_off); |
| 955 | return result; |
| 956 | |
| 957 | clk_err: |
| 958 | result = PTR_ERR(clk); |
| 959 | KGSL_PWR_ERR(device, "clk_get(%s) failed: %d\n", |
Lucille Sylvester | dce84cd | 2011-10-12 14:15:37 -0600 | [diff] [blame] | 960 | clks[i].name, result); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 961 | |
| 962 | done: |
| 963 | return result; |
| 964 | } |
| 965 | |
| 966 | void kgsl_pwrctrl_close(struct kgsl_device *device) |
| 967 | { |
| 968 | struct kgsl_pwrctrl *pwr = &device->pwrctrl; |
| 969 | int i; |
| 970 | |
| 971 | KGSL_PWR_INFO(device, "close device %d\n", device->id); |
| 972 | |
Jeremy Gebben | 4f5f0de | 2012-03-01 15:51:37 -0700 | [diff] [blame] | 973 | pm_runtime_disable(device->parentdev); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 974 | unregister_early_suspend(&device->display_off); |
| 975 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 976 | clk_put(pwr->ebi1_clk); |
| 977 | |
| 978 | if (pwr->pcl) |
| 979 | msm_bus_scale_unregister_client(pwr->pcl); |
| 980 | |
| 981 | pwr->pcl = 0; |
| 982 | |
| 983 | if (pwr->gpu_reg) { |
| 984 | regulator_put(pwr->gpu_reg); |
| 985 | pwr->gpu_reg = NULL; |
| 986 | } |
| 987 | |
Pu Chen | 1205378 | 2012-07-24 17:04:27 -0700 | [diff] [blame] | 988 | if (pwr->gpu_cx) { |
| 989 | regulator_put(pwr->gpu_cx); |
| 990 | pwr->gpu_cx = NULL; |
Pu Chen | fe0dd3a | 2012-06-01 14:39:08 -0700 | [diff] [blame] | 991 | } |
| 992 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 993 | for (i = 1; i < KGSL_MAX_CLKS; i++) |
| 994 | if (pwr->grp_clks[i]) { |
| 995 | clk_put(pwr->grp_clks[i]); |
| 996 | pwr->grp_clks[i] = NULL; |
| 997 | } |
| 998 | |
| 999 | pwr->grp_clks[0] = NULL; |
| 1000 | pwr->power_flags = 0; |
| 1001 | } |
| 1002 | |
| 1003 | void kgsl_idle_check(struct work_struct *work) |
| 1004 | { |
| 1005 | struct kgsl_device *device = container_of(work, struct kgsl_device, |
| 1006 | idle_check_ws); |
Jeremy Gebben | 388c297 | 2011-12-16 09:05:07 -0700 | [diff] [blame] | 1007 | WARN_ON(device == NULL); |
| 1008 | if (device == NULL) |
| 1009 | return; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1010 | |
| 1011 | mutex_lock(&device->mutex); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1012 | if (device->state & (KGSL_STATE_ACTIVE | KGSL_STATE_NAP)) { |
Lucille Sylvester | 721f7e7 | 2012-08-21 16:31:26 -0600 | [diff] [blame] | 1013 | kgsl_pwrscale_idle(device); |
Lucille Sylvester | c4af355 | 2011-10-27 11:44:24 -0600 | [diff] [blame] | 1014 | |
Suman Tatiraju | 7fe62a3 | 2011-07-14 16:40:37 -0700 | [diff] [blame] | 1015 | if (kgsl_pwrctrl_sleep(device) != 0) { |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1016 | mod_timer(&device->idle_timer, |
| 1017 | jiffies + |
| 1018 | device->pwrctrl.interval_timeout); |
Suman Tatiraju | 7fe62a3 | 2011-07-14 16:40:37 -0700 | [diff] [blame] | 1019 | /* If the GPU has been too busy to sleep, make sure * |
| 1020 | * that is acurately reflected in the % busy numbers. */ |
Suman Tatiraju | 2bdd056 | 2012-01-26 14:49:46 -0800 | [diff] [blame] | 1021 | device->pwrctrl.clk_stats.no_nap_cnt++; |
| 1022 | if (device->pwrctrl.clk_stats.no_nap_cnt > |
| 1023 | UPDATE_BUSY) { |
Suman Tatiraju | 7fe62a3 | 2011-07-14 16:40:37 -0700 | [diff] [blame] | 1024 | kgsl_pwrctrl_busy_time(device, true); |
Suman Tatiraju | 2bdd056 | 2012-01-26 14:49:46 -0800 | [diff] [blame] | 1025 | device->pwrctrl.clk_stats.no_nap_cnt = 0; |
Suman Tatiraju | 7fe62a3 | 2011-07-14 16:40:37 -0700 | [diff] [blame] | 1026 | } |
| 1027 | } |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1028 | } else if (device->state & (KGSL_STATE_HUNG | |
Tarun Karra | d20d71a | 2013-01-25 15:38:57 -0800 | [diff] [blame] | 1029 | KGSL_STATE_DUMP_AND_FT)) { |
Jeremy Gebben | 388c297 | 2011-12-16 09:05:07 -0700 | [diff] [blame] | 1030 | kgsl_pwrctrl_request_state(device, KGSL_STATE_NONE); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1031 | } |
| 1032 | |
| 1033 | mutex_unlock(&device->mutex); |
| 1034 | } |
| 1035 | |
| 1036 | void kgsl_timer(unsigned long data) |
| 1037 | { |
| 1038 | struct kgsl_device *device = (struct kgsl_device *) data; |
| 1039 | |
| 1040 | KGSL_PWR_INFO(device, "idle timer expired device %d\n", device->id); |
Anoop Kumar Yerukala | 03ba25f | 2012-01-23 17:32:02 +0530 | [diff] [blame] | 1041 | if (device->requested_state != KGSL_STATE_SUSPEND) { |
Lynus Vaz | fe4bede | 2012-04-06 11:53:30 -0700 | [diff] [blame] | 1042 | if (device->pwrctrl.restore_slumber || |
| 1043 | device->pwrctrl.strtstp_sleepwake) |
Lucille Sylvester | a985adf | 2012-01-16 11:11:55 -0700 | [diff] [blame] | 1044 | kgsl_pwrctrl_request_state(device, KGSL_STATE_SLUMBER); |
| 1045 | else |
| 1046 | kgsl_pwrctrl_request_state(device, KGSL_STATE_SLEEP); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1047 | /* Have work run in a non-interrupt context. */ |
| 1048 | queue_work(device->work_queue, &device->idle_check_ws); |
| 1049 | } |
| 1050 | } |
| 1051 | |
| 1052 | void kgsl_pre_hwaccess(struct kgsl_device *device) |
| 1053 | { |
| 1054 | BUG_ON(!mutex_is_locked(&device->mutex)); |
Lucille Sylvester | 8b803e9 | 2012-01-12 15:19:55 -0700 | [diff] [blame] | 1055 | switch (device->state) { |
| 1056 | case KGSL_STATE_ACTIVE: |
| 1057 | return; |
| 1058 | case KGSL_STATE_NAP: |
| 1059 | case KGSL_STATE_SLEEP: |
| 1060 | case KGSL_STATE_SLUMBER: |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1061 | kgsl_pwrctrl_wake(device); |
Lucille Sylvester | 8b803e9 | 2012-01-12 15:19:55 -0700 | [diff] [blame] | 1062 | break; |
| 1063 | case KGSL_STATE_SUSPEND: |
| 1064 | kgsl_check_suspended(device); |
| 1065 | break; |
| 1066 | case KGSL_STATE_INIT: |
| 1067 | case KGSL_STATE_HUNG: |
Tarun Karra | d20d71a | 2013-01-25 15:38:57 -0800 | [diff] [blame] | 1068 | case KGSL_STATE_DUMP_AND_FT: |
Lucille Sylvester | 8b803e9 | 2012-01-12 15:19:55 -0700 | [diff] [blame] | 1069 | if (test_bit(KGSL_PWRFLAGS_CLK_ON, |
| 1070 | &device->pwrctrl.power_flags)) |
| 1071 | break; |
| 1072 | else |
| 1073 | KGSL_PWR_ERR(device, |
| 1074 | "hw access while clocks off from state %d\n", |
| 1075 | device->state); |
| 1076 | break; |
| 1077 | default: |
| 1078 | KGSL_PWR_ERR(device, "hw access while in unknown state %d\n", |
| 1079 | device->state); |
| 1080 | break; |
| 1081 | } |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1082 | } |
| 1083 | EXPORT_SYMBOL(kgsl_pre_hwaccess); |
| 1084 | |
| 1085 | void kgsl_check_suspended(struct kgsl_device *device) |
| 1086 | { |
| 1087 | if (device->requested_state == KGSL_STATE_SUSPEND || |
| 1088 | device->state == KGSL_STATE_SUSPEND) { |
| 1089 | mutex_unlock(&device->mutex); |
| 1090 | wait_for_completion(&device->hwaccess_gate); |
| 1091 | mutex_lock(&device->mutex); |
Tarun Karra | d20d71a | 2013-01-25 15:38:57 -0800 | [diff] [blame] | 1092 | } else if (device->state == KGSL_STATE_DUMP_AND_FT) { |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1093 | mutex_unlock(&device->mutex); |
Tarun Karra | d20d71a | 2013-01-25 15:38:57 -0800 | [diff] [blame] | 1094 | wait_for_completion(&device->ft_gate); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1095 | mutex_lock(&device->mutex); |
Suman Tatiraju | 2456902 | 2011-10-27 11:11:12 -0700 | [diff] [blame] | 1096 | } else if (device->state == KGSL_STATE_SLUMBER) |
| 1097 | kgsl_pwrctrl_wake(device); |
| 1098 | } |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1099 | |
Suman Tatiraju | 2456902 | 2011-10-27 11:11:12 -0700 | [diff] [blame] | 1100 | static int |
Jeremy Gebben | 388c297 | 2011-12-16 09:05:07 -0700 | [diff] [blame] | 1101 | _nap(struct kgsl_device *device) |
Suman Tatiraju | 2456902 | 2011-10-27 11:11:12 -0700 | [diff] [blame] | 1102 | { |
Suman Tatiraju | 2456902 | 2011-10-27 11:11:12 -0700 | [diff] [blame] | 1103 | switch (device->state) { |
| 1104 | case KGSL_STATE_ACTIVE: |
Jeremy Gebben | 388c297 | 2011-12-16 09:05:07 -0700 | [diff] [blame] | 1105 | if (!device->ftbl->isidle(device)) { |
| 1106 | kgsl_pwrctrl_request_state(device, KGSL_STATE_NONE); |
| 1107 | return -EBUSY; |
| 1108 | } |
| 1109 | kgsl_pwrctrl_irq(device, KGSL_PWRFLAGS_OFF); |
Lucille Sylvester | e4a7c1a | 2012-04-11 12:17:38 -0600 | [diff] [blame] | 1110 | kgsl_pwrctrl_clk(device, KGSL_PWRFLAGS_OFF, KGSL_STATE_NAP); |
| 1111 | kgsl_pwrctrl_set_state(device, KGSL_STATE_NAP); |
Suman Tatiraju | 2456902 | 2011-10-27 11:11:12 -0700 | [diff] [blame] | 1112 | case KGSL_STATE_NAP: |
| 1113 | case KGSL_STATE_SLEEP: |
Jeremy Gebben | 388c297 | 2011-12-16 09:05:07 -0700 | [diff] [blame] | 1114 | case KGSL_STATE_SLUMBER: |
Suman Tatiraju | 2456902 | 2011-10-27 11:11:12 -0700 | [diff] [blame] | 1115 | break; |
| 1116 | default: |
Jeremy Gebben | 388c297 | 2011-12-16 09:05:07 -0700 | [diff] [blame] | 1117 | kgsl_pwrctrl_request_state(device, KGSL_STATE_NONE); |
Suman Tatiraju | 2456902 | 2011-10-27 11:11:12 -0700 | [diff] [blame] | 1118 | break; |
| 1119 | } |
Jeremy Gebben | 388c297 | 2011-12-16 09:05:07 -0700 | [diff] [blame] | 1120 | return 0; |
| 1121 | } |
| 1122 | |
| 1123 | static void |
| 1124 | _sleep_accounting(struct kgsl_device *device) |
| 1125 | { |
| 1126 | kgsl_pwrctrl_busy_time(device, false); |
Suman Tatiraju | 2bdd056 | 2012-01-26 14:49:46 -0800 | [diff] [blame] | 1127 | device->pwrctrl.clk_stats.start = ktime_set(0, 0); |
Jeremy Gebben | 388c297 | 2011-12-16 09:05:07 -0700 | [diff] [blame] | 1128 | device->pwrctrl.time = 0; |
| 1129 | kgsl_pwrscale_sleep(device); |
| 1130 | } |
| 1131 | |
| 1132 | static int |
| 1133 | _sleep(struct kgsl_device *device) |
| 1134 | { |
Jeremy Gebben | 388c297 | 2011-12-16 09:05:07 -0700 | [diff] [blame] | 1135 | switch (device->state) { |
| 1136 | case KGSL_STATE_ACTIVE: |
| 1137 | if (!device->ftbl->isidle(device)) { |
| 1138 | kgsl_pwrctrl_request_state(device, KGSL_STATE_NONE); |
| 1139 | return -EBUSY; |
| 1140 | } |
| 1141 | /* fall through */ |
| 1142 | case KGSL_STATE_NAP: |
| 1143 | kgsl_pwrctrl_irq(device, KGSL_PWRFLAGS_OFF); |
| 1144 | kgsl_pwrctrl_axi(device, KGSL_PWRFLAGS_OFF); |
Jeremy Gebben | 388c297 | 2011-12-16 09:05:07 -0700 | [diff] [blame] | 1145 | _sleep_accounting(device); |
Lucille Sylvester | e4a7c1a | 2012-04-11 12:17:38 -0600 | [diff] [blame] | 1146 | kgsl_pwrctrl_clk(device, KGSL_PWRFLAGS_OFF, KGSL_STATE_SLEEP); |
Jeremy Gebben | 388c297 | 2011-12-16 09:05:07 -0700 | [diff] [blame] | 1147 | kgsl_pwrctrl_set_state(device, KGSL_STATE_SLEEP); |
Lucille Sylvester | 1029789 | 2012-02-27 13:54:47 -0700 | [diff] [blame] | 1148 | pm_qos_update_request(&device->pm_qos_req_dma, |
| 1149 | PM_QOS_DEFAULT_VALUE); |
Jeremy Gebben | 388c297 | 2011-12-16 09:05:07 -0700 | [diff] [blame] | 1150 | break; |
| 1151 | case KGSL_STATE_SLEEP: |
| 1152 | case KGSL_STATE_SLUMBER: |
| 1153 | break; |
| 1154 | default: |
Jeremy Gebben | b50f331 | 2011-12-16 08:58:33 -0700 | [diff] [blame] | 1155 | KGSL_PWR_WARN(device, "unhandled state %s\n", |
| 1156 | kgsl_pwrstate_to_str(device->state)); |
Jeremy Gebben | 388c297 | 2011-12-16 09:05:07 -0700 | [diff] [blame] | 1157 | break; |
| 1158 | } |
Shubhraprakash Das | 7a0c93c | 2012-11-20 15:15:08 -0700 | [diff] [blame] | 1159 | |
| 1160 | kgsl_mmu_disable_clk_on_ts(&device->mmu, 0, false); |
| 1161 | |
Jeremy Gebben | 388c297 | 2011-12-16 09:05:07 -0700 | [diff] [blame] | 1162 | return 0; |
| 1163 | } |
| 1164 | |
| 1165 | static int |
| 1166 | _slumber(struct kgsl_device *device) |
| 1167 | { |
| 1168 | switch (device->state) { |
| 1169 | case KGSL_STATE_ACTIVE: |
| 1170 | if (!device->ftbl->isidle(device)) { |
| 1171 | kgsl_pwrctrl_request_state(device, KGSL_STATE_NONE); |
Jeremy Gebben | 388c297 | 2011-12-16 09:05:07 -0700 | [diff] [blame] | 1172 | return -EBUSY; |
| 1173 | } |
| 1174 | /* fall through */ |
| 1175 | case KGSL_STATE_NAP: |
| 1176 | case KGSL_STATE_SLEEP: |
| 1177 | del_timer_sync(&device->idle_timer); |
Jeremy Gebben | 388c297 | 2011-12-16 09:05:07 -0700 | [diff] [blame] | 1178 | device->ftbl->suspend_context(device); |
| 1179 | device->ftbl->stop(device); |
Jeremy Gebben | 388c297 | 2011-12-16 09:05:07 -0700 | [diff] [blame] | 1180 | _sleep_accounting(device); |
| 1181 | kgsl_pwrctrl_set_state(device, KGSL_STATE_SLUMBER); |
Suman Tatiraju | 3005cdd | 2012-03-19 14:38:11 -0700 | [diff] [blame] | 1182 | pm_qos_update_request(&device->pm_qos_req_dma, |
| 1183 | PM_QOS_DEFAULT_VALUE); |
Jeremy Gebben | 388c297 | 2011-12-16 09:05:07 -0700 | [diff] [blame] | 1184 | break; |
| 1185 | case KGSL_STATE_SLUMBER: |
| 1186 | break; |
| 1187 | default: |
Jeremy Gebben | b50f331 | 2011-12-16 08:58:33 -0700 | [diff] [blame] | 1188 | KGSL_PWR_WARN(device, "unhandled state %s\n", |
| 1189 | kgsl_pwrstate_to_str(device->state)); |
Jeremy Gebben | 388c297 | 2011-12-16 09:05:07 -0700 | [diff] [blame] | 1190 | break; |
| 1191 | } |
| 1192 | return 0; |
Suman Tatiraju | 2456902 | 2011-10-27 11:11:12 -0700 | [diff] [blame] | 1193 | } |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1194 | |
| 1195 | /******************************************************************/ |
| 1196 | /* Caller must hold the device mutex. */ |
| 1197 | int kgsl_pwrctrl_sleep(struct kgsl_device *device) |
| 1198 | { |
Jeremy Gebben | 388c297 | 2011-12-16 09:05:07 -0700 | [diff] [blame] | 1199 | int status = 0; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1200 | KGSL_PWR_INFO(device, "sleep device %d\n", device->id); |
| 1201 | |
| 1202 | /* Work through the legal state transitions */ |
Jeremy Gebben | 388c297 | 2011-12-16 09:05:07 -0700 | [diff] [blame] | 1203 | switch (device->requested_state) { |
| 1204 | case KGSL_STATE_NAP: |
Jeremy Gebben | 388c297 | 2011-12-16 09:05:07 -0700 | [diff] [blame] | 1205 | status = _nap(device); |
| 1206 | break; |
| 1207 | case KGSL_STATE_SLEEP: |
Lucille Sylvester | a985adf | 2012-01-16 11:11:55 -0700 | [diff] [blame] | 1208 | status = _sleep(device); |
Shubhraprakash Das | 602497c | 2013-05-28 16:53:24 -0600 | [diff] [blame] | 1209 | kgsl_mmu_disable_clk_on_ts(&device->mmu, 0, false); |
Jeremy Gebben | 388c297 | 2011-12-16 09:05:07 -0700 | [diff] [blame] | 1210 | break; |
| 1211 | case KGSL_STATE_SLUMBER: |
| 1212 | status = _slumber(device); |
| 1213 | break; |
| 1214 | default: |
| 1215 | KGSL_PWR_INFO(device, "bad state request 0x%x\n", |
| 1216 | device->requested_state); |
| 1217 | kgsl_pwrctrl_request_state(device, KGSL_STATE_NONE); |
| 1218 | status = -EINVAL; |
| 1219 | break; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1220 | } |
Suman Tatiraju | 2456902 | 2011-10-27 11:11:12 -0700 | [diff] [blame] | 1221 | return status; |
| 1222 | } |
Jeremy Gebben | 388c297 | 2011-12-16 09:05:07 -0700 | [diff] [blame] | 1223 | EXPORT_SYMBOL(kgsl_pwrctrl_sleep); |
Suman Tatiraju | 2456902 | 2011-10-27 11:11:12 -0700 | [diff] [blame] | 1224 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1225 | /******************************************************************/ |
| 1226 | /* Caller must hold the device mutex. */ |
| 1227 | void kgsl_pwrctrl_wake(struct kgsl_device *device) |
| 1228 | { |
Jeremy Gebben | 388c297 | 2011-12-16 09:05:07 -0700 | [diff] [blame] | 1229 | int status; |
Ranjhith Kalisamy | cb1721c | 2013-05-28 16:59:59 -0600 | [diff] [blame^] | 1230 | unsigned int context_id; |
| 1231 | unsigned int state = device->state; |
| 1232 | unsigned int ts_processed = 0xdeaddead; |
| 1233 | struct kgsl_context *context; |
| 1234 | |
Jeremy Gebben | 388c297 | 2011-12-16 09:05:07 -0700 | [diff] [blame] | 1235 | kgsl_pwrctrl_request_state(device, KGSL_STATE_ACTIVE); |
| 1236 | switch (device->state) { |
| 1237 | case KGSL_STATE_SLUMBER: |
| 1238 | status = device->ftbl->start(device, 0); |
| 1239 | if (status) { |
| 1240 | kgsl_pwrctrl_request_state(device, KGSL_STATE_NONE); |
| 1241 | KGSL_DRV_ERR(device, "start failed %d\n", status); |
| 1242 | break; |
| 1243 | } |
| 1244 | /* fall through */ |
| 1245 | case KGSL_STATE_SLEEP: |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1246 | kgsl_pwrctrl_axi(device, KGSL_PWRFLAGS_ON); |
| 1247 | kgsl_pwrscale_wake(device); |
Ranjhith Kalisamy | cb1721c | 2013-05-28 16:59:59 -0600 | [diff] [blame^] | 1248 | kgsl_sharedmem_readl(&device->memstore, |
| 1249 | (unsigned int *) &context_id, |
| 1250 | KGSL_MEMSTORE_OFFSET(KGSL_MEMSTORE_GLOBAL, |
| 1251 | current_context)); |
| 1252 | context = idr_find(&device->context_idr, context_id); |
| 1253 | if (context) |
| 1254 | ts_processed = kgsl_readtimestamp(device, context, |
| 1255 | KGSL_TIMESTAMP_RETIRED); |
| 1256 | KGSL_PWR_INFO(device, "Wake from %s state. CTXT: %d RTRD TS: %08X\n", |
| 1257 | kgsl_pwrstate_to_str(state), |
| 1258 | context ? context->id : -1, ts_processed); |
Jeremy Gebben | 388c297 | 2011-12-16 09:05:07 -0700 | [diff] [blame] | 1259 | /* fall through */ |
| 1260 | case KGSL_STATE_NAP: |
| 1261 | /* Turn on the core clocks */ |
Lucille Sylvester | e4a7c1a | 2012-04-11 12:17:38 -0600 | [diff] [blame] | 1262 | kgsl_pwrctrl_clk(device, KGSL_PWRFLAGS_ON, KGSL_STATE_ACTIVE); |
Jeremy Gebben | 388c297 | 2011-12-16 09:05:07 -0700 | [diff] [blame] | 1263 | /* Enable state before turning on irq */ |
| 1264 | kgsl_pwrctrl_set_state(device, KGSL_STATE_ACTIVE); |
| 1265 | kgsl_pwrctrl_irq(device, KGSL_PWRFLAGS_ON); |
| 1266 | /* Re-enable HW access */ |
| 1267 | mod_timer(&device->idle_timer, |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1268 | jiffies + device->pwrctrl.interval_timeout); |
Devin Kim | 66ad4c0 | 2012-09-21 20:28:50 -0700 | [diff] [blame] | 1269 | pm_qos_update_request(&device->pm_qos_req_dma, |
| 1270 | GPU_SWFI_LATENCY); |
Jeremy Gebben | 388c297 | 2011-12-16 09:05:07 -0700 | [diff] [blame] | 1271 | case KGSL_STATE_ACTIVE: |
Vinay Roy | 65c41b3 | 2012-11-25 00:48:38 +0530 | [diff] [blame] | 1272 | kgsl_pwrctrl_request_state(device, KGSL_STATE_NONE); |
Jeremy Gebben | 388c297 | 2011-12-16 09:05:07 -0700 | [diff] [blame] | 1273 | break; |
| 1274 | default: |
Jeremy Gebben | b50f331 | 2011-12-16 08:58:33 -0700 | [diff] [blame] | 1275 | KGSL_PWR_WARN(device, "unhandled state %s\n", |
| 1276 | kgsl_pwrstate_to_str(device->state)); |
Jeremy Gebben | 388c297 | 2011-12-16 09:05:07 -0700 | [diff] [blame] | 1277 | kgsl_pwrctrl_request_state(device, KGSL_STATE_NONE); |
| 1278 | break; |
| 1279 | } |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1280 | } |
| 1281 | EXPORT_SYMBOL(kgsl_pwrctrl_wake); |
| 1282 | |
| 1283 | void kgsl_pwrctrl_enable(struct kgsl_device *device) |
| 1284 | { |
| 1285 | /* Order pwrrail/clk sequence based upon platform */ |
| 1286 | kgsl_pwrctrl_pwrrail(device, KGSL_PWRFLAGS_ON); |
Lucille Sylvester | e4a7c1a | 2012-04-11 12:17:38 -0600 | [diff] [blame] | 1287 | kgsl_pwrctrl_clk(device, KGSL_PWRFLAGS_ON, KGSL_STATE_ACTIVE); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1288 | kgsl_pwrctrl_axi(device, KGSL_PWRFLAGS_ON); |
| 1289 | } |
| 1290 | EXPORT_SYMBOL(kgsl_pwrctrl_enable); |
| 1291 | |
| 1292 | void kgsl_pwrctrl_disable(struct kgsl_device *device) |
| 1293 | { |
| 1294 | /* Order pwrrail/clk sequence based upon platform */ |
| 1295 | kgsl_pwrctrl_axi(device, KGSL_PWRFLAGS_OFF); |
Lucille Sylvester | e4a7c1a | 2012-04-11 12:17:38 -0600 | [diff] [blame] | 1296 | kgsl_pwrctrl_clk(device, KGSL_PWRFLAGS_OFF, KGSL_STATE_SLEEP); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1297 | kgsl_pwrctrl_pwrrail(device, KGSL_PWRFLAGS_OFF); |
| 1298 | } |
| 1299 | EXPORT_SYMBOL(kgsl_pwrctrl_disable); |
Jeremy Gebben | 388c297 | 2011-12-16 09:05:07 -0700 | [diff] [blame] | 1300 | |
| 1301 | void kgsl_pwrctrl_set_state(struct kgsl_device *device, unsigned int state) |
| 1302 | { |
Jeremy Gebben | b50f331 | 2011-12-16 08:58:33 -0700 | [diff] [blame] | 1303 | trace_kgsl_pwr_set_state(device, state); |
Jeremy Gebben | 388c297 | 2011-12-16 09:05:07 -0700 | [diff] [blame] | 1304 | device->state = state; |
| 1305 | device->requested_state = KGSL_STATE_NONE; |
| 1306 | } |
| 1307 | EXPORT_SYMBOL(kgsl_pwrctrl_set_state); |
| 1308 | |
| 1309 | void kgsl_pwrctrl_request_state(struct kgsl_device *device, unsigned int state) |
| 1310 | { |
| 1311 | if (state != KGSL_STATE_NONE && state != device->requested_state) |
Jeremy Gebben | b50f331 | 2011-12-16 08:58:33 -0700 | [diff] [blame] | 1312 | trace_kgsl_pwr_request_state(device, state); |
Jeremy Gebben | 388c297 | 2011-12-16 09:05:07 -0700 | [diff] [blame] | 1313 | device->requested_state = state; |
| 1314 | } |
| 1315 | EXPORT_SYMBOL(kgsl_pwrctrl_request_state); |
Jeremy Gebben | b50f331 | 2011-12-16 08:58:33 -0700 | [diff] [blame] | 1316 | |
| 1317 | const char *kgsl_pwrstate_to_str(unsigned int state) |
| 1318 | { |
| 1319 | switch (state) { |
| 1320 | case KGSL_STATE_NONE: |
| 1321 | return "NONE"; |
| 1322 | case KGSL_STATE_INIT: |
| 1323 | return "INIT"; |
| 1324 | case KGSL_STATE_ACTIVE: |
| 1325 | return "ACTIVE"; |
| 1326 | case KGSL_STATE_NAP: |
| 1327 | return "NAP"; |
| 1328 | case KGSL_STATE_SLEEP: |
| 1329 | return "SLEEP"; |
| 1330 | case KGSL_STATE_SUSPEND: |
| 1331 | return "SUSPEND"; |
| 1332 | case KGSL_STATE_HUNG: |
| 1333 | return "HUNG"; |
Tarun Karra | d20d71a | 2013-01-25 15:38:57 -0800 | [diff] [blame] | 1334 | case KGSL_STATE_DUMP_AND_FT: |
Jeremy Gebben | b50f331 | 2011-12-16 08:58:33 -0700 | [diff] [blame] | 1335 | return "DNR"; |
| 1336 | case KGSL_STATE_SLUMBER: |
| 1337 | return "SLUMBER"; |
| 1338 | default: |
| 1339 | break; |
| 1340 | } |
| 1341 | return "UNKNOWN"; |
| 1342 | } |
| 1343 | EXPORT_SYMBOL(kgsl_pwrstate_to_str); |
| 1344 | |