blob: f86918aed9e1181e3dc2546a1b0520f814138164 [file] [log] [blame]
Yoshinori Satod2a5f492015-05-11 02:20:06 +09001#ifndef _H8300_IO_H
2#define _H8300_IO_H
3
4#ifdef __KERNEL__
5
Guenter Roeck2b059802016-06-08 20:11:58 -07006#include <linux/types.h>
7
Yoshinori Satod2a5f492015-05-11 02:20:06 +09008/* H8/300 internal I/O functions */
Daniel Lezcano75160512015-11-08 22:55:12 +01009
10#define __raw_readb __raw_readb
11static inline u8 __raw_readb(const volatile void __iomem *addr)
Yoshinori Satod2a5f492015-05-11 02:20:06 +090012{
Daniel Lezcano75160512015-11-08 22:55:12 +010013 return *(volatile u8 *)addr;
Yoshinori Satod2a5f492015-05-11 02:20:06 +090014}
15
Daniel Lezcano75160512015-11-08 22:55:12 +010016#define __raw_readw __raw_readw
17static inline u16 __raw_readw(const volatile void __iomem *addr)
Yoshinori Satod2a5f492015-05-11 02:20:06 +090018{
Daniel Lezcano75160512015-11-08 22:55:12 +010019 return *(volatile u16 *)addr;
Yoshinori Satod2a5f492015-05-11 02:20:06 +090020}
21
Daniel Lezcano75160512015-11-08 22:55:12 +010022#define __raw_readl __raw_readl
23static inline u32 __raw_readl(const volatile void __iomem *addr)
Yoshinori Satod2a5f492015-05-11 02:20:06 +090024{
Daniel Lezcano75160512015-11-08 22:55:12 +010025 return *(volatile u32 *)addr;
Yoshinori Satod2a5f492015-05-11 02:20:06 +090026}
27
Daniel Lezcano75160512015-11-08 22:55:12 +010028#define __raw_writeb __raw_writeb
29static inline void __raw_writeb(u8 b, const volatile void __iomem *addr)
Yoshinori Satod2a5f492015-05-11 02:20:06 +090030{
Daniel Lezcano75160512015-11-08 22:55:12 +010031 *(volatile u8 *)addr = b;
Yoshinori Satod2a5f492015-05-11 02:20:06 +090032}
33
Daniel Lezcano75160512015-11-08 22:55:12 +010034#define __raw_writew __raw_writew
35static inline void __raw_writew(u16 b, const volatile void __iomem *addr)
Yoshinori Satod2a5f492015-05-11 02:20:06 +090036{
Daniel Lezcano75160512015-11-08 22:55:12 +010037 *(volatile u16 *)addr = b;
Yoshinori Satod2a5f492015-05-11 02:20:06 +090038}
39
Daniel Lezcano75160512015-11-08 22:55:12 +010040#define __raw_writel __raw_writel
41static inline void __raw_writel(u32 b, const volatile void __iomem *addr)
Yoshinori Satod2a5f492015-05-11 02:20:06 +090042{
Daniel Lezcano75160512015-11-08 22:55:12 +010043 *(volatile u32 *)addr = b;
Yoshinori Satod2a5f492015-05-11 02:20:06 +090044}
45
Daniel Lezcano75160512015-11-08 22:55:12 +010046static inline void ctrl_bclr(int b, void __iomem *addr)
Yoshinori Satod2a5f492015-05-11 02:20:06 +090047{
48 if (__builtin_constant_p(b))
Yoshinori Satodb903b42016-01-15 13:28:18 +090049 __asm__("bclr %1,%0" : "+WU"(*(u8 *)addr): "i"(b));
Yoshinori Satod2a5f492015-05-11 02:20:06 +090050 else
Yoshinori Satodb903b42016-01-15 13:28:18 +090051 __asm__("bclr %w1,%0" : "+WU"(*(u8 *)addr): "r"(b));
Yoshinori Satod2a5f492015-05-11 02:20:06 +090052}
53
Daniel Lezcano75160512015-11-08 22:55:12 +010054static inline void ctrl_bset(int b, void __iomem *addr)
Yoshinori Satod2a5f492015-05-11 02:20:06 +090055{
56 if (__builtin_constant_p(b))
Yoshinori Satodb903b42016-01-15 13:28:18 +090057 __asm__("bset %1,%0" : "+WU"(*(u8 *)addr): "i"(b));
Yoshinori Satod2a5f492015-05-11 02:20:06 +090058 else
Yoshinori Satodb903b42016-01-15 13:28:18 +090059 __asm__("bset %w1,%0" : "+WU"(*(u8 *)addr): "r"(b));
Yoshinori Satod2a5f492015-05-11 02:20:06 +090060}
61
Daniel Lezcano75160512015-11-08 22:55:12 +010062#include <asm-generic/io.h>
63
Yoshinori Satod2a5f492015-05-11 02:20:06 +090064#endif /* __KERNEL__ */
65
66#endif /* _H8300_IO_H */