blob: 1d09b2f2e0fefd9625cd7e39f92e5e40dce2152f [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
6#include <asm-generic/io.h>
7
8/* H8/300 internal I/O functions */
9static inline unsigned char ctrl_inb(unsigned long addr)
10{
11 return *(volatile unsigned char *)addr;
12}
13
14static inline unsigned short ctrl_inw(unsigned long addr)
15{
16 return *(volatile unsigned short *)addr;
17}
18
19static inline unsigned long ctrl_inl(unsigned long addr)
20{
21 return *(volatile unsigned long *)addr;
22}
23
24static inline void ctrl_outb(unsigned char b, unsigned long addr)
25{
26 *(volatile unsigned char *)addr = b;
27}
28
29static inline void ctrl_outw(unsigned short b, unsigned long addr)
30{
31 *(volatile unsigned short *)addr = b;
32}
33
34static inline void ctrl_outl(unsigned long b, unsigned long addr)
35{
36 *(volatile unsigned long *)addr = b;
37}
38
39static inline void ctrl_bclr(int b, unsigned long addr)
40{
41 if (__builtin_constant_p(b))
42 __asm__("bclr %1,%0" : : "WU"(addr), "i"(b));
43 else
44 __asm__("bclr %w1,%0" : : "WU"(addr), "r"(b));
45}
46
47static inline void ctrl_bset(int b, unsigned long addr)
48{
49 if (__builtin_constant_p(b))
50 __asm__("bset %1,%0" : : "WU"(addr), "i"(b));
51 else
52 __asm__("bset %w1,%0" : : "WU"(addr), "r"(b));
53}
54
55#endif /* __KERNEL__ */
56
57#endif /* _H8300_IO_H */