aboutsummaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
authorScott Wood <scottwood@freescale.com>2007-08-20 13:39:51 -0400
committerPaul Mackerras <paulus@samba.org>2007-08-22 01:21:48 -0400
commit6e913c67b3eb93e2b8bc1dc0ff854f00a760f41b (patch)
treea998424f035f70a942d17f8619d711c400079fb0 /arch
parenta73ac50c4787b1b28d5c94bb18c60352f5dd7d6f (diff)
[POWERPC] bootwrapper: Add 16-bit I/O, sync(), eieio(), and barrier()
Also, include types.h from io.h, so callers don't have to. Signed-off-by: Scott Wood <scottwood@freescale.com> Acked-by: David Gibson <david@gibson.dropbear.id.au> Signed-off-by: Paul Mackerras <paulus@samba.org>
Diffstat (limited to 'arch')
-rw-r--r--arch/powerpc/boot/io.h49
1 files changed, 49 insertions, 0 deletions
diff --git a/arch/powerpc/boot/io.h b/arch/powerpc/boot/io.h
index 32974ed49e02..ccaedaec50d5 100644
--- a/arch/powerpc/boot/io.h
+++ b/arch/powerpc/boot/io.h
@@ -1,5 +1,8 @@
1#ifndef _IO_H 1#ifndef _IO_H
2#define __IO_H 2#define __IO_H
3
4#include "types.h"
5
3/* 6/*
4 * Low-level I/O routines. 7 * Low-level I/O routines.
5 * 8 *
@@ -20,6 +23,37 @@ static inline void out_8(volatile unsigned char *addr, int val)
20 : "=m" (*addr) : "r" (val)); 23 : "=m" (*addr) : "r" (val));
21} 24}
22 25
26static inline unsigned in_le16(const volatile u16 *addr)
27{
28 unsigned ret;
29
30 __asm__ __volatile__("lhbrx %0,0,%1; twi 0,%0,0; isync"
31 : "=r" (ret) : "r" (addr), "m" (*addr));
32
33 return ret;
34}
35
36static inline unsigned in_be16(const volatile u16 *addr)
37{
38 unsigned ret;
39
40 __asm__ __volatile__("lhz%U1%X1 %0,%1; twi 0,%0,0; isync"
41 : "=r" (ret) : "m" (*addr));
42 return ret;
43}
44
45static inline void out_le16(volatile u16 *addr, int val)
46{
47 __asm__ __volatile__("sthbrx %1,0,%2; sync" : "=m" (*addr)
48 : "r" (val), "r" (addr));
49}
50
51static inline void out_be16(volatile u16 *addr, int val)
52{
53 __asm__ __volatile__("sth%U0%X0 %1,%0; sync"
54 : "=m" (*addr) : "r" (val));
55}
56
23static inline unsigned in_le32(const volatile unsigned *addr) 57static inline unsigned in_le32(const volatile unsigned *addr)
24{ 58{
25 unsigned ret; 59 unsigned ret;
@@ -50,4 +84,19 @@ static inline void out_be32(volatile unsigned *addr, int val)
50 : "=m" (*addr) : "r" (val)); 84 : "=m" (*addr) : "r" (val));
51} 85}
52 86
87static inline void sync(void)
88{
89 asm volatile("sync" : : : "memory");
90}
91
92static inline void eieio(void)
93{
94 asm volatile("eieio" : : : "memory");
95}
96
97static inline void barrier(void)
98{
99 asm volatile("" : : : "memory");
100}
101
53#endif /* _IO_H */ 102#endif /* _IO_H */