Merge tag 'thermal-v5.13-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/therma...
[linux-2.6-microblaze.git] / drivers / vfio / fsl-mc / vfio_fsl_mc_private.h
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 vfio_device              vdev;
40         struct fsl_mc_device            *mc_dev;
41         struct notifier_block        nb;
42         int                             refcnt;
43         struct vfio_fsl_mc_region       *regions;
44         struct vfio_fsl_mc_reflck   *reflck;
45         struct mutex         igate;
46         struct vfio_fsl_mc_irq      *mc_irqs;
47 };
48
49 extern int vfio_fsl_mc_set_irqs_ioctl(struct vfio_fsl_mc_device *vdev,
50                                u32 flags, unsigned int index,
51                                unsigned int start, unsigned int count,
52                                void *data);
53
54 void vfio_fsl_mc_irqs_cleanup(struct vfio_fsl_mc_device *vdev);
55
56 #endif /* VFIO_FSL_MC_PRIVATE_H */