Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 #ifndef _LINUX_IO_64_NONATOMIC_HI_LO_H_
0003 #define _LINUX_IO_64_NONATOMIC_HI_LO_H_
0004 
0005 #include <linux/io.h>
0006 #include <asm-generic/int-ll64.h>
0007 
0008 static inline __u64 hi_lo_readq(const volatile void __iomem *addr)
0009 {
0010     const volatile u32 __iomem *p = addr;
0011     u32 low, high;
0012 
0013     high = readl(p + 1);
0014     low = readl(p);
0015 
0016     return low + ((u64)high << 32);
0017 }
0018 
0019 static inline void hi_lo_writeq(__u64 val, volatile void __iomem *addr)
0020 {
0021     writel(val >> 32, addr + 4);
0022     writel(val, addr);
0023 }
0024 
0025 static inline __u64 hi_lo_readq_relaxed(const volatile void __iomem *addr)
0026 {
0027     const volatile u32 __iomem *p = addr;
0028     u32 low, high;
0029 
0030     high = readl_relaxed(p + 1);
0031     low = readl_relaxed(p);
0032 
0033     return low + ((u64)high << 32);
0034 }
0035 
0036 static inline void hi_lo_writeq_relaxed(__u64 val, volatile void __iomem *addr)
0037 {
0038     writel_relaxed(val >> 32, addr + 4);
0039     writel_relaxed(val, addr);
0040 }
0041 
0042 #ifndef readq
0043 #define readq hi_lo_readq
0044 #endif
0045 
0046 #ifndef writeq
0047 #define writeq hi_lo_writeq
0048 #endif
0049 
0050 #ifndef readq_relaxed
0051 #define readq_relaxed hi_lo_readq_relaxed
0052 #endif
0053 
0054 #ifndef writeq_relaxed
0055 #define writeq_relaxed hi_lo_writeq_relaxed
0056 #endif
0057 
0058 #ifndef ioread64_hi_lo
0059 #define ioread64_hi_lo ioread64_hi_lo
0060 static inline u64 ioread64_hi_lo(const void __iomem *addr)
0061 {
0062     u32 low, high;
0063 
0064     high = ioread32(addr + sizeof(u32));
0065     low = ioread32(addr);
0066 
0067     return low + ((u64)high << 32);
0068 }
0069 #endif
0070 
0071 #ifndef iowrite64_hi_lo
0072 #define iowrite64_hi_lo iowrite64_hi_lo
0073 static inline void iowrite64_hi_lo(u64 val, void __iomem *addr)
0074 {
0075     iowrite32(val >> 32, addr + sizeof(u32));
0076     iowrite32(val, addr);
0077 }
0078 #endif
0079 
0080 #ifndef ioread64be_hi_lo
0081 #define ioread64be_hi_lo ioread64be_hi_lo
0082 static inline u64 ioread64be_hi_lo(const void __iomem *addr)
0083 {
0084     u32 low, high;
0085 
0086     high = ioread32be(addr);
0087     low = ioread32be(addr + sizeof(u32));
0088 
0089     return low + ((u64)high << 32);
0090 }
0091 #endif
0092 
0093 #ifndef iowrite64be_hi_lo
0094 #define iowrite64be_hi_lo iowrite64be_hi_lo
0095 static inline void iowrite64be_hi_lo(u64 val, void __iomem *addr)
0096 {
0097     iowrite32be(val >> 32, addr);
0098     iowrite32be(val, addr + sizeof(u32));
0099 }
0100 #endif
0101 
0102 #ifndef ioread64
0103 #define ioread64_is_nonatomic
0104 #define ioread64 ioread64_hi_lo
0105 #endif
0106 
0107 #ifndef iowrite64
0108 #define iowrite64_is_nonatomic
0109 #define iowrite64 iowrite64_hi_lo
0110 #endif
0111 
0112 #ifndef ioread64be
0113 #define ioread64be_is_nonatomic
0114 #define ioread64be ioread64be_hi_lo
0115 #endif
0116 
0117 #ifndef iowrite64be
0118 #define iowrite64be_is_nonatomic
0119 #define iowrite64be iowrite64be_hi_lo
0120 #endif
0121 
0122 #endif  /* _LINUX_IO_64_NONATOMIC_HI_LO_H_ */