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)  * Based on arch/arm/kernel/io.c
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  4)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  5)  * Copyright (C) 2012 ARM Ltd.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  6)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  7) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  8) #include <linux/export.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  9) #include <linux/types.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) #include <linux/io.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13)  * Copy data from IO memory space to "real" memory space.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) void __memcpy_fromio(void *to, const volatile void __iomem *from, size_t count)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) 	while (count && !IS_ALIGNED((unsigned long)from, 8)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) 		*(u8 *)to = __raw_readb(from);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) 		from++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) 		to++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) 		count--;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) 	while (count >= 8) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) 		*(u64 *)to = __raw_readq(from);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) 		from += 8;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) 		to += 8;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) 		count -= 8;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) 	while (count) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) 		*(u8 *)to = __raw_readb(from);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) 		from++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) 		to++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) 		count--;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) EXPORT_SYMBOL(__memcpy_fromio);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41)  * Copy data from "real" memory space to IO memory space.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) void __memcpy_toio(volatile void __iomem *to, const void *from, size_t count)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) 	while (count && !IS_ALIGNED((unsigned long)to, 8)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) 		__raw_writeb(*(u8 *)from, to);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) 		from++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) 		to++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) 		count--;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) 	while (count >= 8) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) 		__raw_writeq(*(u64 *)from, to);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) 		from += 8;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) 		to += 8;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) 		count -= 8;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) 	while (count) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) 		__raw_writeb(*(u8 *)from, to);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) 		from++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) 		to++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) 		count--;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) EXPORT_SYMBOL(__memcpy_toio);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69)  * "memset" on IO memory space.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) void __memset_io(volatile void __iomem *dst, int c, size_t count)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) 	u64 qc = (u8)c;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) 	qc |= qc << 8;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) 	qc |= qc << 16;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) 	qc |= qc << 32;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) 	while (count && !IS_ALIGNED((unsigned long)dst, 8)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) 		__raw_writeb(c, dst);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) 		dst++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) 		count--;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) 	while (count >= 8) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) 		__raw_writeq(qc, dst);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) 		dst += 8;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) 		count -= 8;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) 	while (count) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) 		__raw_writeb(c, dst);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) 		dst++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) 		count--;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) EXPORT_SYMBOL(__memset_io);