dma-mapping.h 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. /*
  2. * Copyright 2004-2009 Analog Devices Inc.
  3. *
  4. * Licensed under the GPL-2 or later.
  5. */
  6. #ifndef _BLACKFIN_DMA_MAPPING_H
  7. #define _BLACKFIN_DMA_MAPPING_H
  8. #include <asm/cacheflush.h>
  9. extern void
  10. __dma_sync(dma_addr_t addr, size_t size, enum dma_data_direction dir);
  11. static inline void
  12. __dma_sync_inline(dma_addr_t addr, size_t size, enum dma_data_direction dir)
  13. {
  14. switch (dir) {
  15. case DMA_NONE:
  16. BUG();
  17. case DMA_TO_DEVICE: /* writeback only */
  18. flush_dcache_range(addr, addr + size);
  19. break;
  20. case DMA_FROM_DEVICE: /* invalidate only */
  21. case DMA_BIDIRECTIONAL: /* flush and invalidate */
  22. /* Blackfin has no dedicated invalidate (it includes a flush) */
  23. invalidate_dcache_range(addr, addr + size);
  24. break;
  25. }
  26. }
  27. static inline void
  28. _dma_sync(dma_addr_t addr, size_t size, enum dma_data_direction dir)
  29. {
  30. if (__builtin_constant_p(dir))
  31. __dma_sync_inline(addr, size, dir);
  32. else
  33. __dma_sync(addr, size, dir);
  34. }
  35. extern struct dma_map_ops bfin_dma_ops;
  36. static inline struct dma_map_ops *get_dma_ops(struct device *dev)
  37. {
  38. return &bfin_dma_ops;
  39. }
  40. #endif /* _BLACKFIN_DMA_MAPPING_H */