1 /* SPDX-License-Identifier: GPL-2.0 */
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
)
16 __asm__
__volatile__("lbz%U1%X1 %0,%1; twi 0,%0,0; isync"
17 : "=r" (ret
) : "m" (*addr
));
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
)
31 __asm__
__volatile__("lhbrx %0,0,%1; twi 0,%0,0; isync"
32 : "=r" (ret
) : "r" (addr
), "m" (*addr
));
37 static inline unsigned in_be16(const volatile u16
*addr
)
41 __asm__
__volatile__("lhz%U1%X1 %0,%1; twi 0,%0,0; isync"
42 : "=r" (ret
) : "m" (*addr
));
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
)
62 __asm__
__volatile__("lwbrx %0,0,%1; twi 0,%0,0; isync"
63 : "=r" (ret
) : "r" (addr
), "m" (*addr
));
67 static inline unsigned in_be32(const volatile unsigned *addr
)
71 __asm__
__volatile__("lwz%U1%X1 %0,%1; twi 0,%0,0; isync"
72 : "=r" (ret
) : "m" (*addr
));
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");