Lines Matching refs:host

303 static void host1x_setup_virtualization_tables(struct host1x *host)  in host1x_setup_virtualization_tables()  argument
305 const struct host1x_info *info = host->info; in host1x_setup_virtualization_tables()
314 host1x_hypervisor_writel(host, entry->offset, entry->base); in host1x_setup_virtualization_tables()
315 host1x_hypervisor_writel(host, entry->limit, entry->base + 4); in host1x_setup_virtualization_tables()
320 host1x_hypervisor_writel(host, 0xff, info->streamid_vm_table.base + 4 * i); in host1x_setup_virtualization_tables()
325 host1x_hypervisor_writel(host, 0xff, info->classid_vm_table.base + 4 * i); in host1x_setup_virtualization_tables()
330 host1x_hypervisor_writel(host, 0x1, info->mmio_vm_table.base + 4 * i); in host1x_setup_virtualization_tables()
377 static struct iommu_domain *host1x_iommu_attach(struct host1x *host) in host1x_iommu_attach() argument
379 struct iommu_domain *domain = iommu_get_domain_for_dev(host->dev); in host1x_iommu_attach()
383 if (host->dev->archdata.mapping) { in host1x_iommu_attach()
385 to_dma_iommu_mapping(host->dev); in host1x_iommu_attach()
386 arm_iommu_detach_device(host->dev); in host1x_iommu_attach()
389 domain = iommu_get_domain_for_dev(host->dev); in host1x_iommu_attach()
403 if (!host1x_wants_iommu(host) || domain) in host1x_iommu_attach()
406 host->group = iommu_group_get(host->dev); in host1x_iommu_attach()
407 if (host->group) { in host1x_iommu_attach()
416 host->domain = iommu_paging_domain_alloc(host->dev); in host1x_iommu_attach()
417 if (IS_ERR(host->domain)) { in host1x_iommu_attach()
418 err = PTR_ERR(host->domain); in host1x_iommu_attach()
419 host->domain = NULL; in host1x_iommu_attach()
423 err = iommu_attach_group(host->domain, host->group); in host1x_iommu_attach()
431 geometry = &host->domain->geometry; in host1x_iommu_attach()
432 start = geometry->aperture_start & host->info->dma_mask; in host1x_iommu_attach()
433 end = geometry->aperture_end & host->info->dma_mask; in host1x_iommu_attach()
435 order = __ffs(host->domain->pgsize_bitmap); in host1x_iommu_attach()
436 init_iova_domain(&host->iova, 1UL << order, start >> order); in host1x_iommu_attach()
437 host->iova_end = end; in host1x_iommu_attach()
439 domain = host->domain; in host1x_iommu_attach()
445 iommu_domain_free(host->domain); in host1x_iommu_attach()
446 host->domain = NULL; in host1x_iommu_attach()
450 iommu_group_put(host->group); in host1x_iommu_attach()
451 host->group = NULL; in host1x_iommu_attach()
456 static int host1x_iommu_init(struct host1x *host) in host1x_iommu_init() argument
458 u64 mask = host->info->dma_mask; in host1x_iommu_init()
462 domain = host1x_iommu_attach(host); in host1x_iommu_init()
465 dev_err(host->dev, "failed to attach to IOMMU: %d\n", err); in host1x_iommu_init()
477 if (!domain && !host->info->has_wide_gather) in host1x_iommu_init()
480 err = dma_coerce_mask_and_coherent(host->dev, mask); in host1x_iommu_init()
482 dev_err(host->dev, "failed to set DMA mask: %d\n", err); in host1x_iommu_init()
489 static void host1x_iommu_exit(struct host1x *host) in host1x_iommu_exit() argument
491 if (host->domain) { in host1x_iommu_exit()
492 put_iova_domain(&host->iova); in host1x_iommu_exit()
493 iommu_detach_group(host->domain, host->group); in host1x_iommu_exit()
495 iommu_domain_free(host->domain); in host1x_iommu_exit()
496 host->domain = NULL; in host1x_iommu_exit()
500 iommu_group_put(host->group); in host1x_iommu_exit()
501 host->group = NULL; in host1x_iommu_exit()
505 static int host1x_get_resets(struct host1x *host) in host1x_get_resets() argument
509 host->resets[0].id = "mc"; in host1x_get_resets()
510 host->resets[1].id = "host1x"; in host1x_get_resets()
511 host->nresets = ARRAY_SIZE(host->resets); in host1x_get_resets()
514 host->dev, host->nresets, host->resets); in host1x_get_resets()
516 dev_err(host->dev, "failed to get reset: %d\n", err); in host1x_get_resets()
525 struct host1x *host; in host1x_probe() local
528 host = devm_kzalloc(&pdev->dev, sizeof(*host), GFP_KERNEL); in host1x_probe()
529 if (!host) in host1x_probe()
532 host->info = of_device_get_match_data(&pdev->dev); in host1x_probe()
534 if (host->info->has_hypervisor) { in host1x_probe()
535 host->regs = devm_platform_ioremap_resource_byname(pdev, "vm"); in host1x_probe()
536 if (IS_ERR(host->regs)) in host1x_probe()
537 return PTR_ERR(host->regs); in host1x_probe()
539 host->hv_regs = devm_platform_ioremap_resource_byname(pdev, "hypervisor"); in host1x_probe()
540 if (IS_ERR(host->hv_regs)) in host1x_probe()
541 return PTR_ERR(host->hv_regs); in host1x_probe()
543 if (host->info->has_common) { in host1x_probe()
544 host->common_regs = devm_platform_ioremap_resource_byname(pdev, "common"); in host1x_probe()
545 if (IS_ERR(host->common_regs)) in host1x_probe()
546 return PTR_ERR(host->common_regs); in host1x_probe()
549 host->regs = devm_platform_ioremap_resource(pdev, 0); in host1x_probe()
550 if (IS_ERR(host->regs)) in host1x_probe()
551 return PTR_ERR(host->regs); in host1x_probe()
554 for (i = 0; i < ARRAY_SIZE(host->syncpt_irqs); i++) { in host1x_probe()
565 host->syncpt_irqs[i] = err; in host1x_probe()
568 host->num_syncpt_irqs = i; in host1x_probe()
572 host->syncpt_irqs[0] = platform_get_irq(pdev, 0); in host1x_probe()
573 if (host->syncpt_irqs[0] < 0) in host1x_probe()
574 return host->syncpt_irqs[0]; in host1x_probe()
576 host->num_syncpt_irqs = 1; in host1x_probe()
579 mutex_init(&host->devices_lock); in host1x_probe()
580 INIT_LIST_HEAD(&host->devices); in host1x_probe()
581 INIT_LIST_HEAD(&host->list); in host1x_probe()
582 host->dev = &pdev->dev; in host1x_probe()
585 platform_set_drvdata(pdev, host); in host1x_probe()
587 host->dev->dma_parms = &host->dma_parms; in host1x_probe()
588 dma_set_max_seg_size(host->dev, UINT_MAX); in host1x_probe()
590 if (host->info->init) { in host1x_probe()
591 err = host->info->init(host); in host1x_probe()
596 host->clk = devm_clk_get(&pdev->dev, NULL); in host1x_probe()
597 if (IS_ERR(host->clk)) in host1x_probe()
598 return dev_err_probe(&pdev->dev, PTR_ERR(host->clk), "failed to get clock\n"); in host1x_probe()
600 err = host1x_get_resets(host); in host1x_probe()
604 host1x_bo_cache_init(&host->cache); in host1x_probe()
606 err = host1x_iommu_init(host); in host1x_probe()
612 err = host1x_channel_list_init(&host->channel_list, in host1x_probe()
613 host->info->nb_channels); in host1x_probe()
619 err = host1x_memory_context_list_init(host); in host1x_probe()
625 err = host1x_syncpt_init(host); in host1x_probe()
631 mutex_init(&host->intr_mutex); in host1x_probe()
644 err = host1x_intr_init(host); in host1x_probe()
650 host1x_debug_init(host); in host1x_probe()
652 err = host1x_register(host); in host1x_probe()
663 host1x_unregister(host); in host1x_probe()
665 host1x_debug_deinit(host); in host1x_probe()
666 host1x_intr_deinit(host); in host1x_probe()
671 host1x_syncpt_deinit(host); in host1x_probe()
673 host1x_memory_context_list_free(&host->context_list); in host1x_probe()
675 host1x_channel_list_free(&host->channel_list); in host1x_probe()
677 host1x_iommu_exit(host); in host1x_probe()
679 host1x_bo_cache_destroy(&host->cache); in host1x_probe()
686 struct host1x *host = platform_get_drvdata(pdev); in host1x_remove() local
688 host1x_unregister(host); in host1x_remove()
689 host1x_debug_deinit(host); in host1x_remove()
693 host1x_intr_deinit(host); in host1x_remove()
694 host1x_syncpt_deinit(host); in host1x_remove()
695 host1x_memory_context_list_free(&host->context_list); in host1x_remove()
696 host1x_channel_list_free(&host->channel_list); in host1x_remove()
697 host1x_iommu_exit(host); in host1x_remove()
698 host1x_bo_cache_destroy(&host->cache); in host1x_remove()
703 struct host1x *host = dev_get_drvdata(dev); in host1x_runtime_suspend() local
706 host1x_channel_stop_all(host); in host1x_runtime_suspend()
707 host1x_intr_stop(host); in host1x_runtime_suspend()
708 host1x_syncpt_save(host); in host1x_runtime_suspend()
710 if (!host->info->skip_reset_assert) { in host1x_runtime_suspend()
711 err = reset_control_bulk_assert(host->nresets, host->resets); in host1x_runtime_suspend()
720 clk_disable_unprepare(host->clk); in host1x_runtime_suspend()
721 reset_control_bulk_release(host->nresets, host->resets); in host1x_runtime_suspend()
726 host1x_setup_virtualization_tables(host); in host1x_runtime_suspend()
727 host1x_syncpt_restore(host); in host1x_runtime_suspend()
728 host1x_intr_start(host); in host1x_runtime_suspend()
735 struct host1x *host = dev_get_drvdata(dev); in host1x_runtime_resume() local
738 err = reset_control_bulk_acquire(host->nresets, host->resets); in host1x_runtime_resume()
744 err = clk_prepare_enable(host->clk); in host1x_runtime_resume()
750 err = reset_control_bulk_deassert(host->nresets, host->resets); in host1x_runtime_resume()
756 host1x_setup_virtualization_tables(host); in host1x_runtime_resume()
757 host1x_syncpt_restore(host); in host1x_runtime_resume()
758 host1x_intr_start(host); in host1x_runtime_resume()
763 clk_disable_unprepare(host->clk); in host1x_runtime_resume()
765 reset_control_bulk_release(host->nresets, host->resets); in host1x_runtime_resume()