PCI: rcar: Fix incorrect programming of OB windows
The outbound windows (PCIEPAUR(x), PCIEPALR(x)) describe a mapping between
a CPU address (which is determined by the window number 'x') and a
programmed PCI address - Thus allowing the controller to translate CPU
accesses into PCI accesses.
However the existing code incorrectly writes the CPU address - lets fix
this by writing the PCI address instead.
For memory transactions, existing DT users describe a 1:1 identity mapping
and thus this change should have no effect. However the same isn't true for
I/O.
Link: https://lore.kernel.org/r/20191004132941.6660-1-andrew.murray@arm.com
Fixes: c25da47788
("PCI: rcar: Add Renesas R-Car PCIe driver")
Tested-by: Marek Vasut <marek.vasut+renesas@gmail.com>
Signed-off-by: Andrew Murray <andrew.murray@arm.com>
Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Reviewed-by: Marek Vasut <marek.vasut+renesas@gmail.com>
alistair/sunxi64-5.8
parent
8f3d9f3542
commit
2b9f217433
|
@ -333,11 +333,12 @@ static struct pci_ops rcar_pcie_ops = {
|
||||||
};
|
};
|
||||||
|
|
||||||
static void rcar_pcie_setup_window(int win, struct rcar_pcie *pcie,
|
static void rcar_pcie_setup_window(int win, struct rcar_pcie *pcie,
|
||||||
struct resource *res)
|
struct resource_entry *window)
|
||||||
{
|
{
|
||||||
/* Setup PCIe address space mappings for each resource */
|
/* Setup PCIe address space mappings for each resource */
|
||||||
resource_size_t size;
|
resource_size_t size;
|
||||||
resource_size_t res_start;
|
resource_size_t res_start;
|
||||||
|
struct resource *res = window->res;
|
||||||
u32 mask;
|
u32 mask;
|
||||||
|
|
||||||
rcar_pci_write_reg(pcie, 0x00000000, PCIEPTCTLR(win));
|
rcar_pci_write_reg(pcie, 0x00000000, PCIEPTCTLR(win));
|
||||||
|
@ -351,9 +352,9 @@ static void rcar_pcie_setup_window(int win, struct rcar_pcie *pcie,
|
||||||
rcar_pci_write_reg(pcie, mask << 7, PCIEPAMR(win));
|
rcar_pci_write_reg(pcie, mask << 7, PCIEPAMR(win));
|
||||||
|
|
||||||
if (res->flags & IORESOURCE_IO)
|
if (res->flags & IORESOURCE_IO)
|
||||||
res_start = pci_pio_to_address(res->start);
|
res_start = pci_pio_to_address(res->start) - window->offset;
|
||||||
else
|
else
|
||||||
res_start = res->start;
|
res_start = res->start - window->offset;
|
||||||
|
|
||||||
rcar_pci_write_reg(pcie, upper_32_bits(res_start), PCIEPAUR(win));
|
rcar_pci_write_reg(pcie, upper_32_bits(res_start), PCIEPAUR(win));
|
||||||
rcar_pci_write_reg(pcie, lower_32_bits(res_start) & ~0x7F,
|
rcar_pci_write_reg(pcie, lower_32_bits(res_start) & ~0x7F,
|
||||||
|
@ -382,7 +383,7 @@ static int rcar_pcie_setup(struct list_head *resource, struct rcar_pcie *pci)
|
||||||
switch (resource_type(res)) {
|
switch (resource_type(res)) {
|
||||||
case IORESOURCE_IO:
|
case IORESOURCE_IO:
|
||||||
case IORESOURCE_MEM:
|
case IORESOURCE_MEM:
|
||||||
rcar_pcie_setup_window(i, pci, res);
|
rcar_pcie_setup_window(i, pci, win);
|
||||||
i++;
|
i++;
|
||||||
break;
|
break;
|
||||||
case IORESOURCE_BUS:
|
case IORESOURCE_BUS:
|
||||||
|
|
Loading…
Reference in New Issue