Lines Matching +full:pcie +full:- +full:x1
1 // SPDX-License-Identifier: GPL-2.0
3 * PCIe driver for Renesas R-Car SoCs
4 * Copyright (C) 2014-2020 Renesas Electronics Europe Ltd
7 * arch/sh/drivers/pci/pcie-sh7786.c
8 * arch/sh/drivers/pci/ops-sh7786.c
9 * Copyright (C) 2009 - 2011 Paul Mundt
16 #include <linux/clk-provider.h>
34 #include "pcie-rcar.h"
45 /* Structure representing the PCIe interface */
47 struct rcar_pcie pcie; member
65 ret = -EINVAL; in rcar_pcie_wakeup()
72 * Test if the PCIe controller received PM_ENTER_L1 DLLP and in rcar_pcie_wakeup()
73 * the PCIe controller is not in L1 link state. If true, apply in rcar_pcie_wakeup()
99 static u32 rcar_read_conf(struct rcar_pcie *pcie, int where) in rcar_read_conf() argument
102 u32 val = rcar_pci_read_reg(pcie, where & ~3); in rcar_read_conf()
109 " .arch armv7-a\n" \
124 static int rcar_pci_write_reg_workaround(struct rcar_pcie *pcie, u32 val, in rcar_pci_write_reg_workaround() argument
131 : "+r"(error):"r"(val), "r"(pcie->base + reg) : "memory"); in rcar_pci_write_reg_workaround()
133 rcar_pci_write_reg(pcie, val, reg); in rcar_pci_write_reg_workaround()
138 static int rcar_pci_read_reg_workaround(struct rcar_pcie *pcie, u32 *val, in rcar_pci_read_reg_workaround() argument
145 : "+r"(error), "=r"(*val) : "r"(pcie->base + reg) : "memory"); in rcar_pci_read_reg_workaround()
150 *val = rcar_pci_read_reg(pcie, reg); in rcar_pci_read_reg_workaround()
160 struct rcar_pcie *pcie = &host->pcie; in rcar_pcie_config_access() local
165 ret = rcar_pcie_wakeup(pcie->dev, pcie->base); in rcar_pcie_config_access()
177 * While each channel has its own memory-mapped extended config in rcar_pcie_config_access()
185 * the same channel <-> device access works for any PCI_SLOT() in rcar_pcie_config_access()
187 * space to devfn 0 in order to enable self-enumeration. In this in rcar_pcie_config_access()
196 *data = rcar_pci_read_reg(pcie, PCICONF(index)); in rcar_pcie_config_access()
198 rcar_pci_write_reg(pcie, *data, PCICONF(index)); in rcar_pcie_config_access()
204 rcar_pci_write_reg(pcie, rcar_pci_read_reg(pcie, PCIEERRFR), PCIEERRFR); in rcar_pcie_config_access()
207 rcar_pci_write_reg(pcie, PCIE_CONF_BUS(bus->number) | in rcar_pcie_config_access()
211 if (pci_is_root_bus(bus->parent)) in rcar_pcie_config_access()
212 rcar_pci_write_reg(pcie, PCIECCTLR_CCIE | TYPE0, PCIECCTLR); in rcar_pcie_config_access()
214 rcar_pci_write_reg(pcie, PCIECCTLR_CCIE | TYPE1, PCIECCTLR); in rcar_pcie_config_access()
217 if (rcar_pci_read_reg(pcie, PCIEERRFR) & UNSUPPORTED_REQUEST) in rcar_pcie_config_access()
221 if (rcar_read_conf(pcie, RCONF(PCI_STATUS)) & in rcar_pcie_config_access()
226 ret = rcar_pci_read_reg_workaround(pcie, data, PCIECDR); in rcar_pcie_config_access()
228 ret = rcar_pci_write_reg_workaround(pcie, *data, PCIECDR); in rcar_pcie_config_access()
231 rcar_pci_write_reg(pcie, 0, PCIECCTLR); in rcar_pcie_config_access()
239 struct rcar_pcie_host *host = bus->sysdata; in rcar_pcie_read_conf()
252 dev_dbg(&bus->dev, "pcie-config-read: bus=%3d devfn=0x%04x where=0x%04x size=%d val=0x%08x\n", in rcar_pcie_read_conf()
253 bus->number, devfn, where, size, *val); in rcar_pcie_read_conf()
262 struct rcar_pcie_host *host = bus->sysdata; in rcar_pcie_write_conf()
272 dev_dbg(&bus->dev, "pcie-config-write: bus=%3d devfn=0x%04x where=0x%04x size=%d val=0x%08x\n", in rcar_pcie_write_conf()
273 bus->number, devfn, where, size, val); in rcar_pcie_write_conf()
297 static void rcar_pcie_force_speedup(struct rcar_pcie *pcie) in rcar_pcie_force_speedup() argument
299 struct device *dev = pcie->dev; in rcar_pcie_force_speedup()
303 if ((rcar_pci_read_reg(pcie, MACS2R) & LINK_SPEED) != LINK_SPEED_5_0GTS) in rcar_pcie_force_speedup()
306 if (rcar_pci_read_reg(pcie, MACCTLR) & SPEED_CHANGE) { in rcar_pcie_force_speedup()
311 macsr = rcar_pci_read_reg(pcie, MACSR); in rcar_pcie_force_speedup()
316 rcar_rmw32(pcie, EXPCAP(12), PCI_EXP_LNKSTA_CLS, in rcar_pcie_force_speedup()
320 rcar_rmw32(pcie, MACCGSPSETR, SPCNGRSN, 0); in rcar_pcie_force_speedup()
324 rcar_pci_write_reg(pcie, macsr, MACSR); in rcar_pcie_force_speedup()
327 rcar_rmw32(pcie, MACCTLR, SPEED_CHANGE, SPEED_CHANGE); in rcar_pcie_force_speedup()
329 while (timeout--) { in rcar_pcie_force_speedup()
330 macsr = rcar_pci_read_reg(pcie, MACSR); in rcar_pcie_force_speedup()
333 rcar_pci_write_reg(pcie, macsr, MACSR); in rcar_pcie_force_speedup()
353 struct rcar_pcie *pcie = &host->pcie; in rcar_pcie_hw_enable() local
360 rcar_pcie_force_speedup(pcie); in rcar_pcie_hw_enable()
363 resource_list_for_each_entry(win, &bridge->windows) { in rcar_pcie_hw_enable()
364 struct resource *res = win->res; in rcar_pcie_hw_enable()
366 if (!res->flags) in rcar_pcie_hw_enable()
372 rcar_pcie_set_outbound(pcie, i, win); in rcar_pcie_hw_enable()
387 bridge->sysdata = host; in rcar_pcie_enable()
388 bridge->ops = &rcar_pcie_ops; in rcar_pcie_enable()
393 static int phy_wait_for_ack(struct rcar_pcie *pcie) in phy_wait_for_ack() argument
395 struct device *dev = pcie->dev; in phy_wait_for_ack()
398 while (timeout--) { in phy_wait_for_ack()
399 if (rcar_pci_read_reg(pcie, H1_PCIEPHYADRR) & PHY_ACK) in phy_wait_for_ack()
405 dev_err(dev, "Access to PCIe phy timed out\n"); in phy_wait_for_ack()
407 return -ETIMEDOUT; in phy_wait_for_ack()
410 static void phy_write_reg(struct rcar_pcie *pcie, in phy_write_reg() argument
422 rcar_pci_write_reg(pcie, data, H1_PCIEPHYDOUTR); in phy_write_reg()
423 rcar_pci_write_reg(pcie, phyaddr, H1_PCIEPHYADRR); in phy_write_reg()
426 phy_wait_for_ack(pcie); in phy_write_reg()
429 rcar_pci_write_reg(pcie, 0, H1_PCIEPHYDOUTR); in phy_write_reg()
430 rcar_pci_write_reg(pcie, 0, H1_PCIEPHYADRR); in phy_write_reg()
433 phy_wait_for_ack(pcie); in phy_write_reg()
436 static int rcar_pcie_hw_init(struct rcar_pcie *pcie) in rcar_pcie_hw_init() argument
441 rcar_pci_write_reg(pcie, 0, PCIETCTLR); in rcar_pcie_hw_init()
444 rcar_pci_write_reg(pcie, 1, PCIEMSR); in rcar_pcie_hw_init()
446 err = rcar_pcie_wait_for_phyrdy(pcie); in rcar_pcie_hw_init()
455 rcar_pci_write_reg(pcie, PCI_CLASS_BRIDGE_PCI_NORMAL << 8, IDSETR1); in rcar_pcie_hw_init()
461 rcar_rmw32(pcie, RCONF(PCI_SECONDARY_BUS), 0xff, 1); in rcar_pcie_hw_init()
462 rcar_rmw32(pcie, RCONF(PCI_SUBORDINATE_BUS), 0xff, 1); in rcar_pcie_hw_init()
465 rcar_rmw32(pcie, REXPCAP(0), 0xff, PCI_CAP_ID_EXP); in rcar_pcie_hw_init()
466 rcar_rmw32(pcie, REXPCAP(PCI_EXP_FLAGS), in rcar_pcie_hw_init()
468 rcar_rmw32(pcie, RCONF(PCI_HEADER_TYPE), PCI_HEADER_TYPE_MASK, in rcar_pcie_hw_init()
472 rcar_rmw32(pcie, REXPCAP(PCI_EXP_LNKCAP), PCI_EXP_LNKCAP_DLLLARC, in rcar_pcie_hw_init()
476 rcar_rmw32(pcie, REXPCAP(PCI_EXP_SLTCAP), PCI_EXP_SLTCAP_PSN, 0); in rcar_pcie_hw_init()
479 rcar_rmw32(pcie, TLCTLR + 1, 0x3f, 50); in rcar_pcie_hw_init()
482 rcar_rmw32(pcie, RVCCAP(0), 0xfff00000, 0); in rcar_pcie_hw_init()
486 rcar_pci_write_reg(pcie, 0x801f0000, PCIEMSITXR); in rcar_pcie_hw_init()
488 rcar_pci_write_reg(pcie, MACCTLR_INIT_VAL, MACCTLR); in rcar_pcie_hw_init()
490 /* Finish initialization - establish a PCI Express link */ in rcar_pcie_hw_init()
491 rcar_pci_write_reg(pcie, CFINIT, PCIETCTLR); in rcar_pcie_hw_init()
494 err = rcar_pcie_wait_for_dl(pcie); in rcar_pcie_hw_init()
499 rcar_rmw32(pcie, PCIEINTXR, 0, 0xF << 8); in rcar_pcie_hw_init()
508 struct rcar_pcie *pcie = &host->pcie; in rcar_pcie_phy_init_h1() local
511 phy_write_reg(pcie, 0, 0x42, 0x1, 0x0EC34191); in rcar_pcie_phy_init_h1()
512 phy_write_reg(pcie, 1, 0x42, 0x1, 0x0EC34180); in rcar_pcie_phy_init_h1()
513 phy_write_reg(pcie, 0, 0x43, 0x1, 0x00210188); in rcar_pcie_phy_init_h1()
514 phy_write_reg(pcie, 1, 0x43, 0x1, 0x00210188); in rcar_pcie_phy_init_h1()
515 phy_write_reg(pcie, 0, 0x44, 0x1, 0x015C0014); in rcar_pcie_phy_init_h1()
516 phy_write_reg(pcie, 1, 0x44, 0x1, 0x015C0014); in rcar_pcie_phy_init_h1()
517 phy_write_reg(pcie, 1, 0x4C, 0x1, 0x786174A0); in rcar_pcie_phy_init_h1()
518 phy_write_reg(pcie, 1, 0x4D, 0x1, 0x048000BB); in rcar_pcie_phy_init_h1()
519 phy_write_reg(pcie, 0, 0x51, 0x1, 0x079EC062); in rcar_pcie_phy_init_h1()
520 phy_write_reg(pcie, 0, 0x52, 0x1, 0x20000000); in rcar_pcie_phy_init_h1()
521 phy_write_reg(pcie, 1, 0x52, 0x1, 0x20000000); in rcar_pcie_phy_init_h1()
522 phy_write_reg(pcie, 1, 0x56, 0x1, 0x00003806); in rcar_pcie_phy_init_h1()
524 phy_write_reg(pcie, 0, 0x60, 0x1, 0x004B03A5); in rcar_pcie_phy_init_h1()
525 phy_write_reg(pcie, 0, 0x64, 0x1, 0x3F0F1F0F); in rcar_pcie_phy_init_h1()
526 phy_write_reg(pcie, 0, 0x66, 0x1, 0x00008000); in rcar_pcie_phy_init_h1()
533 struct rcar_pcie *pcie = &host->pcie; in rcar_pcie_phy_init_gen2() local
536 * These settings come from the R-Car Series, 2nd Generation User's in rcar_pcie_phy_init_gen2()
539 rcar_pci_write_reg(pcie, 0x000f0030, GEN2_PCIEPHYADDR); in rcar_pcie_phy_init_gen2()
540 rcar_pci_write_reg(pcie, 0x00381203, GEN2_PCIEPHYDATA); in rcar_pcie_phy_init_gen2()
541 rcar_pci_write_reg(pcie, 0x00000001, GEN2_PCIEPHYCTRL); in rcar_pcie_phy_init_gen2()
542 rcar_pci_write_reg(pcie, 0x00000006, GEN2_PCIEPHYCTRL); in rcar_pcie_phy_init_gen2()
544 rcar_pci_write_reg(pcie, 0x000f0054, GEN2_PCIEPHYADDR); in rcar_pcie_phy_init_gen2()
546 rcar_pci_write_reg(pcie, 0x13802007, GEN2_PCIEPHYDATA); in rcar_pcie_phy_init_gen2()
547 rcar_pci_write_reg(pcie, 0x00000001, GEN2_PCIEPHYCTRL); in rcar_pcie_phy_init_gen2()
548 rcar_pci_write_reg(pcie, 0x00000006, GEN2_PCIEPHYCTRL); in rcar_pcie_phy_init_gen2()
557 err = phy_init(host->phy); in rcar_pcie_phy_init_gen3()
561 err = phy_power_on(host->phy); in rcar_pcie_phy_init_gen3()
563 phy_exit(host->phy); in rcar_pcie_phy_init_gen3()
571 struct rcar_pcie *pcie = &host->pcie; in rcar_pcie_msi_irq() local
572 struct rcar_msi *msi = &host->msi; in rcar_pcie_msi_irq()
573 struct device *dev = pcie->dev; in rcar_pcie_msi_irq()
576 reg = rcar_pci_read_reg(pcie, PCIEMSIFR); in rcar_pcie_msi_irq()
578 /* MSI & INTx share an interrupt - we only handle MSI here */ in rcar_pcie_msi_irq()
586 ret = generic_handle_domain_irq(msi->domain->parent, index); in rcar_pcie_msi_irq()
590 rcar_pci_write_reg(pcie, BIT(index), PCIEMSIFR); in rcar_pcie_msi_irq()
594 reg = rcar_pci_read_reg(pcie, PCIEMSIFR); in rcar_pcie_msi_irq()
618 .name = "PCIe MSI",
627 struct rcar_pcie *pcie = &msi_to_host(msi)->pcie; in rcar_msi_irq_ack() local
630 rcar_pci_write_reg(pcie, BIT(d->hwirq), PCIEMSIFR); in rcar_msi_irq_ack()
636 struct rcar_pcie *pcie = &msi_to_host(msi)->pcie; in rcar_msi_irq_mask() local
640 spin_lock_irqsave(&msi->mask_lock, flags); in rcar_msi_irq_mask()
641 value = rcar_pci_read_reg(pcie, PCIEMSIIER); in rcar_msi_irq_mask()
642 value &= ~BIT(d->hwirq); in rcar_msi_irq_mask()
643 rcar_pci_write_reg(pcie, value, PCIEMSIIER); in rcar_msi_irq_mask()
644 spin_unlock_irqrestore(&msi->mask_lock, flags); in rcar_msi_irq_mask()
650 struct rcar_pcie *pcie = &msi_to_host(msi)->pcie; in rcar_msi_irq_unmask() local
654 spin_lock_irqsave(&msi->mask_lock, flags); in rcar_msi_irq_unmask()
655 value = rcar_pci_read_reg(pcie, PCIEMSIIER); in rcar_msi_irq_unmask()
656 value |= BIT(d->hwirq); in rcar_msi_irq_unmask()
657 rcar_pci_write_reg(pcie, value, PCIEMSIIER); in rcar_msi_irq_unmask()
658 spin_unlock_irqrestore(&msi->mask_lock, flags); in rcar_msi_irq_unmask()
664 struct rcar_pcie *pcie = &msi_to_host(msi)->pcie; in rcar_compose_msi_msg() local
666 msg->address_lo = rcar_pci_read_reg(pcie, PCIEMSIALR) & ~MSIFE; in rcar_compose_msi_msg()
667 msg->address_hi = rcar_pci_read_reg(pcie, PCIEMSIAUR); in rcar_compose_msi_msg()
668 msg->data = data->hwirq; in rcar_compose_msi_msg()
672 .name = "R-Car MSI",
682 struct rcar_msi *msi = domain->host_data; in rcar_msi_domain_alloc()
686 mutex_lock(&msi->map_lock); in rcar_msi_domain_alloc()
688 hwirq = bitmap_find_free_region(msi->used, INT_PCI_MSI_NR, order_base_2(nr_irqs)); in rcar_msi_domain_alloc()
690 mutex_unlock(&msi->map_lock); in rcar_msi_domain_alloc()
693 return -ENOSPC; in rcar_msi_domain_alloc()
697 &rcar_msi_bottom_chip, domain->host_data, in rcar_msi_domain_alloc()
707 struct rcar_msi *msi = domain->host_data; in rcar_msi_domain_free()
709 mutex_lock(&msi->map_lock); in rcar_msi_domain_free()
711 bitmap_release_region(msi->used, d->hwirq, order_base_2(nr_irqs)); in rcar_msi_domain_free()
713 mutex_unlock(&msi->map_lock); in rcar_msi_domain_free()
729 struct rcar_pcie *pcie = &msi_to_host(msi)->pcie; in rcar_allocate_domains() local
730 struct fwnode_handle *fwnode = dev_fwnode(pcie->dev); in rcar_allocate_domains()
736 dev_err(pcie->dev, "failed to create IRQ domain\n"); in rcar_allocate_domains()
737 return -ENOMEM; in rcar_allocate_domains()
741 msi->domain = pci_msi_create_irq_domain(fwnode, &rcar_msi_info, parent); in rcar_allocate_domains()
742 if (!msi->domain) { in rcar_allocate_domains()
743 dev_err(pcie->dev, "failed to create MSI domain\n"); in rcar_allocate_domains()
745 return -ENOMEM; in rcar_allocate_domains()
753 struct irq_domain *parent = msi->domain->parent; in rcar_free_domains()
755 irq_domain_remove(msi->domain); in rcar_free_domains()
761 struct rcar_pcie *pcie = &host->pcie; in rcar_pcie_enable_msi() local
762 struct device *dev = pcie->dev; in rcar_pcie_enable_msi()
763 struct rcar_msi *msi = &host->msi; in rcar_pcie_enable_msi()
767 mutex_init(&msi->map_lock); in rcar_pcie_enable_msi()
768 spin_lock_init(&msi->mask_lock); in rcar_pcie_enable_msi()
770 err = of_address_to_resource(dev->of_node, 0, &res); in rcar_pcie_enable_msi()
778 /* Two irqs are for MSI, but they are also used for non-MSI irqs */ in rcar_pcie_enable_msi()
779 err = devm_request_irq(dev, msi->irq1, rcar_pcie_msi_irq, in rcar_pcie_enable_msi()
787 err = devm_request_irq(dev, msi->irq2, rcar_pcie_msi_irq, in rcar_pcie_enable_msi()
796 rcar_pci_write_reg(pcie, 0, PCIEMSIIER); in rcar_pcie_enable_msi()
800 * is guaranteed to be in the low 32bit range on any R-Car HW. in rcar_pcie_enable_msi()
802 rcar_pci_write_reg(pcie, lower_32_bits(res.start) | MSIFE, PCIEMSIALR); in rcar_pcie_enable_msi()
803 rcar_pci_write_reg(pcie, upper_32_bits(res.start), PCIEMSIAUR); in rcar_pcie_enable_msi()
814 struct rcar_pcie *pcie = &host->pcie; in rcar_pcie_teardown_msi() local
817 rcar_pci_write_reg(pcie, 0, PCIEMSIIER); in rcar_pcie_teardown_msi()
820 rcar_pci_write_reg(pcie, 0, PCIEMSIALR); in rcar_pcie_teardown_msi()
822 rcar_free_domains(&host->msi); in rcar_pcie_teardown_msi()
827 struct rcar_pcie *pcie = &host->pcie; in rcar_pcie_get_resources() local
828 struct device *dev = pcie->dev; in rcar_pcie_get_resources()
832 host->phy = devm_phy_optional_get(dev, "pcie"); in rcar_pcie_get_resources()
833 if (IS_ERR(host->phy)) in rcar_pcie_get_resources()
834 return PTR_ERR(host->phy); in rcar_pcie_get_resources()
836 err = of_address_to_resource(dev->of_node, 0, &res); in rcar_pcie_get_resources()
840 pcie->base = devm_ioremap_resource(dev, &res); in rcar_pcie_get_resources()
841 if (IS_ERR(pcie->base)) in rcar_pcie_get_resources()
842 return PTR_ERR(pcie->base); in rcar_pcie_get_resources()
844 host->bus_clk = devm_clk_get(dev, "pcie_bus"); in rcar_pcie_get_resources()
845 if (IS_ERR(host->bus_clk)) { in rcar_pcie_get_resources()
846 dev_err(dev, "cannot get pcie bus clock\n"); in rcar_pcie_get_resources()
847 return PTR_ERR(host->bus_clk); in rcar_pcie_get_resources()
850 i = irq_of_parse_and_map(dev->of_node, 0); in rcar_pcie_get_resources()
853 err = -ENOENT; in rcar_pcie_get_resources()
856 host->msi.irq1 = i; in rcar_pcie_get_resources()
858 i = irq_of_parse_and_map(dev->of_node, 1); in rcar_pcie_get_resources()
861 err = -ENOENT; in rcar_pcie_get_resources()
864 host->msi.irq2 = i; in rcar_pcie_get_resources()
869 irq_dispose_mapping(host->msi.irq1); in rcar_pcie_get_resources()
874 static int rcar_pcie_inbound_ranges(struct rcar_pcie *pcie, in rcar_pcie_inbound_ranges() argument
878 u64 restype = entry->res->flags; in rcar_pcie_inbound_ranges()
879 u64 cpu_addr = entry->res->start; in rcar_pcie_inbound_ranges()
880 u64 cpu_end = entry->res->end; in rcar_pcie_inbound_ranges()
881 u64 pci_addr = entry->res->start - entry->offset; in rcar_pcie_inbound_ranges()
884 u64 size = resource_size(entry->res); in rcar_pcie_inbound_ranges()
891 if (idx >= MAX_NR_INBOUND_MAPS - 1) { in rcar_pcie_inbound_ranges()
892 dev_err(pcie->dev, "Failed to map inbound regions!\n"); in rcar_pcie_inbound_ranges()
893 return -EINVAL; in rcar_pcie_inbound_ranges()
909 mask = roundup_pow_of_two(size) - 1; in rcar_pcie_inbound_ranges()
912 rcar_pcie_set_inbound(pcie, cpu_addr, pci_addr, in rcar_pcie_inbound_ranges()
930 resource_list_for_each_entry(entry, &bridge->dma_ranges) { in rcar_pcie_parse_map_dma_ranges()
931 err = rcar_pcie_inbound_ranges(&host->pcie, entry, &index); in rcar_pcie_parse_map_dma_ranges()
940 { .compatible = "renesas,pcie-r8a7779",
942 { .compatible = "renesas,pcie-r8a7790",
944 { .compatible = "renesas,pcie-r8a7791",
946 { .compatible = "renesas,pcie-rcar-gen2",
948 { .compatible = "renesas,pcie-r8a7795",
950 { .compatible = "renesas,pcie-rcar-gen3",
964 struct device *dev = &pdev->dev; in rcar_pcie_probe()
967 struct rcar_pcie *pcie; in rcar_pcie_probe() local
974 return -ENOMEM; in rcar_pcie_probe()
977 pcie = &host->pcie; in rcar_pcie_probe()
978 pcie->dev = dev; in rcar_pcie_probe()
983 if (err < 0 && err != -ENODEV) in rcar_pcie_probe()
988 pm_runtime_enable(pcie->dev); in rcar_pcie_probe()
989 err = pm_runtime_get_sync(pcie->dev); in rcar_pcie_probe()
991 dev_err(pcie->dev, "pm_runtime_get_sync failed\n"); in rcar_pcie_probe()
1001 err = clk_prepare_enable(host->bus_clk); in rcar_pcie_probe()
1011 host->phy_init_fn = of_device_get_match_data(dev); in rcar_pcie_probe()
1012 err = host->phy_init_fn(host); in rcar_pcie_probe()
1014 dev_err(dev, "failed to init PCIe PHY\n"); in rcar_pcie_probe()
1019 if (rcar_pcie_hw_init(pcie)) { in rcar_pcie_probe()
1020 dev_info(dev, "PCIe link down\n"); in rcar_pcie_probe()
1021 err = -ENODEV; in rcar_pcie_probe()
1025 data = rcar_pci_read_reg(pcie, MACSR); in rcar_pcie_probe()
1026 dev_info(dev, "PCIe x%d: link up\n", (data >> 20) & 0x3f); in rcar_pcie_probe()
1049 if (host->phy) { in rcar_pcie_probe()
1050 phy_power_off(host->phy); in rcar_pcie_probe()
1051 phy_exit(host->phy); in rcar_pcie_probe()
1055 clk_disable_unprepare(host->bus_clk); in rcar_pcie_probe()
1058 irq_dispose_mapping(host->msi.irq2); in rcar_pcie_probe()
1059 irq_dispose_mapping(host->msi.irq1); in rcar_pcie_probe()
1071 struct rcar_pcie *pcie = &host->pcie; in rcar_pcie_resume() local
1080 err = host->phy_init_fn(host); in rcar_pcie_resume()
1082 dev_info(dev, "PCIe link down\n"); in rcar_pcie_resume()
1086 data = rcar_pci_read_reg(pcie, MACSR); in rcar_pcie_resume()
1087 dev_info(dev, "PCIe x%d: link up\n", (data >> 20) & 0x3f); in rcar_pcie_resume()
1094 of_address_to_resource(dev->of_node, 0, &res); in rcar_pcie_resume()
1095 rcar_pci_write_reg(pcie, upper_32_bits(res.start), PCIEMSIAUR); in rcar_pcie_resume()
1096 rcar_pci_write_reg(pcie, lower_32_bits(res.start) | MSIFE, PCIEMSIALR); in rcar_pcie_resume()
1098 bitmap_to_arr32(&val, host->msi.used, INT_PCI_MSI_NR); in rcar_pcie_resume()
1099 rcar_pci_write_reg(pcie, val, PCIEMSIIER); in rcar_pcie_resume()
1110 struct rcar_pcie *pcie = &host->pcie; in rcar_pcie_resume_noirq() local
1112 if (rcar_pci_read_reg(pcie, PMSR) && in rcar_pcie_resume_noirq()
1113 !(rcar_pci_read_reg(pcie, PCIETCTLR) & DL_DOWN)) in rcar_pcie_resume_noirq()
1116 /* Re-establish the PCIe link */ in rcar_pcie_resume_noirq()
1117 rcar_pci_write_reg(pcie, MACCTLR_INIT_VAL, MACCTLR); in rcar_pcie_resume_noirq()
1118 rcar_pci_write_reg(pcie, CFINIT, PCIETCTLR); in rcar_pcie_resume_noirq()
1119 return rcar_pcie_wait_for_dl(pcie); in rcar_pcie_resume_noirq()
1129 .name = "rcar-pcie",
1145 { .compatible = "renesas,pcie-r8a7779" },
1146 { .compatible = "renesas,pcie-r8a7790" },
1147 { .compatible = "renesas,pcie-r8a7791" },
1148 { .compatible = "renesas,pcie-rcar-gen2" },