@@ -2145,12 +2145,18 @@ static int tegra_pcie_dw_remove(struct platform_device *pdev)
21452145{
21462146 struct tegra_pcie_dw * pcie = platform_get_drvdata (pdev );
21472147
2148- if (!pcie -> link_state )
2149- return 0 ;
2148+ if (pcie -> mode == DW_PCIE_RC_TYPE ) {
2149+ if (!pcie -> link_state )
2150+ return 0 ;
2151+
2152+ debugfs_remove_recursive (pcie -> debugfs );
2153+ tegra_pcie_deinit_controller (pcie );
2154+ pm_runtime_put_sync (pcie -> dev );
2155+ } else {
2156+ disable_irq (pcie -> pex_rst_irq );
2157+ pex_ep_event_pex_rst_assert (pcie );
2158+ }
21502159
2151- debugfs_remove_recursive (pcie -> debugfs );
2152- tegra_pcie_deinit_controller (pcie );
2153- pm_runtime_put_sync (pcie -> dev );
21542160 pm_runtime_disable (pcie -> dev );
21552161 tegra_bpmp_put (pcie -> bpmp );
21562162 if (pcie -> pex_refclk_sel_gpiod )
@@ -2164,6 +2170,11 @@ static int tegra_pcie_dw_suspend_late(struct device *dev)
21642170 struct tegra_pcie_dw * pcie = dev_get_drvdata (dev );
21652171 u32 val ;
21662172
2173+ if (pcie -> mode == DW_PCIE_EP_TYPE ) {
2174+ dev_err (dev , "Failed to Suspend as Tegra PCIe is in EP mode\n" );
2175+ return - EPERM ;
2176+ }
2177+
21672178 if (!pcie -> link_state )
21682179 return 0 ;
21692180
@@ -2251,18 +2262,24 @@ static void tegra_pcie_dw_shutdown(struct platform_device *pdev)
22512262{
22522263 struct tegra_pcie_dw * pcie = platform_get_drvdata (pdev );
22532264
2254- if (!pcie -> link_state )
2255- return ;
2265+ if (pcie -> mode == DW_PCIE_RC_TYPE ) {
2266+ if (!pcie -> link_state )
2267+ return ;
22562268
2257- debugfs_remove_recursive (pcie -> debugfs );
2258- tegra_pcie_downstream_dev_to_D0 (pcie );
2269+ debugfs_remove_recursive (pcie -> debugfs );
2270+ tegra_pcie_downstream_dev_to_D0 (pcie );
22592271
2260- disable_irq (pcie -> pci .pp .irq );
2261- if (IS_ENABLED (CONFIG_PCI_MSI ))
2262- disable_irq (pcie -> pci .pp .msi_irq );
2272+ disable_irq (pcie -> pci .pp .irq );
2273+ if (IS_ENABLED (CONFIG_PCI_MSI ))
2274+ disable_irq (pcie -> pci .pp .msi_irq );
22632275
2264- tegra_pcie_dw_pme_turnoff (pcie );
2265- tegra_pcie_unconfig_controller (pcie );
2276+ tegra_pcie_dw_pme_turnoff (pcie );
2277+ tegra_pcie_unconfig_controller (pcie );
2278+ pm_runtime_put_sync (pcie -> dev );
2279+ } else {
2280+ disable_irq (pcie -> pex_rst_irq );
2281+ pex_ep_event_pex_rst_assert (pcie );
2282+ }
22662283}
22672284
22682285static const struct tegra_pcie_dw_of_data tegra_pcie_dw_rc_of_data = {
0 commit comments