1 /* SPDX-License-Identifier: (GPL-2.0+ OR BSD-3-Clause) */ 2 /* 3 * Copyright 2013-2016 Freescale Semiconductor Inc. 4 * Copyright 2016,2019-2020 NXP 5 */ 6 7 #ifndef VFIO_FSL_MC_PRIVATE_H 8 #define VFIO_FSL_MC_PRIVATE_H 9 10 #define VFIO_FSL_MC_OFFSET_SHIFT 40 11 #define VFIO_FSL_MC_OFFSET_MASK (((u64)(1) << VFIO_FSL_MC_OFFSET_SHIFT) - 1) 12 13 #define VFIO_FSL_MC_OFFSET_TO_INDEX(off) ((off) >> VFIO_FSL_MC_OFFSET_SHIFT) 14 15 #define VFIO_FSL_MC_INDEX_TO_OFFSET(index) \ 16 ((u64)(index) << VFIO_FSL_MC_OFFSET_SHIFT) 17 18 struct vfio_fsl_mc_irq { 19 u32 flags; 20 u32 count; 21 struct eventfd_ctx *trigger; 22 char *name; 23 }; 24 25 struct vfio_fsl_mc_reflck { 26 struct kref kref; 27 struct mutex lock; 28 }; 29 30 struct vfio_fsl_mc_region { 31 u32 flags; 32 u32 type; 33 u64 addr; 34 resource_size_t size; 35 void __iomem *ioaddr; 36 }; 37 38 struct vfio_fsl_mc_device { 39 struct fsl_mc_device *mc_dev; 40 struct notifier_block nb; 41 int refcnt; 42 struct vfio_fsl_mc_region *regions; 43 struct vfio_fsl_mc_reflck *reflck; 44 struct mutex igate; 45 struct vfio_fsl_mc_irq *mc_irqs; 46 }; 47 48 extern int vfio_fsl_mc_set_irqs_ioctl(struct vfio_fsl_mc_device *vdev, 49 u32 flags, unsigned int index, 50 unsigned int start, unsigned int count, 51 void *data); 52 53 void vfio_fsl_mc_irqs_cleanup(struct vfio_fsl_mc_device *vdev); 54 55 #endif /* VFIO_FSL_MC_PRIVATE_H */ 56