xref: /openbmc/linux/arch/arm64/mm/ioremap.c (revision 4e508b25)
1 // SPDX-License-Identifier: GPL-2.0-only
2 
3 #include <linux/mm.h>
4 #include <linux/io.h>
5 
6 bool ioremap_allowed(phys_addr_t phys_addr, size_t size, unsigned long prot)
7 {
8 	unsigned long last_addr = phys_addr + size - 1;
9 
10 	/* Don't allow outside PHYS_MASK */
11 	if (last_addr & ~PHYS_MASK)
12 		return false;
13 
14 	/* Don't allow RAM to be mapped. */
15 	if (WARN_ON(pfn_is_map_memory(__phys_to_pfn(phys_addr))))
16 		return false;
17 
18 	return true;
19 }
20 
21 /*
22  * Must be called after early_fixmap_init
23  */
24 void __init early_ioremap_init(void)
25 {
26 	early_ioremap_setup();
27 }
28 
29 bool arch_memremap_can_ram_remap(resource_size_t offset, size_t size,
30 				 unsigned long flags)
31 {
32 	unsigned long pfn = PHYS_PFN(offset);
33 
34 	return pfn_is_map_memory(pfn);
35 }
36