Skip to content

Commit 2c5643b

Browse files
mitakeIngo Molnar
authored andcommitted
x86: provide readq()/writeq() on 32-bit too
Impact: add new API for drivers Add implementation of readq/writeq to x86_32, and add config value to the x86 architecture to determine existence of readq/writeq. Signed-off-by: Hitoshi Mitake <[email protected]> Acked-by: Sam Ravnborg <[email protected]> Signed-off-by: Ingo Molnar <[email protected]>
1 parent ed31348 commit 2c5643b

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

arch/x86/Kconfig

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ config X86_64
1919
config X86
2020
def_bool y
2121
select HAVE_AOUT if X86_32
22+
select HAVE_READQ
23+
select HAVE_WRITEQ
2224
select HAVE_UNSTABLE_SCHED_CLOCK
2325
select HAVE_IDE
2426
select HAVE_OPROFILE

arch/x86/include/asm/io.h

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#define ARCH_HAS_IOREMAP_WC
55

66
#include <linux/compiler.h>
7+
#include <asm-generic/int-ll64.h>
78

89
#define build_mmio_read(name, size, type, reg, barrier) \
910
static inline type name(const volatile void __iomem *addr) \
@@ -57,6 +58,29 @@ build_mmio_write(__writeq, "q", unsigned long, "r", )
5758
/* Let people know we have them */
5859
#define readq readq
5960
#define writeq writeq
61+
62+
#else /* CONFIG_X86_32 from here */
63+
64+
static inline __u64 readq(const volatile void __iomem *addr)
65+
{
66+
const volatile u32 __iomem *p = addr;
67+
u32 l, h;
68+
69+
l = readl(p);
70+
h = readl(p + 1);
71+
72+
return l + ((u64)h << 32);
73+
}
74+
75+
static inline void writeq(__u64 val, volatile void __iomem *addr)
76+
{
77+
writel(val, addr);
78+
writel(val >> 32, addr+4);
79+
}
80+
81+
#define readq readq
82+
#define writeq writeq
83+
6084
#endif
6185

6286
extern int iommu_bio_merge;

0 commit comments

Comments
 (0)