@@ -117,6 +117,8 @@ enum imx_pcie_variants {
117117#define IMX_PCIE_FLAG_HAS_LUT BIT(10)
118118#define IMX_PCIE_FLAG_8GT_ECN_ERR051586 BIT(11)
119119#define IMX_PCIE_FLAG_SKIP_L23_READY BIT(12)
120+ /* Preserve MSI capability for platforms that require it */
121+ #define IMX_PCIE_FLAG_KEEP_MSI_CAP BIT(13)
120122
121123#define imx_check_flag (pci , val ) (pci->drvdata->flags & val)
122124
@@ -268,8 +270,8 @@ static int imx95_pcie_init_phy(struct imx_pcie *imx_pcie)
268270 IMX95_PCIE_PHY_CR_PARA_SEL );
269271
270272 regmap_update_bits (imx_pcie -> iomuxc_gpr , IMX95_PCIE_PHY_GEN_CTRL ,
271- ext ? IMX95_PCIE_REF_USE_PAD : 0 ,
272- IMX95_PCIE_REF_USE_PAD );
273+ IMX95_PCIE_REF_USE_PAD ,
274+ ext ? IMX95_PCIE_REF_USE_PAD : 0 );
273275 regmap_update_bits (imx_pcie -> iomuxc_gpr , IMX95_PCIE_SS_RW_REG_0 ,
274276 IMX95_PCIE_REF_CLKEN ,
275277 ext ? 0 : IMX95_PCIE_REF_CLKEN );
@@ -901,27 +903,14 @@ static void imx_pcie_assert_core_reset(struct imx_pcie *imx_pcie)
901903
902904 if (imx_pcie -> drvdata -> core_reset )
903905 imx_pcie -> drvdata -> core_reset (imx_pcie , true);
904-
905- /* Some boards don't have PCIe reset GPIO. */
906- gpiod_set_value_cansleep (imx_pcie -> reset_gpiod , 1 );
907906}
908907
909- static int imx_pcie_deassert_core_reset (struct imx_pcie * imx_pcie )
908+ static void imx_pcie_deassert_core_reset (struct imx_pcie * imx_pcie )
910909{
911910 reset_control_deassert (imx_pcie -> pciephy_reset );
912911
913912 if (imx_pcie -> drvdata -> core_reset )
914913 imx_pcie -> drvdata -> core_reset (imx_pcie , false);
915-
916- /* Some boards don't have PCIe reset GPIO. */
917- if (imx_pcie -> reset_gpiod ) {
918- msleep (100 );
919- gpiod_set_value_cansleep (imx_pcie -> reset_gpiod , 0 );
920- /* Wait for 100ms after PERST# deassertion (PCIe r5.0, 6.6.1) */
921- msleep (100 );
922- }
923-
924- return 0 ;
925914}
926915
927916static int imx_pcie_wait_for_speed_change (struct imx_pcie * imx_pcie )
@@ -1233,6 +1222,19 @@ static void imx_pcie_disable_device(struct pci_host_bridge *bridge,
12331222 imx_pcie_remove_lut (imx_pcie , pci_dev_id (pdev ));
12341223}
12351224
1225+ static void imx_pcie_assert_perst (struct imx_pcie * imx_pcie , bool assert )
1226+ {
1227+ if (assert ) {
1228+ gpiod_set_value_cansleep (imx_pcie -> reset_gpiod , 1 );
1229+ } else {
1230+ if (imx_pcie -> reset_gpiod ) {
1231+ msleep (PCIE_T_PVPERL_MS );
1232+ gpiod_set_value_cansleep (imx_pcie -> reset_gpiod , 0 );
1233+ msleep (PCIE_RESET_CONFIG_WAIT_MS );
1234+ }
1235+ }
1236+ }
1237+
12361238static int imx_pcie_host_init (struct dw_pcie_rp * pp )
12371239{
12381240 struct dw_pcie * pci = to_dw_pcie_from_pp (pp );
@@ -1255,6 +1257,7 @@ static int imx_pcie_host_init(struct dw_pcie_rp *pp)
12551257 }
12561258
12571259 imx_pcie_assert_core_reset (imx_pcie );
1260+ imx_pcie_assert_perst (imx_pcie , true);
12581261
12591262 if (imx_pcie -> drvdata -> init_phy )
12601263 imx_pcie -> drvdata -> init_phy (imx_pcie );
@@ -1292,11 +1295,8 @@ static int imx_pcie_host_init(struct dw_pcie_rp *pp)
12921295 /* Make sure that PCIe LTSSM is cleared */
12931296 imx_pcie_ltssm_disable (dev );
12941297
1295- ret = imx_pcie_deassert_core_reset (imx_pcie );
1296- if (ret < 0 ) {
1297- dev_err (dev , "pcie deassert core reset failed: %d\n" , ret );
1298- goto err_phy_off ;
1299- }
1298+ imx_pcie_deassert_core_reset (imx_pcie );
1299+ imx_pcie_assert_perst (imx_pcie , false);
13001300
13011301 if (imx_pcie -> drvdata -> wait_pll_lock ) {
13021302 ret = imx_pcie -> drvdata -> wait_pll_lock (imx_pcie );
@@ -1583,6 +1583,7 @@ static int imx_pcie_suspend_noirq(struct device *dev)
15831583 * clock which saves some power.
15841584 */
15851585 imx_pcie_assert_core_reset (imx_pcie );
1586+ imx_pcie_assert_perst (imx_pcie , true);
15861587 imx_pcie -> drvdata -> enable_ref_clk (imx_pcie , false);
15871588 } else {
15881589 return dw_pcie_suspend_noirq (imx_pcie -> pci );
@@ -1603,9 +1604,8 @@ static int imx_pcie_resume_noirq(struct device *dev)
16031604 ret = imx_pcie -> drvdata -> enable_ref_clk (imx_pcie , true);
16041605 if (ret )
16051606 return ret ;
1606- ret = imx_pcie_deassert_core_reset (imx_pcie );
1607- if (ret )
1608- return ret ;
1607+ imx_pcie_deassert_core_reset (imx_pcie );
1608+ imx_pcie_assert_perst (imx_pcie , false);
16091609
16101610 /*
16111611 * Using PCIE_TEST_PD seems to disable MSI and powers down the
@@ -1637,7 +1637,6 @@ static int imx_pcie_probe(struct platform_device *pdev)
16371637 struct device * dev = & pdev -> dev ;
16381638 struct dw_pcie * pci ;
16391639 struct imx_pcie * imx_pcie ;
1640- struct device_node * np ;
16411640 struct device_node * node = dev -> of_node ;
16421641 int i , ret , domain ;
16431642 u16 val ;
@@ -1664,7 +1663,8 @@ static int imx_pcie_probe(struct platform_device *pdev)
16641663 pci -> pp .ops = & imx_pcie_host_dw_pme_ops ;
16651664
16661665 /* Find the PHY if one is defined, only imx7d uses it */
1667- np = of_parse_phandle (node , "fsl,imx7d-pcie-phy" , 0 );
1666+ struct device_node * np __free (device_node ) =
1667+ of_parse_phandle (node , "fsl,imx7d-pcie-phy" , 0 );
16681668 if (np ) {
16691669 struct resource res ;
16701670
@@ -1820,6 +1820,8 @@ static int imx_pcie_probe(struct platform_device *pdev)
18201820 } else {
18211821 if (imx_check_flag (imx_pcie , IMX_PCIE_FLAG_SKIP_L23_READY ))
18221822 pci -> pp .skip_l23_ready = true;
1823+ if (imx_check_flag (imx_pcie , IMX_PCIE_FLAG_KEEP_MSI_CAP ))
1824+ pci -> pp .keep_rp_msi_en = true;
18231825 pci -> pp .use_atu_msg = true;
18241826 ret = dw_pcie_host_init (& pci -> pp );
18251827 if (ret < 0 )
@@ -1843,6 +1845,7 @@ static void imx_pcie_shutdown(struct platform_device *pdev)
18431845
18441846 /* bring down link, so bootloader gets clean state in case of reboot */
18451847 imx_pcie_assert_core_reset (imx_pcie );
1848+ imx_pcie_assert_perst (imx_pcie , true);
18461849}
18471850
18481851static const struct imx_pcie_drvdata drvdata [] = {
@@ -1866,6 +1869,7 @@ static const struct imx_pcie_drvdata drvdata[] = {
18661869 .variant = IMX6SX ,
18671870 .flags = IMX_PCIE_FLAG_IMX_PHY |
18681871 IMX_PCIE_FLAG_SPEED_CHANGE_WORKAROUND |
1872+ IMX_PCIE_FLAG_SKIP_L23_READY |
18691873 IMX_PCIE_FLAG_SUPPORTS_SUSPEND ,
18701874 .gpr = "fsl,imx6q-iomuxc-gpr" ,
18711875 .ltssm_off = IOMUXC_GPR12 ,
@@ -1897,6 +1901,7 @@ static const struct imx_pcie_drvdata drvdata[] = {
18971901 [IMX7D ] = {
18981902 .variant = IMX7D ,
18991903 .flags = IMX_PCIE_FLAG_SUPPORTS_SUSPEND |
1904+ IMX_PCIE_FLAG_KEEP_MSI_CAP |
19001905 IMX_PCIE_FLAG_HAS_APP_RESET |
19011906 IMX_PCIE_FLAG_SKIP_L23_READY |
19021907 IMX_PCIE_FLAG_HAS_PHY_RESET ,
@@ -1909,6 +1914,7 @@ static const struct imx_pcie_drvdata drvdata[] = {
19091914 [IMX8MQ ] = {
19101915 .variant = IMX8MQ ,
19111916 .flags = IMX_PCIE_FLAG_HAS_APP_RESET |
1917+ IMX_PCIE_FLAG_KEEP_MSI_CAP |
19121918 IMX_PCIE_FLAG_HAS_PHY_RESET |
19131919 IMX_PCIE_FLAG_SUPPORTS_SUSPEND ,
19141920 .gpr = "fsl,imx8mq-iomuxc-gpr" ,
@@ -1923,6 +1929,7 @@ static const struct imx_pcie_drvdata drvdata[] = {
19231929 [IMX8MM ] = {
19241930 .variant = IMX8MM ,
19251931 .flags = IMX_PCIE_FLAG_SUPPORTS_SUSPEND |
1932+ IMX_PCIE_FLAG_KEEP_MSI_CAP |
19261933 IMX_PCIE_FLAG_HAS_PHYDRV |
19271934 IMX_PCIE_FLAG_HAS_APP_RESET ,
19281935 .gpr = "fsl,imx8mm-iomuxc-gpr" ,
0 commit comments