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
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  2) #include <linux/ioport.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  3) #include <asm/e820/api.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  4) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  5) static void resource_clip(struct resource *res, resource_size_t start,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  6) 			  resource_size_t end)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  7) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  8) 	resource_size_t low = 0, high = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  9) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) 	if (res->end < start || res->start > end)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) 		return;		/* no conflict */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) 	if (res->start < start)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) 		low = start - res->start;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) 	if (res->end > end)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) 		high = res->end - end;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) 	/* Keep the area above or below the conflict, whichever is larger */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) 	if (low > high)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) 		res->end = start - 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) 	else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) 		res->start = end + 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) static void remove_e820_regions(struct resource *avail)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) 	int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) 	struct e820_entry *entry;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) 	for (i = 0; i < e820_table->nr_entries; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) 		entry = &e820_table->entries[i];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) 		resource_clip(avail, entry->addr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) 			      entry->addr + entry->size - 1);
^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) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) void arch_remove_reservations(struct resource *avail)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) 	 * Trim out BIOS area (high 2MB) and E820 regions. We do not remove
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) 	 * the low 1MB unconditionally, as this area is needed for some ISA
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) 	 * cards requiring a memory range, e.g. the i82365 PCMCIA controller.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) 	if (avail->flags & IORESOURCE_MEM) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) 		resource_clip(avail, BIOS_ROM_BASE, BIOS_ROM_END);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) 		remove_e820_regions(avail);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) }