PCI: dwc: Remove storing of PCI resources
[linux-2.6-microblaze.git] / drivers / pci / controller / dwc / pcie-al.c
index 270868f..f973fbc 100644 (file)
@@ -67,13 +67,8 @@ static int al_pcie_init(struct pci_config_window *cfg)
        dev_dbg(dev, "Root port dbi res: %pR\n", res);
 
        al_pcie->dbi_base = devm_pci_remap_cfg_resource(dev, res);
-       if (IS_ERR(al_pcie->dbi_base)) {
-               long err = PTR_ERR(al_pcie->dbi_base);
-
-               dev_err(dev, "couldn't remap dbi base %pR (err:%ld)\n",
-                       res, err);
-               return err;
-       }
+       if (IS_ERR(al_pcie->dbi_base))
+               return PTR_ERR(al_pcie->dbi_base);
 
        cfg->priv = al_pcie;
 
@@ -222,14 +217,15 @@ static inline void al_pcie_target_bus_set(struct al_pcie *pcie,
                                  reg);
 }
 
-static void __iomem *al_pcie_conf_addr_map(struct al_pcie *pcie,
-                                          unsigned int busnr,
-                                          unsigned int devfn)
+static void __iomem *al_pcie_conf_addr_map_bus(struct pci_bus *bus,
+                                              unsigned int devfn, int where)
 {
+       struct pcie_port *pp = bus->sysdata;
+       struct al_pcie *pcie = to_al_pcie(to_dw_pcie_from_pp(pp));
+       unsigned int busnr = bus->number;
        struct al_pcie_target_bus_cfg *target_bus_cfg = &pcie->target_bus_cfg;
        unsigned int busnr_ecam = busnr & target_bus_cfg->ecam_mask;
        unsigned int busnr_reg = busnr & target_bus_cfg->reg_mask;
-       struct pcie_port *pp = &pcie->pci->pp;
        void __iomem *pci_base_addr;
 
        pci_base_addr = (void __iomem *)((uintptr_t)pp->va_cfg0_base +
@@ -245,52 +241,14 @@ static void __iomem *al_pcie_conf_addr_map(struct al_pcie *pcie,
                                       target_bus_cfg->reg_mask);
        }
 
-       return pci_base_addr;
-}
-
-static int al_pcie_rd_other_conf(struct pcie_port *pp, struct pci_bus *bus,
-                                unsigned int devfn, int where, int size,
-                                u32 *val)
-{
-       struct dw_pcie *pci = to_dw_pcie_from_pp(pp);
-       struct al_pcie *pcie = to_al_pcie(pci);
-       unsigned int busnr = bus->number;
-       void __iomem *pci_addr;
-       int rc;
-
-       pci_addr = al_pcie_conf_addr_map(pcie, busnr, devfn);
-
-       rc = dw_pcie_read(pci_addr + where, size, val);
-
-       dev_dbg(pci->dev, "%d-byte config read from %04x:%02x:%02x.%d offset 0x%x (pci_addr: 0x%px) - val:0x%x\n",
-               size, pci_domain_nr(bus), bus->number,
-               PCI_SLOT(devfn), PCI_FUNC(devfn), where,
-               (pci_addr + where), *val);
-
-       return rc;
+       return pci_base_addr + where;
 }
 
-static int al_pcie_wr_other_conf(struct pcie_port *pp, struct pci_bus *bus,
-                                unsigned int devfn, int where, int size,
-                                u32 val)
-{
-       struct dw_pcie *pci = to_dw_pcie_from_pp(pp);
-       struct al_pcie *pcie = to_al_pcie(pci);
-       unsigned int busnr = bus->number;
-       void __iomem *pci_addr;
-       int rc;
-
-       pci_addr = al_pcie_conf_addr_map(pcie, busnr, devfn);
-
-       rc = dw_pcie_write(pci_addr + where, size, val);
-
-       dev_dbg(pci->dev, "%d-byte config write to %04x:%02x:%02x.%d offset 0x%x (pci_addr: 0x%px) - val:0x%x\n",
-               size, pci_domain_nr(bus), bus->number,
-               PCI_SLOT(devfn), PCI_FUNC(devfn), where,
-               (pci_addr + where), val);
-
-       return rc;
-}
+static struct pci_ops al_child_pci_ops = {
+       .map_bus = al_pcie_conf_addr_map_bus,
+       .read = pci_generic_config_read,
+       .write = pci_generic_config_write,
+};
 
 static void al_pcie_config_prepare(struct al_pcie *pcie)
 {
@@ -302,6 +260,7 @@ static void al_pcie_config_prepare(struct al_pcie *pcie)
        u8 secondary_bus;
        u32 cfg_control;
        u32 reg;
+       struct resource *bus = resource_list_first_type(&pp->bridge->windows, IORESOURCE_BUS)->res;
 
        target_bus_cfg = &pcie->target_bus_cfg;
 
@@ -315,13 +274,13 @@ static void al_pcie_config_prepare(struct al_pcie *pcie)
        target_bus_cfg->ecam_mask = ecam_bus_mask;
        /* This portion is taken from the cfg_target_bus reg */
        target_bus_cfg->reg_mask = ~target_bus_cfg->ecam_mask;
-       target_bus_cfg->reg_val = pp->busn->start & target_bus_cfg->reg_mask;
+       target_bus_cfg->reg_val = bus->start & target_bus_cfg->reg_mask;
 
        al_pcie_target_bus_set(pcie, target_bus_cfg->reg_val,
                               target_bus_cfg->reg_mask);
 
-       secondary_bus = pp->busn->start + 1;
-       subordinate_bus = pp->busn->end;
+       secondary_bus = bus->start + 1;
+       subordinate_bus = bus->end;
 
        /* Set the valid values of secondary and subordinate buses */
        cfg_control_offset = AXI_BASE_OFFSET + pcie->reg_offsets.ob_ctrl +
@@ -344,6 +303,8 @@ static int al_pcie_host_init(struct pcie_port *pp)
        struct al_pcie *pcie = to_al_pcie(pci);
        int rc;
 
+       pp->bridge->child_ops = &al_child_pci_ops;
+
        rc = al_pcie_rev_id_get(pcie, &pcie->controller_rev_id);
        if (rc)
                return rc;
@@ -358,8 +319,6 @@ static int al_pcie_host_init(struct pcie_port *pp)
 }
 
 static const struct dw_pcie_host_ops al_pcie_host_ops = {
-       .rd_other_conf = al_pcie_rd_other_conf,
-       .wr_other_conf = al_pcie_wr_other_conf,
        .host_init = al_pcie_host_init,
 };
 
@@ -408,10 +367,8 @@ static int al_pcie_probe(struct platform_device *pdev)
 
        dbi_res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "dbi");
        pci->dbi_base = devm_pci_remap_cfg_resource(dev, dbi_res);
-       if (IS_ERR(pci->dbi_base)) {
-               dev_err(dev, "couldn't remap dbi base %pR\n", dbi_res);
+       if (IS_ERR(pci->dbi_base))
                return PTR_ERR(pci->dbi_base);
-       }
 
        ecam_res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "config");
        if (!ecam_res) {