Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-only OR MIT */
0002 /*
0003  * Apple SART device driver
0004  * Copyright (C) The Asahi Linux Contributors
0005  *
0006  * Apple SART is a simple address filter for DMA transactions.
0007  * Regions of physical memory must be added to the SART's allow
0008  * list before any DMA can target these. Unlike a proper
0009  * IOMMU no remapping can be done.
0010  */
0011 
0012 #ifndef _LINUX_SOC_APPLE_SART_H_
0013 #define _LINUX_SOC_APPLE_SART_H_
0014 
0015 #include <linux/device.h>
0016 #include <linux/err.h>
0017 #include <linux/types.h>
0018 
0019 struct apple_sart;
0020 
0021 /*
0022  * Get a reference to the SART attached to dev.
0023  *
0024  * Looks for the phandle reference in apple,sart and returns a pointer
0025  * to the corresponding apple_sart struct to be used with
0026  * apple_sart_add_allowed_region and apple_sart_remove_allowed_region.
0027  */
0028 struct apple_sart *devm_apple_sart_get(struct device *dev);
0029 
0030 /*
0031  * Adds the region [paddr, paddr+size] to the DMA allow list.
0032  *
0033  * @sart: SART reference
0034  * @paddr: Start address of the region to be used for DMA
0035  * @size: Size of the region to be used for DMA.
0036  */
0037 int apple_sart_add_allowed_region(struct apple_sart *sart, phys_addr_t paddr,
0038                   size_t size);
0039 
0040 /*
0041  * Removes the region [paddr, paddr+size] from the DMA allow list.
0042  *
0043  * Note that exact same paddr and size used for apple_sart_add_allowed_region
0044  * have to be passed.
0045  *
0046  * @sart: SART reference
0047  * @paddr: Start address of the region no longer used for DMA
0048  * @size: Size of the region no longer used for DMA.
0049  */
0050 int apple_sart_remove_allowed_region(struct apple_sart *sart, phys_addr_t paddr,
0051                      size_t size);
0052 
0053 #endif /* _LINUX_SOC_APPLE_SART_H_ */