13d0407baSopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-only */
23d0407baSopenharmony_ci/*
33d0407baSopenharmony_ci * Copyright (C) 2007-2008 Advanced Micro Devices, Inc.
43d0407baSopenharmony_ci * Author: Joerg Roedel <joerg.roedel@amd.com>
53d0407baSopenharmony_ci */
63d0407baSopenharmony_ci
73d0407baSopenharmony_ci#ifndef __LINUX_IOMMU_H
83d0407baSopenharmony_ci#define __LINUX_IOMMU_H
93d0407baSopenharmony_ci
103d0407baSopenharmony_ci#include <linux/scatterlist.h>
113d0407baSopenharmony_ci#include <linux/device.h>
123d0407baSopenharmony_ci#include <linux/types.h>
133d0407baSopenharmony_ci#include <linux/errno.h>
143d0407baSopenharmony_ci#include <linux/err.h>
153d0407baSopenharmony_ci#include <linux/of.h>
163d0407baSopenharmony_ci#include <linux/ioasid.h>
173d0407baSopenharmony_ci#include <uapi/linux/iommu.h>
183d0407baSopenharmony_ci
193d0407baSopenharmony_ci#define IOMMU_READ (1 << 0)
203d0407baSopenharmony_ci#define IOMMU_WRITE (1 << 1)
213d0407baSopenharmony_ci#define IOMMU_CACHE (1 << 2) /* DMA cache coherency */
223d0407baSopenharmony_ci#define IOMMU_NOEXEC (1 << 3)
233d0407baSopenharmony_ci#define IOMMU_MMIO (1 << 4) /* e.g. things like MSI doorbells */
243d0407baSopenharmony_ci/*
253d0407baSopenharmony_ci * Where the bus hardware includes a privilege level as part of its access type
263d0407baSopenharmony_ci * markings, and certain devices are capable of issuing transactions marked as
273d0407baSopenharmony_ci * either 'supervisor' or 'user', the IOMMU_PRIV flag requests that the other
283d0407baSopenharmony_ci * given permission flags only apply to accesses at the higher privilege level,
293d0407baSopenharmony_ci * and that unprivileged transactions should have as little access as possible.
303d0407baSopenharmony_ci * This would usually imply the same permissions as kernel mappings on the CPU,
313d0407baSopenharmony_ci * if the IOMMU page table format is equivalent.
323d0407baSopenharmony_ci */
333d0407baSopenharmony_ci#define IOMMU_PRIV (1 << 5)
343d0407baSopenharmony_ci/*
353d0407baSopenharmony_ci * Non-coherent masters can use this page protection flag to set cacheable
363d0407baSopenharmony_ci * memory attributes for only a transparent outer level of cache, also known as
373d0407baSopenharmony_ci * the last-level or system cache.
383d0407baSopenharmony_ci */
393d0407baSopenharmony_ci#define IOMMU_SYS_CACHE_ONLY (1 << 6)
403d0407baSopenharmony_ci/*
413d0407baSopenharmony_ci * Non-coherent masters can use this page protection flag to set cacheable
423d0407baSopenharmony_ci * memory attributes with a no write allocation cache policy for only a
433d0407baSopenharmony_ci * transparent outer level of cache, also known as the last-level or system
443d0407baSopenharmony_ci * cache.
453d0407baSopenharmony_ci */
463d0407baSopenharmony_ci#define IOMMU_SYS_CACHE_ONLY_NWA (1 << 7)
473d0407baSopenharmony_ci
483d0407baSopenharmony_ci#ifdef CONFIG_NO_GKI
493d0407baSopenharmony_ci
503d0407baSopenharmony_ci/* For shoting entire IOMMU tlb once */
513d0407baSopenharmony_ci#define IOMMU_TLB_SHOT_ENTIRE (1 << 8)
523d0407baSopenharmony_ci
533d0407baSopenharmony_ci#endif
543d0407baSopenharmony_ci
553d0407baSopenharmony_cistruct iommu_ops;
563d0407baSopenharmony_cistruct iommu_group;
573d0407baSopenharmony_cistruct bus_type;
583d0407baSopenharmony_cistruct device;
593d0407baSopenharmony_cistruct iommu_domain;
603d0407baSopenharmony_cistruct notifier_block;
613d0407baSopenharmony_cistruct iommu_sva;
623d0407baSopenharmony_cistruct iommu_fault_event;
633d0407baSopenharmony_ci
643d0407baSopenharmony_ci/* iommu fault flags */
653d0407baSopenharmony_ci#define IOMMU_FAULT_READ 0x0
663d0407baSopenharmony_ci#define IOMMU_FAULT_WRITE 0x1
673d0407baSopenharmony_ci
683d0407baSopenharmony_citypedef int (*iommu_fault_handler_t)(struct iommu_domain *, struct device *, unsigned long, int, void *);
693d0407baSopenharmony_citypedef int (*iommu_dev_fault_handler_t)(struct iommu_fault *, void *);
703d0407baSopenharmony_ci
713d0407baSopenharmony_cistruct iommu_domain_geometry {
723d0407baSopenharmony_ci    dma_addr_t aperture_start; /* First address that can be mapped    */
733d0407baSopenharmony_ci    dma_addr_t aperture_end;   /* Last address that can be mapped     */
743d0407baSopenharmony_ci    bool force_aperture;       /* DMA only allowed in mappable range? */
753d0407baSopenharmony_ci};
763d0407baSopenharmony_ci
773d0407baSopenharmony_ci/* Domain feature flags */
783d0407baSopenharmony_ci#define __IOMMU_DOMAIN_PAGING (1U << 0) /* Support for iommu_map/unmap */
793d0407baSopenharmony_ci#define IOMMU_DOMAIN_DMA_API                                                                                           \
803d0407baSopenharmony_ci    (1U << 1)                     /* Domain for use in DMA-API                                                         \
813d0407baSopenharmony_ci                 implementation              */
823d0407baSopenharmony_ci#define IOMMU_DOMAIN_PT (1U << 2) /* Domain is identity mapped   */
833d0407baSopenharmony_ci
843d0407baSopenharmony_ci/*
853d0407baSopenharmony_ci * This are the possible domain-types
863d0407baSopenharmony_ci *
873d0407baSopenharmony_ci *    IOMMU_DOMAIN_BLOCKED    - All DMA is blocked, can be used to isolate
883d0407baSopenharmony_ci *                  devices
893d0407baSopenharmony_ci *    IOMMU_DOMAIN_IDENTITY    - DMA addresses are system physical addresses
903d0407baSopenharmony_ci *    IOMMU_DOMAIN_UNMANAGED    - DMA mappings managed by IOMMU-API user, used
913d0407baSopenharmony_ci *                  for VMs
923d0407baSopenharmony_ci *    IOMMU_DOMAIN_DMA    - Internally used for DMA-API implementations.
933d0407baSopenharmony_ci *                  This flag allows IOMMU drivers to implement
943d0407baSopenharmony_ci *                  certain optimizations for these domains
953d0407baSopenharmony_ci */
963d0407baSopenharmony_ci#define IOMMU_DOMAIN_BLOCKED (0U)
973d0407baSopenharmony_ci#define IOMMU_DOMAIN_IDENTITY (IOMMU_DOMAIN_PT)
983d0407baSopenharmony_ci#define IOMMU_DOMAIN_UNMANAGED (__IOMMU_DOMAIN_PAGING)
993d0407baSopenharmony_ci#define IOMMU_DOMAIN_DMA (__IOMMU_DOMAIN_PAGING | IOMMU_DOMAIN_DMA_API)
1003d0407baSopenharmony_ci
1013d0407baSopenharmony_cistruct iommu_domain {
1023d0407baSopenharmony_ci    unsigned type;
1033d0407baSopenharmony_ci    const struct iommu_ops *ops;
1043d0407baSopenharmony_ci    unsigned long pgsize_bitmap; /* Bitmap of page sizes in use */
1053d0407baSopenharmony_ci    iommu_fault_handler_t handler;
1063d0407baSopenharmony_ci    void *handler_token;
1073d0407baSopenharmony_ci    struct iommu_domain_geometry geometry;
1083d0407baSopenharmony_ci    void *iova_cookie;
1093d0407baSopenharmony_ci};
1103d0407baSopenharmony_ci
1113d0407baSopenharmony_cienum iommu_cap {
1123d0407baSopenharmony_ci    IOMMU_CAP_CACHE_COHERENCY, /* IOMMU can enforce cache coherent DMA
1133d0407baSopenharmony_ci                    transactions */
1143d0407baSopenharmony_ci    IOMMU_CAP_INTR_REMAP,      /* IOMMU supports interrupt isolation */
1153d0407baSopenharmony_ci    IOMMU_CAP_NOEXEC,          /* IOMMU_NOEXEC flag */
1163d0407baSopenharmony_ci};
1173d0407baSopenharmony_ci
1183d0407baSopenharmony_ci/*
1193d0407baSopenharmony_ci * Following constraints are specifc to FSL_PAMUV1:
1203d0407baSopenharmony_ci *  -aperture must be power of 2, and naturally aligned
1213d0407baSopenharmony_ci *  -number of windows must be power of 2, and address space size
1223d0407baSopenharmony_ci *   of each window is determined by aperture size / # of windows
1233d0407baSopenharmony_ci *  -the actual size of the mapped region of a window must be power
1243d0407baSopenharmony_ci *   of 2 starting with 4KB and physical address must be naturally
1253d0407baSopenharmony_ci *   aligned.
1263d0407baSopenharmony_ci * DOMAIN_ATTR_FSL_PAMUV1 corresponds to the above mentioned contraints.
1273d0407baSopenharmony_ci * The caller can invoke iommu_domain_get_attr to check if the underlying
1283d0407baSopenharmony_ci * iommu implementation supports these constraints.
1293d0407baSopenharmony_ci */
1303d0407baSopenharmony_ci
1313d0407baSopenharmony_cienum iommu_attr {
1323d0407baSopenharmony_ci    DOMAIN_ATTR_GEOMETRY,
1333d0407baSopenharmony_ci    DOMAIN_ATTR_PAGING,
1343d0407baSopenharmony_ci    DOMAIN_ATTR_WINDOWS,
1353d0407baSopenharmony_ci    DOMAIN_ATTR_FSL_PAMU_STASH,
1363d0407baSopenharmony_ci    DOMAIN_ATTR_FSL_PAMU_ENABLE,
1373d0407baSopenharmony_ci    DOMAIN_ATTR_FSL_PAMUV1,
1383d0407baSopenharmony_ci    DOMAIN_ATTR_NESTING, /* two stages of translation */
1393d0407baSopenharmony_ci    DOMAIN_ATTR_DMA_USE_FLUSH_QUEUE,
1403d0407baSopenharmony_ci    DOMAIN_ATTR_MAX,
1413d0407baSopenharmony_ci};
1423d0407baSopenharmony_ci
1433d0407baSopenharmony_ci/* These are the possible reserved region types */
1443d0407baSopenharmony_cienum iommu_resv_type {
1453d0407baSopenharmony_ci    /* Memory regions which must be mapped 1:1 at all times */
1463d0407baSopenharmony_ci    IOMMU_RESV_DIRECT,
1473d0407baSopenharmony_ci    /*
1483d0407baSopenharmony_ci     * Memory regions which are advertised to be 1:1 but are
1493d0407baSopenharmony_ci     * commonly considered relaxable in some conditions,
1503d0407baSopenharmony_ci     * for instance in device assignment use case (USB, Graphics)
1513d0407baSopenharmony_ci     */
1523d0407baSopenharmony_ci    IOMMU_RESV_DIRECT_RELAXABLE,
1533d0407baSopenharmony_ci    /* Arbitrary "never map this or give it to a device" address ranges */
1543d0407baSopenharmony_ci    IOMMU_RESV_RESERVED,
1553d0407baSopenharmony_ci    /* Hardware MSI region (untranslated) */
1563d0407baSopenharmony_ci    IOMMU_RESV_MSI,
1573d0407baSopenharmony_ci    /* Software-managed MSI translation window */
1583d0407baSopenharmony_ci    IOMMU_RESV_SW_MSI,
1593d0407baSopenharmony_ci};
1603d0407baSopenharmony_ci
1613d0407baSopenharmony_ci/**
1623d0407baSopenharmony_ci * struct iommu_resv_region - descriptor for a reserved memory region
1633d0407baSopenharmony_ci * @list: Linked list pointers
1643d0407baSopenharmony_ci * @start: System physical start address of the region
1653d0407baSopenharmony_ci * @length: Length of the region in bytes
1663d0407baSopenharmony_ci * @prot: IOMMU Protection flags (READ/WRITE/...)
1673d0407baSopenharmony_ci * @type: Type of the reserved region
1683d0407baSopenharmony_ci */
1693d0407baSopenharmony_cistruct iommu_resv_region {
1703d0407baSopenharmony_ci    struct list_head list;
1713d0407baSopenharmony_ci    phys_addr_t start;
1723d0407baSopenharmony_ci    size_t length;
1733d0407baSopenharmony_ci    int prot;
1743d0407baSopenharmony_ci    enum iommu_resv_type type;
1753d0407baSopenharmony_ci};
1763d0407baSopenharmony_ci
1773d0407baSopenharmony_ci/* Per device IOMMU features */
1783d0407baSopenharmony_cienum iommu_dev_features {
1793d0407baSopenharmony_ci    IOMMU_DEV_FEAT_AUX, /* Aux-domain feature */
1803d0407baSopenharmony_ci    IOMMU_DEV_FEAT_SVA, /* Shared Virtual Addresses */
1813d0407baSopenharmony_ci};
1823d0407baSopenharmony_ci
1833d0407baSopenharmony_ci#define IOMMU_PASID_INVALID (-1U)
1843d0407baSopenharmony_ci
1853d0407baSopenharmony_ci#ifdef CONFIG_IOMMU_API
1863d0407baSopenharmony_ci
1873d0407baSopenharmony_ci/**
1883d0407baSopenharmony_ci * struct iommu_iotlb_gather - Range information for a pending IOTLB flush
1893d0407baSopenharmony_ci *
1903d0407baSopenharmony_ci * @start: IOVA representing the start of the range to be flushed
1913d0407baSopenharmony_ci * @end: IOVA representing the end of the range to be flushed (inclusive)
1923d0407baSopenharmony_ci * @pgsize: The interval at which to perform the flush
1933d0407baSopenharmony_ci *
1943d0407baSopenharmony_ci * This structure is intended to be updated by multiple calls to the
1953d0407baSopenharmony_ci * ->unmap() function in struct iommu_ops before eventually being passed
1963d0407baSopenharmony_ci * into ->iotlb_sync().
1973d0407baSopenharmony_ci */
1983d0407baSopenharmony_cistruct iommu_iotlb_gather {
1993d0407baSopenharmony_ci    unsigned long start;
2003d0407baSopenharmony_ci    unsigned long end;
2013d0407baSopenharmony_ci    size_t pgsize;
2023d0407baSopenharmony_ci};
2033d0407baSopenharmony_ci
2043d0407baSopenharmony_ci/**
2053d0407baSopenharmony_ci * struct iommu_ops - iommu ops and capabilities
2063d0407baSopenharmony_ci * @capable: check capability
2073d0407baSopenharmony_ci * @domain_alloc: allocate iommu domain
2083d0407baSopenharmony_ci * @domain_free: free iommu domain
2093d0407baSopenharmony_ci * @attach_dev: attach device to an iommu domain
2103d0407baSopenharmony_ci * @detach_dev: detach device from an iommu domain
2113d0407baSopenharmony_ci * @map: map a physically contiguous memory region to an iommu domain
2123d0407baSopenharmony_ci * @map_pages: map a physically contiguous set of pages of the same size to
2133d0407baSopenharmony_ci *             an iommu domain.
2143d0407baSopenharmony_ci * @map_sg: map a scatter-gather list of physically contiguous chunks to
2153d0407baSopenharmony_ci *          an iommu domain.
2163d0407baSopenharmony_ci * @unmap: unmap a physically contiguous memory region from an iommu domain
2173d0407baSopenharmony_ci * @unmap_pages: unmap a number of pages of the same size from an iommu domain
2183d0407baSopenharmony_ci * @flush_iotlb_all: Synchronously flush all hardware TLBs for this domain
2193d0407baSopenharmony_ci * @iotlb_sync_map: Sync mappings created recently using @map to the hardware
2203d0407baSopenharmony_ci * @iotlb_sync: Flush all queued ranges from the hardware TLBs and empty flush
2213d0407baSopenharmony_ci *            queue
2223d0407baSopenharmony_ci * @iova_to_phys: translate iova to physical address
2233d0407baSopenharmony_ci * @probe_device: Add device to iommu driver handling
2243d0407baSopenharmony_ci * @release_device: Remove device from iommu driver handling
2253d0407baSopenharmony_ci * @probe_finalize: Do final setup work after the device is added to an IOMMU
2263d0407baSopenharmony_ci *                  group and attached to the groups domain
2273d0407baSopenharmony_ci * @device_group: find iommu group for a particular device
2283d0407baSopenharmony_ci * @domain_get_attr: Query domain attributes
2293d0407baSopenharmony_ci * @domain_set_attr: Change domain attributes
2303d0407baSopenharmony_ci * @get_resv_regions: Request list of reserved regions for a device
2313d0407baSopenharmony_ci * @put_resv_regions: Free list of reserved regions for a device
2323d0407baSopenharmony_ci * @apply_resv_region: Temporary helper call-back for iova reserved ranges
2333d0407baSopenharmony_ci * @domain_window_enable: Configure and enable a particular window for a domain
2343d0407baSopenharmony_ci * @domain_window_disable: Disable a particular window for a domain
2353d0407baSopenharmony_ci * @of_xlate: add OF master IDs to iommu grouping
2363d0407baSopenharmony_ci * @is_attach_deferred: Check if domain attach should be deferred from iommu
2373d0407baSopenharmony_ci *                      driver init to device driver init (default no)
2383d0407baSopenharmony_ci * @dev_has/enable/disable_feat: per device entries to check/enable/disable
2393d0407baSopenharmony_ci *                               iommu specific features.
2403d0407baSopenharmony_ci * @dev_feat_enabled: check enabled feature
2413d0407baSopenharmony_ci * @aux_attach/detach_dev: aux-domain specific attach/detach entries.
2423d0407baSopenharmony_ci * @aux_get_pasid: get the pasid given an aux-domain
2433d0407baSopenharmony_ci * @sva_bind: Bind process address space to device
2443d0407baSopenharmony_ci * @sva_unbind: Unbind process address space from device
2453d0407baSopenharmony_ci * @sva_get_pasid: Get PASID associated to a SVA handle
2463d0407baSopenharmony_ci * @page_response: handle page request response
2473d0407baSopenharmony_ci * @cache_invalidate: invalidate translation caches
2483d0407baSopenharmony_ci * @sva_bind_gpasid: bind guest pasid and mm
2493d0407baSopenharmony_ci * @sva_unbind_gpasid: unbind guest pasid and mm
2503d0407baSopenharmony_ci * @def_domain_type: device default domain type, return value:
2513d0407baSopenharmony_ci *        - IOMMU_DOMAIN_IDENTITY: must use an identity domain
2523d0407baSopenharmony_ci *        - IOMMU_DOMAIN_DMA: must use a dma domain
2533d0407baSopenharmony_ci *        - 0: use the default setting
2543d0407baSopenharmony_ci * @pgsize_bitmap: bitmap of all possible supported page sizes
2553d0407baSopenharmony_ci * @owner: Driver module providing these ops
2563d0407baSopenharmony_ci */
2573d0407baSopenharmony_cistruct iommu_ops {
2583d0407baSopenharmony_ci    bool (*capable)(enum iommu_cap);
2593d0407baSopenharmony_ci
2603d0407baSopenharmony_ci    /* Domain allocation and freeing by the iommu driver */
2613d0407baSopenharmony_ci    struct iommu_domain *(*domain_alloc)(unsigned iommu_domain_type);
2623d0407baSopenharmony_ci    void (*domain_free)(struct iommu_domain *);
2633d0407baSopenharmony_ci
2643d0407baSopenharmony_ci    int (*attach_dev)(struct iommu_domain *domain, struct device *dev);
2653d0407baSopenharmony_ci    void (*detach_dev)(struct iommu_domain *domain, struct device *dev);
2663d0407baSopenharmony_ci    int (*map)(struct iommu_domain *domain, unsigned long iova, phys_addr_t paddr, size_t size, int prot, gfp_t gfp);
2673d0407baSopenharmony_ci    int (*map_pages)(struct iommu_domain *domain, unsigned long iova, phys_addr_t paddr, size_t pgsize, size_t pgcount,
2683d0407baSopenharmony_ci                     int prot, gfp_t gfp, size_t *mapped);
2693d0407baSopenharmony_ci    int (*map_sg)(struct iommu_domain *domain, unsigned long iova, struct scatterlist *sg, unsigned int nents, int prot,
2703d0407baSopenharmony_ci                  gfp_t gfp, size_t *mapped);
2713d0407baSopenharmony_ci    size_t (*unmap)(struct iommu_domain *domain, unsigned long iova, size_t size,
2723d0407baSopenharmony_ci                    struct iommu_iotlb_gather *iotlb_gather);
2733d0407baSopenharmony_ci    size_t (*unmap_pages)(struct iommu_domain *domain, unsigned long iova, size_t pgsize, size_t pgcount,
2743d0407baSopenharmony_ci                          struct iommu_iotlb_gather *iotlb_gather);
2753d0407baSopenharmony_ci    void (*flush_iotlb_all)(struct iommu_domain *domain);
2763d0407baSopenharmony_ci    void (*iotlb_sync_map)(struct iommu_domain *domain, unsigned long iova, size_t size);
2773d0407baSopenharmony_ci    void (*iotlb_sync)(struct iommu_domain *domain, struct iommu_iotlb_gather *iotlb_gather);
2783d0407baSopenharmony_ci    phys_addr_t (*iova_to_phys)(struct iommu_domain *domain, dma_addr_t iova);
2793d0407baSopenharmony_ci    struct iommu_device *(*probe_device)(struct device *dev);
2803d0407baSopenharmony_ci    void (*release_device)(struct device *dev);
2813d0407baSopenharmony_ci    void (*probe_finalize)(struct device *dev);
2823d0407baSopenharmony_ci    struct iommu_group *(*device_group)(struct device *dev);
2833d0407baSopenharmony_ci    int (*domain_get_attr)(struct iommu_domain *domain, enum iommu_attr attr, void *data);
2843d0407baSopenharmony_ci    int (*domain_set_attr)(struct iommu_domain *domain, enum iommu_attr attr, void *data);
2853d0407baSopenharmony_ci
2863d0407baSopenharmony_ci    /* Request/Free a list of reserved regions for a device */
2873d0407baSopenharmony_ci    void (*get_resv_regions)(struct device *dev, struct list_head *list);
2883d0407baSopenharmony_ci    void (*put_resv_regions)(struct device *dev, struct list_head *list);
2893d0407baSopenharmony_ci    void (*apply_resv_region)(struct device *dev, struct iommu_domain *domain, struct iommu_resv_region *region);
2903d0407baSopenharmony_ci
2913d0407baSopenharmony_ci    /* Window handling functions */
2923d0407baSopenharmony_ci    int (*domain_window_enable)(struct iommu_domain *domain, u32 wnd_nr, phys_addr_t paddr, u64 size, int prot);
2933d0407baSopenharmony_ci    void (*domain_window_disable)(struct iommu_domain *domain, u32 wnd_nr);
2943d0407baSopenharmony_ci
2953d0407baSopenharmony_ci    int (*of_xlate)(struct device *dev, struct of_phandle_args *args);
2963d0407baSopenharmony_ci    bool (*is_attach_deferred)(struct iommu_domain *domain, struct device *dev);
2973d0407baSopenharmony_ci
2983d0407baSopenharmony_ci    /* Per device IOMMU features */
2993d0407baSopenharmony_ci    bool (*dev_has_feat)(struct device *dev, enum iommu_dev_features f);
3003d0407baSopenharmony_ci    bool (*dev_feat_enabled)(struct device *dev, enum iommu_dev_features f);
3013d0407baSopenharmony_ci    int (*dev_enable_feat)(struct device *dev, enum iommu_dev_features f);
3023d0407baSopenharmony_ci    int (*dev_disable_feat)(struct device *dev, enum iommu_dev_features f);
3033d0407baSopenharmony_ci
3043d0407baSopenharmony_ci    /* Aux-domain specific attach/detach entries */
3053d0407baSopenharmony_ci    int (*aux_attach_dev)(struct iommu_domain *domain, struct device *dev);
3063d0407baSopenharmony_ci    void (*aux_detach_dev)(struct iommu_domain *domain, struct device *dev);
3073d0407baSopenharmony_ci    int (*aux_get_pasid)(struct iommu_domain *domain, struct device *dev);
3083d0407baSopenharmony_ci
3093d0407baSopenharmony_ci    struct iommu_sva *(*sva_bind)(struct device *dev, struct mm_struct *mm, void *drvdata);
3103d0407baSopenharmony_ci    void (*sva_unbind)(struct iommu_sva *handle);
3113d0407baSopenharmony_ci    u32 (*sva_get_pasid)(struct iommu_sva *handle);
3123d0407baSopenharmony_ci
3133d0407baSopenharmony_ci    int (*page_response)(struct device *dev, struct iommu_fault_event *evt, struct iommu_page_response *msg);
3143d0407baSopenharmony_ci    int (*cache_invalidate)(struct iommu_domain *domain, struct device *dev,
3153d0407baSopenharmony_ci                            struct iommu_cache_invalidate_info *inv_info);
3163d0407baSopenharmony_ci    int (*sva_bind_gpasid)(struct iommu_domain *domain, struct device *dev, struct iommu_gpasid_bind_data *data);
3173d0407baSopenharmony_ci
3183d0407baSopenharmony_ci    int (*sva_unbind_gpasid)(struct device *dev, u32 pasid);
3193d0407baSopenharmony_ci
3203d0407baSopenharmony_ci    int (*def_domain_type)(struct device *dev);
3213d0407baSopenharmony_ci
3223d0407baSopenharmony_ci    unsigned long pgsize_bitmap;
3233d0407baSopenharmony_ci    struct module *owner;
3243d0407baSopenharmony_ci};
3253d0407baSopenharmony_ci
3263d0407baSopenharmony_ci/**
3273d0407baSopenharmony_ci * struct iommu_device - IOMMU core representation of one IOMMU hardware
3283d0407baSopenharmony_ci *             instance
3293d0407baSopenharmony_ci * @list: Used by the iommu-core to keep a list of registered iommus
3303d0407baSopenharmony_ci * @ops: iommu-ops for talking to this iommu
3313d0407baSopenharmony_ci * @dev: struct device for sysfs handling
3323d0407baSopenharmony_ci */
3333d0407baSopenharmony_cistruct iommu_device {
3343d0407baSopenharmony_ci    struct list_head list;
3353d0407baSopenharmony_ci    const struct iommu_ops *ops;
3363d0407baSopenharmony_ci    struct fwnode_handle *fwnode;
3373d0407baSopenharmony_ci    struct device *dev;
3383d0407baSopenharmony_ci};
3393d0407baSopenharmony_ci
3403d0407baSopenharmony_ci/**
3413d0407baSopenharmony_ci * struct iommu_fault_event - Generic fault event
3423d0407baSopenharmony_ci *
3433d0407baSopenharmony_ci * Can represent recoverable faults such as a page requests or
3443d0407baSopenharmony_ci * unrecoverable faults such as DMA or IRQ remapping faults.
3453d0407baSopenharmony_ci *
3463d0407baSopenharmony_ci * @fault: fault descriptor
3473d0407baSopenharmony_ci * @list: pending fault event list, used for tracking responses
3483d0407baSopenharmony_ci */
3493d0407baSopenharmony_cistruct iommu_fault_event {
3503d0407baSopenharmony_ci    struct iommu_fault fault;
3513d0407baSopenharmony_ci    struct list_head list;
3523d0407baSopenharmony_ci};
3533d0407baSopenharmony_ci
3543d0407baSopenharmony_ci/**
3553d0407baSopenharmony_ci * struct iommu_fault_param - per-device IOMMU fault data
3563d0407baSopenharmony_ci * @handler: Callback function to handle IOMMU faults at device level
3573d0407baSopenharmony_ci * @data: handler private data
3583d0407baSopenharmony_ci * @faults: holds the pending faults which needs response
3593d0407baSopenharmony_ci * @lock: protect pending faults list
3603d0407baSopenharmony_ci */
3613d0407baSopenharmony_cistruct iommu_fault_param {
3623d0407baSopenharmony_ci    iommu_dev_fault_handler_t handler;
3633d0407baSopenharmony_ci    void *data;
3643d0407baSopenharmony_ci    struct list_head faults;
3653d0407baSopenharmony_ci    struct mutex lock;
3663d0407baSopenharmony_ci};
3673d0407baSopenharmony_ci
3683d0407baSopenharmony_ci/**
3693d0407baSopenharmony_ci * struct dev_iommu - Collection of per-device IOMMU data
3703d0407baSopenharmony_ci *
3713d0407baSopenharmony_ci * @fault_param: IOMMU detected device fault reporting data
3723d0407baSopenharmony_ci * @fwspec:     IOMMU fwspec data
3733d0407baSopenharmony_ci * @iommu_dev:     IOMMU device this device is linked to
3743d0407baSopenharmony_ci * @priv:     IOMMU Driver private data
3753d0407baSopenharmony_ci *
3763d0407baSopenharmony_ci * migrate other per device data pointers under iommu_dev_data, e.g.
3773d0407baSopenharmony_ci * struct iommu_group    *iommu_group;
3783d0407baSopenharmony_ci */
3793d0407baSopenharmony_cistruct dev_iommu {
3803d0407baSopenharmony_ci    struct mutex lock;
3813d0407baSopenharmony_ci    struct iommu_fault_param *fault_param;
3823d0407baSopenharmony_ci    struct iommu_fwspec *fwspec;
3833d0407baSopenharmony_ci    struct iommu_device *iommu_dev;
3843d0407baSopenharmony_ci    void *priv;
3853d0407baSopenharmony_ci};
3863d0407baSopenharmony_ci
3873d0407baSopenharmony_ciint iommu_device_register(struct iommu_device *iommu);
3883d0407baSopenharmony_civoid iommu_device_unregister(struct iommu_device *iommu);
3893d0407baSopenharmony_ciint iommu_device_sysfs_add(struct iommu_device *iommu, struct device *parent, const struct attribute_group **groups,
3903d0407baSopenharmony_ci                           const char *fmt, ...) __printf(4, 5);
3913d0407baSopenharmony_civoid iommu_device_sysfs_remove(struct iommu_device *iommu);
3923d0407baSopenharmony_ciint iommu_device_link(struct iommu_device *iommu, struct device *link);
3933d0407baSopenharmony_civoid iommu_device_unlink(struct iommu_device *iommu, struct device *link);
3943d0407baSopenharmony_ci
3953d0407baSopenharmony_cistatic inline void _iommu_device_set_ops(struct iommu_device *iommu, const struct iommu_ops *ops)
3963d0407baSopenharmony_ci{
3973d0407baSopenharmony_ci    iommu->ops = ops;
3983d0407baSopenharmony_ci}
3993d0407baSopenharmony_ci
4003d0407baSopenharmony_ci#define iommu_device_set_ops(iommu, ops)                                                                               \
4013d0407baSopenharmony_ci    do {                                                                                                               \
4023d0407baSopenharmony_ci        struct iommu_ops *__ops = (struct iommu_ops *)(ops);                                                           \
4033d0407baSopenharmony_ci        __ops->owner = THIS_MODULE;                                                                                    \
4043d0407baSopenharmony_ci        _iommu_device_set_ops(iommu, __ops);                                                                           \
4053d0407baSopenharmony_ci    } while (0)
4063d0407baSopenharmony_ci
4073d0407baSopenharmony_cistatic inline void iommu_device_set_fwnode(struct iommu_device *iommu, struct fwnode_handle *fwnode)
4083d0407baSopenharmony_ci{
4093d0407baSopenharmony_ci    iommu->fwnode = fwnode;
4103d0407baSopenharmony_ci}
4113d0407baSopenharmony_ci
4123d0407baSopenharmony_cistatic inline struct iommu_device *dev_to_iommu_device(struct device *dev)
4133d0407baSopenharmony_ci{
4143d0407baSopenharmony_ci    return (struct iommu_device *)dev_get_drvdata(dev);
4153d0407baSopenharmony_ci}
4163d0407baSopenharmony_ci
4173d0407baSopenharmony_cistatic inline void iommu_iotlb_gather_init(struct iommu_iotlb_gather *gather)
4183d0407baSopenharmony_ci{
4193d0407baSopenharmony_ci    *gather = (struct iommu_iotlb_gather) {
4203d0407baSopenharmony_ci        .start = ULONG_MAX,
4213d0407baSopenharmony_ci    };
4223d0407baSopenharmony_ci}
4233d0407baSopenharmony_ci
4243d0407baSopenharmony_ci#define IOMMU_GROUP_NOTIFY_ADD_DEVICE 1     /* Device added */
4253d0407baSopenharmony_ci#define IOMMU_GROUP_NOTIFY_DEL_DEVICE 2     /* Pre Device removed */
4263d0407baSopenharmony_ci#define IOMMU_GROUP_NOTIFY_BIND_DRIVER 3    /* Pre Driver bind */
4273d0407baSopenharmony_ci#define IOMMU_GROUP_NOTIFY_BOUND_DRIVER 4   /* Post Driver bind */
4283d0407baSopenharmony_ci#define IOMMU_GROUP_NOTIFY_UNBIND_DRIVER 5  /* Pre Driver unbind */
4293d0407baSopenharmony_ci#define IOMMU_GROUP_NOTIFY_UNBOUND_DRIVER 6 /* Post Driver unbind */
4303d0407baSopenharmony_ci
4313d0407baSopenharmony_ciextern int bus_set_iommu(struct bus_type *bus, const struct iommu_ops *ops);
4323d0407baSopenharmony_ciextern int bus_iommu_probe(struct bus_type *bus);
4333d0407baSopenharmony_ciextern bool iommu_present(struct bus_type *bus);
4343d0407baSopenharmony_ciextern bool iommu_capable(struct bus_type *bus, enum iommu_cap cap);
4353d0407baSopenharmony_ciextern struct iommu_domain *iommu_domain_alloc(struct bus_type *bus);
4363d0407baSopenharmony_ciextern struct iommu_group *iommu_group_get_by_id(int id);
4373d0407baSopenharmony_ciextern void iommu_domain_free(struct iommu_domain *domain);
4383d0407baSopenharmony_ciextern int iommu_attach_device(struct iommu_domain *domain, struct device *dev);
4393d0407baSopenharmony_ciextern void iommu_detach_device(struct iommu_domain *domain, struct device *dev);
4403d0407baSopenharmony_ciextern int iommu_uapi_cache_invalidate(struct iommu_domain *domain, struct device *dev, void __user *uinfo);
4413d0407baSopenharmony_ci
4423d0407baSopenharmony_ciextern int iommu_uapi_sva_bind_gpasid(struct iommu_domain *domain, struct device *dev, void __user *udata);
4433d0407baSopenharmony_ciextern int iommu_uapi_sva_unbind_gpasid(struct iommu_domain *domain, struct device *dev, void __user *udata);
4443d0407baSopenharmony_ciextern int iommu_sva_unbind_gpasid(struct iommu_domain *domain, struct device *dev, ioasid_t pasid);
4453d0407baSopenharmony_ciextern struct iommu_domain *iommu_get_domain_for_dev(struct device *dev);
4463d0407baSopenharmony_ciextern struct iommu_domain *iommu_get_dma_domain(struct device *dev);
4473d0407baSopenharmony_ciextern int iommu_map(struct iommu_domain *domain, unsigned long iova, phys_addr_t paddr, size_t size, int prot);
4483d0407baSopenharmony_ciextern int iommu_map_atomic(struct iommu_domain *domain, unsigned long iova, phys_addr_t paddr, size_t size, int prot);
4493d0407baSopenharmony_ciextern size_t iommu_unmap(struct iommu_domain *domain, unsigned long iova, size_t size);
4503d0407baSopenharmony_ciextern size_t iommu_unmap_fast(struct iommu_domain *domain, unsigned long iova, size_t size,
4513d0407baSopenharmony_ci                               struct iommu_iotlb_gather *iotlb_gather);
4523d0407baSopenharmony_ciextern size_t iommu_map_sg(struct iommu_domain *domain, unsigned long iova, struct scatterlist *sg, unsigned int nents,
4533d0407baSopenharmony_ci                           int prot);
4543d0407baSopenharmony_ciextern size_t iommu_map_sg_atomic(struct iommu_domain *domain, unsigned long iova, struct scatterlist *sg,
4553d0407baSopenharmony_ci                                  unsigned int nents, int prot);
4563d0407baSopenharmony_ciextern phys_addr_t iommu_iova_to_phys(struct iommu_domain *domain, dma_addr_t iova);
4573d0407baSopenharmony_ciextern void iommu_set_fault_handler(struct iommu_domain *domain, iommu_fault_handler_t handler, void *token);
4583d0407baSopenharmony_ci
4593d0407baSopenharmony_ciextern void iommu_get_resv_regions(struct device *dev, struct list_head *list);
4603d0407baSopenharmony_ciextern void iommu_put_resv_regions(struct device *dev, struct list_head *list);
4613d0407baSopenharmony_ciextern void generic_iommu_put_resv_regions(struct device *dev, struct list_head *list);
4623d0407baSopenharmony_ciextern void iommu_set_default_passthrough(bool cmd_line);
4633d0407baSopenharmony_ciextern void iommu_set_default_translated(bool cmd_line);
4643d0407baSopenharmony_ciextern bool iommu_default_passthrough(void);
4653d0407baSopenharmony_ciextern struct iommu_resv_region *iommu_alloc_resv_region(phys_addr_t start, size_t length, int prot,
4663d0407baSopenharmony_ci                                                         enum iommu_resv_type type);
4673d0407baSopenharmony_ciextern int iommu_get_group_resv_regions(struct iommu_group *group, struct list_head *head);
4683d0407baSopenharmony_ci
4693d0407baSopenharmony_ciextern int iommu_attach_group(struct iommu_domain *domain, struct iommu_group *group);
4703d0407baSopenharmony_ciextern void iommu_detach_group(struct iommu_domain *domain, struct iommu_group *group);
4713d0407baSopenharmony_ciextern struct iommu_group *iommu_group_alloc(void);
4723d0407baSopenharmony_ciextern void *iommu_group_get_iommudata(struct iommu_group *group);
4733d0407baSopenharmony_ciextern void iommu_group_set_iommudata(struct iommu_group *group, void *iommu_data, void (*release)(void *iommu_data));
4743d0407baSopenharmony_ciextern int iommu_group_set_name(struct iommu_group *group, const char *name);
4753d0407baSopenharmony_ciextern int iommu_group_add_device(struct iommu_group *group, struct device *dev);
4763d0407baSopenharmony_ciextern void iommu_group_remove_device(struct device *dev);
4773d0407baSopenharmony_ciextern int iommu_group_for_each_dev(struct iommu_group *group, void *data, int (*fn)(struct device *, void *));
4783d0407baSopenharmony_ciextern struct iommu_group *iommu_group_get(struct device *dev);
4793d0407baSopenharmony_ciextern struct iommu_group *iommu_group_ref_get(struct iommu_group *group);
4803d0407baSopenharmony_ciextern void iommu_group_put(struct iommu_group *group);
4813d0407baSopenharmony_ciextern int iommu_group_register_notifier(struct iommu_group *group, struct notifier_block *nb);
4823d0407baSopenharmony_ciextern int iommu_group_unregister_notifier(struct iommu_group *group, struct notifier_block *nb);
4833d0407baSopenharmony_ciextern int iommu_register_device_fault_handler(struct device *dev, iommu_dev_fault_handler_t handler, void *data);
4843d0407baSopenharmony_ci
4853d0407baSopenharmony_ciextern int iommu_unregister_device_fault_handler(struct device *dev);
4863d0407baSopenharmony_ci
4873d0407baSopenharmony_ciextern int iommu_report_device_fault(struct device *dev, struct iommu_fault_event *evt);
4883d0407baSopenharmony_ciextern int iommu_page_response(struct device *dev, struct iommu_page_response *msg);
4893d0407baSopenharmony_ci
4903d0407baSopenharmony_ciextern int iommu_group_id(struct iommu_group *group);
4913d0407baSopenharmony_ciextern struct iommu_domain *iommu_group_default_domain(struct iommu_group *);
4923d0407baSopenharmony_ci
4933d0407baSopenharmony_ciextern int iommu_domain_get_attr(struct iommu_domain *domain, enum iommu_attr, void *data);
4943d0407baSopenharmony_ciextern int iommu_domain_set_attr(struct iommu_domain *domain, enum iommu_attr, void *data);
4953d0407baSopenharmony_ci
4963d0407baSopenharmony_ci/* Window handling function prototypes */
4973d0407baSopenharmony_ciextern int iommu_domain_window_enable(struct iommu_domain *domain, u32 wnd_nr, phys_addr_t offset, u64 size, int prot);
4983d0407baSopenharmony_ciextern void iommu_domain_window_disable(struct iommu_domain *domain, u32 wnd_nr);
4993d0407baSopenharmony_ci
5003d0407baSopenharmony_ciextern int report_iommu_fault(struct iommu_domain *domain, struct device *dev, unsigned long iova, int flags);
5013d0407baSopenharmony_ci
5023d0407baSopenharmony_cistatic inline void iommu_flush_iotlb_all(struct iommu_domain *domain)
5033d0407baSopenharmony_ci{
5043d0407baSopenharmony_ci    if (domain->ops->flush_iotlb_all) {
5053d0407baSopenharmony_ci        domain->ops->flush_iotlb_all(domain);
5063d0407baSopenharmony_ci    }
5073d0407baSopenharmony_ci}
5083d0407baSopenharmony_ci
5093d0407baSopenharmony_cistatic inline void iommu_iotlb_sync(struct iommu_domain *domain, struct iommu_iotlb_gather *iotlb_gather)
5103d0407baSopenharmony_ci{
5113d0407baSopenharmony_ci    if (domain->ops->iotlb_sync) {
5123d0407baSopenharmony_ci        domain->ops->iotlb_sync(domain, iotlb_gather);
5133d0407baSopenharmony_ci    }
5143d0407baSopenharmony_ci
5153d0407baSopenharmony_ci    iommu_iotlb_gather_init(iotlb_gather);
5163d0407baSopenharmony_ci}
5173d0407baSopenharmony_ci
5183d0407baSopenharmony_cistatic inline void iommu_iotlb_gather_add_page(struct iommu_domain *domain, struct iommu_iotlb_gather *gather,
5193d0407baSopenharmony_ci                                               unsigned long iova, size_t size)
5203d0407baSopenharmony_ci{
5213d0407baSopenharmony_ci    unsigned long start = iova, end = start + size - 1;
5223d0407baSopenharmony_ci
5233d0407baSopenharmony_ci    /*
5243d0407baSopenharmony_ci     * If the new page is disjoint from the current range or is mapped at
5253d0407baSopenharmony_ci     * a different granularity, then sync the TLB so that the gather
5263d0407baSopenharmony_ci     * structure can be rewritten.
5273d0407baSopenharmony_ci     */
5283d0407baSopenharmony_ci    if (gather->pgsize != size || end + 1 < gather->start || start > gather->end + 1) {
5293d0407baSopenharmony_ci        if (gather->pgsize) {
5303d0407baSopenharmony_ci            iommu_iotlb_sync(domain, gather);
5313d0407baSopenharmony_ci        }
5323d0407baSopenharmony_ci        gather->pgsize = size;
5333d0407baSopenharmony_ci    }
5343d0407baSopenharmony_ci
5353d0407baSopenharmony_ci    if (gather->end < end) {
5363d0407baSopenharmony_ci        gather->end = end;
5373d0407baSopenharmony_ci    }
5383d0407baSopenharmony_ci
5393d0407baSopenharmony_ci    if (gather->start > start) {
5403d0407baSopenharmony_ci        gather->start = start;
5413d0407baSopenharmony_ci    }
5423d0407baSopenharmony_ci}
5433d0407baSopenharmony_ci
5443d0407baSopenharmony_ci/* PCI device grouping function */
5453d0407baSopenharmony_ciextern struct iommu_group *pci_device_group(struct device *dev);
5463d0407baSopenharmony_ci/* Generic device grouping function */
5473d0407baSopenharmony_ciextern struct iommu_group *generic_device_group(struct device *dev);
5483d0407baSopenharmony_ciextern void rk_iommu_mask_irq(struct device *dev);
5493d0407baSopenharmony_ciextern void rk_iommu_unmask_irq(struct device *dev);
5503d0407baSopenharmony_ci/* FSL-MC device grouping function */
5513d0407baSopenharmony_cistruct iommu_group *fsl_mc_device_group(struct device *dev);
5523d0407baSopenharmony_ci
5533d0407baSopenharmony_ci/**
5543d0407baSopenharmony_ci * struct iommu_fwspec - per-device IOMMU instance data
5553d0407baSopenharmony_ci * @ops: ops for this device's IOMMU
5563d0407baSopenharmony_ci * @iommu_fwnode: firmware handle for this device's IOMMU
5573d0407baSopenharmony_ci * @iommu_priv: IOMMU driver private data for this device
5583d0407baSopenharmony_ci * @num_pasid_bits: number of PASID bits supported by this device
5593d0407baSopenharmony_ci * @num_ids: number of associated device IDs
5603d0407baSopenharmony_ci * @ids: IDs which this device may present to the IOMMU
5613d0407baSopenharmony_ci */
5623d0407baSopenharmony_cistruct iommu_fwspec {
5633d0407baSopenharmony_ci    const struct iommu_ops *ops;
5643d0407baSopenharmony_ci    struct fwnode_handle *iommu_fwnode;
5653d0407baSopenharmony_ci    u32 flags;
5663d0407baSopenharmony_ci    u32 num_pasid_bits;
5673d0407baSopenharmony_ci    unsigned int num_ids;
5683d0407baSopenharmony_ci    u32 ids[];
5693d0407baSopenharmony_ci};
5703d0407baSopenharmony_ci
5713d0407baSopenharmony_ci/* ATS is supported */
5723d0407baSopenharmony_ci#define IOMMU_FWSPEC_PCI_RC_ATS (1 << 0)
5733d0407baSopenharmony_ci
5743d0407baSopenharmony_ci/**
5753d0407baSopenharmony_ci * struct iommu_sva - handle to a device-mm bond
5763d0407baSopenharmony_ci */
5773d0407baSopenharmony_cistruct iommu_sva {
5783d0407baSopenharmony_ci    struct device *dev;
5793d0407baSopenharmony_ci};
5803d0407baSopenharmony_ci
5813d0407baSopenharmony_ciint iommu_fwspec_init(struct device *dev, struct fwnode_handle *iommu_fwnode, const struct iommu_ops *ops);
5823d0407baSopenharmony_civoid iommu_fwspec_free(struct device *dev);
5833d0407baSopenharmony_ciint iommu_fwspec_add_ids(struct device *dev, u32 *ids, int num_ids);
5843d0407baSopenharmony_ciconst struct iommu_ops *iommu_ops_from_fwnode(struct fwnode_handle *fwnode);
5853d0407baSopenharmony_ci
5863d0407baSopenharmony_cistatic inline struct iommu_fwspec *dev_iommu_fwspec_get(struct device *dev)
5873d0407baSopenharmony_ci{
5883d0407baSopenharmony_ci    if (dev->iommu) {
5893d0407baSopenharmony_ci        return dev->iommu->fwspec;
5903d0407baSopenharmony_ci    } else {
5913d0407baSopenharmony_ci        return NULL;
5923d0407baSopenharmony_ci    }
5933d0407baSopenharmony_ci}
5943d0407baSopenharmony_ci
5953d0407baSopenharmony_cistatic inline void dev_iommu_fwspec_set(struct device *dev, struct iommu_fwspec *fwspec)
5963d0407baSopenharmony_ci{
5973d0407baSopenharmony_ci    dev->iommu->fwspec = fwspec;
5983d0407baSopenharmony_ci}
5993d0407baSopenharmony_ci
6003d0407baSopenharmony_cistatic inline void *dev_iommu_priv_get(struct device *dev)
6013d0407baSopenharmony_ci{
6023d0407baSopenharmony_ci    if (dev->iommu) {
6033d0407baSopenharmony_ci        return dev->iommu->priv;
6043d0407baSopenharmony_ci    } else {
6053d0407baSopenharmony_ci        return NULL;
6063d0407baSopenharmony_ci    }
6073d0407baSopenharmony_ci}
6083d0407baSopenharmony_ci
6093d0407baSopenharmony_cistatic inline void dev_iommu_priv_set(struct device *dev, void *priv)
6103d0407baSopenharmony_ci{
6113d0407baSopenharmony_ci    dev->iommu->priv = priv;
6123d0407baSopenharmony_ci}
6133d0407baSopenharmony_ci
6143d0407baSopenharmony_ciint iommu_probe_device(struct device *dev);
6153d0407baSopenharmony_civoid iommu_release_device(struct device *dev);
6163d0407baSopenharmony_ci
6173d0407baSopenharmony_cibool iommu_dev_has_feature(struct device *dev, enum iommu_dev_features f);
6183d0407baSopenharmony_ciint iommu_dev_enable_feature(struct device *dev, enum iommu_dev_features f);
6193d0407baSopenharmony_ciint iommu_dev_disable_feature(struct device *dev, enum iommu_dev_features f);
6203d0407baSopenharmony_cibool iommu_dev_feature_enabled(struct device *dev, enum iommu_dev_features f);
6213d0407baSopenharmony_ciint iommu_aux_attach_device(struct iommu_domain *domain, struct device *dev);
6223d0407baSopenharmony_civoid iommu_aux_detach_device(struct iommu_domain *domain, struct device *dev);
6233d0407baSopenharmony_ciint iommu_aux_get_pasid(struct iommu_domain *domain, struct device *dev);
6243d0407baSopenharmony_ci
6253d0407baSopenharmony_cistruct iommu_sva *iommu_sva_bind_device(struct device *dev, struct mm_struct *mm, void *drvdata);
6263d0407baSopenharmony_civoid iommu_sva_unbind_device(struct iommu_sva *handle);
6273d0407baSopenharmony_ciu32 iommu_sva_get_pasid(struct iommu_sva *handle);
6283d0407baSopenharmony_ci
6293d0407baSopenharmony_ci#else  /* CONFIG_IOMMU_API */
6303d0407baSopenharmony_ci
6313d0407baSopenharmony_cistruct iommu_ops {
6323d0407baSopenharmony_ci};
6333d0407baSopenharmony_cistruct iommu_group {
6343d0407baSopenharmony_ci};
6353d0407baSopenharmony_cistruct iommu_fwspec {
6363d0407baSopenharmony_ci};
6373d0407baSopenharmony_cistruct iommu_device {
6383d0407baSopenharmony_ci};
6393d0407baSopenharmony_cistruct iommu_fault_param {
6403d0407baSopenharmony_ci};
6413d0407baSopenharmony_cistruct iommu_iotlb_gather {
6423d0407baSopenharmony_ci};
6433d0407baSopenharmony_ci
6443d0407baSopenharmony_cistatic inline bool iommu_present(struct bus_type *bus)
6453d0407baSopenharmony_ci{
6463d0407baSopenharmony_ci    return false;
6473d0407baSopenharmony_ci}
6483d0407baSopenharmony_ci
6493d0407baSopenharmony_cistatic inline bool iommu_capable(struct bus_type *bus, enum iommu_cap cap)
6503d0407baSopenharmony_ci{
6513d0407baSopenharmony_ci    return false;
6523d0407baSopenharmony_ci}
6533d0407baSopenharmony_ci
6543d0407baSopenharmony_cistatic inline struct iommu_domain *iommu_domain_alloc(struct bus_type *bus)
6553d0407baSopenharmony_ci{
6563d0407baSopenharmony_ci    return NULL;
6573d0407baSopenharmony_ci}
6583d0407baSopenharmony_ci
6593d0407baSopenharmony_cistatic inline struct iommu_group *iommu_group_get_by_id(int id)
6603d0407baSopenharmony_ci{
6613d0407baSopenharmony_ci    return NULL;
6623d0407baSopenharmony_ci}
6633d0407baSopenharmony_ci
6643d0407baSopenharmony_cistatic inline void iommu_domain_free(struct iommu_domain *domain)
6653d0407baSopenharmony_ci{
6663d0407baSopenharmony_ci}
6673d0407baSopenharmony_ci
6683d0407baSopenharmony_cistatic inline int iommu_attach_device(struct iommu_domain *domain, struct device *dev)
6693d0407baSopenharmony_ci{
6703d0407baSopenharmony_ci    return -ENODEV;
6713d0407baSopenharmony_ci}
6723d0407baSopenharmony_ci
6733d0407baSopenharmony_cistatic inline void iommu_detach_device(struct iommu_domain *domain, struct device *dev)
6743d0407baSopenharmony_ci{
6753d0407baSopenharmony_ci}
6763d0407baSopenharmony_ci
6773d0407baSopenharmony_cistatic inline struct iommu_domain *iommu_get_domain_for_dev(struct device *dev)
6783d0407baSopenharmony_ci{
6793d0407baSopenharmony_ci    return NULL;
6803d0407baSopenharmony_ci}
6813d0407baSopenharmony_ci
6823d0407baSopenharmony_cistatic inline int iommu_map(struct iommu_domain *domain, unsigned long iova, phys_addr_t paddr, size_t size, int prot)
6833d0407baSopenharmony_ci{
6843d0407baSopenharmony_ci    return -ENODEV;
6853d0407baSopenharmony_ci}
6863d0407baSopenharmony_ci
6873d0407baSopenharmony_cistatic inline int iommu_map_atomic(struct iommu_domain *domain, unsigned long iova, phys_addr_t paddr, size_t size,
6883d0407baSopenharmony_ci                                   int prot)
6893d0407baSopenharmony_ci{
6903d0407baSopenharmony_ci    return -ENODEV;
6913d0407baSopenharmony_ci}
6923d0407baSopenharmony_ci
6933d0407baSopenharmony_cistatic inline size_t iommu_unmap(struct iommu_domain *domain, unsigned long iova, size_t size)
6943d0407baSopenharmony_ci{
6953d0407baSopenharmony_ci    return 0;
6963d0407baSopenharmony_ci}
6973d0407baSopenharmony_ci
6983d0407baSopenharmony_cistatic inline size_t iommu_unmap_fast(struct iommu_domain *domain, unsigned long iova, int gfp_order,
6993d0407baSopenharmony_ci                                      struct iommu_iotlb_gather *iotlb_gather)
7003d0407baSopenharmony_ci{
7013d0407baSopenharmony_ci    return 0;
7023d0407baSopenharmony_ci}
7033d0407baSopenharmony_ci
7043d0407baSopenharmony_cistatic inline size_t iommu_map_sg(struct iommu_domain *domain, unsigned long iova, struct scatterlist *sg,
7053d0407baSopenharmony_ci                                  unsigned int nents, int prot)
7063d0407baSopenharmony_ci{
7073d0407baSopenharmony_ci    return 0;
7083d0407baSopenharmony_ci}
7093d0407baSopenharmony_ci
7103d0407baSopenharmony_cistatic inline size_t iommu_map_sg_atomic(struct iommu_domain *domain, unsigned long iova, struct scatterlist *sg,
7113d0407baSopenharmony_ci                                         unsigned int nents, int prot)
7123d0407baSopenharmony_ci{
7133d0407baSopenharmony_ci    return 0;
7143d0407baSopenharmony_ci}
7153d0407baSopenharmony_ci
7163d0407baSopenharmony_cistatic inline void iommu_flush_iotlb_all(struct iommu_domain *domain)
7173d0407baSopenharmony_ci{
7183d0407baSopenharmony_ci}
7193d0407baSopenharmony_ci
7203d0407baSopenharmony_cistatic inline void iommu_iotlb_sync(struct iommu_domain *domain, struct iommu_iotlb_gather *iotlb_gather)
7213d0407baSopenharmony_ci{
7223d0407baSopenharmony_ci}
7233d0407baSopenharmony_ci
7243d0407baSopenharmony_cistatic inline int iommu_domain_window_enable(struct iommu_domain *domain, u32 wnd_nr, phys_addr_t paddr, u64 size,
7253d0407baSopenharmony_ci                                             int prot)
7263d0407baSopenharmony_ci{
7273d0407baSopenharmony_ci    return -ENODEV;
7283d0407baSopenharmony_ci}
7293d0407baSopenharmony_ci
7303d0407baSopenharmony_cistatic inline void iommu_domain_window_disable(struct iommu_domain *domain, u32 wnd_nr)
7313d0407baSopenharmony_ci{
7323d0407baSopenharmony_ci}
7333d0407baSopenharmony_ci
7343d0407baSopenharmony_cistatic inline phys_addr_t iommu_iova_to_phys(struct iommu_domain *domain, dma_addr_t iova)
7353d0407baSopenharmony_ci{
7363d0407baSopenharmony_ci    return 0;
7373d0407baSopenharmony_ci}
7383d0407baSopenharmony_ci
7393d0407baSopenharmony_cistatic inline void iommu_set_fault_handler(struct iommu_domain *domain, iommu_fault_handler_t handler, void *token)
7403d0407baSopenharmony_ci{
7413d0407baSopenharmony_ci}
7423d0407baSopenharmony_ci
7433d0407baSopenharmony_cistatic inline void iommu_get_resv_regions(struct device *dev, struct list_head *list)
7443d0407baSopenharmony_ci{
7453d0407baSopenharmony_ci}
7463d0407baSopenharmony_ci
7473d0407baSopenharmony_cistatic inline void iommu_put_resv_regions(struct device *dev, struct list_head *list)
7483d0407baSopenharmony_ci{
7493d0407baSopenharmony_ci}
7503d0407baSopenharmony_ci
7513d0407baSopenharmony_cistatic inline int iommu_get_group_resv_regions(struct iommu_group *group, struct list_head *head)
7523d0407baSopenharmony_ci{
7533d0407baSopenharmony_ci    return -ENODEV;
7543d0407baSopenharmony_ci}
7553d0407baSopenharmony_ci
7563d0407baSopenharmony_cistatic inline void iommu_set_default_passthrough(bool cmd_line)
7573d0407baSopenharmony_ci{
7583d0407baSopenharmony_ci}
7593d0407baSopenharmony_ci
7603d0407baSopenharmony_cistatic inline void iommu_set_default_translated(bool cmd_line)
7613d0407baSopenharmony_ci{
7623d0407baSopenharmony_ci}
7633d0407baSopenharmony_ci
7643d0407baSopenharmony_cistatic inline bool iommu_default_passthrough(void)
7653d0407baSopenharmony_ci{
7663d0407baSopenharmony_ci    return true;
7673d0407baSopenharmony_ci}
7683d0407baSopenharmony_ci
7693d0407baSopenharmony_cistatic inline int iommu_attach_group(struct iommu_domain *domain, struct iommu_group *group)
7703d0407baSopenharmony_ci{
7713d0407baSopenharmony_ci    return -ENODEV;
7723d0407baSopenharmony_ci}
7733d0407baSopenharmony_ci
7743d0407baSopenharmony_cistatic inline void iommu_detach_group(struct iommu_domain *domain, struct iommu_group *group)
7753d0407baSopenharmony_ci{
7763d0407baSopenharmony_ci}
7773d0407baSopenharmony_ci
7783d0407baSopenharmony_cistatic inline struct iommu_group *iommu_group_alloc(void)
7793d0407baSopenharmony_ci{
7803d0407baSopenharmony_ci    return ERR_PTR(-ENODEV);
7813d0407baSopenharmony_ci}
7823d0407baSopenharmony_ci
7833d0407baSopenharmony_cistatic inline void *iommu_group_get_iommudata(struct iommu_group *group)
7843d0407baSopenharmony_ci{
7853d0407baSopenharmony_ci    return NULL;
7863d0407baSopenharmony_ci}
7873d0407baSopenharmony_ci
7883d0407baSopenharmony_cistatic inline void iommu_group_set_iommudata(struct iommu_group *group, void *iommu_data,
7893d0407baSopenharmony_ci                                             void (*release)(void *iommu_data))
7903d0407baSopenharmony_ci{
7913d0407baSopenharmony_ci}
7923d0407baSopenharmony_ci
7933d0407baSopenharmony_cistatic inline int iommu_group_set_name(struct iommu_group *group, const char *name)
7943d0407baSopenharmony_ci{
7953d0407baSopenharmony_ci    return -ENODEV;
7963d0407baSopenharmony_ci}
7973d0407baSopenharmony_ci
7983d0407baSopenharmony_cistatic inline int iommu_group_add_device(struct iommu_group *group, struct device *dev)
7993d0407baSopenharmony_ci{
8003d0407baSopenharmony_ci    return -ENODEV;
8013d0407baSopenharmony_ci}
8023d0407baSopenharmony_ci
8033d0407baSopenharmony_cistatic inline void iommu_group_remove_device(struct device *dev)
8043d0407baSopenharmony_ci{
8053d0407baSopenharmony_ci}
8063d0407baSopenharmony_ci
8073d0407baSopenharmony_cistatic inline int iommu_group_for_each_dev(struct iommu_group *group, void *data, int (*fn)(struct device *, void *))
8083d0407baSopenharmony_ci{
8093d0407baSopenharmony_ci    return -ENODEV;
8103d0407baSopenharmony_ci}
8113d0407baSopenharmony_ci
8123d0407baSopenharmony_cistatic inline struct iommu_group *iommu_group_get(struct device *dev)
8133d0407baSopenharmony_ci{
8143d0407baSopenharmony_ci    return NULL;
8153d0407baSopenharmony_ci}
8163d0407baSopenharmony_ci
8173d0407baSopenharmony_cistatic inline void iommu_group_put(struct iommu_group *group)
8183d0407baSopenharmony_ci{
8193d0407baSopenharmony_ci}
8203d0407baSopenharmony_ci
8213d0407baSopenharmony_cistatic inline int iommu_group_register_notifier(struct iommu_group *group, struct notifier_block *nb)
8223d0407baSopenharmony_ci{
8233d0407baSopenharmony_ci    return -ENODEV;
8243d0407baSopenharmony_ci}
8253d0407baSopenharmony_ci
8263d0407baSopenharmony_cistatic inline int iommu_group_unregister_notifier(struct iommu_group *group, struct notifier_block *nb)
8273d0407baSopenharmony_ci{
8283d0407baSopenharmony_ci    return 0;
8293d0407baSopenharmony_ci}
8303d0407baSopenharmony_ci
8313d0407baSopenharmony_cistatic inline int iommu_register_device_fault_handler(struct device *dev, iommu_dev_fault_handler_t handler, void *data)
8323d0407baSopenharmony_ci{
8333d0407baSopenharmony_ci    return -ENODEV;
8343d0407baSopenharmony_ci}
8353d0407baSopenharmony_ci
8363d0407baSopenharmony_cistatic inline int iommu_unregister_device_fault_handler(struct device *dev)
8373d0407baSopenharmony_ci{
8383d0407baSopenharmony_ci    return 0;
8393d0407baSopenharmony_ci}
8403d0407baSopenharmony_ci
8413d0407baSopenharmony_cistatic inline int iommu_report_device_fault(struct device *dev, struct iommu_fault_event *evt)
8423d0407baSopenharmony_ci{
8433d0407baSopenharmony_ci    return -ENODEV;
8443d0407baSopenharmony_ci}
8453d0407baSopenharmony_ci
8463d0407baSopenharmony_cistatic inline int iommu_page_response(struct device *dev, struct iommu_page_response *msg)
8473d0407baSopenharmony_ci{
8483d0407baSopenharmony_ci    return -ENODEV;
8493d0407baSopenharmony_ci}
8503d0407baSopenharmony_ci
8513d0407baSopenharmony_cistatic inline int iommu_group_id(struct iommu_group *group)
8523d0407baSopenharmony_ci{
8533d0407baSopenharmony_ci    return -ENODEV;
8543d0407baSopenharmony_ci}
8553d0407baSopenharmony_ci
8563d0407baSopenharmony_cistatic inline int iommu_domain_get_attr(struct iommu_domain *domain, enum iommu_attr attr, void *data)
8573d0407baSopenharmony_ci{
8583d0407baSopenharmony_ci    return -EINVAL;
8593d0407baSopenharmony_ci}
8603d0407baSopenharmony_ci
8613d0407baSopenharmony_cistatic inline int iommu_domain_set_attr(struct iommu_domain *domain, enum iommu_attr attr, void *data)
8623d0407baSopenharmony_ci{
8633d0407baSopenharmony_ci    return -EINVAL;
8643d0407baSopenharmony_ci}
8653d0407baSopenharmony_ci
8663d0407baSopenharmony_cistatic inline int iommu_device_register(struct iommu_device *iommu)
8673d0407baSopenharmony_ci{
8683d0407baSopenharmony_ci    return -ENODEV;
8693d0407baSopenharmony_ci}
8703d0407baSopenharmony_ci
8713d0407baSopenharmony_cistatic inline void iommu_device_set_ops(struct iommu_device *iommu, const struct iommu_ops *ops)
8723d0407baSopenharmony_ci{
8733d0407baSopenharmony_ci}
8743d0407baSopenharmony_ci
8753d0407baSopenharmony_cistatic inline void iommu_device_set_fwnode(struct iommu_device *iommu, struct fwnode_handle *fwnode)
8763d0407baSopenharmony_ci{
8773d0407baSopenharmony_ci}
8783d0407baSopenharmony_ci
8793d0407baSopenharmony_cistatic inline struct iommu_device *dev_to_iommu_device(struct device *dev)
8803d0407baSopenharmony_ci{
8813d0407baSopenharmony_ci    return NULL;
8823d0407baSopenharmony_ci}
8833d0407baSopenharmony_ci
8843d0407baSopenharmony_cistatic inline void iommu_iotlb_gather_init(struct iommu_iotlb_gather *gather)
8853d0407baSopenharmony_ci{
8863d0407baSopenharmony_ci}
8873d0407baSopenharmony_ci
8883d0407baSopenharmony_cistatic inline void iommu_iotlb_gather_add_page(struct iommu_domain *domain, struct iommu_iotlb_gather *gather,
8893d0407baSopenharmony_ci                                               unsigned long iova, size_t size)
8903d0407baSopenharmony_ci{
8913d0407baSopenharmony_ci}
8923d0407baSopenharmony_ci
8933d0407baSopenharmony_cistatic inline void iommu_device_unregister(struct iommu_device *iommu)
8943d0407baSopenharmony_ci{
8953d0407baSopenharmony_ci}
8963d0407baSopenharmony_ci
8973d0407baSopenharmony_cistatic inline int iommu_device_sysfs_add(struct iommu_device *iommu, struct device *parent,
8983d0407baSopenharmony_ci                                         const struct attribute_group **groups, const char *fmt, ...)
8993d0407baSopenharmony_ci{
9003d0407baSopenharmony_ci    return -ENODEV;
9013d0407baSopenharmony_ci}
9023d0407baSopenharmony_ci
9033d0407baSopenharmony_cistatic inline void iommu_device_sysfs_remove(struct iommu_device *iommu)
9043d0407baSopenharmony_ci{
9053d0407baSopenharmony_ci}
9063d0407baSopenharmony_ci
9073d0407baSopenharmony_cistatic inline int iommu_device_link(struct device *dev, struct device *link)
9083d0407baSopenharmony_ci{
9093d0407baSopenharmony_ci    return -EINVAL;
9103d0407baSopenharmony_ci}
9113d0407baSopenharmony_ci
9123d0407baSopenharmony_cistatic inline void iommu_device_unlink(struct device *dev, struct device *link)
9133d0407baSopenharmony_ci{
9143d0407baSopenharmony_ci}
9153d0407baSopenharmony_ci
9163d0407baSopenharmony_cistatic inline int iommu_fwspec_init(struct device *dev, struct fwnode_handle *iommu_fwnode, const struct iommu_ops *ops)
9173d0407baSopenharmony_ci{
9183d0407baSopenharmony_ci    return -ENODEV;
9193d0407baSopenharmony_ci}
9203d0407baSopenharmony_ci
9213d0407baSopenharmony_cistatic inline void iommu_fwspec_free(struct device *dev)
9223d0407baSopenharmony_ci{
9233d0407baSopenharmony_ci}
9243d0407baSopenharmony_ci
9253d0407baSopenharmony_cistatic inline int iommu_fwspec_add_ids(struct device *dev, u32 *ids, int num_ids)
9263d0407baSopenharmony_ci{
9273d0407baSopenharmony_ci    return -ENODEV;
9283d0407baSopenharmony_ci}
9293d0407baSopenharmony_ci
9303d0407baSopenharmony_cistatic inline const struct iommu_ops *iommu_ops_from_fwnode(struct fwnode_handle *fwnode)
9313d0407baSopenharmony_ci{
9323d0407baSopenharmony_ci    return NULL;
9333d0407baSopenharmony_ci}
9343d0407baSopenharmony_ci
9353d0407baSopenharmony_cistatic inline bool iommu_dev_has_feature(struct device *dev, enum iommu_dev_features feat)
9363d0407baSopenharmony_ci{
9373d0407baSopenharmony_ci    return false;
9383d0407baSopenharmony_ci}
9393d0407baSopenharmony_ci
9403d0407baSopenharmony_cistatic inline bool iommu_dev_feature_enabled(struct device *dev, enum iommu_dev_features feat)
9413d0407baSopenharmony_ci{
9423d0407baSopenharmony_ci    return false;
9433d0407baSopenharmony_ci}
9443d0407baSopenharmony_ci
9453d0407baSopenharmony_cistatic inline int iommu_dev_enable_feature(struct device *dev, enum iommu_dev_features feat)
9463d0407baSopenharmony_ci{
9473d0407baSopenharmony_ci    return -ENODEV;
9483d0407baSopenharmony_ci}
9493d0407baSopenharmony_ci
9503d0407baSopenharmony_cistatic inline int iommu_dev_disable_feature(struct device *dev, enum iommu_dev_features feat)
9513d0407baSopenharmony_ci{
9523d0407baSopenharmony_ci    return -ENODEV;
9533d0407baSopenharmony_ci}
9543d0407baSopenharmony_ci
9553d0407baSopenharmony_cistatic inline int iommu_aux_attach_device(struct iommu_domain *domain, struct device *dev)
9563d0407baSopenharmony_ci{
9573d0407baSopenharmony_ci    return -ENODEV;
9583d0407baSopenharmony_ci}
9593d0407baSopenharmony_ci
9603d0407baSopenharmony_cistatic inline void iommu_aux_detach_device(struct iommu_domain *domain, struct device *dev)
9613d0407baSopenharmony_ci{
9623d0407baSopenharmony_ci}
9633d0407baSopenharmony_ci
9643d0407baSopenharmony_cistatic inline int iommu_aux_get_pasid(struct iommu_domain *domain, struct device *dev)
9653d0407baSopenharmony_ci{
9663d0407baSopenharmony_ci    return -ENODEV;
9673d0407baSopenharmony_ci}
9683d0407baSopenharmony_ci
9693d0407baSopenharmony_cistatic inline struct iommu_sva *iommu_sva_bind_device(struct device *dev, struct mm_struct *mm, void *drvdata)
9703d0407baSopenharmony_ci{
9713d0407baSopenharmony_ci    return NULL;
9723d0407baSopenharmony_ci}
9733d0407baSopenharmony_ci
9743d0407baSopenharmony_cistatic inline void iommu_sva_unbind_device(struct iommu_sva *handle)
9753d0407baSopenharmony_ci{
9763d0407baSopenharmony_ci}
9773d0407baSopenharmony_ci
9783d0407baSopenharmony_cistatic inline u32 iommu_sva_get_pasid(struct iommu_sva *handle)
9793d0407baSopenharmony_ci{
9803d0407baSopenharmony_ci    return IOMMU_PASID_INVALID;
9813d0407baSopenharmony_ci}
9823d0407baSopenharmony_ci
9833d0407baSopenharmony_cistatic inline int iommu_uapi_cache_invalidate(struct iommu_domain *domain, struct device *dev,
9843d0407baSopenharmony_ci                                              struct iommu_cache_invalidate_info *inv_info)
9853d0407baSopenharmony_ci{
9863d0407baSopenharmony_ci    return -ENODEV;
9873d0407baSopenharmony_ci}
9883d0407baSopenharmony_ci
9893d0407baSopenharmony_cistatic inline int iommu_uapi_sva_bind_gpasid(struct iommu_domain *domain, struct device *dev, void __user *udata)
9903d0407baSopenharmony_ci{
9913d0407baSopenharmony_ci    return -ENODEV;
9923d0407baSopenharmony_ci}
9933d0407baSopenharmony_ci
9943d0407baSopenharmony_cistatic inline int iommu_uapi_sva_unbind_gpasid(struct iommu_domain *domain, struct device *dev, void __user *udata)
9953d0407baSopenharmony_ci{
9963d0407baSopenharmony_ci    return -ENODEV;
9973d0407baSopenharmony_ci}
9983d0407baSopenharmony_ci
9993d0407baSopenharmony_cistatic inline int iommu_sva_unbind_gpasid(struct iommu_domain *domain, struct device *dev, ioasid_t pasid)
10003d0407baSopenharmony_ci{
10013d0407baSopenharmony_ci    return -ENODEV;
10023d0407baSopenharmony_ci}
10033d0407baSopenharmony_ci
10043d0407baSopenharmony_cistatic inline struct iommu_fwspec *dev_iommu_fwspec_get(struct device *dev)
10053d0407baSopenharmony_ci{
10063d0407baSopenharmony_ci    return NULL;
10073d0407baSopenharmony_ci}
10083d0407baSopenharmony_ci
10093d0407baSopenharmony_cistatic inline void rk_iommu_mask_irq(struct device *dev)
10103d0407baSopenharmony_ci{
10113d0407baSopenharmony_ci}
10123d0407baSopenharmony_ci
10133d0407baSopenharmony_cistatic inline void rk_iommu_unmask_irq(struct device *dev)
10143d0407baSopenharmony_ci{
10153d0407baSopenharmony_ci}
10163d0407baSopenharmony_ci#endif /* CONFIG_IOMMU_API */
10173d0407baSopenharmony_ci
10183d0407baSopenharmony_ci/**
10193d0407baSopenharmony_ci * iommu_map_sgtable - Map the given buffer to the IOMMU domain
10203d0407baSopenharmony_ci * @domain:    The IOMMU domain to perform the mapping
10213d0407baSopenharmony_ci * @iova:    The start address to map the buffer
10223d0407baSopenharmony_ci * @sgt:    The sg_table object describing the buffer
10233d0407baSopenharmony_ci * @prot:    IOMMU protection bits
10243d0407baSopenharmony_ci *
10253d0407baSopenharmony_ci * Creates a mapping at @iova for the buffer described by a scatterlist
10263d0407baSopenharmony_ci * stored in the given sg_table object in the provided IOMMU domain.
10273d0407baSopenharmony_ci */
10283d0407baSopenharmony_cistatic inline size_t iommu_map_sgtable(struct iommu_domain *domain, unsigned long iova, struct sg_table *sgt, int prot)
10293d0407baSopenharmony_ci{
10303d0407baSopenharmony_ci    return iommu_map_sg(domain, iova, sgt->sgl, sgt->orig_nents, prot);
10313d0407baSopenharmony_ci}
10323d0407baSopenharmony_ci
10333d0407baSopenharmony_ci#ifdef CONFIG_IOMMU_DEBUGFS
10343d0407baSopenharmony_ciextern struct dentry *iommu_debugfs_dir;
10353d0407baSopenharmony_civoid iommu_debugfs_setup(void);
10363d0407baSopenharmony_ci#else
10373d0407baSopenharmony_cistatic inline void iommu_debugfs_setup(void)
10383d0407baSopenharmony_ci{
10393d0407baSopenharmony_ci}
10403d0407baSopenharmony_ci#endif
10413d0407baSopenharmony_ci
10423d0407baSopenharmony_ci#endif /* __LINUX_IOMMU_H */
1043