Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

microblaze: Use asm-generic/io.h

Using generic io.h will narrow down code duplication
in architecture io.h.

- define PCI_IOBASE
- remove non existing pci_io_base extern

Signed-off-by: Michal Simek <michal.simek@xilinx.com>

+19 -294
+13 -289
arch/microblaze/include/asm/io.h
··· 15 15 #include <asm/page.h> 16 16 #include <linux/types.h> 17 17 #include <linux/mm.h> /* Get struct page {...} */ 18 - #include <asm-generic/iomap.h> 19 18 20 19 #ifndef CONFIG_PCI 21 20 #define _IO_BASE 0 ··· 24 25 #define _IO_BASE isa_io_base 25 26 #define _ISA_MEM_BASE isa_mem_base 26 27 #define PCI_DRAM_OFFSET pci_dram_offset 27 - #endif 28 + struct pci_dev; 29 + extern void pci_iounmap(struct pci_dev *dev, void __iomem *); 30 + #define pci_iounmap pci_iounmap 28 31 29 32 extern unsigned long isa_io_base; 30 - extern unsigned long pci_io_base; 31 33 extern unsigned long pci_dram_offset; 32 - 33 34 extern resource_size_t isa_mem_base; 35 + #endif 34 36 37 + #define PCI_IOBASE ((void __iomem *)_IO_BASE) 35 38 #define IO_SPACE_LIMIT (0xFFFFFFFF) 36 39 37 - /* the following is needed to support PCI with some drivers */ 38 - 39 - #define mmiowb() 40 - 41 - static inline unsigned char __raw_readb(const volatile void __iomem *addr) 42 - { 43 - return *(volatile unsigned char __force *)addr; 44 - } 45 - static inline unsigned short __raw_readw(const volatile void __iomem *addr) 46 - { 47 - return *(volatile unsigned short __force *)addr; 48 - } 49 - static inline unsigned int __raw_readl(const volatile void __iomem *addr) 50 - { 51 - return *(volatile unsigned int __force *)addr; 52 - } 53 - static inline unsigned long __raw_readq(const volatile void __iomem *addr) 54 - { 55 - return *(volatile unsigned long __force *)addr; 56 - } 57 - static inline void __raw_writeb(unsigned char v, volatile void __iomem *addr) 58 - { 59 - *(volatile unsigned char __force *)addr = v; 60 - } 61 - static inline void __raw_writew(unsigned short v, volatile void __iomem *addr) 62 - { 63 - *(volatile unsigned short __force *)addr = v; 64 - } 65 - static inline void __raw_writel(unsigned int v, volatile void __iomem *addr) 66 - { 67 - *(volatile unsigned int __force *)addr = v; 68 - } 69 - static inline void __raw_writeq(unsigned long v, volatile void __iomem *addr) 70 - { 71 - *(volatile unsigned long __force *)addr = v; 72 - } 73 - 74 - /* 75 - * read (readb, readw, readl, readq) and write (writeb, writew, 76 - * writel, writeq) accessors are for PCI and thus little endian. 77 - * Linux 2.4 for Microblaze had this wrong. 78 - */ 79 - static inline unsigned char readb(const volatile void __iomem *addr) 80 - { 81 - return *(volatile unsigned char __force *)addr; 82 - } 83 - static inline unsigned short readw(const volatile void __iomem *addr) 84 - { 85 - return le16_to_cpu(*(volatile unsigned short __force *)addr); 86 - } 87 - static inline unsigned int readl(const volatile void __iomem *addr) 88 - { 89 - return le32_to_cpu(*(volatile unsigned int __force *)addr); 90 - } 91 - #define readq readq 92 - static inline u64 readq(const volatile void __iomem *addr) 93 - { 94 - return le64_to_cpu(__raw_readq(addr)); 95 - } 96 - static inline void writeb(unsigned char v, volatile void __iomem *addr) 97 - { 98 - *(volatile unsigned char __force *)addr = v; 99 - } 100 - static inline void writew(unsigned short v, volatile void __iomem *addr) 101 - { 102 - *(volatile unsigned short __force *)addr = cpu_to_le16(v); 103 - } 104 - static inline void writel(unsigned int v, volatile void __iomem *addr) 105 - { 106 - *(volatile unsigned int __force *)addr = cpu_to_le32(v); 107 - } 108 - #define writeq(b, addr) __raw_writeq(cpu_to_le64(b), addr) 109 - 110 - /* ioread and iowrite variants. thease are for now same as __raw_ 111 - * variants of accessors. we might check for endianess in the feature 112 - */ 113 - #define ioread8(addr) __raw_readb((u8 *)(addr)) 114 - #define ioread16(addr) __raw_readw((u16 *)(addr)) 115 - #define ioread32(addr) __raw_readl((u32 *)(addr)) 116 - #define iowrite8(v, addr) __raw_writeb((u8)(v), (u8 *)(addr)) 117 - #define iowrite16(v, addr) __raw_writew((u16)(v), (u16 *)(addr)) 118 - #define iowrite32(v, addr) __raw_writel((u32)(v), (u32 *)(addr)) 119 - 120 - #define ioread16be(addr) __raw_readw((u16 *)(addr)) 121 - #define ioread32be(addr) __raw_readl((u32 *)(addr)) 122 - #define iowrite16be(v, addr) __raw_writew((u16)(v), (u16 *)(addr)) 123 - #define iowrite32be(v, addr) __raw_writel((u32)(v), (u32 *)(addr)) 124 - 125 - /* These are the definitions for the x86 IO instructions 126 - * inb/inw/inl/outb/outw/outl, the "string" versions 127 - * insb/insw/insl/outsb/outsw/outsl, and the "pausing" versions 128 - * inb_p/inw_p/... 129 - * The macros don't do byte-swapping. 130 - */ 131 - #define inb(port) readb((u8 *)((unsigned long)(port))) 132 - #define outb(val, port) writeb((val), (u8 *)((unsigned long)(port))) 133 - #define inw(port) readw((u16 *)((unsigned long)(port))) 134 - #define outw(val, port) writew((val), (u16 *)((unsigned long)(port))) 135 - #define inl(port) readl((u32 *)((unsigned long)(port))) 136 - #define outl(val, port) writel((val), (u32 *)((unsigned long)(port))) 137 - 138 - #define inb_p(port) inb((port)) 139 - #define outb_p(val, port) outb((val), (port)) 140 - #define inw_p(port) inw((port)) 141 - #define outw_p(val, port) outw((val), (port)) 142 - #define inl_p(port) inl((port)) 143 - #define outl_p(val, port) outl((val), (port)) 144 - 145 - #define memset_io(a, b, c) memset((void *)(a), (b), (c)) 146 - #define memcpy_fromio(a, b, c) memcpy((a), (void *)(b), (c)) 147 - #define memcpy_toio(a, b, c) memcpy((void *)(a), (b), (c)) 148 - 149 40 #ifdef CONFIG_MMU 150 - 151 - #define phys_to_virt(addr) ((void *)__phys_to_virt(addr)) 152 - #define virt_to_phys(addr) ((unsigned long)__virt_to_phys(addr)) 153 - #define virt_to_bus(addr) ((unsigned long)__virt_to_phys(addr)) 154 - 155 41 #define page_to_bus(page) (page_to_phys(page)) 156 - #define bus_to_virt(addr) (phys_to_virt(addr)) 157 42 158 43 extern void iounmap(void __iomem *addr); 159 - /*extern void *__ioremap(phys_addr_t address, unsigned long size, 160 - unsigned long flags);*/ 44 + 161 45 extern void __iomem *ioremap(phys_addr_t address, unsigned long size); 162 - #define ioremap_writethrough(addr, size) ioremap((addr), (size)) 163 - #define ioremap_nocache(addr, size) ioremap((addr), (size)) 164 - #define ioremap_fullcache(addr, size) ioremap((addr), (size)) 165 - 166 - #else /* CONFIG_MMU */ 167 - 168 - /** 169 - * virt_to_phys - map virtual addresses to physical 170 - * @address: address to remap 171 - * 172 - * The returned physical address is the physical (CPU) mapping for 173 - * the memory address given. It is only valid to use this function on 174 - * addresses directly mapped or allocated via kmalloc. 175 - * 176 - * This function does not give bus mappings for DMA transfers. In 177 - * almost all conceivable cases a device driver should not be using 178 - * this function 179 - */ 180 - static inline unsigned long __iomem virt_to_phys(volatile void *address) 181 - { 182 - return __pa((unsigned long)address); 183 - } 184 - 185 - #define virt_to_bus virt_to_phys 186 - 187 - /** 188 - * phys_to_virt - map physical address to virtual 189 - * @address: address to remap 190 - * 191 - * The returned virtual address is a current CPU mapping for 192 - * the memory address given. It is only valid to use this function on 193 - * addresses that have a kernel mapping 194 - * 195 - * This function does not handle bus mappings for DMA transfers. In 196 - * almost all conceivable cases a device driver should not be using 197 - * this function 198 - */ 199 - static inline void *phys_to_virt(unsigned long address) 200 - { 201 - return (void *)__va(address); 202 - } 203 - 204 - #define bus_to_virt(a) phys_to_virt(a) 205 - 206 - static inline void __iomem *__ioremap(phys_addr_t address, unsigned long size, 207 - unsigned long flags) 208 - { 209 - return (void *)address; 210 - } 211 - 212 - #define ioremap(physaddr, size) ((void __iomem *)(unsigned long)(physaddr)) 213 - #define iounmap(addr) ((void)0) 214 - #define ioremap_nocache(physaddr, size) ioremap(physaddr, size) 46 + #define ioremap_writethrough(addr, size) ioremap((addr), (size)) 47 + #define ioremap_nocache(addr, size) ioremap((addr), (size)) 48 + #define ioremap_fullcache(addr, size) ioremap((addr), (size)) 49 + #define ioremap_wc(addr, size) ioremap((addr), (size)) 215 50 216 51 #endif /* CONFIG_MMU */ 217 52 218 - /* 219 - * Convert a physical pointer to a virtual kernel pointer for /dev/mem 220 - * access 221 - */ 222 - #define xlate_dev_mem_ptr(p) __va(p) 223 - 224 - /* 225 - * Convert a virtual cached pointer to an uncached pointer 226 - */ 227 - #define xlate_dev_kmem_ptr(p) p 228 - 229 - /* 230 - * Big Endian 231 - */ 53 + /* Big Endian */ 232 54 #define out_be32(a, v) __raw_writel((v), (void __iomem __force *)(a)) 233 55 #define out_be16(a, v) __raw_writew((v), (a)) 234 56 ··· 59 239 #define writel_be(v, a) out_be32((__force unsigned *)a, v) 60 240 #define readl_be(a) in_be32((__force unsigned *)a) 61 241 62 - /* 63 - * Little endian 64 - */ 65 - 242 + /* Little endian */ 66 243 #define out_le32(a, v) __raw_writel(__cpu_to_le32(v), (a)) 67 244 #define out_le16(a, v) __raw_writew(__cpu_to_le16(v), (a)) 68 245 ··· 70 253 #define out_8(a, v) __raw_writeb((v), (a)) 71 254 #define in_8(a) __raw_readb(a) 72 255 73 - #define mmiowb() 74 - 75 - #define ioport_map(port, nr) ((void __iomem *)(port)) 76 - #define ioport_unmap(addr) 77 - 78 - /* from asm-generic/io.h */ 79 - #ifndef insb 80 - static inline void insb(unsigned long addr, void *buffer, int count) 81 - { 82 - if (count) { 83 - u8 *buf = buffer; 84 - do { 85 - u8 x = inb(addr); 86 - *buf++ = x; 87 - } while (--count); 88 - } 89 - } 90 - #endif 91 - 92 - #ifndef insw 93 - static inline void insw(unsigned long addr, void *buffer, int count) 94 - { 95 - if (count) { 96 - u16 *buf = buffer; 97 - do { 98 - u16 x = inw(addr); 99 - *buf++ = x; 100 - } while (--count); 101 - } 102 - } 103 - #endif 104 - 105 - #ifndef insl 106 - static inline void insl(unsigned long addr, void *buffer, int count) 107 - { 108 - if (count) { 109 - u32 *buf = buffer; 110 - do { 111 - u32 x = inl(addr); 112 - *buf++ = x; 113 - } while (--count); 114 - } 115 - } 116 - #endif 117 - 118 - #ifndef outsb 119 - static inline void outsb(unsigned long addr, const void *buffer, int count) 120 - { 121 - if (count) { 122 - const u8 *buf = buffer; 123 - do { 124 - outb(*buf++, addr); 125 - } while (--count); 126 - } 127 - } 128 - #endif 129 - 130 - #ifndef outsw 131 - static inline void outsw(unsigned long addr, const void *buffer, int count) 132 - { 133 - if (count) { 134 - const u16 *buf = buffer; 135 - do { 136 - outw(*buf++, addr); 137 - } while (--count); 138 - } 139 - } 140 - #endif 141 - 142 - #ifndef outsl 143 - static inline void outsl(unsigned long addr, const void *buffer, int count) 144 - { 145 - if (count) { 146 - const u32 *buf = buffer; 147 - do { 148 - outl(*buf++, addr); 149 - } while (--count); 150 - } 151 - } 152 - #endif 153 - 154 - #define ioread8_rep(p, dst, count) \ 155 - insb((unsigned long) (p), (dst), (count)) 156 - #define ioread16_rep(p, dst, count) \ 157 - insw((unsigned long) (p), (dst), (count)) 158 - #define ioread32_rep(p, dst, count) \ 159 - insl((unsigned long) (p), (dst), (count)) 160 - 161 - #define iowrite8_rep(p, src, count) \ 162 - outsb((unsigned long) (p), (src), (count)) 163 - #define iowrite16_rep(p, src, count) \ 164 - outsw((unsigned long) (p), (src), (count)) 165 - #define iowrite32_rep(p, src, count) \ 166 - outsl((unsigned long) (p), (src), (count)) 256 + #include <asm-generic/io.h> 167 257 168 258 #define readb_relaxed readb 169 259 #define readw_relaxed readw
+1 -1
arch/microblaze/kernel/signal.c
··· 216 216 /* MS: I need add offset in page */ 217 217 address += ((unsigned long)frame->tramp) & ~PAGE_MASK; 218 218 /* MS address is virtual */ 219 - address = virt_to_phys(address); 219 + address = __virt_to_phys(address); 220 220 invalidate_icache_range(address, address + 8); 221 221 flush_dcache_range(address, address + 8); 222 222 }
+1 -1
arch/microblaze/mm/consistent.c
··· 117 117 ret = (void *)va; 118 118 119 119 /* This gives us the real physical address of the first page. */ 120 - *dma_handle = pa = virt_to_bus((void *)vaddr); 120 + *dma_handle = pa = __virt_to_phys(vaddr); 121 121 #endif 122 122 123 123 /*
+1 -1
arch/microblaze/mm/init.c
··· 369 369 if (initrd_start) { 370 370 unsigned long size; 371 371 size = initrd_end - initrd_start; 372 - memblock_reserve(virt_to_phys(initrd_start), size); 372 + memblock_reserve(__virt_to_phys(initrd_start), size); 373 373 } 374 374 #endif /* CONFIG_BLK_DEV_INITRD */ 375 375
+3 -2
arch/microblaze/mm/pgtable.c
··· 69 69 * 70 70 * However, allow remap of rootfs: TBD 71 71 */ 72 + 72 73 if (mem_init_done && 73 74 p >= memory_start && p < virt_to_phys(high_memory) && 74 - !(p >= virt_to_phys((unsigned long)&__bss_stop) && 75 - p < virt_to_phys((unsigned long)__bss_stop))) { 75 + !(p >= __virt_to_phys((phys_addr_t)__bss_stop) && 76 + p < __virt_to_phys((phys_addr_t)__bss_stop))) { 76 77 pr_warn("__ioremap(): phys addr "PTE_FMT" is RAM lr %pf\n", 77 78 (unsigned long)p, __builtin_return_address(0)); 78 79 return NULL;