dma-mapping.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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 <asm/io.h>
  26. #include <asm/cacheflush.h>
  27. #define DMA_ERROR_CODE (~(dma_addr_t)0x0)
  28. #define __dma_alloc_coherent(dev, gfp, size, handle) NULL
  29. #define __dma_free_coherent(size, addr) ((void)0)
  30. /*
  31. * Available generic sets of operations
  32. */
  33. extern struct dma_map_ops dma_direct_ops;
  34. static inline struct dma_map_ops *get_dma_ops(struct device *dev)
  35. {
  36. return &dma_direct_ops;
  37. }
  38. static inline void __dma_sync(unsigned long paddr,
  39. size_t size, enum dma_data_direction direction)
  40. {
  41. switch (direction) {
  42. case DMA_TO_DEVICE:
  43. case DMA_BIDIRECTIONAL:
  44. flush_dcache_range(paddr, paddr + size);
  45. break;
  46. case DMA_FROM_DEVICE:
  47. invalidate_dcache_range(paddr, paddr + size);
  48. break;
  49. default:
  50. BUG();
  51. }
  52. }
  53. static inline void dma_cache_sync(struct device *dev, void *vaddr, size_t size,
  54. enum dma_data_direction direction)
  55. {
  56. BUG_ON(direction == DMA_NONE);
  57. __dma_sync(virt_to_phys(vaddr), size, (int)direction);
  58. }
  59. #endif /* _ASM_MICROBLAZE_DMA_MAPPING_H */