|
@@ -17,6 +17,7 @@
|
|
|
#include <linux/module.h>
|
|
|
#include <linux/msi.h>
|
|
|
#include <linux/of_address.h>
|
|
|
+#include <linux/of_pci.h>
|
|
|
#include <linux/pci.h>
|
|
|
#include <linux/pci_regs.h>
|
|
|
#include <linux/types.h>
|
|
@@ -490,7 +491,7 @@ int __init dw_pcie_host_init(struct pcie_port *pp)
|
|
|
dw_pci.nr_controllers = 1;
|
|
|
dw_pci.private_data = (void **)&pp;
|
|
|
|
|
|
- pci_common_init(&dw_pci);
|
|
|
+ pci_common_init_dev(pp->dev, &dw_pci);
|
|
|
pci_assign_unassigned_resources();
|
|
|
#ifdef CONFIG_PCI_DOMAINS
|
|
|
dw_pci.domain++;
|
|
@@ -520,13 +521,13 @@ static void dw_pcie_prog_viewport_cfg1(struct pcie_port *pp, u32 busdev)
|
|
|
dw_pcie_writel_rc(pp, PCIE_ATU_REGION_OUTBOUND | PCIE_ATU_REGION_INDEX1,
|
|
|
PCIE_ATU_VIEWPORT);
|
|
|
dw_pcie_writel_rc(pp, PCIE_ATU_TYPE_CFG1, PCIE_ATU_CR1);
|
|
|
- dw_pcie_writel_rc(pp, PCIE_ATU_ENABLE, PCIE_ATU_CR2);
|
|
|
dw_pcie_writel_rc(pp, pp->cfg1_base, PCIE_ATU_LOWER_BASE);
|
|
|
dw_pcie_writel_rc(pp, (pp->cfg1_base >> 32), PCIE_ATU_UPPER_BASE);
|
|
|
dw_pcie_writel_rc(pp, pp->cfg1_base + pp->config.cfg1_size - 1,
|
|
|
PCIE_ATU_LIMIT);
|
|
|
dw_pcie_writel_rc(pp, busdev, PCIE_ATU_LOWER_TARGET);
|
|
|
dw_pcie_writel_rc(pp, 0, PCIE_ATU_UPPER_TARGET);
|
|
|
+ dw_pcie_writel_rc(pp, PCIE_ATU_ENABLE, PCIE_ATU_CR2);
|
|
|
}
|
|
|
|
|
|
static void dw_pcie_prog_viewport_mem_outbound(struct pcie_port *pp)
|
|
@@ -535,7 +536,6 @@ static void dw_pcie_prog_viewport_mem_outbound(struct pcie_port *pp)
|
|
|
dw_pcie_writel_rc(pp, PCIE_ATU_REGION_OUTBOUND | PCIE_ATU_REGION_INDEX0,
|
|
|
PCIE_ATU_VIEWPORT);
|
|
|
dw_pcie_writel_rc(pp, PCIE_ATU_TYPE_MEM, PCIE_ATU_CR1);
|
|
|
- dw_pcie_writel_rc(pp, PCIE_ATU_ENABLE, PCIE_ATU_CR2);
|
|
|
dw_pcie_writel_rc(pp, pp->mem_base, PCIE_ATU_LOWER_BASE);
|
|
|
dw_pcie_writel_rc(pp, (pp->mem_base >> 32), PCIE_ATU_UPPER_BASE);
|
|
|
dw_pcie_writel_rc(pp, pp->mem_base + pp->config.mem_size - 1,
|
|
@@ -543,6 +543,7 @@ static void dw_pcie_prog_viewport_mem_outbound(struct pcie_port *pp)
|
|
|
dw_pcie_writel_rc(pp, pp->config.mem_bus_addr, PCIE_ATU_LOWER_TARGET);
|
|
|
dw_pcie_writel_rc(pp, upper_32_bits(pp->config.mem_bus_addr),
|
|
|
PCIE_ATU_UPPER_TARGET);
|
|
|
+ dw_pcie_writel_rc(pp, PCIE_ATU_ENABLE, PCIE_ATU_CR2);
|
|
|
}
|
|
|
|
|
|
static void dw_pcie_prog_viewport_io_outbound(struct pcie_port *pp)
|
|
@@ -551,7 +552,6 @@ static void dw_pcie_prog_viewport_io_outbound(struct pcie_port *pp)
|
|
|
dw_pcie_writel_rc(pp, PCIE_ATU_REGION_OUTBOUND | PCIE_ATU_REGION_INDEX1,
|
|
|
PCIE_ATU_VIEWPORT);
|
|
|
dw_pcie_writel_rc(pp, PCIE_ATU_TYPE_IO, PCIE_ATU_CR1);
|
|
|
- dw_pcie_writel_rc(pp, PCIE_ATU_ENABLE, PCIE_ATU_CR2);
|
|
|
dw_pcie_writel_rc(pp, pp->io_base, PCIE_ATU_LOWER_BASE);
|
|
|
dw_pcie_writel_rc(pp, (pp->io_base >> 32), PCIE_ATU_UPPER_BASE);
|
|
|
dw_pcie_writel_rc(pp, pp->io_base + pp->config.io_size - 1,
|
|
@@ -559,6 +559,7 @@ static void dw_pcie_prog_viewport_io_outbound(struct pcie_port *pp)
|
|
|
dw_pcie_writel_rc(pp, pp->config.io_bus_addr, PCIE_ATU_LOWER_TARGET);
|
|
|
dw_pcie_writel_rc(pp, upper_32_bits(pp->config.io_bus_addr),
|
|
|
PCIE_ATU_UPPER_TARGET);
|
|
|
+ dw_pcie_writel_rc(pp, PCIE_ATU_ENABLE, PCIE_ATU_CR2);
|
|
|
}
|
|
|
|
|
|
static int dw_pcie_rd_other_conf(struct pcie_port *pp, struct pci_bus *bus,
|
|
@@ -723,7 +724,7 @@ static struct pci_bus *dw_pcie_scan_bus(int nr, struct pci_sys_data *sys)
|
|
|
|
|
|
if (pp) {
|
|
|
pp->root_bus_nr = sys->busnr;
|
|
|
- bus = pci_scan_root_bus(NULL, sys->busnr, &dw_pcie_ops,
|
|
|
+ bus = pci_scan_root_bus(pp->dev, sys->busnr, &dw_pcie_ops,
|
|
|
sys, &sys->resources);
|
|
|
} else {
|
|
|
bus = NULL;
|
|
@@ -736,8 +737,13 @@ static struct pci_bus *dw_pcie_scan_bus(int nr, struct pci_sys_data *sys)
|
|
|
static int dw_pcie_map_irq(const struct pci_dev *dev, u8 slot, u8 pin)
|
|
|
{
|
|
|
struct pcie_port *pp = sys_to_pcie(dev->bus->sysdata);
|
|
|
+ int irq;
|
|
|
+
|
|
|
+ irq = of_irq_parse_and_map_pci(dev, slot, pin);
|
|
|
+ if (!irq)
|
|
|
+ irq = pp->irq;
|
|
|
|
|
|
- return pp->irq;
|
|
|
+ return irq;
|
|
|
}
|
|
|
|
|
|
static void dw_pcie_add_bus(struct pci_bus *bus)
|
|
@@ -764,7 +770,7 @@ void dw_pcie_setup_rc(struct pcie_port *pp)
|
|
|
u32 membase;
|
|
|
u32 memlimit;
|
|
|
|
|
|
- /* set the number of lines as 4 */
|
|
|
+ /* set the number of lanes */
|
|
|
dw_pcie_readl_rc(pp, PCIE_PORT_LINK_CONTROL, &val);
|
|
|
val &= ~PORT_LINK_MODE_MASK;
|
|
|
switch (pp->lanes) {
|