dma-mapping.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. /*
  2. * linux/arch/unicore32/include/asm/dma-mapping.h
  3. *
  4. * Code specific to PKUnity SoC and UniCore ISA
  5. *
  6. * Copyright (C) 2001-2010 GUAN Xue-tao
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License version 2 as
  10. * published by the Free Software Foundation.
  11. */
  12. #ifndef __UNICORE_DMA_MAPPING_H__
  13. #define __UNICORE_DMA_MAPPING_H__
  14. #ifdef __KERNEL__
  15. #include <linux/mm_types.h>
  16. #include <linux/scatterlist.h>
  17. #include <linux/swiotlb.h>
  18. #include <asm/memory.h>
  19. #include <asm/cacheflush.h>
  20. extern struct dma_map_ops swiotlb_dma_map_ops;
  21. static inline struct dma_map_ops *get_dma_ops(struct device *dev)
  22. {
  23. return &swiotlb_dma_map_ops;
  24. }
  25. static inline bool dma_capable(struct device *dev, dma_addr_t addr, size_t size)
  26. {
  27. if (dev && dev->dma_mask)
  28. return addr + size - 1 <= *dev->dma_mask;
  29. return 1;
  30. }
  31. static inline dma_addr_t phys_to_dma(struct device *dev, phys_addr_t paddr)
  32. {
  33. return paddr;
  34. }
  35. static inline phys_addr_t dma_to_phys(struct device *dev, dma_addr_t daddr)
  36. {
  37. return daddr;
  38. }
  39. static inline void dma_mark_clean(void *addr, size_t size) {}
  40. static inline void dma_cache_sync(struct device *dev, void *vaddr,
  41. size_t size, enum dma_data_direction direction)
  42. {
  43. unsigned long start = (unsigned long)vaddr;
  44. unsigned long end = start + size;
  45. switch (direction) {
  46. case DMA_NONE:
  47. BUG();
  48. case DMA_FROM_DEVICE:
  49. case DMA_BIDIRECTIONAL: /* writeback and invalidate */
  50. __cpuc_dma_flush_range(start, end);
  51. break;
  52. case DMA_TO_DEVICE: /* writeback only */
  53. __cpuc_dma_clean_range(start, end);
  54. break;
  55. }
  56. }
  57. #endif /* __KERNEL__ */
  58. #endif