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

[ARM] 4182/1: iop3xx: fix the ioremap implementation to not remap static ranges

Implement a custom ioremap implementation for iop3xx. This saves
establishing new mappings. It also cleans up the PCI IO resource to be a
physical address rather than a virtual address as Russell pointed out on
the original iop13xx port.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>

authored by

Dan Williams and committed by
Russell King
6df26700 ae0a846e

+92 -7
+1 -1
arch/arm/plat-iop/Makefile
··· 2 2 # Makefile for the linux kernel. 3 3 # 4 4 5 - obj-y := gpio.o i2c.o pci.o setup.o time.o 5 + obj-y := gpio.o i2c.o pci.o setup.o time.o io.o 6 6 obj-m := 7 7 obj-n := 8 8 obj- :=
+58
arch/arm/plat-iop/io.c
··· 1 + /* 2 + * iop3xx custom ioremap implementation 3 + * Copyright (c) 2006, Intel Corporation. 4 + * 5 + * This program is free software; you can redistribute it and/or modify it 6 + * under the terms and conditions of the GNU General Public License, 7 + * version 2, as published by the Free Software Foundation. 8 + * 9 + * This program is distributed in the hope it will be useful, but WITHOUT 10 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 12 + * more details. 13 + * 14 + * You should have received a copy of the GNU General Public License along with 15 + * this program; if not, write to the Free Software Foundation, Inc., 59 Temple 16 + * Place - Suite 330, Boston, MA 02111-1307 USA. 17 + * 18 + */ 19 + #include <linux/kernel.h> 20 + #include <linux/module.h> 21 + #include <asm/hardware.h> 22 + #include <asm/io.h> 23 + 24 + void * __iomem __iop3xx_ioremap(unsigned long cookie, size_t size, 25 + unsigned long flags) 26 + { 27 + void __iomem * retval; 28 + 29 + switch (cookie) { 30 + case IOP3XX_PCI_LOWER_IO_PA ... IOP3XX_PCI_UPPER_IO_PA: 31 + retval = (void *) IOP3XX_PCI_IO_PHYS_TO_VIRT(cookie); 32 + break; 33 + case IOP3XX_PERIPHERAL_PHYS_BASE ... IOP3XX_PERIPHERAL_UPPER_PA: 34 + retval = (void *) IOP3XX_PMMR_PHYS_TO_VIRT(cookie); 35 + break; 36 + default: 37 + retval = __ioremap(cookie, size, flags); 38 + } 39 + 40 + return retval; 41 + } 42 + EXPORT_SYMBOL(__iop3xx_ioremap); 43 + 44 + void __iop3xx_iounmap(void __iomem *addr) 45 + { 46 + extern void __iounmap(volatile void __iomem *addr); 47 + 48 + switch ((u32) addr) { 49 + case IOP3XX_PCI_LOWER_IO_VA ... IOP3XX_PCI_UPPER_IO_VA: 50 + case IOP3XX_PERIPHERAL_VIRT_BASE ... IOP3XX_PERIPHERAL_UPPER_VA: 51 + goto skip; 52 + } 53 + __iounmap(addr); 54 + 55 + skip: 56 + return; 57 + } 58 + EXPORT_SYMBOL(__iop3xx_iounmap);
+3 -3
arch/arm/plat-iop/pci.c
··· 196 196 if (!res) 197 197 panic("PCI: unable to alloc resources"); 198 198 199 - res[0].start = IOP3XX_PCI_LOWER_IO_VA; 200 - res[0].end = IOP3XX_PCI_LOWER_IO_VA + IOP3XX_PCI_IO_WINDOW_SIZE - 1; 199 + res[0].start = IOP3XX_PCI_LOWER_IO_PA; 200 + res[0].end = IOP3XX_PCI_LOWER_IO_PA + IOP3XX_PCI_IO_WINDOW_SIZE - 1; 201 201 res[0].name = "IOP3XX PCI I/O Space"; 202 202 res[0].flags = IORESOURCE_IO; 203 203 request_resource(&ioport_resource, &res[0]); ··· 209 209 request_resource(&iomem_resource, &res[1]); 210 210 211 211 sys->mem_offset = IOP3XX_PCI_LOWER_MEM_PA - IOP3XX_PCI_LOWER_MEM_BA; 212 - sys->io_offset = IOP3XX_PCI_LOWER_IO_VA - IOP3XX_PCI_LOWER_IO_BA; 212 + sys->io_offset = IOP3XX_PCI_LOWER_IO_PA - IOP3XX_PCI_LOWER_IO_BA; 213 213 214 214 sys->resource[0] = &res[0]; 215 215 sys->resource[1] = &res[1];
+8 -2
include/asm-arm/arch-iop32x/io.h
··· 13 13 14 14 #include <asm/hardware.h> 15 15 16 - #define IO_SPACE_LIMIT 0xffffffff 16 + extern void __iomem * __ioremap(unsigned long, size_t, unsigned long); 17 + extern void __iomem *__iop3xx_ioremap(unsigned long cookie, size_t size, 18 + unsigned long flags); 19 + extern void __iop3xx_iounmap(void __iomem *addr); 17 20 18 - #define __io(p) ((void __iomem *)(p)) 21 + #define IO_SPACE_LIMIT 0xffffffff 22 + #define __io(p) ((void __iomem *)IOP3XX_PCI_IO_PHYS_TO_VIRT(p)) 19 23 #define __mem_pci(a) (a) 20 24 25 + #define __arch_ioremap(a, s, f) __iop3xx_ioremap(a, s, f) 26 + #define __arch_iounmap(a) __iop3xx_iounmap(a) 21 27 22 28 #endif
+8 -1
include/asm-arm/arch-iop33x/io.h
··· 13 13 14 14 #include <asm/hardware.h> 15 15 16 + extern void __iomem * __ioremap(unsigned long, size_t, unsigned long); 17 + extern void __iomem *__iop3xx_ioremap(unsigned long cookie, size_t size, 18 + unsigned long flags); 19 + extern void __iop3xx_iounmap(void __iomem *addr); 20 + 16 21 #define IO_SPACE_LIMIT 0xffffffff 17 - #define __io(p) ((void __iomem *)(p)) 22 + #define __io(p) ((void __iomem *)IOP3XX_PCI_IO_PHYS_TO_VIRT(p)) 18 23 #define __mem_pci(a) (a) 19 24 25 + #define __arch_ioremap(a, s, f) __iop3xx_ioremap(a, s, f) 26 + #define __arch_iounmap(a) __iop3xx_iounmap(a) 20 27 21 28 #endif
+14
include/asm-arm/hardware/iop3xx.h
··· 37 37 #define IOP3XX_PERIPHERAL_PHYS_BASE 0xffffe000 38 38 #define IOP3XX_PERIPHERAL_VIRT_BASE 0xfeffe000 39 39 #define IOP3XX_PERIPHERAL_SIZE 0x00002000 40 + #define IOP3XX_PERIPHERAL_UPPER_PA (IOP3XX_PERIPHERAL_PHYS_BASE +\ 41 + IOP3XX_PERIPHERAL_SIZE - 1) 42 + #define IOP3XX_PERIPHERAL_UPPER_VA (IOP3XX_PERIPHERAL_VIRT_BASE +\ 43 + IOP3XX_PERIPHERAL_SIZE - 1) 44 + #define IOP3XX_PMMR_PHYS_TO_VIRT(addr) (u32) ((u32) addr -\ 45 + (IOP3XX_PERIPHERAL_PHYS_BASE\ 46 + - IOP3XX_PERIPHERAL_VIRT_BASE)) 40 47 #define IOP3XX_REG_ADDR(reg) (IOP3XX_PERIPHERAL_VIRT_BASE + (reg)) 41 48 42 49 /* Address Translation Unit */ ··· 265 258 #define IOP3XX_PCI_LOWER_IO_PA 0x90000000 266 259 #define IOP3XX_PCI_LOWER_IO_VA 0xfe000000 267 260 #define IOP3XX_PCI_LOWER_IO_BA (*IOP3XX_OIOWTVR) 261 + #define IOP3XX_PCI_UPPER_IO_PA (IOP3XX_PCI_LOWER_IO_PA +\ 262 + IOP3XX_PCI_IO_WINDOW_SIZE - 1) 263 + #define IOP3XX_PCI_UPPER_IO_VA (IOP3XX_PCI_LOWER_IO_VA +\ 264 + IOP3XX_PCI_IO_WINDOW_SIZE - 1) 265 + #define IOP3XX_PCI_IO_PHYS_TO_VIRT(addr) (((u32) addr -\ 266 + IOP3XX_PCI_LOWER_IO_PA) +\ 267 + IOP3XX_PCI_LOWER_IO_VA) 268 268 269 269 270 270 #ifndef __ASSEMBLY__