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