diff options
Diffstat (limited to 'drivers/pci')
| -rw-r--r-- | drivers/pci/access.c | 87 | ||||
| -rw-r--r-- | drivers/pci/host/pci-host-generic.c | 51 | ||||
| -rw-r--r-- | drivers/pci/host/pci-rcar-gen2.c | 51 | ||||
| -rw-r--r-- | drivers/pci/host/pci-tegra.c | 55 | ||||
| -rw-r--r-- | drivers/pci/host/pci-xgene.c | 150 | ||||
| -rw-r--r-- | drivers/pci/host/pcie-xilinx.c | 88 |
6 files changed, 114 insertions, 368 deletions
diff --git a/drivers/pci/access.c b/drivers/pci/access.c index 49dd766852ba..d9b64a175990 100644 --- a/drivers/pci/access.c +++ b/drivers/pci/access.c | |||
| @@ -67,6 +67,93 @@ EXPORT_SYMBOL(pci_bus_write_config_byte); | |||
| 67 | EXPORT_SYMBOL(pci_bus_write_config_word); | 67 | EXPORT_SYMBOL(pci_bus_write_config_word); |
| 68 | EXPORT_SYMBOL(pci_bus_write_config_dword); | 68 | EXPORT_SYMBOL(pci_bus_write_config_dword); |
| 69 | 69 | ||
| 70 | int pci_generic_config_read(struct pci_bus *bus, unsigned int devfn, | ||
| 71 | int where, int size, u32 *val) | ||
| 72 | { | ||
| 73 | void __iomem *addr; | ||
| 74 | |||
| 75 | addr = bus->ops->map_bus(bus, devfn, where); | ||
| 76 | if (!addr) { | ||
| 77 | *val = ~0; | ||
| 78 | return PCIBIOS_DEVICE_NOT_FOUND; | ||
| 79 | } | ||
| 80 | |||
| 81 | if (size == 1) | ||
| 82 | *val = readb(addr); | ||
| 83 | else if (size == 2) | ||
| 84 | *val = readw(addr); | ||
| 85 | else | ||
| 86 | *val = readl(addr); | ||
| 87 | |||
| 88 | return PCIBIOS_SUCCESSFUL; | ||
| 89 | } | ||
| 90 | EXPORT_SYMBOL_GPL(pci_generic_config_read); | ||
| 91 | |||
| 92 | int pci_generic_config_write(struct pci_bus *bus, unsigned int devfn, | ||
| 93 | int where, int size, u32 val) | ||
| 94 | { | ||
| 95 | void __iomem *addr; | ||
| 96 | |||
| 97 | addr = bus->ops->map_bus(bus, devfn, where); | ||
| 98 | if (!addr) | ||
| 99 | return PCIBIOS_DEVICE_NOT_FOUND; | ||
| 100 | |||
| 101 | if (size == 1) | ||
| 102 | writeb(val, addr); | ||
| 103 | else if (size == 2) | ||
| 104 | writew(val, addr); | ||
| 105 | else | ||
| 106 | writel(val, addr); | ||
| 107 | |||
| 108 | return PCIBIOS_SUCCESSFUL; | ||
| 109 | } | ||
| 110 | EXPORT_SYMBOL_GPL(pci_generic_config_write); | ||
| 111 | |||
| 112 | int pci_generic_config_read32(struct pci_bus *bus, unsigned int devfn, | ||
| 113 | int where, int size, u32 *val) | ||
| 114 | { | ||
| 115 | void __iomem *addr; | ||
| 116 | |||
| 117 | addr = bus->ops->map_bus(bus, devfn, where & ~0x3); | ||
| 118 | if (!addr) { | ||
| 119 | *val = ~0; | ||
| 120 | return PCIBIOS_DEVICE_NOT_FOUND; | ||
| 121 | } | ||
| 122 | |||
| 123 | *val = readl(addr); | ||
| 124 | |||
| 125 | if (size <= 2) | ||
| 126 | *val = (*val >> (8 * (where & 3))) & ((1 << (size * 8)) - 1); | ||
| 127 | |||
| 128 | return PCIBIOS_SUCCESSFUL; | ||
| 129 | } | ||
| 130 | EXPORT_SYMBOL_GPL(pci_generic_config_read32); | ||
| 131 | |||
| 132 | int pci_generic_config_write32(struct pci_bus *bus, unsigned int devfn, | ||
| 133 | int where, int size, u32 val) | ||
| 134 | { | ||
| 135 | void __iomem *addr; | ||
| 136 | u32 mask, tmp; | ||
| 137 | |||
| 138 | addr = bus->ops->map_bus(bus, devfn, where & ~0x3); | ||
| 139 | if (!addr) | ||
| 140 | return PCIBIOS_DEVICE_NOT_FOUND; | ||
| 141 | |||
| 142 | if (size == 4) { | ||
| 143 | writel(val, addr); | ||
| 144 | return PCIBIOS_SUCCESSFUL; | ||
| 145 | } else { | ||
| 146 | mask = ~(((1 << (size * 8)) - 1) << ((where & 0x3) * 8)); | ||
| 147 | } | ||
| 148 | |||
| 149 | tmp = readl(addr) & mask; | ||
| 150 | tmp |= val << ((where & 0x3) * 8); | ||
| 151 | writel(tmp, addr); | ||
| 152 | |||
| 153 | return PCIBIOS_SUCCESSFUL; | ||
| 154 | } | ||
| 155 | EXPORT_SYMBOL_GPL(pci_generic_config_write32); | ||
| 156 | |||
| 70 | /** | 157 | /** |
| 71 | * pci_bus_set_ops - Set raw operations of pci bus | 158 | * pci_bus_set_ops - Set raw operations of pci bus |
| 72 | * @bus: pci bus struct | 159 | * @bus: pci bus struct |
diff --git a/drivers/pci/host/pci-host-generic.c b/drivers/pci/host/pci-host-generic.c index 6eb1aa75bd37..925e29e3d4c8 100644 --- a/drivers/pci/host/pci-host-generic.c +++ b/drivers/pci/host/pci-host-generic.c | |||
| @@ -76,55 +76,9 @@ static struct gen_pci_cfg_bus_ops gen_pci_cfg_ecam_bus_ops = { | |||
| 76 | .map_bus = gen_pci_map_cfg_bus_ecam, | 76 | .map_bus = gen_pci_map_cfg_bus_ecam, |
| 77 | }; | 77 | }; |
| 78 | 78 | ||
| 79 | static int gen_pci_config_read(struct pci_bus *bus, unsigned int devfn, | ||
| 80 | int where, int size, u32 *val) | ||
| 81 | { | ||
| 82 | void __iomem *addr; | ||
| 83 | struct pci_sys_data *sys = bus->sysdata; | ||
| 84 | struct gen_pci *pci = sys->private_data; | ||
| 85 | |||
| 86 | addr = pci->cfg.ops->map_bus(bus, devfn, where); | ||
| 87 | |||
| 88 | switch (size) { | ||
| 89 | case 1: | ||
| 90 | *val = readb(addr); | ||
| 91 | break; | ||
| 92 | case 2: | ||
| 93 | *val = readw(addr); | ||
| 94 | break; | ||
| 95 | default: | ||
| 96 | *val = readl(addr); | ||
| 97 | } | ||
| 98 | |||
| 99 | return PCIBIOS_SUCCESSFUL; | ||
| 100 | } | ||
| 101 | |||
| 102 | static int gen_pci_config_write(struct pci_bus *bus, unsigned int devfn, | ||
| 103 | int where, int size, u32 val) | ||
| 104 | { | ||
| 105 | void __iomem *addr; | ||
| 106 | struct pci_sys_data *sys = bus->sysdata; | ||
| 107 | struct gen_pci *pci = sys->private_data; | ||
| 108 | |||
| 109 | addr = pci->cfg.ops->map_bus(bus, devfn, where); | ||
| 110 | |||
| 111 | switch (size) { | ||
| 112 | case 1: | ||
| 113 | writeb(val, addr); | ||
| 114 | break; | ||
| 115 | case 2: | ||
| 116 | writew(val, addr); | ||
| 117 | break; | ||
| 118 | default: | ||
| 119 | writel(val, addr); | ||
| 120 | } | ||
| 121 | |||
| 122 | return PCIBIOS_SUCCESSFUL; | ||
| 123 | } | ||
| 124 | |||
| 125 | static struct pci_ops gen_pci_ops = { | 79 | static struct pci_ops gen_pci_ops = { |
| 126 | .read = gen_pci_config_read, | 80 | .read = pci_generic_config_read, |
| 127 | .write = gen_pci_config_write, | 81 | .write = pci_generic_config_write, |
| 128 | }; | 82 | }; |
| 129 | 83 | ||
| 130 | static const struct of_device_id gen_pci_of_match[] = { | 84 | static const struct of_device_id gen_pci_of_match[] = { |
| @@ -287,6 +241,7 @@ static int gen_pci_probe(struct platform_device *pdev) | |||
| 287 | 241 | ||
| 288 | of_id = of_match_node(gen_pci_of_match, np); | 242 | of_id = of_match_node(gen_pci_of_match, np); |
| 289 | pci->cfg.ops = of_id->data; | 243 | pci->cfg.ops = of_id->data; |
| 244 | gen_pci_ops.map_bus = pci->cfg.ops->map_bus; | ||
| 290 | pci->host.dev.parent = dev; | 245 | pci->host.dev.parent = dev; |
| 291 | INIT_LIST_HEAD(&pci->host.windows); | 246 | INIT_LIST_HEAD(&pci->host.windows); |
| 292 | INIT_LIST_HEAD(&pci->resources); | 247 | INIT_LIST_HEAD(&pci->resources); |
diff --git a/drivers/pci/host/pci-rcar-gen2.c b/drivers/pci/host/pci-rcar-gen2.c index d9c042febb1a..dd6b84e6206c 100644 --- a/drivers/pci/host/pci-rcar-gen2.c +++ b/drivers/pci/host/pci-rcar-gen2.c | |||
| @@ -131,52 +131,6 @@ static void __iomem *rcar_pci_cfg_base(struct pci_bus *bus, unsigned int devfn, | |||
| 131 | return priv->reg + (slot >> 1) * 0x100 + where; | 131 | return priv->reg + (slot >> 1) * 0x100 + where; |
| 132 | } | 132 | } |
| 133 | 133 | ||
| 134 | static int rcar_pci_read_config(struct pci_bus *bus, unsigned int devfn, | ||
| 135 | int where, int size, u32 *val) | ||
| 136 | { | ||
| 137 | void __iomem *reg = rcar_pci_cfg_base(bus, devfn, where); | ||
| 138 | |||
| 139 | if (!reg) | ||
| 140 | return PCIBIOS_DEVICE_NOT_FOUND; | ||
| 141 | |||
| 142 | switch (size) { | ||
| 143 | case 1: | ||
| 144 | *val = ioread8(reg); | ||
| 145 | break; | ||
| 146 | case 2: | ||
| 147 | *val = ioread16(reg); | ||
| 148 | break; | ||
| 149 | default: | ||
| 150 | *val = ioread32(reg); | ||
| 151 | break; | ||
| 152 | } | ||
| 153 | |||
| 154 | return PCIBIOS_SUCCESSFUL; | ||
| 155 | } | ||
| 156 | |||
| 157 | static int rcar_pci_write_config(struct pci_bus *bus, unsigned int devfn, | ||
| 158 | int where, int size, u32 val) | ||
| 159 | { | ||
| 160 | void __iomem *reg = rcar_pci_cfg_base(bus, devfn, where); | ||
| 161 | |||
| 162 | if (!reg) | ||
| 163 | return PCIBIOS_DEVICE_NOT_FOUND; | ||
| 164 | |||
| 165 | switch (size) { | ||
| 166 | case 1: | ||
| 167 | iowrite8(val, reg); | ||
| 168 | break; | ||
| 169 | case 2: | ||
| 170 | iowrite16(val, reg); | ||
| 171 | break; | ||
| 172 | default: | ||
| 173 | iowrite32(val, reg); | ||
| 174 | break; | ||
| 175 | } | ||
| 176 | |||
| 177 | return PCIBIOS_SUCCESSFUL; | ||
| 178 | } | ||
| 179 | |||
| 180 | /* PCI interrupt mapping */ | 134 | /* PCI interrupt mapping */ |
| 181 | static int rcar_pci_map_irq(const struct pci_dev *dev, u8 slot, u8 pin) | 135 | static int rcar_pci_map_irq(const struct pci_dev *dev, u8 slot, u8 pin) |
| 182 | { | 136 | { |
| @@ -325,8 +279,9 @@ static int rcar_pci_setup(int nr, struct pci_sys_data *sys) | |||
| 325 | } | 279 | } |
| 326 | 280 | ||
| 327 | static struct pci_ops rcar_pci_ops = { | 281 | static struct pci_ops rcar_pci_ops = { |
| 328 | .read = rcar_pci_read_config, | 282 | .map_bus = rcar_pci_cfg_base, |
| 329 | .write = rcar_pci_write_config, | 283 | .read = pci_generic_config_read, |
| 284 | .write = pci_generic_config_write, | ||
| 330 | }; | 285 | }; |
| 331 | 286 | ||
| 332 | static int rcar_pci_probe(struct platform_device *pdev) | 287 | static int rcar_pci_probe(struct platform_device *pdev) |
diff --git a/drivers/pci/host/pci-tegra.c b/drivers/pci/host/pci-tegra.c index 6f9c29fa70e7..00e92720d7f7 100644 --- a/drivers/pci/host/pci-tegra.c +++ b/drivers/pci/host/pci-tegra.c | |||
| @@ -480,59 +480,10 @@ static void __iomem *tegra_pcie_conf_address(struct pci_bus *bus, | |||
| 480 | return addr; | 480 | return addr; |
| 481 | } | 481 | } |
| 482 | 482 | ||
| 483 | static int tegra_pcie_read_conf(struct pci_bus *bus, unsigned int devfn, | ||
| 484 | int where, int size, u32 *value) | ||
| 485 | { | ||
| 486 | void __iomem *addr; | ||
| 487 | |||
| 488 | addr = tegra_pcie_conf_address(bus, devfn, where); | ||
| 489 | if (!addr) { | ||
| 490 | *value = 0xffffffff; | ||
| 491 | return PCIBIOS_DEVICE_NOT_FOUND; | ||
| 492 | } | ||
| 493 | |||
| 494 | *value = readl(addr); | ||
| 495 | |||
| 496 | if (size == 1) | ||
| 497 | *value = (*value >> (8 * (where & 3))) & 0xff; | ||
| 498 | else if (size == 2) | ||
| 499 | *value = (*value >> (8 * (where & 3))) & 0xffff; | ||
| 500 | |||
| 501 | return PCIBIOS_SUCCESSFUL; | ||
| 502 | } | ||
| 503 | |||
| 504 | static int tegra_pcie_write_conf(struct pci_bus *bus, unsigned int devfn, | ||
| 505 | int where, int size, u32 value) | ||
| 506 | { | ||
| 507 | void __iomem *addr; | ||
| 508 | u32 mask, tmp; | ||
| 509 | |||
| 510 | addr = tegra_pcie_conf_address(bus, devfn, where); | ||
| 511 | if (!addr) | ||
| 512 | return PCIBIOS_DEVICE_NOT_FOUND; | ||
| 513 | |||
| 514 | if (size == 4) { | ||
| 515 | writel(value, addr); | ||
| 516 | return PCIBIOS_SUCCESSFUL; | ||
| 517 | } | ||
| 518 | |||
| 519 | if (size == 2) | ||
| 520 | mask = ~(0xffff << ((where & 0x3) * 8)); | ||
| 521 | else if (size == 1) | ||
| 522 | mask = ~(0xff << ((where & 0x3) * 8)); | ||
| 523 | else | ||
| 524 | return PCIBIOS_BAD_REGISTER_NUMBER; | ||
| 525 | |||
| 526 | tmp = readl(addr) & mask; | ||
| 527 | tmp |= value << ((where & 0x3) * 8); | ||
| 528 | writel(tmp, addr); | ||
| 529 | |||
| 530 | return PCIBIOS_SUCCESSFUL; | ||
| 531 | } | ||
| 532 | |||
| 533 | static struct pci_ops tegra_pcie_ops = { | 483 | static struct pci_ops tegra_pcie_ops = { |
| 534 | .read = tegra_pcie_read_conf, | 484 | .map_bus = tegra_pcie_conf_address, |
| 535 | .write = tegra_pcie_write_conf, | 485 | .read = pci_generic_config_read32, |
| 486 | .write = pci_generic_config_write32, | ||
| 536 | }; | 487 | }; |
| 537 | 488 | ||
| 538 | static unsigned long tegra_pcie_port_get_pex_ctrl(struct tegra_pcie_port *port) | 489 | static unsigned long tegra_pcie_port_get_pex_ctrl(struct tegra_pcie_port *port) |
diff --git a/drivers/pci/host/pci-xgene.c b/drivers/pci/host/pci-xgene.c index fdb348d3ccd3..e77d831dc241 100644 --- a/drivers/pci/host/pci-xgene.c +++ b/drivers/pci/host/pci-xgene.c | |||
| @@ -74,92 +74,6 @@ static inline u32 pcie_bar_low_val(u32 addr, u32 flags) | |||
| 74 | return (addr & PCI_BASE_ADDRESS_MEM_MASK) | flags; | 74 | return (addr & PCI_BASE_ADDRESS_MEM_MASK) | flags; |
| 75 | } | 75 | } |
| 76 | 76 | ||
| 77 | /* PCIe Configuration Out/In */ | ||
| 78 | static inline void xgene_pcie_cfg_out32(void __iomem *addr, int offset, u32 val) | ||
| 79 | { | ||
| 80 | writel(val, addr + offset); | ||
| 81 | } | ||
| 82 | |||
| 83 | static inline void xgene_pcie_cfg_out16(void __iomem *addr, int offset, u16 val) | ||
| 84 | { | ||
| 85 | u32 val32 = readl(addr + (offset & ~0x3)); | ||
| 86 | |||
| 87 | switch (offset & 0x3) { | ||
| 88 | case 2: | ||
| 89 | val32 &= ~0xFFFF0000; | ||
| 90 | val32 |= (u32)val << 16; | ||
| 91 | break; | ||
| 92 | case 0: | ||
| 93 | default: | ||
| 94 | val32 &= ~0xFFFF; | ||
| 95 | val32 |= val; | ||
| 96 | break; | ||
| 97 | } | ||
| 98 | writel(val32, addr + (offset & ~0x3)); | ||
| 99 | } | ||
| 100 | |||
| 101 | static inline void xgene_pcie_cfg_out8(void __iomem *addr, int offset, u8 val) | ||
| 102 | { | ||
| 103 | u32 val32 = readl(addr + (offset & ~0x3)); | ||
| 104 | |||
| 105 | switch (offset & 0x3) { | ||
| 106 | case 0: | ||
| 107 | val32 &= ~0xFF; | ||
| 108 | val32 |= val; | ||
| 109 | break; | ||
| 110 | case 1: | ||
| 111 | val32 &= ~0xFF00; | ||
| 112 | val32 |= (u32)val << 8; | ||
| 113 | break; | ||
| 114 | case 2: | ||
| 115 | val32 &= ~0xFF0000; | ||
| 116 | val32 |= (u32)val << 16; | ||
| 117 | break; | ||
| 118 | case 3: | ||
| 119 | default: | ||
| 120 | val32 &= ~0xFF000000; | ||
| 121 | val32 |= (u32)val << 24; | ||
| 122 | break; | ||
| 123 | } | ||
| 124 | writel(val32, addr + (offset & ~0x3)); | ||
| 125 | } | ||
| 126 | |||
| 127 | static inline void xgene_pcie_cfg_in32(void __iomem *addr, int offset, u32 *val) | ||
| 128 | { | ||
| 129 | *val = readl(addr + offset); | ||
| 130 | } | ||
| 131 | |||
| 132 | static inline void xgene_pcie_cfg_in16(void __iomem *addr, int offset, u32 *val) | ||
| 133 | { | ||
| 134 | *val = readl(addr + (offset & ~0x3)); | ||
| 135 | |||
| 136 | switch (offset & 0x3) { | ||
| 137 | case 2: | ||
| 138 | *val >>= 16; | ||
| 139 | break; | ||
| 140 | } | ||
| 141 | |||
| 142 | *val &= 0xFFFF; | ||
| 143 | } | ||
| 144 | |||
| 145 | static inline void xgene_pcie_cfg_in8(void __iomem *addr, int offset, u32 *val) | ||
| 146 | { | ||
| 147 | *val = readl(addr + (offset & ~0x3)); | ||
| 148 | |||
| 149 | switch (offset & 0x3) { | ||
| 150 | case 3: | ||
| 151 | *val = *val >> 24; | ||
| 152 | break; | ||
| 153 | case 2: | ||
| 154 | *val = *val >> 16; | ||
| 155 | break; | ||
| 156 | case 1: | ||
| 157 | *val = *val >> 8; | ||
| 158 | break; | ||
| 159 | } | ||
| 160 | *val &= 0xFF; | ||
| 161 | } | ||
| 162 | |||
| 163 | /* | 77 | /* |
| 164 | * When the address bit [17:16] is 2'b01, the Configuration access will be | 78 | * When the address bit [17:16] is 2'b01, the Configuration access will be |
| 165 | * treated as Type 1 and it will be forwarded to external PCIe device. | 79 | * treated as Type 1 and it will be forwarded to external PCIe device. |
| @@ -213,69 +127,23 @@ static bool xgene_pcie_hide_rc_bars(struct pci_bus *bus, int offset) | |||
| 213 | return false; | 127 | return false; |
| 214 | } | 128 | } |
| 215 | 129 | ||
| 216 | static int xgene_pcie_read_config(struct pci_bus *bus, unsigned int devfn, | 130 | static int xgene_pcie_map_bus(struct pci_bus *bus, unsigned int devfn, |
| 217 | int offset, int len, u32 *val) | 131 | int offset) |
| 218 | { | ||
| 219 | struct xgene_pcie_port *port = bus->sysdata; | ||
| 220 | void __iomem *addr; | ||
| 221 | |||
| 222 | if ((pci_is_root_bus(bus) && devfn != 0) || !port->link_up) | ||
| 223 | return PCIBIOS_DEVICE_NOT_FOUND; | ||
| 224 | |||
| 225 | if (xgene_pcie_hide_rc_bars(bus, offset)) { | ||
| 226 | *val = 0; | ||
| 227 | return PCIBIOS_SUCCESSFUL; | ||
| 228 | } | ||
| 229 | |||
| 230 | xgene_pcie_set_rtdid_reg(bus, devfn); | ||
| 231 | addr = xgene_pcie_get_cfg_base(bus); | ||
| 232 | switch (len) { | ||
| 233 | case 1: | ||
| 234 | xgene_pcie_cfg_in8(addr, offset, val); | ||
| 235 | break; | ||
| 236 | case 2: | ||
| 237 | xgene_pcie_cfg_in16(addr, offset, val); | ||
| 238 | break; | ||
| 239 | default: | ||
| 240 | xgene_pcie_cfg_in32(addr, offset, val); | ||
| 241 | break; | ||
| 242 | } | ||
| 243 | |||
| 244 | return PCIBIOS_SUCCESSFUL; | ||
| 245 | } | ||
| 246 | |||
| 247 | static int xgene_pcie_write_config(struct pci_bus *bus, unsigned int devfn, | ||
| 248 | int offset, int len, u32 val) | ||
| 249 | { | 132 | { |
| 250 | struct xgene_pcie_port *port = bus->sysdata; | 133 | struct xgene_pcie_port *port = bus->sysdata; |
| 251 | void __iomem *addr; | ||
| 252 | 134 | ||
| 253 | if ((pci_is_root_bus(bus) && devfn != 0) || !port->link_up) | 135 | if ((pci_is_root_bus(bus) && devfn != 0) || !port->link_up || |
| 254 | return PCIBIOS_DEVICE_NOT_FOUND; | 136 | xgene_pcie_hide_rc_bars(bus, offset)) |
| 255 | 137 | return NULL; | |
| 256 | if (xgene_pcie_hide_rc_bars(bus, offset)) | ||
| 257 | return PCIBIOS_SUCCESSFUL; | ||
| 258 | 138 | ||
| 259 | xgene_pcie_set_rtdid_reg(bus, devfn); | 139 | xgene_pcie_set_rtdid_reg(bus, devfn); |
| 260 | addr = xgene_pcie_get_cfg_base(bus); | 140 | return xgene_pcie_get_cfg_base(bus); |
| 261 | switch (len) { | ||
| 262 | case 1: | ||
| 263 | xgene_pcie_cfg_out8(addr, offset, (u8)val); | ||
| 264 | break; | ||
| 265 | case 2: | ||
| 266 | xgene_pcie_cfg_out16(addr, offset, (u16)val); | ||
| 267 | break; | ||
| 268 | default: | ||
| 269 | xgene_pcie_cfg_out32(addr, offset, val); | ||
| 270 | break; | ||
| 271 | } | ||
| 272 | |||
| 273 | return PCIBIOS_SUCCESSFUL; | ||
| 274 | } | 141 | } |
| 275 | 142 | ||
| 276 | static struct pci_ops xgene_pcie_ops = { | 143 | static struct pci_ops xgene_pcie_ops = { |
| 277 | .read = xgene_pcie_read_config, | 144 | .map_bus = xgene_pcie_map_bus, |
| 278 | .write = xgene_pcie_write_config | 145 | .read = pci_generic_config_read32, |
| 146 | .write = pci_generic_config_write32, | ||
| 279 | }; | 147 | }; |
| 280 | 148 | ||
| 281 | static u64 xgene_pcie_set_ib_mask(void __iomem *csr_base, u32 addr, | 149 | static u64 xgene_pcie_set_ib_mask(void __iomem *csr_base, u32 addr, |
diff --git a/drivers/pci/host/pcie-xilinx.c b/drivers/pci/host/pcie-xilinx.c index ce1c61d85b2c..eac4a4b957ca 100644 --- a/drivers/pci/host/pcie-xilinx.c +++ b/drivers/pci/host/pcie-xilinx.c | |||
| @@ -189,7 +189,7 @@ static bool xilinx_pcie_valid_device(struct pci_bus *bus, unsigned int devfn) | |||
| 189 | } | 189 | } |
| 190 | 190 | ||
| 191 | /** | 191 | /** |
| 192 | * xilinx_pcie_config_base - Get configuration base | 192 | * xilinx_pcie_map_bus - Get configuration base |
| 193 | * @bus: PCI Bus structure | 193 | * @bus: PCI Bus structure |
| 194 | * @devfn: Device/function | 194 | * @devfn: Device/function |
| 195 | * @where: Offset from base | 195 | * @where: Offset from base |
| @@ -197,96 +197,26 @@ static bool xilinx_pcie_valid_device(struct pci_bus *bus, unsigned int devfn) | |||
| 197 | * Return: Base address of the configuration space needed to be | 197 | * Return: Base address of the configuration space needed to be |
| 198 | * accessed. | 198 | * accessed. |
| 199 | */ | 199 | */ |
| 200 | static void __iomem *xilinx_pcie_config_base(struct pci_bus *bus, | 200 | static void __iomem *xilinx_pcie_map_bus(struct pci_bus *bus, |
| 201 | unsigned int devfn, int where) | 201 | unsigned int devfn, int where) |
| 202 | { | 202 | { |
| 203 | struct xilinx_pcie_port *port = sys_to_pcie(bus->sysdata); | 203 | struct xilinx_pcie_port *port = sys_to_pcie(bus->sysdata); |
| 204 | int relbus; | 204 | int relbus; |
| 205 | 205 | ||
| 206 | if (!xilinx_pcie_valid_device(bus, devfn)) | ||
| 207 | return NULL; | ||
| 208 | |||
| 206 | relbus = (bus->number << ECAM_BUS_NUM_SHIFT) | | 209 | relbus = (bus->number << ECAM_BUS_NUM_SHIFT) | |
| 207 | (devfn << ECAM_DEV_NUM_SHIFT); | 210 | (devfn << ECAM_DEV_NUM_SHIFT); |
| 208 | 211 | ||
| 209 | return port->reg_base + relbus + where; | 212 | return port->reg_base + relbus + where; |
| 210 | } | 213 | } |
| 211 | 214 | ||
| 212 | /** | ||
| 213 | * xilinx_pcie_read_config - Read configuration space | ||
| 214 | * @bus: PCI Bus structure | ||
| 215 | * @devfn: Device/function | ||
| 216 | * @where: Offset from base | ||
| 217 | * @size: Byte/word/dword | ||
| 218 | * @val: Value to be read | ||
| 219 | * | ||
| 220 | * Return: PCIBIOS_SUCCESSFUL on success | ||
| 221 | * PCIBIOS_DEVICE_NOT_FOUND on failure | ||
| 222 | */ | ||
| 223 | static int xilinx_pcie_read_config(struct pci_bus *bus, unsigned int devfn, | ||
| 224 | int where, int size, u32 *val) | ||
| 225 | { | ||
| 226 | void __iomem *addr; | ||
| 227 | |||
| 228 | if (!xilinx_pcie_valid_device(bus, devfn)) { | ||
| 229 | *val = 0xFFFFFFFF; | ||
| 230 | return PCIBIOS_DEVICE_NOT_FOUND; | ||
| 231 | } | ||
| 232 | |||
| 233 | addr = xilinx_pcie_config_base(bus, devfn, where); | ||
| 234 | |||
| 235 | switch (size) { | ||
| 236 | case 1: | ||
| 237 | *val = readb(addr); | ||
| 238 | break; | ||
| 239 | case 2: | ||
| 240 | *val = readw(addr); | ||
| 241 | break; | ||
| 242 | default: | ||
| 243 | *val = readl(addr); | ||
| 244 | break; | ||
| 245 | } | ||
| 246 | |||
| 247 | return PCIBIOS_SUCCESSFUL; | ||
| 248 | } | ||
| 249 | |||
| 250 | /** | ||
| 251 | * xilinx_pcie_write_config - Write configuration space | ||
| 252 | * @bus: PCI Bus structure | ||
| 253 | * @devfn: Device/function | ||
| 254 | * @where: Offset from base | ||
| 255 | * @size: Byte/word/dword | ||
| 256 | * @val: Value to be written to device | ||
| 257 | * | ||
| 258 | * Return: PCIBIOS_SUCCESSFUL on success | ||
| 259 | * PCIBIOS_DEVICE_NOT_FOUND on failure | ||
| 260 | */ | ||
| 261 | static int xilinx_pcie_write_config(struct pci_bus *bus, unsigned int devfn, | ||
| 262 | int where, int size, u32 val) | ||
| 263 | { | ||
| 264 | void __iomem *addr; | ||
| 265 | |||
| 266 | if (!xilinx_pcie_valid_device(bus, devfn)) | ||
| 267 | return PCIBIOS_DEVICE_NOT_FOUND; | ||
| 268 | |||
| 269 | addr = xilinx_pcie_config_base(bus, devfn, where); | ||
| 270 | |||
| 271 | switch (size) { | ||
| 272 | case 1: | ||
| 273 | writeb(val, addr); | ||
| 274 | break; | ||
| 275 | case 2: | ||
| 276 | writew(val, addr); | ||
| 277 | break; | ||
| 278 | default: | ||
| 279 | writel(val, addr); | ||
| 280 | break; | ||
| 281 | } | ||
| 282 | |||
| 283 | return PCIBIOS_SUCCESSFUL; | ||
| 284 | } | ||
| 285 | |||
| 286 | /* PCIe operations */ | 215 | /* PCIe operations */ |
| 287 | static struct pci_ops xilinx_pcie_ops = { | 216 | static struct pci_ops xilinx_pcie_ops = { |
| 288 | .read = xilinx_pcie_read_config, | 217 | .map_bus = xilinx_pcie_map_bus, |
| 289 | .write = xilinx_pcie_write_config, | 218 | .read = pci_generic_config_read, |
| 219 | .write = pci_generic_config_write, | ||
| 290 | }; | 220 | }; |
| 291 | 221 | ||
| 292 | /* MSI functions */ | 222 | /* MSI functions */ |
