1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef __ASM_SH_BITOPS_LLSC_H
3 #define __ASM_SH_BITOPS_LLSC_H
5 static inline void set_bit(int nr
, volatile void *addr
)
8 volatile unsigned int *a
= addr
;
12 mask
= 1 << (nr
& 0x1f);
14 __asm__
__volatile__ (
16 "movli.l @%1, %0 ! set_bit \n\t"
18 "movco.l %0, @%1 \n\t"
26 static inline void clear_bit(int nr
, volatile void *addr
)
29 volatile unsigned int *a
= addr
;
33 mask
= 1 << (nr
& 0x1f);
35 __asm__
__volatile__ (
37 "movli.l @%1, %0 ! clear_bit \n\t"
39 "movco.l %0, @%1 \n\t"
42 : "r" (a
), "r" (~mask
)
47 static inline void change_bit(int nr
, volatile void *addr
)
50 volatile unsigned int *a
= addr
;
54 mask
= 1 << (nr
& 0x1f);
56 __asm__
__volatile__ (
58 "movli.l @%1, %0 ! change_bit \n\t"
60 "movco.l %0, @%1 \n\t"
68 static inline int test_and_set_bit(int nr
, volatile void *addr
)
71 volatile unsigned int *a
= addr
;
75 mask
= 1 << (nr
& 0x1f);
77 __asm__
__volatile__ (
79 "movli.l @%2, %0 ! test_and_set_bit \n\t"
82 "movco.l %0, @%2 \n\t"
85 : "=&z" (tmp
), "=&r" (retval
)
93 static inline int test_and_clear_bit(int nr
, volatile void *addr
)
96 volatile unsigned int *a
= addr
;
100 mask
= 1 << (nr
& 0x1f);
102 __asm__
__volatile__ (
104 "movli.l @%2, %0 ! test_and_clear_bit \n\t"
107 "movco.l %0, @%2 \n\t"
111 : "=&z" (tmp
), "=&r" (retval
)
112 : "r" (a
), "r" (mask
), "r" (~mask
)
119 static inline int test_and_change_bit(int nr
, volatile void *addr
)
122 volatile unsigned int *a
= addr
;
126 mask
= 1 << (nr
& 0x1f);
128 __asm__
__volatile__ (
130 "movli.l @%2, %0 ! test_and_change_bit \n\t"
133 "movco.l %0, @%2 \n\t"
137 : "=&z" (tmp
), "=&r" (retval
)
138 : "r" (a
), "r" (mask
)
145 #include <asm-generic/bitops/non-atomic.h>
147 #endif /* __ASM_SH_BITOPS_LLSC_H */