1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _LINUX_IO_64_NONATOMIC_LO_HI_H_
3 #define _LINUX_IO_64_NONATOMIC_LO_HI_H_
6 #include <asm-generic/int-ll64.h>
8 static inline __u64 lo_hi_readq(const volatile void __iomem *addr)
10 const volatile u32 __iomem *p = addr;
16 return low + ((u64)high << 32);
19 static inline void lo_hi_writeq(__u64 val, volatile void __iomem *addr)
22 writel(val >> 32, addr + 4);
25 static inline __u64 lo_hi_readq_relaxed(const volatile void __iomem *addr)
27 const volatile u32 __iomem *p = addr;
30 low = readl_relaxed(p);
31 high = readl_relaxed(p + 1);
33 return low + ((u64)high << 32);
36 static inline void lo_hi_writeq_relaxed(__u64 val, volatile void __iomem *addr)
38 writel_relaxed(val, addr);
39 writel_relaxed(val >> 32, addr + 4);
43 #define readq lo_hi_readq
47 #define writeq lo_hi_writeq
51 #define readq_relaxed lo_hi_readq_relaxed
54 #ifndef writeq_relaxed
55 #define writeq_relaxed lo_hi_writeq_relaxed
58 #ifndef ioread64_lo_hi
59 #define ioread64_lo_hi ioread64_lo_hi
60 static inline u64 ioread64_lo_hi(const void __iomem *addr)
65 high = ioread32(addr + sizeof(u32));
67 return low + ((u64)high << 32);
71 #ifndef iowrite64_lo_hi
72 #define iowrite64_lo_hi iowrite64_lo_hi
73 static inline void iowrite64_lo_hi(u64 val, void __iomem *addr)
76 iowrite32(val >> 32, addr + sizeof(u32));
80 #ifndef ioread64be_lo_hi
81 #define ioread64be_lo_hi ioread64be_lo_hi
82 static inline u64 ioread64be_lo_hi(const void __iomem *addr)
86 low = ioread32be(addr + sizeof(u32));
87 high = ioread32be(addr);
89 return low + ((u64)high << 32);
93 #ifndef iowrite64be_lo_hi
94 #define iowrite64be_lo_hi iowrite64be_lo_hi
95 static inline void iowrite64be_lo_hi(u64 val, void __iomem *addr)
97 iowrite32be(val, addr + sizeof(u32));
98 iowrite32be(val >> 32, addr);
103 #define ioread64_is_nonatomic
104 #define ioread64 ioread64_lo_hi
108 #define iowrite64_is_nonatomic
109 #define iowrite64 iowrite64_lo_hi
113 #define ioread64be_is_nonatomic
114 #define ioread64be ioread64be_lo_hi
118 #define iowrite64be_is_nonatomic
119 #define iowrite64be iowrite64be_lo_hi
122 #endif /* _LINUX_IO_64_NONATOMIC_LO_HI_H_ */