1 /* SPDX-License-Identifier: GPL-2.0 */
2 /* Trivial implementations of basic i/o routines. Assumes that all
3 of the hard work has been done by ioremap and ioportmap, and that
4 access to i/o space is linear. */
6 /* This file may be included multiple times. */
8 #if IO_CONCAT(__IO_PREFIX,trivial_io_bw)
9 __EXTERN_INLINE
unsigned int
10 IO_CONCAT(__IO_PREFIX
,ioread8
)(void __iomem
*a
)
12 return __kernel_ldbu(*(volatile u8 __force
*)a
);
15 __EXTERN_INLINE
unsigned int
16 IO_CONCAT(__IO_PREFIX
,ioread16
)(void __iomem
*a
)
18 return __kernel_ldwu(*(volatile u16 __force
*)a
);
22 IO_CONCAT(__IO_PREFIX
,iowrite8
)(u8 b
, void __iomem
*a
)
24 __kernel_stb(b
, *(volatile u8 __force
*)a
);
28 IO_CONCAT(__IO_PREFIX
,iowrite16
)(u16 b
, void __iomem
*a
)
30 __kernel_stw(b
, *(volatile u16 __force
*)a
);
34 #if IO_CONCAT(__IO_PREFIX,trivial_io_lq)
35 __EXTERN_INLINE
unsigned int
36 IO_CONCAT(__IO_PREFIX
,ioread32
)(void __iomem
*a
)
38 return *(volatile u32 __force
*)a
;
42 IO_CONCAT(__IO_PREFIX
,iowrite32
)(u32 b
, void __iomem
*a
)
44 *(volatile u32 __force
*)a
= b
;
48 #if IO_CONCAT(__IO_PREFIX,trivial_rw_bw) == 1
50 IO_CONCAT(__IO_PREFIX
,readb
)(const volatile void __iomem
*a
)
52 return __kernel_ldbu(*(const volatile u8 __force
*)a
);
56 IO_CONCAT(__IO_PREFIX
,readw
)(const volatile void __iomem
*a
)
58 return __kernel_ldwu(*(const volatile u16 __force
*)a
);
62 IO_CONCAT(__IO_PREFIX
,writeb
)(u8 b
, volatile void __iomem
*a
)
64 __kernel_stb(b
, *(volatile u8 __force
*)a
);
68 IO_CONCAT(__IO_PREFIX
,writew
)(u16 b
, volatile void __iomem
*a
)
70 __kernel_stw(b
, *(volatile u16 __force
*)a
);
72 #elif IO_CONCAT(__IO_PREFIX,trivial_rw_bw) == 2
74 IO_CONCAT(__IO_PREFIX
,readb
)(const volatile void __iomem
*a
)
76 void __iomem
*addr
= (void __iomem
*)a
;
77 return IO_CONCAT(__IO_PREFIX
,ioread8
)(addr
);
81 IO_CONCAT(__IO_PREFIX
,readw
)(const volatile void __iomem
*a
)
83 void __iomem
*addr
= (void __iomem
*)a
;
84 return IO_CONCAT(__IO_PREFIX
,ioread16
)(addr
);
88 IO_CONCAT(__IO_PREFIX
,writeb
)(u8 b
, volatile void __iomem
*a
)
90 void __iomem
*addr
= (void __iomem
*)a
;
91 IO_CONCAT(__IO_PREFIX
,iowrite8
)(b
, addr
);
95 IO_CONCAT(__IO_PREFIX
,writew
)(u16 b
, volatile void __iomem
*a
)
97 void __iomem
*addr
= (void __iomem
*)a
;
98 IO_CONCAT(__IO_PREFIX
,iowrite16
)(b
, addr
);
102 #if IO_CONCAT(__IO_PREFIX,trivial_rw_lq) == 1
104 IO_CONCAT(__IO_PREFIX
,readl
)(const volatile void __iomem
*a
)
106 return *(const volatile u32 __force
*)a
;
110 IO_CONCAT(__IO_PREFIX
,readq
)(const volatile void __iomem
*a
)
112 return *(const volatile u64 __force
*)a
;
116 IO_CONCAT(__IO_PREFIX
,writel
)(u32 b
, volatile void __iomem
*a
)
118 *(volatile u32 __force
*)a
= b
;
122 IO_CONCAT(__IO_PREFIX
,writeq
)(u64 b
, volatile void __iomem
*a
)
124 *(volatile u64 __force
*)a
= b
;
128 #if IO_CONCAT(__IO_PREFIX,trivial_iounmap)
129 __EXTERN_INLINE
void IO_CONCAT(__IO_PREFIX
,iounmap
)(volatile void __iomem
*a
)