dma-mapping.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. /*
  2. * Port on Texas Instruments TMS320C6x architecture
  3. *
  4. * Copyright (C) 2004, 2009, 2010, 2011 Texas Instruments Incorporated
  5. * Author: Aurelien Jacquiot <aurelien.jacquiot@ti.com>
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License version 2 as
  9. * published by the Free Software Foundation.
  10. *
  11. */
  12. #ifndef _ASM_C6X_DMA_MAPPING_H
  13. #define _ASM_C6X_DMA_MAPPING_H
  14. #include <linux/dma-debug.h>
  15. #include <asm-generic/dma-coherent.h>
  16. #define dma_supported(d, m) 1
  17. static inline void dma_sync_single_range_for_device(struct device *dev,
  18. dma_addr_t addr,
  19. unsigned long offset,
  20. size_t size,
  21. enum dma_data_direction dir)
  22. {
  23. }
  24. static inline int dma_set_mask(struct device *dev, u64 dma_mask)
  25. {
  26. if (!dev->dma_mask || !dma_supported(dev, dma_mask))
  27. return -EIO;
  28. *dev->dma_mask = dma_mask;
  29. return 0;
  30. }
  31. /*
  32. * DMA errors are defined by all-bits-set in the DMA address.
  33. */
  34. static inline int dma_mapping_error(struct device *dev, dma_addr_t dma_addr)
  35. {
  36. debug_dma_mapping_error(dev, dma_addr);
  37. return dma_addr == ~0;
  38. }
  39. extern dma_addr_t dma_map_single(struct device *dev, void *cpu_addr,
  40. size_t size, enum dma_data_direction dir);
  41. extern void dma_unmap_single(struct device *dev, dma_addr_t handle,
  42. size_t size, enum dma_data_direction dir);
  43. extern int dma_map_sg(struct device *dev, struct scatterlist *sglist,
  44. int nents, enum dma_data_direction direction);
  45. extern void dma_unmap_sg(struct device *dev, struct scatterlist *sglist,
  46. int nents, enum dma_data_direction direction);
  47. static inline dma_addr_t dma_map_page(struct device *dev, struct page *page,
  48. unsigned long offset, size_t size,
  49. enum dma_data_direction dir)
  50. {
  51. dma_addr_t handle;
  52. handle = dma_map_single(dev, page_address(page) + offset, size, dir);
  53. debug_dma_map_page(dev, page, offset, size, dir, handle, false);
  54. return handle;
  55. }
  56. static inline void dma_unmap_page(struct device *dev, dma_addr_t handle,
  57. size_t size, enum dma_data_direction dir)
  58. {
  59. dma_unmap_single(dev, handle, size, dir);
  60. debug_dma_unmap_page(dev, handle, size, dir, false);
  61. }
  62. extern void dma_sync_single_for_cpu(struct device *dev, dma_addr_t handle,
  63. size_t size, enum dma_data_direction dir);
  64. extern void dma_sync_single_for_device(struct device *dev, dma_addr_t handle,
  65. size_t size,
  66. enum dma_data_direction dir);
  67. extern void dma_sync_sg_for_cpu(struct device *dev, struct scatterlist *sg,
  68. int nents, enum dma_data_direction dir);
  69. extern void dma_sync_sg_for_device(struct device *dev, struct scatterlist *sg,
  70. int nents, enum dma_data_direction dir);
  71. extern void coherent_mem_init(u32 start, u32 size);
  72. extern void *dma_alloc_coherent(struct device *, size_t, dma_addr_t *, gfp_t);
  73. extern void dma_free_coherent(struct device *, size_t, void *, dma_addr_t);
  74. #define dma_alloc_noncoherent(d, s, h, f) dma_alloc_coherent((d), (s), (h), (f))
  75. #define dma_free_noncoherent(d, s, v, h) dma_free_coherent((d), (s), (v), (h))
  76. /* Not supported for now */
  77. static inline int dma_mmap_coherent(struct device *dev,
  78. struct vm_area_struct *vma, void *cpu_addr,
  79. dma_addr_t dma_addr, size_t size)
  80. {
  81. return -EINVAL;
  82. }
  83. static inline int dma_get_sgtable(struct device *dev, struct sg_table *sgt,
  84. void *cpu_addr, dma_addr_t dma_addr,
  85. size_t size)
  86. {
  87. return -EINVAL;
  88. }
  89. #endif /* _ASM_C6X_DMA_MAPPING_H */