|
13 | 13 | #include <linux/platform_device.h>
|
14 | 14 | #include <linux/pm_runtime.h>
|
15 | 15 | #include <linux/regulator/consumer.h>
|
| 16 | +#include <linux/reset.h> |
16 | 17 | #include <linux/thermal.h>
|
17 | 18 |
|
18 | 19 | #include "etnaviv_cmdbuf.h"
|
@@ -172,6 +173,29 @@ int etnaviv_gpu_get_param(struct etnaviv_gpu *gpu, u32 param, u64 *value)
|
172 | 173 | return 0;
|
173 | 174 | }
|
174 | 175 |
|
| 176 | +static int etnaviv_gpu_reset_deassert(struct etnaviv_gpu *gpu) |
| 177 | +{ |
| 178 | + int ret; |
| 179 | + |
| 180 | + /* |
| 181 | + * 32 core clock cycles (slowest clock) required before deassertion |
| 182 | + * 1 microsecond might match all implementations without computation |
| 183 | + */ |
| 184 | + usleep_range(1, 2); |
| 185 | + |
| 186 | + ret = reset_control_deassert(gpu->rst); |
| 187 | + if (ret) |
| 188 | + return ret; |
| 189 | + |
| 190 | + /* |
| 191 | + * 128 core clock cycles (slowest clock) required before any activity on AHB |
| 192 | + * 1 microsecond might match all implementations without computation |
| 193 | + */ |
| 194 | + usleep_range(1, 2); |
| 195 | + |
| 196 | + return 0; |
| 197 | +} |
| 198 | + |
175 | 199 | static inline bool etnaviv_is_model_rev(struct etnaviv_gpu *gpu, u32 model, u32 revision)
|
176 | 200 | {
|
177 | 201 | return gpu->identity.model == model &&
|
@@ -799,6 +823,12 @@ int etnaviv_gpu_init(struct etnaviv_gpu *gpu)
|
799 | 823 | goto pm_put;
|
800 | 824 | }
|
801 | 825 |
|
| 826 | + ret = etnaviv_gpu_reset_deassert(gpu); |
| 827 | + if (ret) { |
| 828 | + dev_err(gpu->dev, "GPU reset deassert failed\n"); |
| 829 | + goto fail; |
| 830 | + } |
| 831 | + |
802 | 832 | etnaviv_hw_identify(gpu);
|
803 | 833 |
|
804 | 834 | if (gpu->identity.model == 0) {
|
@@ -1860,6 +1890,17 @@ static int etnaviv_gpu_platform_probe(struct platform_device *pdev)
|
1860 | 1890 | if (IS_ERR(gpu->mmio))
|
1861 | 1891 | return PTR_ERR(gpu->mmio);
|
1862 | 1892 |
|
| 1893 | + |
| 1894 | + /* Get Reset: */ |
| 1895 | + gpu->rst = devm_reset_control_get_optional_exclusive(&pdev->dev, NULL); |
| 1896 | + if (IS_ERR(gpu->rst)) |
| 1897 | + return dev_err_probe(dev, PTR_ERR(gpu->rst), |
| 1898 | + "failed to get reset\n"); |
| 1899 | + |
| 1900 | + err = reset_control_assert(gpu->rst); |
| 1901 | + if (err) |
| 1902 | + return dev_err_probe(dev, err, "failed to assert reset\n"); |
| 1903 | + |
1863 | 1904 | /* Get Interrupt: */
|
1864 | 1905 | gpu->irq = platform_get_irq(pdev, 0);
|
1865 | 1906 | if (gpu->irq < 0)
|
|
0 commit comments