diff options
Diffstat (limited to 'arch/arm/mach-tegra/pcie.c')
-rw-r--r-- | arch/arm/mach-tegra/pcie.c | 107 |
1 files changed, 23 insertions, 84 deletions
diff --git a/arch/arm/mach-tegra/pcie.c b/arch/arm/mach-tegra/pcie.c index d3ad5150d660..a8dba6489c9b 100644 --- a/arch/arm/mach-tegra/pcie.c +++ b/arch/arm/mach-tegra/pcie.c | |||
@@ -171,8 +171,6 @@ static void __iomem *reg_pmc_base = IO_ADDRESS(TEGRA_PMC_BASE); | |||
171 | * 0x90000000 - 0x9fffffff - non-prefetchable memory | 171 | * 0x90000000 - 0x9fffffff - non-prefetchable memory |
172 | * 0xa0000000 - 0xbfffffff - prefetchable memory | 172 | * 0xa0000000 - 0xbfffffff - prefetchable memory |
173 | */ | 173 | */ |
174 | #define TEGRA_PCIE_BASE 0x80000000 | ||
175 | |||
176 | #define PCIE_REGS_SZ SZ_16K | 174 | #define PCIE_REGS_SZ SZ_16K |
177 | #define PCIE_CFG_OFF PCIE_REGS_SZ | 175 | #define PCIE_CFG_OFF PCIE_REGS_SZ |
178 | #define PCIE_CFG_SZ SZ_1M | 176 | #define PCIE_CFG_SZ SZ_1M |
@@ -180,8 +178,6 @@ static void __iomem *reg_pmc_base = IO_ADDRESS(TEGRA_PMC_BASE); | |||
180 | #define PCIE_EXT_CFG_SZ SZ_1M | 178 | #define PCIE_EXT_CFG_SZ SZ_1M |
181 | #define PCIE_IOMAP_SZ (PCIE_REGS_SZ + PCIE_CFG_SZ + PCIE_EXT_CFG_SZ) | 179 | #define PCIE_IOMAP_SZ (PCIE_REGS_SZ + PCIE_CFG_SZ + PCIE_EXT_CFG_SZ) |
182 | 180 | ||
183 | #define MMIO_BASE (TEGRA_PCIE_BASE + SZ_4M) | ||
184 | #define MMIO_SIZE SZ_64K | ||
185 | #define MEM_BASE_0 (TEGRA_PCIE_BASE + SZ_256M) | 181 | #define MEM_BASE_0 (TEGRA_PCIE_BASE + SZ_256M) |
186 | #define MEM_SIZE_0 SZ_128M | 182 | #define MEM_SIZE_0 SZ_128M |
187 | #define MEM_BASE_1 (MEM_BASE_0 + MEM_SIZE_0) | 183 | #define MEM_BASE_1 (MEM_BASE_0 + MEM_SIZE_0) |
@@ -204,10 +200,9 @@ struct tegra_pcie_port { | |||
204 | 200 | ||
205 | bool link_up; | 201 | bool link_up; |
206 | 202 | ||
207 | char io_space_name[16]; | ||
208 | char mem_space_name[16]; | 203 | char mem_space_name[16]; |
209 | char prefetch_space_name[20]; | 204 | char prefetch_space_name[20]; |
210 | struct resource res[3]; | 205 | struct resource res[2]; |
211 | }; | 206 | }; |
212 | 207 | ||
213 | struct tegra_pcie_info { | 208 | struct tegra_pcie_info { |
@@ -223,17 +218,7 @@ struct tegra_pcie_info { | |||
223 | struct clk *pll_e; | 218 | struct clk *pll_e; |
224 | }; | 219 | }; |
225 | 220 | ||
226 | static struct tegra_pcie_info tegra_pcie = { | 221 | static struct tegra_pcie_info tegra_pcie; |
227 | .res_mmio = { | ||
228 | .name = "PCI IO", | ||
229 | .start = MMIO_BASE, | ||
230 | .end = MMIO_BASE + MMIO_SIZE - 1, | ||
231 | .flags = IORESOURCE_MEM, | ||
232 | }, | ||
233 | }; | ||
234 | |||
235 | void __iomem *tegra_pcie_io_base; | ||
236 | EXPORT_SYMBOL(tegra_pcie_io_base); | ||
237 | 222 | ||
238 | static inline void afi_writel(u32 value, unsigned long offset) | 223 | static inline void afi_writel(u32 value, unsigned long offset) |
239 | { | 224 | { |
@@ -367,17 +352,7 @@ DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_NVIDIA, 0x0bf1, tegra_pcie_fixup_class); | |||
367 | /* Tegra PCIE requires relaxed ordering */ | 352 | /* Tegra PCIE requires relaxed ordering */ |
368 | static void __devinit tegra_pcie_relax_enable(struct pci_dev *dev) | 353 | static void __devinit tegra_pcie_relax_enable(struct pci_dev *dev) |
369 | { | 354 | { |
370 | u16 val16; | 355 | pcie_capability_set_word(dev, PCI_EXP_DEVCTL, PCI_EXP_DEVCTL_RELAX_EN); |
371 | int pos = pci_find_capability(dev, PCI_CAP_ID_EXP); | ||
372 | |||
373 | if (pos <= 0) { | ||
374 | dev_err(&dev->dev, "skipping relaxed ordering fixup\n"); | ||
375 | return; | ||
376 | } | ||
377 | |||
378 | pci_read_config_word(dev, pos + PCI_EXP_DEVCTL, &val16); | ||
379 | val16 |= PCI_EXP_DEVCTL_RELAX_EN; | ||
380 | pci_write_config_word(dev, pos + PCI_EXP_DEVCTL, val16); | ||
381 | } | 356 | } |
382 | DECLARE_PCI_FIXUP_FINAL(PCI_ANY_ID, PCI_ANY_ID, tegra_pcie_relax_enable); | 357 | DECLARE_PCI_FIXUP_FINAL(PCI_ANY_ID, PCI_ANY_ID, tegra_pcie_relax_enable); |
383 | 358 | ||
@@ -391,24 +366,7 @@ static int tegra_pcie_setup(int nr, struct pci_sys_data *sys) | |||
391 | pp = tegra_pcie.port + nr; | 366 | pp = tegra_pcie.port + nr; |
392 | pp->root_bus_nr = sys->busnr; | 367 | pp->root_bus_nr = sys->busnr; |
393 | 368 | ||
394 | /* | 369 | pci_ioremap_io(nr * SZ_64K, TEGRA_PCIE_IO_BASE); |
395 | * IORESOURCE_IO | ||
396 | */ | ||
397 | snprintf(pp->io_space_name, sizeof(pp->io_space_name), | ||
398 | "PCIe %d I/O", pp->index); | ||
399 | pp->io_space_name[sizeof(pp->io_space_name) - 1] = 0; | ||
400 | pp->res[0].name = pp->io_space_name; | ||
401 | if (pp->index == 0) { | ||
402 | pp->res[0].start = PCIBIOS_MIN_IO; | ||
403 | pp->res[0].end = pp->res[0].start + SZ_32K - 1; | ||
404 | } else { | ||
405 | pp->res[0].start = PCIBIOS_MIN_IO + SZ_32K; | ||
406 | pp->res[0].end = IO_SPACE_LIMIT; | ||
407 | } | ||
408 | pp->res[0].flags = IORESOURCE_IO; | ||
409 | if (request_resource(&ioport_resource, &pp->res[0])) | ||
410 | panic("Request PCIe IO resource failed\n"); | ||
411 | pci_add_resource_offset(&sys->resources, &pp->res[0], sys->io_offset); | ||
412 | 370 | ||
413 | /* | 371 | /* |
414 | * IORESOURCE_MEM | 372 | * IORESOURCE_MEM |
@@ -416,18 +374,18 @@ static int tegra_pcie_setup(int nr, struct pci_sys_data *sys) | |||
416 | snprintf(pp->mem_space_name, sizeof(pp->mem_space_name), | 374 | snprintf(pp->mem_space_name, sizeof(pp->mem_space_name), |
417 | "PCIe %d MEM", pp->index); | 375 | "PCIe %d MEM", pp->index); |
418 | pp->mem_space_name[sizeof(pp->mem_space_name) - 1] = 0; | 376 | pp->mem_space_name[sizeof(pp->mem_space_name) - 1] = 0; |
419 | pp->res[1].name = pp->mem_space_name; | 377 | pp->res[0].name = pp->mem_space_name; |
420 | if (pp->index == 0) { | 378 | if (pp->index == 0) { |
421 | pp->res[1].start = MEM_BASE_0; | 379 | pp->res[0].start = MEM_BASE_0; |
422 | pp->res[1].end = pp->res[1].start + MEM_SIZE_0 - 1; | 380 | pp->res[0].end = pp->res[0].start + MEM_SIZE_0 - 1; |
423 | } else { | 381 | } else { |
424 | pp->res[1].start = MEM_BASE_1; | 382 | pp->res[0].start = MEM_BASE_1; |
425 | pp->res[1].end = pp->res[1].start + MEM_SIZE_1 - 1; | 383 | pp->res[0].end = pp->res[0].start + MEM_SIZE_1 - 1; |
426 | } | 384 | } |
427 | pp->res[1].flags = IORESOURCE_MEM; | 385 | pp->res[0].flags = IORESOURCE_MEM; |
428 | if (request_resource(&iomem_resource, &pp->res[1])) | 386 | if (request_resource(&iomem_resource, &pp->res[0])) |
429 | panic("Request PCIe Memory resource failed\n"); | 387 | panic("Request PCIe Memory resource failed\n"); |
430 | pci_add_resource_offset(&sys->resources, &pp->res[1], sys->mem_offset); | 388 | pci_add_resource_offset(&sys->resources, &pp->res[0], sys->mem_offset); |
431 | 389 | ||
432 | /* | 390 | /* |
433 | * IORESOURCE_MEM | IORESOURCE_PREFETCH | 391 | * IORESOURCE_MEM | IORESOURCE_PREFETCH |
@@ -435,18 +393,18 @@ static int tegra_pcie_setup(int nr, struct pci_sys_data *sys) | |||
435 | snprintf(pp->prefetch_space_name, sizeof(pp->prefetch_space_name), | 393 | snprintf(pp->prefetch_space_name, sizeof(pp->prefetch_space_name), |
436 | "PCIe %d PREFETCH MEM", pp->index); | 394 | "PCIe %d PREFETCH MEM", pp->index); |
437 | pp->prefetch_space_name[sizeof(pp->prefetch_space_name) - 1] = 0; | 395 | pp->prefetch_space_name[sizeof(pp->prefetch_space_name) - 1] = 0; |
438 | pp->res[2].name = pp->prefetch_space_name; | 396 | pp->res[1].name = pp->prefetch_space_name; |
439 | if (pp->index == 0) { | 397 | if (pp->index == 0) { |
440 | pp->res[2].start = PREFETCH_MEM_BASE_0; | 398 | pp->res[1].start = PREFETCH_MEM_BASE_0; |
441 | pp->res[2].end = pp->res[2].start + PREFETCH_MEM_SIZE_0 - 1; | 399 | pp->res[1].end = pp->res[1].start + PREFETCH_MEM_SIZE_0 - 1; |
442 | } else { | 400 | } else { |
443 | pp->res[2].start = PREFETCH_MEM_BASE_1; | 401 | pp->res[1].start = PREFETCH_MEM_BASE_1; |
444 | pp->res[2].end = pp->res[2].start + PREFETCH_MEM_SIZE_1 - 1; | 402 | pp->res[1].end = pp->res[1].start + PREFETCH_MEM_SIZE_1 - 1; |
445 | } | 403 | } |
446 | pp->res[2].flags = IORESOURCE_MEM | IORESOURCE_PREFETCH; | 404 | pp->res[1].flags = IORESOURCE_MEM | IORESOURCE_PREFETCH; |
447 | if (request_resource(&iomem_resource, &pp->res[2])) | 405 | if (request_resource(&iomem_resource, &pp->res[1])) |
448 | panic("Request PCIe Prefetch Memory resource failed\n"); | 406 | panic("Request PCIe Prefetch Memory resource failed\n"); |
449 | pci_add_resource_offset(&sys->resources, &pp->res[2], sys->mem_offset); | 407 | pci_add_resource_offset(&sys->resources, &pp->res[1], sys->mem_offset); |
450 | 408 | ||
451 | return 1; | 409 | return 1; |
452 | } | 410 | } |
@@ -541,8 +499,8 @@ static void tegra_pcie_setup_translations(void) | |||
541 | 499 | ||
542 | /* Bar 2: downstream IO bar */ | 500 | /* Bar 2: downstream IO bar */ |
543 | fpci_bar = ((__u32)0xfdfc << 16); | 501 | fpci_bar = ((__u32)0xfdfc << 16); |
544 | size = MMIO_SIZE; | 502 | size = SZ_128K; |
545 | axi_address = MMIO_BASE; | 503 | axi_address = TEGRA_PCIE_IO_BASE; |
546 | afi_writel(axi_address, AFI_AXI_BAR2_START); | 504 | afi_writel(axi_address, AFI_AXI_BAR2_START); |
547 | afi_writel(size >> 12, AFI_AXI_BAR2_SZ); | 505 | afi_writel(size >> 12, AFI_AXI_BAR2_SZ); |
548 | afi_writel(fpci_bar, AFI_FPCI_BAR2); | 506 | afi_writel(fpci_bar, AFI_FPCI_BAR2); |
@@ -776,7 +734,6 @@ static void tegra_pcie_clocks_put(void) | |||
776 | 734 | ||
777 | static int __init tegra_pcie_get_resources(void) | 735 | static int __init tegra_pcie_get_resources(void) |
778 | { | 736 | { |
779 | struct resource *res_mmio = &tegra_pcie.res_mmio; | ||
780 | int err; | 737 | int err; |
781 | 738 | ||
782 | err = tegra_pcie_clocks_get(); | 739 | err = tegra_pcie_clocks_get(); |
@@ -798,34 +755,16 @@ static int __init tegra_pcie_get_resources(void) | |||
798 | goto err_map_reg; | 755 | goto err_map_reg; |
799 | } | 756 | } |
800 | 757 | ||
801 | err = request_resource(&iomem_resource, res_mmio); | ||
802 | if (err) { | ||
803 | pr_err("PCIE: Failed to request resources: %d\n", err); | ||
804 | goto err_req_io; | ||
805 | } | ||
806 | |||
807 | tegra_pcie_io_base = ioremap_nocache(res_mmio->start, | ||
808 | resource_size(res_mmio)); | ||
809 | if (tegra_pcie_io_base == NULL) { | ||
810 | pr_err("PCIE: Failed to map IO\n"); | ||
811 | err = -ENOMEM; | ||
812 | goto err_map_io; | ||
813 | } | ||
814 | |||
815 | err = request_irq(INT_PCIE_INTR, tegra_pcie_isr, | 758 | err = request_irq(INT_PCIE_INTR, tegra_pcie_isr, |
816 | IRQF_SHARED, "PCIE", &tegra_pcie); | 759 | IRQF_SHARED, "PCIE", &tegra_pcie); |
817 | if (err) { | 760 | if (err) { |
818 | pr_err("PCIE: Failed to register IRQ: %d\n", err); | 761 | pr_err("PCIE: Failed to register IRQ: %d\n", err); |
819 | goto err_irq; | 762 | goto err_req_io; |
820 | } | 763 | } |
821 | set_irq_flags(INT_PCIE_INTR, IRQF_VALID); | 764 | set_irq_flags(INT_PCIE_INTR, IRQF_VALID); |
822 | 765 | ||
823 | return 0; | 766 | return 0; |
824 | 767 | ||
825 | err_irq: | ||
826 | iounmap(tegra_pcie_io_base); | ||
827 | err_map_io: | ||
828 | release_resource(&tegra_pcie.res_mmio); | ||
829 | err_req_io: | 768 | err_req_io: |
830 | iounmap(tegra_pcie.regs); | 769 | iounmap(tegra_pcie.regs); |
831 | err_map_reg: | 770 | err_map_reg: |