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