aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/pci/dwc/pcie-kirin.c2
-rw-r--r--drivers/pci/host/pci-aardvark.c53
2 files changed, 31 insertions, 24 deletions
diff --git a/drivers/pci/dwc/pcie-kirin.c b/drivers/pci/dwc/pcie-kirin.c
index a6b88c7f6e3e..d2970a009eb5 100644
--- a/drivers/pci/dwc/pcie-kirin.c
+++ b/drivers/pci/dwc/pcie-kirin.c
@@ -486,7 +486,7 @@ static int kirin_pcie_probe(struct platform_device *pdev)
486 return ret; 486 return ret;
487 487
488 kirin_pcie->gpio_id_reset = of_get_named_gpio(dev->of_node, 488 kirin_pcie->gpio_id_reset = of_get_named_gpio(dev->of_node,
489 "reset-gpio", 0); 489 "reset-gpios", 0);
490 if (kirin_pcie->gpio_id_reset < 0) 490 if (kirin_pcie->gpio_id_reset < 0)
491 return -ENODEV; 491 return -ENODEV;
492 492
diff --git a/drivers/pci/host/pci-aardvark.c b/drivers/pci/host/pci-aardvark.c
index b04d37b3c5de..9abf549631b4 100644
--- a/drivers/pci/host/pci-aardvark.c
+++ b/drivers/pci/host/pci-aardvark.c
@@ -29,6 +29,7 @@
29#define PCIE_CORE_DEV_CTRL_STATS_MAX_PAYLOAD_SZ_SHIFT 5 29#define PCIE_CORE_DEV_CTRL_STATS_MAX_PAYLOAD_SZ_SHIFT 5
30#define PCIE_CORE_DEV_CTRL_STATS_SNOOP_DISABLE (0 << 11) 30#define PCIE_CORE_DEV_CTRL_STATS_SNOOP_DISABLE (0 << 11)
31#define PCIE_CORE_DEV_CTRL_STATS_MAX_RD_REQ_SIZE_SHIFT 12 31#define PCIE_CORE_DEV_CTRL_STATS_MAX_RD_REQ_SIZE_SHIFT 12
32#define PCIE_CORE_DEV_CTRL_STATS_MAX_RD_REQ_SZ 0x2
32#define PCIE_CORE_LINK_CTRL_STAT_REG 0xd0 33#define PCIE_CORE_LINK_CTRL_STAT_REG 0xd0
33#define PCIE_CORE_LINK_L0S_ENTRY BIT(0) 34#define PCIE_CORE_LINK_L0S_ENTRY BIT(0)
34#define PCIE_CORE_LINK_TRAINING BIT(5) 35#define PCIE_CORE_LINK_TRAINING BIT(5)
@@ -100,7 +101,8 @@
100#define PCIE_ISR1_MASK_REG (CONTROL_BASE_ADDR + 0x4C) 101#define PCIE_ISR1_MASK_REG (CONTROL_BASE_ADDR + 0x4C)
101#define PCIE_ISR1_POWER_STATE_CHANGE BIT(4) 102#define PCIE_ISR1_POWER_STATE_CHANGE BIT(4)
102#define PCIE_ISR1_FLUSH BIT(5) 103#define PCIE_ISR1_FLUSH BIT(5)
103#define PCIE_ISR1_ALL_MASK GENMASK(5, 4) 104#define PCIE_ISR1_INTX_ASSERT(val) BIT(8 + (val))
105#define PCIE_ISR1_ALL_MASK GENMASK(11, 4)
104#define PCIE_MSI_ADDR_LOW_REG (CONTROL_BASE_ADDR + 0x50) 106#define PCIE_MSI_ADDR_LOW_REG (CONTROL_BASE_ADDR + 0x50)
105#define PCIE_MSI_ADDR_HIGH_REG (CONTROL_BASE_ADDR + 0x54) 107#define PCIE_MSI_ADDR_HIGH_REG (CONTROL_BASE_ADDR + 0x54)
106#define PCIE_MSI_STATUS_REG (CONTROL_BASE_ADDR + 0x58) 108#define PCIE_MSI_STATUS_REG (CONTROL_BASE_ADDR + 0x58)
@@ -172,8 +174,6 @@
172#define PCIE_CONFIG_WR_TYPE0 0xa 174#define PCIE_CONFIG_WR_TYPE0 0xa
173#define PCIE_CONFIG_WR_TYPE1 0xb 175#define PCIE_CONFIG_WR_TYPE1 0xb
174 176
175/* PCI_BDF shifts 8bit, so we need extra 4bit shift */
176#define PCIE_BDF(dev) (dev << 4)
177#define PCIE_CONF_BUS(bus) (((bus) & 0xff) << 20) 177#define PCIE_CONF_BUS(bus) (((bus) & 0xff) << 20)
178#define PCIE_CONF_DEV(dev) (((dev) & 0x1f) << 15) 178#define PCIE_CONF_DEV(dev) (((dev) & 0x1f) << 15)
179#define PCIE_CONF_FUNC(fun) (((fun) & 0x7) << 12) 179#define PCIE_CONF_FUNC(fun) (((fun) & 0x7) << 12)
@@ -296,7 +296,8 @@ static void advk_pcie_setup_hw(struct advk_pcie *pcie)
296 reg = PCIE_CORE_DEV_CTRL_STATS_RELAX_ORDER_DISABLE | 296 reg = PCIE_CORE_DEV_CTRL_STATS_RELAX_ORDER_DISABLE |
297 (7 << PCIE_CORE_DEV_CTRL_STATS_MAX_PAYLOAD_SZ_SHIFT) | 297 (7 << PCIE_CORE_DEV_CTRL_STATS_MAX_PAYLOAD_SZ_SHIFT) |
298 PCIE_CORE_DEV_CTRL_STATS_SNOOP_DISABLE | 298 PCIE_CORE_DEV_CTRL_STATS_SNOOP_DISABLE |
299 PCIE_CORE_DEV_CTRL_STATS_MAX_RD_REQ_SIZE_SHIFT; 299 (PCIE_CORE_DEV_CTRL_STATS_MAX_RD_REQ_SZ <<
300 PCIE_CORE_DEV_CTRL_STATS_MAX_RD_REQ_SIZE_SHIFT);
300 advk_writel(pcie, reg, PCIE_CORE_DEV_CTRL_STATS_REG); 301 advk_writel(pcie, reg, PCIE_CORE_DEV_CTRL_STATS_REG);
301 302
302 /* Program PCIe Control 2 to disable strict ordering */ 303 /* Program PCIe Control 2 to disable strict ordering */
@@ -437,7 +438,7 @@ static int advk_pcie_rd_conf(struct pci_bus *bus, u32 devfn,
437 u32 reg; 438 u32 reg;
438 int ret; 439 int ret;
439 440
440 if (PCI_SLOT(devfn) != 0) { 441 if ((bus->number == pcie->root_bus_nr) && PCI_SLOT(devfn) != 0) {
441 *val = 0xffffffff; 442 *val = 0xffffffff;
442 return PCIBIOS_DEVICE_NOT_FOUND; 443 return PCIBIOS_DEVICE_NOT_FOUND;
443 } 444 }
@@ -456,7 +457,7 @@ static int advk_pcie_rd_conf(struct pci_bus *bus, u32 devfn,
456 advk_writel(pcie, reg, PIO_CTRL); 457 advk_writel(pcie, reg, PIO_CTRL);
457 458
458 /* Program the address registers */ 459 /* Program the address registers */
459 reg = PCIE_BDF(devfn) | PCIE_CONF_REG(where); 460 reg = PCIE_CONF_ADDR(bus->number, devfn, where);
460 advk_writel(pcie, reg, PIO_ADDR_LS); 461 advk_writel(pcie, reg, PIO_ADDR_LS);
461 advk_writel(pcie, 0, PIO_ADDR_MS); 462 advk_writel(pcie, 0, PIO_ADDR_MS);
462 463
@@ -491,7 +492,7 @@ static int advk_pcie_wr_conf(struct pci_bus *bus, u32 devfn,
491 int offset; 492 int offset;
492 int ret; 493 int ret;
493 494
494 if (PCI_SLOT(devfn) != 0) 495 if ((bus->number == pcie->root_bus_nr) && PCI_SLOT(devfn) != 0)
495 return PCIBIOS_DEVICE_NOT_FOUND; 496 return PCIBIOS_DEVICE_NOT_FOUND;
496 497
497 if (where % size) 498 if (where % size)
@@ -609,9 +610,9 @@ static void advk_pcie_irq_mask(struct irq_data *d)
609 irq_hw_number_t hwirq = irqd_to_hwirq(d); 610 irq_hw_number_t hwirq = irqd_to_hwirq(d);
610 u32 mask; 611 u32 mask;
611 612
612 mask = advk_readl(pcie, PCIE_ISR0_MASK_REG); 613 mask = advk_readl(pcie, PCIE_ISR1_MASK_REG);
613 mask |= PCIE_ISR0_INTX_ASSERT(hwirq); 614 mask |= PCIE_ISR1_INTX_ASSERT(hwirq);
614 advk_writel(pcie, mask, PCIE_ISR0_MASK_REG); 615 advk_writel(pcie, mask, PCIE_ISR1_MASK_REG);
615} 616}
616 617
617static void advk_pcie_irq_unmask(struct irq_data *d) 618static void advk_pcie_irq_unmask(struct irq_data *d)
@@ -620,9 +621,9 @@ static void advk_pcie_irq_unmask(struct irq_data *d)
620 irq_hw_number_t hwirq = irqd_to_hwirq(d); 621 irq_hw_number_t hwirq = irqd_to_hwirq(d);
621 u32 mask; 622 u32 mask;
622 623
623 mask = advk_readl(pcie, PCIE_ISR0_MASK_REG); 624 mask = advk_readl(pcie, PCIE_ISR1_MASK_REG);
624 mask &= ~PCIE_ISR0_INTX_ASSERT(hwirq); 625 mask &= ~PCIE_ISR1_INTX_ASSERT(hwirq);
625 advk_writel(pcie, mask, PCIE_ISR0_MASK_REG); 626 advk_writel(pcie, mask, PCIE_ISR1_MASK_REG);
626} 627}
627 628
628static int advk_pcie_irq_map(struct irq_domain *h, 629static int advk_pcie_irq_map(struct irq_domain *h,
@@ -765,29 +766,35 @@ static void advk_pcie_handle_msi(struct advk_pcie *pcie)
765 766
766static void advk_pcie_handle_int(struct advk_pcie *pcie) 767static void advk_pcie_handle_int(struct advk_pcie *pcie)
767{ 768{
768 u32 val, mask, status; 769 u32 isr0_val, isr0_mask, isr0_status;
770 u32 isr1_val, isr1_mask, isr1_status;
769 int i, virq; 771 int i, virq;
770 772
771 val = advk_readl(pcie, PCIE_ISR0_REG); 773 isr0_val = advk_readl(pcie, PCIE_ISR0_REG);
772 mask = advk_readl(pcie, PCIE_ISR0_MASK_REG); 774 isr0_mask = advk_readl(pcie, PCIE_ISR0_MASK_REG);
773 status = val & ((~mask) & PCIE_ISR0_ALL_MASK); 775 isr0_status = isr0_val & ((~isr0_mask) & PCIE_ISR0_ALL_MASK);
776
777 isr1_val = advk_readl(pcie, PCIE_ISR1_REG);
778 isr1_mask = advk_readl(pcie, PCIE_ISR1_MASK_REG);
779 isr1_status = isr1_val & ((~isr1_mask) & PCIE_ISR1_ALL_MASK);
774 780
775 if (!status) { 781 if (!isr0_status && !isr1_status) {
776 advk_writel(pcie, val, PCIE_ISR0_REG); 782 advk_writel(pcie, isr0_val, PCIE_ISR0_REG);
783 advk_writel(pcie, isr1_val, PCIE_ISR1_REG);
777 return; 784 return;
778 } 785 }
779 786
780 /* Process MSI interrupts */ 787 /* Process MSI interrupts */
781 if (status & PCIE_ISR0_MSI_INT_PENDING) 788 if (isr0_status & PCIE_ISR0_MSI_INT_PENDING)
782 advk_pcie_handle_msi(pcie); 789 advk_pcie_handle_msi(pcie);
783 790
784 /* Process legacy interrupts */ 791 /* Process legacy interrupts */
785 for (i = 0; i < PCI_NUM_INTX; i++) { 792 for (i = 0; i < PCI_NUM_INTX; i++) {
786 if (!(status & PCIE_ISR0_INTX_ASSERT(i))) 793 if (!(isr1_status & PCIE_ISR1_INTX_ASSERT(i)))
787 continue; 794 continue;
788 795
789 advk_writel(pcie, PCIE_ISR0_INTX_ASSERT(i), 796 advk_writel(pcie, PCIE_ISR1_INTX_ASSERT(i),
790 PCIE_ISR0_REG); 797 PCIE_ISR1_REG);
791 798
792 virq = irq_find_mapping(pcie->irq_domain, i); 799 virq = irq_find_mapping(pcie->irq_domain, i);
793 generic_handle_irq(virq); 800 generic_handle_irq(virq);