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