Merge tag 'sched-urgent-2020-12-27' of git://git.kernel.org/pub/scm/linux/kernel...
[linux/fpc-iii.git] / arch / powerpc / boot / io.h
blob5c6f90c34923f1a1d2a16c425caf53cb0cbd60a8
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _IO_H
3 #define _IO_H
5 #include "types.h"
7 /*
8 * Low-level I/O routines.
10 * Copied from <file:arch/powerpc/include/asm/io.h> (which has no copyright)
12 static inline int in_8(const volatile unsigned char *addr)
14 int ret;
16 __asm__ __volatile__("lbz%U1%X1 %0,%1; twi 0,%0,0; isync"
17 : "=r" (ret) : "m" (*addr));
18 return ret;
21 static inline void out_8(volatile unsigned char *addr, int val)
23 __asm__ __volatile__("stb%U0%X0 %1,%0; sync"
24 : "=m" (*addr) : "r" (val));
27 static inline unsigned in_le16(const volatile u16 *addr)
29 unsigned ret;
31 __asm__ __volatile__("lhbrx %0,0,%1; twi 0,%0,0; isync"
32 : "=r" (ret) : "r" (addr), "m" (*addr));
34 return ret;
37 static inline unsigned in_be16(const volatile u16 *addr)
39 unsigned ret;
41 __asm__ __volatile__("lhz%U1%X1 %0,%1; twi 0,%0,0; isync"
42 : "=r" (ret) : "m" (*addr));
43 return ret;
46 static inline void out_le16(volatile u16 *addr, int val)
48 __asm__ __volatile__("sthbrx %1,0,%2; sync" : "=m" (*addr)
49 : "r" (val), "r" (addr));
52 static inline void out_be16(volatile u16 *addr, int val)
54 __asm__ __volatile__("sth%U0%X0 %1,%0; sync"
55 : "=m" (*addr) : "r" (val));
58 static inline unsigned in_le32(const volatile unsigned *addr)
60 unsigned ret;
62 __asm__ __volatile__("lwbrx %0,0,%1; twi 0,%0,0; isync"
63 : "=r" (ret) : "r" (addr), "m" (*addr));
64 return ret;
67 static inline unsigned in_be32(const volatile unsigned *addr)
69 unsigned ret;
71 __asm__ __volatile__("lwz%U1%X1 %0,%1; twi 0,%0,0; isync"
72 : "=r" (ret) : "m" (*addr));
73 return ret;
76 static inline void out_le32(volatile unsigned *addr, int val)
78 __asm__ __volatile__("stwbrx %1,0,%2; sync" : "=m" (*addr)
79 : "r" (val), "r" (addr));
82 static inline void out_be32(volatile unsigned *addr, int val)
84 __asm__ __volatile__("stw%U0%X0 %1,%0; sync"
85 : "=m" (*addr) : "r" (val));
88 static inline void sync(void)
90 asm volatile("sync" : : : "memory");
93 static inline void eieio(void)
95 asm volatile("eieio" : : : "memory");
98 static inline void barrier(void)
100 asm volatile("" : : : "memory");
103 #endif /* _IO_H */