Lines Matching +full:pcie +full:- +full:host +full:- +full:1

1 // SPDX-License-Identifier: GPL-2.0
3 * PCIe driver for Renesas R-Car SoCs
4 * Copyright (C) 2014-2020 Renesas Electronics Europe Ltd
12 #include "pcie-rcar.h"
14 void rcar_pci_write_reg(struct rcar_pcie *pcie, u32 val, unsigned int reg) in rcar_pci_write_reg() argument
16 writel(val, pcie->base + reg); in rcar_pci_write_reg()
19 u32 rcar_pci_read_reg(struct rcar_pcie *pcie, unsigned int reg) in rcar_pci_read_reg() argument
21 return readl(pcie->base + reg); in rcar_pci_read_reg()
24 void rcar_rmw32(struct rcar_pcie *pcie, int where, u32 mask, u32 data) in rcar_rmw32() argument
27 u32 val = rcar_pci_read_reg(pcie, where & ~3); in rcar_rmw32()
31 rcar_pci_write_reg(pcie, val, where & ~3); in rcar_rmw32()
34 int rcar_pcie_wait_for_phyrdy(struct rcar_pcie *pcie) in rcar_pcie_wait_for_phyrdy() argument
38 while (timeout--) { in rcar_pcie_wait_for_phyrdy()
39 if (rcar_pci_read_reg(pcie, PCIEPHYSR) & PHYRDY) in rcar_pcie_wait_for_phyrdy()
45 return -ETIMEDOUT; in rcar_pcie_wait_for_phyrdy()
48 int rcar_pcie_wait_for_dl(struct rcar_pcie *pcie) in rcar_pcie_wait_for_dl() argument
52 while (timeout--) { in rcar_pcie_wait_for_dl()
53 if ((rcar_pci_read_reg(pcie, PCIETSTR) & DATA_LINK_ACTIVE)) in rcar_pcie_wait_for_dl()
60 return -ETIMEDOUT; in rcar_pcie_wait_for_dl()
63 void rcar_pcie_set_outbound(struct rcar_pcie *pcie, int win, in rcar_pcie_set_outbound() argument
66 /* Setup PCIe address space mappings for each resource */ in rcar_pcie_set_outbound()
67 struct resource *res = window->res; in rcar_pcie_set_outbound()
72 rcar_pci_write_reg(pcie, 0x00000000, PCIEPTCTLR(win)); in rcar_pcie_set_outbound()
80 mask = (roundup_pow_of_two(size) / SZ_128) - 1; in rcar_pcie_set_outbound()
83 rcar_pci_write_reg(pcie, mask << 7, PCIEPAMR(win)); in rcar_pcie_set_outbound()
85 if (res->flags & IORESOURCE_IO) in rcar_pcie_set_outbound()
86 res_start = pci_pio_to_address(res->start) - window->offset; in rcar_pcie_set_outbound()
88 res_start = res->start - window->offset; in rcar_pcie_set_outbound()
90 rcar_pci_write_reg(pcie, upper_32_bits(res_start), PCIEPAUR(win)); in rcar_pcie_set_outbound()
91 rcar_pci_write_reg(pcie, lower_32_bits(res_start) & ~0x7F, in rcar_pcie_set_outbound()
96 if (res->flags & IORESOURCE_IO) in rcar_pcie_set_outbound()
99 rcar_pci_write_reg(pcie, mask, PCIEPTCTLR(win)); in rcar_pcie_set_outbound()
102 void rcar_pcie_set_inbound(struct rcar_pcie *pcie, u64 cpu_addr, in rcar_pcie_set_inbound() argument
103 u64 pci_addr, u64 flags, int idx, bool host) in rcar_pcie_set_inbound() argument
106 * Set up 64-bit inbound regions as the range parser doesn't in rcar_pcie_set_inbound()
107 * distinguish between 32 and 64-bit types. in rcar_pcie_set_inbound()
109 if (host) in rcar_pcie_set_inbound()
110 rcar_pci_write_reg(pcie, lower_32_bits(pci_addr), in rcar_pcie_set_inbound()
112 rcar_pci_write_reg(pcie, lower_32_bits(cpu_addr), PCIELAR(idx)); in rcar_pcie_set_inbound()
113 rcar_pci_write_reg(pcie, flags, PCIELAMR(idx)); in rcar_pcie_set_inbound()
115 if (host) in rcar_pcie_set_inbound()
116 rcar_pci_write_reg(pcie, upper_32_bits(pci_addr), in rcar_pcie_set_inbound()
117 PCIEPRAR(idx + 1)); in rcar_pcie_set_inbound()
118 rcar_pci_write_reg(pcie, upper_32_bits(cpu_addr), PCIELAR(idx + 1)); in rcar_pcie_set_inbound()
119 rcar_pci_write_reg(pcie, 0, PCIELAMR(idx + 1)); in rcar_pcie_set_inbound()