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