blob: bb837cded268446bbd67d7610daf374807d502bb [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
Yoshinori Satoa7952392015-06-12 17:57:24 +090039static inline void ctrl_bclr(int b, unsigned char *addr)
Yoshinori Satod2a5f492015-05-11 02:20:06 +090040{
41 if (__builtin_constant_p(b))
Yoshinori Satoa7952392015-06-12 17:57:24 +090042 __asm__("bclr %1,%0" : "+WU"(*addr): "i"(b));
Yoshinori Satod2a5f492015-05-11 02:20:06 +090043 else
Yoshinori Satoa7952392015-06-12 17:57:24 +090044 __asm__("bclr %w1,%0" : "+WU"(*addr): "r"(b));
Yoshinori Satod2a5f492015-05-11 02:20:06 +090045}
46
Yoshinori Satoa7952392015-06-12 17:57:24 +090047static inline void ctrl_bset(int b, unsigned char *addr)
Yoshinori Satod2a5f492015-05-11 02:20:06 +090048{
49 if (__builtin_constant_p(b))
Yoshinori Satoa7952392015-06-12 17:57:24 +090050 __asm__("bset %1,%0" : "+WU"(*addr): "i"(b));
Yoshinori Satod2a5f492015-05-11 02:20:06 +090051 else
Yoshinori Satoa7952392015-06-12 17:57:24 +090052 __asm__("bset %w1,%0" : "+WU"(*addr): "r"(b));
Yoshinori Satod2a5f492015-05-11 02:20:06 +090053}
54
55#endif /* __KERNEL__ */
56
57#endif /* _H8300_IO_H */