diff options
Diffstat (limited to 'drivers/pci/host/pcie-rcar.c')
-rw-r--r-- | drivers/pci/host/pcie-rcar.c | 158 |
1 files changed, 72 insertions, 86 deletions
diff --git a/drivers/pci/host/pcie-rcar.c b/drivers/pci/host/pcie-rcar.c index f7d3de32c9a0..4884ee5e07d4 100644 --- a/drivers/pci/host/pcie-rcar.c +++ b/drivers/pci/host/pcie-rcar.c | |||
@@ -105,7 +105,7 @@ | |||
105 | #define PCIE_CONF_DEV(d) (((d) & 0x1f) << 19) | 105 | #define PCIE_CONF_DEV(d) (((d) & 0x1f) << 19) |
106 | #define PCIE_CONF_FUNC(f) (((f) & 0x7) << 16) | 106 | #define PCIE_CONF_FUNC(f) (((f) & 0x7) << 16) |
107 | 107 | ||
108 | #define PCI_MAX_RESOURCES 4 | 108 | #define RCAR_PCI_MAX_RESOURCES 4 |
109 | #define MAX_NR_INBOUND_MAPS 6 | 109 | #define MAX_NR_INBOUND_MAPS 6 |
110 | 110 | ||
111 | struct rcar_msi { | 111 | struct rcar_msi { |
@@ -127,7 +127,7 @@ static inline struct rcar_msi *to_rcar_msi(struct msi_chip *chip) | |||
127 | struct rcar_pcie { | 127 | struct rcar_pcie { |
128 | struct device *dev; | 128 | struct device *dev; |
129 | void __iomem *base; | 129 | void __iomem *base; |
130 | struct resource res[PCI_MAX_RESOURCES]; | 130 | struct resource res[RCAR_PCI_MAX_RESOURCES]; |
131 | struct resource busn; | 131 | struct resource busn; |
132 | int root_bus_nr; | 132 | int root_bus_nr; |
133 | struct clk *clk; | 133 | struct clk *clk; |
@@ -140,36 +140,37 @@ static inline struct rcar_pcie *sys_to_pcie(struct pci_sys_data *sys) | |||
140 | return sys->private_data; | 140 | return sys->private_data; |
141 | } | 141 | } |
142 | 142 | ||
143 | static void pci_write_reg(struct rcar_pcie *pcie, unsigned long val, | 143 | static void rcar_pci_write_reg(struct rcar_pcie *pcie, unsigned long val, |
144 | unsigned long reg) | 144 | unsigned long reg) |
145 | { | 145 | { |
146 | writel(val, pcie->base + reg); | 146 | writel(val, pcie->base + reg); |
147 | } | 147 | } |
148 | 148 | ||
149 | static unsigned long pci_read_reg(struct rcar_pcie *pcie, unsigned long reg) | 149 | static unsigned long rcar_pci_read_reg(struct rcar_pcie *pcie, |
150 | unsigned long reg) | ||
150 | { | 151 | { |
151 | return readl(pcie->base + reg); | 152 | return readl(pcie->base + reg); |
152 | } | 153 | } |
153 | 154 | ||
154 | enum { | 155 | enum { |
155 | PCI_ACCESS_READ, | 156 | RCAR_PCI_ACCESS_READ, |
156 | PCI_ACCESS_WRITE, | 157 | RCAR_PCI_ACCESS_WRITE, |
157 | }; | 158 | }; |
158 | 159 | ||
159 | static void rcar_rmw32(struct rcar_pcie *pcie, int where, u32 mask, u32 data) | 160 | static void rcar_rmw32(struct rcar_pcie *pcie, int where, u32 mask, u32 data) |
160 | { | 161 | { |
161 | int shift = 8 * (where & 3); | 162 | int shift = 8 * (where & 3); |
162 | u32 val = pci_read_reg(pcie, where & ~3); | 163 | u32 val = rcar_pci_read_reg(pcie, where & ~3); |
163 | 164 | ||
164 | val &= ~(mask << shift); | 165 | val &= ~(mask << shift); |
165 | val |= data << shift; | 166 | val |= data << shift; |
166 | pci_write_reg(pcie, val, where & ~3); | 167 | rcar_pci_write_reg(pcie, val, where & ~3); |
167 | } | 168 | } |
168 | 169 | ||
169 | static u32 rcar_read_conf(struct rcar_pcie *pcie, int where) | 170 | static u32 rcar_read_conf(struct rcar_pcie *pcie, int where) |
170 | { | 171 | { |
171 | int shift = 8 * (where & 3); | 172 | int shift = 8 * (where & 3); |
172 | u32 val = pci_read_reg(pcie, where & ~3); | 173 | u32 val = rcar_pci_read_reg(pcie, where & ~3); |
173 | 174 | ||
174 | return val >> shift; | 175 | return val >> shift; |
175 | } | 176 | } |
@@ -205,14 +206,14 @@ static int rcar_pcie_config_access(struct rcar_pcie *pcie, | |||
205 | if (dev != 0) | 206 | if (dev != 0) |
206 | return PCIBIOS_DEVICE_NOT_FOUND; | 207 | return PCIBIOS_DEVICE_NOT_FOUND; |
207 | 208 | ||
208 | if (access_type == PCI_ACCESS_READ) { | 209 | if (access_type == RCAR_PCI_ACCESS_READ) { |
209 | *data = pci_read_reg(pcie, PCICONF(index)); | 210 | *data = rcar_pci_read_reg(pcie, PCICONF(index)); |
210 | } else { | 211 | } else { |
211 | /* Keep an eye out for changes to the root bus number */ | 212 | /* Keep an eye out for changes to the root bus number */ |
212 | if (pci_is_root_bus(bus) && (reg == PCI_PRIMARY_BUS)) | 213 | if (pci_is_root_bus(bus) && (reg == PCI_PRIMARY_BUS)) |
213 | pcie->root_bus_nr = *data & 0xff; | 214 | pcie->root_bus_nr = *data & 0xff; |
214 | 215 | ||
215 | pci_write_reg(pcie, *data, PCICONF(index)); | 216 | rcar_pci_write_reg(pcie, *data, PCICONF(index)); |
216 | } | 217 | } |
217 | 218 | ||
218 | return PCIBIOS_SUCCESSFUL; | 219 | return PCIBIOS_SUCCESSFUL; |
@@ -222,20 +223,20 @@ static int rcar_pcie_config_access(struct rcar_pcie *pcie, | |||
222 | return PCIBIOS_DEVICE_NOT_FOUND; | 223 | return PCIBIOS_DEVICE_NOT_FOUND; |
223 | 224 | ||
224 | /* Clear errors */ | 225 | /* Clear errors */ |
225 | pci_write_reg(pcie, pci_read_reg(pcie, PCIEERRFR), PCIEERRFR); | 226 | rcar_pci_write_reg(pcie, rcar_pci_read_reg(pcie, PCIEERRFR), PCIEERRFR); |
226 | 227 | ||
227 | /* Set the PIO address */ | 228 | /* Set the PIO address */ |
228 | pci_write_reg(pcie, PCIE_CONF_BUS(bus->number) | PCIE_CONF_DEV(dev) | | 229 | rcar_pci_write_reg(pcie, PCIE_CONF_BUS(bus->number) | |
229 | PCIE_CONF_FUNC(func) | reg, PCIECAR); | 230 | PCIE_CONF_DEV(dev) | PCIE_CONF_FUNC(func) | reg, PCIECAR); |
230 | 231 | ||
231 | /* Enable the configuration access */ | 232 | /* Enable the configuration access */ |
232 | if (bus->parent->number == pcie->root_bus_nr) | 233 | if (bus->parent->number == pcie->root_bus_nr) |
233 | pci_write_reg(pcie, CONFIG_SEND_ENABLE | TYPE0, PCIECCTLR); | 234 | rcar_pci_write_reg(pcie, CONFIG_SEND_ENABLE | TYPE0, PCIECCTLR); |
234 | else | 235 | else |
235 | pci_write_reg(pcie, CONFIG_SEND_ENABLE | TYPE1, PCIECCTLR); | 236 | rcar_pci_write_reg(pcie, CONFIG_SEND_ENABLE | TYPE1, PCIECCTLR); |
236 | 237 | ||
237 | /* Check for errors */ | 238 | /* Check for errors */ |
238 | if (pci_read_reg(pcie, PCIEERRFR) & UNSUPPORTED_REQUEST) | 239 | if (rcar_pci_read_reg(pcie, PCIEERRFR) & UNSUPPORTED_REQUEST) |
239 | return PCIBIOS_DEVICE_NOT_FOUND; | 240 | return PCIBIOS_DEVICE_NOT_FOUND; |
240 | 241 | ||
241 | /* Check for master and target aborts */ | 242 | /* Check for master and target aborts */ |
@@ -243,13 +244,13 @@ static int rcar_pcie_config_access(struct rcar_pcie *pcie, | |||
243 | (PCI_STATUS_REC_MASTER_ABORT | PCI_STATUS_REC_TARGET_ABORT)) | 244 | (PCI_STATUS_REC_MASTER_ABORT | PCI_STATUS_REC_TARGET_ABORT)) |
244 | return PCIBIOS_DEVICE_NOT_FOUND; | 245 | return PCIBIOS_DEVICE_NOT_FOUND; |
245 | 246 | ||
246 | if (access_type == PCI_ACCESS_READ) | 247 | if (access_type == RCAR_PCI_ACCESS_READ) |
247 | *data = pci_read_reg(pcie, PCIECDR); | 248 | *data = rcar_pci_read_reg(pcie, PCIECDR); |
248 | else | 249 | else |
249 | pci_write_reg(pcie, *data, PCIECDR); | 250 | rcar_pci_write_reg(pcie, *data, PCIECDR); |
250 | 251 | ||
251 | /* Disable the configuration access */ | 252 | /* Disable the configuration access */ |
252 | pci_write_reg(pcie, 0, PCIECCTLR); | 253 | rcar_pci_write_reg(pcie, 0, PCIECCTLR); |
253 | 254 | ||
254 | return PCIBIOS_SUCCESSFUL; | 255 | return PCIBIOS_SUCCESSFUL; |
255 | } | 256 | } |
@@ -260,12 +261,7 @@ static int rcar_pcie_read_conf(struct pci_bus *bus, unsigned int devfn, | |||
260 | struct rcar_pcie *pcie = sys_to_pcie(bus->sysdata); | 261 | struct rcar_pcie *pcie = sys_to_pcie(bus->sysdata); |
261 | int ret; | 262 | int ret; |
262 | 263 | ||
263 | if ((size == 2) && (where & 1)) | 264 | ret = rcar_pcie_config_access(pcie, RCAR_PCI_ACCESS_READ, |
264 | return PCIBIOS_BAD_REGISTER_NUMBER; | ||
265 | else if ((size == 4) && (where & 3)) | ||
266 | return PCIBIOS_BAD_REGISTER_NUMBER; | ||
267 | |||
268 | ret = rcar_pcie_config_access(pcie, PCI_ACCESS_READ, | ||
269 | bus, devfn, where, val); | 265 | bus, devfn, where, val); |
270 | if (ret != PCIBIOS_SUCCESSFUL) { | 266 | if (ret != PCIBIOS_SUCCESSFUL) { |
271 | *val = 0xffffffff; | 267 | *val = 0xffffffff; |
@@ -291,12 +287,7 @@ static int rcar_pcie_write_conf(struct pci_bus *bus, unsigned int devfn, | |||
291 | int shift, ret; | 287 | int shift, ret; |
292 | u32 data; | 288 | u32 data; |
293 | 289 | ||
294 | if ((size == 2) && (where & 1)) | 290 | ret = rcar_pcie_config_access(pcie, RCAR_PCI_ACCESS_READ, |
295 | return PCIBIOS_BAD_REGISTER_NUMBER; | ||
296 | else if ((size == 4) && (where & 3)) | ||
297 | return PCIBIOS_BAD_REGISTER_NUMBER; | ||
298 | |||
299 | ret = rcar_pcie_config_access(pcie, PCI_ACCESS_READ, | ||
300 | bus, devfn, where, &data); | 291 | bus, devfn, where, &data); |
301 | if (ret != PCIBIOS_SUCCESSFUL) | 292 | if (ret != PCIBIOS_SUCCESSFUL) |
302 | return ret; | 293 | return ret; |
@@ -315,7 +306,7 @@ static int rcar_pcie_write_conf(struct pci_bus *bus, unsigned int devfn, | |||
315 | } else | 306 | } else |
316 | data = val; | 307 | data = val; |
317 | 308 | ||
318 | ret = rcar_pcie_config_access(pcie, PCI_ACCESS_WRITE, | 309 | ret = rcar_pcie_config_access(pcie, RCAR_PCI_ACCESS_WRITE, |
319 | bus, devfn, where, &data); | 310 | bus, devfn, where, &data); |
320 | 311 | ||
321 | return ret; | 312 | return ret; |
@@ -326,14 +317,15 @@ static struct pci_ops rcar_pcie_ops = { | |||
326 | .write = rcar_pcie_write_conf, | 317 | .write = rcar_pcie_write_conf, |
327 | }; | 318 | }; |
328 | 319 | ||
329 | static void rcar_pcie_setup_window(int win, struct resource *res, | 320 | static void rcar_pcie_setup_window(int win, struct rcar_pcie *pcie) |
330 | struct rcar_pcie *pcie) | ||
331 | { | 321 | { |
322 | struct resource *res = &pcie->res[win]; | ||
323 | |||
332 | /* Setup PCIe address space mappings for each resource */ | 324 | /* Setup PCIe address space mappings for each resource */ |
333 | resource_size_t size; | 325 | resource_size_t size; |
334 | u32 mask; | 326 | u32 mask; |
335 | 327 | ||
336 | pci_write_reg(pcie, 0x00000000, PCIEPTCTLR(win)); | 328 | rcar_pci_write_reg(pcie, 0x00000000, PCIEPTCTLR(win)); |
337 | 329 | ||
338 | /* | 330 | /* |
339 | * The PAMR mask is calculated in units of 128Bytes, which | 331 | * The PAMR mask is calculated in units of 128Bytes, which |
@@ -341,17 +333,17 @@ static void rcar_pcie_setup_window(int win, struct resource *res, | |||
341 | */ | 333 | */ |
342 | size = resource_size(res); | 334 | size = resource_size(res); |
343 | mask = (roundup_pow_of_two(size) / SZ_128) - 1; | 335 | mask = (roundup_pow_of_two(size) / SZ_128) - 1; |
344 | pci_write_reg(pcie, mask << 7, PCIEPAMR(win)); | 336 | rcar_pci_write_reg(pcie, mask << 7, PCIEPAMR(win)); |
345 | 337 | ||
346 | pci_write_reg(pcie, upper_32_bits(res->start), PCIEPARH(win)); | 338 | rcar_pci_write_reg(pcie, upper_32_bits(res->start), PCIEPARH(win)); |
347 | pci_write_reg(pcie, lower_32_bits(res->start), PCIEPARL(win)); | 339 | rcar_pci_write_reg(pcie, lower_32_bits(res->start), PCIEPARL(win)); |
348 | 340 | ||
349 | /* First resource is for IO */ | 341 | /* First resource is for IO */ |
350 | mask = PAR_ENABLE; | 342 | mask = PAR_ENABLE; |
351 | if (res->flags & IORESOURCE_IO) | 343 | if (res->flags & IORESOURCE_IO) |
352 | mask |= IO_SPACE; | 344 | mask |= IO_SPACE; |
353 | 345 | ||
354 | pci_write_reg(pcie, mask, PCIEPTCTLR(win)); | 346 | rcar_pci_write_reg(pcie, mask, PCIEPTCTLR(win)); |
355 | } | 347 | } |
356 | 348 | ||
357 | static int rcar_pcie_setup(int nr, struct pci_sys_data *sys) | 349 | static int rcar_pcie_setup(int nr, struct pci_sys_data *sys) |
@@ -363,13 +355,13 @@ static int rcar_pcie_setup(int nr, struct pci_sys_data *sys) | |||
363 | pcie->root_bus_nr = -1; | 355 | pcie->root_bus_nr = -1; |
364 | 356 | ||
365 | /* Setup PCI resources */ | 357 | /* Setup PCI resources */ |
366 | for (i = 0; i < PCI_MAX_RESOURCES; i++) { | 358 | for (i = 0; i < RCAR_PCI_MAX_RESOURCES; i++) { |
367 | 359 | ||
368 | res = &pcie->res[i]; | 360 | res = &pcie->res[i]; |
369 | if (!res->flags) | 361 | if (!res->flags) |
370 | continue; | 362 | continue; |
371 | 363 | ||
372 | rcar_pcie_setup_window(i, res, pcie); | 364 | rcar_pcie_setup_window(i, pcie); |
373 | 365 | ||
374 | if (res->flags & IORESOURCE_IO) | 366 | if (res->flags & IORESOURCE_IO) |
375 | pci_ioremap_io(nr * SZ_64K, res->start); | 367 | pci_ioremap_io(nr * SZ_64K, res->start); |
@@ -415,7 +407,7 @@ static int phy_wait_for_ack(struct rcar_pcie *pcie) | |||
415 | unsigned int timeout = 100; | 407 | unsigned int timeout = 100; |
416 | 408 | ||
417 | while (timeout--) { | 409 | while (timeout--) { |
418 | if (pci_read_reg(pcie, H1_PCIEPHYADRR) & PHY_ACK) | 410 | if (rcar_pci_read_reg(pcie, H1_PCIEPHYADRR) & PHY_ACK) |
419 | return 0; | 411 | return 0; |
420 | 412 | ||
421 | udelay(100); | 413 | udelay(100); |
@@ -438,15 +430,15 @@ static void phy_write_reg(struct rcar_pcie *pcie, | |||
438 | ((addr & 0xff) << ADR_POS); | 430 | ((addr & 0xff) << ADR_POS); |
439 | 431 | ||
440 | /* Set write data */ | 432 | /* Set write data */ |
441 | pci_write_reg(pcie, data, H1_PCIEPHYDOUTR); | 433 | rcar_pci_write_reg(pcie, data, H1_PCIEPHYDOUTR); |
442 | pci_write_reg(pcie, phyaddr, H1_PCIEPHYADRR); | 434 | rcar_pci_write_reg(pcie, phyaddr, H1_PCIEPHYADRR); |
443 | 435 | ||
444 | /* Ignore errors as they will be dealt with if the data link is down */ | 436 | /* Ignore errors as they will be dealt with if the data link is down */ |
445 | phy_wait_for_ack(pcie); | 437 | phy_wait_for_ack(pcie); |
446 | 438 | ||
447 | /* Clear command */ | 439 | /* Clear command */ |
448 | pci_write_reg(pcie, 0, H1_PCIEPHYDOUTR); | 440 | rcar_pci_write_reg(pcie, 0, H1_PCIEPHYDOUTR); |
449 | pci_write_reg(pcie, 0, H1_PCIEPHYADRR); | 441 | rcar_pci_write_reg(pcie, 0, H1_PCIEPHYADRR); |
450 | 442 | ||
451 | /* Ignore errors as they will be dealt with if the data link is down */ | 443 | /* Ignore errors as they will be dealt with if the data link is down */ |
452 | phy_wait_for_ack(pcie); | 444 | phy_wait_for_ack(pcie); |
@@ -457,7 +449,7 @@ static int rcar_pcie_wait_for_dl(struct rcar_pcie *pcie) | |||
457 | unsigned int timeout = 10; | 449 | unsigned int timeout = 10; |
458 | 450 | ||
459 | while (timeout--) { | 451 | while (timeout--) { |
460 | if ((pci_read_reg(pcie, PCIETSTR) & DATA_LINK_ACTIVE)) | 452 | if ((rcar_pci_read_reg(pcie, PCIETSTR) & DATA_LINK_ACTIVE)) |
461 | return 0; | 453 | return 0; |
462 | 454 | ||
463 | msleep(5); | 455 | msleep(5); |
@@ -471,17 +463,17 @@ static int rcar_pcie_hw_init(struct rcar_pcie *pcie) | |||
471 | int err; | 463 | int err; |
472 | 464 | ||
473 | /* Begin initialization */ | 465 | /* Begin initialization */ |
474 | pci_write_reg(pcie, 0, PCIETCTLR); | 466 | rcar_pci_write_reg(pcie, 0, PCIETCTLR); |
475 | 467 | ||
476 | /* Set mode */ | 468 | /* Set mode */ |
477 | pci_write_reg(pcie, 1, PCIEMSR); | 469 | rcar_pci_write_reg(pcie, 1, PCIEMSR); |
478 | 470 | ||
479 | /* | 471 | /* |
480 | * Initial header for port config space is type 1, set the device | 472 | * Initial header for port config space is type 1, set the device |
481 | * class to match. Hardware takes care of propagating the IDSETR | 473 | * class to match. Hardware takes care of propagating the IDSETR |
482 | * settings, so there is no need to bother with a quirk. | 474 | * settings, so there is no need to bother with a quirk. |
483 | */ | 475 | */ |
484 | pci_write_reg(pcie, PCI_CLASS_BRIDGE_PCI << 16, IDSETR1); | 476 | rcar_pci_write_reg(pcie, PCI_CLASS_BRIDGE_PCI << 16, IDSETR1); |
485 | 477 | ||
486 | /* | 478 | /* |
487 | * Setup Secondary Bus Number & Subordinate Bus Number, even though | 479 | * Setup Secondary Bus Number & Subordinate Bus Number, even though |
@@ -491,33 +483,31 @@ static int rcar_pcie_hw_init(struct rcar_pcie *pcie) | |||
491 | rcar_rmw32(pcie, RCONF(PCI_SUBORDINATE_BUS), 0xff, 1); | 483 | rcar_rmw32(pcie, RCONF(PCI_SUBORDINATE_BUS), 0xff, 1); |
492 | 484 | ||
493 | /* Initialize default capabilities. */ | 485 | /* Initialize default capabilities. */ |
494 | rcar_rmw32(pcie, REXPCAP(0), 0, PCI_CAP_ID_EXP); | 486 | rcar_rmw32(pcie, REXPCAP(0), 0xff, PCI_CAP_ID_EXP); |
495 | rcar_rmw32(pcie, REXPCAP(PCI_EXP_FLAGS), | 487 | rcar_rmw32(pcie, REXPCAP(PCI_EXP_FLAGS), |
496 | PCI_EXP_FLAGS_TYPE, PCI_EXP_TYPE_ROOT_PORT << 4); | 488 | PCI_EXP_FLAGS_TYPE, PCI_EXP_TYPE_ROOT_PORT << 4); |
497 | rcar_rmw32(pcie, RCONF(PCI_HEADER_TYPE), 0x7f, | 489 | rcar_rmw32(pcie, RCONF(PCI_HEADER_TYPE), 0x7f, |
498 | PCI_HEADER_TYPE_BRIDGE); | 490 | PCI_HEADER_TYPE_BRIDGE); |
499 | 491 | ||
500 | /* Enable data link layer active state reporting */ | 492 | /* Enable data link layer active state reporting */ |
501 | rcar_rmw32(pcie, REXPCAP(PCI_EXP_LNKCAP), 0, PCI_EXP_LNKCAP_DLLLARC); | 493 | rcar_rmw32(pcie, REXPCAP(PCI_EXP_LNKCAP), PCI_EXP_LNKCAP_DLLLARC, |
494 | PCI_EXP_LNKCAP_DLLLARC); | ||
502 | 495 | ||
503 | /* Write out the physical slot number = 0 */ | 496 | /* Write out the physical slot number = 0 */ |
504 | rcar_rmw32(pcie, REXPCAP(PCI_EXP_SLTCAP), PCI_EXP_SLTCAP_PSN, 0); | 497 | rcar_rmw32(pcie, REXPCAP(PCI_EXP_SLTCAP), PCI_EXP_SLTCAP_PSN, 0); |
505 | 498 | ||
506 | /* Set the completion timer timeout to the maximum 50ms. */ | 499 | /* Set the completion timer timeout to the maximum 50ms. */ |
507 | rcar_rmw32(pcie, TLCTLR+1, 0x3f, 50); | 500 | rcar_rmw32(pcie, TLCTLR + 1, 0x3f, 50); |
508 | 501 | ||
509 | /* Terminate list of capabilities (Next Capability Offset=0) */ | 502 | /* Terminate list of capabilities (Next Capability Offset=0) */ |
510 | rcar_rmw32(pcie, RVCCAP(0), 0xfff0, 0); | 503 | rcar_rmw32(pcie, RVCCAP(0), 0xfff00000, 0); |
511 | |||
512 | /* Enable MAC data scrambling. */ | ||
513 | rcar_rmw32(pcie, MACCTLR, SCRAMBLE_DISABLE, 0); | ||
514 | 504 | ||
515 | /* Enable MSI */ | 505 | /* Enable MSI */ |
516 | if (IS_ENABLED(CONFIG_PCI_MSI)) | 506 | if (IS_ENABLED(CONFIG_PCI_MSI)) |
517 | pci_write_reg(pcie, 0x101f0000, PCIEMSITXR); | 507 | rcar_pci_write_reg(pcie, 0x101f0000, PCIEMSITXR); |
518 | 508 | ||
519 | /* Finish initialization - establish a PCI Express link */ | 509 | /* Finish initialization - establish a PCI Express link */ |
520 | pci_write_reg(pcie, CFINIT, PCIETCTLR); | 510 | rcar_pci_write_reg(pcie, CFINIT, PCIETCTLR); |
521 | 511 | ||
522 | /* This will timeout if we don't have a link. */ | 512 | /* This will timeout if we don't have a link. */ |
523 | err = rcar_pcie_wait_for_dl(pcie); | 513 | err = rcar_pcie_wait_for_dl(pcie); |
@@ -527,11 +517,6 @@ static int rcar_pcie_hw_init(struct rcar_pcie *pcie) | |||
527 | /* Enable INTx interrupts */ | 517 | /* Enable INTx interrupts */ |
528 | rcar_rmw32(pcie, PCIEINTXR, 0, 0xF << 8); | 518 | rcar_rmw32(pcie, PCIEINTXR, 0, 0xF << 8); |
529 | 519 | ||
530 | /* Enable slave Bus Mastering */ | ||
531 | rcar_rmw32(pcie, RCONF(PCI_STATUS), PCI_STATUS_DEVSEL_MASK, | ||
532 | PCI_COMMAND_IO | PCI_COMMAND_MEMORY | PCI_COMMAND_MASTER | | ||
533 | PCI_STATUS_CAP_LIST | PCI_STATUS_DEVSEL_FAST); | ||
534 | |||
535 | wmb(); | 520 | wmb(); |
536 | 521 | ||
537 | return 0; | 522 | return 0; |
@@ -560,7 +545,7 @@ static int rcar_pcie_hw_init_h1(struct rcar_pcie *pcie) | |||
560 | phy_write_reg(pcie, 0, 0x66, 0x1, 0x00008000); | 545 | phy_write_reg(pcie, 0, 0x66, 0x1, 0x00008000); |
561 | 546 | ||
562 | while (timeout--) { | 547 | while (timeout--) { |
563 | if (pci_read_reg(pcie, H1_PCIEPHYSR)) | 548 | if (rcar_pci_read_reg(pcie, H1_PCIEPHYSR)) |
564 | return rcar_pcie_hw_init(pcie); | 549 | return rcar_pcie_hw_init(pcie); |
565 | 550 | ||
566 | msleep(5); | 551 | msleep(5); |
@@ -599,7 +584,7 @@ static irqreturn_t rcar_pcie_msi_irq(int irq, void *data) | |||
599 | struct rcar_msi *msi = &pcie->msi; | 584 | struct rcar_msi *msi = &pcie->msi; |
600 | unsigned long reg; | 585 | unsigned long reg; |
601 | 586 | ||
602 | reg = pci_read_reg(pcie, PCIEMSIFR); | 587 | reg = rcar_pci_read_reg(pcie, PCIEMSIFR); |
603 | 588 | ||
604 | /* MSI & INTx share an interrupt - we only handle MSI here */ | 589 | /* MSI & INTx share an interrupt - we only handle MSI here */ |
605 | if (!reg) | 590 | if (!reg) |
@@ -610,7 +595,7 @@ static irqreturn_t rcar_pcie_msi_irq(int irq, void *data) | |||
610 | unsigned int irq; | 595 | unsigned int irq; |
611 | 596 | ||
612 | /* clear the interrupt */ | 597 | /* clear the interrupt */ |
613 | pci_write_reg(pcie, 1 << index, PCIEMSIFR); | 598 | rcar_pci_write_reg(pcie, 1 << index, PCIEMSIFR); |
614 | 599 | ||
615 | irq = irq_find_mapping(msi->domain, index); | 600 | irq = irq_find_mapping(msi->domain, index); |
616 | if (irq) { | 601 | if (irq) { |
@@ -624,7 +609,7 @@ static irqreturn_t rcar_pcie_msi_irq(int irq, void *data) | |||
624 | } | 609 | } |
625 | 610 | ||
626 | /* see if there's any more pending in this vector */ | 611 | /* see if there's any more pending in this vector */ |
627 | reg = pci_read_reg(pcie, PCIEMSIFR); | 612 | reg = rcar_pci_read_reg(pcie, PCIEMSIFR); |
628 | } | 613 | } |
629 | 614 | ||
630 | return IRQ_HANDLED; | 615 | return IRQ_HANDLED; |
@@ -651,8 +636,8 @@ static int rcar_msi_setup_irq(struct msi_chip *chip, struct pci_dev *pdev, | |||
651 | 636 | ||
652 | irq_set_msi_desc(irq, desc); | 637 | irq_set_msi_desc(irq, desc); |
653 | 638 | ||
654 | msg.address_lo = pci_read_reg(pcie, PCIEMSIALR) & ~MSIFE; | 639 | msg.address_lo = rcar_pci_read_reg(pcie, PCIEMSIALR) & ~MSIFE; |
655 | msg.address_hi = pci_read_reg(pcie, PCIEMSIAUR); | 640 | msg.address_hi = rcar_pci_read_reg(pcie, PCIEMSIAUR); |
656 | msg.data = hwirq; | 641 | msg.data = hwirq; |
657 | 642 | ||
658 | write_msi_msg(irq, &msg); | 643 | write_msi_msg(irq, &msg); |
@@ -729,11 +714,11 @@ static int rcar_pcie_enable_msi(struct rcar_pcie *pcie) | |||
729 | msi->pages = __get_free_pages(GFP_KERNEL, 0); | 714 | msi->pages = __get_free_pages(GFP_KERNEL, 0); |
730 | base = virt_to_phys((void *)msi->pages); | 715 | base = virt_to_phys((void *)msi->pages); |
731 | 716 | ||
732 | pci_write_reg(pcie, base | MSIFE, PCIEMSIALR); | 717 | rcar_pci_write_reg(pcie, base | MSIFE, PCIEMSIALR); |
733 | pci_write_reg(pcie, 0, PCIEMSIAUR); | 718 | rcar_pci_write_reg(pcie, 0, PCIEMSIAUR); |
734 | 719 | ||
735 | /* enable all MSI interrupts */ | 720 | /* enable all MSI interrupts */ |
736 | pci_write_reg(pcie, 0xffffffff, PCIEMSIIER); | 721 | rcar_pci_write_reg(pcie, 0xffffffff, PCIEMSIIER); |
737 | 722 | ||
738 | return 0; | 723 | return 0; |
739 | 724 | ||
@@ -826,6 +811,7 @@ static int rcar_pcie_inbound_ranges(struct rcar_pcie *pcie, | |||
826 | if (cpu_addr > 0) { | 811 | if (cpu_addr > 0) { |
827 | unsigned long nr_zeros = __ffs64(cpu_addr); | 812 | unsigned long nr_zeros = __ffs64(cpu_addr); |
828 | u64 alignment = 1ULL << nr_zeros; | 813 | u64 alignment = 1ULL << nr_zeros; |
814 | |||
829 | size = min(range->size, alignment); | 815 | size = min(range->size, alignment); |
830 | } else { | 816 | } else { |
831 | size = range->size; | 817 | size = range->size; |
@@ -841,13 +827,13 @@ static int rcar_pcie_inbound_ranges(struct rcar_pcie *pcie, | |||
841 | * Set up 64-bit inbound regions as the range parser doesn't | 827 | * Set up 64-bit inbound regions as the range parser doesn't |
842 | * distinguish between 32 and 64-bit types. | 828 | * distinguish between 32 and 64-bit types. |
843 | */ | 829 | */ |
844 | pci_write_reg(pcie, lower_32_bits(pci_addr), PCIEPRAR(idx)); | 830 | rcar_pci_write_reg(pcie, lower_32_bits(pci_addr), PCIEPRAR(idx)); |
845 | pci_write_reg(pcie, lower_32_bits(cpu_addr), PCIELAR(idx)); | 831 | rcar_pci_write_reg(pcie, lower_32_bits(cpu_addr), PCIELAR(idx)); |
846 | pci_write_reg(pcie, lower_32_bits(mask) | flags, PCIELAMR(idx)); | 832 | rcar_pci_write_reg(pcie, lower_32_bits(mask) | flags, PCIELAMR(idx)); |
847 | 833 | ||
848 | pci_write_reg(pcie, upper_32_bits(pci_addr), PCIEPRAR(idx+1)); | 834 | rcar_pci_write_reg(pcie, upper_32_bits(pci_addr), PCIEPRAR(idx+1)); |
849 | pci_write_reg(pcie, upper_32_bits(cpu_addr), PCIELAR(idx+1)); | 835 | rcar_pci_write_reg(pcie, upper_32_bits(cpu_addr), PCIELAR(idx+1)); |
850 | pci_write_reg(pcie, 0, PCIELAMR(idx+1)); | 836 | rcar_pci_write_reg(pcie, 0, PCIELAMR(idx + 1)); |
851 | 837 | ||
852 | pci_addr += size; | 838 | pci_addr += size; |
853 | cpu_addr += size; | 839 | cpu_addr += size; |
@@ -952,7 +938,7 @@ static int rcar_pcie_probe(struct platform_device *pdev) | |||
952 | of_pci_range_to_resource(&range, pdev->dev.of_node, | 938 | of_pci_range_to_resource(&range, pdev->dev.of_node, |
953 | &pcie->res[win++]); | 939 | &pcie->res[win++]); |
954 | 940 | ||
955 | if (win > PCI_MAX_RESOURCES) | 941 | if (win > RCAR_PCI_MAX_RESOURCES) |
956 | break; | 942 | break; |
957 | } | 943 | } |
958 | 944 | ||
@@ -982,7 +968,7 @@ static int rcar_pcie_probe(struct platform_device *pdev) | |||
982 | return 0; | 968 | return 0; |
983 | } | 969 | } |
984 | 970 | ||
985 | data = pci_read_reg(pcie, MACSR); | 971 | data = rcar_pci_read_reg(pcie, MACSR); |
986 | dev_info(&pdev->dev, "PCIe x%d: link up\n", (data >> 20) & 0x3f); | 972 | dev_info(&pdev->dev, "PCIe x%d: link up\n", (data >> 20) & 0x3f); |
987 | 973 | ||
988 | rcar_pcie_enable(pcie); | 974 | rcar_pcie_enable(pcie); |
@@ -1003,4 +989,4 @@ module_platform_driver(rcar_pcie_driver); | |||
1003 | 989 | ||
1004 | MODULE_AUTHOR("Phil Edworthy <phil.edworthy@renesas.com>"); | 990 | MODULE_AUTHOR("Phil Edworthy <phil.edworthy@renesas.com>"); |
1005 | MODULE_DESCRIPTION("Renesas R-Car PCIe driver"); | 991 | MODULE_DESCRIPTION("Renesas R-Car PCIe driver"); |
1006 | MODULE_LICENSE("GPLv2"); | 992 | MODULE_LICENSE("GPL v2"); |