1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 /* Generic I/O port emulation.
4 * Copyright (C) 2007 Red Hat, Inc. All Rights Reserved.
5 * Written by David Howells (dhowells@redhat.com)
7 #ifndef __ASM_GENERIC_IO_H
8 #define __ASM_GENERIC_IO_H
10 #include <asm/page.h> /* I/O is all done through memory accesses */
11 #include <linux/string.h> /* for memset() and memcpy() */
12 #include <linux/types.h>
13 #include <linux/instruction_pointer.h>
15 #ifdef CONFIG_GENERIC_IOMAP
16 #include <asm-generic/iomap.h>
19 #include <asm/mmiowb.h>
20 #include <asm-generic/pci_iomap.h>
23 #define __io_br() barrier()
26 /* prevent prefetching of coherent DMA data ahead of a dma-complete */
29 #define __io_ar(v) rmb()
31 #define __io_ar(v) barrier()
35 /* flush writes to coherent DMA data before possibly triggering a DMA read */
38 #define __io_bw() wmb()
40 #define __io_bw() barrier()
44 /* serialize device access against a spin_unlock, usually handled there. */
46 #define __io_aw() mmiowb_set_pending()
50 #define __io_pbw() __io_bw()
54 #define __io_paw() __io_aw()
58 #define __io_pbr() __io_br()
62 #define __io_par(v) __io_ar(v)
66 * "__DISABLE_TRACE_MMIO__" flag can be used to disable MMIO tracing for
67 * specific kernel drivers in case of excessive/unwanted logging.
69 * Usage: Add a #define flag at the beginning of the driver file.
70 * Ex: #define __DISABLE_TRACE_MMIO__
74 #if IS_ENABLED(CONFIG_TRACE_MMIO_ACCESS) && !(defined(__DISABLE_TRACE_MMIO__))
75 #include <linux/tracepoint-defs.h>
77 DECLARE_TRACEPOINT(rwmmio_write);
78 DECLARE_TRACEPOINT(rwmmio_post_write);
79 DECLARE_TRACEPOINT(rwmmio_read);
80 DECLARE_TRACEPOINT(rwmmio_post_read);
82 void log_write_mmio(u64 val, u8 width, volatile void __iomem *addr,
83 unsigned long caller_addr);
84 void log_post_write_mmio(u64 val, u8 width, volatile void __iomem *addr,
85 unsigned long caller_addr);
86 void log_read_mmio(u8 width, const volatile void __iomem *addr,
87 unsigned long caller_addr);
88 void log_post_read_mmio(u64 val, u8 width, const volatile void __iomem *addr,
89 unsigned long caller_addr);
93 static inline void log_write_mmio(u64 val, u8 width, volatile void __iomem *addr,
94 unsigned long caller_addr) {}
95 static inline void log_post_write_mmio(u64 val, u8 width, volatile void __iomem *addr,
96 unsigned long caller_addr) {}
97 static inline void log_read_mmio(u8 width, const volatile void __iomem *addr,
98 unsigned long caller_addr) {}
99 static inline void log_post_read_mmio(u64 val, u8 width, const volatile void __iomem *addr,
100 unsigned long caller_addr) {}
102 #endif /* CONFIG_TRACE_MMIO_ACCESS */
105 * __raw_{read,write}{b,w,l,q}() access memory in native endianness.
107 * On some architectures memory mapped IO needs to be accessed differently.
108 * On the simple architectures, we just read/write the memory location
113 #define __raw_readb __raw_readb
114 static inline u8 __raw_readb(const volatile void __iomem *addr)
116 return *(const volatile u8 __force *)addr;
121 #define __raw_readw __raw_readw
122 static inline u16 __raw_readw(const volatile void __iomem *addr)
124 return *(const volatile u16 __force *)addr;
129 #define __raw_readl __raw_readl
130 static inline u32 __raw_readl(const volatile void __iomem *addr)
132 return *(const volatile u32 __force *)addr;
138 #define __raw_readq __raw_readq
139 static inline u64 __raw_readq(const volatile void __iomem *addr)
141 return *(const volatile u64 __force *)addr;
144 #endif /* CONFIG_64BIT */
147 #define __raw_writeb __raw_writeb
148 static inline void __raw_writeb(u8 value, volatile void __iomem *addr)
150 *(volatile u8 __force *)addr = value;
155 #define __raw_writew __raw_writew
156 static inline void __raw_writew(u16 value, volatile void __iomem *addr)
158 *(volatile u16 __force *)addr = value;
163 #define __raw_writel __raw_writel
164 static inline void __raw_writel(u32 value, volatile void __iomem *addr)
166 *(volatile u32 __force *)addr = value;
172 #define __raw_writeq __raw_writeq
173 static inline void __raw_writeq(u64 value, volatile void __iomem *addr)
175 *(volatile u64 __force *)addr = value;
178 #endif /* CONFIG_64BIT */
181 * {read,write}{b,w,l,q}() access little endian memory and return result in
187 static inline u8 readb(const volatile void __iomem *addr)
191 log_read_mmio(8, addr, _THIS_IP_);
193 val = __raw_readb(addr);
195 log_post_read_mmio(val, 8, addr, _THIS_IP_);
202 static inline u16 readw(const volatile void __iomem *addr)
206 log_read_mmio(16, addr, _THIS_IP_);
208 val = __le16_to_cpu((__le16 __force)__raw_readw(addr));
210 log_post_read_mmio(val, 16, addr, _THIS_IP_);
217 static inline u32 readl(const volatile void __iomem *addr)
221 log_read_mmio(32, addr, _THIS_IP_);
223 val = __le32_to_cpu((__le32 __force)__raw_readl(addr));
225 log_post_read_mmio(val, 32, addr, _THIS_IP_);
233 static inline u64 readq(const volatile void __iomem *addr)
237 log_read_mmio(64, addr, _THIS_IP_);
239 val = __le64_to_cpu(__raw_readq(addr));
241 log_post_read_mmio(val, 64, addr, _THIS_IP_);
245 #endif /* CONFIG_64BIT */
248 #define writeb writeb
249 static inline void writeb(u8 value, volatile void __iomem *addr)
251 log_write_mmio(value, 8, addr, _THIS_IP_);
253 __raw_writeb(value, addr);
255 log_post_write_mmio(value, 8, addr, _THIS_IP_);
260 #define writew writew
261 static inline void writew(u16 value, volatile void __iomem *addr)
263 log_write_mmio(value, 16, addr, _THIS_IP_);
265 __raw_writew((u16 __force)cpu_to_le16(value), addr);
267 log_post_write_mmio(value, 16, addr, _THIS_IP_);
272 #define writel writel
273 static inline void writel(u32 value, volatile void __iomem *addr)
275 log_write_mmio(value, 32, addr, _THIS_IP_);
277 __raw_writel((u32 __force)__cpu_to_le32(value), addr);
279 log_post_write_mmio(value, 32, addr, _THIS_IP_);
285 #define writeq writeq
286 static inline void writeq(u64 value, volatile void __iomem *addr)
288 log_write_mmio(value, 64, addr, _THIS_IP_);
290 __raw_writeq(__cpu_to_le64(value), addr);
292 log_post_write_mmio(value, 64, addr, _THIS_IP_);
295 #endif /* CONFIG_64BIT */
298 * {read,write}{b,w,l,q}_relaxed() are like the regular version, but
299 * are not guaranteed to provide ordering against spinlocks or memory
302 #ifndef readb_relaxed
303 #define readb_relaxed readb_relaxed
304 static inline u8 readb_relaxed(const volatile void __iomem *addr)
308 log_read_mmio(8, addr, _THIS_IP_);
309 val = __raw_readb(addr);
310 log_post_read_mmio(val, 8, addr, _THIS_IP_);
315 #ifndef readw_relaxed
316 #define readw_relaxed readw_relaxed
317 static inline u16 readw_relaxed(const volatile void __iomem *addr)
321 log_read_mmio(16, addr, _THIS_IP_);
322 val = __le16_to_cpu(__raw_readw(addr));
323 log_post_read_mmio(val, 16, addr, _THIS_IP_);
328 #ifndef readl_relaxed
329 #define readl_relaxed readl_relaxed
330 static inline u32 readl_relaxed(const volatile void __iomem *addr)
334 log_read_mmio(32, addr, _THIS_IP_);
335 val = __le32_to_cpu(__raw_readl(addr));
336 log_post_read_mmio(val, 32, addr, _THIS_IP_);
341 #if defined(readq) && !defined(readq_relaxed)
342 #define readq_relaxed readq_relaxed
343 static inline u64 readq_relaxed(const volatile void __iomem *addr)
347 log_read_mmio(64, addr, _THIS_IP_);
348 val = __le64_to_cpu(__raw_readq(addr));
349 log_post_read_mmio(val, 64, addr, _THIS_IP_);
354 #ifndef writeb_relaxed
355 #define writeb_relaxed writeb_relaxed
356 static inline void writeb_relaxed(u8 value, volatile void __iomem *addr)
358 log_write_mmio(value, 8, addr, _THIS_IP_);
359 __raw_writeb(value, addr);
360 log_post_write_mmio(value, 8, addr, _THIS_IP_);
364 #ifndef writew_relaxed
365 #define writew_relaxed writew_relaxed
366 static inline void writew_relaxed(u16 value, volatile void __iomem *addr)
368 log_write_mmio(value, 16, addr, _THIS_IP_);
369 __raw_writew(cpu_to_le16(value), addr);
370 log_post_write_mmio(value, 16, addr, _THIS_IP_);
374 #ifndef writel_relaxed
375 #define writel_relaxed writel_relaxed
376 static inline void writel_relaxed(u32 value, volatile void __iomem *addr)
378 log_write_mmio(value, 32, addr, _THIS_IP_);
379 __raw_writel(__cpu_to_le32(value), addr);
380 log_post_write_mmio(value, 32, addr, _THIS_IP_);
384 #if defined(writeq) && !defined(writeq_relaxed)
385 #define writeq_relaxed writeq_relaxed
386 static inline void writeq_relaxed(u64 value, volatile void __iomem *addr)
388 log_write_mmio(value, 64, addr, _THIS_IP_);
389 __raw_writeq(__cpu_to_le64(value), addr);
390 log_post_write_mmio(value, 64, addr, _THIS_IP_);
395 * {read,write}s{b,w,l,q}() repeatedly access the same memory address in
396 * native endianness in 8-, 16-, 32- or 64-bit chunks (@count times).
399 #define readsb readsb
400 static inline void readsb(const volatile void __iomem *addr, void *buffer,
407 u8 x = __raw_readb(addr);
415 #define readsw readsw
416 static inline void readsw(const volatile void __iomem *addr, void *buffer,
423 u16 x = __raw_readw(addr);
431 #define readsl readsl
432 static inline void readsl(const volatile void __iomem *addr, void *buffer,
439 u32 x = __raw_readl(addr);
448 #define readsq readsq
449 static inline void readsq(const volatile void __iomem *addr, void *buffer,
456 u64 x = __raw_readq(addr);
462 #endif /* CONFIG_64BIT */
465 #define writesb writesb
466 static inline void writesb(volatile void __iomem *addr, const void *buffer,
470 const u8 *buf = buffer;
473 __raw_writeb(*buf++, addr);
480 #define writesw writesw
481 static inline void writesw(volatile void __iomem *addr, const void *buffer,
485 const u16 *buf = buffer;
488 __raw_writew(*buf++, addr);
495 #define writesl writesl
496 static inline void writesl(volatile void __iomem *addr, const void *buffer,
500 const u32 *buf = buffer;
503 __raw_writel(*buf++, addr);
511 #define writesq writesq
512 static inline void writesq(volatile void __iomem *addr, const void *buffer,
516 const u64 *buf = buffer;
519 __raw_writeq(*buf++, addr);
524 #endif /* CONFIG_64BIT */
527 #define PCI_IOBASE ((void __iomem *)0)
530 #ifndef IO_SPACE_LIMIT
531 #define IO_SPACE_LIMIT 0xffff
535 * {in,out}{b,w,l}() access little endian I/O. {in,out}{b,w,l}_p() can be
536 * implemented on hardware that needs an additional delay for I/O accesses to
540 #if !defined(inb) && !defined(_inb)
542 static inline u8 _inb(unsigned long addr)
547 val = __raw_readb(PCI_IOBASE + addr);
553 #if !defined(inw) && !defined(_inw)
555 static inline u16 _inw(unsigned long addr)
560 val = __le16_to_cpu((__le16 __force)__raw_readw(PCI_IOBASE + addr));
566 #if !defined(inl) && !defined(_inl)
568 static inline u32 _inl(unsigned long addr)
573 val = __le32_to_cpu((__le32 __force)__raw_readl(PCI_IOBASE + addr));
579 #if !defined(outb) && !defined(_outb)
581 static inline void _outb(u8 value, unsigned long addr)
584 __raw_writeb(value, PCI_IOBASE + addr);
589 #if !defined(outw) && !defined(_outw)
591 static inline void _outw(u16 value, unsigned long addr)
594 __raw_writew((u16 __force)cpu_to_le16(value), PCI_IOBASE + addr);
599 #if !defined(outl) && !defined(_outl)
601 static inline void _outl(u32 value, unsigned long addr)
604 __raw_writel((u32 __force)cpu_to_le32(value), PCI_IOBASE + addr);
609 #include <linux/logic_pio.h>
637 static inline u8 inb_p(unsigned long addr)
645 static inline u16 inw_p(unsigned long addr)
653 static inline u32 inl_p(unsigned long addr)
660 #define outb_p outb_p
661 static inline void outb_p(u8 value, unsigned long addr)
668 #define outw_p outw_p
669 static inline void outw_p(u16 value, unsigned long addr)
676 #define outl_p outl_p
677 static inline void outl_p(u32 value, unsigned long addr)
684 * {in,out}s{b,w,l}{,_p}() are variants of the above that repeatedly access a
685 * single I/O port multiple times.
690 static inline void insb(unsigned long addr, void *buffer, unsigned int count)
692 readsb(PCI_IOBASE + addr, buffer, count);
698 static inline void insw(unsigned long addr, void *buffer, unsigned int count)
700 readsw(PCI_IOBASE + addr, buffer, count);
706 static inline void insl(unsigned long addr, void *buffer, unsigned int count)
708 readsl(PCI_IOBASE + addr, buffer, count);
714 static inline void outsb(unsigned long addr, const void *buffer,
717 writesb(PCI_IOBASE + addr, buffer, count);
723 static inline void outsw(unsigned long addr, const void *buffer,
726 writesw(PCI_IOBASE + addr, buffer, count);
732 static inline void outsl(unsigned long addr, const void *buffer,
735 writesl(PCI_IOBASE + addr, buffer, count);
740 #define insb_p insb_p
741 static inline void insb_p(unsigned long addr, void *buffer, unsigned int count)
743 insb(addr, buffer, count);
748 #define insw_p insw_p
749 static inline void insw_p(unsigned long addr, void *buffer, unsigned int count)
751 insw(addr, buffer, count);
756 #define insl_p insl_p
757 static inline void insl_p(unsigned long addr, void *buffer, unsigned int count)
759 insl(addr, buffer, count);
764 #define outsb_p outsb_p
765 static inline void outsb_p(unsigned long addr, const void *buffer,
768 outsb(addr, buffer, count);
773 #define outsw_p outsw_p
774 static inline void outsw_p(unsigned long addr, const void *buffer,
777 outsw(addr, buffer, count);
782 #define outsl_p outsl_p
783 static inline void outsl_p(unsigned long addr, const void *buffer,
786 outsl(addr, buffer, count);
790 #ifndef CONFIG_GENERIC_IOMAP
792 #define ioread8 ioread8
793 static inline u8 ioread8(const volatile void __iomem *addr)
800 #define ioread16 ioread16
801 static inline u16 ioread16(const volatile void __iomem *addr)
808 #define ioread32 ioread32
809 static inline u32 ioread32(const volatile void __iomem *addr)
817 #define ioread64 ioread64
818 static inline u64 ioread64(const volatile void __iomem *addr)
823 #endif /* CONFIG_64BIT */
826 #define iowrite8 iowrite8
827 static inline void iowrite8(u8 value, volatile void __iomem *addr)
834 #define iowrite16 iowrite16
835 static inline void iowrite16(u16 value, volatile void __iomem *addr)
842 #define iowrite32 iowrite32
843 static inline void iowrite32(u32 value, volatile void __iomem *addr)
851 #define iowrite64 iowrite64
852 static inline void iowrite64(u64 value, volatile void __iomem *addr)
857 #endif /* CONFIG_64BIT */
860 #define ioread16be ioread16be
861 static inline u16 ioread16be(const volatile void __iomem *addr)
863 return swab16(readw(addr));
868 #define ioread32be ioread32be
869 static inline u32 ioread32be(const volatile void __iomem *addr)
871 return swab32(readl(addr));
877 #define ioread64be ioread64be
878 static inline u64 ioread64be(const volatile void __iomem *addr)
880 return swab64(readq(addr));
883 #endif /* CONFIG_64BIT */
886 #define iowrite16be iowrite16be
887 static inline void iowrite16be(u16 value, void volatile __iomem *addr)
889 writew(swab16(value), addr);
894 #define iowrite32be iowrite32be
895 static inline void iowrite32be(u32 value, volatile void __iomem *addr)
897 writel(swab32(value), addr);
903 #define iowrite64be iowrite64be
904 static inline void iowrite64be(u64 value, volatile void __iomem *addr)
906 writeq(swab64(value), addr);
909 #endif /* CONFIG_64BIT */
912 #define ioread8_rep ioread8_rep
913 static inline void ioread8_rep(const volatile void __iomem *addr, void *buffer,
916 readsb(addr, buffer, count);
921 #define ioread16_rep ioread16_rep
922 static inline void ioread16_rep(const volatile void __iomem *addr,
923 void *buffer, unsigned int count)
925 readsw(addr, buffer, count);
930 #define ioread32_rep ioread32_rep
931 static inline void ioread32_rep(const volatile void __iomem *addr,
932 void *buffer, unsigned int count)
934 readsl(addr, buffer, count);
940 #define ioread64_rep ioread64_rep
941 static inline void ioread64_rep(const volatile void __iomem *addr,
942 void *buffer, unsigned int count)
944 readsq(addr, buffer, count);
947 #endif /* CONFIG_64BIT */
950 #define iowrite8_rep iowrite8_rep
951 static inline void iowrite8_rep(volatile void __iomem *addr,
955 writesb(addr, buffer, count);
959 #ifndef iowrite16_rep
960 #define iowrite16_rep iowrite16_rep
961 static inline void iowrite16_rep(volatile void __iomem *addr,
965 writesw(addr, buffer, count);
969 #ifndef iowrite32_rep
970 #define iowrite32_rep iowrite32_rep
971 static inline void iowrite32_rep(volatile void __iomem *addr,
975 writesl(addr, buffer, count);
980 #ifndef iowrite64_rep
981 #define iowrite64_rep iowrite64_rep
982 static inline void iowrite64_rep(volatile void __iomem *addr,
986 writesq(addr, buffer, count);
989 #endif /* CONFIG_64BIT */
990 #endif /* CONFIG_GENERIC_IOMAP */
994 #include <linux/vmalloc.h>
995 #define __io_virt(x) ((void __force *)(x))
998 * Change virtual addresses to physical addresses and vv.
999 * These are pretty trivial
1001 #ifndef virt_to_phys
1002 #define virt_to_phys virt_to_phys
1003 static inline unsigned long virt_to_phys(volatile void *address)
1005 return __pa((unsigned long)address);
1009 #ifndef phys_to_virt
1010 #define phys_to_virt phys_to_virt
1011 static inline void *phys_to_virt(unsigned long address)
1013 return __va(address);
1018 * DOC: ioremap() and ioremap_*() variants
1020 * Architectures with an MMU are expected to provide ioremap() and iounmap()
1021 * themselves or rely on GENERIC_IOREMAP. For NOMMU architectures we provide
1022 * a default nop-op implementation that expect that the physical address used
1023 * for MMIO are already marked as uncached, and can be used as kernel virtual
1026 * ioremap_wc() and ioremap_wt() can provide more relaxed caching attributes
1027 * for specific drivers if the architecture choses to implement them. If they
1028 * are not implemented we fall back to plain ioremap. Conversely, ioremap_np()
1029 * can provide stricter non-posted write semantics if the architecture
1034 #define ioremap ioremap
1035 static inline void __iomem *ioremap(phys_addr_t offset, size_t size)
1037 return (void __iomem *)(unsigned long)offset;
1042 #define iounmap iounmap
1043 static inline void iounmap(volatile void __iomem *addr)
1047 #elif defined(CONFIG_GENERIC_IOREMAP)
1048 #include <linux/pgtable.h>
1051 * Arch code can implement the following two hooks when using GENERIC_IOREMAP
1052 * ioremap_allowed() return a bool,
1053 * - true means continue to remap
1054 * - false means skip remap and return directly
1055 * iounmap_allowed() return a bool,
1056 * - true means continue to vunmap
1057 * - false means skip vunmap and return directly
1059 #ifndef ioremap_allowed
1060 #define ioremap_allowed ioremap_allowed
1061 static inline bool ioremap_allowed(phys_addr_t phys_addr, size_t size,
1068 #ifndef iounmap_allowed
1069 #define iounmap_allowed iounmap_allowed
1070 static inline bool iounmap_allowed(void *addr)
1076 void __iomem *ioremap_prot(phys_addr_t phys_addr, size_t size,
1077 unsigned long prot);
1078 void iounmap(volatile void __iomem *addr);
1080 static inline void __iomem *ioremap(phys_addr_t addr, size_t size)
1082 /* _PAGE_IOREMAP needs to be supplied by the architecture */
1083 return ioremap_prot(addr, size, _PAGE_IOREMAP);
1085 #endif /* !CONFIG_MMU || CONFIG_GENERIC_IOREMAP */
1088 #define ioremap_wc ioremap
1092 #define ioremap_wt ioremap
1096 * ioremap_uc is special in that we do require an explicit architecture
1097 * implementation. In general you do not want to use this function in a
1098 * driver and use plain ioremap, which is uncached by default. Similarly
1099 * architectures should not implement it unless they have a very good
1103 #define ioremap_uc ioremap_uc
1104 static inline void __iomem *ioremap_uc(phys_addr_t offset, size_t size)
1111 * ioremap_np needs an explicit architecture implementation, as it
1112 * requests stronger semantics than regular ioremap(). Portable drivers
1113 * should instead use one of the higher-level abstractions, like
1114 * devm_ioremap_resource(), to choose the correct variant for any given
1115 * device and bus. Portable drivers with a good reason to want non-posted
1116 * write semantics should always provide an ioremap() fallback in case
1117 * ioremap_np() is not available.
1120 #define ioremap_np ioremap_np
1121 static inline void __iomem *ioremap_np(phys_addr_t offset, size_t size)
1127 #ifdef CONFIG_HAS_IOPORT_MAP
1128 #ifndef CONFIG_GENERIC_IOMAP
1130 #define ioport_map ioport_map
1131 static inline void __iomem *ioport_map(unsigned long port, unsigned int nr)
1133 port &= IO_SPACE_LIMIT;
1134 return (port > MMIO_UPPER_LIMIT) ? NULL : PCI_IOBASE + port;
1136 #define ARCH_HAS_GENERIC_IOPORT_MAP
1139 #ifndef ioport_unmap
1140 #define ioport_unmap ioport_unmap
1141 static inline void ioport_unmap(void __iomem *p)
1145 #else /* CONFIG_GENERIC_IOMAP */
1146 extern void __iomem *ioport_map(unsigned long port, unsigned int nr);
1147 extern void ioport_unmap(void __iomem *p);
1148 #endif /* CONFIG_GENERIC_IOMAP */
1149 #endif /* CONFIG_HAS_IOPORT_MAP */
1151 #ifndef CONFIG_GENERIC_IOMAP
1153 #define ARCH_WANTS_GENERIC_PCI_IOUNMAP
1157 #ifndef xlate_dev_mem_ptr
1158 #define xlate_dev_mem_ptr xlate_dev_mem_ptr
1159 static inline void *xlate_dev_mem_ptr(phys_addr_t addr)
1165 #ifndef unxlate_dev_mem_ptr
1166 #define unxlate_dev_mem_ptr unxlate_dev_mem_ptr
1167 static inline void unxlate_dev_mem_ptr(phys_addr_t phys, void *addr)
1173 #define memset_io memset_io
1175 * memset_io Set a range of I/O memory to a constant value
1176 * @addr: The beginning of the I/O-memory range to set
1177 * @val: The value to set the memory to
1178 * @count: The number of bytes to set
1180 * Set a range of I/O memory to a given value.
1182 static inline void memset_io(volatile void __iomem *addr, int value,
1185 memset(__io_virt(addr), value, size);
1189 #ifndef memcpy_fromio
1190 #define memcpy_fromio memcpy_fromio
1192 * memcpy_fromio Copy a block of data from I/O memory
1193 * @dst: The (RAM) destination for the copy
1194 * @src: The (I/O memory) source for the data
1195 * @count: The number of bytes to copy
1197 * Copy a block of data from I/O memory.
1199 static inline void memcpy_fromio(void *buffer,
1200 const volatile void __iomem *addr,
1203 memcpy(buffer, __io_virt(addr), size);
1208 #define memcpy_toio memcpy_toio
1210 * memcpy_toio Copy a block of data into I/O memory
1211 * @dst: The (I/O memory) destination for the copy
1212 * @src: The (RAM) source for the data
1213 * @count: The number of bytes to copy
1215 * Copy a block of data to I/O memory.
1217 static inline void memcpy_toio(volatile void __iomem *addr, const void *buffer,
1220 memcpy(__io_virt(addr), buffer, size);
1224 extern int devmem_is_allowed(unsigned long pfn);
1226 #endif /* __KERNEL__ */
1228 #endif /* __ASM_GENERIC_IO_H */