dma-mapping.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. #ifndef _BLACKFIN_DMA_MAPPING_H
  2. #define _BLACKFIN_DMA_MAPPING_H
  3. #include <asm/scatterlist.h>
  4. void dma_alloc_init(unsigned long start, unsigned long end);
  5. void *dma_alloc_coherent(struct device *dev, size_t size,
  6. dma_addr_t *dma_handle, gfp_t gfp);
  7. void dma_free_coherent(struct device *dev, size_t size, void *vaddr,
  8. dma_addr_t dma_handle);
  9. /*
  10. * Now for the API extensions over the pci_ one
  11. */
  12. #define dma_alloc_noncoherent(d, s, h, f) dma_alloc_coherent(d, s, h, f)
  13. #define dma_free_noncoherent(d, s, v, h) dma_free_coherent(d, s, v, h)
  14. /*
  15. * Map a single buffer of the indicated size for DMA in streaming mode.
  16. * The 32-bit bus address to use is returned.
  17. *
  18. * Once the device is given the dma address, the device owns this memory
  19. * until either pci_unmap_single or pci_dma_sync_single is performed.
  20. */
  21. extern dma_addr_t dma_map_single(struct device *dev, void *ptr, size_t size,
  22. enum dma_data_direction direction);
  23. /*
  24. * Unmap a single streaming mode DMA translation. The dma_addr and size
  25. * must match what was provided for in a previous pci_map_single call. All
  26. * other usages are undefined.
  27. *
  28. * After this call, reads by the cpu to the buffer are guarenteed to see
  29. * whatever the device wrote there.
  30. */
  31. extern void dma_unmap_single(struct device *dev, dma_addr_t dma_addr, size_t size,
  32. enum dma_data_direction direction);
  33. /*
  34. * Map a set of buffers described by scatterlist in streaming
  35. * mode for DMA. This is the scather-gather version of the
  36. * above pci_map_single interface. Here the scatter gather list
  37. * elements are each tagged with the appropriate dma address
  38. * and length. They are obtained via sg_dma_{address,length}(SG).
  39. *
  40. * NOTE: An implementation may be able to use a smaller number of
  41. * DMA address/length pairs than there are SG table elements.
  42. * (for example via virtual mapping capabilities)
  43. * The routine returns the number of addr/length pairs actually
  44. * used, at most nents.
  45. *
  46. * Device ownership issues as mentioned above for pci_map_single are
  47. * the same here.
  48. */
  49. extern int dma_map_sg(struct device *dev, struct scatterlist *sg, int nents,
  50. enum dma_data_direction direction);
  51. /*
  52. * Unmap a set of streaming mode DMA translations.
  53. * Again, cpu read rules concerning calls here are the same as for
  54. * pci_unmap_single() above.
  55. */
  56. extern void dma_unmap_sg(struct device *dev, struct scatterlist *sg,
  57. int nhwentries, enum dma_data_direction direction);
  58. #endif /* _BLACKFIN_DMA_MAPPING_H */