Yoshinori Sato | d2a5f49 | 2015-05-11 02:20:06 +0900 | [diff] [blame] | 1 | #ifndef _H8300_IO_H |
| 2 | #define _H8300_IO_H |
| 3 | |
| 4 | #ifdef __KERNEL__ |
| 5 | |
Guenter Roeck | 2b05980 | 2016-06-08 20:11:58 -0700 | [diff] [blame] | 6 | #include <linux/types.h> |
| 7 | |
Yoshinori Sato | d2a5f49 | 2015-05-11 02:20:06 +0900 | [diff] [blame] | 8 | /* H8/300 internal I/O functions */ |
Daniel Lezcano | 7516051 | 2015-11-08 22:55:12 +0100 | [diff] [blame] | 9 | |
| 10 | #define __raw_readb __raw_readb |
| 11 | static inline u8 __raw_readb(const volatile void __iomem *addr) |
Yoshinori Sato | d2a5f49 | 2015-05-11 02:20:06 +0900 | [diff] [blame] | 12 | { |
Daniel Lezcano | 7516051 | 2015-11-08 22:55:12 +0100 | [diff] [blame] | 13 | return *(volatile u8 *)addr; |
Yoshinori Sato | d2a5f49 | 2015-05-11 02:20:06 +0900 | [diff] [blame] | 14 | } |
| 15 | |
Daniel Lezcano | 7516051 | 2015-11-08 22:55:12 +0100 | [diff] [blame] | 16 | #define __raw_readw __raw_readw |
| 17 | static inline u16 __raw_readw(const volatile void __iomem *addr) |
Yoshinori Sato | d2a5f49 | 2015-05-11 02:20:06 +0900 | [diff] [blame] | 18 | { |
Daniel Lezcano | 7516051 | 2015-11-08 22:55:12 +0100 | [diff] [blame] | 19 | return *(volatile u16 *)addr; |
Yoshinori Sato | d2a5f49 | 2015-05-11 02:20:06 +0900 | [diff] [blame] | 20 | } |
| 21 | |
Daniel Lezcano | 7516051 | 2015-11-08 22:55:12 +0100 | [diff] [blame] | 22 | #define __raw_readl __raw_readl |
| 23 | static inline u32 __raw_readl(const volatile void __iomem *addr) |
Yoshinori Sato | d2a5f49 | 2015-05-11 02:20:06 +0900 | [diff] [blame] | 24 | { |
Daniel Lezcano | 7516051 | 2015-11-08 22:55:12 +0100 | [diff] [blame] | 25 | return *(volatile u32 *)addr; |
Yoshinori Sato | d2a5f49 | 2015-05-11 02:20:06 +0900 | [diff] [blame] | 26 | } |
| 27 | |
Daniel Lezcano | 7516051 | 2015-11-08 22:55:12 +0100 | [diff] [blame] | 28 | #define __raw_writeb __raw_writeb |
| 29 | static inline void __raw_writeb(u8 b, const volatile void __iomem *addr) |
Yoshinori Sato | d2a5f49 | 2015-05-11 02:20:06 +0900 | [diff] [blame] | 30 | { |
Daniel Lezcano | 7516051 | 2015-11-08 22:55:12 +0100 | [diff] [blame] | 31 | *(volatile u8 *)addr = b; |
Yoshinori Sato | d2a5f49 | 2015-05-11 02:20:06 +0900 | [diff] [blame] | 32 | } |
| 33 | |
Daniel Lezcano | 7516051 | 2015-11-08 22:55:12 +0100 | [diff] [blame] | 34 | #define __raw_writew __raw_writew |
| 35 | static inline void __raw_writew(u16 b, const volatile void __iomem *addr) |
Yoshinori Sato | d2a5f49 | 2015-05-11 02:20:06 +0900 | [diff] [blame] | 36 | { |
Daniel Lezcano | 7516051 | 2015-11-08 22:55:12 +0100 | [diff] [blame] | 37 | *(volatile u16 *)addr = b; |
Yoshinori Sato | d2a5f49 | 2015-05-11 02:20:06 +0900 | [diff] [blame] | 38 | } |
| 39 | |
Daniel Lezcano | 7516051 | 2015-11-08 22:55:12 +0100 | [diff] [blame] | 40 | #define __raw_writel __raw_writel |
| 41 | static inline void __raw_writel(u32 b, const volatile void __iomem *addr) |
Yoshinori Sato | d2a5f49 | 2015-05-11 02:20:06 +0900 | [diff] [blame] | 42 | { |
Daniel Lezcano | 7516051 | 2015-11-08 22:55:12 +0100 | [diff] [blame] | 43 | *(volatile u32 *)addr = b; |
Yoshinori Sato | d2a5f49 | 2015-05-11 02:20:06 +0900 | [diff] [blame] | 44 | } |
| 45 | |
Daniel Lezcano | 7516051 | 2015-11-08 22:55:12 +0100 | [diff] [blame] | 46 | static inline void ctrl_bclr(int b, void __iomem *addr) |
Yoshinori Sato | d2a5f49 | 2015-05-11 02:20:06 +0900 | [diff] [blame] | 47 | { |
| 48 | if (__builtin_constant_p(b)) |
Yoshinori Sato | db903b4 | 2016-01-15 13:28:18 +0900 | [diff] [blame] | 49 | __asm__("bclr %1,%0" : "+WU"(*(u8 *)addr): "i"(b)); |
Yoshinori Sato | d2a5f49 | 2015-05-11 02:20:06 +0900 | [diff] [blame] | 50 | else |
Yoshinori Sato | db903b4 | 2016-01-15 13:28:18 +0900 | [diff] [blame] | 51 | __asm__("bclr %w1,%0" : "+WU"(*(u8 *)addr): "r"(b)); |
Yoshinori Sato | d2a5f49 | 2015-05-11 02:20:06 +0900 | [diff] [blame] | 52 | } |
| 53 | |
Daniel Lezcano | 7516051 | 2015-11-08 22:55:12 +0100 | [diff] [blame] | 54 | static inline void ctrl_bset(int b, void __iomem *addr) |
Yoshinori Sato | d2a5f49 | 2015-05-11 02:20:06 +0900 | [diff] [blame] | 55 | { |
| 56 | if (__builtin_constant_p(b)) |
Yoshinori Sato | db903b4 | 2016-01-15 13:28:18 +0900 | [diff] [blame] | 57 | __asm__("bset %1,%0" : "+WU"(*(u8 *)addr): "i"(b)); |
Yoshinori Sato | d2a5f49 | 2015-05-11 02:20:06 +0900 | [diff] [blame] | 58 | else |
Yoshinori Sato | db903b4 | 2016-01-15 13:28:18 +0900 | [diff] [blame] | 59 | __asm__("bset %w1,%0" : "+WU"(*(u8 *)addr): "r"(b)); |
Yoshinori Sato | d2a5f49 | 2015-05-11 02:20:06 +0900 | [diff] [blame] | 60 | } |
| 61 | |
Daniel Lezcano | 7516051 | 2015-11-08 22:55:12 +0100 | [diff] [blame] | 62 | #include <asm-generic/io.h> |
| 63 | |
Yoshinori Sato | d2a5f49 | 2015-05-11 02:20:06 +0900 | [diff] [blame] | 64 | #endif /* __KERNEL__ */ |
| 65 | |
| 66 | #endif /* _H8300_IO_H */ |