1 /* SPDX-License-Identifier: GPL-2.0 */ 2 #ifndef __ASM_SPINLOCK_TYPES_H 3 #define __ASM_SPINLOCK_TYPES_H 4 5 #define __ARCH_SPIN_LOCK_UNLOCKED_VAL 0x1a46 6 7 #define SPINLOCK_BREAK_INSN 0x0000c006 /* break 6,6 */ 8 9 #ifndef __ASSEMBLY__ 10 11 typedef struct { 12 #ifdef CONFIG_PA20 13 volatile unsigned int slock; 14 # define __ARCH_SPIN_LOCK_UNLOCKED { __ARCH_SPIN_LOCK_UNLOCKED_VAL } 15 #else 16 volatile unsigned int lock[4]; 17 # define __ARCH_SPIN_LOCK_UNLOCKED \ 18 { { __ARCH_SPIN_LOCK_UNLOCKED_VAL, __ARCH_SPIN_LOCK_UNLOCKED_VAL, \ 19 __ARCH_SPIN_LOCK_UNLOCKED_VAL, __ARCH_SPIN_LOCK_UNLOCKED_VAL } } 20 #endif 21 } arch_spinlock_t; 22 23 24 /* counter: 25 * Unlocked : 0x0100_0000 26 * Read lock(s) : 0x00FF_FFFF to 0x01 (Multiple Readers decrement it) 27 * Write lock : 0x0, but only if prior value is "unlocked" 0x0100_0000 28 */ 29 typedef struct { 30 arch_spinlock_t lock_mutex; 31 volatile unsigned int counter; 32 } arch_rwlock_t; 33 34 #endif /* __ASSEMBLY__ */ 35 36 #define __ARCH_RW_LOCK_UNLOCKED__ 0x01000000 37 #define __ARCH_RW_LOCK_UNLOCKED { .lock_mutex = __ARCH_SPIN_LOCK_UNLOCKED, \ 38 .counter = __ARCH_RW_LOCK_UNLOCKED__ } 39 40 #endif 41