PCI: dwc: exynos: Use pci_ops for root config space accessors
[linux-2.6-microblaze.git] / drivers / pci / controller / dwc / pci-exynos.c
index a075eba..242683c 100644 (file)
@@ -84,14 +84,12 @@ static int exynos5440_pcie_get_mem_resources(struct platform_device *pdev,
 {
        struct dw_pcie *pci = ep->pci;
        struct device *dev = pci->dev;
-       struct resource *res;
 
        ep->mem_res = devm_kzalloc(dev, sizeof(*ep->mem_res), GFP_KERNEL);
        if (!ep->mem_res)
                return -ENOMEM;
 
-       res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-       ep->mem_res->elbi_base = devm_ioremap_resource(dev, res);
+       ep->mem_res->elbi_base = devm_platform_ioremap_resource(pdev, 0);
        if (IS_ERR(ep->mem_res->elbi_base))
                return PTR_ERR(ep->mem_res->elbi_base);
 
@@ -338,32 +336,37 @@ static void exynos_pcie_write_dbi(struct dw_pcie *pci, void __iomem *base,
        exynos_pcie_sideband_dbi_w_mode(ep, false);
 }
 
-static int exynos_pcie_rd_own_conf(struct pcie_port *pp, int where, int size,
-                               u32 *val)
+static int exynos_pcie_rd_own_conf(struct pci_bus *bus, unsigned int devfn,
+                                  int where, int size, u32 *val)
 {
-       struct dw_pcie *pci = to_dw_pcie_from_pp(pp);
-       struct exynos_pcie *ep = to_exynos_pcie(pci);
-       int ret;
+       struct dw_pcie *pci = to_dw_pcie_from_pp(bus->sysdata);
 
-       exynos_pcie_sideband_dbi_r_mode(ep, true);
-       ret = dw_pcie_read(pci->dbi_base + where, size, val);
-       exynos_pcie_sideband_dbi_r_mode(ep, false);
-       return ret;
+       if (PCI_SLOT(devfn)) {
+               *val = ~0;
+               return PCIBIOS_DEVICE_NOT_FOUND;
+       }
+
+       *val = dw_pcie_read_dbi(pci, where, size);
+       return PCIBIOS_SUCCESSFUL;
 }
 
-static int exynos_pcie_wr_own_conf(struct pcie_port *pp, int where, int size,
-                               u32 val)
+static int exynos_pcie_wr_own_conf(struct pci_bus *bus, unsigned int devfn,
+                                  int where, int size, u32 val)
 {
-       struct dw_pcie *pci = to_dw_pcie_from_pp(pp);
-       struct exynos_pcie *ep = to_exynos_pcie(pci);
-       int ret;
+       struct dw_pcie *pci = to_dw_pcie_from_pp(bus->sysdata);
 
-       exynos_pcie_sideband_dbi_w_mode(ep, true);
-       ret = dw_pcie_write(pci->dbi_base + where, size, val);
-       exynos_pcie_sideband_dbi_w_mode(ep, false);
-       return ret;
+       if (PCI_SLOT(devfn))
+               return PCIBIOS_DEVICE_NOT_FOUND;
+
+       dw_pcie_write_dbi(pci, where, size, val);
+       return PCIBIOS_SUCCESSFUL;
 }
 
+static struct pci_ops exynos_pci_ops = {
+       .read = exynos_pcie_rd_own_conf,
+       .write = exynos_pcie_wr_own_conf,
+};
+
 static int exynos_pcie_link_up(struct dw_pcie *pci)
 {
        struct exynos_pcie *ep = to_exynos_pcie(pci);
@@ -381,6 +384,8 @@ static int exynos_pcie_host_init(struct pcie_port *pp)
        struct dw_pcie *pci = to_dw_pcie_from_pp(pp);
        struct exynos_pcie *ep = to_exynos_pcie(pci);
 
+       pp->bridge->ops = &exynos_pci_ops;
+
        exynos_pcie_establish_link(ep);
        exynos_pcie_enable_interrupts(ep);
 
@@ -388,8 +393,6 @@ static int exynos_pcie_host_init(struct pcie_port *pp)
 }
 
 static const struct dw_pcie_host_ops exynos_pcie_host_ops = {
-       .rd_own_conf = exynos_pcie_rd_own_conf,
-       .wr_own_conf = exynos_pcie_wr_own_conf,
        .host_init = exynos_pcie_host_init,
 };
 
@@ -402,10 +405,9 @@ static int __init exynos_add_pcie_port(struct exynos_pcie *ep,
        int ret;
 
        pp->irq = platform_get_irq(pdev, 1);
-       if (pp->irq < 0) {
-               dev_err(dev, "failed to get irq\n");
+       if (pp->irq < 0)
                return pp->irq;
-       }
+
        ret = devm_request_irq(dev, pp->irq, exynos_pcie_irq_handler,
                                IRQF_SHARED, "exynos-pcie", ep);
        if (ret) {
@@ -415,10 +417,8 @@ static int __init exynos_add_pcie_port(struct exynos_pcie *ep,
 
        if (IS_ENABLED(CONFIG_PCI_MSI)) {
                pp->msi_irq = platform_get_irq(pdev, 0);
-               if (pp->msi_irq < 0) {
-                       dev_err(dev, "failed to get msi irq\n");
+               if (pp->msi_irq < 0)
                        return pp->msi_irq;
-               }
        }
 
        pp->ops = &exynos_pcie_host_ops;