Lines Matching full:dra7xx
3 * pcie-dra7xx - PCIe controller driver for TI DRA7xx SoCs
34 /* PCIe controller wrapper DRA7XX configuration registers */
121 struct dra7xx_pcie *dra7xx = to_dra7xx_pcie(pci); in dra7xx_pcie_link_up() local
122 u32 reg = dra7xx_pcie_readl(dra7xx, PCIECTRL_DRA7XX_CONF_PHY_CS); in dra7xx_pcie_link_up()
129 struct dra7xx_pcie *dra7xx = to_dra7xx_pcie(pci); in dra7xx_pcie_stop_link() local
132 reg = dra7xx_pcie_readl(dra7xx, PCIECTRL_DRA7XX_CONF_DEVICE_CMD); in dra7xx_pcie_stop_link()
134 dra7xx_pcie_writel(dra7xx, PCIECTRL_DRA7XX_CONF_DEVICE_CMD, reg); in dra7xx_pcie_stop_link()
139 struct dra7xx_pcie *dra7xx = to_dra7xx_pcie(pci); in dra7xx_pcie_establish_link() local
148 reg = dra7xx_pcie_readl(dra7xx, PCIECTRL_DRA7XX_CONF_DEVICE_CMD); in dra7xx_pcie_establish_link()
150 dra7xx_pcie_writel(dra7xx, PCIECTRL_DRA7XX_CONF_DEVICE_CMD, reg); in dra7xx_pcie_establish_link()
155 static void dra7xx_pcie_enable_msi_interrupts(struct dra7xx_pcie *dra7xx) in dra7xx_pcie_enable_msi_interrupts() argument
157 dra7xx_pcie_writel(dra7xx, PCIECTRL_DRA7XX_CONF_IRQSTATUS_MSI, in dra7xx_pcie_enable_msi_interrupts()
160 dra7xx_pcie_writel(dra7xx, in dra7xx_pcie_enable_msi_interrupts()
165 static void dra7xx_pcie_enable_wrapper_interrupts(struct dra7xx_pcie *dra7xx) in dra7xx_pcie_enable_wrapper_interrupts() argument
167 dra7xx_pcie_writel(dra7xx, PCIECTRL_DRA7XX_CONF_IRQSTATUS_MAIN, in dra7xx_pcie_enable_wrapper_interrupts()
169 dra7xx_pcie_writel(dra7xx, PCIECTRL_DRA7XX_CONF_IRQENABLE_SET_MAIN, in dra7xx_pcie_enable_wrapper_interrupts()
173 static void dra7xx_pcie_enable_interrupts(struct dra7xx_pcie *dra7xx) in dra7xx_pcie_enable_interrupts() argument
175 dra7xx_pcie_enable_wrapper_interrupts(dra7xx); in dra7xx_pcie_enable_interrupts()
176 dra7xx_pcie_enable_msi_interrupts(dra7xx); in dra7xx_pcie_enable_interrupts()
182 struct dra7xx_pcie *dra7xx = to_dra7xx_pcie(pci); in dra7xx_pcie_host_init() local
189 dra7xx_pcie_enable_interrupts(dra7xx); in dra7xx_pcie_host_init()
261 struct dra7xx_pcie *dra7xx; in dra7xx_pcie_msi_irq_handler() local
271 dra7xx = to_dra7xx_pcie(pci); in dra7xx_pcie_msi_irq_handler()
273 reg = dra7xx_pcie_readl(dra7xx, PCIECTRL_DRA7XX_CONF_IRQSTATUS_MSI); in dra7xx_pcie_msi_irq_handler()
274 dra7xx_pcie_writel(dra7xx, PCIECTRL_DRA7XX_CONF_IRQSTATUS_MSI, reg); in dra7xx_pcie_msi_irq_handler()
285 virq = irq_find_mapping(dra7xx->irq_domain, bit); in dra7xx_pcie_msi_irq_handler()
297 struct dra7xx_pcie *dra7xx = arg; in dra7xx_pcie_irq_handler() local
298 struct dw_pcie *pci = dra7xx->pci; in dra7xx_pcie_irq_handler()
303 reg = dra7xx_pcie_readl(dra7xx, PCIECTRL_DRA7XX_CONF_IRQSTATUS_MAIN); in dra7xx_pcie_irq_handler()
338 if (dra7xx->mode == DW_PCIE_EP_TYPE) in dra7xx_pcie_irq_handler()
349 dra7xx_pcie_writel(dra7xx, PCIECTRL_DRA7XX_CONF_IRQSTATUS_MAIN, reg); in dra7xx_pcie_irq_handler()
358 struct dra7xx_pcie *dra7xx = to_dra7xx_pcie(pci); in dra7xx_pcie_init_irq_domain() local
369 dra7xx->irq_domain = irq_domain_add_linear(pcie_intc_node, PCI_NUM_INTX, in dra7xx_pcie_init_irq_domain()
372 if (!dra7xx->irq_domain) { in dra7xx_pcie_init_irq_domain()
458 .name = "DRA7XX-PCI-MSI",
512 struct dra7xx_pcie *dra7xx = to_dra7xx_pcie(pci); in dra7xx_pcie_ep_init() local
518 dra7xx_pcie_enable_wrapper_interrupts(dra7xx); in dra7xx_pcie_ep_init()
521 static void dra7xx_pcie_raise_legacy_irq(struct dra7xx_pcie *dra7xx) in dra7xx_pcie_raise_legacy_irq() argument
523 dra7xx_pcie_writel(dra7xx, PCIECTRL_TI_CONF_INTX_ASSERT, 0x1); in dra7xx_pcie_raise_legacy_irq()
525 dra7xx_pcie_writel(dra7xx, PCIECTRL_TI_CONF_INTX_DEASSERT, 0x1); in dra7xx_pcie_raise_legacy_irq()
528 static void dra7xx_pcie_raise_msi_irq(struct dra7xx_pcie *dra7xx, in dra7xx_pcie_raise_msi_irq() argument
535 dra7xx_pcie_writel(dra7xx, PCIECTRL_TI_CONF_MSI_XMT, reg); in dra7xx_pcie_raise_msi_irq()
542 struct dra7xx_pcie *dra7xx = to_dra7xx_pcie(pci); in dra7xx_pcie_raise_irq() local
546 dra7xx_pcie_raise_legacy_irq(dra7xx); in dra7xx_pcie_raise_irq()
549 dra7xx_pcie_raise_msi_irq(dra7xx, interrupt_num); in dra7xx_pcie_raise_irq()
576 static int __init dra7xx_add_pcie_ep(struct dra7xx_pcie *dra7xx, in dra7xx_add_pcie_ep() argument
583 struct dw_pcie *pci = dra7xx->pci; in dra7xx_add_pcie_ep()
613 static int __init dra7xx_add_pcie_port(struct dra7xx_pcie *dra7xx, in dra7xx_add_pcie_port() argument
617 struct dw_pcie *pci = dra7xx->pci; in dra7xx_add_pcie_port()
651 static void dra7xx_pcie_disable_phy(struct dra7xx_pcie *dra7xx) in dra7xx_pcie_disable_phy() argument
653 int phy_count = dra7xx->phy_count; in dra7xx_pcie_disable_phy()
656 phy_power_off(dra7xx->phy[phy_count]); in dra7xx_pcie_disable_phy()
657 phy_exit(dra7xx->phy[phy_count]); in dra7xx_pcie_disable_phy()
661 static int dra7xx_pcie_enable_phy(struct dra7xx_pcie *dra7xx) in dra7xx_pcie_enable_phy() argument
663 int phy_count = dra7xx->phy_count; in dra7xx_pcie_enable_phy()
668 ret = phy_set_mode(dra7xx->phy[i], PHY_MODE_PCIE); in dra7xx_pcie_enable_phy()
672 ret = phy_init(dra7xx->phy[i]); in dra7xx_pcie_enable_phy()
676 ret = phy_power_on(dra7xx->phy[i]); in dra7xx_pcie_enable_phy()
678 phy_exit(dra7xx->phy[i]); in dra7xx_pcie_enable_phy()
687 phy_power_off(dra7xx->phy[i]); in dra7xx_pcie_enable_phy()
688 phy_exit(dra7xx->phy[i]); in dra7xx_pcie_enable_phy()
752 * @dra7xx: the dra7xx device where the workaround should be applied
831 struct dra7xx_pcie *dra7xx; in dra7xx_pcie_probe() local
849 dra7xx = devm_kzalloc(dev, sizeof(*dra7xx), GFP_KERNEL); in dra7xx_pcie_probe()
850 if (!dra7xx) in dra7xx_pcie_probe()
895 dra7xx->base = base; in dra7xx_pcie_probe()
896 dra7xx->phy = phy; in dra7xx_pcie_probe()
897 dra7xx->pci = pci; in dra7xx_pcie_probe()
898 dra7xx->phy_count = phy_count; in dra7xx_pcie_probe()
903 dra7xx->phy_count = 1; /* Fallback to x1 lane mode */ in dra7xx_pcie_probe()
906 ret = dra7xx_pcie_enable_phy(dra7xx); in dra7xx_pcie_probe()
912 platform_set_drvdata(pdev, dra7xx); in dra7xx_pcie_probe()
928 reg = dra7xx_pcie_readl(dra7xx, PCIECTRL_DRA7XX_CONF_DEVICE_CMD); in dra7xx_pcie_probe()
930 dra7xx_pcie_writel(dra7xx, PCIECTRL_DRA7XX_CONF_DEVICE_CMD, reg); in dra7xx_pcie_probe()
939 dra7xx_pcie_writel(dra7xx, PCIECTRL_TI_CONF_DEVICE_TYPE, in dra7xx_pcie_probe()
946 ret = dra7xx_add_pcie_port(dra7xx, pdev); in dra7xx_pcie_probe()
956 dra7xx_pcie_writel(dra7xx, PCIECTRL_TI_CONF_DEVICE_TYPE, in dra7xx_pcie_probe()
963 ret = dra7xx_add_pcie_ep(dra7xx, pdev); in dra7xx_pcie_probe()
970 dra7xx->mode = mode; in dra7xx_pcie_probe()
973 IRQF_SHARED, "dra7xx-pcie-main", dra7xx); in dra7xx_pcie_probe()
985 dra7xx_pcie_disable_phy(dra7xx); in dra7xx_pcie_probe()
997 struct dra7xx_pcie *dra7xx = dev_get_drvdata(dev); in dra7xx_pcie_suspend() local
998 struct dw_pcie *pci = dra7xx->pci; in dra7xx_pcie_suspend()
1001 if (dra7xx->mode != DW_PCIE_RC_TYPE) in dra7xx_pcie_suspend()
1014 struct dra7xx_pcie *dra7xx = dev_get_drvdata(dev); in dra7xx_pcie_resume() local
1015 struct dw_pcie *pci = dra7xx->pci; in dra7xx_pcie_resume()
1018 if (dra7xx->mode != DW_PCIE_RC_TYPE) in dra7xx_pcie_resume()
1031 struct dra7xx_pcie *dra7xx = dev_get_drvdata(dev); in dra7xx_pcie_suspend_noirq() local
1033 dra7xx_pcie_disable_phy(dra7xx); in dra7xx_pcie_suspend_noirq()
1040 struct dra7xx_pcie *dra7xx = dev_get_drvdata(dev); in dra7xx_pcie_resume_noirq() local
1043 ret = dra7xx_pcie_enable_phy(dra7xx); in dra7xx_pcie_resume_noirq()
1056 struct dra7xx_pcie *dra7xx = dev_get_drvdata(dev); in dra7xx_pcie_shutdown() local
1059 dra7xx_pcie_stop_link(dra7xx->pci); in dra7xx_pcie_shutdown()
1066 dra7xx_pcie_disable_phy(dra7xx); in dra7xx_pcie_shutdown()