Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  1) /* SPDX-License-Identifier: GPL-2.0 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  2) /* iommu_common.h: UltraSparc SBUS/PCI common iommu declarations.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  3)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  4)  * Copyright (C) 1999, 2008 David S. Miller (davem@davemloft.net)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  5)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  6) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  7) #ifndef _IOMMU_COMMON_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  8) #define _IOMMU_COMMON_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  9) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) #include <linux/kernel.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) #include <linux/types.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) #include <linux/sched.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) #include <linux/mm.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) #include <linux/scatterlist.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) #include <linux/device.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) #include <linux/iommu-helper.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) #include <asm/iommu.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21)  * These give mapping size of each iommu pte/tlb.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) #define IO_PAGE_SHIFT			13
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) #define IO_PAGE_SIZE			(1UL << IO_PAGE_SHIFT)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) #define IO_PAGE_MASK			(~(IO_PAGE_SIZE-1))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) #define IO_PAGE_ALIGN(addr)		ALIGN(addr, IO_PAGE_SIZE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) #define IO_TSB_ENTRIES			(128*1024)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) #define IO_TSB_SIZE			(IO_TSB_ENTRIES * 8)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32)  * This is the hardwired shift in the iotlb tag/data parts.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) #define IOMMU_PAGE_SHIFT		13
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) #define SG_ENT_PHYS_ADDRESS(SG)	(__pa(sg_virt((SG))))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) static inline int is_span_boundary(unsigned long entry,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) 				   unsigned long shift,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) 				   unsigned long boundary_size,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) 				   struct scatterlist *outs,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) 				   struct scatterlist *sg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) 	unsigned long paddr = SG_ENT_PHYS_ADDRESS(outs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) 	int nr = iommu_num_pages(paddr, outs->dma_length + sg->length,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) 				 IO_PAGE_SIZE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) 	return iommu_is_span_boundary(entry, nr, shift, boundary_size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) #endif /* _IOMMU_COMMON_H */