Lines Matching refs:pfdev

24 	struct panfrost_device *pfdev = data;  in panfrost_gpu_irq_handler()  local
25 u32 state = gpu_read(pfdev, GPU_INT_STAT); in panfrost_gpu_irq_handler()
26 u32 fault_status = gpu_read(pfdev, GPU_FAULT_STATUS); in panfrost_gpu_irq_handler()
32 u64 address = (u64) gpu_read(pfdev, GPU_FAULT_ADDRESS_HI) << 32; in panfrost_gpu_irq_handler()
33 address |= gpu_read(pfdev, GPU_FAULT_ADDRESS_LO); in panfrost_gpu_irq_handler()
35 dev_warn(pfdev->dev, "GPU Fault 0x%08x (%s) at 0x%016llx\n", in panfrost_gpu_irq_handler()
40 dev_warn(pfdev->dev, "There were multiple GPU faults - some have not been reported\n"); in panfrost_gpu_irq_handler()
42 gpu_write(pfdev, GPU_INT_MASK, 0); in panfrost_gpu_irq_handler()
46 panfrost_perfcnt_sample_done(pfdev); in panfrost_gpu_irq_handler()
49 panfrost_perfcnt_clean_cache_done(pfdev); in panfrost_gpu_irq_handler()
51 gpu_write(pfdev, GPU_INT_CLEAR, state); in panfrost_gpu_irq_handler()
56 int panfrost_gpu_soft_reset(struct panfrost_device *pfdev) in panfrost_gpu_soft_reset() argument
61 gpu_write(pfdev, GPU_INT_MASK, 0); in panfrost_gpu_soft_reset()
62 gpu_write(pfdev, GPU_INT_CLEAR, GPU_IRQ_RESET_COMPLETED); in panfrost_gpu_soft_reset()
63 gpu_write(pfdev, GPU_CMD, GPU_CMD_SOFT_RESET); in panfrost_gpu_soft_reset()
65 ret = readl_relaxed_poll_timeout(pfdev->iomem + GPU_INT_RAWSTAT, in panfrost_gpu_soft_reset()
69 dev_err(pfdev->dev, "gpu soft reset timed out\n"); in panfrost_gpu_soft_reset()
73 gpu_write(pfdev, GPU_INT_CLEAR, GPU_IRQ_MASK_ALL); in panfrost_gpu_soft_reset()
74 gpu_write(pfdev, GPU_INT_MASK, GPU_IRQ_MASK_ALL); in panfrost_gpu_soft_reset()
79 void panfrost_gpu_amlogic_quirk(struct panfrost_device *pfdev) in panfrost_gpu_amlogic_quirk() argument
86 gpu_write(pfdev, GPU_PWR_KEY, GPU_PWR_KEY_UNLOCK); in panfrost_gpu_amlogic_quirk()
87 gpu_write(pfdev, GPU_PWR_OVERRIDE1, 0xfff | (0x20 << 16)); in panfrost_gpu_amlogic_quirk()
90 static void panfrost_gpu_init_quirks(struct panfrost_device *pfdev) in panfrost_gpu_init_quirks() argument
94 if (panfrost_has_hw_issue(pfdev, HW_ISSUE_8443) || in panfrost_gpu_init_quirks()
95 panfrost_has_hw_issue(pfdev, HW_ISSUE_11035)) in panfrost_gpu_init_quirks()
98 if (panfrost_has_hw_issue(pfdev, HW_ISSUE_10327)) in panfrost_gpu_init_quirks()
101 if (panfrost_has_hw_issue(pfdev, HW_ISSUE_10797)) in panfrost_gpu_init_quirks()
104 if (!panfrost_has_hw_issue(pfdev, GPUCORE_1619)) { in panfrost_gpu_init_quirks()
105 if (panfrost_model_cmp(pfdev, 0x750) < 0) /* T60x, T62x, T72x */ in panfrost_gpu_init_quirks()
107 else if (panfrost_model_cmp(pfdev, 0x880) <= 0) /* T76x, T8xx */ in panfrost_gpu_init_quirks()
111 if (panfrost_has_hw_feature(pfdev, HW_FEATURE_TLS_HASHING)) in panfrost_gpu_init_quirks()
115 gpu_write(pfdev, GPU_SHADER_CONFIG, quirks); in panfrost_gpu_init_quirks()
118 quirks = gpu_read(pfdev, GPU_TILER_CONFIG); in panfrost_gpu_init_quirks()
121 if (panfrost_has_hw_issue(pfdev, HW_ISSUE_T76X_3953)) in panfrost_gpu_init_quirks()
124 gpu_write(pfdev, GPU_TILER_CONFIG, quirks); in panfrost_gpu_init_quirks()
127 quirks = gpu_read(pfdev, GPU_L2_MMU_CONFIG); in panfrost_gpu_init_quirks()
130 if (panfrost_has_hw_feature(pfdev, HW_FEATURE_3BIT_EXT_RW_L2_MMU_CONFIG)) in panfrost_gpu_init_quirks()
137 gpu_write(pfdev, GPU_L2_MMU_CONFIG, quirks); in panfrost_gpu_init_quirks()
140 if ((panfrost_model_eq(pfdev, 0x860) || panfrost_model_eq(pfdev, 0x880)) && in panfrost_gpu_init_quirks()
141 pfdev->features.revision >= 0x2000) in panfrost_gpu_init_quirks()
143 else if (panfrost_model_eq(pfdev, 0x6000) && in panfrost_gpu_init_quirks()
144 pfdev->features.coherency_features == COHERENCY_ACE) in panfrost_gpu_init_quirks()
149 gpu_write(pfdev, GPU_JM_CONFIG, quirks); in panfrost_gpu_init_quirks()
152 if (pfdev->comp->vendor_quirk) in panfrost_gpu_init_quirks()
153 pfdev->comp->vendor_quirk(pfdev); in panfrost_gpu_init_quirks()
212 static void panfrost_gpu_init_features(struct panfrost_device *pfdev) in panfrost_gpu_init_features() argument
221 pfdev->features.l2_features = gpu_read(pfdev, GPU_L2_FEATURES); in panfrost_gpu_init_features()
222 pfdev->features.core_features = gpu_read(pfdev, GPU_CORE_FEATURES); in panfrost_gpu_init_features()
223 pfdev->features.tiler_features = gpu_read(pfdev, GPU_TILER_FEATURES); in panfrost_gpu_init_features()
224 pfdev->features.mem_features = gpu_read(pfdev, GPU_MEM_FEATURES); in panfrost_gpu_init_features()
225 pfdev->features.mmu_features = gpu_read(pfdev, GPU_MMU_FEATURES); in panfrost_gpu_init_features()
226 pfdev->features.thread_features = gpu_read(pfdev, GPU_THREAD_FEATURES); in panfrost_gpu_init_features()
227 pfdev->features.max_threads = gpu_read(pfdev, GPU_THREAD_MAX_THREADS); in panfrost_gpu_init_features()
228 pfdev->features.thread_max_workgroup_sz = gpu_read(pfdev, GPU_THREAD_MAX_WORKGROUP_SIZE); in panfrost_gpu_init_features()
229 pfdev->features.thread_max_barrier_sz = gpu_read(pfdev, GPU_THREAD_MAX_BARRIER_SIZE); in panfrost_gpu_init_features()
230 pfdev->features.coherency_features = gpu_read(pfdev, GPU_COHERENCY_FEATURES); in panfrost_gpu_init_features()
231 pfdev->features.afbc_features = gpu_read(pfdev, GPU_AFBC_FEATURES); in panfrost_gpu_init_features()
233 pfdev->features.texture_features[i] = gpu_read(pfdev, GPU_TEXTURE_FEATURES(i)); in panfrost_gpu_init_features()
235 pfdev->features.as_present = gpu_read(pfdev, GPU_AS_PRESENT); in panfrost_gpu_init_features()
237 pfdev->features.js_present = gpu_read(pfdev, GPU_JS_PRESENT); in panfrost_gpu_init_features()
238 num_js = hweight32(pfdev->features.js_present); in panfrost_gpu_init_features()
240 pfdev->features.js_features[i] = gpu_read(pfdev, GPU_JS_FEATURES(i)); in panfrost_gpu_init_features()
242 pfdev->features.shader_present = gpu_read(pfdev, GPU_SHADER_PRESENT_LO); in panfrost_gpu_init_features()
243 pfdev->features.shader_present |= (u64)gpu_read(pfdev, GPU_SHADER_PRESENT_HI) << 32; in panfrost_gpu_init_features()
245 pfdev->features.tiler_present = gpu_read(pfdev, GPU_TILER_PRESENT_LO); in panfrost_gpu_init_features()
246 pfdev->features.tiler_present |= (u64)gpu_read(pfdev, GPU_TILER_PRESENT_HI) << 32; in panfrost_gpu_init_features()
248 pfdev->features.l2_present = gpu_read(pfdev, GPU_L2_PRESENT_LO); in panfrost_gpu_init_features()
249 pfdev->features.l2_present |= (u64)gpu_read(pfdev, GPU_L2_PRESENT_HI) << 32; in panfrost_gpu_init_features()
250 pfdev->features.nr_core_groups = hweight64(pfdev->features.l2_present); in panfrost_gpu_init_features()
252 pfdev->features.stack_present = gpu_read(pfdev, GPU_STACK_PRESENT_LO); in panfrost_gpu_init_features()
253 pfdev->features.stack_present |= (u64)gpu_read(pfdev, GPU_STACK_PRESENT_HI) << 32; in panfrost_gpu_init_features()
255 pfdev->features.thread_tls_alloc = gpu_read(pfdev, GPU_THREAD_TLS_ALLOC); in panfrost_gpu_init_features()
257 gpu_id = gpu_read(pfdev, GPU_ID); in panfrost_gpu_init_features()
258 pfdev->features.revision = gpu_id & 0xffff; in panfrost_gpu_init_features()
259 pfdev->features.id = gpu_id >> 16; in panfrost_gpu_init_features()
264 if (pfdev->features.id == 0x6956) in panfrost_gpu_init_features()
265 pfdev->features.id = 0x0600; in panfrost_gpu_init_features()
267 major = (pfdev->features.revision >> 12) & 0xf; in panfrost_gpu_init_features()
268 minor = (pfdev->features.revision >> 4) & 0xff; in panfrost_gpu_init_features()
269 status = pfdev->features.revision & 0xf; in panfrost_gpu_init_features()
270 rev = pfdev->features.revision; in panfrost_gpu_init_features()
272 gpu_id = pfdev->features.id; in panfrost_gpu_init_features()
277 if (!panfrost_model_eq(pfdev, model->id)) in panfrost_gpu_init_features()
297 bitmap_from_u64(pfdev->features.hw_features, hw_feat); in panfrost_gpu_init_features()
298 bitmap_from_u64(pfdev->features.hw_issues, hw_issues); in panfrost_gpu_init_features()
300 dev_info(pfdev->dev, "mali-%s id 0x%x major 0x%x minor 0x%x status 0x%x", in panfrost_gpu_init_features()
302 dev_info(pfdev->dev, "features: %64pb, issues: %64pb", in panfrost_gpu_init_features()
303 pfdev->features.hw_features, in panfrost_gpu_init_features()
304 pfdev->features.hw_issues); in panfrost_gpu_init_features()
306 …dev_info(pfdev->dev, "Features: L2:0x%08x Shader:0x%08x Tiler:0x%08x Mem:0x%0x MMU:0x%08x AS:0x%x … in panfrost_gpu_init_features()
307 pfdev->features.l2_features, in panfrost_gpu_init_features()
308 pfdev->features.core_features, in panfrost_gpu_init_features()
309 pfdev->features.tiler_features, in panfrost_gpu_init_features()
310 pfdev->features.mem_features, in panfrost_gpu_init_features()
311 pfdev->features.mmu_features, in panfrost_gpu_init_features()
312 pfdev->features.as_present, in panfrost_gpu_init_features()
313 pfdev->features.js_present); in panfrost_gpu_init_features()
315 dev_info(pfdev->dev, "shader_present=0x%0llx l2_present=0x%0llx", in panfrost_gpu_init_features()
316 pfdev->features.shader_present, pfdev->features.l2_present); in panfrost_gpu_init_features()
319 void panfrost_gpu_power_on(struct panfrost_device *pfdev) in panfrost_gpu_power_on() argument
324 panfrost_gpu_init_quirks(pfdev); in panfrost_gpu_power_on()
327 gpu_write(pfdev, L2_PWRON_LO, pfdev->features.l2_present); in panfrost_gpu_power_on()
328 ret = readl_relaxed_poll_timeout(pfdev->iomem + L2_READY_LO, in panfrost_gpu_power_on()
329 val, val == pfdev->features.l2_present, 100, 20000); in panfrost_gpu_power_on()
331 dev_err(pfdev->dev, "error powering up gpu L2"); in panfrost_gpu_power_on()
333 gpu_write(pfdev, SHADER_PWRON_LO, pfdev->features.shader_present); in panfrost_gpu_power_on()
334 ret = readl_relaxed_poll_timeout(pfdev->iomem + SHADER_READY_LO, in panfrost_gpu_power_on()
335 val, val == pfdev->features.shader_present, 100, 20000); in panfrost_gpu_power_on()
337 dev_err(pfdev->dev, "error powering up gpu shader"); in panfrost_gpu_power_on()
339 gpu_write(pfdev, TILER_PWRON_LO, pfdev->features.tiler_present); in panfrost_gpu_power_on()
340 ret = readl_relaxed_poll_timeout(pfdev->iomem + TILER_READY_LO, in panfrost_gpu_power_on()
341 val, val == pfdev->features.tiler_present, 100, 1000); in panfrost_gpu_power_on()
343 dev_err(pfdev->dev, "error powering up gpu tiler"); in panfrost_gpu_power_on()
346 void panfrost_gpu_power_off(struct panfrost_device *pfdev) in panfrost_gpu_power_off() argument
348 gpu_write(pfdev, TILER_PWROFF_LO, 0); in panfrost_gpu_power_off()
349 gpu_write(pfdev, SHADER_PWROFF_LO, 0); in panfrost_gpu_power_off()
350 gpu_write(pfdev, L2_PWROFF_LO, 0); in panfrost_gpu_power_off()
353 int panfrost_gpu_init(struct panfrost_device *pfdev) in panfrost_gpu_init() argument
357 err = panfrost_gpu_soft_reset(pfdev); in panfrost_gpu_init()
361 panfrost_gpu_init_features(pfdev); in panfrost_gpu_init()
363 dma_set_mask_and_coherent(pfdev->dev, in panfrost_gpu_init()
364 DMA_BIT_MASK(FIELD_GET(0xff00, pfdev->features.mmu_features))); in panfrost_gpu_init()
365 dma_set_max_seg_size(pfdev->dev, UINT_MAX); in panfrost_gpu_init()
367 irq = platform_get_irq_byname(to_platform_device(pfdev->dev), "gpu"); in panfrost_gpu_init()
371 err = devm_request_irq(pfdev->dev, irq, panfrost_gpu_irq_handler, in panfrost_gpu_init()
372 IRQF_SHARED, KBUILD_MODNAME "-gpu", pfdev); in panfrost_gpu_init()
374 dev_err(pfdev->dev, "failed to request gpu irq"); in panfrost_gpu_init()
378 panfrost_gpu_power_on(pfdev); in panfrost_gpu_init()
383 void panfrost_gpu_fini(struct panfrost_device *pfdev) in panfrost_gpu_fini() argument
385 panfrost_gpu_power_off(pfdev); in panfrost_gpu_fini()
388 u32 panfrost_gpu_get_latest_flush_id(struct panfrost_device *pfdev) in panfrost_gpu_get_latest_flush_id() argument
392 if (panfrost_has_hw_feature(pfdev, HW_FEATURE_FLUSH_REDUCTION)) { in panfrost_gpu_get_latest_flush_id()
394 if (pm_runtime_get_if_in_use(pfdev->dev)) { in panfrost_gpu_get_latest_flush_id()
395 flush_id = gpu_read(pfdev, GPU_LATEST_FLUSH_ID); in panfrost_gpu_get_latest_flush_id()
396 pm_runtime_put(pfdev->dev); in panfrost_gpu_get_latest_flush_id()