18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-or-later */
28c2ecf20Sopenharmony_ci/* Generic I/O port emulation.
38c2ecf20Sopenharmony_ci *
48c2ecf20Sopenharmony_ci * Copyright (C) 2007 Red Hat, Inc. All Rights Reserved.
58c2ecf20Sopenharmony_ci * Written by David Howells (dhowells@redhat.com)
68c2ecf20Sopenharmony_ci */
78c2ecf20Sopenharmony_ci#ifndef __ASM_GENERIC_IO_H
88c2ecf20Sopenharmony_ci#define __ASM_GENERIC_IO_H
98c2ecf20Sopenharmony_ci
108c2ecf20Sopenharmony_ci#include <asm/page.h> /* I/O is all done through memory accesses */
118c2ecf20Sopenharmony_ci#include <linux/string.h> /* for memset() and memcpy() */
128c2ecf20Sopenharmony_ci#include <linux/types.h>
138c2ecf20Sopenharmony_ci
148c2ecf20Sopenharmony_ci#ifdef CONFIG_GENERIC_IOMAP
158c2ecf20Sopenharmony_ci#include <asm-generic/iomap.h>
168c2ecf20Sopenharmony_ci#endif
178c2ecf20Sopenharmony_ci
188c2ecf20Sopenharmony_ci#include <asm/mmiowb.h>
198c2ecf20Sopenharmony_ci#include <asm-generic/pci_iomap.h>
208c2ecf20Sopenharmony_ci
218c2ecf20Sopenharmony_ci#ifndef __io_br
228c2ecf20Sopenharmony_ci#define __io_br()      barrier()
238c2ecf20Sopenharmony_ci#endif
248c2ecf20Sopenharmony_ci
258c2ecf20Sopenharmony_ci/* prevent prefetching of coherent DMA data ahead of a dma-complete */
268c2ecf20Sopenharmony_ci#ifndef __io_ar
278c2ecf20Sopenharmony_ci#ifdef rmb
288c2ecf20Sopenharmony_ci#define __io_ar(v)      rmb()
298c2ecf20Sopenharmony_ci#else
308c2ecf20Sopenharmony_ci#define __io_ar(v)      barrier()
318c2ecf20Sopenharmony_ci#endif
328c2ecf20Sopenharmony_ci#endif
338c2ecf20Sopenharmony_ci
348c2ecf20Sopenharmony_ci/* flush writes to coherent DMA data before possibly triggering a DMA read */
358c2ecf20Sopenharmony_ci#ifndef __io_bw
368c2ecf20Sopenharmony_ci#ifdef wmb
378c2ecf20Sopenharmony_ci#define __io_bw()      wmb()
388c2ecf20Sopenharmony_ci#else
398c2ecf20Sopenharmony_ci#define __io_bw()      barrier()
408c2ecf20Sopenharmony_ci#endif
418c2ecf20Sopenharmony_ci#endif
428c2ecf20Sopenharmony_ci
438c2ecf20Sopenharmony_ci/* serialize device access against a spin_unlock, usually handled there. */
448c2ecf20Sopenharmony_ci#ifndef __io_aw
458c2ecf20Sopenharmony_ci#define __io_aw()      mmiowb_set_pending()
468c2ecf20Sopenharmony_ci#endif
478c2ecf20Sopenharmony_ci
488c2ecf20Sopenharmony_ci#ifndef __io_pbw
498c2ecf20Sopenharmony_ci#define __io_pbw()     __io_bw()
508c2ecf20Sopenharmony_ci#endif
518c2ecf20Sopenharmony_ci
528c2ecf20Sopenharmony_ci#ifndef __io_paw
538c2ecf20Sopenharmony_ci#define __io_paw()     __io_aw()
548c2ecf20Sopenharmony_ci#endif
558c2ecf20Sopenharmony_ci
568c2ecf20Sopenharmony_ci#ifndef __io_pbr
578c2ecf20Sopenharmony_ci#define __io_pbr()     __io_br()
588c2ecf20Sopenharmony_ci#endif
598c2ecf20Sopenharmony_ci
608c2ecf20Sopenharmony_ci#ifndef __io_par
618c2ecf20Sopenharmony_ci#define __io_par(v)     __io_ar(v)
628c2ecf20Sopenharmony_ci#endif
638c2ecf20Sopenharmony_ci
648c2ecf20Sopenharmony_ci
658c2ecf20Sopenharmony_ci/*
668c2ecf20Sopenharmony_ci * __raw_{read,write}{b,w,l,q}() access memory in native endianness.
678c2ecf20Sopenharmony_ci *
688c2ecf20Sopenharmony_ci * On some architectures memory mapped IO needs to be accessed differently.
698c2ecf20Sopenharmony_ci * On the simple architectures, we just read/write the memory location
708c2ecf20Sopenharmony_ci * directly.
718c2ecf20Sopenharmony_ci */
728c2ecf20Sopenharmony_ci
738c2ecf20Sopenharmony_ci#ifndef __raw_readb
748c2ecf20Sopenharmony_ci#define __raw_readb __raw_readb
758c2ecf20Sopenharmony_cistatic inline u8 __raw_readb(const volatile void __iomem *addr)
768c2ecf20Sopenharmony_ci{
778c2ecf20Sopenharmony_ci	return *(const volatile u8 __force *)addr;
788c2ecf20Sopenharmony_ci}
798c2ecf20Sopenharmony_ci#endif
808c2ecf20Sopenharmony_ci
818c2ecf20Sopenharmony_ci#ifndef __raw_readw
828c2ecf20Sopenharmony_ci#define __raw_readw __raw_readw
838c2ecf20Sopenharmony_cistatic inline u16 __raw_readw(const volatile void __iomem *addr)
848c2ecf20Sopenharmony_ci{
858c2ecf20Sopenharmony_ci	return *(const volatile u16 __force *)addr;
868c2ecf20Sopenharmony_ci}
878c2ecf20Sopenharmony_ci#endif
888c2ecf20Sopenharmony_ci
898c2ecf20Sopenharmony_ci#ifndef __raw_readl
908c2ecf20Sopenharmony_ci#define __raw_readl __raw_readl
918c2ecf20Sopenharmony_cistatic inline u32 __raw_readl(const volatile void __iomem *addr)
928c2ecf20Sopenharmony_ci{
938c2ecf20Sopenharmony_ci	return *(const volatile u32 __force *)addr;
948c2ecf20Sopenharmony_ci}
958c2ecf20Sopenharmony_ci#endif
968c2ecf20Sopenharmony_ci
978c2ecf20Sopenharmony_ci#ifdef CONFIG_64BIT
988c2ecf20Sopenharmony_ci#ifndef __raw_readq
998c2ecf20Sopenharmony_ci#define __raw_readq __raw_readq
1008c2ecf20Sopenharmony_cistatic inline u64 __raw_readq(const volatile void __iomem *addr)
1018c2ecf20Sopenharmony_ci{
1028c2ecf20Sopenharmony_ci	return *(const volatile u64 __force *)addr;
1038c2ecf20Sopenharmony_ci}
1048c2ecf20Sopenharmony_ci#endif
1058c2ecf20Sopenharmony_ci#endif /* CONFIG_64BIT */
1068c2ecf20Sopenharmony_ci
1078c2ecf20Sopenharmony_ci#ifndef __raw_writeb
1088c2ecf20Sopenharmony_ci#define __raw_writeb __raw_writeb
1098c2ecf20Sopenharmony_cistatic inline void __raw_writeb(u8 value, volatile void __iomem *addr)
1108c2ecf20Sopenharmony_ci{
1118c2ecf20Sopenharmony_ci	*(volatile u8 __force *)addr = value;
1128c2ecf20Sopenharmony_ci}
1138c2ecf20Sopenharmony_ci#endif
1148c2ecf20Sopenharmony_ci
1158c2ecf20Sopenharmony_ci#ifndef __raw_writew
1168c2ecf20Sopenharmony_ci#define __raw_writew __raw_writew
1178c2ecf20Sopenharmony_cistatic inline void __raw_writew(u16 value, volatile void __iomem *addr)
1188c2ecf20Sopenharmony_ci{
1198c2ecf20Sopenharmony_ci	*(volatile u16 __force *)addr = value;
1208c2ecf20Sopenharmony_ci}
1218c2ecf20Sopenharmony_ci#endif
1228c2ecf20Sopenharmony_ci
1238c2ecf20Sopenharmony_ci#ifndef __raw_writel
1248c2ecf20Sopenharmony_ci#define __raw_writel __raw_writel
1258c2ecf20Sopenharmony_cistatic inline void __raw_writel(u32 value, volatile void __iomem *addr)
1268c2ecf20Sopenharmony_ci{
1278c2ecf20Sopenharmony_ci	*(volatile u32 __force *)addr = value;
1288c2ecf20Sopenharmony_ci}
1298c2ecf20Sopenharmony_ci#endif
1308c2ecf20Sopenharmony_ci
1318c2ecf20Sopenharmony_ci#ifdef CONFIG_64BIT
1328c2ecf20Sopenharmony_ci#ifndef __raw_writeq
1338c2ecf20Sopenharmony_ci#define __raw_writeq __raw_writeq
1348c2ecf20Sopenharmony_cistatic inline void __raw_writeq(u64 value, volatile void __iomem *addr)
1358c2ecf20Sopenharmony_ci{
1368c2ecf20Sopenharmony_ci	*(volatile u64 __force *)addr = value;
1378c2ecf20Sopenharmony_ci}
1388c2ecf20Sopenharmony_ci#endif
1398c2ecf20Sopenharmony_ci#endif /* CONFIG_64BIT */
1408c2ecf20Sopenharmony_ci
1418c2ecf20Sopenharmony_ci/*
1428c2ecf20Sopenharmony_ci * {read,write}{b,w,l,q}() access little endian memory and return result in
1438c2ecf20Sopenharmony_ci * native endianness.
1448c2ecf20Sopenharmony_ci */
1458c2ecf20Sopenharmony_ci
1468c2ecf20Sopenharmony_ci#ifndef readb
1478c2ecf20Sopenharmony_ci#define readb readb
1488c2ecf20Sopenharmony_cistatic inline u8 readb(const volatile void __iomem *addr)
1498c2ecf20Sopenharmony_ci{
1508c2ecf20Sopenharmony_ci	u8 val;
1518c2ecf20Sopenharmony_ci
1528c2ecf20Sopenharmony_ci	__io_br();
1538c2ecf20Sopenharmony_ci	val = __raw_readb(addr);
1548c2ecf20Sopenharmony_ci	__io_ar(val);
1558c2ecf20Sopenharmony_ci	return val;
1568c2ecf20Sopenharmony_ci}
1578c2ecf20Sopenharmony_ci#endif
1588c2ecf20Sopenharmony_ci
1598c2ecf20Sopenharmony_ci#ifndef readw
1608c2ecf20Sopenharmony_ci#define readw readw
1618c2ecf20Sopenharmony_cistatic inline u16 readw(const volatile void __iomem *addr)
1628c2ecf20Sopenharmony_ci{
1638c2ecf20Sopenharmony_ci	u16 val;
1648c2ecf20Sopenharmony_ci
1658c2ecf20Sopenharmony_ci	__io_br();
1668c2ecf20Sopenharmony_ci	val = __le16_to_cpu((__le16 __force)__raw_readw(addr));
1678c2ecf20Sopenharmony_ci	__io_ar(val);
1688c2ecf20Sopenharmony_ci	return val;
1698c2ecf20Sopenharmony_ci}
1708c2ecf20Sopenharmony_ci#endif
1718c2ecf20Sopenharmony_ci
1728c2ecf20Sopenharmony_ci#ifndef readl
1738c2ecf20Sopenharmony_ci#define readl readl
1748c2ecf20Sopenharmony_cistatic inline u32 readl(const volatile void __iomem *addr)
1758c2ecf20Sopenharmony_ci{
1768c2ecf20Sopenharmony_ci	u32 val;
1778c2ecf20Sopenharmony_ci
1788c2ecf20Sopenharmony_ci	__io_br();
1798c2ecf20Sopenharmony_ci	val = __le32_to_cpu((__le32 __force)__raw_readl(addr));
1808c2ecf20Sopenharmony_ci	__io_ar(val);
1818c2ecf20Sopenharmony_ci	return val;
1828c2ecf20Sopenharmony_ci}
1838c2ecf20Sopenharmony_ci#endif
1848c2ecf20Sopenharmony_ci
1858c2ecf20Sopenharmony_ci#ifdef CONFIG_64BIT
1868c2ecf20Sopenharmony_ci#ifndef readq
1878c2ecf20Sopenharmony_ci#define readq readq
1888c2ecf20Sopenharmony_cistatic inline u64 readq(const volatile void __iomem *addr)
1898c2ecf20Sopenharmony_ci{
1908c2ecf20Sopenharmony_ci	u64 val;
1918c2ecf20Sopenharmony_ci
1928c2ecf20Sopenharmony_ci	__io_br();
1938c2ecf20Sopenharmony_ci	val = __le64_to_cpu((__le64 __force)__raw_readq(addr));
1948c2ecf20Sopenharmony_ci	__io_ar(val);
1958c2ecf20Sopenharmony_ci	return val;
1968c2ecf20Sopenharmony_ci}
1978c2ecf20Sopenharmony_ci#endif
1988c2ecf20Sopenharmony_ci#endif /* CONFIG_64BIT */
1998c2ecf20Sopenharmony_ci
2008c2ecf20Sopenharmony_ci#ifndef writeb
2018c2ecf20Sopenharmony_ci#define writeb writeb
2028c2ecf20Sopenharmony_cistatic inline void writeb(u8 value, volatile void __iomem *addr)
2038c2ecf20Sopenharmony_ci{
2048c2ecf20Sopenharmony_ci	__io_bw();
2058c2ecf20Sopenharmony_ci	__raw_writeb(value, addr);
2068c2ecf20Sopenharmony_ci	__io_aw();
2078c2ecf20Sopenharmony_ci}
2088c2ecf20Sopenharmony_ci#endif
2098c2ecf20Sopenharmony_ci
2108c2ecf20Sopenharmony_ci#ifndef writew
2118c2ecf20Sopenharmony_ci#define writew writew
2128c2ecf20Sopenharmony_cistatic inline void writew(u16 value, volatile void __iomem *addr)
2138c2ecf20Sopenharmony_ci{
2148c2ecf20Sopenharmony_ci	__io_bw();
2158c2ecf20Sopenharmony_ci	__raw_writew((u16 __force)cpu_to_le16(value), addr);
2168c2ecf20Sopenharmony_ci	__io_aw();
2178c2ecf20Sopenharmony_ci}
2188c2ecf20Sopenharmony_ci#endif
2198c2ecf20Sopenharmony_ci
2208c2ecf20Sopenharmony_ci#ifndef writel
2218c2ecf20Sopenharmony_ci#define writel writel
2228c2ecf20Sopenharmony_cistatic inline void writel(u32 value, volatile void __iomem *addr)
2238c2ecf20Sopenharmony_ci{
2248c2ecf20Sopenharmony_ci	__io_bw();
2258c2ecf20Sopenharmony_ci	__raw_writel((u32 __force)__cpu_to_le32(value), addr);
2268c2ecf20Sopenharmony_ci	__io_aw();
2278c2ecf20Sopenharmony_ci}
2288c2ecf20Sopenharmony_ci#endif
2298c2ecf20Sopenharmony_ci
2308c2ecf20Sopenharmony_ci#ifdef CONFIG_64BIT
2318c2ecf20Sopenharmony_ci#ifndef writeq
2328c2ecf20Sopenharmony_ci#define writeq writeq
2338c2ecf20Sopenharmony_cistatic inline void writeq(u64 value, volatile void __iomem *addr)
2348c2ecf20Sopenharmony_ci{
2358c2ecf20Sopenharmony_ci	__io_bw();
2368c2ecf20Sopenharmony_ci	__raw_writeq((u64 __force)__cpu_to_le64(value), addr);
2378c2ecf20Sopenharmony_ci	__io_aw();
2388c2ecf20Sopenharmony_ci}
2398c2ecf20Sopenharmony_ci#endif
2408c2ecf20Sopenharmony_ci#endif /* CONFIG_64BIT */
2418c2ecf20Sopenharmony_ci
2428c2ecf20Sopenharmony_ci/*
2438c2ecf20Sopenharmony_ci * {read,write}{b,w,l,q}_relaxed() are like the regular version, but
2448c2ecf20Sopenharmony_ci * are not guaranteed to provide ordering against spinlocks or memory
2458c2ecf20Sopenharmony_ci * accesses.
2468c2ecf20Sopenharmony_ci */
2478c2ecf20Sopenharmony_ci#ifndef readb_relaxed
2488c2ecf20Sopenharmony_ci#define readb_relaxed readb_relaxed
2498c2ecf20Sopenharmony_cistatic inline u8 readb_relaxed(const volatile void __iomem *addr)
2508c2ecf20Sopenharmony_ci{
2518c2ecf20Sopenharmony_ci	return __raw_readb(addr);
2528c2ecf20Sopenharmony_ci}
2538c2ecf20Sopenharmony_ci#endif
2548c2ecf20Sopenharmony_ci
2558c2ecf20Sopenharmony_ci#ifndef readw_relaxed
2568c2ecf20Sopenharmony_ci#define readw_relaxed readw_relaxed
2578c2ecf20Sopenharmony_cistatic inline u16 readw_relaxed(const volatile void __iomem *addr)
2588c2ecf20Sopenharmony_ci{
2598c2ecf20Sopenharmony_ci	return __le16_to_cpu(__raw_readw(addr));
2608c2ecf20Sopenharmony_ci}
2618c2ecf20Sopenharmony_ci#endif
2628c2ecf20Sopenharmony_ci
2638c2ecf20Sopenharmony_ci#ifndef readl_relaxed
2648c2ecf20Sopenharmony_ci#define readl_relaxed readl_relaxed
2658c2ecf20Sopenharmony_cistatic inline u32 readl_relaxed(const volatile void __iomem *addr)
2668c2ecf20Sopenharmony_ci{
2678c2ecf20Sopenharmony_ci	return __le32_to_cpu(__raw_readl(addr));
2688c2ecf20Sopenharmony_ci}
2698c2ecf20Sopenharmony_ci#endif
2708c2ecf20Sopenharmony_ci
2718c2ecf20Sopenharmony_ci#if defined(readq) && !defined(readq_relaxed)
2728c2ecf20Sopenharmony_ci#define readq_relaxed readq_relaxed
2738c2ecf20Sopenharmony_cistatic inline u64 readq_relaxed(const volatile void __iomem *addr)
2748c2ecf20Sopenharmony_ci{
2758c2ecf20Sopenharmony_ci	return __le64_to_cpu(__raw_readq(addr));
2768c2ecf20Sopenharmony_ci}
2778c2ecf20Sopenharmony_ci#endif
2788c2ecf20Sopenharmony_ci
2798c2ecf20Sopenharmony_ci#ifndef writeb_relaxed
2808c2ecf20Sopenharmony_ci#define writeb_relaxed writeb_relaxed
2818c2ecf20Sopenharmony_cistatic inline void writeb_relaxed(u8 value, volatile void __iomem *addr)
2828c2ecf20Sopenharmony_ci{
2838c2ecf20Sopenharmony_ci	__raw_writeb(value, addr);
2848c2ecf20Sopenharmony_ci}
2858c2ecf20Sopenharmony_ci#endif
2868c2ecf20Sopenharmony_ci
2878c2ecf20Sopenharmony_ci#ifndef writew_relaxed
2888c2ecf20Sopenharmony_ci#define writew_relaxed writew_relaxed
2898c2ecf20Sopenharmony_cistatic inline void writew_relaxed(u16 value, volatile void __iomem *addr)
2908c2ecf20Sopenharmony_ci{
2918c2ecf20Sopenharmony_ci	__raw_writew(cpu_to_le16(value), addr);
2928c2ecf20Sopenharmony_ci}
2938c2ecf20Sopenharmony_ci#endif
2948c2ecf20Sopenharmony_ci
2958c2ecf20Sopenharmony_ci#ifndef writel_relaxed
2968c2ecf20Sopenharmony_ci#define writel_relaxed writel_relaxed
2978c2ecf20Sopenharmony_cistatic inline void writel_relaxed(u32 value, volatile void __iomem *addr)
2988c2ecf20Sopenharmony_ci{
2998c2ecf20Sopenharmony_ci	__raw_writel(__cpu_to_le32(value), addr);
3008c2ecf20Sopenharmony_ci}
3018c2ecf20Sopenharmony_ci#endif
3028c2ecf20Sopenharmony_ci
3038c2ecf20Sopenharmony_ci#if defined(writeq) && !defined(writeq_relaxed)
3048c2ecf20Sopenharmony_ci#define writeq_relaxed writeq_relaxed
3058c2ecf20Sopenharmony_cistatic inline void writeq_relaxed(u64 value, volatile void __iomem *addr)
3068c2ecf20Sopenharmony_ci{
3078c2ecf20Sopenharmony_ci	__raw_writeq(__cpu_to_le64(value), addr);
3088c2ecf20Sopenharmony_ci}
3098c2ecf20Sopenharmony_ci#endif
3108c2ecf20Sopenharmony_ci
3118c2ecf20Sopenharmony_ci/*
3128c2ecf20Sopenharmony_ci * {read,write}s{b,w,l,q}() repeatedly access the same memory address in
3138c2ecf20Sopenharmony_ci * native endianness in 8-, 16-, 32- or 64-bit chunks (@count times).
3148c2ecf20Sopenharmony_ci */
3158c2ecf20Sopenharmony_ci#ifndef readsb
3168c2ecf20Sopenharmony_ci#define readsb readsb
3178c2ecf20Sopenharmony_cistatic inline void readsb(const volatile void __iomem *addr, void *buffer,
3188c2ecf20Sopenharmony_ci			  unsigned int count)
3198c2ecf20Sopenharmony_ci{
3208c2ecf20Sopenharmony_ci	if (count) {
3218c2ecf20Sopenharmony_ci		u8 *buf = buffer;
3228c2ecf20Sopenharmony_ci
3238c2ecf20Sopenharmony_ci		do {
3248c2ecf20Sopenharmony_ci			u8 x = __raw_readb(addr);
3258c2ecf20Sopenharmony_ci			*buf++ = x;
3268c2ecf20Sopenharmony_ci		} while (--count);
3278c2ecf20Sopenharmony_ci	}
3288c2ecf20Sopenharmony_ci}
3298c2ecf20Sopenharmony_ci#endif
3308c2ecf20Sopenharmony_ci
3318c2ecf20Sopenharmony_ci#ifndef readsw
3328c2ecf20Sopenharmony_ci#define readsw readsw
3338c2ecf20Sopenharmony_cistatic inline void readsw(const volatile void __iomem *addr, void *buffer,
3348c2ecf20Sopenharmony_ci			  unsigned int count)
3358c2ecf20Sopenharmony_ci{
3368c2ecf20Sopenharmony_ci	if (count) {
3378c2ecf20Sopenharmony_ci		u16 *buf = buffer;
3388c2ecf20Sopenharmony_ci
3398c2ecf20Sopenharmony_ci		do {
3408c2ecf20Sopenharmony_ci			u16 x = __raw_readw(addr);
3418c2ecf20Sopenharmony_ci			*buf++ = x;
3428c2ecf20Sopenharmony_ci		} while (--count);
3438c2ecf20Sopenharmony_ci	}
3448c2ecf20Sopenharmony_ci}
3458c2ecf20Sopenharmony_ci#endif
3468c2ecf20Sopenharmony_ci
3478c2ecf20Sopenharmony_ci#ifndef readsl
3488c2ecf20Sopenharmony_ci#define readsl readsl
3498c2ecf20Sopenharmony_cistatic inline void readsl(const volatile void __iomem *addr, void *buffer,
3508c2ecf20Sopenharmony_ci			  unsigned int count)
3518c2ecf20Sopenharmony_ci{
3528c2ecf20Sopenharmony_ci	if (count) {
3538c2ecf20Sopenharmony_ci		u32 *buf = buffer;
3548c2ecf20Sopenharmony_ci
3558c2ecf20Sopenharmony_ci		do {
3568c2ecf20Sopenharmony_ci			u32 x = __raw_readl(addr);
3578c2ecf20Sopenharmony_ci			*buf++ = x;
3588c2ecf20Sopenharmony_ci		} while (--count);
3598c2ecf20Sopenharmony_ci	}
3608c2ecf20Sopenharmony_ci}
3618c2ecf20Sopenharmony_ci#endif
3628c2ecf20Sopenharmony_ci
3638c2ecf20Sopenharmony_ci#ifdef CONFIG_64BIT
3648c2ecf20Sopenharmony_ci#ifndef readsq
3658c2ecf20Sopenharmony_ci#define readsq readsq
3668c2ecf20Sopenharmony_cistatic inline void readsq(const volatile void __iomem *addr, void *buffer,
3678c2ecf20Sopenharmony_ci			  unsigned int count)
3688c2ecf20Sopenharmony_ci{
3698c2ecf20Sopenharmony_ci	if (count) {
3708c2ecf20Sopenharmony_ci		u64 *buf = buffer;
3718c2ecf20Sopenharmony_ci
3728c2ecf20Sopenharmony_ci		do {
3738c2ecf20Sopenharmony_ci			u64 x = __raw_readq(addr);
3748c2ecf20Sopenharmony_ci			*buf++ = x;
3758c2ecf20Sopenharmony_ci		} while (--count);
3768c2ecf20Sopenharmony_ci	}
3778c2ecf20Sopenharmony_ci}
3788c2ecf20Sopenharmony_ci#endif
3798c2ecf20Sopenharmony_ci#endif /* CONFIG_64BIT */
3808c2ecf20Sopenharmony_ci
3818c2ecf20Sopenharmony_ci#ifndef writesb
3828c2ecf20Sopenharmony_ci#define writesb writesb
3838c2ecf20Sopenharmony_cistatic inline void writesb(volatile void __iomem *addr, const void *buffer,
3848c2ecf20Sopenharmony_ci			   unsigned int count)
3858c2ecf20Sopenharmony_ci{
3868c2ecf20Sopenharmony_ci	if (count) {
3878c2ecf20Sopenharmony_ci		const u8 *buf = buffer;
3888c2ecf20Sopenharmony_ci
3898c2ecf20Sopenharmony_ci		do {
3908c2ecf20Sopenharmony_ci			__raw_writeb(*buf++, addr);
3918c2ecf20Sopenharmony_ci		} while (--count);
3928c2ecf20Sopenharmony_ci	}
3938c2ecf20Sopenharmony_ci}
3948c2ecf20Sopenharmony_ci#endif
3958c2ecf20Sopenharmony_ci
3968c2ecf20Sopenharmony_ci#ifndef writesw
3978c2ecf20Sopenharmony_ci#define writesw writesw
3988c2ecf20Sopenharmony_cistatic inline void writesw(volatile void __iomem *addr, const void *buffer,
3998c2ecf20Sopenharmony_ci			   unsigned int count)
4008c2ecf20Sopenharmony_ci{
4018c2ecf20Sopenharmony_ci	if (count) {
4028c2ecf20Sopenharmony_ci		const u16 *buf = buffer;
4038c2ecf20Sopenharmony_ci
4048c2ecf20Sopenharmony_ci		do {
4058c2ecf20Sopenharmony_ci			__raw_writew(*buf++, addr);
4068c2ecf20Sopenharmony_ci		} while (--count);
4078c2ecf20Sopenharmony_ci	}
4088c2ecf20Sopenharmony_ci}
4098c2ecf20Sopenharmony_ci#endif
4108c2ecf20Sopenharmony_ci
4118c2ecf20Sopenharmony_ci#ifndef writesl
4128c2ecf20Sopenharmony_ci#define writesl writesl
4138c2ecf20Sopenharmony_cistatic inline void writesl(volatile void __iomem *addr, const void *buffer,
4148c2ecf20Sopenharmony_ci			   unsigned int count)
4158c2ecf20Sopenharmony_ci{
4168c2ecf20Sopenharmony_ci	if (count) {
4178c2ecf20Sopenharmony_ci		const u32 *buf = buffer;
4188c2ecf20Sopenharmony_ci
4198c2ecf20Sopenharmony_ci		do {
4208c2ecf20Sopenharmony_ci			__raw_writel(*buf++, addr);
4218c2ecf20Sopenharmony_ci		} while (--count);
4228c2ecf20Sopenharmony_ci	}
4238c2ecf20Sopenharmony_ci}
4248c2ecf20Sopenharmony_ci#endif
4258c2ecf20Sopenharmony_ci
4268c2ecf20Sopenharmony_ci#ifdef CONFIG_64BIT
4278c2ecf20Sopenharmony_ci#ifndef writesq
4288c2ecf20Sopenharmony_ci#define writesq writesq
4298c2ecf20Sopenharmony_cistatic inline void writesq(volatile void __iomem *addr, const void *buffer,
4308c2ecf20Sopenharmony_ci			   unsigned int count)
4318c2ecf20Sopenharmony_ci{
4328c2ecf20Sopenharmony_ci	if (count) {
4338c2ecf20Sopenharmony_ci		const u64 *buf = buffer;
4348c2ecf20Sopenharmony_ci
4358c2ecf20Sopenharmony_ci		do {
4368c2ecf20Sopenharmony_ci			__raw_writeq(*buf++, addr);
4378c2ecf20Sopenharmony_ci		} while (--count);
4388c2ecf20Sopenharmony_ci	}
4398c2ecf20Sopenharmony_ci}
4408c2ecf20Sopenharmony_ci#endif
4418c2ecf20Sopenharmony_ci#endif /* CONFIG_64BIT */
4428c2ecf20Sopenharmony_ci
4438c2ecf20Sopenharmony_ci#ifndef PCI_IOBASE
4448c2ecf20Sopenharmony_ci#define PCI_IOBASE ((void __iomem *)0)
4458c2ecf20Sopenharmony_ci#endif
4468c2ecf20Sopenharmony_ci
4478c2ecf20Sopenharmony_ci#ifndef IO_SPACE_LIMIT
4488c2ecf20Sopenharmony_ci#define IO_SPACE_LIMIT 0xffff
4498c2ecf20Sopenharmony_ci#endif
4508c2ecf20Sopenharmony_ci
4518c2ecf20Sopenharmony_ci/*
4528c2ecf20Sopenharmony_ci * {in,out}{b,w,l}() access little endian I/O. {in,out}{b,w,l}_p() can be
4538c2ecf20Sopenharmony_ci * implemented on hardware that needs an additional delay for I/O accesses to
4548c2ecf20Sopenharmony_ci * take effect.
4558c2ecf20Sopenharmony_ci */
4568c2ecf20Sopenharmony_ci
4578c2ecf20Sopenharmony_ci#if !defined(inb) && !defined(_inb)
4588c2ecf20Sopenharmony_ci#define _inb _inb
4598c2ecf20Sopenharmony_cistatic inline u8 _inb(unsigned long addr)
4608c2ecf20Sopenharmony_ci{
4618c2ecf20Sopenharmony_ci	u8 val;
4628c2ecf20Sopenharmony_ci
4638c2ecf20Sopenharmony_ci	__io_pbr();
4648c2ecf20Sopenharmony_ci	val = __raw_readb(PCI_IOBASE + addr);
4658c2ecf20Sopenharmony_ci	__io_par(val);
4668c2ecf20Sopenharmony_ci	return val;
4678c2ecf20Sopenharmony_ci}
4688c2ecf20Sopenharmony_ci#endif
4698c2ecf20Sopenharmony_ci
4708c2ecf20Sopenharmony_ci#if !defined(inw) && !defined(_inw)
4718c2ecf20Sopenharmony_ci#define _inw _inw
4728c2ecf20Sopenharmony_cistatic inline u16 _inw(unsigned long addr)
4738c2ecf20Sopenharmony_ci{
4748c2ecf20Sopenharmony_ci	u16 val;
4758c2ecf20Sopenharmony_ci
4768c2ecf20Sopenharmony_ci	__io_pbr();
4778c2ecf20Sopenharmony_ci	val = __le16_to_cpu((__le16 __force)__raw_readw(PCI_IOBASE + addr));
4788c2ecf20Sopenharmony_ci	__io_par(val);
4798c2ecf20Sopenharmony_ci	return val;
4808c2ecf20Sopenharmony_ci}
4818c2ecf20Sopenharmony_ci#endif
4828c2ecf20Sopenharmony_ci
4838c2ecf20Sopenharmony_ci#if !defined(inl) && !defined(_inl)
4848c2ecf20Sopenharmony_ci#define _inl _inl
4858c2ecf20Sopenharmony_cistatic inline u32 _inl(unsigned long addr)
4868c2ecf20Sopenharmony_ci{
4878c2ecf20Sopenharmony_ci	u32 val;
4888c2ecf20Sopenharmony_ci
4898c2ecf20Sopenharmony_ci	__io_pbr();
4908c2ecf20Sopenharmony_ci	val = __le32_to_cpu((__le32 __force)__raw_readl(PCI_IOBASE + addr));
4918c2ecf20Sopenharmony_ci	__io_par(val);
4928c2ecf20Sopenharmony_ci	return val;
4938c2ecf20Sopenharmony_ci}
4948c2ecf20Sopenharmony_ci#endif
4958c2ecf20Sopenharmony_ci
4968c2ecf20Sopenharmony_ci#if !defined(outb) && !defined(_outb)
4978c2ecf20Sopenharmony_ci#define _outb _outb
4988c2ecf20Sopenharmony_cistatic inline void _outb(u8 value, unsigned long addr)
4998c2ecf20Sopenharmony_ci{
5008c2ecf20Sopenharmony_ci	__io_pbw();
5018c2ecf20Sopenharmony_ci	__raw_writeb(value, PCI_IOBASE + addr);
5028c2ecf20Sopenharmony_ci	__io_paw();
5038c2ecf20Sopenharmony_ci}
5048c2ecf20Sopenharmony_ci#endif
5058c2ecf20Sopenharmony_ci
5068c2ecf20Sopenharmony_ci#if !defined(outw) && !defined(_outw)
5078c2ecf20Sopenharmony_ci#define _outw _outw
5088c2ecf20Sopenharmony_cistatic inline void _outw(u16 value, unsigned long addr)
5098c2ecf20Sopenharmony_ci{
5108c2ecf20Sopenharmony_ci	__io_pbw();
5118c2ecf20Sopenharmony_ci	__raw_writew((u16 __force)cpu_to_le16(value), PCI_IOBASE + addr);
5128c2ecf20Sopenharmony_ci	__io_paw();
5138c2ecf20Sopenharmony_ci}
5148c2ecf20Sopenharmony_ci#endif
5158c2ecf20Sopenharmony_ci
5168c2ecf20Sopenharmony_ci#if !defined(outl) && !defined(_outl)
5178c2ecf20Sopenharmony_ci#define _outl _outl
5188c2ecf20Sopenharmony_cistatic inline void _outl(u32 value, unsigned long addr)
5198c2ecf20Sopenharmony_ci{
5208c2ecf20Sopenharmony_ci	__io_pbw();
5218c2ecf20Sopenharmony_ci	__raw_writel((u32 __force)cpu_to_le32(value), PCI_IOBASE + addr);
5228c2ecf20Sopenharmony_ci	__io_paw();
5238c2ecf20Sopenharmony_ci}
5248c2ecf20Sopenharmony_ci#endif
5258c2ecf20Sopenharmony_ci
5268c2ecf20Sopenharmony_ci#include <linux/logic_pio.h>
5278c2ecf20Sopenharmony_ci
5288c2ecf20Sopenharmony_ci#ifndef inb
5298c2ecf20Sopenharmony_ci#define inb _inb
5308c2ecf20Sopenharmony_ci#endif
5318c2ecf20Sopenharmony_ci
5328c2ecf20Sopenharmony_ci#ifndef inw
5338c2ecf20Sopenharmony_ci#define inw _inw
5348c2ecf20Sopenharmony_ci#endif
5358c2ecf20Sopenharmony_ci
5368c2ecf20Sopenharmony_ci#ifndef inl
5378c2ecf20Sopenharmony_ci#define inl _inl
5388c2ecf20Sopenharmony_ci#endif
5398c2ecf20Sopenharmony_ci
5408c2ecf20Sopenharmony_ci#ifndef outb
5418c2ecf20Sopenharmony_ci#define outb _outb
5428c2ecf20Sopenharmony_ci#endif
5438c2ecf20Sopenharmony_ci
5448c2ecf20Sopenharmony_ci#ifndef outw
5458c2ecf20Sopenharmony_ci#define outw _outw
5468c2ecf20Sopenharmony_ci#endif
5478c2ecf20Sopenharmony_ci
5488c2ecf20Sopenharmony_ci#ifndef outl
5498c2ecf20Sopenharmony_ci#define outl _outl
5508c2ecf20Sopenharmony_ci#endif
5518c2ecf20Sopenharmony_ci
5528c2ecf20Sopenharmony_ci#ifndef inb_p
5538c2ecf20Sopenharmony_ci#define inb_p inb_p
5548c2ecf20Sopenharmony_cistatic inline u8 inb_p(unsigned long addr)
5558c2ecf20Sopenharmony_ci{
5568c2ecf20Sopenharmony_ci	return inb(addr);
5578c2ecf20Sopenharmony_ci}
5588c2ecf20Sopenharmony_ci#endif
5598c2ecf20Sopenharmony_ci
5608c2ecf20Sopenharmony_ci#ifndef inw_p
5618c2ecf20Sopenharmony_ci#define inw_p inw_p
5628c2ecf20Sopenharmony_cistatic inline u16 inw_p(unsigned long addr)
5638c2ecf20Sopenharmony_ci{
5648c2ecf20Sopenharmony_ci	return inw(addr);
5658c2ecf20Sopenharmony_ci}
5668c2ecf20Sopenharmony_ci#endif
5678c2ecf20Sopenharmony_ci
5688c2ecf20Sopenharmony_ci#ifndef inl_p
5698c2ecf20Sopenharmony_ci#define inl_p inl_p
5708c2ecf20Sopenharmony_cistatic inline u32 inl_p(unsigned long addr)
5718c2ecf20Sopenharmony_ci{
5728c2ecf20Sopenharmony_ci	return inl(addr);
5738c2ecf20Sopenharmony_ci}
5748c2ecf20Sopenharmony_ci#endif
5758c2ecf20Sopenharmony_ci
5768c2ecf20Sopenharmony_ci#ifndef outb_p
5778c2ecf20Sopenharmony_ci#define outb_p outb_p
5788c2ecf20Sopenharmony_cistatic inline void outb_p(u8 value, unsigned long addr)
5798c2ecf20Sopenharmony_ci{
5808c2ecf20Sopenharmony_ci	outb(value, addr);
5818c2ecf20Sopenharmony_ci}
5828c2ecf20Sopenharmony_ci#endif
5838c2ecf20Sopenharmony_ci
5848c2ecf20Sopenharmony_ci#ifndef outw_p
5858c2ecf20Sopenharmony_ci#define outw_p outw_p
5868c2ecf20Sopenharmony_cistatic inline void outw_p(u16 value, unsigned long addr)
5878c2ecf20Sopenharmony_ci{
5888c2ecf20Sopenharmony_ci	outw(value, addr);
5898c2ecf20Sopenharmony_ci}
5908c2ecf20Sopenharmony_ci#endif
5918c2ecf20Sopenharmony_ci
5928c2ecf20Sopenharmony_ci#ifndef outl_p
5938c2ecf20Sopenharmony_ci#define outl_p outl_p
5948c2ecf20Sopenharmony_cistatic inline void outl_p(u32 value, unsigned long addr)
5958c2ecf20Sopenharmony_ci{
5968c2ecf20Sopenharmony_ci	outl(value, addr);
5978c2ecf20Sopenharmony_ci}
5988c2ecf20Sopenharmony_ci#endif
5998c2ecf20Sopenharmony_ci
6008c2ecf20Sopenharmony_ci/*
6018c2ecf20Sopenharmony_ci * {in,out}s{b,w,l}{,_p}() are variants of the above that repeatedly access a
6028c2ecf20Sopenharmony_ci * single I/O port multiple times.
6038c2ecf20Sopenharmony_ci */
6048c2ecf20Sopenharmony_ci
6058c2ecf20Sopenharmony_ci#ifndef insb
6068c2ecf20Sopenharmony_ci#define insb insb
6078c2ecf20Sopenharmony_cistatic inline void insb(unsigned long addr, void *buffer, unsigned int count)
6088c2ecf20Sopenharmony_ci{
6098c2ecf20Sopenharmony_ci	readsb(PCI_IOBASE + addr, buffer, count);
6108c2ecf20Sopenharmony_ci}
6118c2ecf20Sopenharmony_ci#endif
6128c2ecf20Sopenharmony_ci
6138c2ecf20Sopenharmony_ci#ifndef insw
6148c2ecf20Sopenharmony_ci#define insw insw
6158c2ecf20Sopenharmony_cistatic inline void insw(unsigned long addr, void *buffer, unsigned int count)
6168c2ecf20Sopenharmony_ci{
6178c2ecf20Sopenharmony_ci	readsw(PCI_IOBASE + addr, buffer, count);
6188c2ecf20Sopenharmony_ci}
6198c2ecf20Sopenharmony_ci#endif
6208c2ecf20Sopenharmony_ci
6218c2ecf20Sopenharmony_ci#ifndef insl
6228c2ecf20Sopenharmony_ci#define insl insl
6238c2ecf20Sopenharmony_cistatic inline void insl(unsigned long addr, void *buffer, unsigned int count)
6248c2ecf20Sopenharmony_ci{
6258c2ecf20Sopenharmony_ci	readsl(PCI_IOBASE + addr, buffer, count);
6268c2ecf20Sopenharmony_ci}
6278c2ecf20Sopenharmony_ci#endif
6288c2ecf20Sopenharmony_ci
6298c2ecf20Sopenharmony_ci#ifndef outsb
6308c2ecf20Sopenharmony_ci#define outsb outsb
6318c2ecf20Sopenharmony_cistatic inline void outsb(unsigned long addr, const void *buffer,
6328c2ecf20Sopenharmony_ci			 unsigned int count)
6338c2ecf20Sopenharmony_ci{
6348c2ecf20Sopenharmony_ci	writesb(PCI_IOBASE + addr, buffer, count);
6358c2ecf20Sopenharmony_ci}
6368c2ecf20Sopenharmony_ci#endif
6378c2ecf20Sopenharmony_ci
6388c2ecf20Sopenharmony_ci#ifndef outsw
6398c2ecf20Sopenharmony_ci#define outsw outsw
6408c2ecf20Sopenharmony_cistatic inline void outsw(unsigned long addr, const void *buffer,
6418c2ecf20Sopenharmony_ci			 unsigned int count)
6428c2ecf20Sopenharmony_ci{
6438c2ecf20Sopenharmony_ci	writesw(PCI_IOBASE + addr, buffer, count);
6448c2ecf20Sopenharmony_ci}
6458c2ecf20Sopenharmony_ci#endif
6468c2ecf20Sopenharmony_ci
6478c2ecf20Sopenharmony_ci#ifndef outsl
6488c2ecf20Sopenharmony_ci#define outsl outsl
6498c2ecf20Sopenharmony_cistatic inline void outsl(unsigned long addr, const void *buffer,
6508c2ecf20Sopenharmony_ci			 unsigned int count)
6518c2ecf20Sopenharmony_ci{
6528c2ecf20Sopenharmony_ci	writesl(PCI_IOBASE + addr, buffer, count);
6538c2ecf20Sopenharmony_ci}
6548c2ecf20Sopenharmony_ci#endif
6558c2ecf20Sopenharmony_ci
6568c2ecf20Sopenharmony_ci#ifndef insb_p
6578c2ecf20Sopenharmony_ci#define insb_p insb_p
6588c2ecf20Sopenharmony_cistatic inline void insb_p(unsigned long addr, void *buffer, unsigned int count)
6598c2ecf20Sopenharmony_ci{
6608c2ecf20Sopenharmony_ci	insb(addr, buffer, count);
6618c2ecf20Sopenharmony_ci}
6628c2ecf20Sopenharmony_ci#endif
6638c2ecf20Sopenharmony_ci
6648c2ecf20Sopenharmony_ci#ifndef insw_p
6658c2ecf20Sopenharmony_ci#define insw_p insw_p
6668c2ecf20Sopenharmony_cistatic inline void insw_p(unsigned long addr, void *buffer, unsigned int count)
6678c2ecf20Sopenharmony_ci{
6688c2ecf20Sopenharmony_ci	insw(addr, buffer, count);
6698c2ecf20Sopenharmony_ci}
6708c2ecf20Sopenharmony_ci#endif
6718c2ecf20Sopenharmony_ci
6728c2ecf20Sopenharmony_ci#ifndef insl_p
6738c2ecf20Sopenharmony_ci#define insl_p insl_p
6748c2ecf20Sopenharmony_cistatic inline void insl_p(unsigned long addr, void *buffer, unsigned int count)
6758c2ecf20Sopenharmony_ci{
6768c2ecf20Sopenharmony_ci	insl(addr, buffer, count);
6778c2ecf20Sopenharmony_ci}
6788c2ecf20Sopenharmony_ci#endif
6798c2ecf20Sopenharmony_ci
6808c2ecf20Sopenharmony_ci#ifndef outsb_p
6818c2ecf20Sopenharmony_ci#define outsb_p outsb_p
6828c2ecf20Sopenharmony_cistatic inline void outsb_p(unsigned long addr, const void *buffer,
6838c2ecf20Sopenharmony_ci			   unsigned int count)
6848c2ecf20Sopenharmony_ci{
6858c2ecf20Sopenharmony_ci	outsb(addr, buffer, count);
6868c2ecf20Sopenharmony_ci}
6878c2ecf20Sopenharmony_ci#endif
6888c2ecf20Sopenharmony_ci
6898c2ecf20Sopenharmony_ci#ifndef outsw_p
6908c2ecf20Sopenharmony_ci#define outsw_p outsw_p
6918c2ecf20Sopenharmony_cistatic inline void outsw_p(unsigned long addr, const void *buffer,
6928c2ecf20Sopenharmony_ci			   unsigned int count)
6938c2ecf20Sopenharmony_ci{
6948c2ecf20Sopenharmony_ci	outsw(addr, buffer, count);
6958c2ecf20Sopenharmony_ci}
6968c2ecf20Sopenharmony_ci#endif
6978c2ecf20Sopenharmony_ci
6988c2ecf20Sopenharmony_ci#ifndef outsl_p
6998c2ecf20Sopenharmony_ci#define outsl_p outsl_p
7008c2ecf20Sopenharmony_cistatic inline void outsl_p(unsigned long addr, const void *buffer,
7018c2ecf20Sopenharmony_ci			   unsigned int count)
7028c2ecf20Sopenharmony_ci{
7038c2ecf20Sopenharmony_ci	outsl(addr, buffer, count);
7048c2ecf20Sopenharmony_ci}
7058c2ecf20Sopenharmony_ci#endif
7068c2ecf20Sopenharmony_ci
7078c2ecf20Sopenharmony_ci#ifndef CONFIG_GENERIC_IOMAP
7088c2ecf20Sopenharmony_ci#ifndef ioread8
7098c2ecf20Sopenharmony_ci#define ioread8 ioread8
7108c2ecf20Sopenharmony_cistatic inline u8 ioread8(const volatile void __iomem *addr)
7118c2ecf20Sopenharmony_ci{
7128c2ecf20Sopenharmony_ci	return readb(addr);
7138c2ecf20Sopenharmony_ci}
7148c2ecf20Sopenharmony_ci#endif
7158c2ecf20Sopenharmony_ci
7168c2ecf20Sopenharmony_ci#ifndef ioread16
7178c2ecf20Sopenharmony_ci#define ioread16 ioread16
7188c2ecf20Sopenharmony_cistatic inline u16 ioread16(const volatile void __iomem *addr)
7198c2ecf20Sopenharmony_ci{
7208c2ecf20Sopenharmony_ci	return readw(addr);
7218c2ecf20Sopenharmony_ci}
7228c2ecf20Sopenharmony_ci#endif
7238c2ecf20Sopenharmony_ci
7248c2ecf20Sopenharmony_ci#ifndef ioread32
7258c2ecf20Sopenharmony_ci#define ioread32 ioread32
7268c2ecf20Sopenharmony_cistatic inline u32 ioread32(const volatile void __iomem *addr)
7278c2ecf20Sopenharmony_ci{
7288c2ecf20Sopenharmony_ci	return readl(addr);
7298c2ecf20Sopenharmony_ci}
7308c2ecf20Sopenharmony_ci#endif
7318c2ecf20Sopenharmony_ci
7328c2ecf20Sopenharmony_ci#ifdef CONFIG_64BIT
7338c2ecf20Sopenharmony_ci#ifndef ioread64
7348c2ecf20Sopenharmony_ci#define ioread64 ioread64
7358c2ecf20Sopenharmony_cistatic inline u64 ioread64(const volatile void __iomem *addr)
7368c2ecf20Sopenharmony_ci{
7378c2ecf20Sopenharmony_ci	return readq(addr);
7388c2ecf20Sopenharmony_ci}
7398c2ecf20Sopenharmony_ci#endif
7408c2ecf20Sopenharmony_ci#endif /* CONFIG_64BIT */
7418c2ecf20Sopenharmony_ci
7428c2ecf20Sopenharmony_ci#ifndef iowrite8
7438c2ecf20Sopenharmony_ci#define iowrite8 iowrite8
7448c2ecf20Sopenharmony_cistatic inline void iowrite8(u8 value, volatile void __iomem *addr)
7458c2ecf20Sopenharmony_ci{
7468c2ecf20Sopenharmony_ci	writeb(value, addr);
7478c2ecf20Sopenharmony_ci}
7488c2ecf20Sopenharmony_ci#endif
7498c2ecf20Sopenharmony_ci
7508c2ecf20Sopenharmony_ci#ifndef iowrite16
7518c2ecf20Sopenharmony_ci#define iowrite16 iowrite16
7528c2ecf20Sopenharmony_cistatic inline void iowrite16(u16 value, volatile void __iomem *addr)
7538c2ecf20Sopenharmony_ci{
7548c2ecf20Sopenharmony_ci	writew(value, addr);
7558c2ecf20Sopenharmony_ci}
7568c2ecf20Sopenharmony_ci#endif
7578c2ecf20Sopenharmony_ci
7588c2ecf20Sopenharmony_ci#ifndef iowrite32
7598c2ecf20Sopenharmony_ci#define iowrite32 iowrite32
7608c2ecf20Sopenharmony_cistatic inline void iowrite32(u32 value, volatile void __iomem *addr)
7618c2ecf20Sopenharmony_ci{
7628c2ecf20Sopenharmony_ci	writel(value, addr);
7638c2ecf20Sopenharmony_ci}
7648c2ecf20Sopenharmony_ci#endif
7658c2ecf20Sopenharmony_ci
7668c2ecf20Sopenharmony_ci#ifdef CONFIG_64BIT
7678c2ecf20Sopenharmony_ci#ifndef iowrite64
7688c2ecf20Sopenharmony_ci#define iowrite64 iowrite64
7698c2ecf20Sopenharmony_cistatic inline void iowrite64(u64 value, volatile void __iomem *addr)
7708c2ecf20Sopenharmony_ci{
7718c2ecf20Sopenharmony_ci	writeq(value, addr);
7728c2ecf20Sopenharmony_ci}
7738c2ecf20Sopenharmony_ci#endif
7748c2ecf20Sopenharmony_ci#endif /* CONFIG_64BIT */
7758c2ecf20Sopenharmony_ci
7768c2ecf20Sopenharmony_ci#ifndef ioread16be
7778c2ecf20Sopenharmony_ci#define ioread16be ioread16be
7788c2ecf20Sopenharmony_cistatic inline u16 ioread16be(const volatile void __iomem *addr)
7798c2ecf20Sopenharmony_ci{
7808c2ecf20Sopenharmony_ci	return swab16(readw(addr));
7818c2ecf20Sopenharmony_ci}
7828c2ecf20Sopenharmony_ci#endif
7838c2ecf20Sopenharmony_ci
7848c2ecf20Sopenharmony_ci#ifndef ioread32be
7858c2ecf20Sopenharmony_ci#define ioread32be ioread32be
7868c2ecf20Sopenharmony_cistatic inline u32 ioread32be(const volatile void __iomem *addr)
7878c2ecf20Sopenharmony_ci{
7888c2ecf20Sopenharmony_ci	return swab32(readl(addr));
7898c2ecf20Sopenharmony_ci}
7908c2ecf20Sopenharmony_ci#endif
7918c2ecf20Sopenharmony_ci
7928c2ecf20Sopenharmony_ci#ifdef CONFIG_64BIT
7938c2ecf20Sopenharmony_ci#ifndef ioread64be
7948c2ecf20Sopenharmony_ci#define ioread64be ioread64be
7958c2ecf20Sopenharmony_cistatic inline u64 ioread64be(const volatile void __iomem *addr)
7968c2ecf20Sopenharmony_ci{
7978c2ecf20Sopenharmony_ci	return swab64(readq(addr));
7988c2ecf20Sopenharmony_ci}
7998c2ecf20Sopenharmony_ci#endif
8008c2ecf20Sopenharmony_ci#endif /* CONFIG_64BIT */
8018c2ecf20Sopenharmony_ci
8028c2ecf20Sopenharmony_ci#ifndef iowrite16be
8038c2ecf20Sopenharmony_ci#define iowrite16be iowrite16be
8048c2ecf20Sopenharmony_cistatic inline void iowrite16be(u16 value, void volatile __iomem *addr)
8058c2ecf20Sopenharmony_ci{
8068c2ecf20Sopenharmony_ci	writew(swab16(value), addr);
8078c2ecf20Sopenharmony_ci}
8088c2ecf20Sopenharmony_ci#endif
8098c2ecf20Sopenharmony_ci
8108c2ecf20Sopenharmony_ci#ifndef iowrite32be
8118c2ecf20Sopenharmony_ci#define iowrite32be iowrite32be
8128c2ecf20Sopenharmony_cistatic inline void iowrite32be(u32 value, volatile void __iomem *addr)
8138c2ecf20Sopenharmony_ci{
8148c2ecf20Sopenharmony_ci	writel(swab32(value), addr);
8158c2ecf20Sopenharmony_ci}
8168c2ecf20Sopenharmony_ci#endif
8178c2ecf20Sopenharmony_ci
8188c2ecf20Sopenharmony_ci#ifdef CONFIG_64BIT
8198c2ecf20Sopenharmony_ci#ifndef iowrite64be
8208c2ecf20Sopenharmony_ci#define iowrite64be iowrite64be
8218c2ecf20Sopenharmony_cistatic inline void iowrite64be(u64 value, volatile void __iomem *addr)
8228c2ecf20Sopenharmony_ci{
8238c2ecf20Sopenharmony_ci	writeq(swab64(value), addr);
8248c2ecf20Sopenharmony_ci}
8258c2ecf20Sopenharmony_ci#endif
8268c2ecf20Sopenharmony_ci#endif /* CONFIG_64BIT */
8278c2ecf20Sopenharmony_ci
8288c2ecf20Sopenharmony_ci#ifndef ioread8_rep
8298c2ecf20Sopenharmony_ci#define ioread8_rep ioread8_rep
8308c2ecf20Sopenharmony_cistatic inline void ioread8_rep(const volatile void __iomem *addr, void *buffer,
8318c2ecf20Sopenharmony_ci			       unsigned int count)
8328c2ecf20Sopenharmony_ci{
8338c2ecf20Sopenharmony_ci	readsb(addr, buffer, count);
8348c2ecf20Sopenharmony_ci}
8358c2ecf20Sopenharmony_ci#endif
8368c2ecf20Sopenharmony_ci
8378c2ecf20Sopenharmony_ci#ifndef ioread16_rep
8388c2ecf20Sopenharmony_ci#define ioread16_rep ioread16_rep
8398c2ecf20Sopenharmony_cistatic inline void ioread16_rep(const volatile void __iomem *addr,
8408c2ecf20Sopenharmony_ci				void *buffer, unsigned int count)
8418c2ecf20Sopenharmony_ci{
8428c2ecf20Sopenharmony_ci	readsw(addr, buffer, count);
8438c2ecf20Sopenharmony_ci}
8448c2ecf20Sopenharmony_ci#endif
8458c2ecf20Sopenharmony_ci
8468c2ecf20Sopenharmony_ci#ifndef ioread32_rep
8478c2ecf20Sopenharmony_ci#define ioread32_rep ioread32_rep
8488c2ecf20Sopenharmony_cistatic inline void ioread32_rep(const volatile void __iomem *addr,
8498c2ecf20Sopenharmony_ci				void *buffer, unsigned int count)
8508c2ecf20Sopenharmony_ci{
8518c2ecf20Sopenharmony_ci	readsl(addr, buffer, count);
8528c2ecf20Sopenharmony_ci}
8538c2ecf20Sopenharmony_ci#endif
8548c2ecf20Sopenharmony_ci
8558c2ecf20Sopenharmony_ci#ifdef CONFIG_64BIT
8568c2ecf20Sopenharmony_ci#ifndef ioread64_rep
8578c2ecf20Sopenharmony_ci#define ioread64_rep ioread64_rep
8588c2ecf20Sopenharmony_cistatic inline void ioread64_rep(const volatile void __iomem *addr,
8598c2ecf20Sopenharmony_ci				void *buffer, unsigned int count)
8608c2ecf20Sopenharmony_ci{
8618c2ecf20Sopenharmony_ci	readsq(addr, buffer, count);
8628c2ecf20Sopenharmony_ci}
8638c2ecf20Sopenharmony_ci#endif
8648c2ecf20Sopenharmony_ci#endif /* CONFIG_64BIT */
8658c2ecf20Sopenharmony_ci
8668c2ecf20Sopenharmony_ci#ifndef iowrite8_rep
8678c2ecf20Sopenharmony_ci#define iowrite8_rep iowrite8_rep
8688c2ecf20Sopenharmony_cistatic inline void iowrite8_rep(volatile void __iomem *addr,
8698c2ecf20Sopenharmony_ci				const void *buffer,
8708c2ecf20Sopenharmony_ci				unsigned int count)
8718c2ecf20Sopenharmony_ci{
8728c2ecf20Sopenharmony_ci	writesb(addr, buffer, count);
8738c2ecf20Sopenharmony_ci}
8748c2ecf20Sopenharmony_ci#endif
8758c2ecf20Sopenharmony_ci
8768c2ecf20Sopenharmony_ci#ifndef iowrite16_rep
8778c2ecf20Sopenharmony_ci#define iowrite16_rep iowrite16_rep
8788c2ecf20Sopenharmony_cistatic inline void iowrite16_rep(volatile void __iomem *addr,
8798c2ecf20Sopenharmony_ci				 const void *buffer,
8808c2ecf20Sopenharmony_ci				 unsigned int count)
8818c2ecf20Sopenharmony_ci{
8828c2ecf20Sopenharmony_ci	writesw(addr, buffer, count);
8838c2ecf20Sopenharmony_ci}
8848c2ecf20Sopenharmony_ci#endif
8858c2ecf20Sopenharmony_ci
8868c2ecf20Sopenharmony_ci#ifndef iowrite32_rep
8878c2ecf20Sopenharmony_ci#define iowrite32_rep iowrite32_rep
8888c2ecf20Sopenharmony_cistatic inline void iowrite32_rep(volatile void __iomem *addr,
8898c2ecf20Sopenharmony_ci				 const void *buffer,
8908c2ecf20Sopenharmony_ci				 unsigned int count)
8918c2ecf20Sopenharmony_ci{
8928c2ecf20Sopenharmony_ci	writesl(addr, buffer, count);
8938c2ecf20Sopenharmony_ci}
8948c2ecf20Sopenharmony_ci#endif
8958c2ecf20Sopenharmony_ci
8968c2ecf20Sopenharmony_ci#ifdef CONFIG_64BIT
8978c2ecf20Sopenharmony_ci#ifndef iowrite64_rep
8988c2ecf20Sopenharmony_ci#define iowrite64_rep iowrite64_rep
8998c2ecf20Sopenharmony_cistatic inline void iowrite64_rep(volatile void __iomem *addr,
9008c2ecf20Sopenharmony_ci				 const void *buffer,
9018c2ecf20Sopenharmony_ci				 unsigned int count)
9028c2ecf20Sopenharmony_ci{
9038c2ecf20Sopenharmony_ci	writesq(addr, buffer, count);
9048c2ecf20Sopenharmony_ci}
9058c2ecf20Sopenharmony_ci#endif
9068c2ecf20Sopenharmony_ci#endif /* CONFIG_64BIT */
9078c2ecf20Sopenharmony_ci#endif /* CONFIG_GENERIC_IOMAP */
9088c2ecf20Sopenharmony_ci
9098c2ecf20Sopenharmony_ci#ifdef __KERNEL__
9108c2ecf20Sopenharmony_ci
9118c2ecf20Sopenharmony_ci#include <linux/vmalloc.h>
9128c2ecf20Sopenharmony_ci#define __io_virt(x) ((void __force *)(x))
9138c2ecf20Sopenharmony_ci
9148c2ecf20Sopenharmony_ci/*
9158c2ecf20Sopenharmony_ci * Change virtual addresses to physical addresses and vv.
9168c2ecf20Sopenharmony_ci * These are pretty trivial
9178c2ecf20Sopenharmony_ci */
9188c2ecf20Sopenharmony_ci#ifndef virt_to_phys
9198c2ecf20Sopenharmony_ci#define virt_to_phys virt_to_phys
9208c2ecf20Sopenharmony_cistatic inline unsigned long virt_to_phys(volatile void *address)
9218c2ecf20Sopenharmony_ci{
9228c2ecf20Sopenharmony_ci	return __pa((unsigned long)address);
9238c2ecf20Sopenharmony_ci}
9248c2ecf20Sopenharmony_ci#endif
9258c2ecf20Sopenharmony_ci
9268c2ecf20Sopenharmony_ci#ifndef phys_to_virt
9278c2ecf20Sopenharmony_ci#define phys_to_virt phys_to_virt
9288c2ecf20Sopenharmony_cistatic inline void *phys_to_virt(unsigned long address)
9298c2ecf20Sopenharmony_ci{
9308c2ecf20Sopenharmony_ci	return __va(address);
9318c2ecf20Sopenharmony_ci}
9328c2ecf20Sopenharmony_ci#endif
9338c2ecf20Sopenharmony_ci
9348c2ecf20Sopenharmony_ci/**
9358c2ecf20Sopenharmony_ci * DOC: ioremap() and ioremap_*() variants
9368c2ecf20Sopenharmony_ci *
9378c2ecf20Sopenharmony_ci * Architectures with an MMU are expected to provide ioremap() and iounmap()
9388c2ecf20Sopenharmony_ci * themselves or rely on GENERIC_IOREMAP.  For NOMMU architectures we provide
9398c2ecf20Sopenharmony_ci * a default nop-op implementation that expect that the physical address used
9408c2ecf20Sopenharmony_ci * for MMIO are already marked as uncached, and can be used as kernel virtual
9418c2ecf20Sopenharmony_ci * addresses.
9428c2ecf20Sopenharmony_ci *
9438c2ecf20Sopenharmony_ci * ioremap_wc() and ioremap_wt() can provide more relaxed caching attributes
9448c2ecf20Sopenharmony_ci * for specific drivers if the architecture choses to implement them.  If they
9458c2ecf20Sopenharmony_ci * are not implemented we fall back to plain ioremap.
9468c2ecf20Sopenharmony_ci */
9478c2ecf20Sopenharmony_ci#ifndef CONFIG_MMU
9488c2ecf20Sopenharmony_ci#ifndef ioremap
9498c2ecf20Sopenharmony_ci#define ioremap ioremap
9508c2ecf20Sopenharmony_cistatic inline void __iomem *ioremap(phys_addr_t offset, size_t size)
9518c2ecf20Sopenharmony_ci{
9528c2ecf20Sopenharmony_ci	return (void __iomem *)(unsigned long)offset;
9538c2ecf20Sopenharmony_ci}
9548c2ecf20Sopenharmony_ci#endif
9558c2ecf20Sopenharmony_ci
9568c2ecf20Sopenharmony_ci#ifndef iounmap
9578c2ecf20Sopenharmony_ci#define iounmap iounmap
9588c2ecf20Sopenharmony_cistatic inline void iounmap(void __iomem *addr)
9598c2ecf20Sopenharmony_ci{
9608c2ecf20Sopenharmony_ci}
9618c2ecf20Sopenharmony_ci#endif
9628c2ecf20Sopenharmony_ci#elif defined(CONFIG_GENERIC_IOREMAP)
9638c2ecf20Sopenharmony_ci#include <linux/pgtable.h>
9648c2ecf20Sopenharmony_ci
9658c2ecf20Sopenharmony_civoid __iomem *ioremap_prot(phys_addr_t addr, size_t size, unsigned long prot);
9668c2ecf20Sopenharmony_civoid iounmap(volatile void __iomem *addr);
9678c2ecf20Sopenharmony_ci
9688c2ecf20Sopenharmony_cistatic inline void __iomem *ioremap(phys_addr_t addr, size_t size)
9698c2ecf20Sopenharmony_ci{
9708c2ecf20Sopenharmony_ci	/* _PAGE_IOREMAP needs to be supplied by the architecture */
9718c2ecf20Sopenharmony_ci	return ioremap_prot(addr, size, _PAGE_IOREMAP);
9728c2ecf20Sopenharmony_ci}
9738c2ecf20Sopenharmony_ci#endif /* !CONFIG_MMU || CONFIG_GENERIC_IOREMAP */
9748c2ecf20Sopenharmony_ci
9758c2ecf20Sopenharmony_ci#ifndef ioremap_wc
9768c2ecf20Sopenharmony_ci#define ioremap_wc ioremap
9778c2ecf20Sopenharmony_ci#endif
9788c2ecf20Sopenharmony_ci
9798c2ecf20Sopenharmony_ci#ifndef ioremap_wt
9808c2ecf20Sopenharmony_ci#define ioremap_wt ioremap
9818c2ecf20Sopenharmony_ci#endif
9828c2ecf20Sopenharmony_ci
9838c2ecf20Sopenharmony_ci/*
9848c2ecf20Sopenharmony_ci * ioremap_uc is special in that we do require an explicit architecture
9858c2ecf20Sopenharmony_ci * implementation.  In general you do not want to use this function in a
9868c2ecf20Sopenharmony_ci * driver and use plain ioremap, which is uncached by default.  Similarly
9878c2ecf20Sopenharmony_ci * architectures should not implement it unless they have a very good
9888c2ecf20Sopenharmony_ci * reason.
9898c2ecf20Sopenharmony_ci */
9908c2ecf20Sopenharmony_ci#ifndef ioremap_uc
9918c2ecf20Sopenharmony_ci#define ioremap_uc ioremap_uc
9928c2ecf20Sopenharmony_cistatic inline void __iomem *ioremap_uc(phys_addr_t offset, size_t size)
9938c2ecf20Sopenharmony_ci{
9948c2ecf20Sopenharmony_ci	return NULL;
9958c2ecf20Sopenharmony_ci}
9968c2ecf20Sopenharmony_ci#endif
9978c2ecf20Sopenharmony_ci
9988c2ecf20Sopenharmony_ci#ifdef CONFIG_HAS_IOPORT_MAP
9998c2ecf20Sopenharmony_ci#ifndef CONFIG_GENERIC_IOMAP
10008c2ecf20Sopenharmony_ci#ifndef ioport_map
10018c2ecf20Sopenharmony_ci#define ioport_map ioport_map
10028c2ecf20Sopenharmony_cistatic inline void __iomem *ioport_map(unsigned long port, unsigned int nr)
10038c2ecf20Sopenharmony_ci{
10048c2ecf20Sopenharmony_ci	port &= IO_SPACE_LIMIT;
10058c2ecf20Sopenharmony_ci	return (port > MMIO_UPPER_LIMIT) ? NULL : PCI_IOBASE + port;
10068c2ecf20Sopenharmony_ci}
10078c2ecf20Sopenharmony_ci#define __pci_ioport_unmap __pci_ioport_unmap
10088c2ecf20Sopenharmony_cistatic inline void __pci_ioport_unmap(void __iomem *p)
10098c2ecf20Sopenharmony_ci{
10108c2ecf20Sopenharmony_ci	uintptr_t start = (uintptr_t) PCI_IOBASE;
10118c2ecf20Sopenharmony_ci	uintptr_t addr = (uintptr_t) p;
10128c2ecf20Sopenharmony_ci
10138c2ecf20Sopenharmony_ci	if (addr >= start && addr < start + IO_SPACE_LIMIT)
10148c2ecf20Sopenharmony_ci		return;
10158c2ecf20Sopenharmony_ci	iounmap(p);
10168c2ecf20Sopenharmony_ci}
10178c2ecf20Sopenharmony_ci#endif
10188c2ecf20Sopenharmony_ci
10198c2ecf20Sopenharmony_ci#ifndef ioport_unmap
10208c2ecf20Sopenharmony_ci#define ioport_unmap ioport_unmap
10218c2ecf20Sopenharmony_cistatic inline void ioport_unmap(void __iomem *p)
10228c2ecf20Sopenharmony_ci{
10238c2ecf20Sopenharmony_ci}
10248c2ecf20Sopenharmony_ci#endif
10258c2ecf20Sopenharmony_ci#else /* CONFIG_GENERIC_IOMAP */
10268c2ecf20Sopenharmony_ciextern void __iomem *ioport_map(unsigned long port, unsigned int nr);
10278c2ecf20Sopenharmony_ciextern void ioport_unmap(void __iomem *p);
10288c2ecf20Sopenharmony_ci#endif /* CONFIG_GENERIC_IOMAP */
10298c2ecf20Sopenharmony_ci#endif /* CONFIG_HAS_IOPORT_MAP */
10308c2ecf20Sopenharmony_ci
10318c2ecf20Sopenharmony_ci#ifndef CONFIG_GENERIC_IOMAP
10328c2ecf20Sopenharmony_cistruct pci_dev;
10338c2ecf20Sopenharmony_ciextern void __iomem *pci_iomap(struct pci_dev *dev, int bar, unsigned long max);
10348c2ecf20Sopenharmony_ci
10358c2ecf20Sopenharmony_ci#ifndef __pci_ioport_unmap
10368c2ecf20Sopenharmony_cistatic inline void __pci_ioport_unmap(void __iomem *p) {}
10378c2ecf20Sopenharmony_ci#endif
10388c2ecf20Sopenharmony_ci
10398c2ecf20Sopenharmony_ci#ifndef pci_iounmap
10408c2ecf20Sopenharmony_ci#define pci_iounmap pci_iounmap
10418c2ecf20Sopenharmony_cistatic inline void pci_iounmap(struct pci_dev *dev, void __iomem *p)
10428c2ecf20Sopenharmony_ci{
10438c2ecf20Sopenharmony_ci	__pci_ioport_unmap(p);
10448c2ecf20Sopenharmony_ci}
10458c2ecf20Sopenharmony_ci#endif
10468c2ecf20Sopenharmony_ci#endif /* CONFIG_GENERIC_IOMAP */
10478c2ecf20Sopenharmony_ci
10488c2ecf20Sopenharmony_ci/*
10498c2ecf20Sopenharmony_ci * Convert a virtual cached pointer to an uncached pointer
10508c2ecf20Sopenharmony_ci */
10518c2ecf20Sopenharmony_ci#ifndef xlate_dev_kmem_ptr
10528c2ecf20Sopenharmony_ci#define xlate_dev_kmem_ptr xlate_dev_kmem_ptr
10538c2ecf20Sopenharmony_cistatic inline void *xlate_dev_kmem_ptr(void *addr)
10548c2ecf20Sopenharmony_ci{
10558c2ecf20Sopenharmony_ci	return addr;
10568c2ecf20Sopenharmony_ci}
10578c2ecf20Sopenharmony_ci#endif
10588c2ecf20Sopenharmony_ci
10598c2ecf20Sopenharmony_ci#ifndef xlate_dev_mem_ptr
10608c2ecf20Sopenharmony_ci#define xlate_dev_mem_ptr xlate_dev_mem_ptr
10618c2ecf20Sopenharmony_cistatic inline void *xlate_dev_mem_ptr(phys_addr_t addr)
10628c2ecf20Sopenharmony_ci{
10638c2ecf20Sopenharmony_ci	return __va(addr);
10648c2ecf20Sopenharmony_ci}
10658c2ecf20Sopenharmony_ci#endif
10668c2ecf20Sopenharmony_ci
10678c2ecf20Sopenharmony_ci#ifndef unxlate_dev_mem_ptr
10688c2ecf20Sopenharmony_ci#define unxlate_dev_mem_ptr unxlate_dev_mem_ptr
10698c2ecf20Sopenharmony_cistatic inline void unxlate_dev_mem_ptr(phys_addr_t phys, void *addr)
10708c2ecf20Sopenharmony_ci{
10718c2ecf20Sopenharmony_ci}
10728c2ecf20Sopenharmony_ci#endif
10738c2ecf20Sopenharmony_ci
10748c2ecf20Sopenharmony_ci#ifdef CONFIG_VIRT_TO_BUS
10758c2ecf20Sopenharmony_ci#ifndef virt_to_bus
10768c2ecf20Sopenharmony_cistatic inline unsigned long virt_to_bus(void *address)
10778c2ecf20Sopenharmony_ci{
10788c2ecf20Sopenharmony_ci	return (unsigned long)address;
10798c2ecf20Sopenharmony_ci}
10808c2ecf20Sopenharmony_ci
10818c2ecf20Sopenharmony_cistatic inline void *bus_to_virt(unsigned long address)
10828c2ecf20Sopenharmony_ci{
10838c2ecf20Sopenharmony_ci	return (void *)address;
10848c2ecf20Sopenharmony_ci}
10858c2ecf20Sopenharmony_ci#endif
10868c2ecf20Sopenharmony_ci#endif
10878c2ecf20Sopenharmony_ci
10888c2ecf20Sopenharmony_ci#ifndef memset_io
10898c2ecf20Sopenharmony_ci#define memset_io memset_io
10908c2ecf20Sopenharmony_ci/**
10918c2ecf20Sopenharmony_ci * memset_io	Set a range of I/O memory to a constant value
10928c2ecf20Sopenharmony_ci * @addr:	The beginning of the I/O-memory range to set
10938c2ecf20Sopenharmony_ci * @val:	The value to set the memory to
10948c2ecf20Sopenharmony_ci * @count:	The number of bytes to set
10958c2ecf20Sopenharmony_ci *
10968c2ecf20Sopenharmony_ci * Set a range of I/O memory to a given value.
10978c2ecf20Sopenharmony_ci */
10988c2ecf20Sopenharmony_cistatic inline void memset_io(volatile void __iomem *addr, int value,
10998c2ecf20Sopenharmony_ci			     size_t size)
11008c2ecf20Sopenharmony_ci{
11018c2ecf20Sopenharmony_ci	memset(__io_virt(addr), value, size);
11028c2ecf20Sopenharmony_ci}
11038c2ecf20Sopenharmony_ci#endif
11048c2ecf20Sopenharmony_ci
11058c2ecf20Sopenharmony_ci#ifndef memcpy_fromio
11068c2ecf20Sopenharmony_ci#define memcpy_fromio memcpy_fromio
11078c2ecf20Sopenharmony_ci/**
11088c2ecf20Sopenharmony_ci * memcpy_fromio	Copy a block of data from I/O memory
11098c2ecf20Sopenharmony_ci * @dst:		The (RAM) destination for the copy
11108c2ecf20Sopenharmony_ci * @src:		The (I/O memory) source for the data
11118c2ecf20Sopenharmony_ci * @count:		The number of bytes to copy
11128c2ecf20Sopenharmony_ci *
11138c2ecf20Sopenharmony_ci * Copy a block of data from I/O memory.
11148c2ecf20Sopenharmony_ci */
11158c2ecf20Sopenharmony_cistatic inline void memcpy_fromio(void *buffer,
11168c2ecf20Sopenharmony_ci				 const volatile void __iomem *addr,
11178c2ecf20Sopenharmony_ci				 size_t size)
11188c2ecf20Sopenharmony_ci{
11198c2ecf20Sopenharmony_ci	memcpy(buffer, __io_virt(addr), size);
11208c2ecf20Sopenharmony_ci}
11218c2ecf20Sopenharmony_ci#endif
11228c2ecf20Sopenharmony_ci
11238c2ecf20Sopenharmony_ci#ifndef memcpy_toio
11248c2ecf20Sopenharmony_ci#define memcpy_toio memcpy_toio
11258c2ecf20Sopenharmony_ci/**
11268c2ecf20Sopenharmony_ci * memcpy_toio		Copy a block of data into I/O memory
11278c2ecf20Sopenharmony_ci * @dst:		The (I/O memory) destination for the copy
11288c2ecf20Sopenharmony_ci * @src:		The (RAM) source for the data
11298c2ecf20Sopenharmony_ci * @count:		The number of bytes to copy
11308c2ecf20Sopenharmony_ci *
11318c2ecf20Sopenharmony_ci * Copy a block of data to I/O memory.
11328c2ecf20Sopenharmony_ci */
11338c2ecf20Sopenharmony_cistatic inline void memcpy_toio(volatile void __iomem *addr, const void *buffer,
11348c2ecf20Sopenharmony_ci			       size_t size)
11358c2ecf20Sopenharmony_ci{
11368c2ecf20Sopenharmony_ci	memcpy(__io_virt(addr), buffer, size);
11378c2ecf20Sopenharmony_ci}
11388c2ecf20Sopenharmony_ci#endif
11398c2ecf20Sopenharmony_ci
11408c2ecf20Sopenharmony_ci#endif /* __KERNEL__ */
11418c2ecf20Sopenharmony_ci
11428c2ecf20Sopenharmony_ci#endif /* __ASM_GENERIC_IO_H */
1143