dma-mapping.h 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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 int dma_set_mask(struct device *dev, u64 dma_mask)
  18. {
  19. if (!dev->dma_mask || !dma_supported(dev, dma_mask))
  20. return -EIO;
  21. *dev->dma_mask = dma_mask;
  22. return 0;
  23. }
  24. /*
  25. * DMA errors are defined by all-bits-set in the DMA address.
  26. */
  27. static inline int dma_mapping_error(struct device *dev, dma_addr_t dma_addr)
  28. {
  29. return dma_addr == ~0;
  30. }
  31. extern dma_addr_t dma_map_single(struct device *dev, void *cpu_addr,
  32. size_t size, enum dma_data_direction dir);
  33. extern void dma_unmap_single(struct device *dev, dma_addr_t handle,
  34. size_t size, enum dma_data_direction dir);
  35. extern int dma_map_sg(struct device *dev, struct scatterlist *sglist,
  36. int nents, enum dma_data_direction direction);
  37. extern void dma_unmap_sg(struct device *dev, struct scatterlist *sglist,
  38. int nents, enum dma_data_direction direction);
  39. static inline dma_addr_t dma_map_page(struct device *dev, struct page *page,
  40. unsigned long offset, size_t size,
  41. enum dma_data_direction dir)
  42. {
  43. dma_addr_t handle;
  44. handle = dma_map_single(dev, page_address(page) + offset, size, dir);
  45. debug_dma_map_page(dev, page, offset, size, dir, handle, false);
  46. return handle;
  47. }
  48. static inline void dma_unmap_page(struct device *dev, dma_addr_t handle,
  49. size_t size, enum dma_data_direction dir)
  50. {
  51. dma_unmap_single(dev, handle, size, dir);
  52. debug_dma_unmap_page(dev, handle, size, dir, false);
  53. }
  54. extern void dma_sync_single_for_cpu(struct device *dev, dma_addr_t handle,
  55. size_t size, enum dma_data_direction dir);
  56. extern void dma_sync_single_for_device(struct device *dev, dma_addr_t handle,
  57. size_t size,
  58. enum dma_data_direction dir);
  59. extern void dma_sync_sg_for_cpu(struct device *dev, struct scatterlist *sg,
  60. int nents, enum dma_data_direction dir);
  61. extern void dma_sync_sg_for_device(struct device *dev, struct scatterlist *sg,
  62. int nents, enum dma_data_direction dir);
  63. extern void coherent_mem_init(u32 start, u32 size);
  64. extern void *dma_alloc_coherent(struct device *, size_t, dma_addr_t *, gfp_t);
  65. extern void dma_free_coherent(struct device *, size_t, void *, dma_addr_t);
  66. #define dma_alloc_noncoherent(d, s, h, f) dma_alloc_coherent((d), (s), (h), (f))
  67. #define dma_free_noncoherent(d, s, v, h) dma_free_coherent((d), (s), (v), (h))
  68. #endif /* _ASM_C6X_DMA_MAPPING_H */