2 * Based on arch/arm/kernel/io.c
4 * Copyright (C) 2012 ARM Ltd.
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 #include <linux/export.h>
20 #include <linux/types.h>
24 * Copy data from IO memory space to "real" memory space.
26 void __memcpy_fromio(void *to
, const volatile void __iomem
*from
, size_t count
)
28 while (count
&& !IS_ALIGNED((unsigned long)from
, 8)) {
29 *(u8
*)to
= __raw_readb(from
);
36 *(u64
*)to
= __raw_readq(from
);
43 *(u8
*)to
= __raw_readb(from
);
49 EXPORT_SYMBOL(__memcpy_fromio
);
52 * Copy data from "real" memory space to IO memory space.
54 void __memcpy_toio(volatile void __iomem
*to
, const void *from
, size_t count
)
56 while (count
&& !IS_ALIGNED((unsigned long)to
, 8)) {
57 __raw_writeb(*(u8
*)from
, to
);
64 __raw_writeq(*(u64
*)from
, to
);
71 __raw_writeb(*(u8
*)from
, to
);
77 EXPORT_SYMBOL(__memcpy_toio
);
80 * "memset" on IO memory space.
82 void __memset_io(volatile void __iomem
*dst
, int c
, size_t count
)
90 while (count
&& !IS_ALIGNED((unsigned long)dst
, 8)) {
97 __raw_writeq(qc
, dst
);
103 __raw_writeb(c
, dst
);
108 EXPORT_SYMBOL(__memset_io
);