of_iommu.h 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. #ifndef __OF_IOMMU_H
  2. #define __OF_IOMMU_H
  3. #include <linux/iommu.h>
  4. #include <linux/of.h>
  5. #ifdef CONFIG_OF_IOMMU
  6. extern int of_get_dma_window(struct device_node *dn, const char *prefix,
  7. int index, unsigned long *busno, dma_addr_t *addr,
  8. size_t *size);
  9. extern void of_iommu_init(void);
  10. #else
  11. static inline int of_get_dma_window(struct device_node *dn, const char *prefix,
  12. int index, unsigned long *busno, dma_addr_t *addr,
  13. size_t *size)
  14. {
  15. return -EINVAL;
  16. }
  17. static inline void of_iommu_init(void) { }
  18. #endif /* CONFIG_OF_IOMMU */
  19. static inline void of_iommu_set_ops(struct device_node *np,
  20. const struct iommu_ops *ops)
  21. {
  22. np->data = (struct iommu_ops *)ops;
  23. }
  24. static inline struct iommu_ops *of_iommu_get_ops(struct device_node *np)
  25. {
  26. return np->data;
  27. }
  28. extern struct of_device_id __iommu_of_table;
  29. typedef int (*of_iommu_init_fn)(struct device_node *);
  30. #define IOMMU_OF_DECLARE(name, compat, fn) \
  31. _OF_DECLARE(iommu, name, compat, fn, of_iommu_init_fn)
  32. #endif /* __OF_IOMMU_H */