1 /* Trivial implementations of basic i/o routines. Assumes that all
2 of the hard work has been done by ioremap and ioportmap, and that
3 access to i/o space is linear. */
5 /* This file may be included multiple times. */
7 #if IO_CONCAT(__IO_PREFIX,trivial_io_bw)
8 __EXTERN_INLINE
unsigned int
9 IO_CONCAT(__IO_PREFIX
,ioread8
)(void __iomem
*a
)
11 return __kernel_ldbu(*(volatile u8 __force
*)a
);
14 __EXTERN_INLINE
unsigned int
15 IO_CONCAT(__IO_PREFIX
,ioread16
)(void __iomem
*a
)
17 return __kernel_ldwu(*(volatile u16 __force
*)a
);
21 IO_CONCAT(__IO_PREFIX
,iowrite8
)(u8 b
, void __iomem
*a
)
23 __kernel_stb(b
, *(volatile u8 __force
*)a
);
27 IO_CONCAT(__IO_PREFIX
,iowrite16
)(u16 b
, void __iomem
*a
)
29 __kernel_stw(b
, *(volatile u16 __force
*)a
);
33 #if IO_CONCAT(__IO_PREFIX,trivial_io_lq)
34 __EXTERN_INLINE
unsigned int
35 IO_CONCAT(__IO_PREFIX
,ioread32
)(void __iomem
*a
)
37 return *(volatile u32 __force
*)a
;
41 IO_CONCAT(__IO_PREFIX
,iowrite32
)(u32 b
, void __iomem
*a
)
43 *(volatile u32 __force
*)a
= b
;
47 #if IO_CONCAT(__IO_PREFIX,trivial_rw_bw) == 1
49 IO_CONCAT(__IO_PREFIX
,readb
)(const volatile void __iomem
*a
)
51 return __kernel_ldbu(*(const volatile u8 __force
*)a
);
55 IO_CONCAT(__IO_PREFIX
,readw
)(const volatile void __iomem
*a
)
57 return __kernel_ldwu(*(const volatile u16 __force
*)a
);
61 IO_CONCAT(__IO_PREFIX
,writeb
)(u8 b
, volatile void __iomem
*a
)
63 __kernel_stb(b
, *(volatile u8 __force
*)a
);
67 IO_CONCAT(__IO_PREFIX
,writew
)(u16 b
, volatile void __iomem
*a
)
69 __kernel_stw(b
, *(volatile u16 __force
*)a
);
71 #elif IO_CONCAT(__IO_PREFIX,trivial_rw_bw) == 2
73 IO_CONCAT(__IO_PREFIX
,readb
)(const volatile void __iomem
*a
)
75 void __iomem
*addr
= (void __iomem
*)a
;
76 return IO_CONCAT(__IO_PREFIX
,ioread8
)(addr
);
80 IO_CONCAT(__IO_PREFIX
,readw
)(const volatile void __iomem
*a
)
82 void __iomem
*addr
= (void __iomem
*)a
;
83 return IO_CONCAT(__IO_PREFIX
,ioread16
)(addr
);
87 IO_CONCAT(__IO_PREFIX
,writeb
)(u8 b
, volatile void __iomem
*a
)
89 void __iomem
*addr
= (void __iomem
*)a
;
90 IO_CONCAT(__IO_PREFIX
,iowrite8
)(b
, addr
);
94 IO_CONCAT(__IO_PREFIX
,writew
)(u16 b
, volatile void __iomem
*a
)
96 void __iomem
*addr
= (void __iomem
*)a
;
97 IO_CONCAT(__IO_PREFIX
,iowrite16
)(b
, addr
);
101 #if IO_CONCAT(__IO_PREFIX,trivial_rw_lq) == 1
103 IO_CONCAT(__IO_PREFIX
,readl
)(const volatile void __iomem
*a
)
105 return *(const volatile u32 __force
*)a
;
109 IO_CONCAT(__IO_PREFIX
,readq
)(const volatile void __iomem
*a
)
111 return *(const volatile u64 __force
*)a
;
115 IO_CONCAT(__IO_PREFIX
,writel
)(u32 b
, volatile void __iomem
*a
)
117 *(volatile u32 __force
*)a
= b
;
121 IO_CONCAT(__IO_PREFIX
,writeq
)(u64 b
, volatile void __iomem
*a
)
123 *(volatile u64 __force
*)a
= b
;
127 #if IO_CONCAT(__IO_PREFIX,trivial_iounmap)
128 __EXTERN_INLINE
void IO_CONCAT(__IO_PREFIX
,iounmap
)(volatile void __iomem
*a
)