Lines Matching full:dart

3  * Apple DART (Device Address Resolution Table) IOMMU driver
91 * Private structure associated with each DART device.
97 * @clks: clocks associated with this DART
99 * @lock: lock for hardware operations involving this dart
100 * @pgsize: pagesize supported by this DART
101 * @supports_bypass: indicates if this DART supports bypass mode
135 * and never changed again afterwards. Devices with different dart pointers
138 * @dart dart pointer
142 struct apple_dart *dart; member
146 struct apple_dart *dart; member
151 * This structure is attached to each iommu domain handled by a DART.
191 i < MAX_DARTS_PER_DEVICE && stream_map->dart; \
209 stream_map->dart->regs + DART_TCR(sid)); in apple_dart_hw_enable_translation()
217 writel(0, stream_map->dart->regs + DART_TCR(sid)); in apple_dart_hw_disable_dma()
225 WARN_ON(!stream_map->dart->supports_bypass); in apple_dart_hw_enable_bypass()
228 stream_map->dart->regs + DART_TCR(sid)); in apple_dart_hw_enable_bypass()
239 stream_map->dart->regs + DART_TTBR(sid, idx)); in apple_dart_hw_set_ttbr()
248 writel(0, stream_map->dart->regs + DART_TTBR(sid, idx)); in apple_dart_hw_clear_ttbr()
268 spin_lock_irqsave(&stream_map->dart->lock, flags); in apple_dart_hw_stream_command()
270 writel(stream_map->sidmap, stream_map->dart->regs + DART_STREAM_SELECT); in apple_dart_hw_stream_command()
271 writel(command, stream_map->dart->regs + DART_STREAM_COMMAND); in apple_dart_hw_stream_command()
274 stream_map->dart->regs + DART_STREAM_COMMAND, command_reg, in apple_dart_hw_stream_command()
278 spin_unlock_irqrestore(&stream_map->dart->lock, flags); in apple_dart_hw_stream_command()
281 dev_err(stream_map->dart->dev, in apple_dart_hw_stream_command()
297 static int apple_dart_hw_reset(struct apple_dart *dart) in apple_dart_hw_reset() argument
302 config = readl(dart->regs + DART_CONFIG); in apple_dart_hw_reset()
304 dev_err(dart->dev, "DART is locked down until reboot: %08x\n", in apple_dart_hw_reset()
309 stream_map.dart = dart; in apple_dart_hw_reset()
315 writel(DART_STREAM_ALL, dart->regs + DART_STREAMS_ENABLE); in apple_dart_hw_reset()
318 writel(readl(dart->regs + DART_ERROR), dart->regs + DART_ERROR); in apple_dart_hw_reset()
330 stream_map.dart = domain_stream_map->dart; in apple_dart_domain_flush_tlb()
413 struct apple_dart *dart = cfg->stream_maps[0].dart; in apple_dart_finalize_domain() local
424 dart_domain->stream_maps[i].dart = cfg->stream_maps[i].dart; in apple_dart_finalize_domain()
430 .pgsize_bitmap = dart->pgsize, in apple_dart_finalize_domain()
432 .oas = dart->hw->oas, in apple_dart_finalize_domain()
434 .iommu_dev = dart->dev, in apple_dart_finalize_domain()
438 alloc_io_pgtable_ops(dart->hw->fmt, &pgtbl_cfg, domain); in apple_dart_finalize_domain()
464 if (domain_maps[i].dart != master_maps[i].dart) in apple_dart_mod_streams()
469 if (!domain_maps[i].dart) in apple_dart_mod_streams()
504 if (cfg->stream_maps[0].dart->force_bypass && in apple_dart_attach_dev()
507 if (!cfg->stream_maps[0].dart->supports_bypass && in apple_dart_attach_dev()
565 dev, stream_map->dart->dev, in apple_dart_probe_device()
568 return &cfg->stream_maps[0].dart->iommu; in apple_dart_probe_device()
614 struct apple_dart *dart = platform_get_drvdata(iommu_pdev); in apple_dart_of_xlate() local
628 cfg_dart = cfg->stream_maps[0].dart; in apple_dart_of_xlate()
630 if (cfg_dart->supports_bypass != dart->supports_bypass) in apple_dart_of_xlate()
632 if (cfg_dart->force_bypass != dart->force_bypass) in apple_dart_of_xlate()
634 if (cfg_dart->pgsize != dart->pgsize) in apple_dart_of_xlate()
639 if (cfg->stream_maps[i].dart == dart) { in apple_dart_of_xlate()
645 if (!cfg->stream_maps[i].dart) { in apple_dart_of_xlate()
646 cfg->stream_maps[i].dart = dart; in apple_dart_of_xlate()
667 stream_map->dart->sid2group[sid] = NULL; in apple_dart_release_group()
687 stream_map->dart->sid2group[sid]; in apple_dart_device_group()
725 stream_map->dart->sid2group[sid] = group; in apple_dart_device_group()
738 if (cfg->stream_maps[0].dart->force_bypass) in apple_dart_def_domain_type()
740 if (!cfg->stream_maps[0].dart->supports_bypass) in apple_dart_def_domain_type()
779 .pgsize_bitmap = -1UL, /* Restricted during dart probe */
796 struct apple_dart *dart = dev; in apple_dart_irq() local
798 u32 error = readl(dart->regs + DART_ERROR); in apple_dart_irq()
800 u32 addr_lo = readl(dart->regs + DART_ERROR_ADDR_LO); in apple_dart_irq()
801 u32 addr_hi = readl(dart->regs + DART_ERROR_ADDR_HI); in apple_dart_irq()
823 dart->dev, in apple_dart_irq()
827 writel(error, dart->regs + DART_ERROR); in apple_dart_irq()
836 struct apple_dart *dart; in apple_dart_probe() local
839 dart = devm_kzalloc(dev, sizeof(*dart), GFP_KERNEL); in apple_dart_probe()
840 if (!dart) in apple_dart_probe()
843 dart->dev = dev; in apple_dart_probe()
844 dart->hw = of_device_get_match_data(dev); in apple_dart_probe()
845 spin_lock_init(&dart->lock); in apple_dart_probe()
847 dart->regs = devm_platform_get_and_ioremap_resource(pdev, 0, &res); in apple_dart_probe()
848 if (IS_ERR(dart->regs)) in apple_dart_probe()
849 return PTR_ERR(dart->regs); in apple_dart_probe()
856 dart->irq = platform_get_irq(pdev, 0); in apple_dart_probe()
857 if (dart->irq < 0) in apple_dart_probe()
860 ret = devm_clk_bulk_get_all(dev, &dart->clks); in apple_dart_probe()
863 dart->num_clks = ret; in apple_dart_probe()
865 ret = clk_bulk_prepare_enable(dart->num_clks, dart->clks); in apple_dart_probe()
869 ret = apple_dart_hw_reset(dart); in apple_dart_probe()
873 dart_params[0] = readl(dart->regs + DART_PARAMS1); in apple_dart_probe()
874 dart_params[1] = readl(dart->regs + DART_PARAMS2); in apple_dart_probe()
875 dart->pgsize = 1 << FIELD_GET(DART_PARAMS_PAGE_SHIFT, dart_params[0]); in apple_dart_probe()
876 dart->supports_bypass = dart_params[1] & DART_PARAMS_BYPASS_SUPPORT; in apple_dart_probe()
877 dart->force_bypass = dart->pgsize > PAGE_SIZE; in apple_dart_probe()
879 ret = request_irq(dart->irq, apple_dart_irq, IRQF_SHARED, in apple_dart_probe()
880 "apple-dart fault handler", dart); in apple_dart_probe()
884 platform_set_drvdata(pdev, dart); in apple_dart_probe()
886 ret = iommu_device_sysfs_add(&dart->iommu, dev, NULL, "apple-dart.%s", in apple_dart_probe()
891 ret = iommu_device_register(&dart->iommu, &apple_dart_iommu_ops, dev); in apple_dart_probe()
897 "DART [pagesize %x, bypass support: %d, bypass forced: %d] initialized\n", in apple_dart_probe()
898 dart->pgsize, dart->supports_bypass, dart->force_bypass); in apple_dart_probe()
902 iommu_device_sysfs_remove(&dart->iommu); in apple_dart_probe()
904 free_irq(dart->irq, dart); in apple_dart_probe()
906 clk_bulk_disable_unprepare(dart->num_clks, dart->clks); in apple_dart_probe()
913 struct apple_dart *dart = platform_get_drvdata(pdev); in apple_dart_remove() local
915 apple_dart_hw_reset(dart); in apple_dart_remove()
916 free_irq(dart->irq, dart); in apple_dart_remove()
918 iommu_device_unregister(&dart->iommu); in apple_dart_remove()
919 iommu_device_sysfs_remove(&dart->iommu); in apple_dart_remove()
921 clk_bulk_disable_unprepare(dart->num_clks, dart->clks); in apple_dart_remove()
936 { .compatible = "apple,t8103-dart", .data = &apple_dart_hw_t8103 },
937 { .compatible = "apple,t6000-dart", .data = &apple_dart_hw_t6000 },
944 .name = "apple-dart",
954 MODULE_DESCRIPTION("IOMMU API for Apple's DART");