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

Merge branch 'cleanup/io-pci' into next/cleanups

From Rob Herring <robherring2@gmail.com>:

This is the 2nd part of mach/io.h removals. This series removes io.h on
platforms with PCI by creating a fixed virtual I/O mapping and a common
__io() macro.

This version has changed a bit to accommodate Tegra converting its PCIe
host to a platform driver. Now the virtual space is only reserved during
early boot before .map_io() is called. The mapping is not created until
calling pci_ioremap_io which can be done at any point after vmalloc is
initialized.

I've gone back to fixed 64K windows for each PCI bus. This allows
removing all the i/o resource setup from the individually platforms and
placing it within the common ARM PCI code.

I've only tested versatilepb under qemu (with the model hacked up to
actually enable i/o space), so any testing is appreciated. iop3xx and
mv78xx0 have some risk of breaking as the PCI bus addresses are moved
to 0 from matching the cpu host bus addesss.

* cleanup/io-pci:
ARM: iop3xx: use fixed PCI i/o mapping
ARM: mv78xx0: use fixed pci i/o mapping
ARM: iop13xx: use fixed PCI i/o mapping
iop13xx: use more regular PCI I/O space handling
ARM: orion5x: use fixed PCI i/o mapping
ARM: kirkwood: use fixed PCI i/o mapping
ARM: dove: use fixed PCI i/o mapping
ARM: footbridge: use fixed PCI i/o mapping
ARM: shark: use fixed PCI i/o mapping
ARM: integrator: remove trailing whitespace on pci_v3.c
ARM: integrator: use fixed PCI i/o mapping
ARM: tegra: use fixed PCI i/o mapping
ARM: versatile: use fixed PCI i/o mapping
ARM: move PCI i/o resource setup into common code
ARM: Add fixed PCI i/o mapping
i2c: iop3xx: use standard gpiolib functions
i2c: iop3xx: clean-up trailing whitespace

Signed-off-by: Arnd Bergmann <arnd@arndb.de>

