File Index
Files and directories
Sign in
FILE

io-64-nonatomic-hi-lo.h

File preview with syntax highlighting.

linux-6.19.14/include/linux/io-64-nonatomic-hi-lo.h C
  1/* SPDX-License-Identifier: GPL-2.0 */
  2#ifndef _LINUX_IO_64_NONATOMIC_HI_LO_H_
  3#define _LINUX_IO_64_NONATOMIC_HI_LO_H_
  4
  5#include <linux/io.h>
  6#include <asm-generic/int-ll64.h>
  7
  8static inline __u64 hi_lo_readq(const volatile void __iomem *addr)
  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}
 18
 19static inline void hi_lo_writeq(__u64 val, volatile void __iomem *addr)
 20{
 21	writel(val >> 32, addr + 4);
 22	writel(val, addr);
 23}
 24
 25static 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
 36static 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
 42#ifndef readq
 43#define readq hi_lo_readq
 44#endif
 45
 46#ifndef writeq
 47#define writeq hi_lo_writeq
 48#endif
 49
 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
 58#ifndef ioread64_hi_lo
 59#define ioread64_hi_lo ioread64_hi_lo
 60static inline u64 ioread64_hi_lo(const void __iomem *addr)
 61{
 62	u32 low, high;
 63
 64	high = ioread32(addr + sizeof(u32));
 65	low = ioread32(addr);
 66
 67	return low + ((u64)high << 32);
 68}
 69#endif
 70
 71#ifndef iowrite64_hi_lo
 72#define iowrite64_hi_lo iowrite64_hi_lo
 73static inline void iowrite64_hi_lo(u64 val, void __iomem *addr)
 74{
 75	iowrite32(val >> 32, addr + sizeof(u32));
 76	iowrite32(val, addr);
 77}
 78#endif
 79
 80#ifndef ioread64be_hi_lo
 81#define ioread64be_hi_lo ioread64be_hi_lo
 82static inline u64 ioread64be_hi_lo(const void __iomem *addr)
 83{
 84	u32 low, high;
 85
 86	high = ioread32be(addr);
 87	low = ioread32be(addr + sizeof(u32));
 88
 89	return low + ((u64)high << 32);
 90}
 91#endif
 92
 93#ifndef iowrite64be_hi_lo
 94#define iowrite64be_hi_lo iowrite64be_hi_lo
 95static inline void iowrite64be_hi_lo(u64 val, void __iomem *addr)
 96{
 97	iowrite32be(val >> 32, addr);
 98	iowrite32be(val, addr + sizeof(u32));
 99}
100#endif
101
102#ifndef ioread64
103#define ioread64_is_nonatomic
104#if defined(CONFIG_GENERIC_IOMAP) && defined(CONFIG_64BIT)
105#define ioread64 __ioread64_hi_lo
106#else
107#define ioread64 ioread64_hi_lo
108#endif
109#endif
110
111#ifndef iowrite64
112#define iowrite64_is_nonatomic
113#if defined(CONFIG_GENERIC_IOMAP) && defined(CONFIG_64BIT)
114#define iowrite64 __iowrite64_hi_lo
115#else
116#define iowrite64 iowrite64_hi_lo
117#endif
118#endif
119
120#ifndef ioread64be
121#define ioread64be_is_nonatomic
122#if defined(CONFIG_GENERIC_IOMAP) && defined(CONFIG_64BIT)
123#define ioread64be __ioread64be_hi_lo
124#else
125#define ioread64be ioread64be_hi_lo
126#endif
127#endif
128
129#ifndef iowrite64be
130#define iowrite64be_is_nonatomic
131#if defined(CONFIG_GENERIC_IOMAP) && defined(CONFIG_64BIT)
132#define iowrite64be __iowrite64be_hi_lo
133#else
134#define iowrite64be iowrite64be_hi_lo
135#endif
136#endif
137
138#endif	/* _LINUX_IO_64_NONATOMIC_HI_LO_H_ */
~/ Read-only file preview.