dma-mapping.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. #ifndef _M68K_DMA_MAPPING_H
  2. #define _M68K_DMA_MAPPING_H
  3. #include <asm/cache.h>
  4. struct scatterlist;
  5. static inline int dma_supported(struct device *dev, u64 mask)
  6. {
  7. return 1;
  8. }
  9. static inline int dma_set_mask(struct device *dev, u64 mask)
  10. {
  11. return 0;
  12. }
  13. extern void *dma_alloc_coherent(struct device *, size_t,
  14. dma_addr_t *, gfp_t);
  15. extern void dma_free_coherent(struct device *, size_t,
  16. void *, dma_addr_t);
  17. static inline void *dma_alloc_attrs(struct device *dev, size_t size,
  18. dma_addr_t *dma_handle, gfp_t flag,
  19. struct dma_attrs *attrs)
  20. {
  21. /* attrs is not supported and ignored */
  22. return dma_alloc_coherent(dev, size, dma_handle, flag);
  23. }
  24. static inline void dma_free_attrs(struct device *dev, size_t size,
  25. void *cpu_addr, dma_addr_t dma_handle,
  26. struct dma_attrs *attrs)
  27. {
  28. /* attrs is not supported and ignored */
  29. dma_free_coherent(dev, size, cpu_addr, dma_handle);
  30. }
  31. static inline void *dma_alloc_noncoherent(struct device *dev, size_t size,
  32. dma_addr_t *handle, gfp_t flag)
  33. {
  34. return dma_alloc_coherent(dev, size, handle, flag);
  35. }
  36. static inline void dma_free_noncoherent(struct device *dev, size_t size,
  37. void *addr, dma_addr_t handle)
  38. {
  39. dma_free_coherent(dev, size, addr, handle);
  40. }
  41. static inline void dma_cache_sync(struct device *dev, void *vaddr, size_t size,
  42. enum dma_data_direction dir)
  43. {
  44. /* we use coherent allocation, so not much to do here. */
  45. }
  46. extern dma_addr_t dma_map_single(struct device *, void *, size_t,
  47. enum dma_data_direction);
  48. static inline void dma_unmap_single(struct device *dev, dma_addr_t addr,
  49. size_t size, enum dma_data_direction dir)
  50. {
  51. }
  52. extern dma_addr_t dma_map_page(struct device *, struct page *,
  53. unsigned long, size_t size,
  54. enum dma_data_direction);
  55. static inline void dma_unmap_page(struct device *dev, dma_addr_t address,
  56. size_t size, enum dma_data_direction dir)
  57. {
  58. }
  59. extern int dma_map_sg(struct device *, struct scatterlist *, int,
  60. enum dma_data_direction);
  61. static inline void dma_unmap_sg(struct device *dev, struct scatterlist *sg,
  62. int nhwentries, enum dma_data_direction dir)
  63. {
  64. }
  65. extern void dma_sync_single_for_device(struct device *, dma_addr_t, size_t,
  66. enum dma_data_direction);
  67. extern void dma_sync_sg_for_device(struct device *, struct scatterlist *, int,
  68. enum dma_data_direction);
  69. static inline void dma_sync_single_range_for_device(struct device *dev,
  70. dma_addr_t dma_handle, unsigned long offset, size_t size,
  71. enum dma_data_direction direction)
  72. {
  73. /* just sync everything for now */
  74. dma_sync_single_for_device(dev, dma_handle, offset + size, direction);
  75. }
  76. static inline void dma_sync_single_for_cpu(struct device *dev, dma_addr_t handle,
  77. size_t size, enum dma_data_direction dir)
  78. {
  79. }
  80. static inline void dma_sync_sg_for_cpu(struct device *dev, struct scatterlist *sg,
  81. int nents, enum dma_data_direction dir)
  82. {
  83. }
  84. static inline void dma_sync_single_range_for_cpu(struct device *dev,
  85. dma_addr_t dma_handle, unsigned long offset, size_t size,
  86. enum dma_data_direction direction)
  87. {
  88. /* just sync everything for now */
  89. dma_sync_single_for_cpu(dev, dma_handle, offset + size, direction);
  90. }
  91. static inline int dma_mapping_error(struct device *dev, dma_addr_t handle)
  92. {
  93. return 0;
  94. }
  95. /* drivers/base/dma-mapping.c */
  96. extern int dma_common_mmap(struct device *dev, struct vm_area_struct *vma,
  97. void *cpu_addr, dma_addr_t dma_addr, size_t size);
  98. extern int dma_common_get_sgtable(struct device *dev, struct sg_table *sgt,
  99. void *cpu_addr, dma_addr_t dma_addr,
  100. size_t size);
  101. #define dma_mmap_coherent(d, v, c, h, s) dma_common_mmap(d, v, c, h, s)
  102. #define dma_get_sgtable(d, t, v, h, s) dma_common_get_sgtable(d, t, v, h, s)
  103. #endif /* _M68K_DMA_MAPPING_H */