diff options
author | Jordan Crouse <jcrouse@codeaurora.org> | 2017-11-21 14:40:55 -0500 |
---|---|---|
committer | Rob Clark <robdclark@gmail.com> | 2018-01-10 08:58:42 -0500 |
commit | 999ae6edc1c19e316dd61f4b3e1a6984ea293280 (patch) | |
tree | bdc9f9b25f27025d3a340f9143c9e121585ae6ca /drivers | |
parent | 728bde66df82e8a0ed6114aa55c2ee3e94ff993b (diff) |
drm/msm/adreno: Move clock parsing to adreno_gpu_init()
Move the clock parsing to adreno_gpu_init() to allow for target
specific probing and manipulation of the clock tables.
Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
Signed-off-by: Rob Clark <robdclark@gmail.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/gpu/drm/msm/adreno/adreno_device.c | 72 | ||||
-rw-r--r-- | drivers/gpu/drm/msm/adreno/adreno_gpu.c | 77 | ||||
-rw-r--r-- | drivers/gpu/drm/msm/adreno/adreno_gpu.h | 1 |
3 files changed, 73 insertions, 77 deletions
diff --git a/drivers/gpu/drm/msm/adreno/adreno_device.c b/drivers/gpu/drm/msm/adreno/adreno_device.c index fd2145489c5f..62bdb7316da1 100644 --- a/drivers/gpu/drm/msm/adreno/adreno_device.c +++ b/drivers/gpu/drm/msm/adreno/adreno_device.c | |||
@@ -17,7 +17,6 @@ | |||
17 | * this program. If not, see <http://www.gnu.org/licenses/>. | 17 | * this program. If not, see <http://www.gnu.org/licenses/>. |
18 | */ | 18 | */ |
19 | 19 | ||
20 | #include <linux/pm_opp.h> | ||
21 | #include "adreno_gpu.h" | 20 | #include "adreno_gpu.h" |
22 | 21 | ||
23 | #define ANY_ID 0xff | 22 | #define ANY_ID 0xff |
@@ -204,70 +203,6 @@ static int find_chipid(struct device *dev, struct adreno_rev *rev) | |||
204 | return 0; | 203 | return 0; |
205 | } | 204 | } |
206 | 205 | ||
207 | /* Get legacy powerlevels from qcom,gpu-pwrlevels and populate the opp table */ | ||
208 | static int adreno_get_legacy_pwrlevels(struct device *dev) | ||
209 | { | ||
210 | struct device_node *child, *node; | ||
211 | int ret; | ||
212 | |||
213 | node = of_find_compatible_node(dev->of_node, NULL, | ||
214 | "qcom,gpu-pwrlevels"); | ||
215 | if (!node) { | ||
216 | dev_err(dev, "Could not find the GPU powerlevels\n"); | ||
217 | return -ENXIO; | ||
218 | } | ||
219 | |||
220 | for_each_child_of_node(node, child) { | ||
221 | unsigned int val; | ||
222 | |||
223 | ret = of_property_read_u32(child, "qcom,gpu-freq", &val); | ||
224 | if (ret) | ||
225 | continue; | ||
226 | |||
227 | /* | ||
228 | * Skip the intentionally bogus clock value found at the bottom | ||
229 | * of most legacy frequency tables | ||
230 | */ | ||
231 | if (val != 27000000) | ||
232 | dev_pm_opp_add(dev, val, 0); | ||
233 | } | ||
234 | |||
235 | return 0; | ||
236 | } | ||
237 | |||
238 | static int adreno_get_pwrlevels(struct device *dev, | ||
239 | struct adreno_platform_config *config) | ||
240 | { | ||
241 | unsigned long freq = ULONG_MAX; | ||
242 | struct dev_pm_opp *opp; | ||
243 | int ret; | ||
244 | |||
245 | /* You down with OPP? */ | ||
246 | if (!of_find_property(dev->of_node, "operating-points-v2", NULL)) | ||
247 | ret = adreno_get_legacy_pwrlevels(dev); | ||
248 | else | ||
249 | ret = dev_pm_opp_of_add_table(dev); | ||
250 | |||
251 | if (ret) | ||
252 | return ret; | ||
253 | |||
254 | /* Find the fastest defined rate */ | ||
255 | opp = dev_pm_opp_find_freq_floor(dev, &freq); | ||
256 | if (!IS_ERR(opp)) { | ||
257 | config->fast_rate = freq; | ||
258 | dev_pm_opp_put(opp); | ||
259 | } | ||
260 | |||
261 | if (!config->fast_rate) { | ||
262 | DRM_DEV_INFO(dev, | ||
263 | "Could not find clock rate. Using default\n"); | ||
264 | /* Pick a suitably safe clock speed for any target */ | ||
265 | config->fast_rate = 200000000; | ||
266 | } | ||
267 | |||
268 | return 0; | ||
269 | } | ||
270 | |||
271 | static int adreno_bind(struct device *dev, struct device *master, void *data) | 206 | static int adreno_bind(struct device *dev, struct device *master, void *data) |
272 | { | 207 | { |
273 | static struct adreno_platform_config config = {}; | 208 | static struct adreno_platform_config config = {}; |
@@ -280,13 +215,6 @@ static int adreno_bind(struct device *dev, struct device *master, void *data) | |||
280 | if (ret) | 215 | if (ret) |
281 | return ret; | 216 | return ret; |
282 | 217 | ||
283 | /* find clock rates: */ | ||
284 | config.fast_rate = 0; | ||
285 | |||
286 | ret = adreno_get_pwrlevels(dev, &config); | ||
287 | if (ret) | ||
288 | return ret; | ||
289 | |||
290 | dev->platform_data = &config; | 218 | dev->platform_data = &config; |
291 | set_gpu_pdev(drm, to_platform_device(dev)); | 219 | set_gpu_pdev(drm, to_platform_device(dev)); |
292 | 220 | ||
diff --git a/drivers/gpu/drm/msm/adreno/adreno_gpu.c b/drivers/gpu/drm/msm/adreno/adreno_gpu.c index 61e3091fada9..b4bac84b3b4f 100644 --- a/drivers/gpu/drm/msm/adreno/adreno_gpu.c +++ b/drivers/gpu/drm/msm/adreno/adreno_gpu.c | |||
@@ -17,6 +17,7 @@ | |||
17 | * this program. If not, see <http://www.gnu.org/licenses/>. | 17 | * this program. If not, see <http://www.gnu.org/licenses/>. |
18 | */ | 18 | */ |
19 | 19 | ||
20 | #include <linux/pm_opp.h> | ||
20 | #include "adreno_gpu.h" | 21 | #include "adreno_gpu.h" |
21 | #include "msm_gem.h" | 22 | #include "msm_gem.h" |
22 | #include "msm_mmu.h" | 23 | #include "msm_mmu.h" |
@@ -465,6 +466,76 @@ void adreno_wait_ring(struct msm_ringbuffer *ring, uint32_t ndwords) | |||
465 | ring->id); | 466 | ring->id); |
466 | } | 467 | } |
467 | 468 | ||
469 | /* Get legacy powerlevels from qcom,gpu-pwrlevels and populate the opp table */ | ||
470 | static int adreno_get_legacy_pwrlevels(struct device *dev) | ||
471 | { | ||
472 | struct device_node *child, *node; | ||
473 | int ret; | ||
474 | |||
475 | node = of_find_compatible_node(dev->of_node, NULL, | ||
476 | "qcom,gpu-pwrlevels"); | ||
477 | if (!node) { | ||
478 | dev_err(dev, "Could not find the GPU powerlevels\n"); | ||
479 | return -ENXIO; | ||
480 | } | ||
481 | |||
482 | for_each_child_of_node(node, child) { | ||
483 | unsigned int val; | ||
484 | |||
485 | ret = of_property_read_u32(child, "qcom,gpu-freq", &val); | ||
486 | if (ret) | ||
487 | continue; | ||
488 | |||
489 | /* | ||
490 | * Skip the intentionally bogus clock value found at the bottom | ||
491 | * of most legacy frequency tables | ||
492 | */ | ||
493 | if (val != 27000000) | ||
494 | dev_pm_opp_add(dev, val, 0); | ||
495 | } | ||
496 | |||
497 | return 0; | ||
498 | } | ||
499 | |||
500 | static int adreno_get_pwrlevels(struct device *dev, | ||
501 | struct msm_gpu *gpu) | ||
502 | { | ||
503 | unsigned long freq = ULONG_MAX; | ||
504 | struct dev_pm_opp *opp; | ||
505 | int ret; | ||
506 | |||
507 | gpu->fast_rate = 0; | ||
508 | |||
509 | /* You down with OPP? */ | ||
510 | if (!of_find_property(dev->of_node, "operating-points-v2", NULL)) | ||
511 | ret = adreno_get_legacy_pwrlevels(dev); | ||
512 | else { | ||
513 | ret = dev_pm_opp_of_add_table(dev); | ||
514 | if (ret) | ||
515 | dev_err(dev, "Unable to set the OPP table\n"); | ||
516 | } | ||
517 | |||
518 | if (!ret) { | ||
519 | /* Find the fastest defined rate */ | ||
520 | opp = dev_pm_opp_find_freq_floor(dev, &freq); | ||
521 | if (!IS_ERR(opp)) { | ||
522 | gpu->fast_rate = freq; | ||
523 | dev_pm_opp_put(opp); | ||
524 | } | ||
525 | } | ||
526 | |||
527 | if (!gpu->fast_rate) { | ||
528 | dev_warn(dev, | ||
529 | "Could not find a clock rate. Using a reasonable default\n"); | ||
530 | /* Pick a suitably safe clock speed for any target */ | ||
531 | gpu->fast_rate = 200000000; | ||
532 | } | ||
533 | |||
534 | DBG("fast_rate=%u, slow_rate=27000000", gpu->fast_rate); | ||
535 | |||
536 | return 0; | ||
537 | } | ||
538 | |||
468 | int adreno_gpu_init(struct drm_device *drm, struct platform_device *pdev, | 539 | int adreno_gpu_init(struct drm_device *drm, struct platform_device *pdev, |
469 | struct adreno_gpu *adreno_gpu, | 540 | struct adreno_gpu *adreno_gpu, |
470 | const struct adreno_gpu_funcs *funcs, int nr_rings) | 541 | const struct adreno_gpu_funcs *funcs, int nr_rings) |
@@ -479,10 +550,6 @@ int adreno_gpu_init(struct drm_device *drm, struct platform_device *pdev, | |||
479 | adreno_gpu->revn = adreno_gpu->info->revn; | 550 | adreno_gpu->revn = adreno_gpu->info->revn; |
480 | adreno_gpu->rev = config->rev; | 551 | adreno_gpu->rev = config->rev; |
481 | 552 | ||
482 | gpu->fast_rate = config->fast_rate; | ||
483 | |||
484 | DBG("fast_rate=%u, slow_rate=27000000", gpu->fast_rate); | ||
485 | |||
486 | adreno_gpu_config.ioname = "kgsl_3d0_reg_memory"; | 553 | adreno_gpu_config.ioname = "kgsl_3d0_reg_memory"; |
487 | adreno_gpu_config.irqname = "kgsl_3d0_irq"; | 554 | adreno_gpu_config.irqname = "kgsl_3d0_irq"; |
488 | 555 | ||
@@ -491,6 +558,8 @@ int adreno_gpu_init(struct drm_device *drm, struct platform_device *pdev, | |||
491 | 558 | ||
492 | adreno_gpu_config.nr_rings = nr_rings; | 559 | adreno_gpu_config.nr_rings = nr_rings; |
493 | 560 | ||
561 | adreno_get_pwrlevels(&pdev->dev, gpu); | ||
562 | |||
494 | pm_runtime_set_autosuspend_delay(&pdev->dev, DRM_MSM_INACTIVE_PERIOD); | 563 | pm_runtime_set_autosuspend_delay(&pdev->dev, DRM_MSM_INACTIVE_PERIOD); |
495 | pm_runtime_use_autosuspend(&pdev->dev); | 564 | pm_runtime_use_autosuspend(&pdev->dev); |
496 | pm_runtime_enable(&pdev->dev); | 565 | pm_runtime_enable(&pdev->dev); |
diff --git a/drivers/gpu/drm/msm/adreno/adreno_gpu.h b/drivers/gpu/drm/msm/adreno/adreno_gpu.h index 88d1bdfd9aae..8d3d0a924908 100644 --- a/drivers/gpu/drm/msm/adreno/adreno_gpu.h +++ b/drivers/gpu/drm/msm/adreno/adreno_gpu.h | |||
@@ -129,7 +129,6 @@ struct adreno_gpu { | |||
129 | /* platform config data (ie. from DT, or pdata) */ | 129 | /* platform config data (ie. from DT, or pdata) */ |
130 | struct adreno_platform_config { | 130 | struct adreno_platform_config { |
131 | struct adreno_rev rev; | 131 | struct adreno_rev rev; |
132 | uint32_t fast_rate; | ||
133 | }; | 132 | }; |
134 | 133 | ||
135 | #define ADRENO_IDLE_TIMEOUT msecs_to_jiffies(1000) | 134 | #define ADRENO_IDLE_TIMEOUT msecs_to_jiffies(1000) |