dma.c 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. /*
  2. * This file is subject to the terms and conditions of the GNU General Public
  3. * License. See the file COPYING in the main directory of this archive
  4. * for more details.
  5. */
  6. #include <linux/dma-map-ops.h>
  7. #include <linux/kernel.h>
  8. #include <asm/cacheflush.h>
  9. #ifndef CONFIG_COLDFIRE
  10. void arch_dma_prep_coherent(struct page *page, size_t size)
  11. {
  12. cache_push(page_to_phys(page), size);
  13. }
  14. pgprot_t pgprot_dmacoherent(pgprot_t prot)
  15. {
  16. if (CPU_IS_040_OR_060) {
  17. pgprot_val(prot) &= ~_PAGE_CACHE040;
  18. pgprot_val(prot) |= _PAGE_GLOBAL040 | _PAGE_NOCACHE_S;
  19. } else {
  20. pgprot_val(prot) |= _PAGE_NOCACHE030;
  21. }
  22. return prot;
  23. }
  24. #endif /* CONFIG_MMU && !CONFIG_COLDFIRE */
  25. void arch_sync_dma_for_device(phys_addr_t handle, size_t size,
  26. enum dma_data_direction dir)
  27. {
  28. switch (dir) {
  29. case DMA_BIDIRECTIONAL:
  30. case DMA_TO_DEVICE:
  31. cache_push(handle, size);
  32. break;
  33. case DMA_FROM_DEVICE:
  34. cache_clear(handle, size);
  35. break;
  36. default:
  37. pr_err_ratelimited("dma_sync_single_for_device: unsupported dir %u\n",
  38. dir);
  39. break;
  40. }
  41. }