+416 -912
+3
Documentation/arm/memory.txt
··· 51 51 ff000000 ffbfffff Reserved for future expansion of DMA 52 52 mapping region. 53 53 54 + fee00000 feffffff Mapping of PCI I/O space. This is a static 55 + mapping within the vmalloc space. 56 + 54 57 VMALLOC_START VMALLOC_END-1 vmalloc() / ioremap() space. 55 58 Memory returned by vmalloc/ioremap will 56 59 be dynamically placed in this region.
+1 -12
arch/arm/Kconfig
··· 285 285 select GENERIC_CLOCKEVENTS 286 286 select PLAT_VERSATILE 287 287 select PLAT_VERSATILE_FPGA_IRQ 288 - select NEED_MACH_IO_H 289 288 select NEED_MACH_MEMORY_H 290 289 select SPARSE_IRQ 291 290 select MULTI_IRQ_HANDLER ··· 317 318 select ICST 318 319 select GENERIC_CLOCKEVENTS 319 320 select ARCH_WANT_OPTIONAL_GPIOLIB 320 - select NEED_MACH_IO_H if PCI 321 321 select PLAT_VERSATILE 322 322 select PLAT_VERSATILE_CLOCK 323 323 select PLAT_VERSATILE_CLCD ··· 460 462 select FOOTBRIDGE 461 463 select GENERIC_CLOCKEVENTS 462 464 select HAVE_IDE 463 - select NEED_MACH_IO_H 465 + select NEED_MACH_IO_H if !MMU 464 466 select NEED_MACH_MEMORY_H 465 467 help 466 468 Support for systems based on the DC21285 companion chip ··· 517 519 select PCI 518 520 select ARCH_SUPPORTS_MSI 519 521 select VMSPLIT_1G 520 - select NEED_MACH_IO_H 521 522 select NEED_MACH_MEMORY_H 522 523 select NEED_RET_TO_USER 523 524 help ··· 526 529 bool "IOP32x-based" 527 530 depends on MMU 528 531 select CPU_XSCALE 529 - select NEED_MACH_IO_H 530 532 select NEED_RET_TO_USER 531 533 select PLAT_IOP 532 534 select PCI ··· 538 542 bool "IOP33x-based" 539 543 depends on MMU 540 544 select CPU_XSCALE 541 - select NEED_MACH_IO_H 542 545 select NEED_RET_TO_USER 543 546 select PLAT_IOP 544 547 select PCI ··· 577 582 select PCI 578 583 select ARCH_REQUIRE_GPIOLIB 579 584 select GENERIC_CLOCKEVENTS 580 - select NEED_MACH_IO_H 581 585 select PLAT_ORION 582 586 help 583 587 Support for the Marvell Dove SoC 88AP510 ··· 587 593 select PCI 588 594 select ARCH_REQUIRE_GPIOLIB 589 595 select GENERIC_CLOCKEVENTS 590 - select NEED_MACH_IO_H 591 596 select PLAT_ORION 592 597 help 593 598 Support for the following Marvell Kirkwood series SoCs: ··· 613 620 select PCI 614 621 select ARCH_REQUIRE_GPIOLIB 615 622 select GENERIC_CLOCKEVENTS 616 - select NEED_MACH_IO_H 617 623 select PLAT_ORION 618 624 help 619 625 Support for the following Marvell MV78xx0 series SoCs: ··· 625 633 select PCI 626 634 select ARCH_REQUIRE_GPIOLIB 627 635 select GENERIC_CLOCKEVENTS 628 - select NEED_MACH_IO_H 629 636 select PLAT_ORION 630 637 help 631 638 Support for the following Marvell Orion 5x series SoCs: ··· 680 689 select HAVE_CLK 681 690 select HAVE_SMP 682 691 select MIGHT_HAVE_CACHE_L2X0 683 - select NEED_MACH_IO_H if PCI 684 692 select ARCH_HAS_CPUFREQ 685 693 select USE_OF 686 694 help ··· 908 918 select PCI 909 919 select ARCH_USES_GETTIMEOFFSET 910 920 select NEED_MACH_MEMORY_H 911 - select NEED_MACH_IO_H 912 921 help 913 922 Support for the StrongARM based Digital DNARD machine, also known 914 923 as "Shark" (<http://www.shark-linux.de/shark.html>).
+1 -11
arch/arm/include/asm/hardware/iop3xx.h
··· 217 217 #define IOP3XX_PCI_LOWER_MEM_PA 0x80000000 218 218 #define IOP3XX_PCI_MEM_WINDOW_SIZE 0x08000000 219 219 220 - #define IOP3XX_PCI_IO_WINDOW_SIZE 0x00010000 221 220 #define IOP3XX_PCI_LOWER_IO_PA 0x90000000 222 - #define IOP3XX_PCI_LOWER_IO_VA 0xfe000000 223 - #define IOP3XX_PCI_LOWER_IO_BA 0x90000000 224 - #define IOP3XX_PCI_UPPER_IO_PA (IOP3XX_PCI_LOWER_IO_PA +\ 225 - IOP3XX_PCI_IO_WINDOW_SIZE - 1) 226 - #define IOP3XX_PCI_UPPER_IO_VA (IOP3XX_PCI_LOWER_IO_VA +\ 227 - IOP3XX_PCI_IO_WINDOW_SIZE - 1) 228 - #define IOP3XX_PCI_IO_PHYS_TO_VIRT(addr) (((u32) (addr) -\ 229 - IOP3XX_PCI_LOWER_IO_PA) +\ 230 - IOP3XX_PCI_LOWER_IO_VA) 231 - 221 + #define IOP3XX_PCI_LOWER_IO_BA 0x00000000 232 222 233 223 #ifndef __ASSEMBLY__ 234 224
+8
arch/arm/include/asm/io.h
··· 113 113 #define __iowmb() do { } while (0) 114 114 #endif 115 115 116 + /* PCI fixed i/o mapping */ 117 + #define PCI_IO_VIRT_BASE 0xfee00000 118 + 119 + extern int pci_ioremap_io(unsigned int offset, phys_addr_t phys_addr); 120 + 116 121 /* 117 122 * Now, pick up the machine-defined IO definitions 118 123 */ 119 124 #ifdef CONFIG_NEED_MACH_IO_H 120 125 #include <mach/io.h> 126 + #elif defined(CONFIG_PCI) 127 + #define IO_SPACE_LIMIT ((resource_size_t)0xfffff) 128 + #define __io(a) __typesafe_io(PCI_IO_VIRT_BASE + ((a) & IO_SPACE_LIMIT)) 121 129 #else 122 130 #define __io(a) __typesafe_io((a) & IO_SPACE_LIMIT) 123 131 #endif
+8
arch/arm/include/asm/mach/map.h
··· 9 9 * 10 10 * Page table mapping constructs and function prototypes 11 11 */ 12 + #ifndef __ASM_MACH_MAP_H 13 + #define __ASM_MACH_MAP_H 14 + 12 15 #include <asm/io.h> 13 16 14 17 struct map_desc { ··· 37 34 38 35 #ifdef CONFIG_MMU 39 36 extern void iotable_init(struct map_desc *, int); 37 + extern void vm_reserve_area_early(unsigned long addr, unsigned long size, 38 + void *caller); 40 39 41 40 struct mem_type; 42 41 extern const struct mem_type *get_mem_type(unsigned int type); ··· 49 44 const struct mem_type *mtype); 50 45 #else 51 46 #define iotable_init(map,num) do { } while (0) 47 + #define vm_reserve_area_early(a,s,c) do { } while (0) 48 + #endif 49 + 52 50 #endif
+13
arch/arm/include/asm/mach/pci.h
··· 11 11 #ifndef __ASM_MACH_PCI_H 12 12 #define __ASM_MACH_PCI_H 13 13 14 + #include <linux/ioport.h> 15 + 14 16 struct pci_sys_data; 15 17 struct pci_ops; 16 18 struct pci_bus; ··· 44 42 unsigned long io_offset; /* bus->cpu IO mapping offset */ 45 43 struct pci_bus *bus; /* PCI bus */ 46 44 struct list_head resources; /* root bus resources (apertures) */ 45 + struct resource io_res; 46 + char io_res_name[12]; 47 47 /* Bridge swizzling */ 48 48 u8 (*swizzle)(struct pci_dev *, u8 *); 49 49 /* IRQ mapping */ ··· 57 53 * Call this with your hw_pci struct to initialise the PCI system. 58 54 */ 59 55 void pci_common_init(struct hw_pci *); 56 + 57 + /* 58 + * Setup early fixed I/O mapping. 59 + */ 60 + #if defined(CONFIG_PCI) 61 + extern void pci_map_io_early(unsigned long pfn); 62 + #else 63 + static inline void pci_map_io_early(unsigned long pfn) {} 64 + #endif 60 65 61 66 /* 62 67 * PCI controllers
+49 -5
arch/arm/kernel/bios32.c
··· 13 13 #include <linux/io.h> 14 14 15 15 #include <asm/mach-types.h> 16 + #include <asm/mach/map.h> 16 17 #include <asm/mach/pci.h> 17 18 18 19 static int debug_pci; ··· 424 423 return irq; 425 424 } 426 425 426 + static int __init pcibios_init_resources(int busnr, struct pci_sys_data *sys) 427 + { 428 + int ret; 429 + struct pci_host_bridge_window *window; 430 + 431 + if (list_empty(&sys->resources)) { 432 + pci_add_resource_offset(&sys->resources, 433 + &iomem_resource, sys->mem_offset); 434 + } 435 + 436 + list_for_each_entry(window, &sys->resources, list) { 437 + if (resource_type(window->res) == IORESOURCE_IO) 438 + return 0; 439 + } 440 + 441 + sys->io_res.start = (busnr * SZ_64K) ? : pcibios_min_io; 442 + sys->io_res.end = (busnr + 1) * SZ_64K - 1; 443 + sys->io_res.flags = IORESOURCE_IO; 444 + sys->io_res.name = sys->io_res_name; 445 + sprintf(sys->io_res_name, "PCI%d I/O", busnr); 446 + 447 + ret = request_resource(&ioport_resource, &sys->io_res); 448 + if (ret) { 449 + pr_err("PCI: unable to allocate I/O port region (%d)\n", ret); 450 + return ret; 451 + } 452 + pci_add_resource_offset(&sys->resources, &sys->io_res, 453 + sys->io_offset); 454 + 455 + return 0; 456 + } 457 + 427 458 static void __init pcibios_init_hw(struct hw_pci *hw, struct list_head *head) 428 459 { 429 460 struct pci_sys_data *sys = NULL; ··· 478 445 ret = hw->setup(nr, sys); 479 446 480 447 if (ret > 0) { 481 - if (list_empty(&sys->resources)) { 482 - pci_add_resource_offset(&sys->resources, 483 - &ioport_resource, sys->io_offset); 484 - pci_add_resource_offset(&sys->resources, 485 - &iomem_resource, sys->mem_offset); 448 + ret = pcibios_init_resources(nr, sys); 449 + if (ret) { 450 + kfree(sys); 451 + break; 486 452 } 487 453 488 454 if (hw->scan) ··· 658 626 return -EAGAIN; 659 627 660 628 return 0; 629 + } 630 + 631 + void __init pci_map_io_early(unsigned long pfn) 632 + { 633 + struct map_desc pci_io_desc = { 634 + .virtual = PCI_IO_VIRT_BASE, 635 + .type = MT_DEVICE, 636 + .length = SZ_64K, 637 + }; 638 + 639 + pci_io_desc.pfn = pfn; 640 + iotable_init(&pci_io_desc, 1); 661 641 }
-10
arch/arm/mach-dove/common.c
··· 49 49 .pfn = __phys_to_pfn(DOVE_NB_REGS_PHYS_BASE), 50 50 .length = DOVE_NB_REGS_SIZE, 51 51 .type = MT_DEVICE, 52 - }, { 53 - .virtual = DOVE_PCIE0_IO_VIRT_BASE, 54 - .pfn = __phys_to_pfn(DOVE_PCIE0_IO_PHYS_BASE), 55 - .length = DOVE_PCIE0_IO_SIZE, 56 - .type = MT_DEVICE, 57 - }, { 58 - .virtual = DOVE_PCIE1_IO_VIRT_BASE, 59 - .pfn = __phys_to_pfn(DOVE_PCIE1_IO_PHYS_BASE), 60 - .length = DOVE_PCIE1_IO_SIZE, 61 - .type = MT_DEVICE, 62 52 }, 63 53 }; 64 54
+3 -5
arch/arm/mach-dove/include/mach/dove.h
··· 50 50 #define DOVE_NB_REGS_SIZE SZ_8M 51 51 52 52 #define DOVE_PCIE0_IO_PHYS_BASE 0xf2000000 53 - #define DOVE_PCIE0_IO_VIRT_BASE 0xfee00000 54 53 #define DOVE_PCIE0_IO_BUS_BASE 0x00000000 55 - #define DOVE_PCIE0_IO_SIZE SZ_1M 54 + #define DOVE_PCIE0_IO_SIZE SZ_64K 56 55 57 56 #define DOVE_PCIE1_IO_PHYS_BASE 0xf2100000 58 - #define DOVE_PCIE1_IO_VIRT_BASE 0xfef00000 59 - #define DOVE_PCIE1_IO_BUS_BASE 0x00100000 60 - #define DOVE_PCIE1_IO_SIZE SZ_1M 57 + #define DOVE_PCIE1_IO_BUS_BASE 0x00010000 58 + #define DOVE_PCIE1_IO_SIZE SZ_64K 61 59 62 60 /* 63 61 * Dove Core Registers Map
-19
arch/arm/mach-dove/include/mach/io.h
··· 1 - /* 2 - * arch/arm/mach-dove/include/mach/io.h 3 - * 4 - * This file is licensed under the terms of the GNU General Public 5 - * License version 2. This program is licensed "as is" without any 6 - * warranty of any kind, whether express or implied. 7 - */ 8 - 9 - #ifndef __ASM_ARCH_IO_H 10 - #define __ASM_ARCH_IO_H 11 - 12 - #include "dove.h" 13 - 14 - #define IO_SPACE_LIMIT 0xffffffff 15 - 16 - #define __io(a) ((void __iomem *)(((a) - DOVE_PCIE0_IO_BUS_BASE) + \ 17 - DOVE_PCIE0_IO_VIRT_BASE)) 18 - 19 - #endif
+14 -29
arch/arm/mach-dove/pcie.c
··· 26 26 u8 root_bus_nr; 27 27 void __iomem *base; 28 28 spinlock_t conf_lock; 29 - char io_space_name[16]; 30 29 char mem_space_name[16]; 31 - struct resource res[2]; 30 + struct resource res; 32 31 }; 33 32 34 33 static struct pcie_port pcie_port[2]; ··· 52 53 53 54 orion_pcie_setup(pp->base); 54 55 55 - /* 56 - * IORESOURCE_IO 57 - */ 58 - snprintf(pp->io_space_name, sizeof(pp->io_space_name), 59 - "PCIe %d I/O", pp->index); 60 - pp->io_space_name[sizeof(pp->io_space_name) - 1] = 0; 61 - pp->res[0].name = pp->io_space_name; 62 - if (pp->index == 0) { 63 - pp->res[0].start = DOVE_PCIE0_IO_PHYS_BASE; 64 - pp->res[0].end = pp->res[0].start + DOVE_PCIE0_IO_SIZE - 1; 65 - } else { 66 - pp->res[0].start = DOVE_PCIE1_IO_PHYS_BASE; 67 - pp->res[0].end = pp->res[0].start + DOVE_PCIE1_IO_SIZE - 1; 68 - } 69 - pp->res[0].flags = IORESOURCE_IO; 70 - if (request_resource(&ioport_resource, &pp->res[0])) 71 - panic("Request PCIe IO resource failed\n"); 72 - pci_add_resource_offset(&sys->resources, &pp->res[0], sys->io_offset); 56 + if (pp->index == 0) 57 + pci_ioremap_io(sys->busnr * SZ_64K, DOVE_PCIE0_IO_PHYS_BASE); 58 + else 59 + pci_ioremap_io(sys->busnr * SZ_64K, DOVE_PCIE1_IO_PHYS_BASE); 73 60 74 61 /* 75 62 * IORESOURCE_MEM ··· 63 78 snprintf(pp->mem_space_name, sizeof(pp->mem_space_name), 64 79 "PCIe %d MEM", pp->index); 65 80 pp->mem_space_name[sizeof(pp->mem_space_name) - 1] = 0; 66 - pp->res[1].name = pp->mem_space_name; 81 + pp->res.name = pp->mem_space_name; 67 82 if (pp->index == 0) { 68 - pp->res[1].start = DOVE_PCIE0_MEM_PHYS_BASE; 69 - pp->res[1].end = pp->res[1].start + DOVE_PCIE0_MEM_SIZE - 1; 83 + pp->res.start = DOVE_PCIE0_MEM_PHYS_BASE; 84 + pp->res.end = pp->res.start + DOVE_PCIE0_MEM_SIZE - 1; 70 85 } else { 71 - pp->res[1].start = DOVE_PCIE1_MEM_PHYS_BASE; 72 - pp->res[1].end = pp->res[1].start + DOVE_PCIE1_MEM_SIZE - 1; 86 + pp->res.start = DOVE_PCIE1_MEM_PHYS_BASE; 87 + pp->res.end = pp->res.start + DOVE_PCIE1_MEM_SIZE - 1; 73 88 } 74 - pp->res[1].flags = IORESOURCE_MEM; 75 - if (request_resource(&iomem_resource, &pp->res[1])) 89 + pp->res.flags = IORESOURCE_MEM; 90 + if (request_resource(&iomem_resource, &pp->res)) 76 91 panic("Request PCIe Memory resource failed\n"); 77 - pci_add_resource_offset(&sys->resources, &pp->res[1], sys->mem_offset); 92 + pci_add_resource_offset(&sys->resources, &pp->res, sys->mem_offset); 78 93 79 94 return 1; 80 95 } ··· 195 210 pp->root_bus_nr = -1; 196 211 pp->base = (void __iomem *)base; 197 212 spin_lock_init(&pp->conf_lock); 198 - memset(pp->res, 0, sizeof(pp->res)); 213 + memset(&pp->res, 0, sizeof(pp->res)); 199 214 } else { 200 215 printk(KERN_INFO "link down, ignoring\n"); 201 216 }
+5 -7
arch/arm/mach-footbridge/common.c
··· 15 15 #include <linux/init.h> 16 16 #include <linux/io.h> 17 17 #include <linux/spinlock.h> 18 - 18 + 19 19 #include <asm/pgtable.h> 20 20 #include <asm/page.h> 21 21 #include <asm/irq.h> ··· 26 26 27 27 #include <asm/mach/irq.h> 28 28 #include <asm/mach/map.h> 29 + #include <asm/mach/pci.h> 29 30 30 31 #include "common.h" 31 32 ··· 176 175 .pfn = __phys_to_pfn(DC21285_PCI_IACK), 177 176 .length = PCIIACK_SIZE, 178 177 .type = MT_DEVICE, 179 - }, { 180 - .virtual = PCIO_BASE, 181 - .pfn = __phys_to_pfn(DC21285_PCI_IO), 182 - .length = PCIO_SIZE, 183 - .type = MT_DEVICE, 184 178 }, 185 179 #endif 186 180 }; ··· 192 196 * Now, work out what we've got to map in addition on this 193 197 * platform. 194 198 */ 195 - if (footbridge_cfn_mode()) 199 + if (footbridge_cfn_mode()) { 196 200 iotable_init(ebsa285_host_io_desc, ARRAY_SIZE(ebsa285_host_io_desc)); 201 + pci_map_io_early(__phys_to_pfn(DC21285_PCI_IO)); 202 + } 197 203 } 198 204 199 205 void footbridge_restart(char mode, const char *cmd)
+4 -12
arch/arm/mach-footbridge/dc21285.c
··· 276 276 277 277 sys->mem_offset = DC21285_PCI_MEM; 278 278 279 - pci_add_resource_offset(&sys->resources, 280 - &ioport_resource, sys->io_offset); 279 + pci_ioremap_io(0, DC21285_PCI_IO); 280 + 281 281 pci_add_resource_offset(&sys->resources, &res[0], sys->mem_offset); 282 282 pci_add_resource_offset(&sys->resources, &res[1], sys->mem_offset); 283 283 ··· 298 298 mem_size = (unsigned int)high_memory - PAGE_OFFSET; 299 299 for (mem_mask = 0x00100000; mem_mask < 0x10000000; mem_mask <<= 1) 300 300 if (mem_mask >= mem_size) 301 - break; 301 + break; 302 302 303 303 /* 304 304 * These registers need to be set up whether we're the ··· 350 350 "PCI data parity", NULL); 351 351 352 352 if (cfn_mode) { 353 - static struct resource csrio; 354 - 355 - csrio.flags = IORESOURCE_IO; 356 - csrio.name = "Footbridge"; 357 - 358 - allocate_resource(&ioport_resource, &csrio, 128, 359 - 0xff00, 0xffff, 128, NULL, NULL); 360 - 361 353 /* 362 354 * Map our SDRAM at a known address in PCI space, just in case 363 355 * the firmware had other ideas. Using a nonzero base is ··· 357 365 * in the range 0x000a0000 to 0x000c0000. (eg, S3 cards). 358 366 */ 359 367 *CSR_PCICSRBASE = 0xf4000000; 360 - *CSR_PCICSRIOBASE = csrio.start; 368 + *CSR_PCICSRIOBASE = 0; 361 369 *CSR_PCISDRAMBASE = __virt_to_bus(PAGE_OFFSET); 362 370 *CSR_PCIROMBASE = 0; 363 371 *CSR_PCICMD = PCI_COMMAND_MEMORY | PCI_COMMAND_MASTER |
+2 -1
arch/arm/mach-footbridge/include/mach/debug-macro.S
··· 17 17 /* For NetWinder debugging */ 18 18 .macro addruart, rp, rv, tmp 19 19 mov \rp, #0x000003f8 20 - orr \rv, \rp, #0xff000000 @ virtual 20 + orr \rv, \rp, #0xfe000000 @ virtual 21 + orr \rv, \rv, #0x00e00000 @ virtual 21 22 orr \rp, \rp, #0x7c000000 @ physical 22 23 .endm 23 24
+2 -10
arch/arm/mach-footbridge/include/mach/io.h
··· 14 14 #ifndef __ASM_ARM_ARCH_IO_H 15 15 #define __ASM_ARM_ARCH_IO_H 16 16 17 - #ifdef CONFIG_MMU 18 - #define MMU_IO(a, b) (a) 19 - #else 20 - #define MMU_IO(a, b) (b) 21 - #endif 22 - 23 - #define PCIO_SIZE 0x00100000 24 - #define PCIO_BASE MMU_IO(0xff000000, 0x7c000000) 25 - 26 17 /* 27 - * Translation of various region addresses to virtual addresses 18 + * Translation of various i/o addresses to host addresses for !CONFIG_MMU 28 19 */ 20 + #define PCIO_BASE 0x7c000000 29 21 #define __io(a) ((void __iomem *)(PCIO_BASE + (a))) 30 22 31 23 #endif
-33
arch/arm/mach-integrator/include/mach/io.h
··· 1 - /* 2 - * arch/arm/mach-integrator/include/mach/io.h 3 - * 4 - * Copyright (C) 1999 ARM Limited 5 - * 6 - * This program is free software; you can redistribute it and/or modify 7 - * it under the terms of the GNU General Public License as published by 8 - * the Free Software Foundation; either version 2 of the License, or 9 - * (at your option) any later version. 10 - * 11 - * This program is distributed in the hope that it will be useful, 12 - * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 - * GNU General Public License for more details. 15 - * 16 - * You should have received a copy of the GNU General Public License 17 - * along with this program; if not, write to the Free Software 18 - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 - */ 20 - #ifndef __ASM_ARM_ARCH_IO_H 21 - #define __ASM_ARM_ARCH_IO_H 22 - 23 - /* 24 - * WARNING: this has to mirror definitions in platform.h 25 - */ 26 - #define PCI_MEMORY_VADDR 0xe8000000 27 - #define PCI_CONFIG_VADDR 0xec000000 28 - #define PCI_V3_VADDR 0xed000000 29 - #define PCI_IO_VADDR 0xee000000 30 - 31 - #define __io(a) ((void __iomem *)(PCI_IO_VADDR + (a))) 32 - 33 - #endif
+4
arch/arm/mach-integrator/include/mach/platform.h
··· 324 324 */ 325 325 #define PHYS_PCI_V3_BASE 0x62000000 326 326 327 + #define PCI_MEMORY_VADDR 0xe8000000 328 + #define PCI_CONFIG_VADDR 0xec000000 329 + #define PCI_V3_VADDR 0xed000000 330 + 327 331 /* ------------------------------------------------------------------------ 328 332 * Integrator Interrupt Controllers 329 333 * ------------------------------------------------------------------------
+3 -6
arch/arm/mach-integrator/integrator_ap.c
··· 50 50 #include <asm/mach/arch.h> 51 51 #include <asm/mach/irq.h> 52 52 #include <asm/mach/map.h> 53 + #include <asm/mach/pci.h> 53 54 #include <asm/mach/time.h> 54 55 55 56 #include <plat/fpga-irq.h> ··· 74 73 * e8000000 40000000 PCI memory PHYS_PCI_MEM_BASE (max 512M) 75 74 * ec000000 61000000 PCI config space PHYS_PCI_CONFIG_BASE (max 16M) 76 75 * ed000000 62000000 PCI V3 regs PHYS_PCI_V3_BASE (max 64k) 77 - * ee000000 60000000 PCI IO PHYS_PCI_IO_BASE (max 16M) 76 + * fee00000 60000000 PCI IO PHYS_PCI_IO_BASE (max 16M) 78 77 * ef000000 Cache flush 79 78 * f1000000 10000000 Core module registers 80 79 * f1100000 11000000 System controller registers ··· 148 147 .pfn = __phys_to_pfn(PHYS_PCI_V3_BASE), 149 148 .length = SZ_64K, 150 149 .type = MT_DEVICE 151 - }, { 152 - .virtual = PCI_IO_VADDR, 153 - .pfn = __phys_to_pfn(PHYS_PCI_IO_BASE), 154 - .length = SZ_64K, 155 - .type = MT_DEVICE 156 150 } 157 151 }; 158 152 ··· 155 159 { 156 160 iotable_init(ap_io_desc, ARRAY_SIZE(ap_io_desc)); 157 161 vga_base = PCI_MEMORY_VADDR; 162 + pci_map_io_early(__phys_to_pfn(PHYS_PCI_IO_BASE)); 158 163 } 159 164 160 165 #define INTEGRATOR_SC_VALID_INT 0x003fffff
+23 -27
arch/arm/mach-integrator/pci_v3.c
··· 41 41 /* 42 42 * The V3 PCI interface chip in Integrator provides several windows from 43 43 * local bus memory into the PCI memory areas. Unfortunately, there 44 - * are not really enough windows for our usage, therefore we reuse 44 + * are not really enough windows for our usage, therefore we reuse 45 45 * one of the windows for access to PCI configuration space. The 46 46 * memory map is as follows: 47 - * 47 + * 48 48 * Local Bus Memory Usage 49 - * 49 + * 50 50 * 40000000 - 4FFFFFFF PCI memory. 256M non-prefetchable 51 51 * 50000000 - 5FFFFFFF PCI memory. 256M prefetchable 52 52 * 60000000 - 60FFFFFF PCI IO. 16M 53 53 * 61000000 - 61FFFFFF PCI Configuration. 16M 54 - * 54 + * 55 55 * There are three V3 windows, each described by a pair of V3 registers. 56 56 * These are LB_BASE0/LB_MAP0, LB_BASE1/LB_MAP1 and LB_BASE2/LB_MAP2. 57 57 * Base0 and Base1 can be used for any type of PCI memory access. Base2 58 58 * can be used either for PCI I/O or for I20 accesses. By default, uHAL 59 59 * uses this only for PCI IO space. 60 - * 60 + * 61 61 * Normally these spaces are mapped using the following base registers: 62 - * 62 + * 63 63 * Usage Local Bus Memory Base/Map registers used 64 - * 64 + * 65 65 * Mem 40000000 - 4FFFFFFF LB_BASE0/LB_MAP0 66 66 * Mem 50000000 - 5FFFFFFF LB_BASE1/LB_MAP1 67 67 * IO 60000000 - 60FFFFFF LB_BASE2/LB_MAP2 68 68 * Cfg 61000000 - 61FFFFFF 69 - * 69 + * 70 70 * This means that I20 and PCI configuration space accesses will fail. 71 - * When PCI configuration accesses are needed (via the uHAL PCI 71 + * When PCI configuration accesses are needed (via the uHAL PCI 72 72 * configuration space primitives) we must remap the spaces as follows: 73 - * 73 + * 74 74 * Usage Local Bus Memory Base/Map registers used 75 - * 75 + * 76 76 * Mem 40000000 - 4FFFFFFF LB_BASE0/LB_MAP0 77 77 * Mem 50000000 - 5FFFFFFF LB_BASE0/LB_MAP0 78 78 * IO 60000000 - 60FFFFFF LB_BASE2/LB_MAP2 79 79 * Cfg 61000000 - 61FFFFFF LB_BASE1/LB_MAP1 80 - * 80 + * 81 81 * To make this work, the code depends on overlapping windows working. 82 - * The V3 chip translates an address by checking its range within 82 + * The V3 chip translates an address by checking its range within 83 83 * each of the BASE/MAP pairs in turn (in ascending register number 84 84 * order). It will use the first matching pair. So, for example, 85 85 * if the same address is mapped by both LB_BASE0/LB_MAP0 and 86 - * LB_BASE1/LB_MAP1, the V3 will use the translation from 86 + * LB_BASE1/LB_MAP1, the V3 will use the translation from 87 87 * LB_BASE0/LB_MAP0. 88 - * 88 + * 89 89 * To allow PCI Configuration space access, the code enlarges the 90 90 * window mapped by LB_BASE0/LB_MAP0 from 256M to 512M. This occludes 91 91 * the windows currently mapped by LB_BASE1/LB_MAP1 so that it can 92 92 * be remapped for use by configuration cycles. 93 - * 94 - * At the end of the PCI Configuration space accesses, 93 + * 94 + * At the end of the PCI Configuration space accesses, 95 95 * LB_BASE1/LB_MAP1 is reset to map PCI Memory. Finally the window 96 96 * mapped by LB_BASE0/LB_MAP0 is reduced in size from 512M to 256M to 97 97 * reveal the now restored LB_BASE1/LB_MAP1 window. 98 - * 98 + * 99 99 * NOTE: We do not set up I2O mapping. I suspect that this is only 100 100 * for an intelligent (target) device. Using I2O disables most of 101 101 * the mappings into PCI memory. ··· 127 127 * 128 128 * returns: configuration address to play on the PCI bus 129 129 * 130 - * To generate the appropriate PCI configuration cycles in the PCI 131 - * configuration address space, you present the V3 with the following pattern 130 + * To generate the appropriate PCI configuration cycles in the PCI 131 + * configuration address space, you present the V3 with the following pattern 132 132 * (which is very nearly a type 1 (except that the lower two bits are 00 and 133 133 * not 01). In order for this mapping to work you need to set up one of 134 134 * the local to PCI aperatures to 16Mbytes in length translating to ··· 138 138 * 139 139 * Type 0: 140 140 * 141 - * 3 3|3 3 2 2|2 2 2 2|2 2 2 2|1 1 1 1|1 1 1 1|1 1 141 + * 3 3|3 3 2 2|2 2 2 2|2 2 2 2|1 1 1 1|1 1 1 1|1 1 142 142 * 3 2|1 0 9 8|7 6 5 4|3 2 1 0|9 8 7 6|5 4 3 2|1 0 9 8|7 6 5 4|3 2 1 0 143 143 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 144 144 * | | |D|D|D|D|D|D|D|D|D|D|D|D|D|D|D|D|D|D|D|D|D|F|F|F|R|R|R|R|R|R|0|0| ··· 150 150 * 151 151 * Type 1: 152 152 * 153 - * 3 3|3 3 2 2|2 2 2 2|2 2 2 2|1 1 1 1|1 1 1 1|1 1 153 + * 3 3|3 3 2 2|2 2 2 2|2 2 2 2|1 1 1 1|1 1 1 1|1 1 154 154 * 3 2|1 0 9 8|7 6 5 4|3 2 1 0|9 8 7 6|5 4 3 2|1 0 9 8|7 6 5 4|3 2 1 0 155 155 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 156 156 * | | | | | | | | | | |B|B|B|B|B|B|B|B|D|D|D|D|D|F|F|F|R|R|R|R|R|R|0|1| ··· 161 161 * 15:11 Device number (5 bits) 162 162 * 10:8 function number 163 163 * 7:2 register number 164 - * 164 + * 165 165 */ 166 166 static DEFINE_RAW_SPINLOCK(v3_lock); 167 167 ··· 374 374 } 375 375 376 376 /* 377 - * the IO resource for this bus 378 377 * the mem resource for this bus 379 378 * the prefetch mem resource for this bus 380 379 */ 381 - pci_add_resource_offset(&sys->resources, 382 - &ioport_resource, sys->io_offset); 383 380 pci_add_resource_offset(&sys->resources, &non_mem, sys->mem_offset); 384 381 pci_add_resource_offset(&sys->resources, &pre_mem, sys->mem_offset); 385 382 ··· 495 498 unsigned int temp; 496 499 int ret; 497 500 498 - pcibios_min_io = 0x6000; 499 501 pcibios_min_mem = 0x00100000; 500 502 501 503 /*
-28
arch/arm/mach-iop13xx/include/mach/io.h
··· 1 - /* 2 - * iop13xx custom ioremap implementation 3 - * Copyright (c) 2005-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 - #ifndef __ASM_ARM_ARCH_IO_H 20 - #define __ASM_ARM_ARCH_IO_H 21 - 22 - #define IO_SPACE_LIMIT 0xffffffff 23 - 24 - #define __io(a) __iop13xx_io(a) 25 - 26 - extern void __iomem * __iop13xx_io(unsigned long io_addr); 27 - 28 - #endif
+3 -25
arch/arm/mach-iop13xx/include/mach/iop13xx.h
··· 69 69 * 0x8000.0000 + 928M 0x2.8000.0000 (ioremap) PCIE outbound memory window 70 70 * 71 71 * IO MAP 72 - * 0x1000 + 64K 0x0.fffb.1000 0xfec6.1000 PCIX outbound i/o window 73 - * 0x1000 + 64K 0x0.fffd.1000 0xfed7.1000 PCIE outbound i/o window 72 + * 0x00000 + 64K 0x0.fffb.0000 0xfee0.0000 PCIX outbound i/o window 73 + * 0x10000 + 64K 0x0.fffd.0000 0xfee1.0000 PCIE outbound i/o window 74 74 */ 75 - #define IOP13XX_PCIX_IO_WINDOW_SIZE 0x10000UL 76 75 #define IOP13XX_PCIX_LOWER_IO_PA 0xfffb0000UL 77 - #define IOP13XX_PCIX_LOWER_IO_VA 0xfec60000UL 78 76 #define IOP13XX_PCIX_LOWER_IO_BA 0x0UL /* OIOTVR */ 79 - #define IOP13XX_PCIX_IO_BUS_OFFSET 0x1000UL 80 - #define IOP13XX_PCIX_UPPER_IO_PA (IOP13XX_PCIX_LOWER_IO_PA +\ 81 - IOP13XX_PCIX_IO_WINDOW_SIZE - 1) 82 - #define IOP13XX_PCIX_UPPER_IO_VA (IOP13XX_PCIX_LOWER_IO_VA +\ 83 - IOP13XX_PCIX_IO_WINDOW_SIZE - 1) 84 - #define IOP13XX_PCIX_IO_PHYS_TO_VIRT(addr) (u32) ((u32) addr -\ 85 - (IOP13XX_PCIX_LOWER_IO_PA\ 86 - - IOP13XX_PCIX_LOWER_IO_VA)) 87 77 88 78 #define IOP13XX_PCIX_MEM_PHYS_OFFSET 0x100000000ULL 89 79 #define IOP13XX_PCIX_MEM_WINDOW_SIZE 0x3a000000UL ··· 93 103 IOP13XX_PCIX_LOWER_MEM_BA) 94 104 95 105 /* PCI-E ranges */ 96 - #define IOP13XX_PCIE_IO_WINDOW_SIZE 0x10000UL 97 106 #define IOP13XX_PCIE_LOWER_IO_PA 0xfffd0000UL 98 - #define IOP13XX_PCIE_LOWER_IO_VA 0xfed70000UL 99 - #define IOP13XX_PCIE_LOWER_IO_BA 0x0UL /* OIOTVR */ 100 - #define IOP13XX_PCIE_IO_BUS_OFFSET 0x1000UL 101 - #define IOP13XX_PCIE_UPPER_IO_PA (IOP13XX_PCIE_LOWER_IO_PA +\ 102 - IOP13XX_PCIE_IO_WINDOW_SIZE - 1) 103 - #define IOP13XX_PCIE_UPPER_IO_VA (IOP13XX_PCIE_LOWER_IO_VA +\ 104 - IOP13XX_PCIE_IO_WINDOW_SIZE - 1) 105 - #define IOP13XX_PCIE_UPPER_IO_BA (IOP13XX_PCIE_LOWER_IO_BA +\ 106 - IOP13XX_PCIE_IO_WINDOW_SIZE - 1) 107 - #define IOP13XX_PCIE_IO_PHYS_TO_VIRT(addr) (u32) ((u32) addr -\ 108 - (IOP13XX_PCIE_LOWER_IO_PA\ 109 - - IOP13XX_PCIE_LOWER_IO_VA)) 107 + #define IOP13XX_PCIE_LOWER_IO_BA 0x10000UL /* OIOTVR */ 110 108 111 109 #define IOP13XX_PCIE_MEM_PHYS_OFFSET 0x200000000ULL 112 110 #define IOP13XX_PCIE_MEM_WINDOW_SIZE 0x3a000000UL
-27
arch/arm/mach-iop13xx/io.c
··· 23 23 24 24 #include "pci.h" 25 25 26 - void * __iomem __iop13xx_io(unsigned long io_addr) 27 - { 28 - void __iomem * io_virt; 29 - 30 - switch (io_addr) { 31 - case IOP13XX_PCIE_LOWER_IO_PA ... IOP13XX_PCIE_UPPER_IO_PA: 32 - io_virt = (void *) IOP13XX_PCIE_IO_PHYS_TO_VIRT(io_addr); 33 - break; 34 - case IOP13XX_PCIX_LOWER_IO_PA ... IOP13XX_PCIX_UPPER_IO_PA: 35 - io_virt = (void *) IOP13XX_PCIX_IO_PHYS_TO_VIRT(io_addr); 36 - break; 37 - default: 38 - BUG(); 39 - } 40 - 41 - return io_virt; 42 - } 43 - EXPORT_SYMBOL(__iop13xx_io); 44 - 45 26 static void __iomem *__iop13xx_ioremap_caller(unsigned long cookie, 46 27 size_t size, unsigned int mtype, void *caller) 47 28 { ··· 47 66 retval = __arm_ioremap_caller(IOP13XX_PBI_LOWER_MEM_PA + 48 67 (cookie - IOP13XX_PBI_LOWER_MEM_RA), 49 68 size, mtype, __builtin_return_address(0)); 50 - break; 51 - case IOP13XX_PCIE_LOWER_IO_PA ... IOP13XX_PCIE_UPPER_IO_PA: 52 - retval = (void *) IOP13XX_PCIE_IO_PHYS_TO_VIRT(cookie); 53 - break; 54 - case IOP13XX_PCIX_LOWER_IO_PA ... IOP13XX_PCIX_UPPER_IO_PA: 55 - retval = (void *) IOP13XX_PCIX_IO_PHYS_TO_VIRT(cookie); 56 69 break; 57 70 case IOP13XX_PMMR_PHYS_MEM_BASE ... IOP13XX_PMMR_UPPER_MEM_PA: 58 71 retval = (void *) IOP13XX_PMMR_PHYS_TO_VIRT(cookie); ··· 74 99 goto skip; 75 100 76 101 switch ((u32) addr) { 77 - case IOP13XX_PCIE_LOWER_IO_VA ... IOP13XX_PCIE_UPPER_IO_VA: 78 - case IOP13XX_PCIX_LOWER_IO_VA ... IOP13XX_PCIX_UPPER_IO_VA: 79 102 case IOP13XX_PMMR_VIRT_MEM_BASE ... IOP13XX_PMMR_UPPER_MEM_VA: 80 103 goto skip; 81 104 }
+13 -24
arch/arm/mach-iop13xx/pci.c
··· 970 970 __raw_writel(__raw_readl(IOP13XX_XBG_BECSR) & 3, IOP13XX_XBG_BECSR); 971 971 972 972 /* Setup the Min Address for PCI memory... */ 973 - pcibios_min_io = 0; 974 973 pcibios_min_mem = IOP13XX_PCIX_LOWER_MEM_BA; 975 974 976 975 /* if Linux is given control of an ATU ··· 1002 1003 if (nr > 1) 1003 1004 return 0; 1004 1005 1005 - res = kcalloc(2, sizeof(struct resource), GFP_KERNEL); 1006 + res = kzalloc(sizeof(struct resource), GFP_KERNEL); 1006 1007 if (!res) 1007 1008 panic("PCI: unable to alloc resources"); 1008 1009 ··· 1041 1042 << IOP13XX_ATUX_PCIXSR_FUNC_NUM; 1042 1043 __raw_writel(pcixsr, IOP13XX_ATUX_PCIXSR); 1043 1044 1044 - res[0].start = IOP13XX_PCIX_LOWER_IO_PA + IOP13XX_PCIX_IO_BUS_OFFSET; 1045 - res[0].end = IOP13XX_PCIX_UPPER_IO_PA; 1046 - res[0].name = "IQ81340 ATUX PCI I/O Space"; 1047 - res[0].flags = IORESOURCE_IO; 1045 + pci_ioremap_io(0, IOP13XX_PCIX_LOWER_IO_PA); 1048 1046 1049 - res[1].start = IOP13XX_PCIX_LOWER_MEM_RA; 1050 - res[1].end = IOP13XX_PCIX_UPPER_MEM_RA; 1051 - res[1].name = "IQ81340 ATUX PCI Memory Space"; 1052 - res[1].flags = IORESOURCE_MEM; 1047 + res->start = IOP13XX_PCIX_LOWER_MEM_RA; 1048 + res->end = IOP13XX_PCIX_UPPER_MEM_RA; 1049 + res->name = "IQ81340 ATUX PCI Memory Space"; 1050 + res->flags = IORESOURCE_MEM; 1053 1051 sys->mem_offset = IOP13XX_PCIX_MEM_OFFSET; 1054 - sys->io_offset = IOP13XX_PCIX_LOWER_IO_PA; 1055 1052 break; 1056 1053 case IOP13XX_INIT_ATU_ATUE: 1057 1054 /* Note: the function number field in the PCSR is ro */ ··· 1058 1063 1059 1064 __raw_writel(pcsr, IOP13XX_ATUE_PCSR); 1060 1065 1061 - res[0].start = IOP13XX_PCIE_LOWER_IO_PA + IOP13XX_PCIE_IO_BUS_OFFSET; 1062 - res[0].end = IOP13XX_PCIE_UPPER_IO_PA; 1063 - res[0].name = "IQ81340 ATUE PCI I/O Space"; 1064 - res[0].flags = IORESOURCE_IO; 1066 + pci_ioremap_io(SZ_64K, IOP13XX_PCIE_LOWER_IO_PA); 1065 1067 1066 - res[1].start = IOP13XX_PCIE_LOWER_MEM_RA; 1067 - res[1].end = IOP13XX_PCIE_UPPER_MEM_RA; 1068 - res[1].name = "IQ81340 ATUE PCI Memory Space"; 1069 - res[1].flags = IORESOURCE_MEM; 1068 + res->start = IOP13XX_PCIE_LOWER_MEM_RA; 1069 + res->end = IOP13XX_PCIE_UPPER_MEM_RA; 1070 + res->name = "IQ81340 ATUE PCI Memory Space"; 1071 + res->flags = IORESOURCE_MEM; 1070 1072 sys->mem_offset = IOP13XX_PCIE_MEM_OFFSET; 1071 - sys->io_offset = IOP13XX_PCIE_LOWER_IO_PA; 1072 1073 sys->map_irq = iop13xx_pcie_map_irq; 1073 1074 break; 1074 1075 default: ··· 1072 1081 return 0; 1073 1082 } 1074 1083 1075 - request_resource(&ioport_resource, &res[0]); 1076 - request_resource(&iomem_resource, &res[1]); 1084 + request_resource(&iomem_resource, res); 1077 1085 1078 - pci_add_resource_offset(&sys->resources, &res[0], sys->io_offset); 1079 - pci_add_resource_offset(&sys->resources, &res[1], sys->mem_offset); 1086 + pci_add_resource_offset(&sys->resources, res, sys->mem_offset); 1080 1087 1081 1088 return 1; 1082 1089 }
-10
arch/arm/mach-iop13xx/setup.c
··· 40 40 .pfn = __phys_to_pfn(IOP13XX_PMMR_PHYS_MEM_BASE), 41 41 .length = IOP13XX_PMMR_SIZE, 42 42 .type = MT_DEVICE, 43 - }, { /* PCIE IO space */ 44 - .virtual = IOP13XX_PCIE_LOWER_IO_VA, 45 - .pfn = __phys_to_pfn(IOP13XX_PCIE_LOWER_IO_PA), 46 - .length = IOP13XX_PCIX_IO_WINDOW_SIZE, 47 - .type = MT_DEVICE, 48 - }, { /* PCIX IO space */ 49 - .virtual = IOP13XX_PCIX_LOWER_IO_VA, 50 - .pfn = __phys_to_pfn(IOP13XX_PCIX_LOWER_IO_PA), 51 - .length = IOP13XX_PCIX_IO_WINDOW_SIZE, 52 - .type = MT_DEVICE, 53 43 }, 54 44 }; 55 45
-19
arch/arm/mach-iop32x/include/mach/io.h
··· 1 - /* 2 - * arch/arm/mach-iop32x/include/mach/io.h 3 - * 4 - * Copyright (C) 2001 MontaVista Software, Inc. 5 - * 6 - * This program is free software; you can redistribute it and/or modify 7 - * it under the terms of the GNU General Public License version 2 as 8 - * published by the Free Software Foundation. 9 - */ 10 - 11 - #ifndef __IO_H 12 - #define __IO_H 13 - 14 - #include <asm/hardware/iop3xx.h> 15 - 16 - #define IO_SPACE_LIMIT 0xffffffff 17 - #define __io(p) ((void __iomem *)IOP3XX_PCI_IO_PHYS_TO_VIRT(p)) 18 - 19 - #endif
-19
arch/arm/mach-iop33x/include/mach/io.h
··· 1 - /* 2 - * arch/arm/mach-iop33x/include/mach/io.h 3 - * 4 - * Copyright (C) 2001 MontaVista Software, Inc. 5 - * 6 - * This program is free software; you can redistribute it and/or modify 7 - * it under the terms of the GNU General Public License version 2 as 8 - * published by the Free Software Foundation. 9 - */ 10 - 11 - #ifndef __IO_H 12 - #define __IO_H 13 - 14 - #include <asm/hardware/iop3xx.h> 15 - 16 - #define IO_SPACE_LIMIT 0xffffffff 17 - #define __io(p) ((void __iomem *)IOP3XX_PCI_IO_PHYS_TO_VIRT(p)) 18 - 19 - #endif
-10
arch/arm/mach-kirkwood/common.c
··· 42 42 ****************************************************************************/ 43 43 static struct map_desc kirkwood_io_desc[] __initdata = { 44 44 { 45 - .virtual = KIRKWOOD_PCIE_IO_VIRT_BASE, 46 - .pfn = __phys_to_pfn(KIRKWOOD_PCIE_IO_PHYS_BASE), 47 - .length = KIRKWOOD_PCIE_IO_SIZE, 48 - .type = MT_DEVICE, 49 - }, { 50 - .virtual = KIRKWOOD_PCIE1_IO_VIRT_BASE, 51 - .pfn = __phys_to_pfn(KIRKWOOD_PCIE1_IO_PHYS_BASE), 52 - .length = KIRKWOOD_PCIE1_IO_SIZE, 53 - .type = MT_DEVICE, 54 - }, { 55 45 .virtual = KIRKWOOD_REGS_VIRT_BASE, 56 46 .pfn = __phys_to_pfn(KIRKWOOD_REGS_PHYS_BASE), 57 47 .length = KIRKWOOD_REGS_SIZE,
-24
arch/arm/mach-kirkwood/include/mach/io.h
··· 1 - /* 2 - * arch/arm/mach-kirkwood/include/mach/io.h 3 - * 4 - * This file is licensed under the terms of the GNU General Public 5 - * License version 2. This program is licensed "as is" without any 6 - * warranty of any kind, whether express or implied. 7 - */ 8 - 9 - #ifndef __ASM_ARCH_IO_H 10 - #define __ASM_ARCH_IO_H 11 - 12 - #include "kirkwood.h" 13 - 14 - #define IO_SPACE_LIMIT 0xffffffff 15 - 16 - static inline void __iomem *__io(unsigned long addr) 17 - { 18 - return (void __iomem *)((addr - KIRKWOOD_PCIE_IO_BUS_BASE) 19 - + KIRKWOOD_PCIE_IO_VIRT_BASE); 20 - } 21 - 22 - #define __io(a) __io(a) 23 - 24 - #endif
+3 -5
arch/arm/mach-kirkwood/include/mach/kirkwood.h
··· 37 37 #define KIRKWOOD_NAND_MEM_SIZE SZ_1K 38 38 39 39 #define KIRKWOOD_PCIE1_IO_PHYS_BASE 0xf3000000 40 - #define KIRKWOOD_PCIE1_IO_VIRT_BASE 0xfef00000 41 - #define KIRKWOOD_PCIE1_IO_BUS_BASE 0x00100000 42 - #define KIRKWOOD_PCIE1_IO_SIZE SZ_1M 40 + #define KIRKWOOD_PCIE1_IO_BUS_BASE 0x00010000 41 + #define KIRKWOOD_PCIE1_IO_SIZE SZ_64K 43 42 44 43 #define KIRKWOOD_PCIE_IO_PHYS_BASE 0xf2000000 45 - #define KIRKWOOD_PCIE_IO_VIRT_BASE 0xfee00000 46 44 #define KIRKWOOD_PCIE_IO_BUS_BASE 0x00000000 47 - #define KIRKWOOD_PCIE_IO_SIZE SZ_1M 45 + #define KIRKWOOD_PCIE_IO_SIZE SZ_64K 48 46 49 47 #define KIRKWOOD_REGS_PHYS_BASE 0xf1000000 50 48 #define KIRKWOOD_REGS_VIRT_BASE 0xfed00000
+13 -31
arch/arm/mach-kirkwood/pcie.c
··· 56 56 void __iomem *base; 57 57 spinlock_t conf_lock; 58 58 int irq; 59 - struct resource res[2]; 59 + struct resource res; 60 60 }; 61 61 62 62 static int pcie_port_map[2]; ··· 137 137 pp->irq = IRQ_KIRKWOOD_PCIE; 138 138 139 139 /* 140 - * IORESOURCE_IO 141 - */ 142 - pp->res[0].name = "PCIe 0 I/O Space"; 143 - pp->res[0].start = KIRKWOOD_PCIE_IO_BUS_BASE; 144 - pp->res[0].end = pp->res[0].start + KIRKWOOD_PCIE_IO_SIZE - 1; 145 - pp->res[0].flags = IORESOURCE_IO; 146 - 147 - /* 148 140 * IORESOURCE_MEM 149 141 */ 150 - pp->res[1].name = "PCIe 0 MEM"; 151 - pp->res[1].start = KIRKWOOD_PCIE_MEM_PHYS_BASE; 152 - pp->res[1].end = pp->res[1].start + KIRKWOOD_PCIE_MEM_SIZE - 1; 153 - pp->res[1].flags = IORESOURCE_MEM; 142 + pp->res.name = "PCIe 0 MEM"; 143 + pp->res.start = KIRKWOOD_PCIE_MEM_PHYS_BASE; 144 + pp->res.end = pp->res.start + KIRKWOOD_PCIE_MEM_SIZE - 1; 145 + pp->res.flags = IORESOURCE_MEM; 154 146 } 155 147 156 148 static void __init pcie1_ioresources_init(struct pcie_port *pp) ··· 151 159 pp->irq = IRQ_KIRKWOOD_PCIE1; 152 160 153 161 /* 154 - * IORESOURCE_IO 155 - */ 156 - pp->res[0].name = "PCIe 1 I/O Space"; 157 - pp->res[0].start = KIRKWOOD_PCIE1_IO_BUS_BASE; 158 - pp->res[0].end = pp->res[0].start + KIRKWOOD_PCIE1_IO_SIZE - 1; 159 - pp->res[0].flags = IORESOURCE_IO; 160 - 161 - /* 162 162 * IORESOURCE_MEM 163 163 */ 164 - pp->res[1].name = "PCIe 1 MEM"; 165 - pp->res[1].start = KIRKWOOD_PCIE1_MEM_PHYS_BASE; 166 - pp->res[1].end = pp->res[1].start + KIRKWOOD_PCIE1_MEM_SIZE - 1; 167 - pp->res[1].flags = IORESOURCE_MEM; 164 + pp->res.name = "PCIe 1 MEM"; 165 + pp->res.start = KIRKWOOD_PCIE1_MEM_PHYS_BASE; 166 + pp->res.end = pp->res.start + KIRKWOOD_PCIE1_MEM_SIZE - 1; 167 + pp->res.flags = IORESOURCE_MEM; 168 168 } 169 169 170 170 static int __init kirkwood_pcie_setup(int nr, struct pci_sys_data *sys) ··· 181 197 case 0: 182 198 kirkwood_enable_pcie_clk("0"); 183 199 pcie0_ioresources_init(pp); 200 + pci_ioremap_io(SZ_64K * sys->busnr, KIRKWOOD_PCIE_IO_PHYS_BASE); 184 201 break; 185 202 case 1: 186 203 kirkwood_enable_pcie_clk("1"); 187 204 pcie1_ioresources_init(pp); 205 + pci_ioremap_io(SZ_64K * sys->busnr, KIRKWOOD_PCIE1_IO_PHYS_BASE); 188 206 break; 189 207 default: 190 208 panic("PCIe setup: invalid controller %d", index); 191 209 } 192 210 193 - if (request_resource(&ioport_resource, &pp->res[0])) 194 - panic("Request PCIe%d IO resource failed\n", index); 195 - if (request_resource(&iomem_resource, &pp->res[1])) 211 + if (request_resource(&iomem_resource, &pp->res)) 196 212 panic("Request PCIe%d Memory resource failed\n", index); 197 213 198 - sys->io_offset = 0; 199 - pci_add_resource_offset(&sys->resources, &pp->res[0], sys->io_offset); 200 - pci_add_resource_offset(&sys->resources, &pp->res[1], sys->mem_offset); 214 + pci_add_resource_offset(&sys->resources, &pp->res, sys->mem_offset); 201 215 202 216 /* 203 217 * Generic PCIe unit setup.
+2 -1
arch/arm/mach-mv78xx0/addr-map.c
··· 13 13 #include <linux/mbus.h> 14 14 #include <linux/io.h> 15 15 #include <plat/addr-map.h> 16 + #include <mach/mv78xx0.h> 16 17 #include "common.h" 17 18 18 19 /* ··· 82 81 int maj, int min) 83 82 { 84 83 orion_setup_cpu_win(&addr_map_cfg, window, base, size, 85 - TARGET_PCIE(maj), ATTR_PCIE_IO(min), -1); 84 + TARGET_PCIE(maj), ATTR_PCIE_IO(min), 0); 86 85 } 87 86 88 87 void __init mv78xx0_setup_pcie_mem_win(int window, u32 base, u32 size,
-5
arch/arm/mach-mv78xx0/common.c
··· 135 135 .length = MV78XX0_CORE_REGS_SIZE, 136 136 .type = MT_DEVICE, 137 137 }, { 138 - .virtual = MV78XX0_PCIE_IO_VIRT_BASE(0), 139 - .pfn = __phys_to_pfn(MV78XX0_PCIE_IO_PHYS_BASE(0)), 140 - .length = MV78XX0_PCIE_IO_SIZE * 8, 141 - .type = MT_DEVICE, 142 - }, { 143 138 .virtual = MV78XX0_REGS_VIRT_BASE, 144 139 .pfn = __phys_to_pfn(MV78XX0_REGS_PHYS_BASE), 145 140 .length = MV78XX0_REGS_SIZE,
-24
arch/arm/mach-mv78xx0/include/mach/io.h
··· 1 - /* 2 - * arch/arm/mach-mv78xx0/include/mach/io.h 3 - * 4 - * This file is licensed under the terms of the GNU General Public 5 - * License version 2. This program is licensed "as is" without any 6 - * warranty of any kind, whether express or implied. 7 - */ 8 - 9 - #ifndef __ASM_ARCH_IO_H 10 - #define __ASM_ARCH_IO_H 11 - 12 - #include "mv78xx0.h" 13 - 14 - #define IO_SPACE_LIMIT 0xffffffff 15 - 16 - static inline void __iomem *__io(unsigned long addr) 17 - { 18 - return (void __iomem *)((addr - MV78XX0_PCIE_IO_PHYS_BASE(0)) 19 - + MV78XX0_PCIE_IO_VIRT_BASE(0)); 20 - } 21 - 22 - #define __io(a) __io(a) 23 - 24 - #endif
+10 -11
arch/arm/mach-mv78xx0/include/mach/mv78xx0.h
··· 29 29 * 30 30 * virt phys size 31 31 * fe400000 f102x000 16K core-specific peripheral registers 32 - * fe700000 f0800000 1M PCIe #0 I/O space 33 - * fe800000 f0900000 1M PCIe #1 I/O space 34 - * fe900000 f0a00000 1M PCIe #2 I/O space 35 - * fea00000 f0b00000 1M PCIe #3 I/O space 36 - * feb00000 f0c00000 1M PCIe #4 I/O space 37 - * fec00000 f0d00000 1M PCIe #5 I/O space 38 - * fed00000 f0e00000 1M PCIe #6 I/O space 39 - * fee00000 f0f00000 1M PCIe #7 I/O space 40 - * fef00000 f1000000 1M on-chip peripheral registers 32 + * fee00000 f0800000 64K PCIe #0 I/O space 33 + * fee10000 f0900000 64K PCIe #1 I/O space 34 + * fee20000 f0a00000 64K PCIe #2 I/O space 35 + * fee30000 f0b00000 64K PCIe #3 I/O space 36 + * fee40000 f0c00000 64K PCIe #4 I/O space 37 + * fee50000 f0d00000 64K PCIe #5 I/O space 38 + * fee60000 f0e00000 64K PCIe #6 I/O space 39 + * fee70000 f0f00000 64K PCIe #7 I/O space 40 + * fd000000 f1000000 1M on-chip peripheral registers 41 41 */ 42 42 #define MV78XX0_CORE0_REGS_PHYS_BASE 0xf1020000 43 43 #define MV78XX0_CORE1_REGS_PHYS_BASE 0xf1024000 ··· 46 46 #define MV78XX0_CORE_REGS_SIZE SZ_16K 47 47 48 48 #define MV78XX0_PCIE_IO_PHYS_BASE(i) (0xf0800000 + ((i) << 20)) 49 - #define MV78XX0_PCIE_IO_VIRT_BASE(i) (0xfe700000 + ((i) << 20)) 50 49 #define MV78XX0_PCIE_IO_SIZE SZ_1M 51 50 52 51 #define MV78XX0_REGS_PHYS_BASE 0xf1000000 53 - #define MV78XX0_REGS_VIRT_BASE 0xfef00000 52 + #define MV78XX0_REGS_VIRT_BASE 0xfd000000 54 53 #define MV78XX0_REGS_SIZE SZ_1M 55 54 56 55 #define MV78XX0_PCIE_MEM_PHYS_BASE 0xc0000000
+35 -79
arch/arm/mach-mv78xx0/pcie.c
··· 15 15 #include <asm/mach/pci.h> 16 16 #include <plat/pcie.h> 17 17 #include <plat/addr-map.h> 18 + #include <mach/mv78xx0.h> 18 19 #include "common.h" 19 20 20 21 struct pcie_port { ··· 24 23 u8 root_bus_nr; 25 24 void __iomem *base; 26 25 spinlock_t conf_lock; 27 - char io_space_name[16]; 28 26 char mem_space_name[16]; 29 - struct resource res[2]; 27 + struct resource res; 30 28 }; 31 29 32 30 static struct pcie_port pcie_port[8]; 33 31 static int num_pcie_ports; 34 32 static struct resource pcie_io_space; 35 - static struct resource pcie_mem_space; 36 - 37 33 38 34 void __init mv78xx0_pcie_id(u32 *dev, u32 *rev) 39 35 { ··· 38 40 *rev = orion_pcie_rev((void __iomem *)PCIE00_VIRT_BASE); 39 41 } 40 42 43 + u32 pcie_port_size[8] = { 44 + 0, 45 + 0x30000000, 46 + 0x10000000, 47 + 0x10000000, 48 + 0x08000000, 49 + 0x08000000, 50 + 0x08000000, 51 + 0x04000000, 52 + }; 53 + 41 54 static void __init mv78xx0_pcie_preinit(void) 42 55 { 43 56 int i; 44 57 u32 size_each; 45 58 u32 start; 46 - int win; 59 + int win = 0; 47 60 48 61 pcie_io_space.name = "PCIe I/O Space"; 49 62 pcie_io_space.start = MV78XX0_PCIE_IO_PHYS_BASE(0); 50 63 pcie_io_space.end = 51 64 MV78XX0_PCIE_IO_PHYS_BASE(0) + MV78XX0_PCIE_IO_SIZE * 8 - 1; 52 - pcie_io_space.flags = IORESOURCE_IO; 65 + pcie_io_space.flags = IORESOURCE_MEM; 53 66 if (request_resource(&iomem_resource, &pcie_io_space)) 54 67 panic("can't allocate PCIe I/O space"); 55 68 56 - pcie_mem_space.name = "PCIe MEM Space"; 57 - pcie_mem_space.start = MV78XX0_PCIE_MEM_PHYS_BASE; 58 - pcie_mem_space.end = 59 - MV78XX0_PCIE_MEM_PHYS_BASE + MV78XX0_PCIE_MEM_SIZE - 1; 60 - pcie_mem_space.flags = IORESOURCE_MEM; 61 - if (request_resource(&iomem_resource, &pcie_mem_space)) 62 - panic("can't allocate PCIe MEM space"); 63 - 64 - for (i = 0; i < num_pcie_ports; i++) { 65 - struct pcie_port *pp = pcie_port + i; 66 - 67 - snprintf(pp->io_space_name, sizeof(pp->io_space_name), 68 - "PCIe %d.%d I/O", pp->maj, pp->min); 69 - pp->io_space_name[sizeof(pp->io_space_name) - 1] = 0; 70 - pp->res[0].name = pp->io_space_name; 71 - pp->res[0].start = MV78XX0_PCIE_IO_PHYS_BASE(i); 72 - pp->res[0].end = pp->res[0].start + MV78XX0_PCIE_IO_SIZE - 1; 73 - pp->res[0].flags = IORESOURCE_IO; 74 - 75 - snprintf(pp->mem_space_name, sizeof(pp->mem_space_name), 76 - "PCIe %d.%d MEM", pp->maj, pp->min); 77 - pp->mem_space_name[sizeof(pp->mem_space_name) - 1] = 0; 78 - pp->res[1].name = pp->mem_space_name; 79 - pp->res[1].flags = IORESOURCE_MEM; 80 - } 81 - 82 - switch (num_pcie_ports) { 83 - case 0: 84 - size_each = 0; 85 - break; 86 - 87 - case 1: 88 - size_each = 0x30000000; 89 - break; 90 - 91 - case 2 ... 3: 92 - size_each = 0x10000000; 93 - break; 94 - 95 - case 4 ... 6: 96 - size_each = 0x08000000; 97 - break; 98 - 99 - case 7: 100 - size_each = 0x04000000; 101 - break; 102 - 103 - default: 69 + if (num_pcie_ports > 7) 104 70 panic("invalid number of PCIe ports"); 105 - } 71 + 72 + size_each = pcie_port_size[num_pcie_ports]; 106 73 107 74 start = MV78XX0_PCIE_MEM_PHYS_BASE; 108 75 for (i = 0; i < num_pcie_ports; i++) { 109 76 struct pcie_port *pp = pcie_port + i; 110 77 111 - pp->res[1].start = start; 112 - pp->res[1].end = start + size_each - 1; 78 + snprintf(pp->mem_space_name, sizeof(pp->mem_space_name), 79 + "PCIe %d.%d MEM", pp->maj, pp->min); 80 + pp->mem_space_name[sizeof(pp->mem_space_name) - 1] = 0; 81 + pp->res.name = pp->mem_space_name; 82 + pp->res.flags = IORESOURCE_MEM; 83 + pp->res.start = start; 84 + pp->res.end = start + size_each - 1; 113 85 start += size_each; 114 - } 115 86 116 - for (i = 0; i < num_pcie_ports; i++) { 117 - struct pcie_port *pp = pcie_port + i; 118 - 119 - if (request_resource(&pcie_io_space, &pp->res[0])) 120 - panic("can't allocate PCIe I/O sub-space"); 121 - 122 - if (request_resource(&pcie_mem_space, &pp->res[1])) 87 + if (request_resource(&iomem_resource, &pp->res)) 123 88 panic("can't allocate PCIe MEM sub-space"); 124 - } 125 89 126 - win = 0; 127 - for (i = 0; i < num_pcie_ports; i++) { 128 - struct pcie_port *pp = pcie_port + i; 129 - 130 - mv78xx0_setup_pcie_io_win(win++, pp->res[0].start, 131 - resource_size(&pp->res[0]), 132 - pp->maj, pp->min); 133 - 134 - mv78xx0_setup_pcie_mem_win(win++, pp->res[1].start, 135 - resource_size(&pp->res[1]), 90 + mv78xx0_setup_pcie_mem_win(win + i + 8, pp->res.start, 91 + resource_size(&pp->res), 136 92 pp->maj, pp->min); 93 + 94 + mv78xx0_setup_pcie_io_win(win + i, i * SZ_64K, SZ_64K, 95 + pp->maj, pp->min); 137 96 } 138 97 } 139 98 ··· 111 156 orion_pcie_set_local_bus_nr(pp->base, sys->busnr); 112 157 orion_pcie_setup(pp->base); 113 158 114 - pci_add_resource_offset(&sys->resources, &pp->res[0], sys->io_offset); 115 - pci_add_resource_offset(&sys->resources, &pp->res[1], sys->mem_offset); 159 + pci_ioremap_io(nr * SZ_64K, MV78XX0_PCIE_IO_PHYS_BASE(nr)); 160 + 161 + pci_add_resource_offset(&sys->resources, &pp->res, sys->mem_offset); 116 162 117 163 return 1; 118 164 } ··· 237 281 pp->root_bus_nr = -1; 238 282 pp->base = (void __iomem *)base; 239 283 spin_lock_init(&pp->conf_lock); 240 - memset(pp->res, 0, sizeof(pp->res)); 284 + memset(&pp->res, 0, sizeof(pp->res)); 241 285 } else { 242 286 printk("link down, ignoring\n"); 243 287 }
-10
arch/arm/mach-orion5x/common.c
··· 47 47 .length = ORION5X_REGS_SIZE, 48 48 .type = MT_DEVICE, 49 49 }, { 50 - .virtual = ORION5X_PCIE_IO_VIRT_BASE, 51 - .pfn = __phys_to_pfn(ORION5X_PCIE_IO_PHYS_BASE), 52 - .length = ORION5X_PCIE_IO_SIZE, 53 - .type = MT_DEVICE, 54 - }, { 55 - .virtual = ORION5X_PCI_IO_VIRT_BASE, 56 - .pfn = __phys_to_pfn(ORION5X_PCI_IO_PHYS_BASE), 57 - .length = ORION5X_PCI_IO_SIZE, 58 - .type = MT_DEVICE, 59 - }, { 60 50 .virtual = ORION5X_PCIE_WA_VIRT_BASE, 61 51 .pfn = __phys_to_pfn(ORION5X_PCIE_WA_PHYS_BASE), 62 52 .length = ORION5X_PCIE_WA_SIZE,
-22
arch/arm/mach-orion5x/include/mach/io.h
··· 1 - /* 2 - * arch/arm/mach-orion5x/include/mach/io.h 3 - * 4 - * This file is licensed under the terms of the GNU General Public 5 - * License version 2. This program is licensed "as is" without any 6 - * warranty of any kind, whether express or implied. 7 - */ 8 - 9 - #ifndef __ASM_ARCH_IO_H 10 - #define __ASM_ARCH_IO_H 11 - 12 - #include <mach/orion5x.h> 13 - #include <asm/sizes.h> 14 - 15 - #define IO_SPACE_LIMIT SZ_2M 16 - static inline void __iomem *__io(unsigned long addr) 17 - { 18 - return (void __iomem *)(addr + ORION5X_PCIE_IO_VIRT_BASE); 19 - } 20 - 21 - #define __io(a) __io(a) 22 - #endif
+9 -11
arch/arm/mach-orion5x/include/mach/orion5x.h
··· 31 31 * fc000000 device bus mappings (cs0/cs1) 32 32 * 33 33 * virt phys size 34 - * fdd00000 f1000000 1M on-chip peripheral registers 35 - * fde00000 f2000000 1M PCIe I/O space 36 - * fdf00000 f2100000 1M PCI I/O space 37 - * fe000000 f0000000 16M PCIe WA space (Orion-1/Orion-NAS only) 34 + * fe000000 f1000000 1M on-chip peripheral registers 35 + * fee00000 f2000000 64K PCIe I/O space 36 + * fee10000 f2100000 64K PCI I/O space 37 + * fd000000 f0000000 16M PCIe WA space (Orion-1/Orion-NAS only) 38 38 ****************************************************************************/ 39 39 #define ORION5X_REGS_PHYS_BASE 0xf1000000 40 - #define ORION5X_REGS_VIRT_BASE 0xfdd00000 40 + #define ORION5X_REGS_VIRT_BASE 0xfe000000 41 41 #define ORION5X_REGS_SIZE SZ_1M 42 42 43 43 #define ORION5X_PCIE_IO_PHYS_BASE 0xf2000000 44 - #define ORION5X_PCIE_IO_VIRT_BASE 0xfde00000 45 44 #define ORION5X_PCIE_IO_BUS_BASE 0x00000000 46 - #define ORION5X_PCIE_IO_SIZE SZ_1M 45 + #define ORION5X_PCIE_IO_SIZE SZ_64K 47 46 48 47 #define ORION5X_PCI_IO_PHYS_BASE 0xf2100000 49 - #define ORION5X_PCI_IO_VIRT_BASE 0xfdf00000 50 - #define ORION5X_PCI_IO_BUS_BASE 0x00100000 51 - #define ORION5X_PCI_IO_SIZE SZ_1M 48 + #define ORION5X_PCI_IO_BUS_BASE 0x00010000 49 + #define ORION5X_PCI_IO_SIZE SZ_64K 52 50 53 51 #define ORION5X_SRAM_PHYS_BASE (0xf2200000) 54 52 #define ORION5X_SRAM_SIZE SZ_8K 55 53 56 54 /* Relevant only for Orion-1/Orion-NAS */ 57 55 #define ORION5X_PCIE_WA_PHYS_BASE 0xf0000000 58 - #define ORION5X_PCIE_WA_VIRT_BASE 0xfe000000 56 + #define ORION5X_PCIE_WA_VIRT_BASE 0xfd000000 59 57 #define ORION5X_PCIE_WA_SIZE SZ_16M 60 58 61 59 #define ORION5X_PCIE_MEM_PHYS_BASE 0xe0000000
+18 -38
arch/arm/mach-orion5x/pci.c
··· 162 162 pcie_ops.read = pcie_rd_conf_wa; 163 163 } 164 164 165 + pci_ioremap_io(sys->busnr * SZ_64K, ORION5X_PCIE_IO_PHYS_BASE); 166 + 165 167 /* 166 168 * Request resources. 167 169 */ 168 - res = kzalloc(sizeof(struct resource) * 2, GFP_KERNEL); 170 + res = kzalloc(sizeof(struct resource), GFP_KERNEL); 169 171 if (!res) 170 172 panic("pcie_setup unable to alloc resources"); 171 173 172 174 /* 173 - * IORESOURCE_IO 174 - */ 175 - sys->io_offset = 0; 176 - res[0].name = "PCIe I/O Space"; 177 - res[0].flags = IORESOURCE_IO; 178 - res[0].start = ORION5X_PCIE_IO_BUS_BASE; 179 - res[0].end = res[0].start + ORION5X_PCIE_IO_SIZE - 1; 180 - if (request_resource(&ioport_resource, &res[0])) 181 - panic("Request PCIe IO resource failed\n"); 182 - pci_add_resource_offset(&sys->resources, &res[0], sys->io_offset); 183 - 184 - /* 185 175 * IORESOURCE_MEM 186 176 */ 187 - res[1].name = "PCIe Memory Space"; 188 - res[1].flags = IORESOURCE_MEM; 189 - res[1].start = ORION5X_PCIE_MEM_PHYS_BASE; 190 - res[1].end = res[1].start + ORION5X_PCIE_MEM_SIZE - 1; 191 - if (request_resource(&iomem_resource, &res[1])) 177 + res->name = "PCIe Memory Space"; 178 + res->flags = IORESOURCE_MEM; 179 + res->start = ORION5X_PCIE_MEM_PHYS_BASE; 180 + res->end = res->start + ORION5X_PCIE_MEM_SIZE - 1; 181 + if (request_resource(&iomem_resource, res)) 192 182 panic("Request PCIe Memory resource failed\n"); 193 - pci_add_resource_offset(&sys->resources, &res[1], sys->mem_offset); 183 + pci_add_resource_offset(&sys->resources, res, sys->mem_offset); 194 184 195 185 return 1; 196 186 } ··· 479 489 */ 480 490 orion5x_setbits(PCI_CMD, PCI_CMD_HOST_REORDER); 481 491 492 + pci_ioremap_io(sys->busnr * SZ_64K, ORION5X_PCI_IO_PHYS_BASE); 493 + 482 494 /* 483 495 * Request resources 484 496 */ 485 - res = kzalloc(sizeof(struct resource) * 2, GFP_KERNEL); 497 + res = kzalloc(sizeof(struct resource), GFP_KERNEL); 486 498 if (!res) 487 499 panic("pci_setup unable to alloc resources"); 488 500 489 501 /* 490 - * IORESOURCE_IO 491 - */ 492 - sys->io_offset = 0; 493 - res[0].name = "PCI I/O Space"; 494 - res[0].flags = IORESOURCE_IO; 495 - res[0].start = ORION5X_PCI_IO_BUS_BASE; 496 - res[0].end = res[0].start + ORION5X_PCI_IO_SIZE - 1; 497 - if (request_resource(&ioport_resource, &res[0])) 498 - panic("Request PCI IO resource failed\n"); 499 - pci_add_resource_offset(&sys->resources, &res[0], sys->io_offset); 500 - 501 - /* 502 502 * IORESOURCE_MEM 503 503 */ 504 - res[1].name = "PCI Memory Space"; 505 - res[1].flags = IORESOURCE_MEM; 506 - res[1].start = ORION5X_PCI_MEM_PHYS_BASE; 507 - res[1].end = res[1].start + ORION5X_PCI_MEM_SIZE - 1; 508 - if (request_resource(&iomem_resource, &res[1])) 504 + res->name = "PCI Memory Space"; 505 + res->flags = IORESOURCE_MEM; 506 + res->start = ORION5X_PCI_MEM_PHYS_BASE; 507 + res->end = res->start + ORION5X_PCI_MEM_SIZE - 1; 508 + if (request_resource(&iomem_resource, res)) 509 509 panic("Request PCI Memory resource failed\n"); 510 - pci_add_resource_offset(&sys->resources, &res[1], sys->mem_offset); 510 + pci_add_resource_offset(&sys->resources, res, sys->mem_offset); 511 511 512 512 return 1; 513 513 }
-18
arch/arm/mach-shark/core.c
··· 21 21 #include <asm/mach/arch.h> 22 22 #include <asm/mach/time.h> 23 23 24 - #define IO_BASE 0xe0000000 25 - #define IO_SIZE 0x08000000 26 - #define IO_START 0x40000000 27 24 #define ROMCARD_SIZE 0x08000000 28 25 #define ROMCARD_START 0x10000000 29 26 ··· 101 104 102 105 extern void shark_init_irq(void); 103 106 104 - static struct map_desc shark_io_desc[] __initdata = { 105 - { 106 - .virtual = IO_BASE, 107 - .pfn = __phys_to_pfn(IO_START), 108 - .length = IO_SIZE, 109 - .type = MT_DEVICE 110 - } 111 - }; 112 - 113 - static void __init shark_map_io(void) 114 - { 115 - iotable_init(shark_io_desc, ARRAY_SIZE(shark_io_desc)); 116 - } 117 - 118 107 #define IRQ_TIMER 0 119 108 #define HZ_TIME ((1193180 + HZ/2) / HZ) 120 109 ··· 141 158 MACHINE_START(SHARK, "Shark") 142 159 /* Maintainer: Alexander Schulz */ 143 160 .atag_offset = 0x3000, 144 - .map_io = shark_map_io, 145 161 .init_early = shark_init_early, 146 162 .init_irq = shark_init_irq, 147 163 .timer = &shark_timer,
+4 -3
arch/arm/mach-shark/include/mach/debug-macro.S
··· 12 12 */ 13 13 14 14 .macro addruart, rp, rv, tmp 15 - mov \rp, #0xe0000000 16 - orr \rp, \rp, #0x000003f8 17 - mov \rv, \rp 15 + mov \rp, #0x3f8 16 + orr \rv, \rp, #0xfe000000 17 + orr \rv, \rv, #0x00e00000 18 + orr \rp, \rp, #0x40000000 18 19 .endm 19 20 20 21 .macro senduart,rd,rx
+2 -1
arch/arm/mach-shark/include/mach/entry-macro.S
··· 8 8 * warranty of any kind, whether express or implied. 9 9 */ 10 10 .macro get_irqnr_preamble, base, tmp 11 - mov \base, #0xe0000000 11 + mov \base, #0xfe000000 12 + orr \base, \base, #0x00e00000 12 13 .endm 13 14 14 15 .macro get_irqnr_and_base, irqnr, irqstat, base, tmp
-18
arch/arm/mach-shark/include/mach/io.h
··· 1 - /* 2 - * arch/arm/mach-shark/include/mach/io.h 3 - * 4 - * by Alexander Schulz 5 - * 6 - * derived from: 7 - * arch/arm/mach-ebsa110/include/mach/io.h 8 - * Copyright (C) 1997,1998 Russell King 9 - */ 10 - 11 - #ifndef __ASM_ARM_ARCH_IO_H 12 - #define __ASM_ARM_ARCH_IO_H 13 - 14 - #define IO_SPACE_LIMIT 0xffffffff 15 - 16 - #define __io(a) ((void __iomem *)(0xe0000000 + (a))) 17 - 18 - #endif
+5
arch/arm/mach-shark/pci.c
··· 8 8 #include <linux/kernel.h> 9 9 #include <linux/pci.h> 10 10 #include <linux/init.h> 11 + #include <linux/io.h> 11 12 #include <video/vga.h> 12 13 13 14 #include <asm/irq.h> 14 15 #include <asm/mach/pci.h> 15 16 #include <asm/mach-types.h> 17 + 18 + #define IO_START 0x40000000 16 19 17 20 static int __init shark_map_irq(const struct pci_dev *dev, u8 slot, u8 pin) 18 21 { ··· 46 43 pcibios_min_io = 0x6000; 47 44 pcibios_min_mem = 0x50000000; 48 45 vga_base = 0xe8000000; 46 + 47 + pci_ioremap_io(0, IO_START); 49 48 50 49 pci_common_init(&shark_pci); 51 50
-46
arch/arm/mach-tegra/include/mach/io.h
··· 1 - /* 2 - * arch/arm/mach-tegra/include/mach/io.h 3 - * 4 - * Copyright (C) 2010 Google, Inc. 5 - * 6 - * Author: 7 - * Colin Cross <ccross@google.com> 8 - * Erik Gilling <konkers@google.com> 9 - * 10 - * This software is licensed under the terms of the GNU General Public 11 - * License version 2, as published by the Free Software Foundation, and 12 - * may be copied, distributed, and modified under those terms. 13 - * 14 - * This program is distributed in the hope that it will be useful, 15 - * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 - * GNU General Public License for more details. 18 - * 19 - */ 20 - 21 - #ifndef __MACH_TEGRA_IO_H 22 - #define __MACH_TEGRA_IO_H 23 - 24 - #define IO_SPACE_LIMIT 0xffff 25 - 26 - #ifndef __ASSEMBLER__ 27 - 28 - #ifdef CONFIG_TEGRA_PCI 29 - extern void __iomem *tegra_pcie_io_base; 30 - 31 - static inline void __iomem *__io(unsigned long addr) 32 - { 33 - return tegra_pcie_io_base + (addr & IO_SPACE_LIMIT); 34 - } 35 - #else 36 - static inline void __iomem *__io(unsigned long addr) 37 - { 38 - return (void __iomem *)addr; 39 - } 40 - #endif 41 - 42 - #define __io(a) __io(a) 43 - 44 - #endif 45 - 46 - #endif
+3
arch/arm/mach-tegra/include/mach/iomap.h
··· 303 303 #define IO_APB_VIRT IOMEM(0xFE300000) 304 304 #define IO_APB_SIZE SZ_1M 305 305 306 + #define TEGRA_PCIE_BASE 0x80000000 307 + #define TEGRA_PCIE_IO_BASE (TEGRA_PCIE_BASE + SZ_4M) 308 + 306 309 #define IO_TO_VIRT_BETWEEN(p, st, sz) ((p) >= (st) && (p) < ((st) + (sz))) 307 310 #define IO_TO_VIRT_XLATE(p, pst, vst) (((p) - (pst) + (vst))) 308 311
+22 -73
arch/arm/mach-tegra/pcie.c
··· 171 171 * 0x90000000 - 0x9fffffff - non-prefetchable memory 172 172 * 0xa0000000 - 0xbfffffff - prefetchable memory 173 173 */ 174 - #define TEGRA_PCIE_BASE 0x80000000 175 - 176 174 #define PCIE_REGS_SZ SZ_16K 177 175 #define PCIE_CFG_OFF PCIE_REGS_SZ 178 176 #define PCIE_CFG_SZ SZ_1M ··· 178 180 #define PCIE_EXT_CFG_SZ SZ_1M 179 181 #define PCIE_IOMAP_SZ (PCIE_REGS_SZ + PCIE_CFG_SZ + PCIE_EXT_CFG_SZ) 180 182 181 - #define MMIO_BASE (TEGRA_PCIE_BASE + SZ_4M) 182 - #define MMIO_SIZE SZ_64K 183 183 #define MEM_BASE_0 (TEGRA_PCIE_BASE + SZ_256M) 184 184 #define MEM_SIZE_0 SZ_128M 185 185 #define MEM_BASE_1 (MEM_BASE_0 + MEM_SIZE_0) ··· 200 204 201 205 bool link_up; 202 206 203 - char io_space_name[16]; 204 207 char mem_space_name[16]; 205 208 char prefetch_space_name[20]; 206 - struct resource res[3]; 209 + struct resource res[2]; 207 210 }; 208 211 209 212 struct tegra_pcie_info { ··· 218 223 struct clk *pll_e; 219 224 }; 220 225 221 - static struct tegra_pcie_info tegra_pcie = { 222 - .res_mmio = { 223 - .name = "PCI IO", 224 - .start = MMIO_BASE, 225 - .end = MMIO_BASE + MMIO_SIZE - 1, 226 - .flags = IORESOURCE_MEM, 227 - }, 228 - }; 229 - 230 - void __iomem *tegra_pcie_io_base; 231 - EXPORT_SYMBOL(tegra_pcie_io_base); 226 + static struct tegra_pcie_info tegra_pcie; 232 227 233 228 static inline void afi_writel(u32 value, unsigned long offset) 234 229 { ··· 376 391 pp = tegra_pcie.port + nr; 377 392 pp->root_bus_nr = sys->busnr; 378 393 379 - /* 380 - * IORESOURCE_IO 381 - */ 382 - snprintf(pp->io_space_name, sizeof(pp->io_space_name), 383 - "PCIe %d I/O", pp->index); 384 - pp->io_space_name[sizeof(pp->io_space_name) - 1] = 0; 385 - pp->res[0].name = pp->io_space_name; 386 - if (pp->index == 0) { 387 - pp->res[0].start = PCIBIOS_MIN_IO; 388 - pp->res[0].end = pp->res[0].start + SZ_32K - 1; 389 - } else { 390 - pp->res[0].start = PCIBIOS_MIN_IO + SZ_32K; 391 - pp->res[0].end = IO_SPACE_LIMIT; 392 - } 393 - pp->res[0].flags = IORESOURCE_IO; 394 - if (request_resource(&ioport_resource, &pp->res[0])) 395 - panic("Request PCIe IO resource failed\n"); 396 - pci_add_resource_offset(&sys->resources, &pp->res[0], sys->io_offset); 394 + pci_ioremap_io(nr * SZ_64K, TEGRA_PCIE_IO_BASE); 397 395 398 396 /* 399 397 * IORESOURCE_MEM ··· 384 416 snprintf(pp->mem_space_name, sizeof(pp->mem_space_name), 385 417 "PCIe %d MEM", pp->index); 386 418 pp->mem_space_name[sizeof(pp->mem_space_name) - 1] = 0; 387 - pp->res[1].name = pp->mem_space_name; 419 + pp->res[0].name = pp->mem_space_name; 388 420 if (pp->index == 0) { 389 - pp->res[1].start = MEM_BASE_0; 390 - pp->res[1].end = pp->res[1].start + MEM_SIZE_0 - 1; 421 + pp->res[0].start = MEM_BASE_0; 422 + pp->res[0].end = pp->res[0].start + MEM_SIZE_0 - 1; 391 423 } else { 392 - pp->res[1].start = MEM_BASE_1; 393 - pp->res[1].end = pp->res[1].start + MEM_SIZE_1 - 1; 424 + pp->res[0].start = MEM_BASE_1; 425 + pp->res[0].end = pp->res[0].start + MEM_SIZE_1 - 1; 394 426 } 395 - pp->res[1].flags = IORESOURCE_MEM; 396 - if (request_resource(&iomem_resource, &pp->res[1])) 427 + pp->res[0].flags = IORESOURCE_MEM; 428 + if (request_resource(&iomem_resource, &pp->res[0])) 397 429 panic("Request PCIe Memory resource failed\n"); 398 - pci_add_resource_offset(&sys->resources, &pp->res[1], sys->mem_offset); 430 + pci_add_resource_offset(&sys->resources, &pp->res[0], sys->mem_offset); 399 431 400 432 /* 401 433 * IORESOURCE_MEM | IORESOURCE_PREFETCH ··· 403 435 snprintf(pp->prefetch_space_name, sizeof(pp->prefetch_space_name), 404 436 "PCIe %d PREFETCH MEM", pp->index); 405 437 pp->prefetch_space_name[sizeof(pp->prefetch_space_name) - 1] = 0; 406 - pp->res[2].name = pp->prefetch_space_name; 438 + pp->res[1].name = pp->prefetch_space_name; 407 439 if (pp->index == 0) { 408 - pp->res[2].start = PREFETCH_MEM_BASE_0; 409 - pp->res[2].end = pp->res[2].start + PREFETCH_MEM_SIZE_0 - 1; 440 + pp->res[1].start = PREFETCH_MEM_BASE_0; 441 + pp->res[1].end = pp->res[1].start + PREFETCH_MEM_SIZE_0 - 1; 410 442 } else { 411 - pp->res[2].start = PREFETCH_MEM_BASE_1; 412 - pp->res[2].end = pp->res[2].start + PREFETCH_MEM_SIZE_1 - 1; 443 + pp->res[1].start = PREFETCH_MEM_BASE_1; 444 + pp->res[1].end = pp->res[1].start + PREFETCH_MEM_SIZE_1 - 1; 413 445 } 414 - pp->res[2].flags = IORESOURCE_MEM | IORESOURCE_PREFETCH; 415 - if (request_resource(&iomem_resource, &pp->res[2])) 446 + pp->res[1].flags = IORESOURCE_MEM | IORESOURCE_PREFETCH; 447 + if (request_resource(&iomem_resource, &pp->res[1])) 416 448 panic("Request PCIe Prefetch Memory resource failed\n"); 417 - pci_add_resource_offset(&sys->resources, &pp->res[2], sys->mem_offset); 449 + pci_add_resource_offset(&sys->resources, &pp->res[1], sys->mem_offset); 418 450 419 451 return 1; 420 452 } ··· 509 541 510 542 /* Bar 2: downstream IO bar */ 511 543 fpci_bar = ((__u32)0xfdfc << 16); 512 - size = MMIO_SIZE; 513 - axi_address = MMIO_BASE; 544 + size = SZ_128K; 545 + axi_address = TEGRA_PCIE_IO_BASE; 514 546 afi_writel(axi_address, AFI_AXI_BAR2_START); 515 547 afi_writel(size >> 12, AFI_AXI_BAR2_SZ); 516 548 afi_writel(fpci_bar, AFI_FPCI_BAR2); ··· 744 776 745 777 static int __init tegra_pcie_get_resources(void) 746 778 { 747 - struct resource *res_mmio = &tegra_pcie.res_mmio; 748 779 int err; 749 780 750 781 err = tegra_pcie_clocks_get(); ··· 765 798 goto err_map_reg; 766 799 } 767 800 768 - err = request_resource(&iomem_resource, res_mmio); 769 - if (err) { 770 - pr_err("PCIE: Failed to request resources: %d\n", err); 771 - goto err_req_io; 772 - } 773 - 774 - tegra_pcie_io_base = ioremap_nocache(res_mmio->start, 775 - resource_size(res_mmio)); 776 - if (tegra_pcie_io_base == NULL) { 777 - pr_err("PCIE: Failed to map IO\n"); 778 - err = -ENOMEM; 779 - goto err_map_io; 780 - } 781 - 782 801 err = request_irq(INT_PCIE_INTR, tegra_pcie_isr, 783 802 IRQF_SHARED, "PCIE", &tegra_pcie); 784 803 if (err) { 785 804 pr_err("PCIE: Failed to register IRQ: %d\n", err); 786 - goto err_irq; 805 + goto err_req_io; 787 806 } 788 807 set_irq_flags(INT_PCIE_INTR, IRQF_VALID); 789 808 790 809 return 0; 791 810 792 - err_irq: 793 - iounmap(tegra_pcie_io_base); 794 - err_map_io: 795 - release_resource(&tegra_pcie.res_mmio); 796 811 err_req_io: 797 812 iounmap(tegra_pcie.regs); 798 813 err_map_reg:
-5
arch/arm/mach-versatile/core.c
··· 169 169 .pfn = __phys_to_pfn(VERSATILE_PCI_CFG_BASE), 170 170 .length = VERSATILE_PCI_CFG_BASE_SIZE, 171 171 .type = MT_DEVICE 172 - }, { 173 - .virtual = (unsigned long)VERSATILE_PCI_VIRT_MEM_BASE0, 174 - .pfn = __phys_to_pfn(VERSATILE_PCI_MEM_BASE0), 175 - .length = IO_SPACE_LIMIT, 176 - .type = MT_DEVICE 177 172 }, 178 173 #endif 179 174 };
-1
arch/arm/mach-versatile/include/mach/hardware.h
··· 29 29 */ 30 30 #define VERSATILE_PCI_VIRT_BASE (void __iomem *)0xe8000000ul 31 31 #define VERSATILE_PCI_CFG_VIRT_BASE (void __iomem *)0xe9000000ul 32 - #define VERSATILE_PCI_VIRT_MEM_BASE0 (void __iomem *)PCIO_BASE 33 32 34 33 /* macro to get at MMIO space when running virtually */ 35 34 #define IO_ADDRESS(x) (((x) & 0x0fffffff) + (((x) >> 4) & 0x0f000000) + 0xf0000000)
-27
arch/arm/mach-versatile/include/mach/io.h
··· 1 - /* 2 - * arch/arm/mach-versatile/include/mach/io.h 3 - * 4 - * Copyright (C) 2003 ARM Limited 5 - * 6 - * This program is free software; you can redistribute it and/or modify 7 - * it under the terms of the GNU General Public License as published by 8 - * the Free Software Foundation; either version 2 of the License, or 9 - * (at your option) any later version. 10 - * 11 - * This program is distributed in the hope that it will be useful, 12 - * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 - * GNU General Public License for more details. 15 - * 16 - * You should have received a copy of the GNU General Public License 17 - * along with this program; if not, write to the Free Software 18 - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 - */ 20 - #ifndef __ASM_ARM_ARCH_IO_H 21 - #define __ASM_ARM_ARCH_IO_H 22 - 23 - #define PCIO_BASE 0xeb000000ul 24 - 25 - #define __io(a) ((a) + PCIO_BASE) 26 - 27 - #endif
+4 -18
arch/arm/mach-versatile/pci.c
··· 169 169 .write = versatile_write_config, 170 170 }; 171 171 172 - static struct resource io_port = { 173 - .name = "PCI", 174 - .start = 0, 175 - .end = IO_SPACE_LIMIT, 176 - .flags = IORESOURCE_IO, 177 - }; 178 - 179 172 static struct resource io_mem = { 180 173 .name = "PCI I/O space", 181 174 .start = VERSATILE_PCI_MEM_BASE0, ··· 200 207 "memory region (%d)\n", ret); 201 208 goto out; 202 209 } 203 - ret = request_resource(&ioport_resource, &io_port); 204 - if (ret) { 205 - printk(KERN_ERR "PCI: unable to allocate I/O " 206 - "port region (%d)\n", ret); 207 - goto out; 208 - } 209 210 ret = request_resource(&iomem_resource, &non_mem); 210 211 if (ret) { 211 212 printk(KERN_ERR "PCI: unable to allocate non-prefetchable " ··· 214 227 } 215 228 216 229 /* 217 - * the IO resource for this bus 218 230 * the mem resource for this bus 219 231 * the prefetch mem resource for this bus 220 232 */ 221 - pci_add_resource_offset(&sys->resources, &io_port, sys->io_offset); 222 233 pci_add_resource_offset(&sys->resources, &non_mem, sys->mem_offset); 223 234 pci_add_resource_offset(&sys->resources, &pre_mem, sys->mem_offset); 224 235 ··· 245 260 goto out; 246 261 } 247 262 263 + ret = pci_ioremap_io(0, VERSATILE_PCI_MEM_BASE0); 264 + if (ret) 265 + goto out; 266 + 248 267 if (nr == 0) { 249 - sys->mem_offset = 0; 250 - sys->io_offset = 0; 251 268 ret = pci_versatile_setup_resources(sys); 252 269 if (ret < 0) { 253 270 printk("pci_versatile_setup: resources... oops?\n"); ··· 306 319 307 320 void __init pci_versatile_preinit(void) 308 321 { 309 - pcibios_min_io = 0x44000000; 310 322 pcibios_min_mem = 0x50000000; 311 323 312 324 __raw_writel(VERSATILE_PCI_MEM_BASE0 >> 28, PCI_IMAP0);
+14
arch/arm/mm/ioremap.c
··· 36 36 #include <asm/system_info.h> 37 37 38 38 #include <asm/mach/map.h> 39 + #include <asm/mach/pci.h> 39 40 #include "mm.h" 40 41 41 42 int ioremap_page(unsigned long virt, unsigned long phys, ··· 384 383 arch_iounmap(io_addr); 385 384 } 386 385 EXPORT_SYMBOL(__arm_iounmap); 386 + 387 + #ifdef CONFIG_PCI 388 + int pci_ioremap_io(unsigned int offset, phys_addr_t phys_addr) 389 + { 390 + BUG_ON(offset + SZ_64K > IO_SPACE_LIMIT); 391 + 392 + return ioremap_page_range(PCI_IO_VIRT_BASE + offset, 393 + PCI_IO_VIRT_BASE + offset + SZ_64K, 394 + phys_addr, 395 + __pgprot(get_mem_type(MT_DEVICE)->prot_pte)); 396 + } 397 + EXPORT_SYMBOL_GPL(pci_ioremap_io); 398 + #endif
+43 -11
arch/arm/mm/mmu.c
··· 31 31 32 32 #include <asm/mach/arch.h> 33 33 #include <asm/mach/map.h> 34 + #include <asm/mach/pci.h> 34 35 35 36 #include "mm.h" 36 37 ··· 217 216 .prot_l1 = PMD_TYPE_TABLE, 218 217 .prot_sect = PROT_SECT_DEVICE | PMD_SECT_WB, 219 218 .domain = DOMAIN_IO, 220 - }, 219 + }, 221 220 [MT_DEVICE_WC] = { /* ioremap_wc */ 222 221 .prot_pte = PROT_PTE_DEVICE | L_PTE_MT_DEV_WC, 223 222 .prot_l1 = PMD_TYPE_TABLE, ··· 778 777 create_mapping(md); 779 778 vm->addr = (void *)(md->virtual & PAGE_MASK); 780 779 vm->size = PAGE_ALIGN(md->length + (md->virtual & ~PAGE_MASK)); 781 - vm->phys_addr = __pfn_to_phys(md->pfn); 782 - vm->flags = VM_IOREMAP | VM_ARM_STATIC_MAPPING; 780 + vm->phys_addr = __pfn_to_phys(md->pfn); 781 + vm->flags = VM_IOREMAP | VM_ARM_STATIC_MAPPING; 783 782 vm->flags |= VM_ARM_MTYPE(md->type); 784 783 vm->caller = iotable_init; 785 784 vm_area_add_early(vm++); 786 785 } 786 + } 787 + 788 + void __init vm_reserve_area_early(unsigned long addr, unsigned long size, 789 + void *caller) 790 + { 791 + struct vm_struct *vm; 792 + 793 + vm = early_alloc_aligned(sizeof(*vm), __alignof__(*vm)); 794 + vm->addr = (void *)addr; 795 + vm->size = size; 796 + vm->flags = VM_IOREMAP | VM_ARM_STATIC_MAPPING; 797 + vm->caller = caller; 798 + vm_area_add_early(vm); 787 799 } 788 800 789 801 #ifndef CONFIG_ARM_LPAE ··· 816 802 817 803 static void __init pmd_empty_section_gap(unsigned long addr) 818 804 { 819 - struct vm_struct *vm; 820 - 821 - vm = early_alloc_aligned(sizeof(*vm), __alignof__(*vm)); 822 - vm->addr = (void *)addr; 823 - vm->size = SECTION_SIZE; 824 - vm->flags = VM_IOREMAP | VM_ARM_STATIC_MAPPING; 825 - vm->caller = pmd_empty_section_gap; 826 - vm_area_add_early(vm); 805 + vm_reserve_area_early(addr, SECTION_SIZE, pmd_empty_section_gap); 827 806 } 828 807 829 808 static void __init fill_pmd_gaps(void) ··· 863 856 864 857 #else 865 858 #define fill_pmd_gaps() do { } while (0) 859 + #endif 860 + 861 + #if defined(CONFIG_PCI) && !defined(CONFIG_NEED_MACH_IO_H) 862 + static void __init pci_reserve_io(void) 863 + { 864 + struct vm_struct *vm; 865 + unsigned long addr; 866 + 867 + /* we're still single threaded hence no lock needed here */ 868 + for (vm = vmlist; vm; vm = vm->next) { 869 + if (!(vm->flags & VM_ARM_STATIC_MAPPING)) 870 + continue; 871 + addr = (unsigned long)vm->addr; 872 + addr &= ~(SZ_2M - 1); 873 + if (addr == PCI_IO_VIRT_BASE) 874 + return; 875 + 876 + } 877 + vm_reserve_area_early(PCI_IO_VIRT_BASE, SZ_2M, pci_reserve_io); 878 + } 879 + #else 880 + #define pci_reserve_io() do { } while (0) 866 881 #endif 867 882 868 883 static void * __initdata vmalloc_min = ··· 1169 1140 if (mdesc->map_io) 1170 1141 mdesc->map_io(); 1171 1142 fill_pmd_gaps(); 1143 + 1144 + /* Reserve fixed i/o space in VMALLOC region */ 1145 + pci_reserve_io(); 1172 1146 1173 1147 /* 1174 1148 * Finally flush the caches and tlb to ensure that we're in a
+9 -16
arch/arm/plat-iop/pci.c
··· 192 192 if (nr != 0) 193 193 return 0; 194 194 195 - res = kzalloc(2 * sizeof(struct resource), GFP_KERNEL); 195 + res = kzalloc(sizeof(struct resource), GFP_KERNEL); 196 196 if (!res) 197 197 panic("PCI: unable to alloc resources"); 198 198 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 - res[0].name = "IOP3XX PCI I/O Space"; 202 - res[0].flags = IORESOURCE_IO; 203 - request_resource(&ioport_resource, &res[0]); 204 - 205 - res[1].start = IOP3XX_PCI_LOWER_MEM_PA; 206 - res[1].end = IOP3XX_PCI_LOWER_MEM_PA + IOP3XX_PCI_MEM_WINDOW_SIZE - 1; 207 - res[1].name = "IOP3XX PCI Memory Space"; 208 - res[1].flags = IORESOURCE_MEM; 209 - request_resource(&iomem_resource, &res[1]); 199 + res->start = IOP3XX_PCI_LOWER_MEM_PA; 200 + res->end = IOP3XX_PCI_LOWER_MEM_PA + IOP3XX_PCI_MEM_WINDOW_SIZE - 1; 201 + res->name = "IOP3XX PCI Memory Space"; 202 + res->flags = IORESOURCE_MEM; 203 + request_resource(&iomem_resource, res); 210 204 211 205 /* 212 206 * Use whatever translation is already setup. 213 207 */ 214 208 sys->mem_offset = IOP3XX_PCI_LOWER_MEM_PA - *IOP3XX_OMWTVR0; 215 - sys->io_offset = IOP3XX_PCI_LOWER_IO_PA - *IOP3XX_OIOWTVR; 216 209 217 - pci_add_resource_offset(&sys->resources, &res[0], sys->io_offset); 218 - pci_add_resource_offset(&sys->resources, &res[1], sys->mem_offset); 210 + pci_add_resource_offset(&sys->resources, res, sys->mem_offset); 211 + 212 + pci_ioremap_io(0, IOP3XX_PCI_LOWER_IO_PA); 219 213 220 214 return 1; 221 215 } ··· 361 367 362 368 void __init iop3xx_pci_preinit(void) 363 369 { 364 - pcibios_min_io = 0; 365 370 pcibios_min_mem = 0; 366 371 367 372 iop3xx_atu_disable();
-5
arch/arm/plat-iop/setup.c
··· 25 25 .pfn = __phys_to_pfn(IOP3XX_PERIPHERAL_PHYS_BASE), 26 26 .length = IOP3XX_PERIPHERAL_SIZE, 27 27 .type = MT_UNCACHED, 28 - }, { /* PCI IO space */ 29 - .virtual = IOP3XX_PCI_LOWER_IO_VA, 30 - .pfn = __phys_to_pfn(IOP3XX_PCI_LOWER_IO_PA), 31 - .length = IOP3XX_PCI_IO_WINDOW_SIZE, 32 - .type = MT_DEVICE, 33 28 }, 34 29 }; 35 30
+61 -60
drivers/i2c/busses/i2c-iop3xx.c
··· 4 4 /* Copyright (C) 2003 Peter Milne, D-TACQ Solutions Ltd 5 5 * <Peter dot Milne at D hyphen TACQ dot com> 6 6 * 7 - * With acknowledgements to i2c-algo-ibm_ocp.c by 7 + * With acknowledgements to i2c-algo-ibm_ocp.c by 8 8 * Ian DaSilva, MontaVista Software, Inc. idasilva@mvista.com 9 9 * 10 10 * And i2c-algo-pcf.c, which was created by Simon G. Vogl and Hans Berglund: 11 11 * 12 12 * Copyright (C) 1995-1997 Simon G. Vogl, 1998-2000 Hans Berglund 13 - * 13 + * 14 14 * And which acknowledged Kyösti Mälkki <kmalkki@cc.hut.fi>, 15 15 * Frodo Looijaard <frodol@dds.nl>, Martin Bailey<mbailey@littlefeet-inc.com> 16 16 * ··· 39 39 #include <linux/platform_device.h> 40 40 #include <linux/i2c.h> 41 41 #include <linux/io.h> 42 + #include <linux/gpio.h> 42 43 43 44 #include "i2c-iop3xx.h" 44 45 45 46 /* global unit counter */ 46 47 static int i2c_id; 47 48 48 - static inline unsigned char 49 - iic_cook_addr(struct i2c_msg *msg) 49 + static inline unsigned char 50 + iic_cook_addr(struct i2c_msg *msg) 50 51 { 51 52 unsigned char addr; 52 53 ··· 56 55 if (msg->flags & I2C_M_RD) 57 56 addr |= 1; 58 57 59 - return addr; 58 + return addr; 60 59 } 61 60 62 - static void 61 + static void 63 62 iop3xx_i2c_reset(struct i2c_algo_iop3xx_data *iop3xx_adap) 64 63 { 65 64 /* Follows devman 9.3 */ 66 65 __raw_writel(IOP3XX_ICR_UNIT_RESET, iop3xx_adap->ioaddr + CR_OFFSET); 67 66 __raw_writel(IOP3XX_ISR_CLEARBITS, iop3xx_adap->ioaddr + SR_OFFSET); 68 67 __raw_writel(0, iop3xx_adap->ioaddr + CR_OFFSET); 69 - } 68 + } 70 69 71 - static void 70 + static void 72 71 iop3xx_i2c_enable(struct i2c_algo_iop3xx_data *iop3xx_adap) 73 72 { 74 73 u32 cr = IOP3XX_ICR_GCD | IOP3XX_ICR_SCLEN | IOP3XX_ICR_UE; 75 74 76 - /* 75 + /* 77 76 * Every time unit enable is asserted, GPOD needs to be cleared 78 77 * on IOP3XX to avoid data corruption on the bus. 79 78 */ 80 79 #if defined(CONFIG_ARCH_IOP32X) || defined(CONFIG_ARCH_IOP33X) 81 80 if (iop3xx_adap->id == 0) { 82 - gpio_line_set(IOP3XX_GPIO_LINE(7), GPIO_LOW); 83 - gpio_line_set(IOP3XX_GPIO_LINE(6), GPIO_LOW); 81 + gpio_set_value(7, 0); 82 + gpio_set_value(6, 0); 84 83 } else { 85 - gpio_line_set(IOP3XX_GPIO_LINE(5), GPIO_LOW); 86 - gpio_line_set(IOP3XX_GPIO_LINE(4), GPIO_LOW); 84 + gpio_set_value(5, 0); 85 + gpio_set_value(4, 0); 87 86 } 88 87 #endif 89 88 /* NB SR bits not same position as CR IE bits :-( */ 90 - iop3xx_adap->SR_enabled = 89 + iop3xx_adap->SR_enabled = 91 90 IOP3XX_ISR_ALD | IOP3XX_ISR_BERRD | 92 91 IOP3XX_ISR_RXFULL | IOP3XX_ISR_TXEMPTY; 93 92 ··· 97 96 __raw_writel(cr, iop3xx_adap->ioaddr + CR_OFFSET); 98 97 } 99 98 100 - static void 99 + static void 101 100 iop3xx_i2c_transaction_cleanup(struct i2c_algo_iop3xx_data *iop3xx_adap) 102 101 { 103 102 unsigned long cr = __raw_readl(iop3xx_adap->ioaddr + CR_OFFSET); 104 - 105 - cr &= ~(IOP3XX_ICR_MSTART | IOP3XX_ICR_TBYTE | 103 + 104 + cr &= ~(IOP3XX_ICR_MSTART | IOP3XX_ICR_TBYTE | 106 105 IOP3XX_ICR_MSTOP | IOP3XX_ICR_SCLEN); 107 106 108 107 __raw_writel(cr, iop3xx_adap->ioaddr + CR_OFFSET); 109 108 } 110 109 111 - /* 112 - * NB: the handler has to clear the source of the interrupt! 110 + /* 111 + * NB: the handler has to clear the source of the interrupt! 113 112 * Then it passes the SR flags of interest to BH via adap data 114 113 */ 115 - static irqreturn_t 116 - iop3xx_i2c_irq_handler(int this_irq, void *dev_id) 114 + static irqreturn_t 115 + iop3xx_i2c_irq_handler(int this_irq, void *dev_id) 117 116 { 118 117 struct i2c_algo_iop3xx_data *iop3xx_adap = dev_id; 119 118 u32 sr = __raw_readl(iop3xx_adap->ioaddr + SR_OFFSET); ··· 127 126 } 128 127 129 128 /* check all error conditions, clear them , report most important */ 130 - static int 129 + static int 131 130 iop3xx_i2c_error(u32 sr) 132 131 { 133 132 int rc = 0; ··· 136 135 if ( !rc ) rc = -I2C_ERR_BERR; 137 136 } 138 137 if ((sr & IOP3XX_ISR_ALD)) { 139 - if ( !rc ) rc = -I2C_ERR_ALD; 138 + if ( !rc ) rc = -I2C_ERR_ALD; 140 139 } 141 - return rc; 140 + return rc; 142 141 } 143 142 144 - static inline u32 143 + static inline u32 145 144 iop3xx_i2c_get_srstat(struct i2c_algo_iop3xx_data *iop3xx_adap) 146 145 { 147 146 unsigned long flags; ··· 162 161 typedef int (* compare_func)(unsigned test, unsigned mask); 163 162 /* returns 1 on correct comparison */ 164 163 165 - static int 166 - iop3xx_i2c_wait_event(struct i2c_algo_iop3xx_data *iop3xx_adap, 164 + static int 165 + iop3xx_i2c_wait_event(struct i2c_algo_iop3xx_data *iop3xx_adap, 167 166 unsigned flags, unsigned* status, 168 167 compare_func compare) 169 168 { ··· 193 192 } 194 193 195 194 /* 196 - * Concrete compare_funcs 195 + * Concrete compare_funcs 197 196 */ 198 - static int 197 + static int 199 198 all_bits_clear(unsigned test, unsigned mask) 200 199 { 201 200 return (test & mask) == 0; 202 201 } 203 202 204 - static int 203 + static int 205 204 any_bits_set(unsigned test, unsigned mask) 206 205 { 207 206 return (test & mask) != 0; 208 207 } 209 208 210 - static int 209 + static int 211 210 iop3xx_i2c_wait_tx_done(struct i2c_algo_iop3xx_data *iop3xx_adap, int *status) 212 211 { 213 - return iop3xx_i2c_wait_event( 214 - iop3xx_adap, 212 + return iop3xx_i2c_wait_event( 213 + iop3xx_adap, 215 214 IOP3XX_ISR_TXEMPTY | IOP3XX_ISR_ALD | IOP3XX_ISR_BERRD, 216 215 status, any_bits_set); 217 216 } 218 217 219 - static int 218 + static int 220 219 iop3xx_i2c_wait_rx_done(struct i2c_algo_iop3xx_data *iop3xx_adap, int *status) 221 220 { 222 - return iop3xx_i2c_wait_event( 223 - iop3xx_adap, 221 + return iop3xx_i2c_wait_event( 222 + iop3xx_adap, 224 223 IOP3XX_ISR_RXFULL | IOP3XX_ISR_ALD | IOP3XX_ISR_BERRD, 225 224 status, any_bits_set); 226 225 } 227 226 228 - static int 227 + static int 229 228 iop3xx_i2c_wait_idle(struct i2c_algo_iop3xx_data *iop3xx_adap, int *status) 230 229 { 231 - return iop3xx_i2c_wait_event( 230 + return iop3xx_i2c_wait_event( 232 231 iop3xx_adap, IOP3XX_ISR_UNITBUSY, status, all_bits_clear); 233 232 } 234 233 235 - static int 236 - iop3xx_i2c_send_target_addr(struct i2c_algo_iop3xx_data *iop3xx_adap, 234 + static int 235 + iop3xx_i2c_send_target_addr(struct i2c_algo_iop3xx_data *iop3xx_adap, 237 236 struct i2c_msg* msg) 238 237 { 239 238 unsigned long cr = __raw_readl(iop3xx_adap->ioaddr + CR_OFFSET); ··· 248 247 } 249 248 250 249 __raw_writel(iic_cook_addr(msg), iop3xx_adap->ioaddr + DBR_OFFSET); 251 - 250 + 252 251 cr &= ~(IOP3XX_ICR_MSTOP | IOP3XX_ICR_NACK); 253 252 cr |= IOP3XX_ICR_MSTART | IOP3XX_ICR_TBYTE; 254 253 ··· 258 257 return rc; 259 258 } 260 259 261 - static int 262 - iop3xx_i2c_write_byte(struct i2c_algo_iop3xx_data *iop3xx_adap, char byte, 260 + static int 261 + iop3xx_i2c_write_byte(struct i2c_algo_iop3xx_data *iop3xx_adap, char byte, 263 262 int stop) 264 263 { 265 264 unsigned long cr = __raw_readl(iop3xx_adap->ioaddr + CR_OFFSET); ··· 278 277 rc = iop3xx_i2c_wait_tx_done(iop3xx_adap, &status); 279 278 280 279 return rc; 281 - } 280 + } 282 281 283 - static int 284 - iop3xx_i2c_read_byte(struct i2c_algo_iop3xx_data *iop3xx_adap, char* byte, 282 + static int 283 + iop3xx_i2c_read_byte(struct i2c_algo_iop3xx_data *iop3xx_adap, char* byte, 285 284 int stop) 286 285 { 287 286 unsigned long cr = __raw_readl(iop3xx_adap->ioaddr + CR_OFFSET); ··· 305 304 return rc; 306 305 } 307 306 308 - static int 307 + static int 309 308 iop3xx_i2c_writebytes(struct i2c_adapter *i2c_adap, const char *buf, int count) 310 309 { 311 310 struct i2c_algo_iop3xx_data *iop3xx_adap = i2c_adap->algo_data; 312 311 int ii; 313 312 int rc = 0; 314 313 315 - for (ii = 0; rc == 0 && ii != count; ++ii) 314 + for (ii = 0; rc == 0 && ii != count; ++ii) 316 315 rc = iop3xx_i2c_write_byte(iop3xx_adap, buf[ii], ii==count-1); 317 316 return rc; 318 317 } 319 318 320 - static int 319 + static int 321 320 iop3xx_i2c_readbytes(struct i2c_adapter *i2c_adap, char *buf, int count) 322 321 { 323 322 struct i2c_algo_iop3xx_data *iop3xx_adap = i2c_adap->algo_data; ··· 326 325 327 326 for (ii = 0; rc == 0 && ii != count; ++ii) 328 327 rc = iop3xx_i2c_read_byte(iop3xx_adap, &buf[ii], ii==count-1); 329 - 328 + 330 329 return rc; 331 330 } 332 331 ··· 337 336 * Each transfer (i.e. a read or a write) is separated by a repeated start 338 337 * condition. 339 338 */ 340 - static int 341 - iop3xx_i2c_handle_msg(struct i2c_adapter *i2c_adap, struct i2c_msg* pmsg) 339 + static int 340 + iop3xx_i2c_handle_msg(struct i2c_adapter *i2c_adap, struct i2c_msg* pmsg) 342 341 { 343 342 struct i2c_algo_iop3xx_data *iop3xx_adap = i2c_adap->algo_data; 344 343 int rc; ··· 358 357 /* 359 358 * master_xfer() - main read/write entry 360 359 */ 361 - static int 362 - iop3xx_i2c_master_xfer(struct i2c_adapter *i2c_adap, struct i2c_msg *msgs, 360 + static int 361 + iop3xx_i2c_master_xfer(struct i2c_adapter *i2c_adap, struct i2c_msg *msgs, 363 362 int num) 364 363 { 365 364 struct i2c_algo_iop3xx_data *iop3xx_adap = i2c_adap->algo_data; ··· 376 375 } 377 376 378 377 iop3xx_i2c_transaction_cleanup(iop3xx_adap); 379 - 378 + 380 379 if(ret) 381 380 return ret; 382 381 383 - return im; 382 + return im; 384 383 } 385 384 386 - static u32 385 + static u32 387 386 iop3xx_i2c_func(struct i2c_adapter *adap) 388 387 { 389 388 return I2C_FUNC_I2C | I2C_FUNC_SMBUS_EMUL; ··· 394 393 .functionality = iop3xx_i2c_func, 395 394 }; 396 395 397 - static int 396 + static int 398 397 iop3xx_i2c_remove(struct platform_device *pdev) 399 398 { 400 399 struct i2c_adapter *padapter = platform_get_drvdata(pdev); 401 - struct i2c_algo_iop3xx_data *adapter_data = 400 + struct i2c_algo_iop3xx_data *adapter_data = 402 401 (struct i2c_algo_iop3xx_data *)padapter->algo_data; 403 402 struct resource *res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 404 403 unsigned long cr = __raw_readl(adapter_data->ioaddr + CR_OFFSET); ··· 420 419 return 0; 421 420 } 422 421 423 - static int 422 + static int 424 423 iop3xx_i2c_probe(struct platform_device *pdev) 425 424 { 426 425 struct resource *res;