1 // SPDX-License-Identifier: GPL-2.0-only
3 * Based on arch/arm/kernel/io.c
5 * Copyright (C) 2012 ARM Ltd.
8 #include <linux/export.h>
9 #include <linux/types.h>
13 * Copy data from IO memory space to "real" memory space.
15 void __memcpy_fromio(void *to
, const volatile void __iomem
*from
, size_t count
)
17 while (count
&& !IS_ALIGNED((unsigned long)from
, 8)) {
18 *(u8
*)to
= __raw_readb(from
);
25 *(u64
*)to
= __raw_readq(from
);
32 *(u8
*)to
= __raw_readb(from
);
38 EXPORT_SYMBOL(__memcpy_fromio
);
41 * Copy data from "real" memory space to IO memory space.
43 void __memcpy_toio(volatile void __iomem
*to
, const void *from
, size_t count
)
45 while (count
&& !IS_ALIGNED((unsigned long)to
, 8)) {
46 __raw_writeb(*(u8
*)from
, to
);
53 __raw_writeq(*(u64
*)from
, to
);
60 __raw_writeb(*(u8
*)from
, to
);
66 EXPORT_SYMBOL(__memcpy_toio
);
69 * "memset" on IO memory space.
71 void __memset_io(volatile void __iomem
*dst
, int c
, size_t count
)
79 while (count
&& !IS_ALIGNED((unsigned long)dst
, 8)) {
86 __raw_writeq(qc
, dst
);
97 EXPORT_SYMBOL(__memset_io
);