io.h 1.4 KB
Newer Older
Y
Yoshinori Sato 已提交
1 2 3 4 5
#ifndef _H8300_IO_H
#define _H8300_IO_H

#ifdef __KERNEL__

6 7
#include <linux/types.h>

Y
Yoshinori Sato 已提交
8
/* H8/300 internal I/O functions */
9 10 11

#define __raw_readb __raw_readb
static inline u8 __raw_readb(const volatile void __iomem *addr)
Y
Yoshinori Sato 已提交
12
{
13
	return *(volatile u8 *)addr;
Y
Yoshinori Sato 已提交
14 15
}

16 17
#define __raw_readw __raw_readw
static inline u16 __raw_readw(const volatile void __iomem *addr)
Y
Yoshinori Sato 已提交
18
{
19
	return *(volatile u16 *)addr;
Y
Yoshinori Sato 已提交
20 21
}

22 23
#define __raw_readl __raw_readl
static inline u32  __raw_readl(const volatile void __iomem *addr)
Y
Yoshinori Sato 已提交
24
{
25
	return *(volatile u32 *)addr;
Y
Yoshinori Sato 已提交
26 27
}

28 29
#define __raw_writeb __raw_writeb
static inline void __raw_writeb(u8 b, const volatile void __iomem *addr)
Y
Yoshinori Sato 已提交
30
{
31
	*(volatile u8 *)addr = b;
Y
Yoshinori Sato 已提交
32 33
}

34 35
#define __raw_writew __raw_writew
static inline void __raw_writew(u16 b, const volatile void __iomem *addr)
Y
Yoshinori Sato 已提交
36
{
37
	*(volatile u16 *)addr = b;
Y
Yoshinori Sato 已提交
38 39
}

40 41
#define __raw_writel __raw_writel
static inline void __raw_writel(u32 b, const volatile void __iomem *addr)
Y
Yoshinori Sato 已提交
42
{
43
	*(volatile u32 *)addr = b;
Y
Yoshinori Sato 已提交
44 45
}

46
static inline void ctrl_bclr(int b, void __iomem *addr)
Y
Yoshinori Sato 已提交
47 48
{
	if (__builtin_constant_p(b))
Y
Yoshinori Sato 已提交
49
		__asm__("bclr %1,%0" : "+WU"(*(u8 *)addr): "i"(b));
Y
Yoshinori Sato 已提交
50
	else
Y
Yoshinori Sato 已提交
51
		__asm__("bclr %w1,%0" : "+WU"(*(u8 *)addr): "r"(b));
Y
Yoshinori Sato 已提交
52 53
}

54
static inline void ctrl_bset(int b, void __iomem *addr)
Y
Yoshinori Sato 已提交
55 56
{
	if (__builtin_constant_p(b))
Y
Yoshinori Sato 已提交
57
		__asm__("bset %1,%0" : "+WU"(*(u8 *)addr): "i"(b));
Y
Yoshinori Sato 已提交
58
	else
Y
Yoshinori Sato 已提交
59
		__asm__("bset %w1,%0" : "+WU"(*(u8 *)addr): "r"(b));
Y
Yoshinori Sato 已提交
60 61
}

62 63
#include <asm-generic/io.h>

Y
Yoshinori Sato 已提交
64 65 66
#endif /* __KERNEL__ */

#endif /* _H8300_IO_H */