iommu.h 1.4 KB

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