|
7 | 7 | */
|
8 | 8 |
|
9 | 9 | #include "a3xx_gpu.h"
|
| 10 | +#include <linux/nvmem-consumer.h> |
10 | 11 |
|
11 | 12 | #define A3XX_INT0_MASK \
|
12 | 13 | (A3XX_INT0_RBBM_AHB_ERROR | \
|
@@ -493,6 +494,43 @@ static u32 a3xx_get_rptr(struct msm_gpu *gpu, struct msm_ringbuffer *ring)
|
493 | 494 | return ring->memptrs->rptr;
|
494 | 495 | }
|
495 | 496 |
|
| 497 | +static int a3xx_set_supported_hw(struct device *dev, struct adreno_gpu *adreno_gpu) |
| 498 | +{ |
| 499 | + u32 speedbin, version; |
| 500 | + int ret; |
| 501 | + |
| 502 | + ret = nvmem_cell_read_variable_le_u32(dev, "speed_bin_version", &version); |
| 503 | + /* |
| 504 | + * -ENOENT means that the platform doesn't support speedbin which is |
| 505 | + * fine |
| 506 | + */ |
| 507 | + if (ret == -ENOENT) { |
| 508 | + return 0; |
| 509 | + } else if (ret) { |
| 510 | + dev_err_probe(dev, ret, |
| 511 | + "failed to read speed-bin-version. Some OPPs may not be supported by hardware\n"); |
| 512 | + return ret; |
| 513 | + } |
| 514 | + |
| 515 | + ret = nvmem_cell_read_variable_le_u32(dev, "speed_bin", &speedbin); |
| 516 | + if (ret) { |
| 517 | + dev_err_probe(dev, ret, |
| 518 | + "failed to read speed-bin. Some OPPs may not be supported by hardware\n"); |
| 519 | + return ret; |
| 520 | + } |
| 521 | + dev_info(dev, "speed-bin version: %u value: %u\n", version, speedbin); |
| 522 | + |
| 523 | + // if (version > 0) |
| 524 | + // we must set at least version 0x1 otherwise no opp gets selected |
| 525 | + // having opp-supported-hw property |
| 526 | + if (speedbin == 0) |
| 527 | + speedbin = 0x1; |
| 528 | + |
| 529 | + return devm_pm_opp_set_supported_hw(dev, &speedbin, 1); |
| 530 | + |
| 531 | + return 0; |
| 532 | +} |
| 533 | + |
496 | 534 | static const struct adreno_gpu_funcs funcs = {
|
497 | 535 | .base = {
|
498 | 536 | .get_param = adreno_get_param,
|
@@ -554,6 +592,9 @@ struct msm_gpu *a3xx_gpu_init(struct drm_device *dev)
|
554 | 592 |
|
555 | 593 | adreno_gpu->registers = a3xx_registers;
|
556 | 594 |
|
| 595 | + /* speed-bin */ |
| 596 | + a3xx_set_supported_hw(&pdev->dev, adreno_gpu); |
| 597 | + |
557 | 598 | ret = adreno_gpu_init(dev, pdev, adreno_gpu, &funcs, 1);
|
558 | 599 | if (ret)
|
559 | 600 | goto fail;
|
|
0 commit comments