1 /* SPDX-License-Identifier: GPL-2.0-only OR MIT */ 2 /* 3 * Apple SART device driver 4 * Copyright (C) The Asahi Linux Contributors 5 * 6 * Apple SART is a simple address filter for DMA transactions. 7 * Regions of physical memory must be added to the SART's allow 8 * list before any DMA can target these. Unlike a proper 9 * IOMMU no remapping can be done. 10 */ 11 12 #ifndef _LINUX_SOC_APPLE_SART_H_ 13 #define _LINUX_SOC_APPLE_SART_H_ 14 15 #include <linux/device.h> 16 #include <linux/err.h> 17 #include <linux/types.h> 18 19 struct apple_sart; 20 21 /* 22 * Get a reference to the SART attached to dev. 23 * 24 * Looks for the phandle reference in apple,sart and returns a pointer 25 * to the corresponding apple_sart struct to be used with 26 * apple_sart_add_allowed_region and apple_sart_remove_allowed_region. 27 */ 28 struct apple_sart *devm_apple_sart_get(struct device *dev); 29 30 /* 31 * Adds the region [paddr, paddr+size] to the DMA allow list. 32 * 33 * @sart: SART reference 34 * @paddr: Start address of the region to be used for DMA 35 * @size: Size of the region to be used for DMA. 36 */ 37 int apple_sart_add_allowed_region(struct apple_sart *sart, phys_addr_t paddr, 38 size_t size); 39 40 /* 41 * Removes the region [paddr, paddr+size] from the DMA allow list. 42 * 43 * Note that exact same paddr and size used for apple_sart_add_allowed_region 44 * have to be passed. 45 * 46 * @sart: SART reference 47 * @paddr: Start address of the region no longer used for DMA 48 * @size: Size of the region no longer used for DMA. 49 */ 50 int apple_sart_remove_allowed_region(struct apple_sart *sart, phys_addr_t paddr, 51 size_t size); 52 53 #endif /* _LINUX_SOC_APPLE_SART_H_ */ 54