Lines Matching +full:resume +full:- +full:offset

1 // SPDX-License-Identifier: GPL-2.0 OR MIT
2 /* Copyright 2017-2019 Qiang Yu <yuq825@gmail.com> */
8 #include <linux/dma-mapping.h>
25 int offset[lima_gpu_num]; member
29 int (*resume)(struct lima_ip *ip); member
41 .offset = { \
47 .resume = lima_##func##_resume, \
54 LIMA_IP_DESC(l2_cache1, false, true, -1, 0x01000, l2_cache, NULL),
55 LIMA_IP_DESC(l2_cache2, false, false, -1, 0x11000, l2_cache, NULL),
61 LIMA_IP_DESC(pp4, false, false, -1, 0x28000, pp, "pp4"),
62 LIMA_IP_DESC(pp5, false, false, -1, 0x2A000, pp, "pp5"),
63 LIMA_IP_DESC(pp6, false, false, -1, 0x2C000, pp, "pp6"),
64 LIMA_IP_DESC(pp7, false, false, -1, 0x2E000, pp, "pp7"),
70 LIMA_IP_DESC(ppmmu4, false, false, -1, 0x1C000, mmu, "ppmmu4"),
71 LIMA_IP_DESC(ppmmu5, false, false, -1, 0x1D000, mmu, "ppmmu5"),
72 LIMA_IP_DESC(ppmmu6, false, false, -1, 0x1E000, mmu, "ppmmu6"),
73 LIMA_IP_DESC(ppmmu7, false, false, -1, 0x1F000, mmu, "ppmmu7"),
74 LIMA_IP_DESC(dlbu, false, true, -1, 0x14000, dlbu, NULL),
75 LIMA_IP_DESC(bcast, false, true, -1, 0x13000, bcast, NULL),
76 LIMA_IP_DESC(pp_bcast, false, true, -1, 0x16000, pp_bcast, "pp"),
77 LIMA_IP_DESC(ppmmu_bcast, false, true, -1, 0x15000, mmu, NULL),
82 return lima_ip_desc[ip->id].name; in lima_ip_name()
89 err = clk_prepare_enable(dev->clk_bus); in lima_clk_enable()
93 err = clk_prepare_enable(dev->clk_gpu); in lima_clk_enable()
97 if (dev->reset) { in lima_clk_enable()
98 err = reset_control_deassert(dev->reset); in lima_clk_enable()
100 dev_err(dev->dev, in lima_clk_enable()
109 clk_disable_unprepare(dev->clk_gpu); in lima_clk_enable()
111 clk_disable_unprepare(dev->clk_bus); in lima_clk_enable()
117 if (dev->reset) in lima_clk_disable()
118 reset_control_assert(dev->reset); in lima_clk_disable()
119 clk_disable_unprepare(dev->clk_gpu); in lima_clk_disable()
120 clk_disable_unprepare(dev->clk_bus); in lima_clk_disable()
127 dev->clk_bus = devm_clk_get(dev->dev, "bus"); in lima_clk_init()
128 if (IS_ERR(dev->clk_bus)) { in lima_clk_init()
129 err = PTR_ERR(dev->clk_bus); in lima_clk_init()
130 if (err != -EPROBE_DEFER) in lima_clk_init()
131 dev_err(dev->dev, "get bus clk failed %d\n", err); in lima_clk_init()
132 dev->clk_bus = NULL; in lima_clk_init()
136 dev->clk_gpu = devm_clk_get(dev->dev, "core"); in lima_clk_init()
137 if (IS_ERR(dev->clk_gpu)) { in lima_clk_init()
138 err = PTR_ERR(dev->clk_gpu); in lima_clk_init()
139 if (err != -EPROBE_DEFER) in lima_clk_init()
140 dev_err(dev->dev, "get core clk failed %d\n", err); in lima_clk_init()
141 dev->clk_gpu = NULL; in lima_clk_init()
145 dev->reset = devm_reset_control_array_get_optional_shared(dev->dev); in lima_clk_init()
146 if (IS_ERR(dev->reset)) { in lima_clk_init()
147 err = PTR_ERR(dev->reset); in lima_clk_init()
148 if (err != -EPROBE_DEFER) in lima_clk_init()
149 dev_err(dev->dev, "get reset controller failed %d\n", in lima_clk_init()
151 dev->reset = NULL; in lima_clk_init()
167 if (!dev->regulator) in lima_regulator_enable()
170 ret = regulator_enable(dev->regulator); in lima_regulator_enable()
172 dev_err(dev->dev, "failed to enable regulator: %d\n", ret); in lima_regulator_enable()
181 if (dev->regulator) in lima_regulator_disable()
182 regulator_disable(dev->regulator); in lima_regulator_disable()
189 dev->regulator = devm_regulator_get_optional(dev->dev, "mali"); in lima_regulator_init()
190 if (IS_ERR(dev->regulator)) { in lima_regulator_init()
191 ret = PTR_ERR(dev->regulator); in lima_regulator_init()
192 dev->regulator = NULL; in lima_regulator_init()
193 if (ret == -ENODEV) in lima_regulator_init()
195 if (ret != -EPROBE_DEFER) in lima_regulator_init()
196 dev_err(dev->dev, "failed to get regulator: %d\n", ret); in lima_regulator_init()
210 struct platform_device *pdev = to_platform_device(dev->dev); in lima_init_ip()
212 struct lima_ip *ip = dev->ip + index; in lima_init_ip()
213 const char *irq_name = desc->irq_name; in lima_init_ip()
214 int offset = desc->offset[dev->id]; in lima_init_ip() local
215 bool must = desc->must_have[dev->id]; in lima_init_ip()
218 if (offset < 0) in lima_init_ip()
221 ip->dev = dev; in lima_init_ip()
222 ip->id = index; in lima_init_ip()
223 ip->iomem = dev->iomem + offset; in lima_init_ip()
229 ip->irq = err; in lima_init_ip()
232 err = desc->init(ip); in lima_init_ip()
234 ip->present = true; in lima_init_ip()
245 struct lima_ip *ip = ldev->ip + index; in lima_fini_ip()
247 if (ip->present) in lima_fini_ip()
248 desc->fini(ip); in lima_fini_ip()
254 struct lima_ip *ip = ldev->ip + index; in lima_resume_ip()
257 if (ip->present) in lima_resume_ip()
258 ret = desc->resume(ip); in lima_resume_ip()
266 struct lima_ip *ip = ldev->ip + index; in lima_suspend_ip()
268 if (ip->present) in lima_suspend_ip()
269 desc->suspend(ip); in lima_suspend_ip()
274 struct lima_sched_pipe *pipe = dev->pipe + lima_pipe_gp; in lima_init_gp_pipe()
277 pipe->ldev = dev; in lima_init_gp_pipe()
283 pipe->l2_cache[pipe->num_l2_cache++] = dev->ip + lima_ip_l2_cache0; in lima_init_gp_pipe()
284 pipe->mmu[pipe->num_mmu++] = dev->ip + lima_ip_gpmmu; in lima_init_gp_pipe()
285 pipe->processor[pipe->num_processor++] = dev->ip + lima_ip_gp; in lima_init_gp_pipe()
298 struct lima_sched_pipe *pipe = dev->pipe + lima_pipe_gp; in lima_fini_gp_pipe()
306 struct lima_sched_pipe *pipe = dev->pipe + lima_pipe_pp; in lima_init_pp_pipe()
309 pipe->ldev = dev; in lima_init_pp_pipe()
316 struct lima_ip *pp = dev->ip + lima_ip_pp0 + i; in lima_init_pp_pipe()
317 struct lima_ip *ppmmu = dev->ip + lima_ip_ppmmu0 + i; in lima_init_pp_pipe()
320 if (dev->id == lima_gpu_mali400) in lima_init_pp_pipe()
321 l2_cache = dev->ip + lima_ip_l2_cache0; in lima_init_pp_pipe()
323 l2_cache = dev->ip + lima_ip_l2_cache1 + (i >> 2); in lima_init_pp_pipe()
325 if (pp->present && ppmmu->present && l2_cache->present) { in lima_init_pp_pipe()
326 pipe->mmu[pipe->num_mmu++] = ppmmu; in lima_init_pp_pipe()
327 pipe->processor[pipe->num_processor++] = pp; in lima_init_pp_pipe()
328 if (!pipe->l2_cache[i >> 2]) in lima_init_pp_pipe()
329 pipe->l2_cache[pipe->num_l2_cache++] = l2_cache; in lima_init_pp_pipe()
333 if (dev->ip[lima_ip_bcast].present) { in lima_init_pp_pipe()
334 pipe->bcast_processor = dev->ip + lima_ip_pp_bcast; in lima_init_pp_pipe()
335 pipe->bcast_mmu = dev->ip + lima_ip_ppmmu_bcast; in lima_init_pp_pipe()
349 struct lima_sched_pipe *pipe = dev->pipe + lima_pipe_pp; in lima_fini_pp_pipe()
357 struct platform_device *pdev = to_platform_device(ldev->dev); in lima_device_init()
360 dma_set_coherent_mask(ldev->dev, DMA_BIT_MASK(32)); in lima_device_init()
361 dma_set_max_seg_size(ldev->dev, UINT_MAX); in lima_device_init()
371 ldev->empty_vm = lima_vm_create(ldev); in lima_device_init()
372 if (!ldev->empty_vm) { in lima_device_init()
373 err = -ENOMEM; in lima_device_init()
377 ldev->va_start = 0; in lima_device_init()
378 if (ldev->id == lima_gpu_mali450) { in lima_device_init()
379 ldev->va_end = LIMA_VA_RESERVE_START; in lima_device_init()
380 ldev->dlbu_cpu = dma_alloc_wc( in lima_device_init()
381 ldev->dev, LIMA_PAGE_SIZE, in lima_device_init()
382 &ldev->dlbu_dma, GFP_KERNEL | __GFP_NOWARN); in lima_device_init()
383 if (!ldev->dlbu_cpu) { in lima_device_init()
384 err = -ENOMEM; in lima_device_init()
388 ldev->va_end = LIMA_VA_RESERVE_END; in lima_device_init()
390 ldev->iomem = devm_platform_ioremap_resource(pdev, 0); in lima_device_init()
391 if (IS_ERR(ldev->iomem)) { in lima_device_init()
392 dev_err(ldev->dev, "fail to ioremap iomem\n"); in lima_device_init()
393 err = PTR_ERR(ldev->iomem); in lima_device_init()
411 ldev->dump.magic = LIMA_DUMP_MAGIC; in lima_device_init()
412 ldev->dump.version_major = LIMA_DUMP_MAJOR; in lima_device_init()
413 ldev->dump.version_minor = LIMA_DUMP_MINOR; in lima_device_init()
414 INIT_LIST_HEAD(&ldev->error_task_list); in lima_device_init()
415 mutex_init(&ldev->error_task_list_lock); in lima_device_init()
417 dev_info(ldev->dev, "bus rate = %lu\n", clk_get_rate(ldev->clk_bus)); in lima_device_init()
418 dev_info(ldev->dev, "mod rate = %lu", clk_get_rate(ldev->clk_gpu)); in lima_device_init()
425 while (--i >= 0) in lima_device_init()
428 if (ldev->dlbu_cpu) in lima_device_init()
429 dma_free_wc(ldev->dev, LIMA_PAGE_SIZE, in lima_device_init()
430 ldev->dlbu_cpu, ldev->dlbu_dma); in lima_device_init()
432 lima_vm_put(ldev->empty_vm); in lima_device_init()
445 list_for_each_entry_safe(et, tmp, &ldev->error_task_list, list) { in lima_device_fini()
446 list_del(&et->list); in lima_device_fini()
449 mutex_destroy(&ldev->error_task_list_lock); in lima_device_fini()
454 for (i = lima_ip_num - 1; i >= 0; i--) in lima_device_fini()
457 if (ldev->dlbu_cpu) in lima_device_fini()
458 dma_free_wc(ldev->dev, LIMA_PAGE_SIZE, in lima_device_fini()
459 ldev->dlbu_cpu, ldev->dlbu_dma); in lima_device_fini()
461 lima_vm_put(ldev->empty_vm); in lima_device_fini()
475 dev_err(dev, "resume clk fail %d\n", err); in lima_device_resume()
481 dev_err(dev, "resume regulator fail %d\n", err); in lima_device_resume()
488 dev_err(dev, "resume ip %d fail\n", i); in lima_device_resume()
493 err = lima_devfreq_resume(&ldev->devfreq); in lima_device_resume()
495 dev_err(dev, "devfreq resume fail\n"); in lima_device_resume()
502 while (--i >= 0) in lima_device_resume()
517 if (atomic_read(&ldev->pipe[i].base.credit_count)) in lima_device_suspend()
518 return -EBUSY; in lima_device_suspend()
521 err = lima_devfreq_suspend(&ldev->devfreq); in lima_device_suspend()
527 for (i = lima_ip_num - 1; i >= 0; i--) in lima_device_suspend()