|
@@ -17,6 +17,7 @@
|
|
#include <linux/module.h>
|
|
#include <linux/module.h>
|
|
#include <linux/msi.h>
|
|
#include <linux/msi.h>
|
|
#include <linux/of_address.h>
|
|
#include <linux/of_address.h>
|
|
|
|
+#include <linux/of_pci.h>
|
|
#include <linux/pci.h>
|
|
#include <linux/pci.h>
|
|
#include <linux/pci_regs.h>
|
|
#include <linux/pci_regs.h>
|
|
#include <linux/types.h>
|
|
#include <linux/types.h>
|
|
@@ -494,7 +495,7 @@ int __init dw_pcie_host_init(struct pcie_port *pp)
|
|
dw_pci.nr_controllers = 1;
|
|
dw_pci.nr_controllers = 1;
|
|
dw_pci.private_data = (void **)&pp;
|
|
dw_pci.private_data = (void **)&pp;
|
|
|
|
|
|
- pci_common_init(&dw_pci);
|
|
|
|
|
|
+ pci_common_init_dev(pp->dev, &dw_pci);
|
|
pci_assign_unassigned_resources();
|
|
pci_assign_unassigned_resources();
|
|
#ifdef CONFIG_PCI_DOMAINS
|
|
#ifdef CONFIG_PCI_DOMAINS
|
|
dw_pci.domain++;
|
|
dw_pci.domain++;
|
|
@@ -524,13 +525,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,
|
|
dw_pcie_writel_rc(pp, PCIE_ATU_REGION_OUTBOUND | PCIE_ATU_REGION_INDEX1,
|
|
PCIE_ATU_VIEWPORT);
|
|
PCIE_ATU_VIEWPORT);
|
|
dw_pcie_writel_rc(pp, PCIE_ATU_TYPE_CFG1, PCIE_ATU_CR1);
|
|
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, 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 >> 32), PCIE_ATU_UPPER_BASE);
|
|
dw_pcie_writel_rc(pp, pp->cfg1_base + pp->config.cfg1_size - 1,
|
|
dw_pcie_writel_rc(pp, pp->cfg1_base + pp->config.cfg1_size - 1,
|
|
PCIE_ATU_LIMIT);
|
|
PCIE_ATU_LIMIT);
|
|
dw_pcie_writel_rc(pp, busdev, PCIE_ATU_LOWER_TARGET);
|
|
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, 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)
|
|
static 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)
|
|
dw_pcie_writel_rc(pp, PCIE_ATU_REGION_OUTBOUND | PCIE_ATU_REGION_INDEX0,
|
|
dw_pcie_writel_rc(pp, PCIE_ATU_REGION_OUTBOUND | PCIE_ATU_REGION_INDEX0,
|
|
PCIE_ATU_VIEWPORT);
|
|
PCIE_ATU_VIEWPORT);
|
|
dw_pcie_writel_rc(pp, PCIE_ATU_TYPE_MEM, PCIE_ATU_CR1);
|
|
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, 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 >> 32), PCIE_ATU_UPPER_BASE);
|
|
dw_pcie_writel_rc(pp, pp->mem_base + pp->config.mem_size - 1,
|
|
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)
|
|
dw_pcie_writel_rc(pp, pp->config.mem_bus_addr, PCIE_ATU_LOWER_TARGET);
|
|
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),
|
|
dw_pcie_writel_rc(pp, upper_32_bits(pp->config.mem_bus_addr),
|
|
PCIE_ATU_UPPER_TARGET);
|
|
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)
|
|
static 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)
|
|
dw_pcie_writel_rc(pp, PCIE_ATU_REGION_OUTBOUND | PCIE_ATU_REGION_INDEX1,
|
|
dw_pcie_writel_rc(pp, PCIE_ATU_REGION_OUTBOUND | PCIE_ATU_REGION_INDEX1,
|
|
PCIE_ATU_VIEWPORT);
|
|
PCIE_ATU_VIEWPORT);
|
|
dw_pcie_writel_rc(pp, PCIE_ATU_TYPE_IO, PCIE_ATU_CR1);
|
|
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, 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 >> 32), PCIE_ATU_UPPER_BASE);
|
|
dw_pcie_writel_rc(pp, pp->io_base + pp->config.io_size - 1,
|
|
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)
|
|
dw_pcie_writel_rc(pp, pp->config.io_bus_addr, PCIE_ATU_LOWER_TARGET);
|
|
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),
|
|
dw_pcie_writel_rc(pp, upper_32_bits(pp->config.io_bus_addr),
|
|
PCIE_ATU_UPPER_TARGET);
|
|
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,
|
|
static 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,
|
|
int size, u32 *val)
|
|
int size, u32 *val)
|
|
{
|
|
{
|
|
struct pcie_port *pp = sys_to_pcie(bus->sysdata);
|
|
struct pcie_port *pp = sys_to_pcie(bus->sysdata);
|
|
- unsigned long flags;
|
|
|
|
int ret;
|
|
int ret;
|
|
|
|
|
|
if (!pp) {
|
|
if (!pp) {
|
|
@@ -655,13 +655,11 @@ static int dw_pcie_rd_conf(struct pci_bus *bus, u32 devfn, int where,
|
|
return PCIBIOS_DEVICE_NOT_FOUND;
|
|
return PCIBIOS_DEVICE_NOT_FOUND;
|
|
}
|
|
}
|
|
|
|
|
|
- spin_lock_irqsave(&pp->conf_lock, flags);
|
|
|
|
if (bus->number != pp->root_bus_nr)
|
|
if (bus->number != pp->root_bus_nr)
|
|
ret = dw_pcie_rd_other_conf(pp, bus, devfn,
|
|
ret = dw_pcie_rd_other_conf(pp, bus, devfn,
|
|
where, size, val);
|
|
where, size, val);
|
|
else
|
|
else
|
|
ret = dw_pcie_rd_own_conf(pp, where, size, val);
|
|
ret = dw_pcie_rd_own_conf(pp, where, size, val);
|
|
- spin_unlock_irqrestore(&pp->conf_lock, flags);
|
|
|
|
|
|
|
|
return ret;
|
|
return ret;
|
|
}
|
|
}
|
|
@@ -670,7 +668,6 @@ static int dw_pcie_wr_conf(struct pci_bus *bus, u32 devfn,
|
|
int where, int size, u32 val)
|
|
int where, int size, u32 val)
|
|
{
|
|
{
|
|
struct pcie_port *pp = sys_to_pcie(bus->sysdata);
|
|
struct pcie_port *pp = sys_to_pcie(bus->sysdata);
|
|
- unsigned long flags;
|
|
|
|
int ret;
|
|
int ret;
|
|
|
|
|
|
if (!pp) {
|
|
if (!pp) {
|
|
@@ -681,13 +678,11 @@ static int dw_pcie_wr_conf(struct pci_bus *bus, u32 devfn,
|
|
if (dw_pcie_valid_config(pp, bus, PCI_SLOT(devfn)) == 0)
|
|
if (dw_pcie_valid_config(pp, bus, PCI_SLOT(devfn)) == 0)
|
|
return PCIBIOS_DEVICE_NOT_FOUND;
|
|
return PCIBIOS_DEVICE_NOT_FOUND;
|
|
|
|
|
|
- spin_lock_irqsave(&pp->conf_lock, flags);
|
|
|
|
if (bus->number != pp->root_bus_nr)
|
|
if (bus->number != pp->root_bus_nr)
|
|
ret = dw_pcie_wr_other_conf(pp, bus, devfn,
|
|
ret = dw_pcie_wr_other_conf(pp, bus, devfn,
|
|
where, size, val);
|
|
where, size, val);
|
|
else
|
|
else
|
|
ret = dw_pcie_wr_own_conf(pp, where, size, val);
|
|
ret = dw_pcie_wr_own_conf(pp, where, size, val);
|
|
- spin_unlock_irqrestore(&pp->conf_lock, flags);
|
|
|
|
|
|
|
|
return ret;
|
|
return ret;
|
|
}
|
|
}
|
|
@@ -727,7 +722,7 @@ static struct pci_bus *dw_pcie_scan_bus(int nr, struct pci_sys_data *sys)
|
|
|
|
|
|
if (pp) {
|
|
if (pp) {
|
|
pp->root_bus_nr = sys->busnr;
|
|
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);
|
|
sys, &sys->resources);
|
|
} else {
|
|
} else {
|
|
bus = NULL;
|
|
bus = NULL;
|
|
@@ -740,8 +735,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)
|
|
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);
|
|
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)
|
|
static void dw_pcie_add_bus(struct pci_bus *bus)
|
|
@@ -768,7 +768,7 @@ void dw_pcie_setup_rc(struct pcie_port *pp)
|
|
u32 membase;
|
|
u32 membase;
|
|
u32 memlimit;
|
|
u32 memlimit;
|
|
|
|
|
|
- /* set the number of lines as 4 */
|
|
|
|
|
|
+ /* set the number of lanes */
|
|
dw_pcie_readl_rc(pp, PCIE_PORT_LINK_CONTROL, &val);
|
|
dw_pcie_readl_rc(pp, PCIE_PORT_LINK_CONTROL, &val);
|
|
val &= ~PORT_LINK_MODE_MASK;
|
|
val &= ~PORT_LINK_MODE_MASK;
|
|
switch (pp->lanes) {
|
|
switch (pp->lanes) {
|