dma-mapping.h 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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. #include <asm-generic/dma-mapping-common.h>
  26. static inline bool dma_capable(struct device *dev, dma_addr_t addr, size_t size)
  27. {
  28. if (dev && dev->dma_mask)
  29. return addr + size - 1 <= *dev->dma_mask;
  30. return 1;
  31. }
  32. static inline dma_addr_t phys_to_dma(struct device *dev, phys_addr_t paddr)
  33. {
  34. return paddr;
  35. }
  36. static inline phys_addr_t dma_to_phys(struct device *dev, dma_addr_t daddr)
  37. {
  38. return daddr;
  39. }
  40. static inline void dma_mark_clean(void *addr, size_t size) {}
  41. static inline void dma_cache_sync(struct device *dev, void *vaddr,
  42. size_t size, enum dma_data_direction direction)
  43. {
  44. unsigned long start = (unsigned long)vaddr;
  45. unsigned long end = start + size;
  46. switch (direction) {
  47. case DMA_NONE:
  48. BUG();
  49. case DMA_FROM_DEVICE:
  50. case DMA_BIDIRECTIONAL: /* writeback and invalidate */
  51. __cpuc_dma_flush_range(start, end);
  52. break;
  53. case DMA_TO_DEVICE: /* writeback only */
  54. __cpuc_dma_clean_range(start, end);
  55. break;
  56. }
  57. }
  58. #endif /* __KERNEL__ */
  59. #endif