dma-mapping.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. /*
  2. * Implements the generic device dma API for microblaze and the pci
  3. *
  4. * Copyright (C) 2009-2010 Michal Simek <monstr@monstr.eu>
  5. * Copyright (C) 2009-2010 PetaLogix
  6. *
  7. * This file is subject to the terms and conditions of the GNU General
  8. * Public License. See the file COPYING in the main directory of this
  9. * archive for more details.
  10. *
  11. * This file is base on powerpc and x86 dma-mapping.h versions
  12. * Copyright (C) 2004 IBM
  13. */
  14. #ifndef _ASM_MICROBLAZE_DMA_MAPPING_H
  15. #define _ASM_MICROBLAZE_DMA_MAPPING_H
  16. /*
  17. * See Documentation/DMA-API-HOWTO.txt and
  18. * Documentation/DMA-API.txt for documentation.
  19. */
  20. #include <linux/types.h>
  21. #include <linux/cache.h>
  22. #include <linux/mm.h>
  23. #include <linux/scatterlist.h>
  24. #include <linux/dma-debug.h>
  25. #include <linux/dma-attrs.h>
  26. #include <asm/io.h>
  27. #include <asm/cacheflush.h>
  28. #define DMA_ERROR_CODE (~(dma_addr_t)0x0)
  29. #define __dma_alloc_coherent(dev, gfp, size, handle) NULL
  30. #define __dma_free_coherent(size, addr) ((void)0)
  31. /*
  32. * Available generic sets of operations
  33. */
  34. extern struct dma_map_ops dma_direct_ops;
  35. static inline struct dma_map_ops *get_dma_ops(struct device *dev)
  36. {
  37. return &dma_direct_ops;
  38. }
  39. #include <asm-generic/dma-mapping-common.h>
  40. static inline void __dma_sync(unsigned long paddr,
  41. size_t size, enum dma_data_direction direction)
  42. {
  43. switch (direction) {
  44. case DMA_TO_DEVICE:
  45. case DMA_BIDIRECTIONAL:
  46. flush_dcache_range(paddr, paddr + size);
  47. break;
  48. case DMA_FROM_DEVICE:
  49. invalidate_dcache_range(paddr, paddr + size);
  50. break;
  51. default:
  52. BUG();
  53. }
  54. }
  55. static inline void dma_cache_sync(struct device *dev, void *vaddr, size_t size,
  56. enum dma_data_direction direction)
  57. {
  58. BUG_ON(direction == DMA_NONE);
  59. __dma_sync(virt_to_phys(vaddr), size, (int)direction);
  60. }
  61. #endif /* _ASM_MICROBLAZE_DMA_MAPPING_H */