18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * Implement the default iomap interfaces 48c2ecf20Sopenharmony_ci * 58c2ecf20Sopenharmony_ci * (C) Copyright 2004 Linus Torvalds 68c2ecf20Sopenharmony_ci */ 78c2ecf20Sopenharmony_ci#include <linux/pci.h> 88c2ecf20Sopenharmony_ci#include <linux/io.h> 98c2ecf20Sopenharmony_ci 108c2ecf20Sopenharmony_ci#include <linux/export.h> 118c2ecf20Sopenharmony_ci 128c2ecf20Sopenharmony_ci/* 138c2ecf20Sopenharmony_ci * Read/write from/to an (offsettable) iomem cookie. It might be a PIO 148c2ecf20Sopenharmony_ci * access or a MMIO access, these functions don't care. The info is 158c2ecf20Sopenharmony_ci * encoded in the hardware mapping set up by the mapping functions 168c2ecf20Sopenharmony_ci * (or the cookie itself, depending on implementation and hw). 178c2ecf20Sopenharmony_ci * 188c2ecf20Sopenharmony_ci * The generic routines don't assume any hardware mappings, and just 198c2ecf20Sopenharmony_ci * encode the PIO/MMIO as part of the cookie. They coldly assume that 208c2ecf20Sopenharmony_ci * the MMIO IO mappings are not in the low address range. 218c2ecf20Sopenharmony_ci * 228c2ecf20Sopenharmony_ci * Architectures for which this is not true can't use this generic 238c2ecf20Sopenharmony_ci * implementation and should do their own copy. 248c2ecf20Sopenharmony_ci */ 258c2ecf20Sopenharmony_ci 268c2ecf20Sopenharmony_ci#ifndef HAVE_ARCH_PIO_SIZE 278c2ecf20Sopenharmony_ci/* 288c2ecf20Sopenharmony_ci * We encode the physical PIO addresses (0-0xffff) into the 298c2ecf20Sopenharmony_ci * pointer by offsetting them with a constant (0x10000) and 308c2ecf20Sopenharmony_ci * assuming that all the low addresses are always PIO. That means 318c2ecf20Sopenharmony_ci * we can do some sanity checks on the low bits, and don't 328c2ecf20Sopenharmony_ci * need to just take things for granted. 338c2ecf20Sopenharmony_ci */ 348c2ecf20Sopenharmony_ci#define PIO_OFFSET 0x10000UL 358c2ecf20Sopenharmony_ci#define PIO_MASK 0x0ffffUL 368c2ecf20Sopenharmony_ci#define PIO_RESERVED 0x40000UL 378c2ecf20Sopenharmony_ci#endif 388c2ecf20Sopenharmony_ci 398c2ecf20Sopenharmony_cistatic void bad_io_access(unsigned long port, const char *access) 408c2ecf20Sopenharmony_ci{ 418c2ecf20Sopenharmony_ci static int count = 10; 428c2ecf20Sopenharmony_ci if (count) { 438c2ecf20Sopenharmony_ci count--; 448c2ecf20Sopenharmony_ci WARN(1, KERN_ERR "Bad IO access at port %#lx (%s)\n", port, access); 458c2ecf20Sopenharmony_ci } 468c2ecf20Sopenharmony_ci} 478c2ecf20Sopenharmony_ci 488c2ecf20Sopenharmony_ci/* 498c2ecf20Sopenharmony_ci * Ugly macros are a way of life. 508c2ecf20Sopenharmony_ci */ 518c2ecf20Sopenharmony_ci#define IO_COND(addr, is_pio, is_mmio) do { \ 528c2ecf20Sopenharmony_ci unsigned long port = (unsigned long __force)addr; \ 538c2ecf20Sopenharmony_ci if (port >= PIO_RESERVED) { \ 548c2ecf20Sopenharmony_ci is_mmio; \ 558c2ecf20Sopenharmony_ci } else if (port > PIO_OFFSET) { \ 568c2ecf20Sopenharmony_ci port &= PIO_MASK; \ 578c2ecf20Sopenharmony_ci is_pio; \ 588c2ecf20Sopenharmony_ci } else \ 598c2ecf20Sopenharmony_ci bad_io_access(port, #is_pio ); \ 608c2ecf20Sopenharmony_ci} while (0) 618c2ecf20Sopenharmony_ci 628c2ecf20Sopenharmony_ci#ifndef pio_read16be 638c2ecf20Sopenharmony_ci#define pio_read16be(port) swab16(inw(port)) 648c2ecf20Sopenharmony_ci#define pio_read32be(port) swab32(inl(port)) 658c2ecf20Sopenharmony_ci#endif 668c2ecf20Sopenharmony_ci 678c2ecf20Sopenharmony_ci#ifndef mmio_read16be 688c2ecf20Sopenharmony_ci#define mmio_read16be(addr) swab16(readw(addr)) 698c2ecf20Sopenharmony_ci#define mmio_read32be(addr) swab32(readl(addr)) 708c2ecf20Sopenharmony_ci#define mmio_read64be(addr) swab64(readq(addr)) 718c2ecf20Sopenharmony_ci#endif 728c2ecf20Sopenharmony_ci 738c2ecf20Sopenharmony_ciunsigned int ioread8(const void __iomem *addr) 748c2ecf20Sopenharmony_ci{ 758c2ecf20Sopenharmony_ci IO_COND(addr, return inb(port), return readb(addr)); 768c2ecf20Sopenharmony_ci return 0xff; 778c2ecf20Sopenharmony_ci} 788c2ecf20Sopenharmony_ciunsigned int ioread16(const void __iomem *addr) 798c2ecf20Sopenharmony_ci{ 808c2ecf20Sopenharmony_ci IO_COND(addr, return inw(port), return readw(addr)); 818c2ecf20Sopenharmony_ci return 0xffff; 828c2ecf20Sopenharmony_ci} 838c2ecf20Sopenharmony_ciunsigned int ioread16be(const void __iomem *addr) 848c2ecf20Sopenharmony_ci{ 858c2ecf20Sopenharmony_ci IO_COND(addr, return pio_read16be(port), return mmio_read16be(addr)); 868c2ecf20Sopenharmony_ci return 0xffff; 878c2ecf20Sopenharmony_ci} 888c2ecf20Sopenharmony_ciunsigned int ioread32(const void __iomem *addr) 898c2ecf20Sopenharmony_ci{ 908c2ecf20Sopenharmony_ci IO_COND(addr, return inl(port), return readl(addr)); 918c2ecf20Sopenharmony_ci return 0xffffffff; 928c2ecf20Sopenharmony_ci} 938c2ecf20Sopenharmony_ciunsigned int ioread32be(const void __iomem *addr) 948c2ecf20Sopenharmony_ci{ 958c2ecf20Sopenharmony_ci IO_COND(addr, return pio_read32be(port), return mmio_read32be(addr)); 968c2ecf20Sopenharmony_ci return 0xffffffff; 978c2ecf20Sopenharmony_ci} 988c2ecf20Sopenharmony_ciEXPORT_SYMBOL(ioread8); 998c2ecf20Sopenharmony_ciEXPORT_SYMBOL(ioread16); 1008c2ecf20Sopenharmony_ciEXPORT_SYMBOL(ioread16be); 1018c2ecf20Sopenharmony_ciEXPORT_SYMBOL(ioread32); 1028c2ecf20Sopenharmony_ciEXPORT_SYMBOL(ioread32be); 1038c2ecf20Sopenharmony_ci 1048c2ecf20Sopenharmony_ci#ifdef readq 1058c2ecf20Sopenharmony_cistatic u64 pio_read64_lo_hi(unsigned long port) 1068c2ecf20Sopenharmony_ci{ 1078c2ecf20Sopenharmony_ci u64 lo, hi; 1088c2ecf20Sopenharmony_ci 1098c2ecf20Sopenharmony_ci lo = inl(port); 1108c2ecf20Sopenharmony_ci hi = inl(port + sizeof(u32)); 1118c2ecf20Sopenharmony_ci 1128c2ecf20Sopenharmony_ci return lo | (hi << 32); 1138c2ecf20Sopenharmony_ci} 1148c2ecf20Sopenharmony_ci 1158c2ecf20Sopenharmony_cistatic u64 pio_read64_hi_lo(unsigned long port) 1168c2ecf20Sopenharmony_ci{ 1178c2ecf20Sopenharmony_ci u64 lo, hi; 1188c2ecf20Sopenharmony_ci 1198c2ecf20Sopenharmony_ci hi = inl(port + sizeof(u32)); 1208c2ecf20Sopenharmony_ci lo = inl(port); 1218c2ecf20Sopenharmony_ci 1228c2ecf20Sopenharmony_ci return lo | (hi << 32); 1238c2ecf20Sopenharmony_ci} 1248c2ecf20Sopenharmony_ci 1258c2ecf20Sopenharmony_cistatic u64 pio_read64be_lo_hi(unsigned long port) 1268c2ecf20Sopenharmony_ci{ 1278c2ecf20Sopenharmony_ci u64 lo, hi; 1288c2ecf20Sopenharmony_ci 1298c2ecf20Sopenharmony_ci lo = pio_read32be(port + sizeof(u32)); 1308c2ecf20Sopenharmony_ci hi = pio_read32be(port); 1318c2ecf20Sopenharmony_ci 1328c2ecf20Sopenharmony_ci return lo | (hi << 32); 1338c2ecf20Sopenharmony_ci} 1348c2ecf20Sopenharmony_ci 1358c2ecf20Sopenharmony_cistatic u64 pio_read64be_hi_lo(unsigned long port) 1368c2ecf20Sopenharmony_ci{ 1378c2ecf20Sopenharmony_ci u64 lo, hi; 1388c2ecf20Sopenharmony_ci 1398c2ecf20Sopenharmony_ci hi = pio_read32be(port); 1408c2ecf20Sopenharmony_ci lo = pio_read32be(port + sizeof(u32)); 1418c2ecf20Sopenharmony_ci 1428c2ecf20Sopenharmony_ci return lo | (hi << 32); 1438c2ecf20Sopenharmony_ci} 1448c2ecf20Sopenharmony_ci 1458c2ecf20Sopenharmony_ciu64 ioread64_lo_hi(const void __iomem *addr) 1468c2ecf20Sopenharmony_ci{ 1478c2ecf20Sopenharmony_ci IO_COND(addr, return pio_read64_lo_hi(port), return readq(addr)); 1488c2ecf20Sopenharmony_ci return 0xffffffffffffffffULL; 1498c2ecf20Sopenharmony_ci} 1508c2ecf20Sopenharmony_ci 1518c2ecf20Sopenharmony_ciu64 ioread64_hi_lo(const void __iomem *addr) 1528c2ecf20Sopenharmony_ci{ 1538c2ecf20Sopenharmony_ci IO_COND(addr, return pio_read64_hi_lo(port), return readq(addr)); 1548c2ecf20Sopenharmony_ci return 0xffffffffffffffffULL; 1558c2ecf20Sopenharmony_ci} 1568c2ecf20Sopenharmony_ci 1578c2ecf20Sopenharmony_ciu64 ioread64be_lo_hi(const void __iomem *addr) 1588c2ecf20Sopenharmony_ci{ 1598c2ecf20Sopenharmony_ci IO_COND(addr, return pio_read64be_lo_hi(port), 1608c2ecf20Sopenharmony_ci return mmio_read64be(addr)); 1618c2ecf20Sopenharmony_ci return 0xffffffffffffffffULL; 1628c2ecf20Sopenharmony_ci} 1638c2ecf20Sopenharmony_ci 1648c2ecf20Sopenharmony_ciu64 ioread64be_hi_lo(const void __iomem *addr) 1658c2ecf20Sopenharmony_ci{ 1668c2ecf20Sopenharmony_ci IO_COND(addr, return pio_read64be_hi_lo(port), 1678c2ecf20Sopenharmony_ci return mmio_read64be(addr)); 1688c2ecf20Sopenharmony_ci return 0xffffffffffffffffULL; 1698c2ecf20Sopenharmony_ci} 1708c2ecf20Sopenharmony_ci 1718c2ecf20Sopenharmony_ciEXPORT_SYMBOL(ioread64_lo_hi); 1728c2ecf20Sopenharmony_ciEXPORT_SYMBOL(ioread64_hi_lo); 1738c2ecf20Sopenharmony_ciEXPORT_SYMBOL(ioread64be_lo_hi); 1748c2ecf20Sopenharmony_ciEXPORT_SYMBOL(ioread64be_hi_lo); 1758c2ecf20Sopenharmony_ci 1768c2ecf20Sopenharmony_ci#endif /* readq */ 1778c2ecf20Sopenharmony_ci 1788c2ecf20Sopenharmony_ci#ifndef pio_write16be 1798c2ecf20Sopenharmony_ci#define pio_write16be(val,port) outw(swab16(val),port) 1808c2ecf20Sopenharmony_ci#define pio_write32be(val,port) outl(swab32(val),port) 1818c2ecf20Sopenharmony_ci#endif 1828c2ecf20Sopenharmony_ci 1838c2ecf20Sopenharmony_ci#ifndef mmio_write16be 1848c2ecf20Sopenharmony_ci#define mmio_write16be(val,port) writew(swab16(val),port) 1858c2ecf20Sopenharmony_ci#define mmio_write32be(val,port) writel(swab32(val),port) 1868c2ecf20Sopenharmony_ci#define mmio_write64be(val,port) writeq(swab64(val),port) 1878c2ecf20Sopenharmony_ci#endif 1888c2ecf20Sopenharmony_ci 1898c2ecf20Sopenharmony_civoid iowrite8(u8 val, void __iomem *addr) 1908c2ecf20Sopenharmony_ci{ 1918c2ecf20Sopenharmony_ci IO_COND(addr, outb(val,port), writeb(val, addr)); 1928c2ecf20Sopenharmony_ci} 1938c2ecf20Sopenharmony_civoid iowrite16(u16 val, void __iomem *addr) 1948c2ecf20Sopenharmony_ci{ 1958c2ecf20Sopenharmony_ci IO_COND(addr, outw(val,port), writew(val, addr)); 1968c2ecf20Sopenharmony_ci} 1978c2ecf20Sopenharmony_civoid iowrite16be(u16 val, void __iomem *addr) 1988c2ecf20Sopenharmony_ci{ 1998c2ecf20Sopenharmony_ci IO_COND(addr, pio_write16be(val,port), mmio_write16be(val, addr)); 2008c2ecf20Sopenharmony_ci} 2018c2ecf20Sopenharmony_civoid iowrite32(u32 val, void __iomem *addr) 2028c2ecf20Sopenharmony_ci{ 2038c2ecf20Sopenharmony_ci IO_COND(addr, outl(val,port), writel(val, addr)); 2048c2ecf20Sopenharmony_ci} 2058c2ecf20Sopenharmony_civoid iowrite32be(u32 val, void __iomem *addr) 2068c2ecf20Sopenharmony_ci{ 2078c2ecf20Sopenharmony_ci IO_COND(addr, pio_write32be(val,port), mmio_write32be(val, addr)); 2088c2ecf20Sopenharmony_ci} 2098c2ecf20Sopenharmony_ciEXPORT_SYMBOL(iowrite8); 2108c2ecf20Sopenharmony_ciEXPORT_SYMBOL(iowrite16); 2118c2ecf20Sopenharmony_ciEXPORT_SYMBOL(iowrite16be); 2128c2ecf20Sopenharmony_ciEXPORT_SYMBOL(iowrite32); 2138c2ecf20Sopenharmony_ciEXPORT_SYMBOL(iowrite32be); 2148c2ecf20Sopenharmony_ci 2158c2ecf20Sopenharmony_ci#ifdef writeq 2168c2ecf20Sopenharmony_cistatic void pio_write64_lo_hi(u64 val, unsigned long port) 2178c2ecf20Sopenharmony_ci{ 2188c2ecf20Sopenharmony_ci outl(val, port); 2198c2ecf20Sopenharmony_ci outl(val >> 32, port + sizeof(u32)); 2208c2ecf20Sopenharmony_ci} 2218c2ecf20Sopenharmony_ci 2228c2ecf20Sopenharmony_cistatic void pio_write64_hi_lo(u64 val, unsigned long port) 2238c2ecf20Sopenharmony_ci{ 2248c2ecf20Sopenharmony_ci outl(val >> 32, port + sizeof(u32)); 2258c2ecf20Sopenharmony_ci outl(val, port); 2268c2ecf20Sopenharmony_ci} 2278c2ecf20Sopenharmony_ci 2288c2ecf20Sopenharmony_cistatic void pio_write64be_lo_hi(u64 val, unsigned long port) 2298c2ecf20Sopenharmony_ci{ 2308c2ecf20Sopenharmony_ci pio_write32be(val, port + sizeof(u32)); 2318c2ecf20Sopenharmony_ci pio_write32be(val >> 32, port); 2328c2ecf20Sopenharmony_ci} 2338c2ecf20Sopenharmony_ci 2348c2ecf20Sopenharmony_cistatic void pio_write64be_hi_lo(u64 val, unsigned long port) 2358c2ecf20Sopenharmony_ci{ 2368c2ecf20Sopenharmony_ci pio_write32be(val >> 32, port); 2378c2ecf20Sopenharmony_ci pio_write32be(val, port + sizeof(u32)); 2388c2ecf20Sopenharmony_ci} 2398c2ecf20Sopenharmony_ci 2408c2ecf20Sopenharmony_civoid iowrite64_lo_hi(u64 val, void __iomem *addr) 2418c2ecf20Sopenharmony_ci{ 2428c2ecf20Sopenharmony_ci IO_COND(addr, pio_write64_lo_hi(val, port), 2438c2ecf20Sopenharmony_ci writeq(val, addr)); 2448c2ecf20Sopenharmony_ci} 2458c2ecf20Sopenharmony_ci 2468c2ecf20Sopenharmony_civoid iowrite64_hi_lo(u64 val, void __iomem *addr) 2478c2ecf20Sopenharmony_ci{ 2488c2ecf20Sopenharmony_ci IO_COND(addr, pio_write64_hi_lo(val, port), 2498c2ecf20Sopenharmony_ci writeq(val, addr)); 2508c2ecf20Sopenharmony_ci} 2518c2ecf20Sopenharmony_ci 2528c2ecf20Sopenharmony_civoid iowrite64be_lo_hi(u64 val, void __iomem *addr) 2538c2ecf20Sopenharmony_ci{ 2548c2ecf20Sopenharmony_ci IO_COND(addr, pio_write64be_lo_hi(val, port), 2558c2ecf20Sopenharmony_ci mmio_write64be(val, addr)); 2568c2ecf20Sopenharmony_ci} 2578c2ecf20Sopenharmony_ci 2588c2ecf20Sopenharmony_civoid iowrite64be_hi_lo(u64 val, void __iomem *addr) 2598c2ecf20Sopenharmony_ci{ 2608c2ecf20Sopenharmony_ci IO_COND(addr, pio_write64be_hi_lo(val, port), 2618c2ecf20Sopenharmony_ci mmio_write64be(val, addr)); 2628c2ecf20Sopenharmony_ci} 2638c2ecf20Sopenharmony_ci 2648c2ecf20Sopenharmony_ciEXPORT_SYMBOL(iowrite64_lo_hi); 2658c2ecf20Sopenharmony_ciEXPORT_SYMBOL(iowrite64_hi_lo); 2668c2ecf20Sopenharmony_ciEXPORT_SYMBOL(iowrite64be_lo_hi); 2678c2ecf20Sopenharmony_ciEXPORT_SYMBOL(iowrite64be_hi_lo); 2688c2ecf20Sopenharmony_ci 2698c2ecf20Sopenharmony_ci#endif /* readq */ 2708c2ecf20Sopenharmony_ci 2718c2ecf20Sopenharmony_ci/* 2728c2ecf20Sopenharmony_ci * These are the "repeat MMIO read/write" functions. 2738c2ecf20Sopenharmony_ci * Note the "__raw" accesses, since we don't want to 2748c2ecf20Sopenharmony_ci * convert to CPU byte order. We write in "IO byte 2758c2ecf20Sopenharmony_ci * order" (we also don't have IO barriers). 2768c2ecf20Sopenharmony_ci */ 2778c2ecf20Sopenharmony_ci#ifndef mmio_insb 2788c2ecf20Sopenharmony_cistatic inline void mmio_insb(const void __iomem *addr, u8 *dst, int count) 2798c2ecf20Sopenharmony_ci{ 2808c2ecf20Sopenharmony_ci while (--count >= 0) { 2818c2ecf20Sopenharmony_ci u8 data = __raw_readb(addr); 2828c2ecf20Sopenharmony_ci *dst = data; 2838c2ecf20Sopenharmony_ci dst++; 2848c2ecf20Sopenharmony_ci } 2858c2ecf20Sopenharmony_ci} 2868c2ecf20Sopenharmony_cistatic inline void mmio_insw(const void __iomem *addr, u16 *dst, int count) 2878c2ecf20Sopenharmony_ci{ 2888c2ecf20Sopenharmony_ci while (--count >= 0) { 2898c2ecf20Sopenharmony_ci u16 data = __raw_readw(addr); 2908c2ecf20Sopenharmony_ci *dst = data; 2918c2ecf20Sopenharmony_ci dst++; 2928c2ecf20Sopenharmony_ci } 2938c2ecf20Sopenharmony_ci} 2948c2ecf20Sopenharmony_cistatic inline void mmio_insl(const void __iomem *addr, u32 *dst, int count) 2958c2ecf20Sopenharmony_ci{ 2968c2ecf20Sopenharmony_ci while (--count >= 0) { 2978c2ecf20Sopenharmony_ci u32 data = __raw_readl(addr); 2988c2ecf20Sopenharmony_ci *dst = data; 2998c2ecf20Sopenharmony_ci dst++; 3008c2ecf20Sopenharmony_ci } 3018c2ecf20Sopenharmony_ci} 3028c2ecf20Sopenharmony_ci#endif 3038c2ecf20Sopenharmony_ci 3048c2ecf20Sopenharmony_ci#ifndef mmio_outsb 3058c2ecf20Sopenharmony_cistatic inline void mmio_outsb(void __iomem *addr, const u8 *src, int count) 3068c2ecf20Sopenharmony_ci{ 3078c2ecf20Sopenharmony_ci while (--count >= 0) { 3088c2ecf20Sopenharmony_ci __raw_writeb(*src, addr); 3098c2ecf20Sopenharmony_ci src++; 3108c2ecf20Sopenharmony_ci } 3118c2ecf20Sopenharmony_ci} 3128c2ecf20Sopenharmony_cistatic inline void mmio_outsw(void __iomem *addr, const u16 *src, int count) 3138c2ecf20Sopenharmony_ci{ 3148c2ecf20Sopenharmony_ci while (--count >= 0) { 3158c2ecf20Sopenharmony_ci __raw_writew(*src, addr); 3168c2ecf20Sopenharmony_ci src++; 3178c2ecf20Sopenharmony_ci } 3188c2ecf20Sopenharmony_ci} 3198c2ecf20Sopenharmony_cistatic inline void mmio_outsl(void __iomem *addr, const u32 *src, int count) 3208c2ecf20Sopenharmony_ci{ 3218c2ecf20Sopenharmony_ci while (--count >= 0) { 3228c2ecf20Sopenharmony_ci __raw_writel(*src, addr); 3238c2ecf20Sopenharmony_ci src++; 3248c2ecf20Sopenharmony_ci } 3258c2ecf20Sopenharmony_ci} 3268c2ecf20Sopenharmony_ci#endif 3278c2ecf20Sopenharmony_ci 3288c2ecf20Sopenharmony_civoid ioread8_rep(const void __iomem *addr, void *dst, unsigned long count) 3298c2ecf20Sopenharmony_ci{ 3308c2ecf20Sopenharmony_ci IO_COND(addr, insb(port,dst,count), mmio_insb(addr, dst, count)); 3318c2ecf20Sopenharmony_ci} 3328c2ecf20Sopenharmony_civoid ioread16_rep(const void __iomem *addr, void *dst, unsigned long count) 3338c2ecf20Sopenharmony_ci{ 3348c2ecf20Sopenharmony_ci IO_COND(addr, insw(port,dst,count), mmio_insw(addr, dst, count)); 3358c2ecf20Sopenharmony_ci} 3368c2ecf20Sopenharmony_civoid ioread32_rep(const void __iomem *addr, void *dst, unsigned long count) 3378c2ecf20Sopenharmony_ci{ 3388c2ecf20Sopenharmony_ci IO_COND(addr, insl(port,dst,count), mmio_insl(addr, dst, count)); 3398c2ecf20Sopenharmony_ci} 3408c2ecf20Sopenharmony_ciEXPORT_SYMBOL(ioread8_rep); 3418c2ecf20Sopenharmony_ciEXPORT_SYMBOL(ioread16_rep); 3428c2ecf20Sopenharmony_ciEXPORT_SYMBOL(ioread32_rep); 3438c2ecf20Sopenharmony_ci 3448c2ecf20Sopenharmony_civoid iowrite8_rep(void __iomem *addr, const void *src, unsigned long count) 3458c2ecf20Sopenharmony_ci{ 3468c2ecf20Sopenharmony_ci IO_COND(addr, outsb(port, src, count), mmio_outsb(addr, src, count)); 3478c2ecf20Sopenharmony_ci} 3488c2ecf20Sopenharmony_civoid iowrite16_rep(void __iomem *addr, const void *src, unsigned long count) 3498c2ecf20Sopenharmony_ci{ 3508c2ecf20Sopenharmony_ci IO_COND(addr, outsw(port, src, count), mmio_outsw(addr, src, count)); 3518c2ecf20Sopenharmony_ci} 3528c2ecf20Sopenharmony_civoid iowrite32_rep(void __iomem *addr, const void *src, unsigned long count) 3538c2ecf20Sopenharmony_ci{ 3548c2ecf20Sopenharmony_ci IO_COND(addr, outsl(port, src,count), mmio_outsl(addr, src, count)); 3558c2ecf20Sopenharmony_ci} 3568c2ecf20Sopenharmony_ciEXPORT_SYMBOL(iowrite8_rep); 3578c2ecf20Sopenharmony_ciEXPORT_SYMBOL(iowrite16_rep); 3588c2ecf20Sopenharmony_ciEXPORT_SYMBOL(iowrite32_rep); 3598c2ecf20Sopenharmony_ci 3608c2ecf20Sopenharmony_ci#ifdef CONFIG_HAS_IOPORT_MAP 3618c2ecf20Sopenharmony_ci/* Create a virtual mapping cookie for an IO port range */ 3628c2ecf20Sopenharmony_civoid __iomem *ioport_map(unsigned long port, unsigned int nr) 3638c2ecf20Sopenharmony_ci{ 3648c2ecf20Sopenharmony_ci if (port > PIO_MASK) 3658c2ecf20Sopenharmony_ci return NULL; 3668c2ecf20Sopenharmony_ci return (void __iomem *) (unsigned long) (port + PIO_OFFSET); 3678c2ecf20Sopenharmony_ci} 3688c2ecf20Sopenharmony_ci 3698c2ecf20Sopenharmony_civoid ioport_unmap(void __iomem *addr) 3708c2ecf20Sopenharmony_ci{ 3718c2ecf20Sopenharmony_ci /* Nothing to do */ 3728c2ecf20Sopenharmony_ci} 3738c2ecf20Sopenharmony_ciEXPORT_SYMBOL(ioport_map); 3748c2ecf20Sopenharmony_ciEXPORT_SYMBOL(ioport_unmap); 3758c2ecf20Sopenharmony_ci#endif /* CONFIG_HAS_IOPORT_MAP */ 3768c2ecf20Sopenharmony_ci 3778c2ecf20Sopenharmony_ci#ifdef CONFIG_PCI 3788c2ecf20Sopenharmony_ci/* Hide the details if this is a MMIO or PIO address space and just do what 3798c2ecf20Sopenharmony_ci * you expect in the correct way. */ 3808c2ecf20Sopenharmony_civoid pci_iounmap(struct pci_dev *dev, void __iomem * addr) 3818c2ecf20Sopenharmony_ci{ 3828c2ecf20Sopenharmony_ci IO_COND(addr, /* nothing */, iounmap(addr)); 3838c2ecf20Sopenharmony_ci} 3848c2ecf20Sopenharmony_ciEXPORT_SYMBOL(pci_iounmap); 3858c2ecf20Sopenharmony_ci#endif /* CONFIG_PCI */ 386