Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  1) /* SPDX-License-Identifier: GPL-2.0-only */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  3)  *  Port on Texas Instruments TMS320C6x architecture
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  4)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  5)  *  Copyright (C) 2004, 2009, 2010, 2011 Texas Instruments Incorporated
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  6)  *  Author: Aurelien Jacquiot (aurelien.jacquiot@jaluna.com)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  7)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  8) #ifndef _ASM_C6X_CMPXCHG_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  9) #define _ASM_C6X_CMPXCHG_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) #include <linux/irqflags.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14)  * Misc. functions
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) static inline unsigned int __xchg(unsigned int x, volatile void *ptr, int size)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) 	unsigned int tmp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) 	unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) 	local_irq_save(flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) 	switch (size) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) 	case 1:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) 		tmp = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) 		tmp = *((unsigned char *) ptr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) 		*((unsigned char *) ptr) = (unsigned char) x;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) 	case 2:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) 		tmp = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) 		tmp = *((unsigned short *) ptr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) 		*((unsigned short *) ptr) = x;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) 	case 4:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) 		tmp = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) 		tmp = *((unsigned int *) ptr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) 		*((unsigned int *) ptr) = x;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) 	local_irq_restore(flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) 	return tmp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) #define xchg(ptr, x) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) 	((__typeof__(*(ptr)))__xchg((unsigned int)(x), (void *) (ptr), \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) 				    sizeof(*(ptr))))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) #include <asm-generic/cmpxchg-local.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51)  * cmpxchg_local and cmpxchg64_local are atomic wrt current CPU. Always make
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52)  * them available.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) #define cmpxchg_local(ptr, o, n)					\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) 	((__typeof__(*(ptr)))__cmpxchg_local_generic((ptr),		\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) 						     (unsigned long)(o), \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) 						     (unsigned long)(n), \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) 						     sizeof(*(ptr))))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) #define cmpxchg64_local(ptr, o, n) __cmpxchg64_local_generic((ptr), (o), (n))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) #include <asm-generic/cmpxchg.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) #endif /* _ASM_C6X_CMPXCHG_H */