linux-pci.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Vidya Sagar <vidyas@nvidia.com>
To: <bhelgaas@google.com>, <robh+dt@kernel.org>,
	<krzysztof.kozlowski+dt@linaro.org>, <lpieralisi@kernel.org>,
	<kw@linux.com>, <thierry.reding@gmail.com>,
	<jonathanh@nvidia.com>, <mani@kernel.org>,
	<Sergey.Semin@baikalelectronics.ru>, <jszhang@kernel.org>
Cc: <linux-pci@vger.kernel.org>, <linux-tegra@vger.kernel.org>,
	<linux-kernel@vger.kernel.org>, <devicetree@vger.kernel.org>,
	<kthota@nvidia.com>, <mmaddireddy@nvidia.com>,
	<vidyas@nvidia.com>, <sagar.tv@gmail.com>
Subject: [PATCH V1 3/4] PCI: tegra194: Add support to configure a pluggable slot
Date: Sat, 1 Oct 2022 00:57:46 +0530	[thread overview]
Message-ID: <20220930192747.21471-4-vidyas@nvidia.com> (raw)
In-Reply-To: <20220930192747.21471-1-vidyas@nvidia.com>

Add support to configure a slot as a pluggable slot by not power-gating
the respective controller based on the DT property "hotplug-gpios".

Signed-off-by: Vidya Sagar <vidyas@nvidia.com>
---
 drivers/pci/controller/dwc/pcie-tegra194.c | 21 ++++++++++++++-------
 1 file changed, 14 insertions(+), 7 deletions(-)

diff --git a/drivers/pci/controller/dwc/pcie-tegra194.c b/drivers/pci/controller/dwc/pcie-tegra194.c
index 2600304522eb..0370e881422d 100644
--- a/drivers/pci/controller/dwc/pcie-tegra194.c
+++ b/drivers/pci/controller/dwc/pcie-tegra194.c
@@ -280,6 +280,8 @@ struct tegra_pcie_dw {
 	unsigned int phy_count;
 	struct phy **phys;
 
+	bool slot_pluggable;
+
 	struct dentry *debugfs;
 
 	/* Endpoint mode specific */
@@ -1089,6 +1091,7 @@ static int tegra_pcie_dw_parse_dt(struct tegra_pcie_dw *pcie)
 {
 	struct platform_device *pdev = to_platform_device(pcie->dev);
 	struct device_node *np = pcie->dev->of_node;
+	struct property *prop;
 	int ret;
 
 	pcie->dbi_res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "dbi");
@@ -1158,6 +1161,10 @@ static int tegra_pcie_dw_parse_dt(struct tegra_pcie_dw *pcie)
 		pcie->enable_srns =
 			of_property_read_bool(np, "nvidia,enable-srns");
 
+	prop = of_find_property(np, "hotplug-gpios", NULL);
+	if (prop)
+		pcie->slot_pluggable = true;
+
 	if (pcie->of_data->mode == DW_PCIE_RC_TYPE)
 		return 0;
 
@@ -1655,7 +1662,7 @@ static int tegra_pcie_config_rp(struct tegra_pcie_dw *pcie)
 	}
 
 	pcie->link_state = tegra_pcie_dw_link_up(&pcie->pci);
