blob: 240059cd818541f71380d1dc5b52ebc95495862c [file] [log] [blame]
Christoph Hellwig9b8eeab2019-01-29 19:13:04 +01001#ifndef _IOMMU_H
2#define _IOMMU_H 1
3
4#include <linux/pci.h>
5
6struct parisc_device;
7struct ioc;
8
Christoph Hellwigcb0f7ab2019-01-29 19:13:07 +01009static inline struct pci_hba_data *parisc_walk_tree(struct device *dev)
Christoph Hellwig9b8eeab2019-01-29 19:13:04 +010010{
11 struct device *otherdev;
12
13 if (likely(dev->platform_data))
14 return dev->platform_data;
15
16 /* OK, just traverse the bus to find it */
17 for (otherdev = dev->parent;
18 otherdev;
19 otherdev = otherdev->parent) {
20 if (otherdev->platform_data) {
21 dev->platform_data = otherdev->platform_data;
22 break;
23 }
24 }
25
26 return dev->platform_data;
27}
28
Christoph Hellwig25c9dbe2019-01-29 19:13:05 +010029static inline struct ioc *GET_IOC(struct device *dev)
30{
31 struct pci_hba_data *pdata = parisc_walk_tree(dev);
32
33 if (!pdata)
34 return NULL;
35 return pdata->iommu;
36}
Christoph Hellwig9b8eeab2019-01-29 19:13:04 +010037
38#ifdef CONFIG_IOMMU_CCIO
39void *ccio_get_iommu(const struct parisc_device *dev);
40int ccio_request_resource(const struct parisc_device *dev,
41 struct resource *res);
42int ccio_allocate_resource(const struct parisc_device *dev,
43 struct resource *res, unsigned long size,
44 unsigned long min, unsigned long max, unsigned long align);
45#else /* !CONFIG_IOMMU_CCIO */
46#define ccio_get_iommu(dev) NULL
47#define ccio_request_resource(dev, res) insert_resource(&iomem_resource, res)
48#define ccio_allocate_resource(dev, res, size, min, max, align) \
49 allocate_resource(&iomem_resource, res, size, min, max, \
50 align, NULL, NULL)
51#endif /* !CONFIG_IOMMU_CCIO */
52
53void *sba_get_iommu(struct parisc_device *dev);
54
55#endif /* _IOMMU_H */