aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pci
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/pci')
-rw-r--r--drivers/pci/host/pci-exynos.c1
-rw-r--r--drivers/pci/host/pci-imx6.c1
-rw-r--r--drivers/pci/host/pci-mvebu.c102
-rw-r--r--drivers/pci/host/pci-tegra.c7
-rw-r--r--drivers/pci/host/pcie-designware.c26
-rw-r--r--drivers/pci/host/pcie-designware.h1
6 files changed, 97 insertions, 41 deletions
diff --git a/drivers/pci/host/pci-exynos.c b/drivers/pci/host/pci-exynos.c
index 1632661c5b7f..c5d0ca384502 100644
--- a/drivers/pci/host/pci-exynos.c
+++ b/drivers/pci/host/pci-exynos.c
@@ -545,7 +545,6 @@ static int __init add_pcie_port(struct pcie_port *pp,
545 pp->root_bus_nr = -1; 545 pp->root_bus_nr = -1;
546 pp->ops = &exynos_pcie_host_ops; 546 pp->ops = &exynos_pcie_host_ops;
547 547
548 spin_lock_init(&pp->conf_lock);
549 ret = dw_pcie_host_init(pp); 548 ret = dw_pcie_host_init(pp);
550 if (ret) { 549 if (ret) {
551 dev_err(&pdev->dev, "failed to initialize host\n"); 550 dev_err(&pdev->dev, "failed to initialize host\n");
diff --git a/drivers/pci/host/pci-imx6.c b/drivers/pci/host/pci-imx6.c
index a5645ae4aef0..a568efaa331c 100644
--- a/drivers/pci/host/pci-imx6.c
+++ b/drivers/pci/host/pci-imx6.c
@@ -507,7 +507,6 @@ static int __init imx6_add_pcie_port(struct pcie_port *pp,
507 pp->root_bus_nr = -1; 507 pp->root_bus_nr = -1;
508 pp->ops = &imx6_pcie_host_ops; 508 pp->ops = &imx6_pcie_host_ops;
509 509
510 spin_lock_init(&pp->conf_lock);
511 ret = dw_pcie_host_init(pp); 510 ret = dw_pcie_host_init(pp);
512 if (ret) { 511 if (ret) {
513 dev_err(&pdev->dev, "failed to initialize host\n"); 512 dev_err(&pdev->dev, "failed to initialize host\n");
diff --git a/drivers/pci/host/pci-mvebu.c b/drivers/pci/host/pci-mvebu.c
index d3d1cfd51e09..7f450322f397 100644
--- a/drivers/pci/host/pci-mvebu.c
+++ b/drivers/pci/host/pci-mvebu.c
@@ -113,7 +113,6 @@ struct mvebu_pcie {
113struct mvebu_pcie_port { 113struct mvebu_pcie_port {
114 char *name; 114 char *name;
115 void __iomem *base; 115 void __iomem *base;
116 spinlock_t conf_lock;
117 u32 port; 116 u32 port;
118 u32 lane; 117 u32 lane;
119 int devfn; 118 int devfn;
@@ -293,6 +292,60 @@ static int mvebu_pcie_hw_wr_conf(struct mvebu_pcie_port *port,
293 return PCIBIOS_SUCCESSFUL; 292 return PCIBIOS_SUCCESSFUL;
294} 293}
295 294
295/*
296 * Remove windows, starting from the largest ones to the smallest
297 * ones.
298 */
299static void mvebu_pcie_del_windows(struct mvebu_pcie_port *port,
300 phys_addr_t base, size_t size)
301{
302 while (size) {
303 size_t sz = 1 << (fls(size) - 1);
304
305 mvebu_mbus_del_window(base, sz);
306 base += sz;
307 size -= sz;
308 }
309}
310
311/*
312 * MBus windows can only have a power of two size, but PCI BARs do not
313 * have this constraint. Therefore, we have to split the PCI BAR into
314 * areas each having a power of two size. We start from the largest
315 * one (i.e highest order bit set in the size).
316 */
317static void mvebu_pcie_add_windows(struct mvebu_pcie_port *port,
318 unsigned int target, unsigned int attribute,
319 phys_addr_t base, size_t size,
320 phys_addr_t remap)
321{
322 size_t size_mapped = 0;
323
324 while (size) {
325 size_t sz = 1 << (fls(size) - 1);
326 int ret;
327
328 ret = mvebu_mbus_add_window_remap_by_id(target, attribute, base,
329 sz, remap);
330 if (ret) {
331 phys_addr_t end = base + sz - 1;
332
333 dev_err(&port->pcie->pdev->dev,
334 "Could not create MBus window at [mem %pa-%pa]: %d\n",
335 &base, &end, ret);
336 mvebu_pcie_del_windows(port, base - size_mapped,
337 size_mapped);
338 return;
339 }
340
341 size -= sz;
342 size_mapped += sz;
343 base += sz;
344 if (remap != MVEBU_MBUS_NO_REMAP)
345 remap += sz;
346 }
347}
348
296static void mvebu_pcie_handle_iobase_change(struct mvebu_pcie_port *port) 349static void mvebu_pcie_handle_iobase_change(struct mvebu_pcie_port *port)
297{ 350{
298 phys_addr_t iobase; 351 phys_addr_t iobase;
@@ -304,8 +357,8 @@ static void mvebu_pcie_handle_iobase_change(struct mvebu_pcie_port *port)
304 357
305 /* If a window was configured, remove it */ 358 /* If a window was configured, remove it */
306 if (port->iowin_base) { 359 if (port->iowin_base) {
307 mvebu_mbus_del_window(port->iowin_base, 360 mvebu_pcie_del_windows(port, port->iowin_base,
308 port->iowin_size); 361 port->iowin_size);
309 port->iowin_base = 0; 362 port->iowin_base = 0;
310 port->iowin_size = 0; 363 port->iowin_size = 0;
311 } 364 }
@@ -331,11 +384,11 @@ static void mvebu_pcie_handle_iobase_change(struct mvebu_pcie_port *port)
331 port->iowin_base = port->pcie->io.start + iobase; 384 port->iowin_base = port->pcie->io.start + iobase;
332 port->iowin_size = ((0xFFF | ((port->bridge.iolimit & 0xF0) << 8) | 385 port->iowin_size = ((0xFFF | ((port->bridge.iolimit & 0xF0) << 8) |
333 (port->bridge.iolimitupper << 16)) - 386 (port->bridge.iolimitupper << 16)) -
334 iobase); 387 iobase) + 1;
335 388
336 mvebu_mbus_add_window_remap_by_id(port->io_target, port->io_attr, 389 mvebu_pcie_add_windows(port, port->io_target, port->io_attr,
337 port->iowin_base, port->iowin_size, 390 port->iowin_base, port->iowin_size,
338 iobase); 391 iobase);
339} 392}
340 393
341static void mvebu_pcie_handle_membase_change(struct mvebu_pcie_port *port) 394static void mvebu_pcie_handle_membase_change(struct mvebu_pcie_port *port)
@@ -346,8 +399,8 @@ static void mvebu_pcie_handle_membase_change(struct mvebu_pcie_port *port)
346 399
347 /* If a window was configured, remove it */ 400 /* If a window was configured, remove it */
348 if (port->memwin_base) { 401 if (port->memwin_base) {
349 mvebu_mbus_del_window(port->memwin_base, 402 mvebu_pcie_del_windows(port, port->memwin_base,
350 port->memwin_size); 403 port->memwin_size);
351 port->memwin_base = 0; 404 port->memwin_base = 0;
352 port->memwin_size = 0; 405 port->memwin_size = 0;
353 } 406 }
@@ -364,10 +417,11 @@ static void mvebu_pcie_handle_membase_change(struct mvebu_pcie_port *port)
364 port->memwin_base = ((port->bridge.membase & 0xFFF0) << 16); 417 port->memwin_base = ((port->bridge.membase & 0xFFF0) << 16);
365 port->memwin_size = 418 port->memwin_size =
366 (((port->bridge.memlimit & 0xFFF0) << 16) | 0xFFFFF) - 419 (((port->bridge.memlimit & 0xFFF0) << 16) | 0xFFFFF) -
367 port->memwin_base; 420 port->memwin_base + 1;
368 421
369 mvebu_mbus_add_window_by_id(port->mem_target, port->mem_attr, 422 mvebu_pcie_add_windows(port, port->mem_target, port->mem_attr,
370 port->memwin_base, port->memwin_size); 423 port->memwin_base, port->memwin_size,
424 MVEBU_MBUS_NO_REMAP);
371} 425}
372 426
373/* 427/*
@@ -585,7 +639,6 @@ static int mvebu_pcie_wr_conf(struct pci_bus *bus, u32 devfn,
585{ 639{
586 struct mvebu_pcie *pcie = sys_to_pcie(bus->sysdata); 640 struct mvebu_pcie *pcie = sys_to_pcie(bus->sysdata);
587 struct mvebu_pcie_port *port; 641 struct mvebu_pcie_port *port;
588 unsigned long flags;
589 int ret; 642 int ret;
590 643
591 port = mvebu_pcie_find_port(pcie, bus, devfn); 644 port = mvebu_pcie_find_port(pcie, bus, devfn);
@@ -611,10 +664,8 @@ static int mvebu_pcie_wr_conf(struct pci_bus *bus, u32 devfn,
611 return PCIBIOS_DEVICE_NOT_FOUND; 664 return PCIBIOS_DEVICE_NOT_FOUND;
612 665
613 /* Access the real PCIe interface */ 666 /* Access the real PCIe interface */
614 spin_lock_irqsave(&port->conf_lock, flags);
615 ret = mvebu_pcie_hw_wr_conf(port, bus, devfn, 667 ret = mvebu_pcie_hw_wr_conf(port, bus, devfn,
616 where, size, val); 668 where, size, val);
617 spin_unlock_irqrestore(&port->conf_lock, flags);
618 669
619 return ret; 670 return ret;
620} 671}
@@ -625,7 +676,6 @@ static int mvebu_pcie_rd_conf(struct pci_bus *bus, u32 devfn, int where,
625{ 676{
626 struct mvebu_pcie *pcie = sys_to_pcie(bus->sysdata); 677 struct mvebu_pcie *pcie = sys_to_pcie(bus->sysdata);
627 struct mvebu_pcie_port *port; 678 struct mvebu_pcie_port *port;
628 unsigned long flags;
629 int ret; 679 int ret;
630 680
631 port = mvebu_pcie_find_port(pcie, bus, devfn); 681 port = mvebu_pcie_find_port(pcie, bus, devfn);
@@ -657,10 +707,8 @@ static int mvebu_pcie_rd_conf(struct pci_bus *bus, u32 devfn, int where,
657 } 707 }
658 708
659 /* Access the real PCIe interface */ 709 /* Access the real PCIe interface */
660 spin_lock_irqsave(&port->conf_lock, flags);
661 ret = mvebu_pcie_hw_rd_conf(port, bus, devfn, 710 ret = mvebu_pcie_hw_rd_conf(port, bus, devfn,
662 where, size, val); 711 where, size, val);
663 spin_unlock_irqrestore(&port->conf_lock, flags);
664 712
665 return ret; 713 return ret;
666} 714}
@@ -743,14 +791,21 @@ static resource_size_t mvebu_pcie_align_resource(struct pci_dev *dev,
743 791
744 /* 792 /*
745 * On the PCI-to-PCI bridge side, the I/O windows must have at 793 * On the PCI-to-PCI bridge side, the I/O windows must have at
746 * least a 64 KB size and be aligned on their size, and the 794 * least a 64 KB size and the memory windows must have at
747 * memory windows must have at least a 1 MB size and be 795 * least a 1 MB size. Moreover, MBus windows need to have a
748 * aligned on their size 796 * base address aligned on their size, and their size must be
797 * a power of two. This means that if the BAR doesn't have a
798 * power of two size, several MBus windows will actually be
799 * created. We need to ensure that the biggest MBus window
800 * (which will be the first one) is aligned on its size, which
801 * explains the rounddown_pow_of_two() being done here.
749 */ 802 */
750 if (res->flags & IORESOURCE_IO) 803 if (res->flags & IORESOURCE_IO)
751 return round_up(start, max_t(resource_size_t, SZ_64K, size)); 804 return round_up(start, max_t(resource_size_t, SZ_64K,
805 rounddown_pow_of_two(size)));
752 else if (res->flags & IORESOURCE_MEM) 806 else if (res->flags & IORESOURCE_MEM)
753 return round_up(start, max_t(resource_size_t, SZ_1M, size)); 807 return round_up(start, max_t(resource_size_t, SZ_1M,
808 rounddown_pow_of_two(size)));
754 else 809 else
755 return start; 810 return start;
756} 811}
@@ -1000,7 +1055,6 @@ static int mvebu_pcie_probe(struct platform_device *pdev)
1000 mvebu_pcie_set_local_dev_nr(port, 1); 1055 mvebu_pcie_set_local_dev_nr(port, 1);
1001 1056
1002 port->dn = child; 1057 port->dn = child;
1003 spin_lock_init(&port->conf_lock);
1004 mvebu_sw_pci_bridge_init(port); 1058 mvebu_sw_pci_bridge_init(port);
1005 i++; 1059 i++;
1006 } 1060 }
diff --git a/drivers/pci/host/pci-tegra.c b/drivers/pci/host/pci-tegra.c
index 330f7e3a32dd..083cf37ca047 100644
--- a/drivers/pci/host/pci-tegra.c
+++ b/drivers/pci/host/pci-tegra.c
@@ -639,10 +639,15 @@ static int tegra_pcie_setup(int nr, struct pci_sys_data *sys)
639static int tegra_pcie_map_irq(const struct pci_dev *pdev, u8 slot, u8 pin) 639static int tegra_pcie_map_irq(const struct pci_dev *pdev, u8 slot, u8 pin)
640{ 640{
641 struct tegra_pcie *pcie = sys_to_pcie(pdev->bus->sysdata); 641 struct tegra_pcie *pcie = sys_to_pcie(pdev->bus->sysdata);
642 int irq;
642 643
643 tegra_cpuidle_pcie_irqs_in_use(); 644 tegra_cpuidle_pcie_irqs_in_use();
644 645
645 return pcie->irq; 646 irq = of_irq_parse_and_map_pci(pdev, slot, pin);
647 if (!irq)
648 irq = pcie->irq;
649
650 return irq;
646} 651}
647 652
648static void tegra_pcie_add_bus(struct pci_bus *bus) 653static void tegra_pcie_add_bus(struct pci_bus *bus)
diff --git a/drivers/pci/host/pcie-designware.c b/drivers/pci/host/pcie-designware.c
index 77a649dd1473..1eaf4df3618a 100644
--- a/drivers/pci/host/pcie-designware.c
+++ b/drivers/pci/host/pcie-designware.c
@@ -17,6 +17,7 @@
17#include <linux/module.h> 17#include <linux/module.h>
18#include <linux/msi.h> 18#include <linux/msi.h>
19#include <linux/of_address.h> 19#include <linux/of_address.h>
20#include <linux/of_pci.h>
20#include <linux/pci.h> 21#include <linux/pci.h>
21#include <linux/pci_regs.h> 22#include <linux/pci_regs.h>
22#include <linux/types.h> 23#include <linux/types.h>
@@ -494,7 +495,7 @@ int __init dw_pcie_host_init(struct pcie_port *pp)
494 dw_pci.nr_controllers = 1; 495 dw_pci.nr_controllers = 1;
495 dw_pci.private_data = (void **)&pp; 496 dw_pci.private_data = (void **)&pp;
496 497
497 pci_common_init(&dw_pci); 498 pci_common_init_dev(pp->dev, &dw_pci);
498 pci_assign_unassigned_resources(); 499 pci_assign_unassigned_resources();
499#ifdef CONFIG_PCI_DOMAINS 500#ifdef CONFIG_PCI_DOMAINS
500 dw_pci.domain++; 501 dw_pci.domain++;
@@ -524,13 +525,13 @@ static void dw_pcie_prog_viewport_cfg1(struct pcie_port *pp, u32 busdev)
524 dw_pcie_writel_rc(pp, PCIE_ATU_REGION_OUTBOUND | PCIE_ATU_REGION_INDEX1, 525 dw_pcie_writel_rc(pp, PCIE_ATU_REGION_OUTBOUND | PCIE_ATU_REGION_INDEX1,
525 PCIE_ATU_VIEWPORT); 526 PCIE_ATU_VIEWPORT);
526 dw_pcie_writel_rc(pp, PCIE_ATU_TYPE_CFG1, PCIE_ATU_CR1); 527 dw_pcie_writel_rc(pp, PCIE_ATU_TYPE_CFG1, PCIE_ATU_CR1);
527 dw_pcie_writel_rc(pp, PCIE_ATU_ENABLE, PCIE_ATU_CR2);
528 dw_pcie_writel_rc(pp, pp->cfg1_base, PCIE_ATU_LOWER_BASE); 528 dw_pcie_writel_rc(pp, pp->cfg1_base, PCIE_ATU_LOWER_BASE);
529 dw_pcie_writel_rc(pp, (pp->cfg1_base >> 32), PCIE_ATU_UPPER_BASE); 529 dw_pcie_writel_rc(pp, (pp->cfg1_base >> 32), PCIE_ATU_UPPER_BASE);
530 dw_pcie_writel_rc(pp, pp->cfg1_base + pp->config.cfg1_size - 1, 530 dw_pcie_writel_rc(pp, pp->cfg1_base + pp->config.cfg1_size - 1,
531 PCIE_ATU_LIMIT); 531 PCIE_ATU_LIMIT);
532 dw_pcie_writel_rc(pp, busdev, PCIE_ATU_LOWER_TARGET); 532 dw_pcie_writel_rc(pp, busdev, PCIE_ATU_LOWER_TARGET);
533 dw_pcie_writel_rc(pp, 0, PCIE_ATU_UPPER_TARGET); 533 dw_pcie_writel_rc(pp, 0, PCIE_ATU_UPPER_TARGET);
534 dw_pcie_writel_rc(pp, PCIE_ATU_ENABLE, PCIE_ATU_CR2);
534} 535}
535 536
536static void dw_pcie_prog_viewport_mem_outbound(struct pcie_port *pp) 537static void dw_pcie_prog_viewport_mem_outbound(struct pcie_port *pp)
@@ -539,7 +540,6 @@ static void dw_pcie_prog_viewport_mem_outbound(struct pcie_port *pp)
539 dw_pcie_writel_rc(pp, PCIE_ATU_REGION_OUTBOUND | PCIE_ATU_REGION_INDEX0, 540 dw_pcie_writel_rc(pp, PCIE_ATU_REGION_OUTBOUND | PCIE_ATU_REGION_INDEX0,
540 PCIE_ATU_VIEWPORT); 541 PCIE_ATU_VIEWPORT);
541 dw_pcie_writel_rc(pp, PCIE_ATU_TYPE_MEM, PCIE_ATU_CR1); 542 dw_pcie_writel_rc(pp, PCIE_ATU_TYPE_MEM, PCIE_ATU_CR1);
542 dw_pcie_writel_rc(pp, PCIE_ATU_ENABLE, PCIE_ATU_CR2);
543 dw_pcie_writel_rc(pp, pp->mem_base, PCIE_ATU_LOWER_BASE); 543 dw_pcie_writel_rc(pp, pp->mem_base, PCIE_ATU_LOWER_BASE);
544 dw_pcie_writel_rc(pp, (pp->mem_base >> 32), PCIE_ATU_UPPER_BASE); 544 dw_pcie_writel_rc(pp, (pp->mem_base >> 32), PCIE_ATU_UPPER_BASE);
545 dw_pcie_writel_rc(pp, pp->mem_base + pp->config.mem_size - 1, 545 dw_pcie_writel_rc(pp, pp->mem_base + pp->config.mem_size - 1,
@@ -547,6 +547,7 @@ static void dw_pcie_prog_viewport_mem_outbound(struct pcie_port *pp)
547 dw_pcie_writel_rc(pp, pp->config.mem_bus_addr, PCIE_ATU_LOWER_TARGET); 547 dw_pcie_writel_rc(pp, pp->config.mem_bus_addr, PCIE_ATU_LOWER_TARGET);
548 dw_pcie_writel_rc(pp, upper_32_bits(pp->config.mem_bus_addr), 548 dw_pcie_writel_rc(pp, upper_32_bits(pp->config.mem_bus_addr),
549 PCIE_ATU_UPPER_TARGET); 549 PCIE_ATU_UPPER_TARGET);
550 dw_pcie_writel_rc(pp, PCIE_ATU_ENABLE, PCIE_ATU_CR2);
550} 551}
551 552
552static void dw_pcie_prog_viewport_io_outbound(struct pcie_port *pp) 553static void dw_pcie_prog_viewport_io_outbound(struct pcie_port *pp)
@@ -555,7 +556,6 @@ static void dw_pcie_prog_viewport_io_outbound(struct pcie_port *pp)
555 dw_pcie_writel_rc(pp, PCIE_ATU_REGION_OUTBOUND | PCIE_ATU_REGION_INDEX1, 556 dw_pcie_writel_rc(pp, PCIE_ATU_REGION_OUTBOUND | PCIE_ATU_REGION_INDEX1,
556 PCIE_ATU_VIEWPORT); 557 PCIE_ATU_VIEWPORT);
557 dw_pcie_writel_rc(pp, PCIE_ATU_TYPE_IO, PCIE_ATU_CR1); 558 dw_pcie_writel_rc(pp, PCIE_ATU_TYPE_IO, PCIE_ATU_CR1);
558 dw_pcie_writel_rc(pp, PCIE_ATU_ENABLE, PCIE_ATU_CR2);
559 dw_pcie_writel_rc(pp, pp->io_base, PCIE_ATU_LOWER_BASE); 559 dw_pcie_writel_rc(pp, pp->io_base, PCIE_ATU_LOWER_BASE);
560 dw_pcie_writel_rc(pp, (pp->io_base >> 32), PCIE_ATU_UPPER_BASE); 560 dw_pcie_writel_rc(pp, (pp->io_base >> 32), PCIE_ATU_UPPER_BASE);
561 dw_pcie_writel_rc(pp, pp->io_base + pp->config.io_size - 1, 561 dw_pcie_writel_rc(pp, pp->io_base + pp->config.io_size - 1,
@@ -563,6 +563,7 @@ static void dw_pcie_prog_viewport_io_outbound(struct pcie_port *pp)
563 dw_pcie_writel_rc(pp, pp->config.io_bus_addr, PCIE_ATU_LOWER_TARGET); 563 dw_pcie_writel_rc(pp, pp->config.io_bus_addr, PCIE_ATU_LOWER_TARGET);
564 dw_pcie_writel_rc(pp, upper_32_bits(pp->config.io_bus_addr), 564 dw_pcie_writel_rc(pp, upper_32_bits(pp->config.io_bus_addr),
565 PCIE_ATU_UPPER_TARGET); 565 PCIE_ATU_UPPER_TARGET);
566 dw_pcie_writel_rc(pp, PCIE_ATU_ENABLE, PCIE_ATU_CR2);
566} 567}
567 568
568static int dw_pcie_rd_other_conf(struct pcie_port *pp, struct pci_bus *bus, 569static int dw_pcie_rd_other_conf(struct pcie_port *pp, struct pci_bus *bus,
@@ -642,7 +643,6 @@ static int dw_pcie_rd_conf(struct pci_bus *bus, u32 devfn, int where,
642 int size, u32 *val) 643 int size, u32 *val)
643{ 644{
644 struct pcie_port *pp = sys_to_pcie(bus->sysdata); 645 struct pcie_port *pp = sys_to_pcie(bus->sysdata);
645 unsigned long flags;
646 int ret; 646 int ret;
647 647
648 if (!pp) { 648 if (!pp) {
@@ -655,13 +655,11 @@ static int dw_pcie_rd_conf(struct pci_bus *bus, u32 devfn, int where,
655 return PCIBIOS_DEVICE_NOT_FOUND; 655 return PCIBIOS_DEVICE_NOT_FOUND;
656 } 656 }
657 657
658 spin_lock_irqsave(&pp->conf_lock, flags);
659 if (bus->number != pp->root_bus_nr) 658 if (bus->number != pp->root_bus_nr)
660 ret = dw_pcie_rd_other_conf(pp, bus, devfn, 659 ret = dw_pcie_rd_other_conf(pp, bus, devfn,
661 where, size, val); 660 where, size, val);
662 else 661 else
663 ret = dw_pcie_rd_own_conf(pp, where, size, val); 662 ret = dw_pcie_rd_own_conf(pp, where, size, val);
664 spin_unlock_irqrestore(&pp->conf_lock, flags);
665 663
666 return ret; 664 return ret;
667} 665}
@@ -670,7 +668,6 @@ static int dw_pcie_wr_conf(struct pci_bus *bus, u32 devfn,
670 int where, int size, u32 val) 668 int where, int size, u32 val)
671{ 669{
672 struct pcie_port *pp = sys_to_pcie(bus->sysdata); 670 struct pcie_port *pp = sys_to_pcie(bus->sysdata);
673 unsigned long flags;
674 int ret; 671 int ret;
675 672
676 if (!pp) { 673 if (!pp) {
@@ -681,13 +678,11 @@ static int dw_pcie_wr_conf(struct pci_bus *bus, u32 devfn,
681 if (dw_pcie_valid_config(pp, bus, PCI_SLOT(devfn)) == 0) 678 if (dw_pcie_valid_config(pp, bus, PCI_SLOT(devfn)) == 0)
682 return PCIBIOS_DEVICE_NOT_FOUND; 679 return PCIBIOS_DEVICE_NOT_FOUND;
683 680
684 spin_lock_irqsave(&pp->conf_lock, flags);
685 if (bus->number != pp->root_bus_nr) 681 if (bus->number != pp->root_bus_nr)
686 ret = dw_pcie_wr_other_conf(pp, bus, devfn, 682 ret = dw_pcie_wr_other_conf(pp, bus, devfn,
687 where, size, val); 683 where, size, val);
688 else 684 else
689 ret = dw_pcie_wr_own_conf(pp, where, size, val); 685 ret = dw_pcie_wr_own_conf(pp, where, size, val);
690 spin_unlock_irqrestore(&pp->conf_lock, flags);
691 686
692 return ret; 687 return ret;
693} 688}
@@ -727,7 +722,7 @@ static struct pci_bus *dw_pcie_scan_bus(int nr, struct pci_sys_data *sys)
727 722
728 if (pp) { 723 if (pp) {
729 pp->root_bus_nr = sys->busnr; 724 pp->root_bus_nr = sys->busnr;
730 bus = pci_scan_root_bus(NULL, sys->busnr, &dw_pcie_ops, 725 bus = pci_scan_root_bus(pp->dev, sys->busnr, &dw_pcie_ops,
731 sys, &sys->resources); 726 sys, &sys->resources);
732 } else { 727 } else {
733 bus = NULL; 728 bus = NULL;
@@ -740,8 +735,13 @@ static struct pci_bus *dw_pcie_scan_bus(int nr, struct pci_sys_data *sys)
740static int dw_pcie_map_irq(const struct pci_dev *dev, u8 slot, u8 pin) 735static int dw_pcie_map_irq(const struct pci_dev *dev, u8 slot, u8 pin)
741{ 736{
742 struct pcie_port *pp = sys_to_pcie(dev->bus->sysdata); 737 struct pcie_port *pp = sys_to_pcie(dev->bus->sysdata);
738 int irq;
739
740 irq = of_irq_parse_and_map_pci(dev, slot, pin);
741 if (!irq)
742 irq = pp->irq;
743 743
744 return pp->irq; 744 return irq;
745} 745}
746 746
747static void dw_pcie_add_bus(struct pci_bus *bus) 747static void dw_pcie_add_bus(struct pci_bus *bus)
@@ -768,7 +768,7 @@ void dw_pcie_setup_rc(struct pcie_port *pp)
768 u32 membase; 768 u32 membase;
769 u32 memlimit; 769 u32 memlimit;
770 770
771 /* set the number of lines as 4 */ 771 /* set the number of lanes */
772 dw_pcie_readl_rc(pp, PCIE_PORT_LINK_CONTROL, &val); 772 dw_pcie_readl_rc(pp, PCIE_PORT_LINK_CONTROL, &val);
773 val &= ~PORT_LINK_MODE_MASK; 773 val &= ~PORT_LINK_MODE_MASK;
774 switch (pp->lanes) { 774 switch (pp->lanes) {
diff --git a/drivers/pci/host/pcie-designware.h b/drivers/pci/host/pcie-designware.h
index a169d22d517e..77f592faa7bf 100644
--- a/drivers/pci/host/pcie-designware.h
+++ b/drivers/pci/host/pcie-designware.h
@@ -41,7 +41,6 @@ struct pcie_port {
41 void __iomem *va_cfg1_base; 41 void __iomem *va_cfg1_base;
42 u64 io_base; 42 u64 io_base;
43 u64 mem_base; 43 u64 mem_base;
44 spinlock_t conf_lock;
45 struct resource cfg; 44 struct resource cfg;
46 struct resource io; 45 struct resource io;
47 struct resource mem; 46 struct resource mem;