-	if (!pcie->link_state) {
+	if (!pcie->link_state && !pcie->slot_pluggable) {
 		ret = -ENOMEDIUM;
 		goto fail_host_init;
 	}
@@ -2267,7 +2274,7 @@ static int tegra_pcie_dw_remove(struct platform_device *pdev)
 	struct tegra_pcie_dw *pcie = platform_get_drvdata(pdev);
 
 	if (pcie->of_data->mode == DW_PCIE_RC_TYPE) {
-		if (!pcie->link_state)
+		if (!pcie->link_state && !pcie->slot_pluggable)
 			return 0;
 
 		debugfs_remove_recursive(pcie->debugfs);
@@ -2296,7 +2303,7 @@ static int tegra_pcie_dw_suspend_late(struct device *dev)
 		return -EPERM;
 	}
 
-	if (!pcie->link_state)
+	if (!pcie->link_state && !pcie->slot_pluggable)
 		return 0;
 
 	/* Enable HW_HOT_RST mode */
@@ -2315,7 +2322,7 @@ static int tegra_pcie_dw_suspend_noirq(struct device *dev)
 {
 	struct tegra_pcie_dw *pcie = dev_get_drvdata(dev);
 
-	if (!pcie->link_state)
+	if (!pcie->link_state && !pcie->slot_pluggable)
 		return 0;
 
 	tegra_pcie_downstream_dev_to_D0(pcie);
@@ -2330,7 +2337,7 @@ static int tegra_pcie_dw_resume_noirq(struct device *dev)
 	struct tegra_pcie_dw *pcie = dev_get_drvdata(dev);
 	int ret;
 
-	if (!pcie->link_state)
+	if (!pcie->link_state && !pcie->slot_pluggable)
 		return 0;
 
 	ret = tegra_pcie_config_controller(pcie, true);
@@ -2366,7 +2373,7 @@ static int tegra_pcie_dw_resume_early(struct device *dev)
 		return -ENOTSUPP;
 	}
 
-	if (!pcie->link_state)
+	if (!pcie->link_state && !pcie->slot_pluggable)
 		return 0;
 
 	/* Disable HW_HOT_RST mode */
@@ -2388,7 +2395,7 @@ static void tegra_pcie_dw_shutdown(struct platform_device *pdev)
 	struct tegra_pcie_dw *pcie = platform_get_drvdata(pdev);
 
 	if (pcie->of_data->mode == DW_PCIE_RC_TYPE) {
-		if (!pcie->link_state)
+		if (!pcie->link_state && !pcie->slot_pluggable)
 			return;
 
 		debugfs_remove_recursive(pcie->debugfs);
-- 
2.17.1


  parent reply	other threads:[~2022-09-30 19:28 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-30 19:27 [PATCH V1 0/4] GPIO based PCIe Hot-Plug support Vidya Sagar
2022-09-30 19:27 ` [PATCH V1 1/4] dt-bindings: Add "hotplug-gpios" PCIe property Vidya Sagar
2022-10-01 15:56   ` Lukas Wunner
2022-10-01 16:10     ` Pali Rohár
2022-09-30 19:27 ` [PATCH V1 2/4] PCI/hotplug: Add GPIO PCIe hotplug driver Vidya Sagar
2022-09-30 19:27 ` Vidya Sagar [this message]
2022-09-30 19:27 ` [PATCH V1 4/4] PCI: tegra194: Enable GPIO based Hot-Plug support Vidya Sagar
2022-10-01 16:00 ` [PATCH V1 0/4] GPIO based PCIe " Lukas Wunner
2022-10-01 16:20   ` Pali Rohár
2022-10-01 23:50     ` Jonathan Derrick
2022-10-03 18:09       ` Bjorn Helgaas
2022-10-03 18:21         ` Pali Rohár
2022-10-03 19:18           ` Jonathan Derrick
2022-10-04  4:04           ` Vidya Sagar
2022-10-10  6:14             ` Vidya Sagar
2022-10-17  2:46               ` Vidya Sagar
2022-11-09 15:35                 ` Manivannan Sadhasivam
2022-10-03 17:04 ` Rob Herring

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220930192747.21471-4-vidyas@nvidia.com \
    --to=vidyas@nvidia.com \
    --cc=Sergey.Semin@baikalelectronics.ru \
    --cc=bhelgaas@google.com \
    --cc=devicetree@vger.kernel.org \
    --cc=jonathanh@nvidia.com \
    --cc=jszhang@kernel.org \
    --cc=krzysztof.kozlowski+dt@linaro.org \
    --cc=kthota@nvidia.com \
    --cc=kw@linux.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=linux-tegra@vger.kernel.org \
    --cc=lpieralisi@kernel.org \
    --cc=mani@kernel.org \
    --cc=mmaddireddy@nvidia.com \
    --cc=robh+dt@kernel.org \
    --cc=sagar.tv@gmail.com \
    --cc=thierry.reding@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).