162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-or-later */ 262306a36Sopenharmony_ci/* Generic I/O port emulation. 362306a36Sopenharmony_ci * 462306a36Sopenharmony_ci * Copyright (C) 2007 Red Hat, Inc. All Rights Reserved. 562306a36Sopenharmony_ci * Written by David Howells (dhowells@redhat.com) 662306a36Sopenharmony_ci */ 762306a36Sopenharmony_ci#ifndef __ASM_GENERIC_IO_H 862306a36Sopenharmony_ci#define __ASM_GENERIC_IO_H 962306a36Sopenharmony_ci 1062306a36Sopenharmony_ci#include <asm/page.h> /* I/O is all done through memory accesses */ 1162306a36Sopenharmony_ci#include <linux/string.h> /* for memset() and memcpy() */ 1262306a36Sopenharmony_ci#include <linux/types.h> 1362306a36Sopenharmony_ci#include <linux/instruction_pointer.h> 1462306a36Sopenharmony_ci 1562306a36Sopenharmony_ci#ifdef CONFIG_GENERIC_IOMAP 1662306a36Sopenharmony_ci#include <asm-generic/iomap.h> 1762306a36Sopenharmony_ci#endif 1862306a36Sopenharmony_ci 1962306a36Sopenharmony_ci#include <asm/mmiowb.h> 2062306a36Sopenharmony_ci#include <asm-generic/pci_iomap.h> 2162306a36Sopenharmony_ci 2262306a36Sopenharmony_ci#ifndef __io_br 2362306a36Sopenharmony_ci#define __io_br() barrier() 2462306a36Sopenharmony_ci#endif 2562306a36Sopenharmony_ci 2662306a36Sopenharmony_ci/* prevent prefetching of coherent DMA data ahead of a dma-complete */ 2762306a36Sopenharmony_ci#ifndef __io_ar 2862306a36Sopenharmony_ci#ifdef rmb 2962306a36Sopenharmony_ci#define __io_ar(v) rmb() 3062306a36Sopenharmony_ci#else 3162306a36Sopenharmony_ci#define __io_ar(v) barrier() 3262306a36Sopenharmony_ci#endif 3362306a36Sopenharmony_ci#endif 3462306a36Sopenharmony_ci 3562306a36Sopenharmony_ci/* flush writes to coherent DMA data before possibly triggering a DMA read */ 3662306a36Sopenharmony_ci#ifndef __io_bw 3762306a36Sopenharmony_ci#ifdef wmb 3862306a36Sopenharmony_ci#define __io_bw() wmb() 3962306a36Sopenharmony_ci#else 4062306a36Sopenharmony_ci#define __io_bw() barrier() 4162306a36Sopenharmony_ci#endif 4262306a36Sopenharmony_ci#endif 4362306a36Sopenharmony_ci 4462306a36Sopenharmony_ci/* serialize device access against a spin_unlock, usually handled there. */ 4562306a36Sopenharmony_ci#ifndef __io_aw 4662306a36Sopenharmony_ci#define __io_aw() mmiowb_set_pending() 4762306a36Sopenharmony_ci#endif 4862306a36Sopenharmony_ci 4962306a36Sopenharmony_ci#ifndef __io_pbw 5062306a36Sopenharmony_ci#define __io_pbw() __io_bw() 5162306a36Sopenharmony_ci#endif 5262306a36Sopenharmony_ci 5362306a36Sopenharmony_ci#ifndef __io_paw 5462306a36Sopenharmony_ci#define __io_paw() __io_aw() 5562306a36Sopenharmony_ci#endif 5662306a36Sopenharmony_ci 5762306a36Sopenharmony_ci#ifndef __io_pbr 5862306a36Sopenharmony_ci#define __io_pbr() __io_br() 5962306a36Sopenharmony_ci#endif 6062306a36Sopenharmony_ci 6162306a36Sopenharmony_ci#ifndef __io_par 6262306a36Sopenharmony_ci#define __io_par(v) __io_ar(v) 6362306a36Sopenharmony_ci#endif 6462306a36Sopenharmony_ci 6562306a36Sopenharmony_ci/* 6662306a36Sopenharmony_ci * "__DISABLE_TRACE_MMIO__" flag can be used to disable MMIO tracing for 6762306a36Sopenharmony_ci * specific kernel drivers in case of excessive/unwanted logging. 6862306a36Sopenharmony_ci * 6962306a36Sopenharmony_ci * Usage: Add a #define flag at the beginning of the driver file. 7062306a36Sopenharmony_ci * Ex: #define __DISABLE_TRACE_MMIO__ 7162306a36Sopenharmony_ci * #include <...> 7262306a36Sopenharmony_ci * ... 7362306a36Sopenharmony_ci */ 7462306a36Sopenharmony_ci#if IS_ENABLED(CONFIG_TRACE_MMIO_ACCESS) && !(defined(__DISABLE_TRACE_MMIO__)) 7562306a36Sopenharmony_ci#include <linux/tracepoint-defs.h> 7662306a36Sopenharmony_ci 7762306a36Sopenharmony_ciDECLARE_TRACEPOINT(rwmmio_write); 7862306a36Sopenharmony_ciDECLARE_TRACEPOINT(rwmmio_post_write); 7962306a36Sopenharmony_ciDECLARE_TRACEPOINT(rwmmio_read); 8062306a36Sopenharmony_ciDECLARE_TRACEPOINT(rwmmio_post_read); 8162306a36Sopenharmony_ci 8262306a36Sopenharmony_civoid log_write_mmio(u64 val, u8 width, volatile void __iomem *addr, 8362306a36Sopenharmony_ci unsigned long caller_addr, unsigned long caller_addr0); 8462306a36Sopenharmony_civoid log_post_write_mmio(u64 val, u8 width, volatile void __iomem *addr, 8562306a36Sopenharmony_ci unsigned long caller_addr, unsigned long caller_addr0); 8662306a36Sopenharmony_civoid log_read_mmio(u8 width, const volatile void __iomem *addr, 8762306a36Sopenharmony_ci unsigned long caller_addr, unsigned long caller_addr0); 8862306a36Sopenharmony_civoid log_post_read_mmio(u64 val, u8 width, const volatile void __iomem *addr, 8962306a36Sopenharmony_ci unsigned long caller_addr, unsigned long caller_addr0); 9062306a36Sopenharmony_ci 9162306a36Sopenharmony_ci#else 9262306a36Sopenharmony_ci 9362306a36Sopenharmony_cistatic inline void log_write_mmio(u64 val, u8 width, volatile void __iomem *addr, 9462306a36Sopenharmony_ci unsigned long caller_addr, unsigned long caller_addr0) {} 9562306a36Sopenharmony_cistatic inline void log_post_write_mmio(u64 val, u8 width, volatile void __iomem *addr, 9662306a36Sopenharmony_ci unsigned long caller_addr, unsigned long caller_addr0) {} 9762306a36Sopenharmony_cistatic inline void log_read_mmio(u8 width, const volatile void __iomem *addr, 9862306a36Sopenharmony_ci unsigned long caller_addr, unsigned long caller_addr0) {} 9962306a36Sopenharmony_cistatic inline void log_post_read_mmio(u64 val, u8 width, const volatile void __iomem *addr, 10062306a36Sopenharmony_ci unsigned long caller_addr, unsigned long caller_addr0) {} 10162306a36Sopenharmony_ci 10262306a36Sopenharmony_ci#endif /* CONFIG_TRACE_MMIO_ACCESS */ 10362306a36Sopenharmony_ci 10462306a36Sopenharmony_ci/* 10562306a36Sopenharmony_ci * __raw_{read,write}{b,w,l,q}() access memory in native endianness. 10662306a36Sopenharmony_ci * 10762306a36Sopenharmony_ci * On some architectures memory mapped IO needs to be accessed differently. 10862306a36Sopenharmony_ci * On the simple architectures, we just read/write the memory location 10962306a36Sopenharmony_ci * directly. 11062306a36Sopenharmony_ci */ 11162306a36Sopenharmony_ci 11262306a36Sopenharmony_ci#ifndef __raw_readb 11362306a36Sopenharmony_ci#define __raw_readb __raw_readb 11462306a36Sopenharmony_cistatic inline u8 __raw_readb(const volatile void __iomem *addr) 11562306a36Sopenharmony_ci{ 11662306a36Sopenharmony_ci return *(const volatile u8 __force *)addr; 11762306a36Sopenharmony_ci} 11862306a36Sopenharmony_ci#endif 11962306a36Sopenharmony_ci 12062306a36Sopenharmony_ci#ifndef __raw_readw 12162306a36Sopenharmony_ci#define __raw_readw __raw_readw 12262306a36Sopenharmony_cistatic inline u16 __raw_readw(const volatile void __iomem *addr) 12362306a36Sopenharmony_ci{ 12462306a36Sopenharmony_ci return *(const volatile u16 __force *)addr; 12562306a36Sopenharmony_ci} 12662306a36Sopenharmony_ci#endif 12762306a36Sopenharmony_ci 12862306a36Sopenharmony_ci#ifndef __raw_readl 12962306a36Sopenharmony_ci#define __raw_readl __raw_readl 13062306a36Sopenharmony_cistatic inline u32 __raw_readl(const volatile void __iomem *addr) 13162306a36Sopenharmony_ci{ 13262306a36Sopenharmony_ci return *(const volatile u32 __force *)addr; 13362306a36Sopenharmony_ci} 13462306a36Sopenharmony_ci#endif 13562306a36Sopenharmony_ci 13662306a36Sopenharmony_ci#ifdef CONFIG_64BIT 13762306a36Sopenharmony_ci#ifndef __raw_readq 13862306a36Sopenharmony_ci#define __raw_readq __raw_readq 13962306a36Sopenharmony_cistatic inline u64 __raw_readq(const volatile void __iomem *addr) 14062306a36Sopenharmony_ci{ 14162306a36Sopenharmony_ci return *(const volatile u64 __force *)addr; 14262306a36Sopenharmony_ci} 14362306a36Sopenharmony_ci#endif 14462306a36Sopenharmony_ci#endif /* CONFIG_64BIT */ 14562306a36Sopenharmony_ci 14662306a36Sopenharmony_ci#ifndef __raw_writeb 14762306a36Sopenharmony_ci#define __raw_writeb __raw_writeb 14862306a36Sopenharmony_cistatic inline void __raw_writeb(u8 value, volatile void __iomem *addr) 14962306a36Sopenharmony_ci{ 15062306a36Sopenharmony_ci *(volatile u8 __force *)addr = value; 15162306a36Sopenharmony_ci} 15262306a36Sopenharmony_ci#endif 15362306a36Sopenharmony_ci 15462306a36Sopenharmony_ci#ifndef __raw_writew 15562306a36Sopenharmony_ci#define __raw_writew __raw_writew 15662306a36Sopenharmony_cistatic inline void __raw_writew(u16 value, volatile void __iomem *addr) 15762306a36Sopenharmony_ci{ 15862306a36Sopenharmony_ci *(volatile u16 __force *)addr = value; 15962306a36Sopenharmony_ci} 16062306a36Sopenharmony_ci#endif 16162306a36Sopenharmony_ci 16262306a36Sopenharmony_ci#ifndef __raw_writel 16362306a36Sopenharmony_ci#define __raw_writel __raw_writel 16462306a36Sopenharmony_cistatic inline void __raw_writel(u32 value, volatile void __iomem *addr) 16562306a36Sopenharmony_ci{ 16662306a36Sopenharmony_ci *(volatile u32 __force *)addr = value; 16762306a36Sopenharmony_ci} 16862306a36Sopenharmony_ci#endif 16962306a36Sopenharmony_ci 17062306a36Sopenharmony_ci#ifdef CONFIG_64BIT 17162306a36Sopenharmony_ci#ifndef __raw_writeq 17262306a36Sopenharmony_ci#define __raw_writeq __raw_writeq 17362306a36Sopenharmony_cistatic inline void __raw_writeq(u64 value, volatile void __iomem *addr) 17462306a36Sopenharmony_ci{ 17562306a36Sopenharmony_ci *(volatile u64 __force *)addr = value; 17662306a36Sopenharmony_ci} 17762306a36Sopenharmony_ci#endif 17862306a36Sopenharmony_ci#endif /* CONFIG_64BIT */ 17962306a36Sopenharmony_ci 18062306a36Sopenharmony_ci/* 18162306a36Sopenharmony_ci * {read,write}{b,w,l,q}() access little endian memory and return result in 18262306a36Sopenharmony_ci * native endianness. 18362306a36Sopenharmony_ci */ 18462306a36Sopenharmony_ci 18562306a36Sopenharmony_ci#ifndef readb 18662306a36Sopenharmony_ci#define readb readb 18762306a36Sopenharmony_cistatic inline u8 readb(const volatile void __iomem *addr) 18862306a36Sopenharmony_ci{ 18962306a36Sopenharmony_ci u8 val; 19062306a36Sopenharmony_ci 19162306a36Sopenharmony_ci log_read_mmio(8, addr, _THIS_IP_, _RET_IP_); 19262306a36Sopenharmony_ci __io_br(); 19362306a36Sopenharmony_ci val = __raw_readb(addr); 19462306a36Sopenharmony_ci __io_ar(val); 19562306a36Sopenharmony_ci log_post_read_mmio(val, 8, addr, _THIS_IP_, _RET_IP_); 19662306a36Sopenharmony_ci return val; 19762306a36Sopenharmony_ci} 19862306a36Sopenharmony_ci#endif 19962306a36Sopenharmony_ci 20062306a36Sopenharmony_ci#ifndef readw 20162306a36Sopenharmony_ci#define readw readw 20262306a36Sopenharmony_cistatic inline u16 readw(const volatile void __iomem *addr) 20362306a36Sopenharmony_ci{ 20462306a36Sopenharmony_ci u16 val; 20562306a36Sopenharmony_ci 20662306a36Sopenharmony_ci log_read_mmio(16, addr, _THIS_IP_, _RET_IP_); 20762306a36Sopenharmony_ci __io_br(); 20862306a36Sopenharmony_ci val = __le16_to_cpu((__le16 __force)__raw_readw(addr)); 20962306a36Sopenharmony_ci __io_ar(val); 21062306a36Sopenharmony_ci log_post_read_mmio(val, 16, addr, _THIS_IP_, _RET_IP_); 21162306a36Sopenharmony_ci return val; 21262306a36Sopenharmony_ci} 21362306a36Sopenharmony_ci#endif 21462306a36Sopenharmony_ci 21562306a36Sopenharmony_ci#ifndef readl 21662306a36Sopenharmony_ci#define readl readl 21762306a36Sopenharmony_cistatic inline u32 readl(const volatile void __iomem *addr) 21862306a36Sopenharmony_ci{ 21962306a36Sopenharmony_ci u32 val; 22062306a36Sopenharmony_ci 22162306a36Sopenharmony_ci log_read_mmio(32, addr, _THIS_IP_, _RET_IP_); 22262306a36Sopenharmony_ci __io_br(); 22362306a36Sopenharmony_ci val = __le32_to_cpu((__le32 __force)__raw_readl(addr)); 22462306a36Sopenharmony_ci __io_ar(val); 22562306a36Sopenharmony_ci log_post_read_mmio(val, 32, addr, _THIS_IP_, _RET_IP_); 22662306a36Sopenharmony_ci return val; 22762306a36Sopenharmony_ci} 22862306a36Sopenharmony_ci#endif 22962306a36Sopenharmony_ci 23062306a36Sopenharmony_ci#ifdef CONFIG_64BIT 23162306a36Sopenharmony_ci#ifndef readq 23262306a36Sopenharmony_ci#define readq readq 23362306a36Sopenharmony_cistatic inline u64 readq(const volatile void __iomem *addr) 23462306a36Sopenharmony_ci{ 23562306a36Sopenharmony_ci u64 val; 23662306a36Sopenharmony_ci 23762306a36Sopenharmony_ci log_read_mmio(64, addr, _THIS_IP_, _RET_IP_); 23862306a36Sopenharmony_ci __io_br(); 23962306a36Sopenharmony_ci val = __le64_to_cpu((__le64 __force)__raw_readq(addr)); 24062306a36Sopenharmony_ci __io_ar(val); 24162306a36Sopenharmony_ci log_post_read_mmio(val, 64, addr, _THIS_IP_, _RET_IP_); 24262306a36Sopenharmony_ci return val; 24362306a36Sopenharmony_ci} 24462306a36Sopenharmony_ci#endif 24562306a36Sopenharmony_ci#endif /* CONFIG_64BIT */ 24662306a36Sopenharmony_ci 24762306a36Sopenharmony_ci#ifndef writeb 24862306a36Sopenharmony_ci#define writeb writeb 24962306a36Sopenharmony_cistatic inline void writeb(u8 value, volatile void __iomem *addr) 25062306a36Sopenharmony_ci{ 25162306a36Sopenharmony_ci log_write_mmio(value, 8, addr, _THIS_IP_, _RET_IP_); 25262306a36Sopenharmony_ci __io_bw(); 25362306a36Sopenharmony_ci __raw_writeb(value, addr); 25462306a36Sopenharmony_ci __io_aw(); 25562306a36Sopenharmony_ci log_post_write_mmio(value, 8, addr, _THIS_IP_, _RET_IP_); 25662306a36Sopenharmony_ci} 25762306a36Sopenharmony_ci#endif 25862306a36Sopenharmony_ci 25962306a36Sopenharmony_ci#ifndef writew 26062306a36Sopenharmony_ci#define writew writew 26162306a36Sopenharmony_cistatic inline void writew(u16 value, volatile void __iomem *addr) 26262306a36Sopenharmony_ci{ 26362306a36Sopenharmony_ci log_write_mmio(value, 16, addr, _THIS_IP_, _RET_IP_); 26462306a36Sopenharmony_ci __io_bw(); 26562306a36Sopenharmony_ci __raw_writew((u16 __force)cpu_to_le16(value), addr); 26662306a36Sopenharmony_ci __io_aw(); 26762306a36Sopenharmony_ci log_post_write_mmio(value, 16, addr, _THIS_IP_, _RET_IP_); 26862306a36Sopenharmony_ci} 26962306a36Sopenharmony_ci#endif 27062306a36Sopenharmony_ci 27162306a36Sopenharmony_ci#ifndef writel 27262306a36Sopenharmony_ci#define writel writel 27362306a36Sopenharmony_cistatic inline void writel(u32 value, volatile void __iomem *addr) 27462306a36Sopenharmony_ci{ 27562306a36Sopenharmony_ci log_write_mmio(value, 32, addr, _THIS_IP_, _RET_IP_); 27662306a36Sopenharmony_ci __io_bw(); 27762306a36Sopenharmony_ci __raw_writel((u32 __force)__cpu_to_le32(value), addr); 27862306a36Sopenharmony_ci __io_aw(); 27962306a36Sopenharmony_ci log_post_write_mmio(value, 32, addr, _THIS_IP_, _RET_IP_); 28062306a36Sopenharmony_ci} 28162306a36Sopenharmony_ci#endif 28262306a36Sopenharmony_ci 28362306a36Sopenharmony_ci#ifdef CONFIG_64BIT 28462306a36Sopenharmony_ci#ifndef writeq 28562306a36Sopenharmony_ci#define writeq writeq 28662306a36Sopenharmony_cistatic inline void writeq(u64 value, volatile void __iomem *addr) 28762306a36Sopenharmony_ci{ 28862306a36Sopenharmony_ci log_write_mmio(value, 64, addr, _THIS_IP_, _RET_IP_); 28962306a36Sopenharmony_ci __io_bw(); 29062306a36Sopenharmony_ci __raw_writeq((u64 __force)__cpu_to_le64(value), addr); 29162306a36Sopenharmony_ci __io_aw(); 29262306a36Sopenharmony_ci log_post_write_mmio(value, 64, addr, _THIS_IP_, _RET_IP_); 29362306a36Sopenharmony_ci} 29462306a36Sopenharmony_ci#endif 29562306a36Sopenharmony_ci#endif /* CONFIG_64BIT */ 29662306a36Sopenharmony_ci 29762306a36Sopenharmony_ci/* 29862306a36Sopenharmony_ci * {read,write}{b,w,l,q}_relaxed() are like the regular version, but 29962306a36Sopenharmony_ci * are not guaranteed to provide ordering against spinlocks or memory 30062306a36Sopenharmony_ci * accesses. 30162306a36Sopenharmony_ci */ 30262306a36Sopenharmony_ci#ifndef readb_relaxed 30362306a36Sopenharmony_ci#define readb_relaxed readb_relaxed 30462306a36Sopenharmony_cistatic inline u8 readb_relaxed(const volatile void __iomem *addr) 30562306a36Sopenharmony_ci{ 30662306a36Sopenharmony_ci u8 val; 30762306a36Sopenharmony_ci 30862306a36Sopenharmony_ci log_read_mmio(8, addr, _THIS_IP_, _RET_IP_); 30962306a36Sopenharmony_ci val = __raw_readb(addr); 31062306a36Sopenharmony_ci log_post_read_mmio(val, 8, addr, _THIS_IP_, _RET_IP_); 31162306a36Sopenharmony_ci return val; 31262306a36Sopenharmony_ci} 31362306a36Sopenharmony_ci#endif 31462306a36Sopenharmony_ci 31562306a36Sopenharmony_ci#ifndef readw_relaxed 31662306a36Sopenharmony_ci#define readw_relaxed readw_relaxed 31762306a36Sopenharmony_cistatic inline u16 readw_relaxed(const volatile void __iomem *addr) 31862306a36Sopenharmony_ci{ 31962306a36Sopenharmony_ci u16 val; 32062306a36Sopenharmony_ci 32162306a36Sopenharmony_ci log_read_mmio(16, addr, _THIS_IP_, _RET_IP_); 32262306a36Sopenharmony_ci val = __le16_to_cpu((__le16 __force)__raw_readw(addr)); 32362306a36Sopenharmony_ci log_post_read_mmio(val, 16, addr, _THIS_IP_, _RET_IP_); 32462306a36Sopenharmony_ci return val; 32562306a36Sopenharmony_ci} 32662306a36Sopenharmony_ci#endif 32762306a36Sopenharmony_ci 32862306a36Sopenharmony_ci#ifndef readl_relaxed 32962306a36Sopenharmony_ci#define readl_relaxed readl_relaxed 33062306a36Sopenharmony_cistatic inline u32 readl_relaxed(const volatile void __iomem *addr) 33162306a36Sopenharmony_ci{ 33262306a36Sopenharmony_ci u32 val; 33362306a36Sopenharmony_ci 33462306a36Sopenharmony_ci log_read_mmio(32, addr, _THIS_IP_, _RET_IP_); 33562306a36Sopenharmony_ci val = __le32_to_cpu((__le32 __force)__raw_readl(addr)); 33662306a36Sopenharmony_ci log_post_read_mmio(val, 32, addr, _THIS_IP_, _RET_IP_); 33762306a36Sopenharmony_ci return val; 33862306a36Sopenharmony_ci} 33962306a36Sopenharmony_ci#endif 34062306a36Sopenharmony_ci 34162306a36Sopenharmony_ci#if defined(readq) && !defined(readq_relaxed) 34262306a36Sopenharmony_ci#define readq_relaxed readq_relaxed 34362306a36Sopenharmony_cistatic inline u64 readq_relaxed(const volatile void __iomem *addr) 34462306a36Sopenharmony_ci{ 34562306a36Sopenharmony_ci u64 val; 34662306a36Sopenharmony_ci 34762306a36Sopenharmony_ci log_read_mmio(64, addr, _THIS_IP_, _RET_IP_); 34862306a36Sopenharmony_ci val = __le64_to_cpu((__le64 __force)__raw_readq(addr)); 34962306a36Sopenharmony_ci log_post_read_mmio(val, 64, addr, _THIS_IP_, _RET_IP_); 35062306a36Sopenharmony_ci return val; 35162306a36Sopenharmony_ci} 35262306a36Sopenharmony_ci#endif 35362306a36Sopenharmony_ci 35462306a36Sopenharmony_ci#ifndef writeb_relaxed 35562306a36Sopenharmony_ci#define writeb_relaxed writeb_relaxed 35662306a36Sopenharmony_cistatic inline void writeb_relaxed(u8 value, volatile void __iomem *addr) 35762306a36Sopenharmony_ci{ 35862306a36Sopenharmony_ci log_write_mmio(value, 8, addr, _THIS_IP_, _RET_IP_); 35962306a36Sopenharmony_ci __raw_writeb(value, addr); 36062306a36Sopenharmony_ci log_post_write_mmio(value, 8, addr, _THIS_IP_, _RET_IP_); 36162306a36Sopenharmony_ci} 36262306a36Sopenharmony_ci#endif 36362306a36Sopenharmony_ci 36462306a36Sopenharmony_ci#ifndef writew_relaxed 36562306a36Sopenharmony_ci#define writew_relaxed writew_relaxed 36662306a36Sopenharmony_cistatic inline void writew_relaxed(u16 value, volatile void __iomem *addr) 36762306a36Sopenharmony_ci{ 36862306a36Sopenharmony_ci log_write_mmio(value, 16, addr, _THIS_IP_, _RET_IP_); 36962306a36Sopenharmony_ci __raw_writew((u16 __force)cpu_to_le16(value), addr); 37062306a36Sopenharmony_ci log_post_write_mmio(value, 16, addr, _THIS_IP_, _RET_IP_); 37162306a36Sopenharmony_ci} 37262306a36Sopenharmony_ci#endif 37362306a36Sopenharmony_ci 37462306a36Sopenharmony_ci#ifndef writel_relaxed 37562306a36Sopenharmony_ci#define writel_relaxed writel_relaxed 37662306a36Sopenharmony_cistatic inline void writel_relaxed(u32 value, volatile void __iomem *addr) 37762306a36Sopenharmony_ci{ 37862306a36Sopenharmony_ci log_write_mmio(value, 32, addr, _THIS_IP_, _RET_IP_); 37962306a36Sopenharmony_ci __raw_writel((u32 __force)__cpu_to_le32(value), addr); 38062306a36Sopenharmony_ci log_post_write_mmio(value, 32, addr, _THIS_IP_, _RET_IP_); 38162306a36Sopenharmony_ci} 38262306a36Sopenharmony_ci#endif 38362306a36Sopenharmony_ci 38462306a36Sopenharmony_ci#if defined(writeq) && !defined(writeq_relaxed) 38562306a36Sopenharmony_ci#define writeq_relaxed writeq_relaxed 38662306a36Sopenharmony_cistatic inline void writeq_relaxed(u64 value, volatile void __iomem *addr) 38762306a36Sopenharmony_ci{ 38862306a36Sopenharmony_ci log_write_mmio(value, 64, addr, _THIS_IP_, _RET_IP_); 38962306a36Sopenharmony_ci __raw_writeq((u64 __force)__cpu_to_le64(value), addr); 39062306a36Sopenharmony_ci log_post_write_mmio(value, 64, addr, _THIS_IP_, _RET_IP_); 39162306a36Sopenharmony_ci} 39262306a36Sopenharmony_ci#endif 39362306a36Sopenharmony_ci 39462306a36Sopenharmony_ci/* 39562306a36Sopenharmony_ci * {read,write}s{b,w,l,q}() repeatedly access the same memory address in 39662306a36Sopenharmony_ci * native endianness in 8-, 16-, 32- or 64-bit chunks (@count times). 39762306a36Sopenharmony_ci */ 39862306a36Sopenharmony_ci#ifndef readsb 39962306a36Sopenharmony_ci#define readsb readsb 40062306a36Sopenharmony_cistatic inline void readsb(const volatile void __iomem *addr, void *buffer, 40162306a36Sopenharmony_ci unsigned int count) 40262306a36Sopenharmony_ci{ 40362306a36Sopenharmony_ci if (count) { 40462306a36Sopenharmony_ci u8 *buf = buffer; 40562306a36Sopenharmony_ci 40662306a36Sopenharmony_ci do { 40762306a36Sopenharmony_ci u8 x = __raw_readb(addr); 40862306a36Sopenharmony_ci *buf++ = x; 40962306a36Sopenharmony_ci } while (--count); 41062306a36Sopenharmony_ci } 41162306a36Sopenharmony_ci} 41262306a36Sopenharmony_ci#endif 41362306a36Sopenharmony_ci 41462306a36Sopenharmony_ci#ifndef readsw 41562306a36Sopenharmony_ci#define readsw readsw 41662306a36Sopenharmony_cistatic inline void readsw(const volatile void __iomem *addr, void *buffer, 41762306a36Sopenharmony_ci unsigned int count) 41862306a36Sopenharmony_ci{ 41962306a36Sopenharmony_ci if (count) { 42062306a36Sopenharmony_ci u16 *buf = buffer; 42162306a36Sopenharmony_ci 42262306a36Sopenharmony_ci do { 42362306a36Sopenharmony_ci u16 x = __raw_readw(addr); 42462306a36Sopenharmony_ci *buf++ = x; 42562306a36Sopenharmony_ci } while (--count); 42662306a36Sopenharmony_ci } 42762306a36Sopenharmony_ci} 42862306a36Sopenharmony_ci#endif 42962306a36Sopenharmony_ci 43062306a36Sopenharmony_ci#ifndef readsl 43162306a36Sopenharmony_ci#define readsl readsl 43262306a36Sopenharmony_cistatic inline void readsl(const volatile void __iomem *addr, void *buffer, 43362306a36Sopenharmony_ci unsigned int count) 43462306a36Sopenharmony_ci{ 43562306a36Sopenharmony_ci if (count) { 43662306a36Sopenharmony_ci u32 *buf = buffer; 43762306a36Sopenharmony_ci 43862306a36Sopenharmony_ci do { 43962306a36Sopenharmony_ci u32 x = __raw_readl(addr); 44062306a36Sopenharmony_ci *buf++ = x; 44162306a36Sopenharmony_ci } while (--count); 44262306a36Sopenharmony_ci } 44362306a36Sopenharmony_ci} 44462306a36Sopenharmony_ci#endif 44562306a36Sopenharmony_ci 44662306a36Sopenharmony_ci#ifdef CONFIG_64BIT 44762306a36Sopenharmony_ci#ifndef readsq 44862306a36Sopenharmony_ci#define readsq readsq 44962306a36Sopenharmony_cistatic inline void readsq(const volatile void __iomem *addr, void *buffer, 45062306a36Sopenharmony_ci unsigned int count) 45162306a36Sopenharmony_ci{ 45262306a36Sopenharmony_ci if (count) { 45362306a36Sopenharmony_ci u64 *buf = buffer; 45462306a36Sopenharmony_ci 45562306a36Sopenharmony_ci do { 45662306a36Sopenharmony_ci u64 x = __raw_readq(addr); 45762306a36Sopenharmony_ci *buf++ = x; 45862306a36Sopenharmony_ci } while (--count); 45962306a36Sopenharmony_ci } 46062306a36Sopenharmony_ci} 46162306a36Sopenharmony_ci#endif 46262306a36Sopenharmony_ci#endif /* CONFIG_64BIT */ 46362306a36Sopenharmony_ci 46462306a36Sopenharmony_ci#ifndef writesb 46562306a36Sopenharmony_ci#define writesb writesb 46662306a36Sopenharmony_cistatic inline void writesb(volatile void __iomem *addr, const void *buffer, 46762306a36Sopenharmony_ci unsigned int count) 46862306a36Sopenharmony_ci{ 46962306a36Sopenharmony_ci if (count) { 47062306a36Sopenharmony_ci const u8 *buf = buffer; 47162306a36Sopenharmony_ci 47262306a36Sopenharmony_ci do { 47362306a36Sopenharmony_ci __raw_writeb(*buf++, addr); 47462306a36Sopenharmony_ci } while (--count); 47562306a36Sopenharmony_ci } 47662306a36Sopenharmony_ci} 47762306a36Sopenharmony_ci#endif 47862306a36Sopenharmony_ci 47962306a36Sopenharmony_ci#ifndef writesw 48062306a36Sopenharmony_ci#define writesw writesw 48162306a36Sopenharmony_cistatic inline void writesw(volatile void __iomem *addr, const void *buffer, 48262306a36Sopenharmony_ci unsigned int count) 48362306a36Sopenharmony_ci{ 48462306a36Sopenharmony_ci if (count) { 48562306a36Sopenharmony_ci const u16 *buf = buffer; 48662306a36Sopenharmony_ci 48762306a36Sopenharmony_ci do { 48862306a36Sopenharmony_ci __raw_writew(*buf++, addr); 48962306a36Sopenharmony_ci } while (--count); 49062306a36Sopenharmony_ci } 49162306a36Sopenharmony_ci} 49262306a36Sopenharmony_ci#endif 49362306a36Sopenharmony_ci 49462306a36Sopenharmony_ci#ifndef writesl 49562306a36Sopenharmony_ci#define writesl writesl 49662306a36Sopenharmony_cistatic inline void writesl(volatile void __iomem *addr, const void *buffer, 49762306a36Sopenharmony_ci unsigned int count) 49862306a36Sopenharmony_ci{ 49962306a36Sopenharmony_ci if (count) { 50062306a36Sopenharmony_ci const u32 *buf = buffer; 50162306a36Sopenharmony_ci 50262306a36Sopenharmony_ci do { 50362306a36Sopenharmony_ci __raw_writel(*buf++, addr); 50462306a36Sopenharmony_ci } while (--count); 50562306a36Sopenharmony_ci } 50662306a36Sopenharmony_ci} 50762306a36Sopenharmony_ci#endif 50862306a36Sopenharmony_ci 50962306a36Sopenharmony_ci#ifdef CONFIG_64BIT 51062306a36Sopenharmony_ci#ifndef writesq 51162306a36Sopenharmony_ci#define writesq writesq 51262306a36Sopenharmony_cistatic inline void writesq(volatile void __iomem *addr, const void *buffer, 51362306a36Sopenharmony_ci unsigned int count) 51462306a36Sopenharmony_ci{ 51562306a36Sopenharmony_ci if (count) { 51662306a36Sopenharmony_ci const u64 *buf = buffer; 51762306a36Sopenharmony_ci 51862306a36Sopenharmony_ci do { 51962306a36Sopenharmony_ci __raw_writeq(*buf++, addr); 52062306a36Sopenharmony_ci } while (--count); 52162306a36Sopenharmony_ci } 52262306a36Sopenharmony_ci} 52362306a36Sopenharmony_ci#endif 52462306a36Sopenharmony_ci#endif /* CONFIG_64BIT */ 52562306a36Sopenharmony_ci 52662306a36Sopenharmony_ci#ifndef PCI_IOBASE 52762306a36Sopenharmony_ci#define PCI_IOBASE ((void __iomem *)0) 52862306a36Sopenharmony_ci#endif 52962306a36Sopenharmony_ci 53062306a36Sopenharmony_ci#ifndef IO_SPACE_LIMIT 53162306a36Sopenharmony_ci#define IO_SPACE_LIMIT 0xffff 53262306a36Sopenharmony_ci#endif 53362306a36Sopenharmony_ci 53462306a36Sopenharmony_ci/* 53562306a36Sopenharmony_ci * {in,out}{b,w,l}() access little endian I/O. {in,out}{b,w,l}_p() can be 53662306a36Sopenharmony_ci * implemented on hardware that needs an additional delay for I/O accesses to 53762306a36Sopenharmony_ci * take effect. 53862306a36Sopenharmony_ci */ 53962306a36Sopenharmony_ci 54062306a36Sopenharmony_ci#if !defined(inb) && !defined(_inb) 54162306a36Sopenharmony_ci#define _inb _inb 54262306a36Sopenharmony_cistatic inline u8 _inb(unsigned long addr) 54362306a36Sopenharmony_ci{ 54462306a36Sopenharmony_ci u8 val; 54562306a36Sopenharmony_ci 54662306a36Sopenharmony_ci __io_pbr(); 54762306a36Sopenharmony_ci val = __raw_readb(PCI_IOBASE + addr); 54862306a36Sopenharmony_ci __io_par(val); 54962306a36Sopenharmony_ci return val; 55062306a36Sopenharmony_ci} 55162306a36Sopenharmony_ci#endif 55262306a36Sopenharmony_ci 55362306a36Sopenharmony_ci#if !defined(inw) && !defined(_inw) 55462306a36Sopenharmony_ci#define _inw _inw 55562306a36Sopenharmony_cistatic inline u16 _inw(unsigned long addr) 55662306a36Sopenharmony_ci{ 55762306a36Sopenharmony_ci u16 val; 55862306a36Sopenharmony_ci 55962306a36Sopenharmony_ci __io_pbr(); 56062306a36Sopenharmony_ci val = __le16_to_cpu((__le16 __force)__raw_readw(PCI_IOBASE + addr)); 56162306a36Sopenharmony_ci __io_par(val); 56262306a36Sopenharmony_ci return val; 56362306a36Sopenharmony_ci} 56462306a36Sopenharmony_ci#endif 56562306a36Sopenharmony_ci 56662306a36Sopenharmony_ci#if !defined(inl) && !defined(_inl) 56762306a36Sopenharmony_ci#define _inl _inl 56862306a36Sopenharmony_cistatic inline u32 _inl(unsigned long addr) 56962306a36Sopenharmony_ci{ 57062306a36Sopenharmony_ci u32 val; 57162306a36Sopenharmony_ci 57262306a36Sopenharmony_ci __io_pbr(); 57362306a36Sopenharmony_ci val = __le32_to_cpu((__le32 __force)__raw_readl(PCI_IOBASE + addr)); 57462306a36Sopenharmony_ci __io_par(val); 57562306a36Sopenharmony_ci return val; 57662306a36Sopenharmony_ci} 57762306a36Sopenharmony_ci#endif 57862306a36Sopenharmony_ci 57962306a36Sopenharmony_ci#if !defined(outb) && !defined(_outb) 58062306a36Sopenharmony_ci#define _outb _outb 58162306a36Sopenharmony_cistatic inline void _outb(u8 value, unsigned long addr) 58262306a36Sopenharmony_ci{ 58362306a36Sopenharmony_ci __io_pbw(); 58462306a36Sopenharmony_ci __raw_writeb(value, PCI_IOBASE + addr); 58562306a36Sopenharmony_ci __io_paw(); 58662306a36Sopenharmony_ci} 58762306a36Sopenharmony_ci#endif 58862306a36Sopenharmony_ci 58962306a36Sopenharmony_ci#if !defined(outw) && !defined(_outw) 59062306a36Sopenharmony_ci#define _outw _outw 59162306a36Sopenharmony_cistatic inline void _outw(u16 value, unsigned long addr) 59262306a36Sopenharmony_ci{ 59362306a36Sopenharmony_ci __io_pbw(); 59462306a36Sopenharmony_ci __raw_writew((u16 __force)cpu_to_le16(value), PCI_IOBASE + addr); 59562306a36Sopenharmony_ci __io_paw(); 59662306a36Sopenharmony_ci} 59762306a36Sopenharmony_ci#endif 59862306a36Sopenharmony_ci 59962306a36Sopenharmony_ci#if !defined(outl) && !defined(_outl) 60062306a36Sopenharmony_ci#define _outl _outl 60162306a36Sopenharmony_cistatic inline void _outl(u32 value, unsigned long addr) 60262306a36Sopenharmony_ci{ 60362306a36Sopenharmony_ci __io_pbw(); 60462306a36Sopenharmony_ci __raw_writel((u32 __force)cpu_to_le32(value), PCI_IOBASE + addr); 60562306a36Sopenharmony_ci __io_paw(); 60662306a36Sopenharmony_ci} 60762306a36Sopenharmony_ci#endif 60862306a36Sopenharmony_ci 60962306a36Sopenharmony_ci#include <linux/logic_pio.h> 61062306a36Sopenharmony_ci 61162306a36Sopenharmony_ci#ifndef inb 61262306a36Sopenharmony_ci#define inb _inb 61362306a36Sopenharmony_ci#endif 61462306a36Sopenharmony_ci 61562306a36Sopenharmony_ci#ifndef inw 61662306a36Sopenharmony_ci#define inw _inw 61762306a36Sopenharmony_ci#endif 61862306a36Sopenharmony_ci 61962306a36Sopenharmony_ci#ifndef inl 62062306a36Sopenharmony_ci#define inl _inl 62162306a36Sopenharmony_ci#endif 62262306a36Sopenharmony_ci 62362306a36Sopenharmony_ci#ifndef outb 62462306a36Sopenharmony_ci#define outb _outb 62562306a36Sopenharmony_ci#endif 62662306a36Sopenharmony_ci 62762306a36Sopenharmony_ci#ifndef outw 62862306a36Sopenharmony_ci#define outw _outw 62962306a36Sopenharmony_ci#endif 63062306a36Sopenharmony_ci 63162306a36Sopenharmony_ci#ifndef outl 63262306a36Sopenharmony_ci#define outl _outl 63362306a36Sopenharmony_ci#endif 63462306a36Sopenharmony_ci 63562306a36Sopenharmony_ci#ifndef inb_p 63662306a36Sopenharmony_ci#define inb_p inb_p 63762306a36Sopenharmony_cistatic inline u8 inb_p(unsigned long addr) 63862306a36Sopenharmony_ci{ 63962306a36Sopenharmony_ci return inb(addr); 64062306a36Sopenharmony_ci} 64162306a36Sopenharmony_ci#endif 64262306a36Sopenharmony_ci 64362306a36Sopenharmony_ci#ifndef inw_p 64462306a36Sopenharmony_ci#define inw_p inw_p 64562306a36Sopenharmony_cistatic inline u16 inw_p(unsigned long addr) 64662306a36Sopenharmony_ci{ 64762306a36Sopenharmony_ci return inw(addr); 64862306a36Sopenharmony_ci} 64962306a36Sopenharmony_ci#endif 65062306a36Sopenharmony_ci 65162306a36Sopenharmony_ci#ifndef inl_p 65262306a36Sopenharmony_ci#define inl_p inl_p 65362306a36Sopenharmony_cistatic inline u32 inl_p(unsigned long addr) 65462306a36Sopenharmony_ci{ 65562306a36Sopenharmony_ci return inl(addr); 65662306a36Sopenharmony_ci} 65762306a36Sopenharmony_ci#endif 65862306a36Sopenharmony_ci 65962306a36Sopenharmony_ci#ifndef outb_p 66062306a36Sopenharmony_ci#define outb_p outb_p 66162306a36Sopenharmony_cistatic inline void outb_p(u8 value, unsigned long addr) 66262306a36Sopenharmony_ci{ 66362306a36Sopenharmony_ci outb(value, addr); 66462306a36Sopenharmony_ci} 66562306a36Sopenharmony_ci#endif 66662306a36Sopenharmony_ci 66762306a36Sopenharmony_ci#ifndef outw_p 66862306a36Sopenharmony_ci#define outw_p outw_p 66962306a36Sopenharmony_cistatic inline void outw_p(u16 value, unsigned long addr) 67062306a36Sopenharmony_ci{ 67162306a36Sopenharmony_ci outw(value, addr); 67262306a36Sopenharmony_ci} 67362306a36Sopenharmony_ci#endif 67462306a36Sopenharmony_ci 67562306a36Sopenharmony_ci#ifndef outl_p 67662306a36Sopenharmony_ci#define outl_p outl_p 67762306a36Sopenharmony_cistatic inline void outl_p(u32 value, unsigned long addr) 67862306a36Sopenharmony_ci{ 67962306a36Sopenharmony_ci outl(value, addr); 68062306a36Sopenharmony_ci} 68162306a36Sopenharmony_ci#endif 68262306a36Sopenharmony_ci 68362306a36Sopenharmony_ci/* 68462306a36Sopenharmony_ci * {in,out}s{b,w,l}{,_p}() are variants of the above that repeatedly access a 68562306a36Sopenharmony_ci * single I/O port multiple times. 68662306a36Sopenharmony_ci */ 68762306a36Sopenharmony_ci 68862306a36Sopenharmony_ci#ifndef insb 68962306a36Sopenharmony_ci#define insb insb 69062306a36Sopenharmony_cistatic inline void insb(unsigned long addr, void *buffer, unsigned int count) 69162306a36Sopenharmony_ci{ 69262306a36Sopenharmony_ci readsb(PCI_IOBASE + addr, buffer, count); 69362306a36Sopenharmony_ci} 69462306a36Sopenharmony_ci#endif 69562306a36Sopenharmony_ci 69662306a36Sopenharmony_ci#ifndef insw 69762306a36Sopenharmony_ci#define insw insw 69862306a36Sopenharmony_cistatic inline void insw(unsigned long addr, void *buffer, unsigned int count) 69962306a36Sopenharmony_ci{ 70062306a36Sopenharmony_ci readsw(PCI_IOBASE + addr, buffer, count); 70162306a36Sopenharmony_ci} 70262306a36Sopenharmony_ci#endif 70362306a36Sopenharmony_ci 70462306a36Sopenharmony_ci#ifndef insl 70562306a36Sopenharmony_ci#define insl insl 70662306a36Sopenharmony_cistatic inline void insl(unsigned long addr, void *buffer, unsigned int count) 70762306a36Sopenharmony_ci{ 70862306a36Sopenharmony_ci readsl(PCI_IOBASE + addr, buffer, count); 70962306a36Sopenharmony_ci} 71062306a36Sopenharmony_ci#endif 71162306a36Sopenharmony_ci 71262306a36Sopenharmony_ci#ifndef outsb 71362306a36Sopenharmony_ci#define outsb outsb 71462306a36Sopenharmony_cistatic inline void outsb(unsigned long addr, const void *buffer, 71562306a36Sopenharmony_ci unsigned int count) 71662306a36Sopenharmony_ci{ 71762306a36Sopenharmony_ci writesb(PCI_IOBASE + addr, buffer, count); 71862306a36Sopenharmony_ci} 71962306a36Sopenharmony_ci#endif 72062306a36Sopenharmony_ci 72162306a36Sopenharmony_ci#ifndef outsw 72262306a36Sopenharmony_ci#define outsw outsw 72362306a36Sopenharmony_cistatic inline void outsw(unsigned long addr, const void *buffer, 72462306a36Sopenharmony_ci unsigned int count) 72562306a36Sopenharmony_ci{ 72662306a36Sopenharmony_ci writesw(PCI_IOBASE + addr, buffer, count); 72762306a36Sopenharmony_ci} 72862306a36Sopenharmony_ci#endif 72962306a36Sopenharmony_ci 73062306a36Sopenharmony_ci#ifndef outsl 73162306a36Sopenharmony_ci#define outsl outsl 73262306a36Sopenharmony_cistatic inline void outsl(unsigned long addr, const void *buffer, 73362306a36Sopenharmony_ci unsigned int count) 73462306a36Sopenharmony_ci{ 73562306a36Sopenharmony_ci writesl(PCI_IOBASE + addr, buffer, count); 73662306a36Sopenharmony_ci} 73762306a36Sopenharmony_ci#endif 73862306a36Sopenharmony_ci 73962306a36Sopenharmony_ci#ifndef insb_p 74062306a36Sopenharmony_ci#define insb_p insb_p 74162306a36Sopenharmony_cistatic inline void insb_p(unsigned long addr, void *buffer, unsigned int count) 74262306a36Sopenharmony_ci{ 74362306a36Sopenharmony_ci insb(addr, buffer, count); 74462306a36Sopenharmony_ci} 74562306a36Sopenharmony_ci#endif 74662306a36Sopenharmony_ci 74762306a36Sopenharmony_ci#ifndef insw_p 74862306a36Sopenharmony_ci#define insw_p insw_p 74962306a36Sopenharmony_cistatic inline void insw_p(unsigned long addr, void *buffer, unsigned int count) 75062306a36Sopenharmony_ci{ 75162306a36Sopenharmony_ci insw(addr, buffer, count); 75262306a36Sopenharmony_ci} 75362306a36Sopenharmony_ci#endif 75462306a36Sopenharmony_ci 75562306a36Sopenharmony_ci#ifndef insl_p 75662306a36Sopenharmony_ci#define insl_p insl_p 75762306a36Sopenharmony_cistatic inline void insl_p(unsigned long addr, void *buffer, unsigned int count) 75862306a36Sopenharmony_ci{ 75962306a36Sopenharmony_ci insl(addr, buffer, count); 76062306a36Sopenharmony_ci} 76162306a36Sopenharmony_ci#endif 76262306a36Sopenharmony_ci 76362306a36Sopenharmony_ci#ifndef outsb_p 76462306a36Sopenharmony_ci#define outsb_p outsb_p 76562306a36Sopenharmony_cistatic inline void outsb_p(unsigned long addr, const void *buffer, 76662306a36Sopenharmony_ci unsigned int count) 76762306a36Sopenharmony_ci{ 76862306a36Sopenharmony_ci outsb(addr, buffer, count); 76962306a36Sopenharmony_ci} 77062306a36Sopenharmony_ci#endif 77162306a36Sopenharmony_ci 77262306a36Sopenharmony_ci#ifndef outsw_p 77362306a36Sopenharmony_ci#define outsw_p outsw_p 77462306a36Sopenharmony_cistatic inline void outsw_p(unsigned long addr, const void *buffer, 77562306a36Sopenharmony_ci unsigned int count) 77662306a36Sopenharmony_ci{ 77762306a36Sopenharmony_ci outsw(addr, buffer, count); 77862306a36Sopenharmony_ci} 77962306a36Sopenharmony_ci#endif 78062306a36Sopenharmony_ci 78162306a36Sopenharmony_ci#ifndef outsl_p 78262306a36Sopenharmony_ci#define outsl_p outsl_p 78362306a36Sopenharmony_cistatic inline void outsl_p(unsigned long addr, const void *buffer, 78462306a36Sopenharmony_ci unsigned int count) 78562306a36Sopenharmony_ci{ 78662306a36Sopenharmony_ci outsl(addr, buffer, count); 78762306a36Sopenharmony_ci} 78862306a36Sopenharmony_ci#endif 78962306a36Sopenharmony_ci 79062306a36Sopenharmony_ci#ifndef CONFIG_GENERIC_IOMAP 79162306a36Sopenharmony_ci#ifndef ioread8 79262306a36Sopenharmony_ci#define ioread8 ioread8 79362306a36Sopenharmony_cistatic inline u8 ioread8(const volatile void __iomem *addr) 79462306a36Sopenharmony_ci{ 79562306a36Sopenharmony_ci return readb(addr); 79662306a36Sopenharmony_ci} 79762306a36Sopenharmony_ci#endif 79862306a36Sopenharmony_ci 79962306a36Sopenharmony_ci#ifndef ioread16 80062306a36Sopenharmony_ci#define ioread16 ioread16 80162306a36Sopenharmony_cistatic inline u16 ioread16(const volatile void __iomem *addr) 80262306a36Sopenharmony_ci{ 80362306a36Sopenharmony_ci return readw(addr); 80462306a36Sopenharmony_ci} 80562306a36Sopenharmony_ci#endif 80662306a36Sopenharmony_ci 80762306a36Sopenharmony_ci#ifndef ioread32 80862306a36Sopenharmony_ci#define ioread32 ioread32 80962306a36Sopenharmony_cistatic inline u32 ioread32(const volatile void __iomem *addr) 81062306a36Sopenharmony_ci{ 81162306a36Sopenharmony_ci return readl(addr); 81262306a36Sopenharmony_ci} 81362306a36Sopenharmony_ci#endif 81462306a36Sopenharmony_ci 81562306a36Sopenharmony_ci#ifdef CONFIG_64BIT 81662306a36Sopenharmony_ci#ifndef ioread64 81762306a36Sopenharmony_ci#define ioread64 ioread64 81862306a36Sopenharmony_cistatic inline u64 ioread64(const volatile void __iomem *addr) 81962306a36Sopenharmony_ci{ 82062306a36Sopenharmony_ci return readq(addr); 82162306a36Sopenharmony_ci} 82262306a36Sopenharmony_ci#endif 82362306a36Sopenharmony_ci#endif /* CONFIG_64BIT */ 82462306a36Sopenharmony_ci 82562306a36Sopenharmony_ci#ifndef iowrite8 82662306a36Sopenharmony_ci#define iowrite8 iowrite8 82762306a36Sopenharmony_cistatic inline void iowrite8(u8 value, volatile void __iomem *addr) 82862306a36Sopenharmony_ci{ 82962306a36Sopenharmony_ci writeb(value, addr); 83062306a36Sopenharmony_ci} 83162306a36Sopenharmony_ci#endif 83262306a36Sopenharmony_ci 83362306a36Sopenharmony_ci#ifndef iowrite16 83462306a36Sopenharmony_ci#define iowrite16 iowrite16 83562306a36Sopenharmony_cistatic inline void iowrite16(u16 value, volatile void __iomem *addr) 83662306a36Sopenharmony_ci{ 83762306a36Sopenharmony_ci writew(value, addr); 83862306a36Sopenharmony_ci} 83962306a36Sopenharmony_ci#endif 84062306a36Sopenharmony_ci 84162306a36Sopenharmony_ci#ifndef iowrite32 84262306a36Sopenharmony_ci#define iowrite32 iowrite32 84362306a36Sopenharmony_cistatic inline void iowrite32(u32 value, volatile void __iomem *addr) 84462306a36Sopenharmony_ci{ 84562306a36Sopenharmony_ci writel(value, addr); 84662306a36Sopenharmony_ci} 84762306a36Sopenharmony_ci#endif 84862306a36Sopenharmony_ci 84962306a36Sopenharmony_ci#ifdef CONFIG_64BIT 85062306a36Sopenharmony_ci#ifndef iowrite64 85162306a36Sopenharmony_ci#define iowrite64 iowrite64 85262306a36Sopenharmony_cistatic inline void iowrite64(u64 value, volatile void __iomem *addr) 85362306a36Sopenharmony_ci{ 85462306a36Sopenharmony_ci writeq(value, addr); 85562306a36Sopenharmony_ci} 85662306a36Sopenharmony_ci#endif 85762306a36Sopenharmony_ci#endif /* CONFIG_64BIT */ 85862306a36Sopenharmony_ci 85962306a36Sopenharmony_ci#ifndef ioread16be 86062306a36Sopenharmony_ci#define ioread16be ioread16be 86162306a36Sopenharmony_cistatic inline u16 ioread16be(const volatile void __iomem *addr) 86262306a36Sopenharmony_ci{ 86362306a36Sopenharmony_ci return swab16(readw(addr)); 86462306a36Sopenharmony_ci} 86562306a36Sopenharmony_ci#endif 86662306a36Sopenharmony_ci 86762306a36Sopenharmony_ci#ifndef ioread32be 86862306a36Sopenharmony_ci#define ioread32be ioread32be 86962306a36Sopenharmony_cistatic inline u32 ioread32be(const volatile void __iomem *addr) 87062306a36Sopenharmony_ci{ 87162306a36Sopenharmony_ci return swab32(readl(addr)); 87262306a36Sopenharmony_ci} 87362306a36Sopenharmony_ci#endif 87462306a36Sopenharmony_ci 87562306a36Sopenharmony_ci#ifdef CONFIG_64BIT 87662306a36Sopenharmony_ci#ifndef ioread64be 87762306a36Sopenharmony_ci#define ioread64be ioread64be 87862306a36Sopenharmony_cistatic inline u64 ioread64be(const volatile void __iomem *addr) 87962306a36Sopenharmony_ci{ 88062306a36Sopenharmony_ci return swab64(readq(addr)); 88162306a36Sopenharmony_ci} 88262306a36Sopenharmony_ci#endif 88362306a36Sopenharmony_ci#endif /* CONFIG_64BIT */ 88462306a36Sopenharmony_ci 88562306a36Sopenharmony_ci#ifndef iowrite16be 88662306a36Sopenharmony_ci#define iowrite16be iowrite16be 88762306a36Sopenharmony_cistatic inline void iowrite16be(u16 value, void volatile __iomem *addr) 88862306a36Sopenharmony_ci{ 88962306a36Sopenharmony_ci writew(swab16(value), addr); 89062306a36Sopenharmony_ci} 89162306a36Sopenharmony_ci#endif 89262306a36Sopenharmony_ci 89362306a36Sopenharmony_ci#ifndef iowrite32be 89462306a36Sopenharmony_ci#define iowrite32be iowrite32be 89562306a36Sopenharmony_cistatic inline void iowrite32be(u32 value, volatile void __iomem *addr) 89662306a36Sopenharmony_ci{ 89762306a36Sopenharmony_ci writel(swab32(value), addr); 89862306a36Sopenharmony_ci} 89962306a36Sopenharmony_ci#endif 90062306a36Sopenharmony_ci 90162306a36Sopenharmony_ci#ifdef CONFIG_64BIT 90262306a36Sopenharmony_ci#ifndef iowrite64be 90362306a36Sopenharmony_ci#define iowrite64be iowrite64be 90462306a36Sopenharmony_cistatic inline void iowrite64be(u64 value, volatile void __iomem *addr) 90562306a36Sopenharmony_ci{ 90662306a36Sopenharmony_ci writeq(swab64(value), addr); 90762306a36Sopenharmony_ci} 90862306a36Sopenharmony_ci#endif 90962306a36Sopenharmony_ci#endif /* CONFIG_64BIT */ 91062306a36Sopenharmony_ci 91162306a36Sopenharmony_ci#ifndef ioread8_rep 91262306a36Sopenharmony_ci#define ioread8_rep ioread8_rep 91362306a36Sopenharmony_cistatic inline void ioread8_rep(const volatile void __iomem *addr, void *buffer, 91462306a36Sopenharmony_ci unsigned int count) 91562306a36Sopenharmony_ci{ 91662306a36Sopenharmony_ci readsb(addr, buffer, count); 91762306a36Sopenharmony_ci} 91862306a36Sopenharmony_ci#endif 91962306a36Sopenharmony_ci 92062306a36Sopenharmony_ci#ifndef ioread16_rep 92162306a36Sopenharmony_ci#define ioread16_rep ioread16_rep 92262306a36Sopenharmony_cistatic inline void ioread16_rep(const volatile void __iomem *addr, 92362306a36Sopenharmony_ci void *buffer, unsigned int count) 92462306a36Sopenharmony_ci{ 92562306a36Sopenharmony_ci readsw(addr, buffer, count); 92662306a36Sopenharmony_ci} 92762306a36Sopenharmony_ci#endif 92862306a36Sopenharmony_ci 92962306a36Sopenharmony_ci#ifndef ioread32_rep 93062306a36Sopenharmony_ci#define ioread32_rep ioread32_rep 93162306a36Sopenharmony_cistatic inline void ioread32_rep(const volatile void __iomem *addr, 93262306a36Sopenharmony_ci void *buffer, unsigned int count) 93362306a36Sopenharmony_ci{ 93462306a36Sopenharmony_ci readsl(addr, buffer, count); 93562306a36Sopenharmony_ci} 93662306a36Sopenharmony_ci#endif 93762306a36Sopenharmony_ci 93862306a36Sopenharmony_ci#ifdef CONFIG_64BIT 93962306a36Sopenharmony_ci#ifndef ioread64_rep 94062306a36Sopenharmony_ci#define ioread64_rep ioread64_rep 94162306a36Sopenharmony_cistatic inline void ioread64_rep(const volatile void __iomem *addr, 94262306a36Sopenharmony_ci void *buffer, unsigned int count) 94362306a36Sopenharmony_ci{ 94462306a36Sopenharmony_ci readsq(addr, buffer, count); 94562306a36Sopenharmony_ci} 94662306a36Sopenharmony_ci#endif 94762306a36Sopenharmony_ci#endif /* CONFIG_64BIT */ 94862306a36Sopenharmony_ci 94962306a36Sopenharmony_ci#ifndef iowrite8_rep 95062306a36Sopenharmony_ci#define iowrite8_rep iowrite8_rep 95162306a36Sopenharmony_cistatic inline void iowrite8_rep(volatile void __iomem *addr, 95262306a36Sopenharmony_ci const void *buffer, 95362306a36Sopenharmony_ci unsigned int count) 95462306a36Sopenharmony_ci{ 95562306a36Sopenharmony_ci writesb(addr, buffer, count); 95662306a36Sopenharmony_ci} 95762306a36Sopenharmony_ci#endif 95862306a36Sopenharmony_ci 95962306a36Sopenharmony_ci#ifndef iowrite16_rep 96062306a36Sopenharmony_ci#define iowrite16_rep iowrite16_rep 96162306a36Sopenharmony_cistatic inline void iowrite16_rep(volatile void __iomem *addr, 96262306a36Sopenharmony_ci const void *buffer, 96362306a36Sopenharmony_ci unsigned int count) 96462306a36Sopenharmony_ci{ 96562306a36Sopenharmony_ci writesw(addr, buffer, count); 96662306a36Sopenharmony_ci} 96762306a36Sopenharmony_ci#endif 96862306a36Sopenharmony_ci 96962306a36Sopenharmony_ci#ifndef iowrite32_rep 97062306a36Sopenharmony_ci#define iowrite32_rep iowrite32_rep 97162306a36Sopenharmony_cistatic inline void iowrite32_rep(volatile void __iomem *addr, 97262306a36Sopenharmony_ci const void *buffer, 97362306a36Sopenharmony_ci unsigned int count) 97462306a36Sopenharmony_ci{ 97562306a36Sopenharmony_ci writesl(addr, buffer, count); 97662306a36Sopenharmony_ci} 97762306a36Sopenharmony_ci#endif 97862306a36Sopenharmony_ci 97962306a36Sopenharmony_ci#ifdef CONFIG_64BIT 98062306a36Sopenharmony_ci#ifndef iowrite64_rep 98162306a36Sopenharmony_ci#define iowrite64_rep iowrite64_rep 98262306a36Sopenharmony_cistatic inline void iowrite64_rep(volatile void __iomem *addr, 98362306a36Sopenharmony_ci const void *buffer, 98462306a36Sopenharmony_ci unsigned int count) 98562306a36Sopenharmony_ci{ 98662306a36Sopenharmony_ci writesq(addr, buffer, count); 98762306a36Sopenharmony_ci} 98862306a36Sopenharmony_ci#endif 98962306a36Sopenharmony_ci#endif /* CONFIG_64BIT */ 99062306a36Sopenharmony_ci#endif /* CONFIG_GENERIC_IOMAP */ 99162306a36Sopenharmony_ci 99262306a36Sopenharmony_ci#ifdef __KERNEL__ 99362306a36Sopenharmony_ci 99462306a36Sopenharmony_ci#include <linux/vmalloc.h> 99562306a36Sopenharmony_ci#define __io_virt(x) ((void __force *)(x)) 99662306a36Sopenharmony_ci 99762306a36Sopenharmony_ci/* 99862306a36Sopenharmony_ci * Change virtual addresses to physical addresses and vv. 99962306a36Sopenharmony_ci * These are pretty trivial 100062306a36Sopenharmony_ci */ 100162306a36Sopenharmony_ci#ifndef virt_to_phys 100262306a36Sopenharmony_ci#define virt_to_phys virt_to_phys 100362306a36Sopenharmony_cistatic inline unsigned long virt_to_phys(volatile void *address) 100462306a36Sopenharmony_ci{ 100562306a36Sopenharmony_ci return __pa((unsigned long)address); 100662306a36Sopenharmony_ci} 100762306a36Sopenharmony_ci#endif 100862306a36Sopenharmony_ci 100962306a36Sopenharmony_ci#ifndef phys_to_virt 101062306a36Sopenharmony_ci#define phys_to_virt phys_to_virt 101162306a36Sopenharmony_cistatic inline void *phys_to_virt(unsigned long address) 101262306a36Sopenharmony_ci{ 101362306a36Sopenharmony_ci return __va(address); 101462306a36Sopenharmony_ci} 101562306a36Sopenharmony_ci#endif 101662306a36Sopenharmony_ci 101762306a36Sopenharmony_ci/** 101862306a36Sopenharmony_ci * DOC: ioremap() and ioremap_*() variants 101962306a36Sopenharmony_ci * 102062306a36Sopenharmony_ci * Architectures with an MMU are expected to provide ioremap() and iounmap() 102162306a36Sopenharmony_ci * themselves or rely on GENERIC_IOREMAP. For NOMMU architectures we provide 102262306a36Sopenharmony_ci * a default nop-op implementation that expect that the physical address used 102362306a36Sopenharmony_ci * for MMIO are already marked as uncached, and can be used as kernel virtual 102462306a36Sopenharmony_ci * addresses. 102562306a36Sopenharmony_ci * 102662306a36Sopenharmony_ci * ioremap_wc() and ioremap_wt() can provide more relaxed caching attributes 102762306a36Sopenharmony_ci * for specific drivers if the architecture choses to implement them. If they 102862306a36Sopenharmony_ci * are not implemented we fall back to plain ioremap. Conversely, ioremap_np() 102962306a36Sopenharmony_ci * can provide stricter non-posted write semantics if the architecture 103062306a36Sopenharmony_ci * implements them. 103162306a36Sopenharmony_ci */ 103262306a36Sopenharmony_ci#ifndef CONFIG_MMU 103362306a36Sopenharmony_ci#ifndef ioremap 103462306a36Sopenharmony_ci#define ioremap ioremap 103562306a36Sopenharmony_cistatic inline void __iomem *ioremap(phys_addr_t offset, size_t size) 103662306a36Sopenharmony_ci{ 103762306a36Sopenharmony_ci return (void __iomem *)(unsigned long)offset; 103862306a36Sopenharmony_ci} 103962306a36Sopenharmony_ci#endif 104062306a36Sopenharmony_ci 104162306a36Sopenharmony_ci#ifndef iounmap 104262306a36Sopenharmony_ci#define iounmap iounmap 104362306a36Sopenharmony_cistatic inline void iounmap(volatile void __iomem *addr) 104462306a36Sopenharmony_ci{ 104562306a36Sopenharmony_ci} 104662306a36Sopenharmony_ci#endif 104762306a36Sopenharmony_ci#elif defined(CONFIG_GENERIC_IOREMAP) 104862306a36Sopenharmony_ci#include <linux/pgtable.h> 104962306a36Sopenharmony_ci 105062306a36Sopenharmony_civoid __iomem *generic_ioremap_prot(phys_addr_t phys_addr, size_t size, 105162306a36Sopenharmony_ci pgprot_t prot); 105262306a36Sopenharmony_ci 105362306a36Sopenharmony_civoid __iomem *ioremap_prot(phys_addr_t phys_addr, size_t size, 105462306a36Sopenharmony_ci unsigned long prot); 105562306a36Sopenharmony_civoid iounmap(volatile void __iomem *addr); 105662306a36Sopenharmony_civoid generic_iounmap(volatile void __iomem *addr); 105762306a36Sopenharmony_ci 105862306a36Sopenharmony_ci#ifndef ioremap 105962306a36Sopenharmony_ci#define ioremap ioremap 106062306a36Sopenharmony_cistatic inline void __iomem *ioremap(phys_addr_t addr, size_t size) 106162306a36Sopenharmony_ci{ 106262306a36Sopenharmony_ci /* _PAGE_IOREMAP needs to be supplied by the architecture */ 106362306a36Sopenharmony_ci return ioremap_prot(addr, size, _PAGE_IOREMAP); 106462306a36Sopenharmony_ci} 106562306a36Sopenharmony_ci#endif 106662306a36Sopenharmony_ci#endif /* !CONFIG_MMU || CONFIG_GENERIC_IOREMAP */ 106762306a36Sopenharmony_ci 106862306a36Sopenharmony_ci#ifndef ioremap_wc 106962306a36Sopenharmony_ci#define ioremap_wc ioremap 107062306a36Sopenharmony_ci#endif 107162306a36Sopenharmony_ci 107262306a36Sopenharmony_ci#ifndef ioremap_wt 107362306a36Sopenharmony_ci#define ioremap_wt ioremap 107462306a36Sopenharmony_ci#endif 107562306a36Sopenharmony_ci 107662306a36Sopenharmony_ci/* 107762306a36Sopenharmony_ci * ioremap_uc is special in that we do require an explicit architecture 107862306a36Sopenharmony_ci * implementation. In general you do not want to use this function in a 107962306a36Sopenharmony_ci * driver and use plain ioremap, which is uncached by default. Similarly 108062306a36Sopenharmony_ci * architectures should not implement it unless they have a very good 108162306a36Sopenharmony_ci * reason. 108262306a36Sopenharmony_ci */ 108362306a36Sopenharmony_ci#ifndef ioremap_uc 108462306a36Sopenharmony_ci#define ioremap_uc ioremap_uc 108562306a36Sopenharmony_cistatic inline void __iomem *ioremap_uc(phys_addr_t offset, size_t size) 108662306a36Sopenharmony_ci{ 108762306a36Sopenharmony_ci return NULL; 108862306a36Sopenharmony_ci} 108962306a36Sopenharmony_ci#endif 109062306a36Sopenharmony_ci 109162306a36Sopenharmony_ci/* 109262306a36Sopenharmony_ci * ioremap_np needs an explicit architecture implementation, as it 109362306a36Sopenharmony_ci * requests stronger semantics than regular ioremap(). Portable drivers 109462306a36Sopenharmony_ci * should instead use one of the higher-level abstractions, like 109562306a36Sopenharmony_ci * devm_ioremap_resource(), to choose the correct variant for any given 109662306a36Sopenharmony_ci * device and bus. Portable drivers with a good reason to want non-posted 109762306a36Sopenharmony_ci * write semantics should always provide an ioremap() fallback in case 109862306a36Sopenharmony_ci * ioremap_np() is not available. 109962306a36Sopenharmony_ci */ 110062306a36Sopenharmony_ci#ifndef ioremap_np 110162306a36Sopenharmony_ci#define ioremap_np ioremap_np 110262306a36Sopenharmony_cistatic inline void __iomem *ioremap_np(phys_addr_t offset, size_t size) 110362306a36Sopenharmony_ci{ 110462306a36Sopenharmony_ci return NULL; 110562306a36Sopenharmony_ci} 110662306a36Sopenharmony_ci#endif 110762306a36Sopenharmony_ci 110862306a36Sopenharmony_ci#ifdef CONFIG_HAS_IOPORT_MAP 110962306a36Sopenharmony_ci#ifndef CONFIG_GENERIC_IOMAP 111062306a36Sopenharmony_ci#ifndef ioport_map 111162306a36Sopenharmony_ci#define ioport_map ioport_map 111262306a36Sopenharmony_cistatic inline void __iomem *ioport_map(unsigned long port, unsigned int nr) 111362306a36Sopenharmony_ci{ 111462306a36Sopenharmony_ci port &= IO_SPACE_LIMIT; 111562306a36Sopenharmony_ci return (port > MMIO_UPPER_LIMIT) ? NULL : PCI_IOBASE + port; 111662306a36Sopenharmony_ci} 111762306a36Sopenharmony_ci#define ARCH_HAS_GENERIC_IOPORT_MAP 111862306a36Sopenharmony_ci#endif 111962306a36Sopenharmony_ci 112062306a36Sopenharmony_ci#ifndef ioport_unmap 112162306a36Sopenharmony_ci#define ioport_unmap ioport_unmap 112262306a36Sopenharmony_cistatic inline void ioport_unmap(void __iomem *p) 112362306a36Sopenharmony_ci{ 112462306a36Sopenharmony_ci} 112562306a36Sopenharmony_ci#endif 112662306a36Sopenharmony_ci#else /* CONFIG_GENERIC_IOMAP */ 112762306a36Sopenharmony_ciextern void __iomem *ioport_map(unsigned long port, unsigned int nr); 112862306a36Sopenharmony_ciextern void ioport_unmap(void __iomem *p); 112962306a36Sopenharmony_ci#endif /* CONFIG_GENERIC_IOMAP */ 113062306a36Sopenharmony_ci#endif /* CONFIG_HAS_IOPORT_MAP */ 113162306a36Sopenharmony_ci 113262306a36Sopenharmony_ci#ifndef CONFIG_GENERIC_IOMAP 113362306a36Sopenharmony_ci#ifndef pci_iounmap 113462306a36Sopenharmony_ci#define ARCH_WANTS_GENERIC_PCI_IOUNMAP 113562306a36Sopenharmony_ci#endif 113662306a36Sopenharmony_ci#endif 113762306a36Sopenharmony_ci 113862306a36Sopenharmony_ci#ifndef xlate_dev_mem_ptr 113962306a36Sopenharmony_ci#define xlate_dev_mem_ptr xlate_dev_mem_ptr 114062306a36Sopenharmony_cistatic inline void *xlate_dev_mem_ptr(phys_addr_t addr) 114162306a36Sopenharmony_ci{ 114262306a36Sopenharmony_ci return __va(addr); 114362306a36Sopenharmony_ci} 114462306a36Sopenharmony_ci#endif 114562306a36Sopenharmony_ci 114662306a36Sopenharmony_ci#ifndef unxlate_dev_mem_ptr 114762306a36Sopenharmony_ci#define unxlate_dev_mem_ptr unxlate_dev_mem_ptr 114862306a36Sopenharmony_cistatic inline void unxlate_dev_mem_ptr(phys_addr_t phys, void *addr) 114962306a36Sopenharmony_ci{ 115062306a36Sopenharmony_ci} 115162306a36Sopenharmony_ci#endif 115262306a36Sopenharmony_ci 115362306a36Sopenharmony_ci#ifndef memset_io 115462306a36Sopenharmony_ci#define memset_io memset_io 115562306a36Sopenharmony_ci/** 115662306a36Sopenharmony_ci * memset_io Set a range of I/O memory to a constant value 115762306a36Sopenharmony_ci * @addr: The beginning of the I/O-memory range to set 115862306a36Sopenharmony_ci * @val: The value to set the memory to 115962306a36Sopenharmony_ci * @count: The number of bytes to set 116062306a36Sopenharmony_ci * 116162306a36Sopenharmony_ci * Set a range of I/O memory to a given value. 116262306a36Sopenharmony_ci */ 116362306a36Sopenharmony_cistatic inline void memset_io(volatile void __iomem *addr, int value, 116462306a36Sopenharmony_ci size_t size) 116562306a36Sopenharmony_ci{ 116662306a36Sopenharmony_ci memset(__io_virt(addr), value, size); 116762306a36Sopenharmony_ci} 116862306a36Sopenharmony_ci#endif 116962306a36Sopenharmony_ci 117062306a36Sopenharmony_ci#ifndef memcpy_fromio 117162306a36Sopenharmony_ci#define memcpy_fromio memcpy_fromio 117262306a36Sopenharmony_ci/** 117362306a36Sopenharmony_ci * memcpy_fromio Copy a block of data from I/O memory 117462306a36Sopenharmony_ci * @dst: The (RAM) destination for the copy 117562306a36Sopenharmony_ci * @src: The (I/O memory) source for the data 117662306a36Sopenharmony_ci * @count: The number of bytes to copy 117762306a36Sopenharmony_ci * 117862306a36Sopenharmony_ci * Copy a block of data from I/O memory. 117962306a36Sopenharmony_ci */ 118062306a36Sopenharmony_cistatic inline void memcpy_fromio(void *buffer, 118162306a36Sopenharmony_ci const volatile void __iomem *addr, 118262306a36Sopenharmony_ci size_t size) 118362306a36Sopenharmony_ci{ 118462306a36Sopenharmony_ci memcpy(buffer, __io_virt(addr), size); 118562306a36Sopenharmony_ci} 118662306a36Sopenharmony_ci#endif 118762306a36Sopenharmony_ci 118862306a36Sopenharmony_ci#ifndef memcpy_toio 118962306a36Sopenharmony_ci#define memcpy_toio memcpy_toio 119062306a36Sopenharmony_ci/** 119162306a36Sopenharmony_ci * memcpy_toio Copy a block of data into I/O memory 119262306a36Sopenharmony_ci * @dst: The (I/O memory) destination for the copy 119362306a36Sopenharmony_ci * @src: The (RAM) source for the data 119462306a36Sopenharmony_ci * @count: The number of bytes to copy 119562306a36Sopenharmony_ci * 119662306a36Sopenharmony_ci * Copy a block of data to I/O memory. 119762306a36Sopenharmony_ci */ 119862306a36Sopenharmony_cistatic inline void memcpy_toio(volatile void __iomem *addr, const void *buffer, 119962306a36Sopenharmony_ci size_t size) 120062306a36Sopenharmony_ci{ 120162306a36Sopenharmony_ci memcpy(__io_virt(addr), buffer, size); 120262306a36Sopenharmony_ci} 120362306a36Sopenharmony_ci#endif 120462306a36Sopenharmony_ci 120562306a36Sopenharmony_ciextern int devmem_is_allowed(unsigned long pfn); 120662306a36Sopenharmony_ci 120762306a36Sopenharmony_ci#endif /* __KERNEL__ */ 120862306a36Sopenharmony_ci 120962306a36Sopenharmony_ci#endif /* __ASM_GENERIC_IO_H */ 1210