dma-mapping.h 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. /*
  2. * Copyright 2010 Tilera Corporation. All Rights Reserved.
  3. *
  4. * This program is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU General Public License
  6. * as published by the Free Software Foundation, version 2.
  7. *
  8. * This program is distributed in the hope that it will be useful, but
  9. * WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
  11. * NON INFRINGEMENT. See the GNU General Public License for
  12. * more details.
  13. */
  14. #ifndef _ASM_TILE_DMA_MAPPING_H
  15. #define _ASM_TILE_DMA_MAPPING_H
  16. #include <linux/mm.h>
  17. #include <linux/scatterlist.h>
  18. #include <linux/cache.h>
  19. #include <linux/io.h>
  20. /*
  21. * Note that on x86 and powerpc, there is a "struct dma_mapping_ops"
  22. * that is used for all the DMA operations. For now, we don't have an
  23. * equivalent on tile, because we only have a single way of doing DMA.
  24. * (Tilera bug 7994 to use dma_mapping_ops.)
  25. */
  26. #define dma_alloc_noncoherent(d, s, h, f) dma_alloc_coherent(d, s, h, f)
  27. #define dma_free_noncoherent(d, s, v, h) dma_free_coherent(d, s, v, h)
  28. extern dma_addr_t dma_map_single(struct device *dev, void *ptr, size_t size,
  29. enum dma_data_direction);
  30. extern void dma_unmap_single(struct device *dev, dma_addr_t dma_addr,
  31. size_t size, enum dma_data_direction);
  32. extern int dma_map_sg(struct device *dev, struct scatterlist *sg, int nents,
  33. enum dma_data_direction);
  34. extern void dma_unmap_sg(struct device *dev, struct scatterlist *sg,
  35. int nhwentries, enum dma_data_direction);
  36. extern dma_addr_t dma_map_page(struct device *dev, struct page *page,
  37. unsigned long offset, size_t size,
  38. enum dma_data_direction);
  39. extern void dma_unmap_page(struct device *dev, dma_addr_t dma_address,
  40. size_t size, enum dma_data_direction);
  41. extern void dma_sync_sg_for_cpu(struct device *dev, struct scatterlist *sg,
  42. int nelems, enum dma_data_direction);
  43. extern void dma_sync_sg_for_device(struct device *dev, struct scatterlist *sg,
  44. int nelems, enum dma_data_direction);
  45. void *dma_alloc_coherent(struct device *dev, size_t size,
  46. dma_addr_t *dma_handle, gfp_t flag);
  47. void dma_free_coherent(struct device *dev, size_t size,
  48. void *vaddr, dma_addr_t dma_handle);
  49. extern void dma_sync_single_for_cpu(struct device *, dma_addr_t, size_t,
  50. enum dma_data_direction);
  51. extern void dma_sync_single_for_device(struct device *, dma_addr_t,
  52. size_t, enum dma_data_direction);
  53. extern void dma_sync_single_range_for_cpu(struct device *, dma_addr_t,
  54. unsigned long offset, size_t,
  55. enum dma_data_direction);
  56. extern void dma_sync_single_range_for_device(struct device *, dma_addr_t,
  57. unsigned long offset, size_t,
  58. enum dma_data_direction);
  59. extern void dma_cache_sync(struct device *dev, void *vaddr, size_t,
  60. enum dma_data_direction);
  61. static inline int
  62. dma_mapping_error(struct device *dev, dma_addr_t dma_addr)
  63. {
  64. return 0;
  65. }
  66. static inline int
  67. dma_supported(struct device *dev, u64 mask)
  68. {
  69. return 1;
  70. }
  71. static inline int
  72. dma_set_mask(struct device *dev, u64 mask)
  73. {
  74. if (!dev->dma_mask || !dma_supported(dev, mask))
  75. return -EIO;
  76. *dev->dma_mask = mask;
  77. return 0;
  78. }
  79. #endif /* _ASM_TILE_DMA_MAPPING_H */