1 // SPDX-License-Identifier: GPL-2.0
3 * Copyright (C) 2020-2022 Loongson Technology Corporation Limited
5 #include <linux/export.h>
6 #include <linux/types.h>
10 * Copy data from IO memory space to "real" memory space.
12 void __memcpy_fromio(void *to, const volatile void __iomem *from, size_t count)
14 while (count && !IS_ALIGNED((unsigned long)from, 8)) {
15 *(u8 *)to = __raw_readb(from);
22 *(u64 *)to = __raw_readq(from);
29 *(u8 *)to = __raw_readb(from);
35 EXPORT_SYMBOL(__memcpy_fromio);
38 * Copy data from "real" memory space to IO memory space.
40 void __memcpy_toio(volatile void __iomem *to, const void *from, size_t count)
42 while (count && !IS_ALIGNED((unsigned long)to, 8)) {
43 __raw_writeb(*(u8 *)from, to);
50 __raw_writeq(*(u64 *)from, to);
57 __raw_writeb(*(u8 *)from, to);
63 EXPORT_SYMBOL(__memcpy_toio);
66 * "memset" on IO memory space.
68 void __memset_io(volatile void __iomem *dst, int c, size_t count)
76 while (count && !IS_ALIGNED((unsigned long)dst, 8)) {
83 __raw_writeq(qc, dst);
94 EXPORT_SYMBOL(__memset_io);