iovmm.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. /*
  2. * omap iommu: simple virtual address space management
  3. *
  4. * Copyright (C) 2008-2009 Nokia Corporation
  5. *
  6. * Written by Hiroshi DOYU <Hiroshi.DOYU@nokia.com>
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License version 2 as
  10. * published by the Free Software Foundation.
  11. */
  12. #ifndef __IOMMU_MMAP_H
  13. #define __IOMMU_MMAP_H
  14. #include <linux/iommu.h>
  15. struct iovm_struct {
  16. struct omap_iommu *iommu; /* iommu object which this belongs to */
  17. u32 da_start; /* area definition */
  18. u32 da_end;
  19. u32 flags; /* IOVMF_: see below */
  20. struct list_head list; /* linked in ascending order */
  21. const struct sg_table *sgt; /* keep 'page' <-> 'da' mapping */
  22. void *va; /* mpu side mapped address */
  23. };
  24. /*
  25. * IOVMF_FLAGS: attribute for iommu virtual memory area(iovma)
  26. *
  27. * lower 16 bit is used for h/w and upper 16 bit is for s/w.
  28. */
  29. #define IOVMF_SW_SHIFT 16
  30. /*
  31. * iovma: h/w flags derived from cam and ram attribute
  32. */
  33. #define IOVMF_CAM_MASK (~((1 << 10) - 1))
  34. #define IOVMF_RAM_MASK (~IOVMF_CAM_MASK)
  35. #define IOVMF_PGSZ_MASK (3 << 0)
  36. #define IOVMF_PGSZ_1M MMU_CAM_PGSZ_1M
  37. #define IOVMF_PGSZ_64K MMU_CAM_PGSZ_64K
  38. #define IOVMF_PGSZ_4K MMU_CAM_PGSZ_4K
  39. #define IOVMF_PGSZ_16M MMU_CAM_PGSZ_16M
  40. #define IOVMF_ENDIAN_MASK (1 << 9)
  41. #define IOVMF_ENDIAN_BIG MMU_RAM_ENDIAN_BIG
  42. #define IOVMF_ENDIAN_LITTLE MMU_RAM_ENDIAN_LITTLE
  43. #define IOVMF_ELSZ_MASK (3 << 7)
  44. #define IOVMF_ELSZ_8 MMU_RAM_ELSZ_8
  45. #define IOVMF_ELSZ_16 MMU_RAM_ELSZ_16
  46. #define IOVMF_ELSZ_32 MMU_RAM_ELSZ_32
  47. #define IOVMF_ELSZ_NONE MMU_RAM_ELSZ_NONE
  48. #define IOVMF_MIXED_MASK (1 << 6)
  49. #define IOVMF_MIXED MMU_RAM_MIXED
  50. /*
  51. * iovma: s/w flags, used for mapping and umapping internally.
  52. */
  53. #define IOVMF_MMIO (1 << IOVMF_SW_SHIFT)
  54. #define IOVMF_ALLOC (2 << IOVMF_SW_SHIFT)
  55. #define IOVMF_ALLOC_MASK (3 << IOVMF_SW_SHIFT)
  56. /* "superpages" is supported just with physically linear pages */
  57. #define IOVMF_DISCONT (1 << (2 + IOVMF_SW_SHIFT))
  58. #define IOVMF_LINEAR (2 << (2 + IOVMF_SW_SHIFT))
  59. #define IOVMF_LINEAR_MASK (3 << (2 + IOVMF_SW_SHIFT))
  60. #define IOVMF_DA_FIXED (1 << (4 + IOVMF_SW_SHIFT))
  61. extern struct iovm_struct *omap_find_iovm_area(struct device *dev, u32 da);
  62. extern u32
  63. omap_iommu_vmap(struct iommu_domain *domain, struct device *dev, u32 da,
  64. const struct sg_table *sgt, u32 flags);
  65. extern struct sg_table *omap_iommu_vunmap(struct iommu_domain *domain,
  66. struct device *dev, u32 da);
  67. extern u32
  68. omap_iommu_vmalloc(struct iommu_domain *domain, struct device *dev,
  69. u32 da, size_t bytes, u32 flags);
  70. extern void
  71. omap_iommu_vfree(struct iommu_domain *domain, struct device *dev,
  72. const u32 da);
  73. extern void *omap_da_to_va(struct device *dev, u32 da);
  74. #endif /* __IOMMU_MMAP_H */