1 /* SPDX-License-Identifier: GPL-2.0-only */
3 * linux/arch/unicore32/include/asm/io.h
5 * Code specific to PKUnity SoC and UniCore ISA
7 * Copyright (C) 2001-2010 GUAN Xue-tao
9 #ifndef __UNICORE_IO_H__
10 #define __UNICORE_IO_H__
14 #include <asm/byteorder.h>
15 #include <asm/memory.h>
17 #define PCI_IOBASE PKUNITY_PCILIO_BASE
18 #include <asm-generic/io.h>
21 * __uc32_ioremap takes CPU physical address.
23 extern void __iomem *__uc32_ioremap(unsigned long, size_t);
24 extern void __uc32_iounmap(volatile void __iomem *addr);
27 * ioremap and friends.
29 * ioremap takes a PCI memory address, as specified in
30 * Documentation/driver-api/io-mapping.rst.
33 #define ioremap(cookie, size) __uc32_ioremap(cookie, size)
34 #define iounmap(cookie) __uc32_iounmap(cookie)
36 #define readb_relaxed readb
37 #define readw_relaxed readw
38 #define readl_relaxed readl
40 #define HAVE_ARCH_PIO_SIZE
41 #define PIO_OFFSET (unsigned int)(PCI_IOBASE)
42 #define PIO_MASK (unsigned int)(IO_SPACE_LIMIT)
43 #define PIO_RESERVED (PIO_OFFSET + PIO_MASK + 1)
45 #ifdef CONFIG_STRICT_DEVMEM
47 #include <linux/ioport.h>
51 * devmem_is_allowed() checks to see if /dev/mem access to a certain
52 * address is valid. The argument is a physical page number.
53 * We mimic x86 here by disallowing access to system RAM as well as
54 * device-exclusive MMIO regions. This effectively disable read()/write()
57 static inline int devmem_is_allowed(unsigned long pfn)
59 if (iomem_is_exclusive(pfn << PAGE_SHIFT))
61 if (!page_is_ram(pfn))
66 #endif /* CONFIG_STRICT_DEVMEM */
68 #endif /* __KERNEL__ */
69 #endif /* __UNICORE_IO_H__ */