From: Sherry Sun <sherry.sun@nxp.com>
To: hongxing.zhu@nxp.com, l.stach@pengutronix.de,
bhelgaas@google.com, lpieralisi@kernel.org,
kwilczynski@kernel.org, mani@kernel.org, robh@kernel.org,
krzk+dt@kernel.org, conor+dt@kernel.org, shawnguo@kernel.org,
s.hauer@pengutronix.de, festevam@gmail.com, frank.li@nxp.com
Cc: kernel@pengutronix.de, linux-pci@vger.kernel.org,
devicetree@vger.kernel.org, imx@lists.linux.dev,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org
Subject: [PATCH 02/10] PCI: imx6: Add support for parsing the reset property in new Root Port binding
Date: Mon, 19 Jan 2026 18:02:27 +0800 [thread overview]
Message-ID: <20260119100235.1173839-3-sherry.sun@nxp.com> (raw)
In-Reply-To: <20260119100235.1173839-1-sherry.sun@nxp.com>
DT binding allows specifying 'reset' property in both host bridge and
Root Port nodes, but specifying in the host bridge node is marked as
deprecated. So add support for parsing the new binding that uses
'reset-gpios' property for PERST#.
To maintain DT backwards compatibility, fallback to the legacy method of
parsing the host bridge node if the reset property is not present in the
Root Port node.
Signed-off-by: Sherry Sun <sherry.sun@nxp.com>
---
drivers/pci/controller/dwc/pci-imx6.c | 128 +++++++++++++++++++++++---
1 file changed, 114 insertions(+), 14 deletions(-)
diff --git a/drivers/pci/controller/dwc/pci-imx6.c b/drivers/pci/controller/dwc/pci-imx6.c
index 1d8677d7de04..0592b24071bc 100644
--- a/drivers/pci/controller/dwc/pci-imx6.c
+++ b/drivers/pci/controller/dwc/pci-imx6.c
@@ -147,10 +147,15 @@ struct imx_lut_data {
u32 data2;
};
+struct imx_pcie_port {
+ struct list_head list;
+ struct gpio_desc *reset;
+};
+
struct imx_pcie {
struct dw_pcie *pci;
- struct gpio_desc *reset_gpiod;
struct clk_bulk_data *clks;
+ struct list_head ports;
int num_clks;
bool supports_clkreq;
bool enable_ext_refclk;
@@ -896,29 +901,35 @@ static int imx95_pcie_core_reset(struct imx_pcie *imx_pcie, bool assert)
static void imx_pcie_assert_core_reset(struct imx_pcie *imx_pcie)
{
+ struct imx_pcie_port *port;
+
reset_control_assert(imx_pcie->pciephy_reset);
if (imx_pcie->drvdata->core_reset)
imx_pcie->drvdata->core_reset(imx_pcie, true);
/* Some boards don't have PCIe reset GPIO. */
- gpiod_set_value_cansleep(imx_pcie->reset_gpiod, 1);
+ list_for_each_entry(port, &imx_pcie->ports, list)
+ gpiod_set_value_cansleep(port->reset, 1);
}
static int imx_pcie_deassert_core_reset(struct imx_pcie *imx_pcie)
{
+ struct imx_pcie_port *port;
+
reset_control_deassert(imx_pcie->pciephy_reset);
if (imx_pcie->drvdata->core_reset)
imx_pcie->drvdata->core_reset(imx_pcie, false);
/* Some boards don't have PCIe reset GPIO. */
- if (imx_pcie->reset_gpiod) {
- msleep(100);
- gpiod_set_value_cansleep(imx_pcie->reset_gpiod, 0);
- /* Wait for 100ms after PERST# deassertion (PCIe r5.0, 6.6.1) */
- msleep(100);
- }
+ list_for_each_entry(port, &imx_pcie->ports, list)
+ if (port->reset) {
+ msleep(100);
+ gpiod_set_value_cansleep(port->reset, 0);
+ /* Wait for 100ms after PERST# deassertion (PCIe r5.0, 6.6.1) */
+ msleep(100);
+ }
return 0;
}
@@ -1638,6 +1649,81 @@ static const struct dev_pm_ops imx_pcie_pm_ops = {
imx_pcie_resume_noirq)
};
+static int imx_pcie_parse_port(struct imx_pcie *pcie, struct device_node *node)
+{
+ struct device *dev = pcie->pci->dev;
+ struct imx_pcie_port *port;
+ struct gpio_desc *reset;
+
+ reset = devm_fwnode_gpiod_get(dev, of_fwnode_handle(node),
+ "reset", GPIOD_OUT_HIGH, "PCIe reset");
+ if (IS_ERR(reset))
+ return PTR_ERR(reset);
+
+ port = devm_kzalloc(dev, sizeof(*port), GFP_KERNEL);
+ if (!port)
+ return -ENOMEM;
+
+ port->reset = reset;
+ INIT_LIST_HEAD(&port->list);
+ list_add_tail(&port->list, &pcie->ports);
+
+ return 0;
+}
+
+static int imx_pcie_parse_ports(struct imx_pcie *pcie)
+{
+ struct device *dev = pcie->pci->dev;
+ struct imx_pcie_port *port, *tmp;
+ int ret = -ENOENT;
+
+ for_each_available_child_of_node_scoped(dev->of_node, of_port) {
+ if (!of_node_is_type(of_port, "pci"))
+ continue;
+ ret = imx_pcie_parse_port(pcie, of_port);
+ if (ret)
+ goto err_port_del;
+ }
+
+ return ret;
+
+err_port_del:
+ list_for_each_entry_safe(port, tmp, &pcie->ports, list)
+ list_del(&port->list);
+
+ return ret;
+}
+
+static int imx_pcie_parse_legacy_binding(struct imx_pcie *pcie)
+{
+ struct device *dev = pcie->pci->dev;
+ struct imx_pcie_port *port;
+ struct gpio_desc *reset;
+
+ reset = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_HIGH);
+ if (IS_ERR(reset))
+ return PTR_ERR(reset);
+
+ port = devm_kzalloc(dev, sizeof(*port), GFP_KERNEL);
+ if (!port)
+ return -ENOMEM;
+
+ port->reset = reset;
+ INIT_LIST_HEAD(&port->list);
+ list_add_tail(&port->list, &pcie->ports);
+
+ return 0;
+}
+
+static void imx_pcie_delete_ports(void *data)
+{
+ struct imx_pcie *pcie = data;
+ struct imx_pcie_port *port, *tmp;
+
+ list_for_each_entry_safe(port, tmp, &pcie->ports, list)
+ list_del(&port->list);
+}
+
static int imx_pcie_probe(struct platform_device *pdev)
{
struct device *dev = &pdev->dev;
@@ -1656,6 +1742,8 @@ static int imx_pcie_probe(struct platform_device *pdev)
if (!pci)
return -ENOMEM;
+ INIT_LIST_HEAD(&imx_pcie->ports);
+
pci->dev = dev;
pci->ops = &dw_pcie_ops;
@@ -1684,12 +1772,24 @@ static int imx_pcie_probe(struct platform_device *pdev)
return PTR_ERR(imx_pcie->phy_base);
}
- /* Fetch GPIOs */
- imx_pcie->reset_gpiod = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_HIGH);
- if (IS_ERR(imx_pcie->reset_gpiod))
- return dev_err_probe(dev, PTR_ERR(imx_pcie->reset_gpiod),
- "unable to get reset gpio\n");
- gpiod_set_consumer_name(imx_pcie->reset_gpiod, "PCIe reset");
+ ret = imx_pcie_parse_ports(imx_pcie);
+ if (ret) {
+ if (ret != -ENOENT)
+ return dev_err_probe(dev, ret, "Failed to parse Root Port: %d\n", ret);
+
+ /*
+ * In the case of properties not populated in Root Port node,
+ * fallback to the legacy method of parsing the Host Bridge
+ * node. This is to maintain DT backwards compatibility.
+ */
+ ret = imx_pcie_parse_legacy_binding(imx_pcie);
+ if (ret)
+ return dev_err_probe(dev, ret, "Unable to get reset gpio: %d\n", ret);
+ }
+
+ ret = devm_add_action_or_reset(dev, imx_pcie_delete_ports, imx_pcie);
+ if (ret)
+ return ret;
/* Fetch clocks */
imx_pcie->num_clks = devm_clk_bulk_get_all(dev, &imx_pcie->clks);
--
2.37.1
next prev parent reply other threads:[~2026-01-19 10:03 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-19 10:02 [PATCH 00/10] pci-imx6: Add support for parsing the reset property in new Root Port binding Sherry Sun
2026-01-19 10:02 ` [PATCH 01/10] dt-bindings: PCI: fsl,imx6q-pcie: Add reset GPIO in Root Port node Sherry Sun
2026-01-19 16:15 ` Frank Li
2026-01-20 2:22 ` Sherry Sun
2026-01-21 16:40 ` Rob Herring
2026-01-22 2:31 ` Sherry Sun
2026-01-19 10:02 ` Sherry Sun [this message]
2026-01-19 16:22 ` [PATCH 02/10] PCI: imx6: Add support for parsing the reset property in new Root Port binding Frank Li
2026-01-20 2:33 ` Sherry Sun
2026-01-19 10:02 ` [PATCH 03/10] arm: dts: imx6qdl: Add Root Port node and move PERST property to Root Port node Sherry Sun
2026-01-19 16:24 ` Frank Li
2026-01-20 2:44 ` Sherry Sun
2026-01-20 16:48 ` Frank Li
2026-01-21 6:44 ` Sherry Sun
2026-01-19 10:02 ` [PATCH 04/10] arm: dts: imx6sx: " Sherry Sun
2026-01-19 10:02 ` [PATCH 05/10] arm: dts: imx7d: " Sherry Sun
2026-01-19 10:02 ` [PATCH 06/10] arm64: dts: imx8mm: " Sherry Sun
2026-01-19 10:02 ` [PATCH 07/10] arm64: dts: imx8mp: " Sherry Sun
2026-01-19 10:02 ` [PATCH 08/10] arm64: dts: imx8mq: Add Root Port nodes " Sherry Sun
2026-01-19 10:02 ` [PATCH 09/10] arm64: dts: imx8dxl/qm/qxp: " Sherry Sun
2026-01-19 10:02 ` [PATCH 10/10] arm64: dts: imx95: " Sherry Sun
2026-01-21 23:06 ` [PATCH 00/10] pci-imx6: Add support for parsing the reset property in new Root Port binding Bjorn Helgaas
2026-01-22 4:46 ` Sherry Sun
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=20260119100235.1173839-3-sherry.sun@nxp.com \
--to=sherry.sun@nxp.com \
--cc=bhelgaas@google.com \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=festevam@gmail.com \
--cc=frank.li@nxp.com \
--cc=hongxing.zhu@nxp.com \
--cc=imx@lists.linux.dev \
--cc=kernel@pengutronix.de \
--cc=krzk+dt@kernel.org \
--cc=kwilczynski@kernel.org \
--cc=l.stach@pengutronix.de \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=lpieralisi@kernel.org \
--cc=mani@kernel.org \
--cc=robh@kernel.org \
--cc=s.hauer@pengutronix.de \
--cc=shawnguo@kernel.org \
/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