iomap_copy.c 807 B

1234567891011121314151617181920212223242526272829
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. #include <linux/export.h>
  3. #include <linux/io.h>
  4. /**
  5. * __ioread64_copy - copy data from MMIO space, in 64-bit units
  6. * @to: destination (must be 64-bit aligned)
  7. * @from: source, in MMIO space (must be 64-bit aligned)
  8. * @count: number of 64-bit quantities to copy
  9. *
  10. * Copy data from MMIO space to kernel space, in units of 32 or 64 bits at a
  11. * time. Order of access is not guaranteed, nor is a memory barrier
  12. * performed afterwards.
  13. */
  14. void __ioread64_copy(void *to, const void __iomem *from, size_t count)
  15. {
  16. #ifdef CONFIG_64BIT
  17. u64 *dst = to;
  18. const u64 __iomem *src = from;
  19. const u64 __iomem *end = src + count;
  20. while (src < end)
  21. *dst++ = __raw_readq(src++);
  22. #else
  23. __ioread32_copy(to, from, count * 2);
  24. #endif
  25. }
  26. EXPORT_SYMBOL_GPL(__ioread64_copy);