dma-mapping.h 3.3 KB

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