GuanXuetao | 96cf518 | 2011-01-15 18:23:09 +0800 | [diff] [blame] | 1 | /* |
| 2 | * linux/arch/unicore32/include/asm/io.h |
| 3 | * |
| 4 | * Code specific to PKUnity SoC and UniCore ISA |
| 5 | * |
| 6 | * Copyright (C) 2001-2010 GUAN Xue-tao |
| 7 | * |
| 8 | * This program is free software; you can redistribute it and/or modify |
| 9 | * it under the terms of the GNU General Public License version 2 as |
| 10 | * published by the Free Software Foundation. |
| 11 | */ |
| 12 | #ifndef __UNICORE_IO_H__ |
| 13 | #define __UNICORE_IO_H__ |
| 14 | |
| 15 | #ifdef __KERNEL__ |
| 16 | |
| 17 | #include <asm/byteorder.h> |
| 18 | #include <asm/memory.h> |
GuanXuetao | 96cf518 | 2011-01-15 18:23:09 +0800 | [diff] [blame] | 19 | |
GuanXuetao | 1cf46c4 | 2011-03-04 18:07:48 +0800 | [diff] [blame] | 20 | #define PCI_IOBASE PKUNITY_PCILIO_BASE |
GuanXuetao | 96cf518 | 2011-01-15 18:23:09 +0800 | [diff] [blame] | 21 | #include <asm-generic/io.h> |
| 22 | |
| 23 | /* |
| 24 | * __uc32_ioremap and __uc32_ioremap_cached takes CPU physical address. |
| 25 | */ |
| 26 | extern void __iomem *__uc32_ioremap(unsigned long, size_t); |
| 27 | extern void __iomem *__uc32_ioremap_cached(unsigned long, size_t); |
| 28 | extern void __uc32_iounmap(volatile void __iomem *addr); |
| 29 | |
| 30 | /* |
| 31 | * ioremap and friends. |
| 32 | * |
| 33 | * ioremap takes a PCI memory address, as specified in |
Paul Bolle | 395cf96 | 2011-08-15 02:02:26 +0200 | [diff] [blame] | 34 | * Documentation/io-mapping.txt. |
GuanXuetao | 96cf518 | 2011-01-15 18:23:09 +0800 | [diff] [blame] | 35 | * |
| 36 | */ |
| 37 | #define ioremap(cookie, size) __uc32_ioremap(cookie, size) |
| 38 | #define ioremap_cached(cookie, size) __uc32_ioremap_cached(cookie, size) |
Guan Xuetao | a50e421 | 2011-08-18 15:38:05 +0800 | [diff] [blame] | 39 | #define ioremap_nocache(cookie, size) __uc32_ioremap(cookie, size) |
GuanXuetao | 96cf518 | 2011-01-15 18:23:09 +0800 | [diff] [blame] | 40 | #define iounmap(cookie) __uc32_iounmap(cookie) |
| 41 | |
Chen Gang | 312c6df | 2014-05-03 09:06:28 +0800 | [diff] [blame] | 42 | #define readb_relaxed readb |
| 43 | #define readw_relaxed readw |
| 44 | #define readl_relaxed readl |
| 45 | |
GuanXuetao | 4fde87c | 2011-02-27 12:46:06 +0800 | [diff] [blame] | 46 | #define HAVE_ARCH_PIO_SIZE |
| 47 | #define PIO_OFFSET (unsigned int)(PCI_IOBASE) |
| 48 | #define PIO_MASK (unsigned int)(IO_SPACE_LIMIT) |
| 49 | #define PIO_RESERVED (PIO_OFFSET + PIO_MASK + 1) |
| 50 | |
Chen Gang | 8a01659 | 2014-04-15 09:21:30 +0800 | [diff] [blame] | 51 | #ifdef CONFIG_STRICT_DEVMEM |
| 52 | |
| 53 | #include <linux/ioport.h> |
| 54 | #include <linux/mm.h> |
| 55 | |
| 56 | /* |
| 57 | * devmem_is_allowed() checks to see if /dev/mem access to a certain |
| 58 | * address is valid. The argument is a physical page number. |
| 59 | * We mimic x86 here by disallowing access to system RAM as well as |
| 60 | * device-exclusive MMIO regions. This effectively disable read()/write() |
| 61 | * on /dev/mem. |
| 62 | */ |
| 63 | static inline int devmem_is_allowed(unsigned long pfn) |
| 64 | { |
| 65 | if (iomem_is_exclusive(pfn << PAGE_SHIFT)) |
| 66 | return 0; |
| 67 | if (!page_is_ram(pfn)) |
| 68 | return 1; |
| 69 | return 0; |
| 70 | } |
| 71 | |
| 72 | #endif /* CONFIG_STRICT_DEVMEM */ |
| 73 | |
GuanXuetao | 96cf518 | 2011-01-15 18:23:09 +0800 | [diff] [blame] | 74 | #endif /* __KERNEL__ */ |
| 75 | #endif /* __UNICORE_IO_H__ */ |