xref: /linux/arch/xtensa/mm/ioremap.c (revision af1f459233d4edeef634f559539e7f4b64cb1d25)
1 // SPDX-License-Identifier: GPL-2.0-only
2 /*
3  * ioremap implementation.
4  *
5  * Copyright (C) 2015 Cadence Design Systems Inc.
6  */
7 
8 #include <linux/io.h>
9 #include <linux/pgtable.h>
10 #include <asm/cacheflush.h>
11 #include <asm/io.h>
12 
13 void __iomem *ioremap_prot(phys_addr_t phys_addr, size_t size,
14 			   unsigned long prot)
15 {
16 	unsigned long pfn = __phys_to_pfn((phys_addr));
17 	WARN_ON(pfn_valid(pfn));
18 
19 	return generic_ioremap_prot(phys_addr, size, __pgprot(prot));
20 }
21 EXPORT_SYMBOL(ioremap_prot);
22 
23 void iounmap(volatile void __iomem *addr)
24 {
25 	unsigned long va = (unsigned long) addr;
26 
27 	if ((va >= XCHAL_KIO_CACHED_VADDR &&
28 	      va - XCHAL_KIO_CACHED_VADDR < XCHAL_KIO_SIZE) ||
29 	    (va >= XCHAL_KIO_BYPASS_VADDR &&
30 	      va - XCHAL_KIO_BYPASS_VADDR < XCHAL_KIO_SIZE))
31 		return;
32 
33 	generic_iounmap(addr);
34 }
35 EXPORT_SYMBOL(iounmap);
36