Christoph Hellwig | 2f8e2c8 | 2015-08-28 09:27:14 +0200 | [diff] [blame] | 1 | #ifndef _LINUX_IO_64_NONATOMIC_LO_HI_H_ |
| 2 | #define _LINUX_IO_64_NONATOMIC_LO_HI_H_ |
Hitoshi Mitake | 797a796 | 2012-02-07 11:45:33 +0900 | [diff] [blame] | 3 | |
| 4 | #include <linux/io.h> |
| 5 | #include <asm-generic/int-ll64.h> |
| 6 | |
Jason Baron | 3a04417 | 2014-07-04 13:27:04 +0200 | [diff] [blame] | 7 | static inline __u64 lo_hi_readq(const volatile void __iomem *addr) |
Hitoshi Mitake | 797a796 | 2012-02-07 11:45:33 +0900 | [diff] [blame] | 8 | { |
| 9 | const volatile u32 __iomem *p = addr; |
| 10 | u32 low, high; |
| 11 | |
| 12 | low = readl(p); |
| 13 | high = readl(p + 1); |
| 14 | |
| 15 | return low + ((u64)high << 32); |
| 16 | } |
Hitoshi Mitake | 797a796 | 2012-02-07 11:45:33 +0900 | [diff] [blame] | 17 | |
Jason Baron | 3a04417 | 2014-07-04 13:27:04 +0200 | [diff] [blame] | 18 | static inline void lo_hi_writeq(__u64 val, volatile void __iomem *addr) |
Hitoshi Mitake | 797a796 | 2012-02-07 11:45:33 +0900 | [diff] [blame] | 19 | { |
| 20 | writel(val, addr); |
| 21 | writel(val >> 32, addr + 4); |
| 22 | } |
Jason Baron | 3a04417 | 2014-07-04 13:27:04 +0200 | [diff] [blame] | 23 | |
Robin Murphy | e511267 | 2016-04-26 11:38:20 +0100 | [diff] [blame] | 24 | static inline __u64 lo_hi_readq_relaxed(const volatile void __iomem *addr) |
| 25 | { |
| 26 | const volatile u32 __iomem *p = addr; |
| 27 | u32 low, high; |
| 28 | |
| 29 | low = readl_relaxed(p); |
| 30 | high = readl_relaxed(p + 1); |
| 31 | |
| 32 | return low + ((u64)high << 32); |
| 33 | } |
| 34 | |
| 35 | static inline void lo_hi_writeq_relaxed(__u64 val, volatile void __iomem *addr) |
| 36 | { |
| 37 | writel_relaxed(val, addr); |
| 38 | writel_relaxed(val >> 32, addr + 4); |
| 39 | } |
| 40 | |
Jason Baron | 3a04417 | 2014-07-04 13:27:04 +0200 | [diff] [blame] | 41 | #ifndef readq |
| 42 | #define readq lo_hi_readq |
| 43 | #endif |
| 44 | |
| 45 | #ifndef writeq |
| 46 | #define writeq lo_hi_writeq |
Hitoshi Mitake | 797a796 | 2012-02-07 11:45:33 +0900 | [diff] [blame] | 47 | #endif |
| 48 | |
Robin Murphy | e511267 | 2016-04-26 11:38:20 +0100 | [diff] [blame] | 49 | #ifndef readq_relaxed |
| 50 | #define readq_relaxed lo_hi_readq_relaxed |
| 51 | #endif |
| 52 | |
| 53 | #ifndef writeq_relaxed |
| 54 | #define writeq_relaxed lo_hi_writeq_relaxed |
| 55 | #endif |
| 56 | |
Christoph Hellwig | 2f8e2c8 | 2015-08-28 09:27:14 +0200 | [diff] [blame] | 57 | #endif /* _LINUX_IO_64_NONATOMIC_LO_HI_H_ */ |