Lines Matching +full:imx7d +full:- +full:pcie
1 // SPDX-License-Identifier: GPL-2.0
3 * PCIe host controller driver for Freescale i.MX6 SoCs
17 #include <linux/mfd/syscon/imx6q-iomuxc-gpr.h>
18 #include <linux/mfd/syscon/imx7-iomuxc-gpr.h>
36 #include "pcie-designware.h"
45 #define to_imx6_pcie(x) dev_get_drvdata((x)->dev)
51 IMX7D, enumerator
80 struct clk *pcie; member
97 /* power domain for pcie */
99 /* power domain for pcie phy */
105 /* Parameters for the waiting for PCIe PHY PLL to lock on i.MX7 */
109 /* PCIe Port Logic registers (memory-mapped) */
122 /* PHY registers (not memory-mapped) */
136 /* iMX7 PCIe PHY registers */
159 WARN_ON(imx6_pcie->drvdata->variant != IMX8MQ && in imx6_pcie_grp_offset()
160 imx6_pcie->drvdata->variant != IMX8MQ_EP && in imx6_pcie_grp_offset()
161 imx6_pcie->drvdata->variant != IMX8MM && in imx6_pcie_grp_offset()
162 imx6_pcie->drvdata->variant != IMX8MM_EP && in imx6_pcie_grp_offset()
163 imx6_pcie->drvdata->variant != IMX8MP && in imx6_pcie_grp_offset()
164 imx6_pcie->drvdata->variant != IMX8MP_EP); in imx6_pcie_grp_offset()
165 return imx6_pcie->controller_id == 1 ? IOMUXC_GPR16 : IOMUXC_GPR14; in imx6_pcie_grp_offset()
172 if (imx6_pcie->drvdata->mode == DW_PCIE_EP_TYPE) in imx6_pcie_configure_type()
177 switch (imx6_pcie->drvdata->variant) { in imx6_pcie_configure_type()
180 if (imx6_pcie->controller_id == 1) { in imx6_pcie_configure_type()
195 regmap_update_bits(imx6_pcie->iomuxc_gpr, IOMUXC_GPR12, mask, val); in imx6_pcie_configure_type()
200 struct dw_pcie *pci = imx6_pcie->pci; in pcie_phy_poll_ack()
216 return -ETIMEDOUT; in pcie_phy_poll_ack()
221 struct dw_pcie *pci = imx6_pcie->pci; in pcie_phy_wait_ack()
241 /* Read from the 16-bit PCIe PHY control registers (not memory-mapped) */
244 struct dw_pcie *pci = imx6_pcie->pci; in pcie_phy_read()
270 struct dw_pcie *pci = imx6_pcie->pci; in pcie_phy_write()
295 /* wait for ack de-assertion */ in pcie_phy_write()
313 /* wait for ack de-assertion */ in pcie_phy_write()
325 switch (imx6_pcie->drvdata->variant) { in imx6_pcie_init_phy()
341 regmap_update_bits(imx6_pcie->iomuxc_gpr, in imx6_pcie_init_phy()
350 if (imx6_pcie->vph && in imx6_pcie_init_phy()
351 regulator_get_voltage(imx6_pcie->vph) > 3000000) in imx6_pcie_init_phy()
352 regmap_update_bits(imx6_pcie->iomuxc_gpr, in imx6_pcie_init_phy()
357 case IMX7D: in imx6_pcie_init_phy()
358 regmap_update_bits(imx6_pcie->iomuxc_gpr, IOMUXC_GPR12, in imx6_pcie_init_phy()
362 regmap_update_bits(imx6_pcie->iomuxc_gpr, IOMUXC_GPR12, in imx6_pcie_init_phy()
367 regmap_update_bits(imx6_pcie->iomuxc_gpr, IOMUXC_GPR12, in imx6_pcie_init_phy()
370 /* configure constant input signal to the pcie ctrl and phy */ in imx6_pcie_init_phy()
371 regmap_update_bits(imx6_pcie->iomuxc_gpr, IOMUXC_GPR12, in imx6_pcie_init_phy()
374 regmap_update_bits(imx6_pcie->iomuxc_gpr, IOMUXC_GPR8, in imx6_pcie_init_phy()
376 imx6_pcie->tx_deemph_gen1 << 0); in imx6_pcie_init_phy()
377 regmap_update_bits(imx6_pcie->iomuxc_gpr, IOMUXC_GPR8, in imx6_pcie_init_phy()
379 imx6_pcie->tx_deemph_gen2_3p5db << 6); in imx6_pcie_init_phy()
380 regmap_update_bits(imx6_pcie->iomuxc_gpr, IOMUXC_GPR8, in imx6_pcie_init_phy()
382 imx6_pcie->tx_deemph_gen2_6db << 12); in imx6_pcie_init_phy()
383 regmap_update_bits(imx6_pcie->iomuxc_gpr, IOMUXC_GPR8, in imx6_pcie_init_phy()
385 imx6_pcie->tx_swing_full << 18); in imx6_pcie_init_phy()
386 regmap_update_bits(imx6_pcie->iomuxc_gpr, IOMUXC_GPR8, in imx6_pcie_init_phy()
388 imx6_pcie->tx_swing_low << 25); in imx6_pcie_init_phy()
398 struct device *dev = imx6_pcie->pci->dev; in imx7d_pcie_wait_for_phy_pll_lock()
400 if (regmap_read_poll_timeout(imx6_pcie->iomuxc_gpr, in imx7d_pcie_wait_for_phy_pll_lock()
405 dev_err(dev, "PCIe PLL lock timeout\n"); in imx7d_pcie_wait_for_phy_pll_lock()
410 unsigned long phy_rate = clk_get_rate(imx6_pcie->pcie_phy); in imx6_setup_phy_mpll()
414 if (!(imx6_pcie->drvdata->flags & IMX6_PCIE_FLAG_IMX6_PHY)) in imx6_setup_phy_mpll()
433 dev_err(imx6_pcie->pci->dev, in imx6_setup_phy_mpll()
435 return -EINVAL; in imx6_setup_phy_mpll()
459 if (!(imx6_pcie->drvdata->flags & IMX6_PCIE_FLAG_IMX6_PHY)) in imx6_pcie_reset_phy()
486 * make it look like it read all-ones. in imx6q_pcie_abort_handler()
494 val = -1; in imx6q_pcie_abort_handler()
496 regs->uregs[reg] = val; in imx6q_pcie_abort_handler()
497 regs->ARM_pc += 4; in imx6q_pcie_abort_handler()
502 regs->uregs[reg] = -1; in imx6q_pcie_abort_handler()
503 regs->ARM_pc += 4; in imx6q_pcie_abort_handler()
517 if (dev->pm_domain) in imx6_pcie_attach_pd()
520 imx6_pcie->pd_pcie = dev_pm_domain_attach_by_name(dev, "pcie"); in imx6_pcie_attach_pd()
521 if (IS_ERR(imx6_pcie->pd_pcie)) in imx6_pcie_attach_pd()
522 return PTR_ERR(imx6_pcie->pd_pcie); in imx6_pcie_attach_pd()
524 if (!imx6_pcie->pd_pcie) in imx6_pcie_attach_pd()
526 link = device_link_add(dev, imx6_pcie->pd_pcie, in imx6_pcie_attach_pd()
531 dev_err(dev, "Failed to add device_link to pcie pd.\n"); in imx6_pcie_attach_pd()
532 return -EINVAL; in imx6_pcie_attach_pd()
535 imx6_pcie->pd_pcie_phy = dev_pm_domain_attach_by_name(dev, "pcie_phy"); in imx6_pcie_attach_pd()
536 if (IS_ERR(imx6_pcie->pd_pcie_phy)) in imx6_pcie_attach_pd()
537 return PTR_ERR(imx6_pcie->pd_pcie_phy); in imx6_pcie_attach_pd()
539 link = device_link_add(dev, imx6_pcie->pd_pcie_phy, in imx6_pcie_attach_pd()
545 return -EINVAL; in imx6_pcie_attach_pd()
553 struct dw_pcie *pci = imx6_pcie->pci; in imx6_pcie_enable_ref_clk()
554 struct device *dev = pci->dev; in imx6_pcie_enable_ref_clk()
558 switch (imx6_pcie->drvdata->variant) { in imx6_pcie_enable_ref_clk()
560 ret = clk_prepare_enable(imx6_pcie->pcie_inbound_axi); in imx6_pcie_enable_ref_clk()
566 regmap_update_bits(imx6_pcie->iomuxc_gpr, IOMUXC_GPR12, in imx6_pcie_enable_ref_clk()
572 regmap_update_bits(imx6_pcie->iomuxc_gpr, IOMUXC_GPR1, in imx6_pcie_enable_ref_clk()
581 regmap_update_bits(imx6_pcie->iomuxc_gpr, IOMUXC_GPR1, in imx6_pcie_enable_ref_clk()
584 case IMX7D: in imx6_pcie_enable_ref_clk()
592 ret = clk_prepare_enable(imx6_pcie->pcie_aux); in imx6_pcie_enable_ref_clk()
603 regmap_update_bits(imx6_pcie->iomuxc_gpr, offset, in imx6_pcie_enable_ref_clk()
606 regmap_update_bits(imx6_pcie->iomuxc_gpr, offset, in imx6_pcie_enable_ref_clk()
617 switch (imx6_pcie->drvdata->variant) { in imx6_pcie_disable_ref_clk()
619 clk_disable_unprepare(imx6_pcie->pcie_inbound_axi); in imx6_pcie_disable_ref_clk()
623 regmap_update_bits(imx6_pcie->iomuxc_gpr, IOMUXC_GPR1, in imx6_pcie_disable_ref_clk()
625 regmap_update_bits(imx6_pcie->iomuxc_gpr, IOMUXC_GPR1, in imx6_pcie_disable_ref_clk()
629 case IMX7D: in imx6_pcie_disable_ref_clk()
630 regmap_update_bits(imx6_pcie->iomuxc_gpr, IOMUXC_GPR12, in imx6_pcie_disable_ref_clk()
640 clk_disable_unprepare(imx6_pcie->pcie_aux); in imx6_pcie_disable_ref_clk()
649 struct dw_pcie *pci = imx6_pcie->pci; in imx6_pcie_clk_enable()
650 struct device *dev = pci->dev; in imx6_pcie_clk_enable()
653 ret = clk_prepare_enable(imx6_pcie->pcie_phy); in imx6_pcie_clk_enable()
659 ret = clk_prepare_enable(imx6_pcie->pcie_bus); in imx6_pcie_clk_enable()
665 ret = clk_prepare_enable(imx6_pcie->pcie); in imx6_pcie_clk_enable()
667 dev_err(dev, "unable to enable pcie clock\n"); in imx6_pcie_clk_enable()
673 dev_err(dev, "unable to enable pcie ref clock\n"); in imx6_pcie_clk_enable()
682 clk_disable_unprepare(imx6_pcie->pcie); in imx6_pcie_clk_enable()
684 clk_disable_unprepare(imx6_pcie->pcie_bus); in imx6_pcie_clk_enable()
686 clk_disable_unprepare(imx6_pcie->pcie_phy); in imx6_pcie_clk_enable()
694 clk_disable_unprepare(imx6_pcie->pcie); in imx6_pcie_clk_disable()
695 clk_disable_unprepare(imx6_pcie->pcie_bus); in imx6_pcie_clk_disable()
696 clk_disable_unprepare(imx6_pcie->pcie_phy); in imx6_pcie_clk_disable()
701 switch (imx6_pcie->drvdata->variant) { in imx6_pcie_assert_core_reset()
702 case IMX7D: in imx6_pcie_assert_core_reset()
705 reset_control_assert(imx6_pcie->pciephy_reset); in imx6_pcie_assert_core_reset()
711 reset_control_assert(imx6_pcie->apps_reset); in imx6_pcie_assert_core_reset()
714 regmap_update_bits(imx6_pcie->iomuxc_gpr, IOMUXC_GPR12, in imx6_pcie_assert_core_reset()
717 /* Force PCIe PHY reset */ in imx6_pcie_assert_core_reset()
718 regmap_update_bits(imx6_pcie->iomuxc_gpr, IOMUXC_GPR5, in imx6_pcie_assert_core_reset()
723 regmap_update_bits(imx6_pcie->iomuxc_gpr, IOMUXC_GPR1, in imx6_pcie_assert_core_reset()
728 regmap_update_bits(imx6_pcie->iomuxc_gpr, IOMUXC_GPR1, in imx6_pcie_assert_core_reset()
730 regmap_update_bits(imx6_pcie->iomuxc_gpr, IOMUXC_GPR1, in imx6_pcie_assert_core_reset()
735 /* Some boards don't have PCIe reset GPIO. */ in imx6_pcie_assert_core_reset()
736 if (gpio_is_valid(imx6_pcie->reset_gpio)) in imx6_pcie_assert_core_reset()
737 gpio_set_value_cansleep(imx6_pcie->reset_gpio, in imx6_pcie_assert_core_reset()
738 imx6_pcie->gpio_active_high); in imx6_pcie_assert_core_reset()
743 struct dw_pcie *pci = imx6_pcie->pci; in imx6_pcie_deassert_core_reset()
744 struct device *dev = pci->dev; in imx6_pcie_deassert_core_reset()
746 switch (imx6_pcie->drvdata->variant) { in imx6_pcie_deassert_core_reset()
749 reset_control_deassert(imx6_pcie->pciephy_reset); in imx6_pcie_deassert_core_reset()
751 case IMX7D: in imx6_pcie_deassert_core_reset()
752 reset_control_deassert(imx6_pcie->pciephy_reset); in imx6_pcie_deassert_core_reset()
754 /* Workaround for ERR010728, failure of PCI-e PLL VCO to in imx6_pcie_deassert_core_reset()
755 * oscillate, especially when cold. This turns off "Duty-cycle in imx6_pcie_deassert_core_reset()
758 if (likely(imx6_pcie->phy_base)) { in imx6_pcie_deassert_core_reset()
759 /* De-assert DCC_FB_EN */ in imx6_pcie_deassert_core_reset()
761 imx6_pcie->phy_base + PCIE_PHY_CMN_REG4); in imx6_pcie_deassert_core_reset()
765 imx6_pcie->phy_base + PCIE_PHY_CMN_REG24); in imx6_pcie_deassert_core_reset()
768 imx6_pcie->phy_base + PCIE_PHY_CMN_REG26); in imx6_pcie_deassert_core_reset()
770 dev_warn(dev, "Unable to apply ERR010728 workaround. DT missing fsl,imx7d-pcie-phy phandle ?\n"); in imx6_pcie_deassert_core_reset()
776 regmap_update_bits(imx6_pcie->iomuxc_gpr, IOMUXC_GPR5, in imx6_pcie_deassert_core_reset()
780 regmap_update_bits(imx6_pcie->iomuxc_gpr, IOMUXC_GPR1, in imx6_pcie_deassert_core_reset()
793 /* Some boards don't have PCIe reset GPIO. */ in imx6_pcie_deassert_core_reset()
794 if (gpio_is_valid(imx6_pcie->reset_gpio)) { in imx6_pcie_deassert_core_reset()
796 gpio_set_value_cansleep(imx6_pcie->reset_gpio, in imx6_pcie_deassert_core_reset()
797 !imx6_pcie->gpio_active_high); in imx6_pcie_deassert_core_reset()
798 /* Wait for 100ms after PERST# deassertion (PCIe r5.0, 6.6.1) */ in imx6_pcie_deassert_core_reset()
807 struct dw_pcie *pci = imx6_pcie->pci; in imx6_pcie_wait_for_speed_change()
808 struct device *dev = pci->dev; in imx6_pcie_wait_for_speed_change()
821 return -ETIMEDOUT; in imx6_pcie_wait_for_speed_change()
828 switch (imx6_pcie->drvdata->variant) { in imx6_pcie_ltssm_enable()
832 regmap_update_bits(imx6_pcie->iomuxc_gpr, IOMUXC_GPR12, in imx6_pcie_ltssm_enable()
836 case IMX7D: in imx6_pcie_ltssm_enable()
843 reset_control_deassert(imx6_pcie->apps_reset); in imx6_pcie_ltssm_enable()
852 switch (imx6_pcie->drvdata->variant) { in imx6_pcie_ltssm_disable()
856 regmap_update_bits(imx6_pcie->iomuxc_gpr, IOMUXC_GPR12, in imx6_pcie_ltssm_disable()
859 case IMX7D: in imx6_pcie_ltssm_disable()
866 reset_control_assert(imx6_pcie->apps_reset); in imx6_pcie_ltssm_disable()
874 struct device *dev = pci->dev; in imx6_pcie_start_link()
882 * bus will not be detected at all. This happens with PCIe switches. in imx6_pcie_start_link()
898 if (pci->link_gen > 1) { in imx6_pcie_start_link()
903 tmp |= pci->link_gen; in imx6_pcie_start_link()
915 if (imx6_pcie->drvdata->flags & in imx6_pcie_start_link()
920 * occurs and we go Gen1 -> yep, Gen1. The difference in imx6_pcie_start_link()
941 imx6_pcie->link_is_up = true; in imx6_pcie_start_link()
947 imx6_pcie->link_is_up = false; in imx6_pcie_start_link()
957 struct device *dev = pci->dev; in imx6_pcie_stop_link()
959 /* Turn off PCIe LTSSM */ in imx6_pcie_stop_link()
966 struct device *dev = pci->dev; in imx6_pcie_host_init()
970 if (imx6_pcie->vpcie) { in imx6_pcie_host_init()
971 ret = regulator_enable(imx6_pcie->vpcie); in imx6_pcie_host_init()
984 dev_err(dev, "unable to enable pcie clocks: %d\n", ret); in imx6_pcie_host_init()
988 if (imx6_pcie->phy) { in imx6_pcie_host_init()
989 ret = phy_init(imx6_pcie->phy); in imx6_pcie_host_init()
991 dev_err(dev, "pcie PHY power up failed\n"); in imx6_pcie_host_init()
996 if (imx6_pcie->phy) { in imx6_pcie_host_init()
997 ret = phy_power_on(imx6_pcie->phy); in imx6_pcie_host_init()
1006 dev_err(dev, "pcie deassert core reset failed: %d\n", ret); in imx6_pcie_host_init()
1015 phy_power_off(imx6_pcie->phy); in imx6_pcie_host_init()
1017 phy_exit(imx6_pcie->phy); in imx6_pcie_host_init()
1021 if (imx6_pcie->vpcie) in imx6_pcie_host_init()
1022 regulator_disable(imx6_pcie->vpcie); in imx6_pcie_host_init()
1031 if (imx6_pcie->phy) { in imx6_pcie_host_exit()
1032 if (phy_power_off(imx6_pcie->phy)) in imx6_pcie_host_exit()
1033 dev_err(pci->dev, "unable to power off PHY\n"); in imx6_pcie_host_exit()
1034 phy_exit(imx6_pcie->phy); in imx6_pcie_host_exit()
1038 if (imx6_pcie->vpcie) in imx6_pcie_host_exit()
1039 regulator_disable(imx6_pcie->vpcie); in imx6_pcie_host_exit()
1075 dev_err(pci->dev, "UNKNOWN IRQ type\n"); in imx6_pcie_ep_raise_irq()
1076 return -EINVAL; in imx6_pcie_ep_raise_irq()
1109 struct dw_pcie *pci = imx6_pcie->pci; in imx6_add_pcie_ep()
1110 struct dw_pcie_rp *pp = &pci->pp; in imx6_add_pcie_ep()
1111 struct device *dev = pci->dev; in imx6_add_pcie_ep()
1114 ep = &pci->ep; in imx6_add_pcie_ep()
1115 ep->ops = &pcie_ep_ops; in imx6_add_pcie_ep()
1117 switch (imx6_pcie->drvdata->variant) { in imx6_add_pcie_ep()
1127 pci->dbi_base2 = pci->dbi_base + pcie_dbi2_offset; in imx6_add_pcie_ep()
1130 return -EINVAL; in imx6_add_pcie_ep()
1132 ep->phys_base = res->start; in imx6_add_pcie_ep()
1133 ep->addr_size = resource_size(res); in imx6_add_pcie_ep()
1134 ep->page_size = SZ_64K; in imx6_add_pcie_ep()
1149 struct device *dev = imx6_pcie->pci->dev; in imx6_pcie_pm_turnoff()
1152 if (imx6_pcie->turnoff_reset) { in imx6_pcie_pm_turnoff()
1153 reset_control_assert(imx6_pcie->turnoff_reset); in imx6_pcie_pm_turnoff()
1154 reset_control_deassert(imx6_pcie->turnoff_reset); in imx6_pcie_pm_turnoff()
1159 switch (imx6_pcie->drvdata->variant) { in imx6_pcie_pm_turnoff()
1162 regmap_update_bits(imx6_pcie->iomuxc_gpr, IOMUXC_GPR12, in imx6_pcie_pm_turnoff()
1165 regmap_update_bits(imx6_pcie->iomuxc_gpr, IOMUXC_GPR12, in imx6_pcie_pm_turnoff()
1177 * The standard recommends a 1-10ms timeout after which to in imx6_pcie_pm_turnoff()
1188 struct dw_pcie *pci = imx6_pcie->pci; in imx6_pcie_msi_save_restore()
1194 imx6_pcie->msi_ctrl = val; in imx6_pcie_msi_save_restore()
1197 val = imx6_pcie->msi_ctrl; in imx6_pcie_msi_save_restore()
1207 struct dw_pcie_rp *pp = &imx6_pcie->pci->pp; in imx6_pcie_suspend_noirq()
1209 if (!(imx6_pcie->drvdata->flags & IMX6_PCIE_FLAG_SUPPORTS_SUSPEND)) in imx6_pcie_suspend_noirq()
1214 imx6_pcie_stop_link(imx6_pcie->pci); in imx6_pcie_suspend_noirq()
1224 struct dw_pcie_rp *pp = &imx6_pcie->pci->pp; in imx6_pcie_resume_noirq()
1226 if (!(imx6_pcie->drvdata->flags & IMX6_PCIE_FLAG_SUPPORTS_SUSPEND)) in imx6_pcie_resume_noirq()
1235 if (imx6_pcie->link_is_up) in imx6_pcie_resume_noirq()
1236 imx6_pcie_start_link(imx6_pcie->pci); in imx6_pcie_resume_noirq()
1248 struct device *dev = &pdev->dev; in imx6_pcie_probe()
1253 struct device_node *node = dev->of_node; in imx6_pcie_probe()
1259 return -ENOMEM; in imx6_pcie_probe()
1263 return -ENOMEM; in imx6_pcie_probe()
1265 pci->dev = dev; in imx6_pcie_probe()
1266 pci->ops = &dw_pcie_ops; in imx6_pcie_probe()
1267 pci->pp.ops = &imx6_pcie_host_ops; in imx6_pcie_probe()
1269 imx6_pcie->pci = pci; in imx6_pcie_probe()
1270 imx6_pcie->drvdata = of_device_get_match_data(dev); in imx6_pcie_probe()
1272 /* Find the PHY if one is defined, only imx7d uses it */ in imx6_pcie_probe()
1273 np = of_parse_phandle(node, "fsl,imx7d-pcie-phy", 0); in imx6_pcie_probe()
1279 dev_err(dev, "Unable to map PCIe PHY\n"); in imx6_pcie_probe()
1282 imx6_pcie->phy_base = devm_ioremap_resource(dev, &res); in imx6_pcie_probe()
1283 if (IS_ERR(imx6_pcie->phy_base)) in imx6_pcie_probe()
1284 return PTR_ERR(imx6_pcie->phy_base); in imx6_pcie_probe()
1287 pci->dbi_base = devm_platform_get_and_ioremap_resource(pdev, 0, &dbi_base); in imx6_pcie_probe()
1288 if (IS_ERR(pci->dbi_base)) in imx6_pcie_probe()
1289 return PTR_ERR(pci->dbi_base); in imx6_pcie_probe()
1292 imx6_pcie->reset_gpio = of_get_named_gpio(node, "reset-gpio", 0); in imx6_pcie_probe()
1293 imx6_pcie->gpio_active_high = of_property_read_bool(node, in imx6_pcie_probe()
1294 "reset-gpio-active-high"); in imx6_pcie_probe()
1295 if (gpio_is_valid(imx6_pcie->reset_gpio)) { in imx6_pcie_probe()
1296 ret = devm_gpio_request_one(dev, imx6_pcie->reset_gpio, in imx6_pcie_probe()
1297 imx6_pcie->gpio_active_high ? in imx6_pcie_probe()
1300 "PCIe reset"); in imx6_pcie_probe()
1305 } else if (imx6_pcie->reset_gpio == -EPROBE_DEFER) { in imx6_pcie_probe()
1306 return imx6_pcie->reset_gpio; in imx6_pcie_probe()
1310 imx6_pcie->pcie_bus = devm_clk_get(dev, "pcie_bus"); in imx6_pcie_probe()
1311 if (IS_ERR(imx6_pcie->pcie_bus)) in imx6_pcie_probe()
1312 return dev_err_probe(dev, PTR_ERR(imx6_pcie->pcie_bus), in imx6_pcie_probe()
1315 imx6_pcie->pcie = devm_clk_get(dev, "pcie"); in imx6_pcie_probe()
1316 if (IS_ERR(imx6_pcie->pcie)) in imx6_pcie_probe()
1317 return dev_err_probe(dev, PTR_ERR(imx6_pcie->pcie), in imx6_pcie_probe()
1318 "pcie clock source missing or invalid\n"); in imx6_pcie_probe()
1320 switch (imx6_pcie->drvdata->variant) { in imx6_pcie_probe()
1322 imx6_pcie->pcie_inbound_axi = devm_clk_get(dev, in imx6_pcie_probe()
1324 if (IS_ERR(imx6_pcie->pcie_inbound_axi)) in imx6_pcie_probe()
1325 return dev_err_probe(dev, PTR_ERR(imx6_pcie->pcie_inbound_axi), in imx6_pcie_probe()
1330 imx6_pcie->pcie_aux = devm_clk_get(dev, "pcie_aux"); in imx6_pcie_probe()
1331 if (IS_ERR(imx6_pcie->pcie_aux)) in imx6_pcie_probe()
1332 return dev_err_probe(dev, PTR_ERR(imx6_pcie->pcie_aux), in imx6_pcie_probe()
1335 case IMX7D: in imx6_pcie_probe()
1336 if (dbi_base->start == IMX8MQ_PCIE2_BASE_ADDR) in imx6_pcie_probe()
1337 imx6_pcie->controller_id = 1; in imx6_pcie_probe()
1339 imx6_pcie->pciephy_reset = devm_reset_control_get_exclusive(dev, in imx6_pcie_probe()
1341 if (IS_ERR(imx6_pcie->pciephy_reset)) { in imx6_pcie_probe()
1343 return PTR_ERR(imx6_pcie->pciephy_reset); in imx6_pcie_probe()
1346 imx6_pcie->apps_reset = devm_reset_control_get_exclusive(dev, in imx6_pcie_probe()
1348 if (IS_ERR(imx6_pcie->apps_reset)) { in imx6_pcie_probe()
1349 dev_err(dev, "Failed to get PCIE APPS reset control\n"); in imx6_pcie_probe()
1350 return PTR_ERR(imx6_pcie->apps_reset); in imx6_pcie_probe()
1357 imx6_pcie->pcie_aux = devm_clk_get(dev, "pcie_aux"); in imx6_pcie_probe()
1358 if (IS_ERR(imx6_pcie->pcie_aux)) in imx6_pcie_probe()
1359 return dev_err_probe(dev, PTR_ERR(imx6_pcie->pcie_aux), in imx6_pcie_probe()
1361 imx6_pcie->apps_reset = devm_reset_control_get_exclusive(dev, in imx6_pcie_probe()
1363 if (IS_ERR(imx6_pcie->apps_reset)) in imx6_pcie_probe()
1364 return dev_err_probe(dev, PTR_ERR(imx6_pcie->apps_reset), in imx6_pcie_probe()
1365 "failed to get pcie apps reset control\n"); in imx6_pcie_probe()
1367 imx6_pcie->phy = devm_phy_get(dev, "pcie-phy"); in imx6_pcie_probe()
1368 if (IS_ERR(imx6_pcie->phy)) in imx6_pcie_probe()
1369 return dev_err_probe(dev, PTR_ERR(imx6_pcie->phy), in imx6_pcie_probe()
1370 "failed to get pcie phy\n"); in imx6_pcie_probe()
1377 if (imx6_pcie->phy == NULL) { in imx6_pcie_probe()
1378 imx6_pcie->pcie_phy = devm_clk_get(dev, "pcie_phy"); in imx6_pcie_probe()
1379 if (IS_ERR(imx6_pcie->pcie_phy)) in imx6_pcie_probe()
1380 return dev_err_probe(dev, PTR_ERR(imx6_pcie->pcie_phy), in imx6_pcie_probe()
1386 imx6_pcie->turnoff_reset = devm_reset_control_get_optional_exclusive(dev, "turnoff"); in imx6_pcie_probe()
1387 if (IS_ERR(imx6_pcie->turnoff_reset)) { in imx6_pcie_probe()
1389 return PTR_ERR(imx6_pcie->turnoff_reset); in imx6_pcie_probe()
1393 imx6_pcie->iomuxc_gpr = in imx6_pcie_probe()
1394 syscon_regmap_lookup_by_compatible(imx6_pcie->drvdata->gpr); in imx6_pcie_probe()
1395 if (IS_ERR(imx6_pcie->iomuxc_gpr)) { in imx6_pcie_probe()
1397 return PTR_ERR(imx6_pcie->iomuxc_gpr); in imx6_pcie_probe()
1400 /* Grab PCIe PHY Tx Settings */ in imx6_pcie_probe()
1401 if (of_property_read_u32(node, "fsl,tx-deemph-gen1", in imx6_pcie_probe()
1402 &imx6_pcie->tx_deemph_gen1)) in imx6_pcie_probe()
1403 imx6_pcie->tx_deemph_gen1 = 0; in imx6_pcie_probe()
1405 if (of_property_read_u32(node, "fsl,tx-deemph-gen2-3p5db", in imx6_pcie_probe()
1406 &imx6_pcie->tx_deemph_gen2_3p5db)) in imx6_pcie_probe()
1407 imx6_pcie->tx_deemph_gen2_3p5db = 0; in imx6_pcie_probe()
1409 if (of_property_read_u32(node, "fsl,tx-deemph-gen2-6db", in imx6_pcie_probe()
1410 &imx6_pcie->tx_deemph_gen2_6db)) in imx6_pcie_probe()
1411 imx6_pcie->tx_deemph_gen2_6db = 20; in imx6_pcie_probe()
1413 if (of_property_read_u32(node, "fsl,tx-swing-full", in imx6_pcie_probe()
1414 &imx6_pcie->tx_swing_full)) in imx6_pcie_probe()
1415 imx6_pcie->tx_swing_full = 127; in imx6_pcie_probe()
1417 if (of_property_read_u32(node, "fsl,tx-swing-low", in imx6_pcie_probe()
1418 &imx6_pcie->tx_swing_low)) in imx6_pcie_probe()
1419 imx6_pcie->tx_swing_low = 127; in imx6_pcie_probe()
1422 pci->link_gen = 1; in imx6_pcie_probe()
1423 of_property_read_u32(node, "fsl,max-link-speed", &pci->link_gen); in imx6_pcie_probe()
1425 imx6_pcie->vpcie = devm_regulator_get_optional(&pdev->dev, "vpcie"); in imx6_pcie_probe()
1426 if (IS_ERR(imx6_pcie->vpcie)) { in imx6_pcie_probe()
1427 if (PTR_ERR(imx6_pcie->vpcie) != -ENODEV) in imx6_pcie_probe()
1428 return PTR_ERR(imx6_pcie->vpcie); in imx6_pcie_probe()
1429 imx6_pcie->vpcie = NULL; in imx6_pcie_probe()
1432 imx6_pcie->vph = devm_regulator_get_optional(&pdev->dev, "vph"); in imx6_pcie_probe()
1433 if (IS_ERR(imx6_pcie->vph)) { in imx6_pcie_probe()
1434 if (PTR_ERR(imx6_pcie->vph) != -ENODEV) in imx6_pcie_probe()
1435 return PTR_ERR(imx6_pcie->vph); in imx6_pcie_probe()
1436 imx6_pcie->vph = NULL; in imx6_pcie_probe()
1445 if (imx6_pcie->drvdata->mode == DW_PCIE_EP_TYPE) { in imx6_pcie_probe()
1450 ret = dw_pcie_host_init(&pci->pp); in imx6_pcie_probe()
1480 .gpr = "fsl,imx6q-iomuxc-gpr",
1487 .gpr = "fsl,imx6q-iomuxc-gpr",
1495 .gpr = "fsl,imx6q-iomuxc-gpr",
1497 [IMX7D] = {
1498 .variant = IMX7D,
1500 .gpr = "fsl,imx7d-iomuxc-gpr",
1504 .gpr = "fsl,imx8mq-iomuxc-gpr",
1509 .gpr = "fsl,imx8mm-iomuxc-gpr",
1514 .gpr = "fsl,imx8mp-iomuxc-gpr",
1519 .gpr = "fsl,imx8mq-iomuxc-gpr",
1524 .gpr = "fsl,imx8mm-iomuxc-gpr",
1529 .gpr = "fsl,imx8mp-iomuxc-gpr",
1534 { .compatible = "fsl,imx6q-pcie", .data = &drvdata[IMX6Q], },
1535 { .compatible = "fsl,imx6sx-pcie", .data = &drvdata[IMX6SX], },
1536 { .compatible = "fsl,imx6qp-pcie", .data = &drvdata[IMX6QP], },
1537 { .compatible = "fsl,imx7d-pcie", .data = &drvdata[IMX7D], },
1538 { .compatible = "fsl,imx8mq-pcie", .data = &drvdata[IMX8MQ], },
1539 { .compatible = "fsl,imx8mm-pcie", .data = &drvdata[IMX8MM], },
1540 { .compatible = "fsl,imx8mp-pcie", .data = &drvdata[IMX8MP], },
1541 { .compatible = "fsl,imx8mq-pcie-ep", .data = &drvdata[IMX8MQ_EP], },
1542 { .compatible = "fsl,imx8mm-pcie-ep", .data = &drvdata[IMX8MM_EP], },
1543 { .compatible = "fsl,imx8mp-pcie-ep", .data = &drvdata[IMX8MP_EP], },
1549 .name = "imx6q-pcie",
1561 struct pci_bus *bus = dev->bus; in imx6_pcie_quirk()
1562 struct dw_pcie_rp *pp = bus->sysdata; in imx6_pcie_quirk()
1565 if (!bus->dev.parent || !bus->dev.parent->parent) in imx6_pcie_quirk()
1569 if (bus->dev.parent->parent->driver != &imx6_pcie_driver.driver) in imx6_pcie_quirk()
1580 if (imx6_pcie->drvdata->dbi_length) { in imx6_pcie_quirk()
1581 dev->cfg_size = imx6_pcie->drvdata->dbi_length; in imx6_pcie_quirk()
1582 dev_info(&dev->dev, "Limiting cfg_size to %d\n", in imx6_pcie_quirk()
1583 dev->cfg_size); in imx6_pcie_quirk()
1597 return -ENODEV; in imx6_pcie_init()
1603 * by kernel and since imx6q_pcie_abort_handler() is a no-op, in imx6_pcie_init()
1608 "external abort on non-linefetch"); in imx6_pcie_init()