Bjorn Helgaas | 8cfab3c | 2018-01-26 12:50:27 -0600 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0 |
Phil Edworthy | c25da47 | 2014-05-12 11:57:48 +0100 | [diff] [blame] | 2 | /* |
| 3 | * PCIe driver for Renesas R-Car SoCs |
Lad Prabhakar | 78a0d7f | 2020-05-07 13:33:13 +0100 | [diff] [blame] | 4 | * Copyright (C) 2014-2020 Renesas Electronics Europe Ltd |
Phil Edworthy | c25da47 | 2014-05-12 11:57:48 +0100 | [diff] [blame] | 5 | * |
| 6 | * Based on: |
| 7 | * arch/sh/drivers/pci/pcie-sh7786.c |
| 8 | * arch/sh/drivers/pci/ops-sh7786.c |
| 9 | * Copyright (C) 2009 - 2011 Paul Mundt |
| 10 | * |
Paul Gortmaker | 42d1071 | 2016-07-22 16:23:21 -0500 | [diff] [blame] | 11 | * Author: Phil Edworthy <phil.edworthy@renesas.com> |
Phil Edworthy | c25da47 | 2014-05-12 11:57:48 +0100 | [diff] [blame] | 12 | */ |
| 13 | |
Marek Vasut | 0ee4082 | 2018-04-08 20:04:31 +0200 | [diff] [blame] | 14 | #include <linux/bitops.h> |
Phil Edworthy | c25da47 | 2014-05-12 11:57:48 +0100 | [diff] [blame] | 15 | #include <linux/clk.h> |
| 16 | #include <linux/delay.h> |
| 17 | #include <linux/interrupt.h> |
Phil Edworthy | 290c1fb | 2014-05-12 11:57:49 +0100 | [diff] [blame] | 18 | #include <linux/irq.h> |
| 19 | #include <linux/irqdomain.h> |
Phil Edworthy | c25da47 | 2014-05-12 11:57:48 +0100 | [diff] [blame] | 20 | #include <linux/kernel.h> |
Paul Gortmaker | 42d1071 | 2016-07-22 16:23:21 -0500 | [diff] [blame] | 21 | #include <linux/init.h> |
Phil Edworthy | 290c1fb | 2014-05-12 11:57:49 +0100 | [diff] [blame] | 22 | #include <linux/msi.h> |
Phil Edworthy | c25da47 | 2014-05-12 11:57:48 +0100 | [diff] [blame] | 23 | #include <linux/of_address.h> |
| 24 | #include <linux/of_irq.h> |
| 25 | #include <linux/of_pci.h> |
| 26 | #include <linux/of_platform.h> |
| 27 | #include <linux/pci.h> |
Sergei Shtylyov | 517ca93 | 2018-05-03 22:40:54 +0300 | [diff] [blame] | 28 | #include <linux/phy/phy.h> |
Phil Edworthy | c25da47 | 2014-05-12 11:57:48 +0100 | [diff] [blame] | 29 | #include <linux/platform_device.h> |
Phil Edworthy | de1be9a | 2016-01-05 13:00:30 +0000 | [diff] [blame] | 30 | #include <linux/pm_runtime.h> |
Phil Edworthy | c25da47 | 2014-05-12 11:57:48 +0100 | [diff] [blame] | 31 | #include <linux/slab.h> |
| 32 | |
Lad Prabhakar | 78a0d7f | 2020-05-07 13:33:13 +0100 | [diff] [blame] | 33 | #include "pcie-rcar.h" |
Phil Edworthy | c25da47 | 2014-05-12 11:57:48 +0100 | [diff] [blame] | 34 | |
Phil Edworthy | 290c1fb | 2014-05-12 11:57:49 +0100 | [diff] [blame] | 35 | struct rcar_msi { |
| 36 | DECLARE_BITMAP(used, INT_PCI_MSI_NR); |
| 37 | struct irq_domain *domain; |
Yijing Wang | c2791b8 | 2014-11-11 17:45:45 -0700 | [diff] [blame] | 38 | struct msi_controller chip; |
Phil Edworthy | 290c1fb | 2014-05-12 11:57:49 +0100 | [diff] [blame] | 39 | unsigned long pages; |
| 40 | struct mutex lock; |
| 41 | int irq1; |
| 42 | int irq2; |
| 43 | }; |
| 44 | |
Yijing Wang | c2791b8 | 2014-11-11 17:45:45 -0700 | [diff] [blame] | 45 | static inline struct rcar_msi *to_rcar_msi(struct msi_controller *chip) |
Phil Edworthy | 290c1fb | 2014-05-12 11:57:49 +0100 | [diff] [blame] | 46 | { |
| 47 | return container_of(chip, struct rcar_msi, chip); |
| 48 | } |
| 49 | |
Phil Edworthy | c25da47 | 2014-05-12 11:57:48 +0100 | [diff] [blame] | 50 | /* Structure representing the PCIe interface */ |
Lad Prabhakar | 78a0d7f | 2020-05-07 13:33:13 +0100 | [diff] [blame] | 51 | struct rcar_pcie_host { |
| 52 | struct rcar_pcie pcie; |
Phil Edworthy | c25da47 | 2014-05-12 11:57:48 +0100 | [diff] [blame] | 53 | struct device *dev; |
Sergei Shtylyov | 517ca93 | 2018-05-03 22:40:54 +0300 | [diff] [blame] | 54 | struct phy *phy; |
Phil Edworthy | c25da47 | 2014-05-12 11:57:48 +0100 | [diff] [blame] | 55 | void __iomem *base; |
Phil Edworthy | c25da47 | 2014-05-12 11:57:48 +0100 | [diff] [blame] | 56 | struct clk *bus_clk; |
Phil Edworthy | 290c1fb | 2014-05-12 11:57:49 +0100 | [diff] [blame] | 57 | struct rcar_msi msi; |
Lad Prabhakar | 78a0d7f | 2020-05-07 13:33:13 +0100 | [diff] [blame] | 58 | int (*phy_init_fn)(struct rcar_pcie_host *host); |
Phil Edworthy | c25da47 | 2014-05-12 11:57:48 +0100 | [diff] [blame] | 59 | }; |
| 60 | |
Phil Edworthy | c25da47 | 2014-05-12 11:57:48 +0100 | [diff] [blame] | 61 | static u32 rcar_read_conf(struct rcar_pcie *pcie, int where) |
| 62 | { |
Marek Vasut | 29ffa6d | 2019-03-25 12:40:59 +0100 | [diff] [blame] | 63 | unsigned int shift = BITS_PER_BYTE * (where & 3); |
Phil Edworthy | b7718849 | 2014-06-30 08:54:23 +0100 | [diff] [blame] | 64 | u32 val = rcar_pci_read_reg(pcie, where & ~3); |
Phil Edworthy | c25da47 | 2014-05-12 11:57:48 +0100 | [diff] [blame] | 65 | |
| 66 | return val >> shift; |
| 67 | } |
| 68 | |
| 69 | /* Serialization is provided by 'pci_lock' in drivers/pci/access.c */ |
Lad Prabhakar | 78a0d7f | 2020-05-07 13:33:13 +0100 | [diff] [blame] | 70 | static int rcar_pcie_config_access(struct rcar_pcie_host *host, |
Phil Edworthy | c25da47 | 2014-05-12 11:57:48 +0100 | [diff] [blame] | 71 | unsigned char access_type, struct pci_bus *bus, |
| 72 | unsigned int devfn, int where, u32 *data) |
| 73 | { |
Lad Prabhakar | 78a0d7f | 2020-05-07 13:33:13 +0100 | [diff] [blame] | 74 | struct rcar_pcie *pcie = &host->pcie; |
Marek Vasut | d8fa266 | 2019-03-25 12:40:58 +0100 | [diff] [blame] | 75 | unsigned int dev, func, reg, index; |
Phil Edworthy | c25da47 | 2014-05-12 11:57:48 +0100 | [diff] [blame] | 76 | |
| 77 | dev = PCI_SLOT(devfn); |
| 78 | func = PCI_FUNC(devfn); |
| 79 | reg = where & ~3; |
| 80 | index = reg / 4; |
| 81 | |
| 82 | /* |
| 83 | * While each channel has its own memory-mapped extended config |
| 84 | * space, it's generally only accessible when in endpoint mode. |
| 85 | * When in root complex mode, the controller is unable to target |
| 86 | * itself with either type 0 or type 1 accesses, and indeed, any |
| 87 | * controller initiated target transfer to its own config space |
| 88 | * result in a completer abort. |
| 89 | * |
| 90 | * Each channel effectively only supports a single device, but as |
| 91 | * the same channel <-> device access works for any PCI_SLOT() |
| 92 | * value, we cheat a bit here and bind the controller's config |
| 93 | * space to devfn 0 in order to enable self-enumeration. In this |
| 94 | * case the regular ECAR/ECDR path is sidelined and the mangled |
| 95 | * config access itself is initiated as an internal bus transaction. |
| 96 | */ |
| 97 | if (pci_is_root_bus(bus)) { |
| 98 | if (dev != 0) |
| 99 | return PCIBIOS_DEVICE_NOT_FOUND; |
| 100 | |
Rob Herring | 6176a5f | 2020-07-21 20:25:05 -0600 | [diff] [blame] | 101 | if (access_type == RCAR_PCI_ACCESS_READ) |
Phil Edworthy | b7718849 | 2014-06-30 08:54:23 +0100 | [diff] [blame] | 102 | *data = rcar_pci_read_reg(pcie, PCICONF(index)); |
Rob Herring | 6176a5f | 2020-07-21 20:25:05 -0600 | [diff] [blame] | 103 | else |
Phil Edworthy | b7718849 | 2014-06-30 08:54:23 +0100 | [diff] [blame] | 104 | rcar_pci_write_reg(pcie, *data, PCICONF(index)); |
Phil Edworthy | c25da47 | 2014-05-12 11:57:48 +0100 | [diff] [blame] | 105 | |
| 106 | return PCIBIOS_SUCCESSFUL; |
| 107 | } |
| 108 | |
Phil Edworthy | c25da47 | 2014-05-12 11:57:48 +0100 | [diff] [blame] | 109 | /* Clear errors */ |
Phil Edworthy | b7718849 | 2014-06-30 08:54:23 +0100 | [diff] [blame] | 110 | rcar_pci_write_reg(pcie, rcar_pci_read_reg(pcie, PCIEERRFR), PCIEERRFR); |
Phil Edworthy | c25da47 | 2014-05-12 11:57:48 +0100 | [diff] [blame] | 111 | |
| 112 | /* Set the PIO address */ |
Phil Edworthy | b7718849 | 2014-06-30 08:54:23 +0100 | [diff] [blame] | 113 | rcar_pci_write_reg(pcie, PCIE_CONF_BUS(bus->number) | |
| 114 | PCIE_CONF_DEV(dev) | PCIE_CONF_FUNC(func) | reg, PCIECAR); |
Phil Edworthy | c25da47 | 2014-05-12 11:57:48 +0100 | [diff] [blame] | 115 | |
| 116 | /* Enable the configuration access */ |
Rob Herring | 6176a5f | 2020-07-21 20:25:05 -0600 | [diff] [blame] | 117 | if (pci_is_root_bus(bus->parent)) |
Phil Edworthy | b7718849 | 2014-06-30 08:54:23 +0100 | [diff] [blame] | 118 | rcar_pci_write_reg(pcie, CONFIG_SEND_ENABLE | TYPE0, PCIECCTLR); |
Phil Edworthy | c25da47 | 2014-05-12 11:57:48 +0100 | [diff] [blame] | 119 | else |
Phil Edworthy | b7718849 | 2014-06-30 08:54:23 +0100 | [diff] [blame] | 120 | rcar_pci_write_reg(pcie, CONFIG_SEND_ENABLE | TYPE1, PCIECCTLR); |
Phil Edworthy | c25da47 | 2014-05-12 11:57:48 +0100 | [diff] [blame] | 121 | |
| 122 | /* Check for errors */ |
Phil Edworthy | b7718849 | 2014-06-30 08:54:23 +0100 | [diff] [blame] | 123 | if (rcar_pci_read_reg(pcie, PCIEERRFR) & UNSUPPORTED_REQUEST) |
Phil Edworthy | c25da47 | 2014-05-12 11:57:48 +0100 | [diff] [blame] | 124 | return PCIBIOS_DEVICE_NOT_FOUND; |
| 125 | |
| 126 | /* Check for master and target aborts */ |
| 127 | if (rcar_read_conf(pcie, RCONF(PCI_STATUS)) & |
| 128 | (PCI_STATUS_REC_MASTER_ABORT | PCI_STATUS_REC_TARGET_ABORT)) |
| 129 | return PCIBIOS_DEVICE_NOT_FOUND; |
| 130 | |
Phil Edworthy | b7718849 | 2014-06-30 08:54:23 +0100 | [diff] [blame] | 131 | if (access_type == RCAR_PCI_ACCESS_READ) |
| 132 | *data = rcar_pci_read_reg(pcie, PCIECDR); |
Phil Edworthy | c25da47 | 2014-05-12 11:57:48 +0100 | [diff] [blame] | 133 | else |
Phil Edworthy | b7718849 | 2014-06-30 08:54:23 +0100 | [diff] [blame] | 134 | rcar_pci_write_reg(pcie, *data, PCIECDR); |
Phil Edworthy | c25da47 | 2014-05-12 11:57:48 +0100 | [diff] [blame] | 135 | |
| 136 | /* Disable the configuration access */ |
Phil Edworthy | b7718849 | 2014-06-30 08:54:23 +0100 | [diff] [blame] | 137 | rcar_pci_write_reg(pcie, 0, PCIECCTLR); |
Phil Edworthy | c25da47 | 2014-05-12 11:57:48 +0100 | [diff] [blame] | 138 | |
| 139 | return PCIBIOS_SUCCESSFUL; |
| 140 | } |
| 141 | |
| 142 | static int rcar_pcie_read_conf(struct pci_bus *bus, unsigned int devfn, |
| 143 | int where, int size, u32 *val) |
| 144 | { |
Lad Prabhakar | 78a0d7f | 2020-05-07 13:33:13 +0100 | [diff] [blame] | 145 | struct rcar_pcie_host *host = bus->sysdata; |
Phil Edworthy | c25da47 | 2014-05-12 11:57:48 +0100 | [diff] [blame] | 146 | int ret; |
| 147 | |
Lad Prabhakar | 78a0d7f | 2020-05-07 13:33:13 +0100 | [diff] [blame] | 148 | ret = rcar_pcie_config_access(host, RCAR_PCI_ACCESS_READ, |
Phil Edworthy | c25da47 | 2014-05-12 11:57:48 +0100 | [diff] [blame] | 149 | bus, devfn, where, val); |
| 150 | if (ret != PCIBIOS_SUCCESSFUL) { |
| 151 | *val = 0xffffffff; |
| 152 | return ret; |
| 153 | } |
| 154 | |
| 155 | if (size == 1) |
Marek Vasut | 29ffa6d | 2019-03-25 12:40:59 +0100 | [diff] [blame] | 156 | *val = (*val >> (BITS_PER_BYTE * (where & 3))) & 0xff; |
Phil Edworthy | c25da47 | 2014-05-12 11:57:48 +0100 | [diff] [blame] | 157 | else if (size == 2) |
Marek Vasut | 29ffa6d | 2019-03-25 12:40:59 +0100 | [diff] [blame] | 158 | *val = (*val >> (BITS_PER_BYTE * (where & 2))) & 0xffff; |
Phil Edworthy | c25da47 | 2014-05-12 11:57:48 +0100 | [diff] [blame] | 159 | |
Marek Vasut | 42a58f7 | 2019-03-25 12:41:00 +0100 | [diff] [blame] | 160 | dev_dbg(&bus->dev, "pcie-config-read: bus=%3d devfn=0x%04x where=0x%04x size=%d val=0x%08x\n", |
| 161 | bus->number, devfn, where, size, *val); |
Phil Edworthy | c25da47 | 2014-05-12 11:57:48 +0100 | [diff] [blame] | 162 | |
| 163 | return ret; |
| 164 | } |
| 165 | |
| 166 | /* Serialization is provided by 'pci_lock' in drivers/pci/access.c */ |
| 167 | static int rcar_pcie_write_conf(struct pci_bus *bus, unsigned int devfn, |
| 168 | int where, int size, u32 val) |
| 169 | { |
Lad Prabhakar | 78a0d7f | 2020-05-07 13:33:13 +0100 | [diff] [blame] | 170 | struct rcar_pcie_host *host = bus->sysdata; |
Marek Vasut | d8fa266 | 2019-03-25 12:40:58 +0100 | [diff] [blame] | 171 | unsigned int shift; |
Phil Edworthy | c25da47 | 2014-05-12 11:57:48 +0100 | [diff] [blame] | 172 | u32 data; |
Marek Vasut | d8fa266 | 2019-03-25 12:40:58 +0100 | [diff] [blame] | 173 | int ret; |
Phil Edworthy | c25da47 | 2014-05-12 11:57:48 +0100 | [diff] [blame] | 174 | |
Lad Prabhakar | 78a0d7f | 2020-05-07 13:33:13 +0100 | [diff] [blame] | 175 | ret = rcar_pcie_config_access(host, RCAR_PCI_ACCESS_READ, |
Phil Edworthy | c25da47 | 2014-05-12 11:57:48 +0100 | [diff] [blame] | 176 | bus, devfn, where, &data); |
| 177 | if (ret != PCIBIOS_SUCCESSFUL) |
| 178 | return ret; |
| 179 | |
Marek Vasut | 42a58f7 | 2019-03-25 12:41:00 +0100 | [diff] [blame] | 180 | dev_dbg(&bus->dev, "pcie-config-write: bus=%3d devfn=0x%04x where=0x%04x size=%d val=0x%08x\n", |
| 181 | bus->number, devfn, where, size, val); |
Phil Edworthy | c25da47 | 2014-05-12 11:57:48 +0100 | [diff] [blame] | 182 | |
| 183 | if (size == 1) { |
Marek Vasut | 29ffa6d | 2019-03-25 12:40:59 +0100 | [diff] [blame] | 184 | shift = BITS_PER_BYTE * (where & 3); |
Phil Edworthy | c25da47 | 2014-05-12 11:57:48 +0100 | [diff] [blame] | 185 | data &= ~(0xff << shift); |
| 186 | data |= ((val & 0xff) << shift); |
| 187 | } else if (size == 2) { |
Marek Vasut | 29ffa6d | 2019-03-25 12:40:59 +0100 | [diff] [blame] | 188 | shift = BITS_PER_BYTE * (where & 2); |
Phil Edworthy | c25da47 | 2014-05-12 11:57:48 +0100 | [diff] [blame] | 189 | data &= ~(0xffff << shift); |
| 190 | data |= ((val & 0xffff) << shift); |
| 191 | } else |
| 192 | data = val; |
| 193 | |
Lad Prabhakar | 78a0d7f | 2020-05-07 13:33:13 +0100 | [diff] [blame] | 194 | ret = rcar_pcie_config_access(host, RCAR_PCI_ACCESS_WRITE, |
Phil Edworthy | c25da47 | 2014-05-12 11:57:48 +0100 | [diff] [blame] | 195 | bus, devfn, where, &data); |
| 196 | |
| 197 | return ret; |
| 198 | } |
| 199 | |
| 200 | static struct pci_ops rcar_pcie_ops = { |
| 201 | .read = rcar_pcie_read_conf, |
| 202 | .write = rcar_pcie_write_conf, |
| 203 | }; |
| 204 | |
Sergei Shtylyov | b3327f7 | 2016-09-22 23:20:18 +0300 | [diff] [blame] | 205 | static void rcar_pcie_force_speedup(struct rcar_pcie *pcie) |
| 206 | { |
Bjorn Helgaas | 4ef80d7 | 2016-10-10 14:31:28 -0500 | [diff] [blame] | 207 | struct device *dev = pcie->dev; |
Sergei Shtylyov | b3327f7 | 2016-09-22 23:20:18 +0300 | [diff] [blame] | 208 | unsigned int timeout = 1000; |
| 209 | u32 macsr; |
| 210 | |
| 211 | if ((rcar_pci_read_reg(pcie, MACS2R) & LINK_SPEED) != LINK_SPEED_5_0GTS) |
| 212 | return; |
| 213 | |
| 214 | if (rcar_pci_read_reg(pcie, MACCTLR) & SPEED_CHANGE) { |
Bjorn Helgaas | 4ef80d7 | 2016-10-10 14:31:28 -0500 | [diff] [blame] | 215 | dev_err(dev, "Speed change already in progress\n"); |
Sergei Shtylyov | b3327f7 | 2016-09-22 23:20:18 +0300 | [diff] [blame] | 216 | return; |
| 217 | } |
| 218 | |
| 219 | macsr = rcar_pci_read_reg(pcie, MACSR); |
| 220 | if ((macsr & LINK_SPEED) == LINK_SPEED_5_0GTS) |
| 221 | goto done; |
| 222 | |
| 223 | /* Set target link speed to 5.0 GT/s */ |
| 224 | rcar_rmw32(pcie, EXPCAP(12), PCI_EXP_LNKSTA_CLS, |
| 225 | PCI_EXP_LNKSTA_CLS_5_0GB); |
| 226 | |
| 227 | /* Set speed change reason as intentional factor */ |
| 228 | rcar_rmw32(pcie, MACCGSPSETR, SPCNGRSN, 0); |
| 229 | |
| 230 | /* Clear SPCHGFIN, SPCHGSUC, and SPCHGFAIL */ |
| 231 | if (macsr & (SPCHGFIN | SPCHGSUC | SPCHGFAIL)) |
| 232 | rcar_pci_write_reg(pcie, macsr, MACSR); |
| 233 | |
| 234 | /* Start link speed change */ |
| 235 | rcar_rmw32(pcie, MACCTLR, SPEED_CHANGE, SPEED_CHANGE); |
| 236 | |
| 237 | while (timeout--) { |
| 238 | macsr = rcar_pci_read_reg(pcie, MACSR); |
| 239 | if (macsr & SPCHGFIN) { |
| 240 | /* Clear the interrupt bits */ |
| 241 | rcar_pci_write_reg(pcie, macsr, MACSR); |
| 242 | |
| 243 | if (macsr & SPCHGFAIL) |
Bjorn Helgaas | 4ef80d7 | 2016-10-10 14:31:28 -0500 | [diff] [blame] | 244 | dev_err(dev, "Speed change failed\n"); |
Sergei Shtylyov | b3327f7 | 2016-09-22 23:20:18 +0300 | [diff] [blame] | 245 | |
| 246 | goto done; |
| 247 | } |
| 248 | |
| 249 | msleep(1); |
Fengguang Wu | d170867 | 2018-03-07 09:42:39 -0600 | [diff] [blame] | 250 | } |
Sergei Shtylyov | b3327f7 | 2016-09-22 23:20:18 +0300 | [diff] [blame] | 251 | |
Bjorn Helgaas | 4ef80d7 | 2016-10-10 14:31:28 -0500 | [diff] [blame] | 252 | dev_err(dev, "Speed change timed out\n"); |
Sergei Shtylyov | b3327f7 | 2016-09-22 23:20:18 +0300 | [diff] [blame] | 253 | |
| 254 | done: |
Bjorn Helgaas | 4ef80d7 | 2016-10-10 14:31:28 -0500 | [diff] [blame] | 255 | dev_info(dev, "Current link speed is %s GT/s\n", |
Sergei Shtylyov | b3327f7 | 2016-09-22 23:20:18 +0300 | [diff] [blame] | 256 | (macsr & LINK_SPEED) == LINK_SPEED_5_0GTS ? "5" : "2.5"); |
| 257 | } |
| 258 | |
Lad Prabhakar | 78a0d7f | 2020-05-07 13:33:13 +0100 | [diff] [blame] | 259 | static void rcar_pcie_hw_enable(struct rcar_pcie_host *host) |
Kazufumi Ikeda | ce35163 | 2020-03-14 20:12:32 +0100 | [diff] [blame] | 260 | { |
Lad Prabhakar | 78a0d7f | 2020-05-07 13:33:13 +0100 | [diff] [blame] | 261 | struct rcar_pcie *pcie = &host->pcie; |
Rob Herring | b411b2e | 2020-07-21 20:25:10 -0600 | [diff] [blame^] | 262 | struct pci_host_bridge *bridge = pci_host_bridge_from_priv(host); |
Kazufumi Ikeda | ce35163 | 2020-03-14 20:12:32 +0100 | [diff] [blame] | 263 | struct resource_entry *win; |
| 264 | LIST_HEAD(res); |
| 265 | int i = 0; |
| 266 | |
| 267 | /* Try setting 5 GT/s link speed */ |
Lad Prabhakar | 78a0d7f | 2020-05-07 13:33:13 +0100 | [diff] [blame] | 268 | rcar_pcie_force_speedup(pcie); |
Kazufumi Ikeda | ce35163 | 2020-03-14 20:12:32 +0100 | [diff] [blame] | 269 | |
| 270 | /* Setup PCI resources */ |
Rob Herring | b411b2e | 2020-07-21 20:25:10 -0600 | [diff] [blame^] | 271 | resource_list_for_each_entry(win, &bridge->windows) { |
Kazufumi Ikeda | ce35163 | 2020-03-14 20:12:32 +0100 | [diff] [blame] | 272 | struct resource *res = win->res; |
| 273 | |
| 274 | if (!res->flags) |
| 275 | continue; |
| 276 | |
| 277 | switch (resource_type(res)) { |
| 278 | case IORESOURCE_IO: |
| 279 | case IORESOURCE_MEM: |
Lad Prabhakar | 78a0d7f | 2020-05-07 13:33:13 +0100 | [diff] [blame] | 280 | rcar_pcie_set_outbound(pcie, i, win); |
Kazufumi Ikeda | ce35163 | 2020-03-14 20:12:32 +0100 | [diff] [blame] | 281 | i++; |
| 282 | break; |
| 283 | } |
| 284 | } |
| 285 | } |
| 286 | |
Lad Prabhakar | 78a0d7f | 2020-05-07 13:33:13 +0100 | [diff] [blame] | 287 | static int rcar_pcie_enable(struct rcar_pcie_host *host) |
Phil Edworthy | c25da47 | 2014-05-12 11:57:48 +0100 | [diff] [blame] | 288 | { |
Lad Prabhakar | 78a0d7f | 2020-05-07 13:33:13 +0100 | [diff] [blame] | 289 | struct pci_host_bridge *bridge = pci_host_bridge_from_priv(host); |
Phil Edworthy | c25da47 | 2014-05-12 11:57:48 +0100 | [diff] [blame] | 290 | |
Rob Herring | b411b2e | 2020-07-21 20:25:10 -0600 | [diff] [blame^] | 291 | rcar_pcie_hw_enable(host); |
Phil Edworthy | c25da47 | 2014-05-12 11:57:48 +0100 | [diff] [blame] | 292 | |
Bjorn Helgaas | 7153884 | 2017-11-30 11:21:57 -0600 | [diff] [blame] | 293 | pci_add_flags(PCI_REASSIGN_ALL_BUS); |
Phil Edworthy | 79953dd | 2015-10-02 11:25:05 +0100 | [diff] [blame] | 294 | |
Lad Prabhakar | 78a0d7f | 2020-05-07 13:33:13 +0100 | [diff] [blame] | 295 | bridge->sysdata = host; |
Lorenzo Pieralisi | 90634e8 | 2017-06-28 15:13:57 -0500 | [diff] [blame] | 296 | bridge->ops = &rcar_pcie_ops; |
Lorenzo Pieralisi | 29db991 | 2017-06-28 15:14:06 -0500 | [diff] [blame] | 297 | bridge->map_irq = of_irq_parse_and_map_pci; |
| 298 | bridge->swizzle_irq = pci_common_swizzle; |
Phil Edworthy | 79953dd | 2015-10-02 11:25:05 +0100 | [diff] [blame] | 299 | if (IS_ENABLED(CONFIG_PCI_MSI)) |
Lad Prabhakar | 78a0d7f | 2020-05-07 13:33:13 +0100 | [diff] [blame] | 300 | bridge->msi = &host->msi.chip; |
Phil Edworthy | 79953dd | 2015-10-02 11:25:05 +0100 | [diff] [blame] | 301 | |
Rob Herring | 56d2923 | 2020-05-22 17:48:29 -0600 | [diff] [blame] | 302 | return pci_host_probe(bridge); |
Phil Edworthy | c25da47 | 2014-05-12 11:57:48 +0100 | [diff] [blame] | 303 | } |
| 304 | |
| 305 | static int phy_wait_for_ack(struct rcar_pcie *pcie) |
| 306 | { |
Bjorn Helgaas | 4ef80d7 | 2016-10-10 14:31:28 -0500 | [diff] [blame] | 307 | struct device *dev = pcie->dev; |
Phil Edworthy | c25da47 | 2014-05-12 11:57:48 +0100 | [diff] [blame] | 308 | unsigned int timeout = 100; |
| 309 | |
| 310 | while (timeout--) { |
Phil Edworthy | b7718849 | 2014-06-30 08:54:23 +0100 | [diff] [blame] | 311 | if (rcar_pci_read_reg(pcie, H1_PCIEPHYADRR) & PHY_ACK) |
Phil Edworthy | c25da47 | 2014-05-12 11:57:48 +0100 | [diff] [blame] | 312 | return 0; |
| 313 | |
| 314 | udelay(100); |
| 315 | } |
| 316 | |
Bjorn Helgaas | 4ef80d7 | 2016-10-10 14:31:28 -0500 | [diff] [blame] | 317 | dev_err(dev, "Access to PCIe phy timed out\n"); |
Phil Edworthy | c25da47 | 2014-05-12 11:57:48 +0100 | [diff] [blame] | 318 | |
| 319 | return -ETIMEDOUT; |
| 320 | } |
| 321 | |
| 322 | static void phy_write_reg(struct rcar_pcie *pcie, |
Marek Vasut | d8fa266 | 2019-03-25 12:40:58 +0100 | [diff] [blame] | 323 | unsigned int rate, u32 addr, |
| 324 | unsigned int lane, u32 data) |
Phil Edworthy | c25da47 | 2014-05-12 11:57:48 +0100 | [diff] [blame] | 325 | { |
Marek Vasut | d8fa266 | 2019-03-25 12:40:58 +0100 | [diff] [blame] | 326 | u32 phyaddr; |
Phil Edworthy | c25da47 | 2014-05-12 11:57:48 +0100 | [diff] [blame] | 327 | |
| 328 | phyaddr = WRITE_CMD | |
| 329 | ((rate & 1) << RATE_POS) | |
| 330 | ((lane & 0xf) << LANE_POS) | |
| 331 | ((addr & 0xff) << ADR_POS); |
| 332 | |
| 333 | /* Set write data */ |
Phil Edworthy | b7718849 | 2014-06-30 08:54:23 +0100 | [diff] [blame] | 334 | rcar_pci_write_reg(pcie, data, H1_PCIEPHYDOUTR); |
| 335 | rcar_pci_write_reg(pcie, phyaddr, H1_PCIEPHYADRR); |
Phil Edworthy | c25da47 | 2014-05-12 11:57:48 +0100 | [diff] [blame] | 336 | |
| 337 | /* Ignore errors as they will be dealt with if the data link is down */ |
| 338 | phy_wait_for_ack(pcie); |
| 339 | |
| 340 | /* Clear command */ |
Phil Edworthy | b7718849 | 2014-06-30 08:54:23 +0100 | [diff] [blame] | 341 | rcar_pci_write_reg(pcie, 0, H1_PCIEPHYDOUTR); |
| 342 | rcar_pci_write_reg(pcie, 0, H1_PCIEPHYADRR); |
Phil Edworthy | c25da47 | 2014-05-12 11:57:48 +0100 | [diff] [blame] | 343 | |
| 344 | /* Ignore errors as they will be dealt with if the data link is down */ |
| 345 | phy_wait_for_ack(pcie); |
| 346 | } |
| 347 | |
Phil Edworthy | c25da47 | 2014-05-12 11:57:48 +0100 | [diff] [blame] | 348 | static int rcar_pcie_hw_init(struct rcar_pcie *pcie) |
| 349 | { |
| 350 | int err; |
| 351 | |
| 352 | /* Begin initialization */ |
Phil Edworthy | b7718849 | 2014-06-30 08:54:23 +0100 | [diff] [blame] | 353 | rcar_pci_write_reg(pcie, 0, PCIETCTLR); |
Phil Edworthy | c25da47 | 2014-05-12 11:57:48 +0100 | [diff] [blame] | 354 | |
| 355 | /* Set mode */ |
Phil Edworthy | b7718849 | 2014-06-30 08:54:23 +0100 | [diff] [blame] | 356 | rcar_pci_write_reg(pcie, 1, PCIEMSR); |
Phil Edworthy | c25da47 | 2014-05-12 11:57:48 +0100 | [diff] [blame] | 357 | |
Sergei Shtylyov | 3ad1d32 | 2018-05-03 22:36:37 +0300 | [diff] [blame] | 358 | err = rcar_pcie_wait_for_phyrdy(pcie); |
| 359 | if (err) |
| 360 | return err; |
| 361 | |
Phil Edworthy | c25da47 | 2014-05-12 11:57:48 +0100 | [diff] [blame] | 362 | /* |
| 363 | * Initial header for port config space is type 1, set the device |
| 364 | * class to match. Hardware takes care of propagating the IDSETR |
| 365 | * settings, so there is no need to bother with a quirk. |
| 366 | */ |
Phil Edworthy | b7718849 | 2014-06-30 08:54:23 +0100 | [diff] [blame] | 367 | rcar_pci_write_reg(pcie, PCI_CLASS_BRIDGE_PCI << 16, IDSETR1); |
Phil Edworthy | c25da47 | 2014-05-12 11:57:48 +0100 | [diff] [blame] | 368 | |
| 369 | /* |
| 370 | * Setup Secondary Bus Number & Subordinate Bus Number, even though |
| 371 | * they aren't used, to avoid bridge being detected as broken. |
| 372 | */ |
| 373 | rcar_rmw32(pcie, RCONF(PCI_SECONDARY_BUS), 0xff, 1); |
| 374 | rcar_rmw32(pcie, RCONF(PCI_SUBORDINATE_BUS), 0xff, 1); |
| 375 | |
| 376 | /* Initialize default capabilities. */ |
Phil Edworthy | 2c3fd4c | 2014-06-30 08:54:22 +0100 | [diff] [blame] | 377 | rcar_rmw32(pcie, REXPCAP(0), 0xff, PCI_CAP_ID_EXP); |
Phil Edworthy | c25da47 | 2014-05-12 11:57:48 +0100 | [diff] [blame] | 378 | rcar_rmw32(pcie, REXPCAP(PCI_EXP_FLAGS), |
| 379 | PCI_EXP_FLAGS_TYPE, PCI_EXP_TYPE_ROOT_PORT << 4); |
| 380 | rcar_rmw32(pcie, RCONF(PCI_HEADER_TYPE), 0x7f, |
| 381 | PCI_HEADER_TYPE_BRIDGE); |
| 382 | |
| 383 | /* Enable data link layer active state reporting */ |
Phil Edworthy | 2c3fd4c | 2014-06-30 08:54:22 +0100 | [diff] [blame] | 384 | rcar_rmw32(pcie, REXPCAP(PCI_EXP_LNKCAP), PCI_EXP_LNKCAP_DLLLARC, |
| 385 | PCI_EXP_LNKCAP_DLLLARC); |
Phil Edworthy | c25da47 | 2014-05-12 11:57:48 +0100 | [diff] [blame] | 386 | |
| 387 | /* Write out the physical slot number = 0 */ |
| 388 | rcar_rmw32(pcie, REXPCAP(PCI_EXP_SLTCAP), PCI_EXP_SLTCAP_PSN, 0); |
| 389 | |
| 390 | /* Set the completion timer timeout to the maximum 50ms. */ |
Phil Edworthy | b7718849 | 2014-06-30 08:54:23 +0100 | [diff] [blame] | 391 | rcar_rmw32(pcie, TLCTLR + 1, 0x3f, 50); |
Phil Edworthy | c25da47 | 2014-05-12 11:57:48 +0100 | [diff] [blame] | 392 | |
| 393 | /* Terminate list of capabilities (Next Capability Offset=0) */ |
Phil Edworthy | 2c3fd4c | 2014-06-30 08:54:22 +0100 | [diff] [blame] | 394 | rcar_rmw32(pcie, RVCCAP(0), 0xfff00000, 0); |
Phil Edworthy | c25da47 | 2014-05-12 11:57:48 +0100 | [diff] [blame] | 395 | |
Phil Edworthy | 290c1fb | 2014-05-12 11:57:49 +0100 | [diff] [blame] | 396 | /* Enable MSI */ |
| 397 | if (IS_ENABLED(CONFIG_PCI_MSI)) |
Nobuhiro Iwamatsu | 1fc6aa9 | 2015-02-02 14:09:39 +0900 | [diff] [blame] | 398 | rcar_pci_write_reg(pcie, 0x801f0000, PCIEMSITXR); |
Phil Edworthy | 290c1fb | 2014-05-12 11:57:49 +0100 | [diff] [blame] | 399 | |
Yoshihiro Shimoda | 7c7e53e | 2019-11-05 19:51:29 +0900 | [diff] [blame] | 400 | rcar_pci_write_reg(pcie, MACCTLR_INIT_VAL, MACCTLR); |
| 401 | |
Phil Edworthy | c25da47 | 2014-05-12 11:57:48 +0100 | [diff] [blame] | 402 | /* Finish initialization - establish a PCI Express link */ |
Phil Edworthy | b7718849 | 2014-06-30 08:54:23 +0100 | [diff] [blame] | 403 | rcar_pci_write_reg(pcie, CFINIT, PCIETCTLR); |
Phil Edworthy | c25da47 | 2014-05-12 11:57:48 +0100 | [diff] [blame] | 404 | |
| 405 | /* This will timeout if we don't have a link. */ |
| 406 | err = rcar_pcie_wait_for_dl(pcie); |
| 407 | if (err) |
| 408 | return err; |
| 409 | |
| 410 | /* Enable INTx interrupts */ |
| 411 | rcar_rmw32(pcie, PCIEINTXR, 0, 0xF << 8); |
| 412 | |
Phil Edworthy | c25da47 | 2014-05-12 11:57:48 +0100 | [diff] [blame] | 413 | wmb(); |
| 414 | |
| 415 | return 0; |
| 416 | } |
| 417 | |
Lad Prabhakar | 78a0d7f | 2020-05-07 13:33:13 +0100 | [diff] [blame] | 418 | static int rcar_pcie_phy_init_h1(struct rcar_pcie_host *host) |
Phil Edworthy | c25da47 | 2014-05-12 11:57:48 +0100 | [diff] [blame] | 419 | { |
Lad Prabhakar | 78a0d7f | 2020-05-07 13:33:13 +0100 | [diff] [blame] | 420 | struct rcar_pcie *pcie = &host->pcie; |
| 421 | |
Phil Edworthy | c25da47 | 2014-05-12 11:57:48 +0100 | [diff] [blame] | 422 | /* Initialize the phy */ |
| 423 | phy_write_reg(pcie, 0, 0x42, 0x1, 0x0EC34191); |
| 424 | phy_write_reg(pcie, 1, 0x42, 0x1, 0x0EC34180); |
| 425 | phy_write_reg(pcie, 0, 0x43, 0x1, 0x00210188); |
| 426 | phy_write_reg(pcie, 1, 0x43, 0x1, 0x00210188); |
| 427 | phy_write_reg(pcie, 0, 0x44, 0x1, 0x015C0014); |
| 428 | phy_write_reg(pcie, 1, 0x44, 0x1, 0x015C0014); |
| 429 | phy_write_reg(pcie, 1, 0x4C, 0x1, 0x786174A0); |
| 430 | phy_write_reg(pcie, 1, 0x4D, 0x1, 0x048000BB); |
| 431 | phy_write_reg(pcie, 0, 0x51, 0x1, 0x079EC062); |
| 432 | phy_write_reg(pcie, 0, 0x52, 0x1, 0x20000000); |
| 433 | phy_write_reg(pcie, 1, 0x52, 0x1, 0x20000000); |
| 434 | phy_write_reg(pcie, 1, 0x56, 0x1, 0x00003806); |
| 435 | |
| 436 | phy_write_reg(pcie, 0, 0x60, 0x1, 0x004B03A5); |
| 437 | phy_write_reg(pcie, 0, 0x64, 0x1, 0x3F0F1F0F); |
| 438 | phy_write_reg(pcie, 0, 0x66, 0x1, 0x00008000); |
| 439 | |
Sergei Shtylyov | 9d5014e | 2018-05-03 22:43:13 +0300 | [diff] [blame] | 440 | return 0; |
Phil Edworthy | c25da47 | 2014-05-12 11:57:48 +0100 | [diff] [blame] | 441 | } |
| 442 | |
Lad Prabhakar | 78a0d7f | 2020-05-07 13:33:13 +0100 | [diff] [blame] | 443 | static int rcar_pcie_phy_init_gen2(struct rcar_pcie_host *host) |
Phil Edworthy | 581d943 | 2016-01-05 13:00:31 +0000 | [diff] [blame] | 444 | { |
Lad Prabhakar | 78a0d7f | 2020-05-07 13:33:13 +0100 | [diff] [blame] | 445 | struct rcar_pcie *pcie = &host->pcie; |
| 446 | |
Phil Edworthy | 581d943 | 2016-01-05 13:00:31 +0000 | [diff] [blame] | 447 | /* |
| 448 | * These settings come from the R-Car Series, 2nd Generation User's |
| 449 | * Manual, section 50.3.1 (2) Initialization of the physical layer. |
| 450 | */ |
| 451 | rcar_pci_write_reg(pcie, 0x000f0030, GEN2_PCIEPHYADDR); |
| 452 | rcar_pci_write_reg(pcie, 0x00381203, GEN2_PCIEPHYDATA); |
| 453 | rcar_pci_write_reg(pcie, 0x00000001, GEN2_PCIEPHYCTRL); |
| 454 | rcar_pci_write_reg(pcie, 0x00000006, GEN2_PCIEPHYCTRL); |
| 455 | |
| 456 | rcar_pci_write_reg(pcie, 0x000f0054, GEN2_PCIEPHYADDR); |
| 457 | /* The following value is for DC connection, no termination resistor */ |
| 458 | rcar_pci_write_reg(pcie, 0x13802007, GEN2_PCIEPHYDATA); |
| 459 | rcar_pci_write_reg(pcie, 0x00000001, GEN2_PCIEPHYCTRL); |
| 460 | rcar_pci_write_reg(pcie, 0x00000006, GEN2_PCIEPHYCTRL); |
| 461 | |
Sergei Shtylyov | 9d5014e | 2018-05-03 22:43:13 +0300 | [diff] [blame] | 462 | return 0; |
Phil Edworthy | 581d943 | 2016-01-05 13:00:31 +0000 | [diff] [blame] | 463 | } |
| 464 | |
Lad Prabhakar | 78a0d7f | 2020-05-07 13:33:13 +0100 | [diff] [blame] | 465 | static int rcar_pcie_phy_init_gen3(struct rcar_pcie_host *host) |
Sergei Shtylyov | 517ca93 | 2018-05-03 22:40:54 +0300 | [diff] [blame] | 466 | { |
| 467 | int err; |
| 468 | |
Lad Prabhakar | 78a0d7f | 2020-05-07 13:33:13 +0100 | [diff] [blame] | 469 | err = phy_init(host->phy); |
Sergei Shtylyov | 517ca93 | 2018-05-03 22:40:54 +0300 | [diff] [blame] | 470 | if (err) |
| 471 | return err; |
| 472 | |
Lad Prabhakar | 78a0d7f | 2020-05-07 13:33:13 +0100 | [diff] [blame] | 473 | err = phy_power_on(host->phy); |
Marek Vasut | 3c5777c | 2018-06-29 13:48:15 -0500 | [diff] [blame] | 474 | if (err) |
Lad Prabhakar | 78a0d7f | 2020-05-07 13:33:13 +0100 | [diff] [blame] | 475 | phy_exit(host->phy); |
Marek Vasut | 3c5777c | 2018-06-29 13:48:15 -0500 | [diff] [blame] | 476 | |
| 477 | return err; |
Phil Edworthy | c25da47 | 2014-05-12 11:57:48 +0100 | [diff] [blame] | 478 | } |
| 479 | |
Phil Edworthy | 290c1fb | 2014-05-12 11:57:49 +0100 | [diff] [blame] | 480 | static int rcar_msi_alloc(struct rcar_msi *chip) |
| 481 | { |
| 482 | int msi; |
| 483 | |
| 484 | mutex_lock(&chip->lock); |
| 485 | |
| 486 | msi = find_first_zero_bit(chip->used, INT_PCI_MSI_NR); |
| 487 | if (msi < INT_PCI_MSI_NR) |
| 488 | set_bit(msi, chip->used); |
| 489 | else |
| 490 | msi = -ENOSPC; |
| 491 | |
| 492 | mutex_unlock(&chip->lock); |
| 493 | |
| 494 | return msi; |
| 495 | } |
| 496 | |
Grigory Kletsko | e3123c2 | 2016-09-08 22:32:59 +0300 | [diff] [blame] | 497 | static int rcar_msi_alloc_region(struct rcar_msi *chip, int no_irqs) |
| 498 | { |
| 499 | int msi; |
| 500 | |
| 501 | mutex_lock(&chip->lock); |
| 502 | msi = bitmap_find_free_region(chip->used, INT_PCI_MSI_NR, |
| 503 | order_base_2(no_irqs)); |
| 504 | mutex_unlock(&chip->lock); |
| 505 | |
| 506 | return msi; |
| 507 | } |
| 508 | |
Phil Edworthy | 290c1fb | 2014-05-12 11:57:49 +0100 | [diff] [blame] | 509 | static void rcar_msi_free(struct rcar_msi *chip, unsigned long irq) |
| 510 | { |
| 511 | mutex_lock(&chip->lock); |
| 512 | clear_bit(irq, chip->used); |
| 513 | mutex_unlock(&chip->lock); |
| 514 | } |
| 515 | |
| 516 | static irqreturn_t rcar_pcie_msi_irq(int irq, void *data) |
| 517 | { |
Lad Prabhakar | 78a0d7f | 2020-05-07 13:33:13 +0100 | [diff] [blame] | 518 | struct rcar_pcie_host *host = data; |
| 519 | struct rcar_pcie *pcie = &host->pcie; |
| 520 | struct rcar_msi *msi = &host->msi; |
Bjorn Helgaas | 4ef80d7 | 2016-10-10 14:31:28 -0500 | [diff] [blame] | 521 | struct device *dev = pcie->dev; |
Phil Edworthy | 290c1fb | 2014-05-12 11:57:49 +0100 | [diff] [blame] | 522 | unsigned long reg; |
| 523 | |
Phil Edworthy | b7718849 | 2014-06-30 08:54:23 +0100 | [diff] [blame] | 524 | reg = rcar_pci_read_reg(pcie, PCIEMSIFR); |
Phil Edworthy | 290c1fb | 2014-05-12 11:57:49 +0100 | [diff] [blame] | 525 | |
| 526 | /* MSI & INTx share an interrupt - we only handle MSI here */ |
| 527 | if (!reg) |
| 528 | return IRQ_NONE; |
| 529 | |
| 530 | while (reg) { |
| 531 | unsigned int index = find_first_bit(®, 32); |
Wolfram Sang | a27beb5 | 2019-03-17 10:34:45 +0100 | [diff] [blame] | 532 | unsigned int msi_irq; |
Phil Edworthy | 290c1fb | 2014-05-12 11:57:49 +0100 | [diff] [blame] | 533 | |
| 534 | /* clear the interrupt */ |
Phil Edworthy | b7718849 | 2014-06-30 08:54:23 +0100 | [diff] [blame] | 535 | rcar_pci_write_reg(pcie, 1 << index, PCIEMSIFR); |
Phil Edworthy | 290c1fb | 2014-05-12 11:57:49 +0100 | [diff] [blame] | 536 | |
Wolfram Sang | a27beb5 | 2019-03-17 10:34:45 +0100 | [diff] [blame] | 537 | msi_irq = irq_find_mapping(msi->domain, index); |
| 538 | if (msi_irq) { |
Phil Edworthy | 290c1fb | 2014-05-12 11:57:49 +0100 | [diff] [blame] | 539 | if (test_bit(index, msi->used)) |
Wolfram Sang | a27beb5 | 2019-03-17 10:34:45 +0100 | [diff] [blame] | 540 | generic_handle_irq(msi_irq); |
Phil Edworthy | 290c1fb | 2014-05-12 11:57:49 +0100 | [diff] [blame] | 541 | else |
Bjorn Helgaas | 4ef80d7 | 2016-10-10 14:31:28 -0500 | [diff] [blame] | 542 | dev_info(dev, "unhandled MSI\n"); |
Phil Edworthy | 290c1fb | 2014-05-12 11:57:49 +0100 | [diff] [blame] | 543 | } else { |
| 544 | /* Unknown MSI, just clear it */ |
Bjorn Helgaas | 4ef80d7 | 2016-10-10 14:31:28 -0500 | [diff] [blame] | 545 | dev_dbg(dev, "unexpected MSI\n"); |
Phil Edworthy | 290c1fb | 2014-05-12 11:57:49 +0100 | [diff] [blame] | 546 | } |
| 547 | |
| 548 | /* see if there's any more pending in this vector */ |
Phil Edworthy | b7718849 | 2014-06-30 08:54:23 +0100 | [diff] [blame] | 549 | reg = rcar_pci_read_reg(pcie, PCIEMSIFR); |
Phil Edworthy | 290c1fb | 2014-05-12 11:57:49 +0100 | [diff] [blame] | 550 | } |
| 551 | |
| 552 | return IRQ_HANDLED; |
| 553 | } |
| 554 | |
Yijing Wang | c2791b8 | 2014-11-11 17:45:45 -0700 | [diff] [blame] | 555 | static int rcar_msi_setup_irq(struct msi_controller *chip, struct pci_dev *pdev, |
Phil Edworthy | 290c1fb | 2014-05-12 11:57:49 +0100 | [diff] [blame] | 556 | struct msi_desc *desc) |
| 557 | { |
| 558 | struct rcar_msi *msi = to_rcar_msi(chip); |
Lad Prabhakar | 78a0d7f | 2020-05-07 13:33:13 +0100 | [diff] [blame] | 559 | struct rcar_pcie_host *host = container_of(chip, struct rcar_pcie_host, |
| 560 | msi.chip); |
| 561 | struct rcar_pcie *pcie = &host->pcie; |
Phil Edworthy | 290c1fb | 2014-05-12 11:57:49 +0100 | [diff] [blame] | 562 | struct msi_msg msg; |
| 563 | unsigned int irq; |
| 564 | int hwirq; |
| 565 | |
| 566 | hwirq = rcar_msi_alloc(msi); |
| 567 | if (hwirq < 0) |
| 568 | return hwirq; |
| 569 | |
Grigory Kletsko | e3123c2 | 2016-09-08 22:32:59 +0300 | [diff] [blame] | 570 | irq = irq_find_mapping(msi->domain, hwirq); |
Phil Edworthy | 290c1fb | 2014-05-12 11:57:49 +0100 | [diff] [blame] | 571 | if (!irq) { |
| 572 | rcar_msi_free(msi, hwirq); |
| 573 | return -EINVAL; |
| 574 | } |
| 575 | |
| 576 | irq_set_msi_desc(irq, desc); |
| 577 | |
Phil Edworthy | b7718849 | 2014-06-30 08:54:23 +0100 | [diff] [blame] | 578 | msg.address_lo = rcar_pci_read_reg(pcie, PCIEMSIALR) & ~MSIFE; |
| 579 | msg.address_hi = rcar_pci_read_reg(pcie, PCIEMSIAUR); |
Phil Edworthy | 290c1fb | 2014-05-12 11:57:49 +0100 | [diff] [blame] | 580 | msg.data = hwirq; |
| 581 | |
Jiang Liu | 83a1891 | 2014-11-09 23:10:34 +0800 | [diff] [blame] | 582 | pci_write_msi_msg(irq, &msg); |
Phil Edworthy | 290c1fb | 2014-05-12 11:57:49 +0100 | [diff] [blame] | 583 | |
| 584 | return 0; |
| 585 | } |
| 586 | |
Grigory Kletsko | e3123c2 | 2016-09-08 22:32:59 +0300 | [diff] [blame] | 587 | static int rcar_msi_setup_irqs(struct msi_controller *chip, |
| 588 | struct pci_dev *pdev, int nvec, int type) |
| 589 | { |
Grigory Kletsko | e3123c2 | 2016-09-08 22:32:59 +0300 | [diff] [blame] | 590 | struct rcar_msi *msi = to_rcar_msi(chip); |
Lad Prabhakar | 78a0d7f | 2020-05-07 13:33:13 +0100 | [diff] [blame] | 591 | struct rcar_pcie_host *host = container_of(chip, struct rcar_pcie_host, |
| 592 | msi.chip); |
| 593 | struct rcar_pcie *pcie = &host->pcie; |
Grigory Kletsko | e3123c2 | 2016-09-08 22:32:59 +0300 | [diff] [blame] | 594 | struct msi_desc *desc; |
| 595 | struct msi_msg msg; |
| 596 | unsigned int irq; |
| 597 | int hwirq; |
| 598 | int i; |
| 599 | |
| 600 | /* MSI-X interrupts are not supported */ |
| 601 | if (type == PCI_CAP_ID_MSIX) |
| 602 | return -EINVAL; |
| 603 | |
| 604 | WARN_ON(!list_is_singular(&pdev->dev.msi_list)); |
| 605 | desc = list_entry(pdev->dev.msi_list.next, struct msi_desc, list); |
| 606 | |
| 607 | hwirq = rcar_msi_alloc_region(msi, nvec); |
| 608 | if (hwirq < 0) |
| 609 | return -ENOSPC; |
| 610 | |
| 611 | irq = irq_find_mapping(msi->domain, hwirq); |
| 612 | if (!irq) |
| 613 | return -ENOSPC; |
| 614 | |
| 615 | for (i = 0; i < nvec; i++) { |
| 616 | /* |
| 617 | * irq_create_mapping() called from rcar_pcie_probe() pre- |
| 618 | * allocates descs, so there is no need to allocate descs here. |
| 619 | * We can therefore assume that if irq_find_mapping() above |
| 620 | * returns non-zero, then the descs are also successfully |
| 621 | * allocated. |
| 622 | */ |
| 623 | if (irq_set_msi_desc_off(irq, i, desc)) { |
| 624 | /* TODO: clear */ |
| 625 | return -EINVAL; |
| 626 | } |
| 627 | } |
| 628 | |
| 629 | desc->nvec_used = nvec; |
| 630 | desc->msi_attrib.multiple = order_base_2(nvec); |
| 631 | |
| 632 | msg.address_lo = rcar_pci_read_reg(pcie, PCIEMSIALR) & ~MSIFE; |
| 633 | msg.address_hi = rcar_pci_read_reg(pcie, PCIEMSIAUR); |
| 634 | msg.data = hwirq; |
| 635 | |
| 636 | pci_write_msi_msg(irq, &msg); |
| 637 | |
| 638 | return 0; |
| 639 | } |
| 640 | |
Yijing Wang | c2791b8 | 2014-11-11 17:45:45 -0700 | [diff] [blame] | 641 | static void rcar_msi_teardown_irq(struct msi_controller *chip, unsigned int irq) |
Phil Edworthy | 290c1fb | 2014-05-12 11:57:49 +0100 | [diff] [blame] | 642 | { |
| 643 | struct rcar_msi *msi = to_rcar_msi(chip); |
| 644 | struct irq_data *d = irq_get_irq_data(irq); |
| 645 | |
| 646 | rcar_msi_free(msi, d->hwirq); |
| 647 | } |
| 648 | |
| 649 | static struct irq_chip rcar_msi_irq_chip = { |
| 650 | .name = "R-Car PCIe MSI", |
Thomas Gleixner | 280510f | 2014-11-23 12:23:20 +0100 | [diff] [blame] | 651 | .irq_enable = pci_msi_unmask_irq, |
| 652 | .irq_disable = pci_msi_mask_irq, |
| 653 | .irq_mask = pci_msi_mask_irq, |
| 654 | .irq_unmask = pci_msi_unmask_irq, |
Phil Edworthy | 290c1fb | 2014-05-12 11:57:49 +0100 | [diff] [blame] | 655 | }; |
| 656 | |
| 657 | static int rcar_msi_map(struct irq_domain *domain, unsigned int irq, |
| 658 | irq_hw_number_t hwirq) |
| 659 | { |
| 660 | irq_set_chip_and_handler(irq, &rcar_msi_irq_chip, handle_simple_irq); |
| 661 | irq_set_chip_data(irq, domain->host_data); |
Phil Edworthy | 290c1fb | 2014-05-12 11:57:49 +0100 | [diff] [blame] | 662 | |
| 663 | return 0; |
| 664 | } |
| 665 | |
| 666 | static const struct irq_domain_ops msi_domain_ops = { |
| 667 | .map = rcar_msi_map, |
| 668 | }; |
| 669 | |
Lad Prabhakar | 78a0d7f | 2020-05-07 13:33:13 +0100 | [diff] [blame] | 670 | static void rcar_pcie_unmap_msi(struct rcar_pcie_host *host) |
Marek Vasut | 0bbf6b9 | 2018-05-24 16:36:23 +0200 | [diff] [blame] | 671 | { |
Lad Prabhakar | 78a0d7f | 2020-05-07 13:33:13 +0100 | [diff] [blame] | 672 | struct rcar_msi *msi = &host->msi; |
Marek Vasut | 0bbf6b9 | 2018-05-24 16:36:23 +0200 | [diff] [blame] | 673 | int i, irq; |
| 674 | |
| 675 | for (i = 0; i < INT_PCI_MSI_NR; i++) { |
| 676 | irq = irq_find_mapping(msi->domain, i); |
| 677 | if (irq > 0) |
| 678 | irq_dispose_mapping(irq); |
| 679 | } |
| 680 | |
| 681 | irq_domain_remove(msi->domain); |
| 682 | } |
| 683 | |
Lad Prabhakar | 78a0d7f | 2020-05-07 13:33:13 +0100 | [diff] [blame] | 684 | static void rcar_pcie_hw_enable_msi(struct rcar_pcie_host *host) |
Kazufumi Ikeda | ce35163 | 2020-03-14 20:12:32 +0100 | [diff] [blame] | 685 | { |
Lad Prabhakar | 78a0d7f | 2020-05-07 13:33:13 +0100 | [diff] [blame] | 686 | struct rcar_pcie *pcie = &host->pcie; |
| 687 | struct rcar_msi *msi = &host->msi; |
Kazufumi Ikeda | ce35163 | 2020-03-14 20:12:32 +0100 | [diff] [blame] | 688 | unsigned long base; |
| 689 | |
| 690 | /* setup MSI data target */ |
| 691 | base = virt_to_phys((void *)msi->pages); |
| 692 | |
| 693 | rcar_pci_write_reg(pcie, lower_32_bits(base) | MSIFE, PCIEMSIALR); |
| 694 | rcar_pci_write_reg(pcie, upper_32_bits(base), PCIEMSIAUR); |
| 695 | |
| 696 | /* enable all MSI interrupts */ |
| 697 | rcar_pci_write_reg(pcie, 0xffffffff, PCIEMSIIER); |
| 698 | } |
| 699 | |
Lad Prabhakar | 78a0d7f | 2020-05-07 13:33:13 +0100 | [diff] [blame] | 700 | static int rcar_pcie_enable_msi(struct rcar_pcie_host *host) |
Phil Edworthy | 290c1fb | 2014-05-12 11:57:49 +0100 | [diff] [blame] | 701 | { |
Lad Prabhakar | 78a0d7f | 2020-05-07 13:33:13 +0100 | [diff] [blame] | 702 | struct rcar_pcie *pcie = &host->pcie; |
Bjorn Helgaas | 4ef80d7 | 2016-10-10 14:31:28 -0500 | [diff] [blame] | 703 | struct device *dev = pcie->dev; |
Lad Prabhakar | 78a0d7f | 2020-05-07 13:33:13 +0100 | [diff] [blame] | 704 | struct rcar_msi *msi = &host->msi; |
Grigory Kletsko | e3123c2 | 2016-09-08 22:32:59 +0300 | [diff] [blame] | 705 | int err, i; |
Phil Edworthy | 290c1fb | 2014-05-12 11:57:49 +0100 | [diff] [blame] | 706 | |
| 707 | mutex_init(&msi->lock); |
| 708 | |
Bjorn Helgaas | 4ef80d7 | 2016-10-10 14:31:28 -0500 | [diff] [blame] | 709 | msi->chip.dev = dev; |
Phil Edworthy | 290c1fb | 2014-05-12 11:57:49 +0100 | [diff] [blame] | 710 | msi->chip.setup_irq = rcar_msi_setup_irq; |
Grigory Kletsko | e3123c2 | 2016-09-08 22:32:59 +0300 | [diff] [blame] | 711 | msi->chip.setup_irqs = rcar_msi_setup_irqs; |
Phil Edworthy | 290c1fb | 2014-05-12 11:57:49 +0100 | [diff] [blame] | 712 | msi->chip.teardown_irq = rcar_msi_teardown_irq; |
| 713 | |
Bjorn Helgaas | 4ef80d7 | 2016-10-10 14:31:28 -0500 | [diff] [blame] | 714 | msi->domain = irq_domain_add_linear(dev->of_node, INT_PCI_MSI_NR, |
Phil Edworthy | 290c1fb | 2014-05-12 11:57:49 +0100 | [diff] [blame] | 715 | &msi_domain_ops, &msi->chip); |
| 716 | if (!msi->domain) { |
Bjorn Helgaas | 4ef80d7 | 2016-10-10 14:31:28 -0500 | [diff] [blame] | 717 | dev_err(dev, "failed to create IRQ domain\n"); |
Phil Edworthy | 290c1fb | 2014-05-12 11:57:49 +0100 | [diff] [blame] | 718 | return -ENOMEM; |
| 719 | } |
| 720 | |
Grigory Kletsko | e3123c2 | 2016-09-08 22:32:59 +0300 | [diff] [blame] | 721 | for (i = 0; i < INT_PCI_MSI_NR; i++) |
| 722 | irq_create_mapping(msi->domain, i); |
| 723 | |
Phil Edworthy | 290c1fb | 2014-05-12 11:57:49 +0100 | [diff] [blame] | 724 | /* Two irqs are for MSI, but they are also used for non-MSI irqs */ |
Bjorn Helgaas | 4ef80d7 | 2016-10-10 14:31:28 -0500 | [diff] [blame] | 725 | err = devm_request_irq(dev, msi->irq1, rcar_pcie_msi_irq, |
Grygorii Strashko | 8ff0ef9 | 2015-12-10 21:18:20 +0200 | [diff] [blame] | 726 | IRQF_SHARED | IRQF_NO_THREAD, |
Lad Prabhakar | 78a0d7f | 2020-05-07 13:33:13 +0100 | [diff] [blame] | 727 | rcar_msi_irq_chip.name, host); |
Phil Edworthy | 290c1fb | 2014-05-12 11:57:49 +0100 | [diff] [blame] | 728 | if (err < 0) { |
Bjorn Helgaas | 4ef80d7 | 2016-10-10 14:31:28 -0500 | [diff] [blame] | 729 | dev_err(dev, "failed to request IRQ: %d\n", err); |
Phil Edworthy | 290c1fb | 2014-05-12 11:57:49 +0100 | [diff] [blame] | 730 | goto err; |
| 731 | } |
| 732 | |
Bjorn Helgaas | 4ef80d7 | 2016-10-10 14:31:28 -0500 | [diff] [blame] | 733 | err = devm_request_irq(dev, msi->irq2, rcar_pcie_msi_irq, |
Grygorii Strashko | 8ff0ef9 | 2015-12-10 21:18:20 +0200 | [diff] [blame] | 734 | IRQF_SHARED | IRQF_NO_THREAD, |
Lad Prabhakar | 78a0d7f | 2020-05-07 13:33:13 +0100 | [diff] [blame] | 735 | rcar_msi_irq_chip.name, host); |
Phil Edworthy | 290c1fb | 2014-05-12 11:57:49 +0100 | [diff] [blame] | 736 | if (err < 0) { |
Bjorn Helgaas | 4ef80d7 | 2016-10-10 14:31:28 -0500 | [diff] [blame] | 737 | dev_err(dev, "failed to request IRQ: %d\n", err); |
Phil Edworthy | 290c1fb | 2014-05-12 11:57:49 +0100 | [diff] [blame] | 738 | goto err; |
| 739 | } |
| 740 | |
| 741 | /* setup MSI data target */ |
| 742 | msi->pages = __get_free_pages(GFP_KERNEL, 0); |
Lad Prabhakar | 78a0d7f | 2020-05-07 13:33:13 +0100 | [diff] [blame] | 743 | rcar_pcie_hw_enable_msi(host); |
Phil Edworthy | 290c1fb | 2014-05-12 11:57:49 +0100 | [diff] [blame] | 744 | |
| 745 | return 0; |
| 746 | |
| 747 | err: |
Lad Prabhakar | 78a0d7f | 2020-05-07 13:33:13 +0100 | [diff] [blame] | 748 | rcar_pcie_unmap_msi(host); |
Phil Edworthy | 290c1fb | 2014-05-12 11:57:49 +0100 | [diff] [blame] | 749 | return err; |
| 750 | } |
| 751 | |
Lad Prabhakar | 78a0d7f | 2020-05-07 13:33:13 +0100 | [diff] [blame] | 752 | static void rcar_pcie_teardown_msi(struct rcar_pcie_host *host) |
Marek Vasut | 1aea58b | 2018-05-24 16:36:21 +0200 | [diff] [blame] | 753 | { |
Lad Prabhakar | 78a0d7f | 2020-05-07 13:33:13 +0100 | [diff] [blame] | 754 | struct rcar_pcie *pcie = &host->pcie; |
| 755 | struct rcar_msi *msi = &host->msi; |
Marek Vasut | 1aea58b | 2018-05-24 16:36:21 +0200 | [diff] [blame] | 756 | |
| 757 | /* Disable all MSI interrupts */ |
| 758 | rcar_pci_write_reg(pcie, 0, PCIEMSIIER); |
| 759 | |
| 760 | /* Disable address decoding of the MSI interrupt, MSIFE */ |
| 761 | rcar_pci_write_reg(pcie, 0, PCIEMSIALR); |
| 762 | |
| 763 | free_pages(msi->pages, 0); |
| 764 | |
Lad Prabhakar | 78a0d7f | 2020-05-07 13:33:13 +0100 | [diff] [blame] | 765 | rcar_pcie_unmap_msi(host); |
Marek Vasut | 1aea58b | 2018-05-24 16:36:21 +0200 | [diff] [blame] | 766 | } |
| 767 | |
Lad Prabhakar | 78a0d7f | 2020-05-07 13:33:13 +0100 | [diff] [blame] | 768 | static int rcar_pcie_get_resources(struct rcar_pcie_host *host) |
Phil Edworthy | c25da47 | 2014-05-12 11:57:48 +0100 | [diff] [blame] | 769 | { |
Lad Prabhakar | 78a0d7f | 2020-05-07 13:33:13 +0100 | [diff] [blame] | 770 | struct rcar_pcie *pcie = &host->pcie; |
Bjorn Helgaas | 4ef80d7 | 2016-10-10 14:31:28 -0500 | [diff] [blame] | 771 | struct device *dev = pcie->dev; |
Phil Edworthy | c25da47 | 2014-05-12 11:57:48 +0100 | [diff] [blame] | 772 | struct resource res; |
Phil Edworthy | 290c1fb | 2014-05-12 11:57:49 +0100 | [diff] [blame] | 773 | int err, i; |
Phil Edworthy | c25da47 | 2014-05-12 11:57:48 +0100 | [diff] [blame] | 774 | |
Lad Prabhakar | 78a0d7f | 2020-05-07 13:33:13 +0100 | [diff] [blame] | 775 | host->phy = devm_phy_optional_get(dev, "pcie"); |
| 776 | if (IS_ERR(host->phy)) |
| 777 | return PTR_ERR(host->phy); |
Sergei Shtylyov | 517ca93 | 2018-05-03 22:40:54 +0300 | [diff] [blame] | 778 | |
Bjorn Helgaas | 4ef80d7 | 2016-10-10 14:31:28 -0500 | [diff] [blame] | 779 | err = of_address_to_resource(dev->of_node, 0, &res); |
Phil Edworthy | c25da47 | 2014-05-12 11:57:48 +0100 | [diff] [blame] | 780 | if (err) |
| 781 | return err; |
| 782 | |
Bjorn Helgaas | 4ef80d7 | 2016-10-10 14:31:28 -0500 | [diff] [blame] | 783 | pcie->base = devm_ioremap_resource(dev, &res); |
Bjorn Helgaas | 51afa3c | 2016-08-22 14:16:38 -0500 | [diff] [blame] | 784 | if (IS_ERR(pcie->base)) |
| 785 | return PTR_ERR(pcie->base); |
| 786 | |
Lad Prabhakar | 78a0d7f | 2020-05-07 13:33:13 +0100 | [diff] [blame] | 787 | host->bus_clk = devm_clk_get(dev, "pcie_bus"); |
| 788 | if (IS_ERR(host->bus_clk)) { |
Bjorn Helgaas | 4ef80d7 | 2016-10-10 14:31:28 -0500 | [diff] [blame] | 789 | dev_err(dev, "cannot get pcie bus clock\n"); |
Lad Prabhakar | 78a0d7f | 2020-05-07 13:33:13 +0100 | [diff] [blame] | 790 | return PTR_ERR(host->bus_clk); |
Phil Edworthy | c25da47 | 2014-05-12 11:57:48 +0100 | [diff] [blame] | 791 | } |
Phil Edworthy | c25da47 | 2014-05-12 11:57:48 +0100 | [diff] [blame] | 792 | |
Bjorn Helgaas | 4ef80d7 | 2016-10-10 14:31:28 -0500 | [diff] [blame] | 793 | i = irq_of_parse_and_map(dev->of_node, 0); |
Dmitry Torokhov | c51d411 | 2014-11-14 14:21:53 -0800 | [diff] [blame] | 794 | if (!i) { |
Bjorn Helgaas | 4ef80d7 | 2016-10-10 14:31:28 -0500 | [diff] [blame] | 795 | dev_err(dev, "cannot get platform resources for msi interrupt\n"); |
Phil Edworthy | 290c1fb | 2014-05-12 11:57:49 +0100 | [diff] [blame] | 796 | err = -ENOENT; |
Marek Vasut | 53f1aeb | 2018-05-24 16:36:20 +0200 | [diff] [blame] | 797 | goto err_irq1; |
Phil Edworthy | 290c1fb | 2014-05-12 11:57:49 +0100 | [diff] [blame] | 798 | } |
Lad Prabhakar | 78a0d7f | 2020-05-07 13:33:13 +0100 | [diff] [blame] | 799 | host->msi.irq1 = i; |
Phil Edworthy | 290c1fb | 2014-05-12 11:57:49 +0100 | [diff] [blame] | 800 | |
Bjorn Helgaas | 4ef80d7 | 2016-10-10 14:31:28 -0500 | [diff] [blame] | 801 | i = irq_of_parse_and_map(dev->of_node, 1); |
Dmitry Torokhov | c51d411 | 2014-11-14 14:21:53 -0800 | [diff] [blame] | 802 | if (!i) { |
Bjorn Helgaas | 4ef80d7 | 2016-10-10 14:31:28 -0500 | [diff] [blame] | 803 | dev_err(dev, "cannot get platform resources for msi interrupt\n"); |
Phil Edworthy | 290c1fb | 2014-05-12 11:57:49 +0100 | [diff] [blame] | 804 | err = -ENOENT; |
Marek Vasut | 53f1aeb | 2018-05-24 16:36:20 +0200 | [diff] [blame] | 805 | goto err_irq2; |
Phil Edworthy | 290c1fb | 2014-05-12 11:57:49 +0100 | [diff] [blame] | 806 | } |
Lad Prabhakar | 78a0d7f | 2020-05-07 13:33:13 +0100 | [diff] [blame] | 807 | host->msi.irq2 = i; |
Phil Edworthy | 290c1fb | 2014-05-12 11:57:49 +0100 | [diff] [blame] | 808 | |
Phil Edworthy | c25da47 | 2014-05-12 11:57:48 +0100 | [diff] [blame] | 809 | return 0; |
| 810 | |
Marek Vasut | 53f1aeb | 2018-05-24 16:36:20 +0200 | [diff] [blame] | 811 | err_irq2: |
Lad Prabhakar | 78a0d7f | 2020-05-07 13:33:13 +0100 | [diff] [blame] | 812 | irq_dispose_mapping(host->msi.irq1); |
Marek Vasut | 53f1aeb | 2018-05-24 16:36:20 +0200 | [diff] [blame] | 813 | err_irq1: |
Phil Edworthy | c25da47 | 2014-05-12 11:57:48 +0100 | [diff] [blame] | 814 | return err; |
| 815 | } |
| 816 | |
| 817 | static int rcar_pcie_inbound_ranges(struct rcar_pcie *pcie, |
Rob Herring | 085f793 | 2019-10-28 11:32:55 -0500 | [diff] [blame] | 818 | struct resource_entry *entry, |
Phil Edworthy | c25da47 | 2014-05-12 11:57:48 +0100 | [diff] [blame] | 819 | int *index) |
| 820 | { |
Rob Herring | 085f793 | 2019-10-28 11:32:55 -0500 | [diff] [blame] | 821 | u64 restype = entry->res->flags; |
| 822 | u64 cpu_addr = entry->res->start; |
| 823 | u64 cpu_end = entry->res->end; |
| 824 | u64 pci_addr = entry->res->start - entry->offset; |
Phil Edworthy | c25da47 | 2014-05-12 11:57:48 +0100 | [diff] [blame] | 825 | u32 flags = LAM_64BIT | LAR_ENABLE; |
| 826 | u64 mask; |
Rob Herring | 085f793 | 2019-10-28 11:32:55 -0500 | [diff] [blame] | 827 | u64 size = resource_size(entry->res); |
Phil Edworthy | c25da47 | 2014-05-12 11:57:48 +0100 | [diff] [blame] | 828 | int idx = *index; |
| 829 | |
| 830 | if (restype & IORESOURCE_PREFETCH) |
| 831 | flags |= LAM_PREFETCH; |
| 832 | |
Phil Edworthy | c25da47 | 2014-05-12 11:57:48 +0100 | [diff] [blame] | 833 | while (cpu_addr < cpu_end) { |
Marek Vasut | 85bff4c | 2019-10-26 20:26:58 +0200 | [diff] [blame] | 834 | if (idx >= MAX_NR_INBOUND_MAPS - 1) { |
| 835 | dev_err(pcie->dev, "Failed to map inbound regions!\n"); |
| 836 | return -EINVAL; |
| 837 | } |
Phil Edworthy | c25da47 | 2014-05-12 11:57:48 +0100 | [diff] [blame] | 838 | /* |
Marek Vasut | 767c784 | 2019-10-26 20:26:59 +0200 | [diff] [blame] | 839 | * If the size of the range is larger than the alignment of |
| 840 | * the start address, we have to use multiple entries to |
| 841 | * perform the mapping. |
| 842 | */ |
| 843 | if (cpu_addr > 0) { |
| 844 | unsigned long nr_zeros = __ffs64(cpu_addr); |
| 845 | u64 alignment = 1ULL << nr_zeros; |
| 846 | |
Bjorn Helgaas | 7bd4c4a | 2019-11-28 08:54:53 -0600 | [diff] [blame] | 847 | size = min(size, alignment); |
Marek Vasut | 767c784 | 2019-10-26 20:26:59 +0200 | [diff] [blame] | 848 | } |
| 849 | /* Hardware supports max 4GiB inbound region */ |
| 850 | size = min(size, 1ULL << 32); |
| 851 | |
| 852 | mask = roundup_pow_of_two(size) - 1; |
| 853 | mask &= ~0xf; |
| 854 | |
Lad Prabhakar | 78a0d7f | 2020-05-07 13:33:13 +0100 | [diff] [blame] | 855 | rcar_pcie_set_inbound(pcie, cpu_addr, pci_addr, |
| 856 | lower_32_bits(mask) | flags, idx, true); |
Phil Edworthy | c25da47 | 2014-05-12 11:57:48 +0100 | [diff] [blame] | 857 | |
| 858 | pci_addr += size; |
| 859 | cpu_addr += size; |
| 860 | idx += 2; |
Phil Edworthy | c25da47 | 2014-05-12 11:57:48 +0100 | [diff] [blame] | 861 | } |
| 862 | *index = idx; |
| 863 | |
| 864 | return 0; |
| 865 | } |
| 866 | |
Lad Prabhakar | 78a0d7f | 2020-05-07 13:33:13 +0100 | [diff] [blame] | 867 | static int rcar_pcie_parse_map_dma_ranges(struct rcar_pcie_host *host) |
Phil Edworthy | c25da47 | 2014-05-12 11:57:48 +0100 | [diff] [blame] | 868 | { |
Lad Prabhakar | 78a0d7f | 2020-05-07 13:33:13 +0100 | [diff] [blame] | 869 | struct pci_host_bridge *bridge = pci_host_bridge_from_priv(host); |
Rob Herring | 085f793 | 2019-10-28 11:32:55 -0500 | [diff] [blame] | 870 | struct resource_entry *entry; |
| 871 | int index = 0, err = 0; |
Phil Edworthy | c25da47 | 2014-05-12 11:57:48 +0100 | [diff] [blame] | 872 | |
Rob Herring | 085f793 | 2019-10-28 11:32:55 -0500 | [diff] [blame] | 873 | resource_list_for_each_entry(entry, &bridge->dma_ranges) { |
Lad Prabhakar | 78a0d7f | 2020-05-07 13:33:13 +0100 | [diff] [blame] | 874 | err = rcar_pcie_inbound_ranges(&host->pcie, entry, &index); |
Phil Edworthy | c25da47 | 2014-05-12 11:57:48 +0100 | [diff] [blame] | 875 | if (err) |
Rob Herring | 085f793 | 2019-10-28 11:32:55 -0500 | [diff] [blame] | 876 | break; |
Phil Edworthy | c25da47 | 2014-05-12 11:57:48 +0100 | [diff] [blame] | 877 | } |
| 878 | |
Rob Herring | 085f793 | 2019-10-28 11:32:55 -0500 | [diff] [blame] | 879 | return err; |
Phil Edworthy | c25da47 | 2014-05-12 11:57:48 +0100 | [diff] [blame] | 880 | } |
| 881 | |
| 882 | static const struct of_device_id rcar_pcie_of_match[] = { |
Sergei Shtylyov | 9d5014e | 2018-05-03 22:43:13 +0300 | [diff] [blame] | 883 | { .compatible = "renesas,pcie-r8a7779", |
| 884 | .data = rcar_pcie_phy_init_h1 }, |
Sergei Shtylyov | f7bc638 | 2016-09-09 01:26:18 +0300 | [diff] [blame] | 885 | { .compatible = "renesas,pcie-r8a7790", |
Sergei Shtylyov | 9d5014e | 2018-05-03 22:43:13 +0300 | [diff] [blame] | 886 | .data = rcar_pcie_phy_init_gen2 }, |
Sergei Shtylyov | f7bc638 | 2016-09-09 01:26:18 +0300 | [diff] [blame] | 887 | { .compatible = "renesas,pcie-r8a7791", |
Sergei Shtylyov | 9d5014e | 2018-05-03 22:43:13 +0300 | [diff] [blame] | 888 | .data = rcar_pcie_phy_init_gen2 }, |
Simon Horman | d83a328 | 2016-12-06 16:51:30 +0100 | [diff] [blame] | 889 | { .compatible = "renesas,pcie-rcar-gen2", |
Sergei Shtylyov | 9d5014e | 2018-05-03 22:43:13 +0300 | [diff] [blame] | 890 | .data = rcar_pcie_phy_init_gen2 }, |
Sergei Shtylyov | 517ca93 | 2018-05-03 22:40:54 +0300 | [diff] [blame] | 891 | { .compatible = "renesas,pcie-r8a7795", |
Sergei Shtylyov | 9d5014e | 2018-05-03 22:43:13 +0300 | [diff] [blame] | 892 | .data = rcar_pcie_phy_init_gen3 }, |
Sergei Shtylyov | 517ca93 | 2018-05-03 22:40:54 +0300 | [diff] [blame] | 893 | { .compatible = "renesas,pcie-rcar-gen3", |
Sergei Shtylyov | 9d5014e | 2018-05-03 22:43:13 +0300 | [diff] [blame] | 894 | .data = rcar_pcie_phy_init_gen3 }, |
Phil Edworthy | c25da47 | 2014-05-12 11:57:48 +0100 | [diff] [blame] | 895 | {}, |
| 896 | }; |
Phil Edworthy | 5d2917d | 2015-11-25 15:30:37 +0000 | [diff] [blame] | 897 | |
Phil Edworthy | c25da47 | 2014-05-12 11:57:48 +0100 | [diff] [blame] | 898 | static int rcar_pcie_probe(struct platform_device *pdev) |
| 899 | { |
Bjorn Helgaas | 4ef80d7 | 2016-10-10 14:31:28 -0500 | [diff] [blame] | 900 | struct device *dev = &pdev->dev; |
Lad Prabhakar | 78a0d7f | 2020-05-07 13:33:13 +0100 | [diff] [blame] | 901 | struct rcar_pcie_host *host; |
Phil Edworthy | c25da47 | 2014-05-12 11:57:48 +0100 | [diff] [blame] | 902 | struct rcar_pcie *pcie; |
Marek Vasut | d8fa266 | 2019-03-25 12:40:58 +0100 | [diff] [blame] | 903 | u32 data; |
Phil Edworthy | 5d2917d | 2015-11-25 15:30:37 +0000 | [diff] [blame] | 904 | int err; |
Lorenzo Pieralisi | 90634e8 | 2017-06-28 15:13:57 -0500 | [diff] [blame] | 905 | struct pci_host_bridge *bridge; |
Phil Edworthy | c25da47 | 2014-05-12 11:57:48 +0100 | [diff] [blame] | 906 | |
Rob Herring | 61f11f8 | 2020-07-21 20:25:09 -0600 | [diff] [blame] | 907 | bridge = devm_pci_alloc_host_bridge(dev, sizeof(*host)); |
Lorenzo Pieralisi | 90634e8 | 2017-06-28 15:13:57 -0500 | [diff] [blame] | 908 | if (!bridge) |
Phil Edworthy | c25da47 | 2014-05-12 11:57:48 +0100 | [diff] [blame] | 909 | return -ENOMEM; |
| 910 | |
Lad Prabhakar | 78a0d7f | 2020-05-07 13:33:13 +0100 | [diff] [blame] | 911 | host = pci_host_bridge_priv(bridge); |
| 912 | pcie = &host->pcie; |
Bjorn Helgaas | 4ef80d7 | 2016-10-10 14:31:28 -0500 | [diff] [blame] | 913 | pcie->dev = dev; |
Lad Prabhakar | 78a0d7f | 2020-05-07 13:33:13 +0100 | [diff] [blame] | 914 | platform_set_drvdata(pdev, host); |
Phil Edworthy | c25da47 | 2014-05-12 11:57:48 +0100 | [diff] [blame] | 915 | |
Rob Herring | b411b2e | 2020-07-21 20:25:10 -0600 | [diff] [blame^] | 916 | err = pci_parse_request_of_pci_ranges(dev, &bridge->windows, |
Rob Herring | 331f634 | 2019-10-30 17:30:57 -0500 | [diff] [blame] | 917 | &bridge->dma_ranges, NULL); |
Geert Uytterhoeven | 83c75dd | 2017-12-07 11:15:20 +0100 | [diff] [blame] | 918 | if (err) |
Rob Herring | 61f11f8 | 2020-07-21 20:25:09 -0600 | [diff] [blame] | 919 | return err; |
Phil Edworthy | c25da47 | 2014-05-12 11:57:48 +0100 | [diff] [blame] | 920 | |
Dien Pham | 0df6150 | 2018-04-08 15:09:25 +0200 | [diff] [blame] | 921 | pm_runtime_enable(pcie->dev); |
| 922 | err = pm_runtime_get_sync(pcie->dev); |
| 923 | if (err < 0) { |
| 924 | dev_err(pcie->dev, "pm_runtime_get_sync failed\n"); |
| 925 | goto err_pm_disable; |
| 926 | } |
| 927 | |
Lad Prabhakar | 78a0d7f | 2020-05-07 13:33:13 +0100 | [diff] [blame] | 928 | err = rcar_pcie_get_resources(host); |
Phil Edworthy | c25da47 | 2014-05-12 11:57:48 +0100 | [diff] [blame] | 929 | if (err < 0) { |
Bjorn Helgaas | 4ef80d7 | 2016-10-10 14:31:28 -0500 | [diff] [blame] | 930 | dev_err(dev, "failed to request resources: %d\n", err); |
Dien Pham | 0df6150 | 2018-04-08 15:09:25 +0200 | [diff] [blame] | 931 | goto err_pm_put; |
Phil Edworthy | c25da47 | 2014-05-12 11:57:48 +0100 | [diff] [blame] | 932 | } |
| 933 | |
Lad Prabhakar | 78a0d7f | 2020-05-07 13:33:13 +0100 | [diff] [blame] | 934 | err = clk_prepare_enable(host->bus_clk); |
Marek Vasut | 80b8471 | 2018-05-24 16:36:19 +0200 | [diff] [blame] | 935 | if (err) { |
| 936 | dev_err(dev, "failed to enable bus clock: %d\n", err); |
Marek Vasut | 53f1aeb | 2018-05-24 16:36:20 +0200 | [diff] [blame] | 937 | goto err_unmap_msi_irqs; |
Phil Edworthy | c25da47 | 2014-05-12 11:57:48 +0100 | [diff] [blame] | 938 | } |
| 939 | |
Lad Prabhakar | 78a0d7f | 2020-05-07 13:33:13 +0100 | [diff] [blame] | 940 | err = rcar_pcie_parse_map_dma_ranges(host); |
Sergei Shtylyov | f7bc638 | 2016-09-09 01:26:18 +0300 | [diff] [blame] | 941 | if (err) |
Marek Vasut | 80b8471 | 2018-05-24 16:36:19 +0200 | [diff] [blame] | 942 | goto err_clk_disable; |
Phil Edworthy | c25da47 | 2014-05-12 11:57:48 +0100 | [diff] [blame] | 943 | |
Lad Prabhakar | 78a0d7f | 2020-05-07 13:33:13 +0100 | [diff] [blame] | 944 | host->phy_init_fn = of_device_get_match_data(dev); |
| 945 | err = host->phy_init_fn(host); |
Phil Edworthy | de1be9a | 2016-01-05 13:00:30 +0000 | [diff] [blame] | 946 | if (err) { |
Sergei Shtylyov | 9d5014e | 2018-05-03 22:43:13 +0300 | [diff] [blame] | 947 | dev_err(dev, "failed to init PCIe PHY\n"); |
Marek Vasut | 80b8471 | 2018-05-24 16:36:19 +0200 | [diff] [blame] | 948 | goto err_clk_disable; |
Phil Edworthy | de1be9a | 2016-01-05 13:00:30 +0000 | [diff] [blame] | 949 | } |
| 950 | |
| 951 | /* Failure to get a link might just be that no cards are inserted */ |
Sergei Shtylyov | 9d5014e | 2018-05-03 22:43:13 +0300 | [diff] [blame] | 952 | if (rcar_pcie_hw_init(pcie)) { |
Bjorn Helgaas | 4ef80d7 | 2016-10-10 14:31:28 -0500 | [diff] [blame] | 953 | dev_info(dev, "PCIe link down\n"); |
Harunobu Kurokawa | e94888d | 2016-12-16 12:50:04 +0100 | [diff] [blame] | 954 | err = -ENODEV; |
Marek Vasut | 4050360 | 2018-06-29 13:47:38 -0500 | [diff] [blame] | 955 | goto err_phy_shutdown; |
Phil Edworthy | de1be9a | 2016-01-05 13:00:30 +0000 | [diff] [blame] | 956 | } |
| 957 | |
| 958 | data = rcar_pci_read_reg(pcie, MACSR); |
Bjorn Helgaas | 4ef80d7 | 2016-10-10 14:31:28 -0500 | [diff] [blame] | 959 | dev_info(dev, "PCIe x%d: link up\n", (data >> 20) & 0x3f); |
Phil Edworthy | de1be9a | 2016-01-05 13:00:30 +0000 | [diff] [blame] | 960 | |
Phil Edworthy | 290c1fb | 2014-05-12 11:57:49 +0100 | [diff] [blame] | 961 | if (IS_ENABLED(CONFIG_PCI_MSI)) { |
Lad Prabhakar | 78a0d7f | 2020-05-07 13:33:13 +0100 | [diff] [blame] | 962 | err = rcar_pcie_enable_msi(host); |
Phil Edworthy | 290c1fb | 2014-05-12 11:57:49 +0100 | [diff] [blame] | 963 | if (err < 0) { |
Bjorn Helgaas | 4ef80d7 | 2016-10-10 14:31:28 -0500 | [diff] [blame] | 964 | dev_err(dev, |
Phil Edworthy | 290c1fb | 2014-05-12 11:57:49 +0100 | [diff] [blame] | 965 | "failed to enable MSI support: %d\n", |
| 966 | err); |
Marek Vasut | 4050360 | 2018-06-29 13:47:38 -0500 | [diff] [blame] | 967 | goto err_phy_shutdown; |
Phil Edworthy | 290c1fb | 2014-05-12 11:57:49 +0100 | [diff] [blame] | 968 | } |
| 969 | } |
| 970 | |
Lad Prabhakar | 78a0d7f | 2020-05-07 13:33:13 +0100 | [diff] [blame] | 971 | err = rcar_pcie_enable(host); |
Phil Edworthy | de1be9a | 2016-01-05 13:00:30 +0000 | [diff] [blame] | 972 | if (err) |
Marek Vasut | 1aea58b | 2018-05-24 16:36:21 +0200 | [diff] [blame] | 973 | goto err_msi_teardown; |
Phil Edworthy | c25da47 | 2014-05-12 11:57:48 +0100 | [diff] [blame] | 974 | |
Phil Edworthy | de1be9a | 2016-01-05 13:00:30 +0000 | [diff] [blame] | 975 | return 0; |
Phil Edworthy | c25da47 | 2014-05-12 11:57:48 +0100 | [diff] [blame] | 976 | |
Marek Vasut | 1aea58b | 2018-05-24 16:36:21 +0200 | [diff] [blame] | 977 | err_msi_teardown: |
| 978 | if (IS_ENABLED(CONFIG_PCI_MSI)) |
Lad Prabhakar | 78a0d7f | 2020-05-07 13:33:13 +0100 | [diff] [blame] | 979 | rcar_pcie_teardown_msi(host); |
Marek Vasut | 1aea58b | 2018-05-24 16:36:21 +0200 | [diff] [blame] | 980 | |
Marek Vasut | 4050360 | 2018-06-29 13:47:38 -0500 | [diff] [blame] | 981 | err_phy_shutdown: |
Lad Prabhakar | 78a0d7f | 2020-05-07 13:33:13 +0100 | [diff] [blame] | 982 | if (host->phy) { |
| 983 | phy_power_off(host->phy); |
| 984 | phy_exit(host->phy); |
Marek Vasut | 4050360 | 2018-06-29 13:47:38 -0500 | [diff] [blame] | 985 | } |
| 986 | |
Marek Vasut | 80b8471 | 2018-05-24 16:36:19 +0200 | [diff] [blame] | 987 | err_clk_disable: |
Lad Prabhakar | 78a0d7f | 2020-05-07 13:33:13 +0100 | [diff] [blame] | 988 | clk_disable_unprepare(host->bus_clk); |
Marek Vasut | 80b8471 | 2018-05-24 16:36:19 +0200 | [diff] [blame] | 989 | |
Marek Vasut | 53f1aeb | 2018-05-24 16:36:20 +0200 | [diff] [blame] | 990 | err_unmap_msi_irqs: |
Lad Prabhakar | 78a0d7f | 2020-05-07 13:33:13 +0100 | [diff] [blame] | 991 | irq_dispose_mapping(host->msi.irq2); |
| 992 | irq_dispose_mapping(host->msi.irq1); |
Marek Vasut | 53f1aeb | 2018-05-24 16:36:20 +0200 | [diff] [blame] | 993 | |
Phil Edworthy | de1be9a | 2016-01-05 13:00:30 +0000 | [diff] [blame] | 994 | err_pm_put: |
Bjorn Helgaas | 4ef80d7 | 2016-10-10 14:31:28 -0500 | [diff] [blame] | 995 | pm_runtime_put(dev); |
Phil Edworthy | c25da47 | 2014-05-12 11:57:48 +0100 | [diff] [blame] | 996 | |
Phil Edworthy | de1be9a | 2016-01-05 13:00:30 +0000 | [diff] [blame] | 997 | err_pm_disable: |
Bjorn Helgaas | 4ef80d7 | 2016-10-10 14:31:28 -0500 | [diff] [blame] | 998 | pm_runtime_disable(dev); |
Dien Pham | 0df6150 | 2018-04-08 15:09:25 +0200 | [diff] [blame] | 999 | |
Phil Edworthy | de1be9a | 2016-01-05 13:00:30 +0000 | [diff] [blame] | 1000 | return err; |
Phil Edworthy | c25da47 | 2014-05-12 11:57:48 +0100 | [diff] [blame] | 1001 | } |
| 1002 | |
Kazufumi Ikeda | ce35163 | 2020-03-14 20:12:32 +0100 | [diff] [blame] | 1003 | static int __maybe_unused rcar_pcie_resume(struct device *dev) |
| 1004 | { |
Lad Prabhakar | 78a0d7f | 2020-05-07 13:33:13 +0100 | [diff] [blame] | 1005 | struct rcar_pcie_host *host = dev_get_drvdata(dev); |
| 1006 | struct rcar_pcie *pcie = &host->pcie; |
Kazufumi Ikeda | ce35163 | 2020-03-14 20:12:32 +0100 | [diff] [blame] | 1007 | unsigned int data; |
| 1008 | int err; |
| 1009 | |
Lad Prabhakar | 78a0d7f | 2020-05-07 13:33:13 +0100 | [diff] [blame] | 1010 | err = rcar_pcie_parse_map_dma_ranges(host); |
Kazufumi Ikeda | ce35163 | 2020-03-14 20:12:32 +0100 | [diff] [blame] | 1011 | if (err) |
| 1012 | return 0; |
| 1013 | |
| 1014 | /* Failure to get a link might just be that no cards are inserted */ |
Lad Prabhakar | 78a0d7f | 2020-05-07 13:33:13 +0100 | [diff] [blame] | 1015 | err = host->phy_init_fn(host); |
Kazufumi Ikeda | ce35163 | 2020-03-14 20:12:32 +0100 | [diff] [blame] | 1016 | if (err) { |
| 1017 | dev_info(dev, "PCIe link down\n"); |
| 1018 | return 0; |
| 1019 | } |
| 1020 | |
| 1021 | data = rcar_pci_read_reg(pcie, MACSR); |
| 1022 | dev_info(dev, "PCIe x%d: link up\n", (data >> 20) & 0x3f); |
| 1023 | |
| 1024 | /* Enable MSI */ |
| 1025 | if (IS_ENABLED(CONFIG_PCI_MSI)) |
Lad Prabhakar | 78a0d7f | 2020-05-07 13:33:13 +0100 | [diff] [blame] | 1026 | rcar_pcie_hw_enable_msi(host); |
Kazufumi Ikeda | ce35163 | 2020-03-14 20:12:32 +0100 | [diff] [blame] | 1027 | |
Lad Prabhakar | 78a0d7f | 2020-05-07 13:33:13 +0100 | [diff] [blame] | 1028 | rcar_pcie_hw_enable(host); |
Kazufumi Ikeda | ce35163 | 2020-03-14 20:12:32 +0100 | [diff] [blame] | 1029 | |
| 1030 | return 0; |
| 1031 | } |
| 1032 | |
Kazufumi Ikeda | be20bbc | 2019-03-25 20:43:19 +0100 | [diff] [blame] | 1033 | static int rcar_pcie_resume_noirq(struct device *dev) |
| 1034 | { |
Lad Prabhakar | 78a0d7f | 2020-05-07 13:33:13 +0100 | [diff] [blame] | 1035 | struct rcar_pcie_host *host = dev_get_drvdata(dev); |
| 1036 | struct rcar_pcie *pcie = &host->pcie; |
Kazufumi Ikeda | be20bbc | 2019-03-25 20:43:19 +0100 | [diff] [blame] | 1037 | |
| 1038 | if (rcar_pci_read_reg(pcie, PMSR) && |
| 1039 | !(rcar_pci_read_reg(pcie, PCIETCTLR) & DL_DOWN)) |
| 1040 | return 0; |
| 1041 | |
| 1042 | /* Re-establish the PCIe link */ |
Yoshihiro Shimoda | 7c7e53e | 2019-11-05 19:51:29 +0900 | [diff] [blame] | 1043 | rcar_pci_write_reg(pcie, MACCTLR_INIT_VAL, MACCTLR); |
Kazufumi Ikeda | be20bbc | 2019-03-25 20:43:19 +0100 | [diff] [blame] | 1044 | rcar_pci_write_reg(pcie, CFINIT, PCIETCTLR); |
| 1045 | return rcar_pcie_wait_for_dl(pcie); |
| 1046 | } |
| 1047 | |
| 1048 | static const struct dev_pm_ops rcar_pcie_pm_ops = { |
Kazufumi Ikeda | ce35163 | 2020-03-14 20:12:32 +0100 | [diff] [blame] | 1049 | SET_SYSTEM_SLEEP_PM_OPS(NULL, rcar_pcie_resume) |
Kazufumi Ikeda | be20bbc | 2019-03-25 20:43:19 +0100 | [diff] [blame] | 1050 | .resume_noirq = rcar_pcie_resume_noirq, |
| 1051 | }; |
| 1052 | |
Phil Edworthy | c25da47 | 2014-05-12 11:57:48 +0100 | [diff] [blame] | 1053 | static struct platform_driver rcar_pcie_driver = { |
| 1054 | .driver = { |
Bjorn Helgaas | 3ff8e4a | 2016-10-06 13:40:28 -0500 | [diff] [blame] | 1055 | .name = "rcar-pcie", |
Phil Edworthy | c25da47 | 2014-05-12 11:57:48 +0100 | [diff] [blame] | 1056 | .of_match_table = rcar_pcie_of_match, |
Kazufumi Ikeda | be20bbc | 2019-03-25 20:43:19 +0100 | [diff] [blame] | 1057 | .pm = &rcar_pcie_pm_ops, |
Phil Edworthy | c25da47 | 2014-05-12 11:57:48 +0100 | [diff] [blame] | 1058 | .suppress_bind_attrs = true, |
| 1059 | }, |
| 1060 | .probe = rcar_pcie_probe, |
| 1061 | }; |
Paul Gortmaker | 42d1071 | 2016-07-22 16:23:21 -0500 | [diff] [blame] | 1062 | builtin_platform_driver(rcar_pcie_driver); |