Skip to content

Commit 883cc17

Browse files
g00308965bjorn-helgaas
authored andcommitted
PCI: designware: Move calculation of bus addresses to DRA7xx
Commit f4c55c5 ("PCI: designware: Program ATU with untranslated address") added the calculation of PCI bus addresses in pcie-designware.c, storing them in new fields added in struct pcie_port. This calculation is done for every DesignWare user even though it only applies to DRA7xx. Move the calculation of the bus addresses to the DRA7xx driver to allow the rework of DesignWare to use the new DT parsing API. Signed-off-by: Gabriele Paoloni <gabriele.paoloni@huawei.com> Signed-off-by: Zhou Wang <wangzhou1@hisilicon.com> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com> Acked-by: Pratyush Anand <pratyush.anand@gmail.com>
1 parent 907fce0 commit 883cc17

2 files changed

Lines changed: 11 additions & 11 deletions

File tree

‎drivers/pci/host/pci-dra7xx.c‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@
6262

6363
#define PCIECTRL_DRA7XX_CONF_PHY_CS 0x010C
6464
#define LINK_UP BIT(16)
65+
#define DRA7XX_CPU_TO_BUS_ADDR 0x0FFFFFFF
6566

6667
struct dra7xx_pcie {
6768
void __iomem *base;
@@ -151,6 +152,12 @@ static void dra7xx_pcie_enable_interrupts(struct pcie_port *pp)
151152
static void dra7xx_pcie_host_init(struct pcie_port *pp)
152153
{
153154
dw_pcie_setup_rc(pp);
155+
156+
pp->io_mod_base &= DRA7XX_CPU_TO_BUS_ADDR;
157+
pp->mem_mod_base &= DRA7XX_CPU_TO_BUS_ADDR;
158+
pp->cfg0_mod_base &= DRA7XX_CPU_TO_BUS_ADDR;
159+
pp->cfg1_mod_base &= DRA7XX_CPU_TO_BUS_ADDR;
160+
154161
dra7xx_pcie_establish_link(pp);
155162
if (IS_ENABLED(CONFIG_PCI_MSI))
156163
dw_pcie_msi_init(pp);

‎drivers/pci/host/pcie-designware.c‎

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -417,14 +417,10 @@ int dw_pcie_host_init(struct pcie_port *pp)
417417
struct of_pci_range range;
418418
struct of_pci_range_parser parser;
419419
struct resource *cfg_res;
420-
u32 val, na, ns;
420+
u32 val, ns;
421421
const __be32 *addrp;
422422
int i, index, ret;
423423

424-
/* Find the address cell size and the number of cells in order to get
425-
* the untranslated address.
426-
*/
427-
of_property_read_u32(np, "#address-cells", &na);
428424
ns = of_n_size_cells(np);
429425

430426
cfg_res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "config");
@@ -467,8 +463,7 @@ int dw_pcie_host_init(struct pcie_port *pp)
467463
pp->io_base = range.cpu_addr;
468464

469465
/* Find the untranslated IO space address */
470-
pp->io_mod_base = of_read_number(parser.range -
471-
parser.np + na, ns);
466+
pp->io_mod_base = range.cpu_addr;
472467
}
473468
if (restype == IORESOURCE_MEM) {
474469
of_pci_range_to_resource(&range, np, &pp->mem);
@@ -477,8 +472,7 @@ int dw_pcie_host_init(struct pcie_port *pp)
477472
pp->mem_bus_addr = range.pci_addr;
478473

479474
/* Find the untranslated MEM space address */
480-
pp->mem_mod_base = of_read_number(parser.range -
481-
parser.np + na, ns);
475+
pp->mem_mod_base = range.cpu_addr;
482476
}
483477
if (restype == 0) {
484478
of_pci_range_to_resource(&range, np, &pp->cfg);
@@ -488,8 +482,7 @@ int dw_pcie_host_init(struct pcie_port *pp)
488482
pp->cfg1_base = pp->cfg.start + pp->cfg0_size;
489483

490484
/* Find the untranslated configuration space address */
491-
pp->cfg0_mod_base = of_read_number(parser.range -
492-
parser.np + na, ns);
485+
pp->cfg0_mod_base = range.cpu_addr;
493486
pp->cfg1_mod_base = pp->cfg0_mod_base +
494487
pp->cfg0_size;
495488
}

0 commit comments

Comments
 (0)