From: Frank Li <Frank.li@nxp.com>
To: Sherry Sun <sherry.sun@nxp.com>
Cc: 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, s.hauer@pengutronix.de,
festevam@gmail.com, imx@lists.linux.dev, kernel@pengutronix.de,
linux-pci@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
devicetree@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH V5 04/12] PCI: imx6: Add support for parsing the reset property in new Root Port binding
Date: Fri, 13 Feb 2026 10:32:33 -0500 [thread overview]
Message-ID: <aY9EESNDhZ5ZvtL0@lizhi-Precision-Tower-5810> (raw)
In-Reply-To: <20260213040852.3340547-5-sherry.sun@nxp.com>
On Fri, Feb 13, 2026 at 12:08:44PM +0800, Sherry Sun wrote:
> The current DT binding for pci-imx6 specifies the 'reset-gpios' property
> in the host bridge node. However, the PERST# signal logically belongs to
> individual Root Ports rather than the host bridge itself. This becomes
> important when supporting PCIe KeyE connector and PCI power control
> framework for pci-imx6 driver, which requires properties to be specified
> in Root Port nodes.
>
> Add support for parsing 'reset-gpios' from Root Port child nodes using
> the common helper pci_host_common_parse_ports(). The parsed reset GPIOs
> are stored in the bridge's ports list and accessed during core reset
> operations. Pre-allocate pci_host_bridge in imx_pcie_probe() for RC mode
> to enable early Root Port parsing.
>
> 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 | 81 ++++++++++++++++++++++-----
> 1 file changed, 67 insertions(+), 14 deletions(-)
>
> diff --git a/drivers/pci/controller/dwc/pci-imx6.c b/drivers/pci/controller/dwc/pci-imx6.c
> index a5b8d0b71677..75afd56dad50 100644
> --- a/drivers/pci/controller/dwc/pci-imx6.c
> +++ b/drivers/pci/controller/dwc/pci-imx6.c
> @@ -34,6 +34,7 @@
> #include <linux/pm_runtime.h>
>
> #include "../../pci.h"
> +#include "../pci-host-common.h"
> #include "pcie-designware.h"
>
> #define IMX8MQ_GPR_PCIE_REF_USE_PAD BIT(9)
> @@ -150,7 +151,6 @@ struct imx_lut_data {
>
> struct imx_pcie {
> struct dw_pcie *pci;
> - struct gpio_desc *reset_gpiod;
> struct clk_bulk_data *clks;
> int num_clks;
> bool supports_clkreq;
> @@ -897,29 +897,40 @@ 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 dw_pcie *pci = imx_pcie->pci;
> + struct pci_host_bridge *bridge = pci->pp.bridge;
> + struct pci_host_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);
> + if (bridge)
> + list_for_each_entry(port, &bridge->ports, list)
> + gpiod_set_value_cansleep(port->reset, 1);
> }
>
> static int imx_pcie_deassert_core_reset(struct imx_pcie *imx_pcie)
> {
> + struct dw_pcie *pci = imx_pcie->pci;
> + struct pci_host_bridge *bridge = pci->pp.bridge;
> + struct pci_host_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);
> - }
> + if (bridge)
> + list_for_each_entry(port, &bridge->ports, list)
> + if (port->reset) {
> + msleep(PCIE_T_PVPERL_MS);
> + gpiod_set_value_cansleep(port->reset, 0);
> + msleep(PCIE_RESET_CONFIG_WAIT_MS);
> + }
>
> return 0;
> }
> @@ -1642,11 +1653,39 @@ static const struct dev_pm_ops imx_pcie_pm_ops = {
> imx_pcie_resume_noirq)
> };
>
> +static int imx_pcie_parse_legacy_binding(struct imx_pcie *pcie)
> +{
> + struct device *dev = pcie->pci->dev;
> + struct pci_host_bridge *bridge = pcie->pci->pp.bridge;
> + struct pci_host_port *port;
> + struct gpio_desc *reset;
> +
> + if (!bridge) {
> + dev_err(dev, "Bridge not allocated yet\n");
> + return -EINVAL;
> + }
> +
> + 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, &bridge->ports);
> +
> + return 0;
> +}
> +
> static int imx_pcie_probe(struct platform_device *pdev)
> {
> struct device *dev = &pdev->dev;
> struct dw_pcie *pci;
> struct imx_pcie *imx_pcie;
> + struct pci_host_bridge *bridge;
> struct device_node *np;
> struct device_node *node = dev->of_node;
> int i, ret, domain;
> @@ -1688,12 +1727,26 @@ 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");
> + /* For RC mode, allocate bridge early so we can parse Root Ports. */
> + if (imx_pcie->drvdata->mode != DW_PCIE_EP_TYPE) {
> + bridge = devm_pci_alloc_host_bridge(dev, 0);
> + if (!bridge)
> + return -ENOMEM;
> +
> + pci->pp.bridge = bridge;
> +
> + /* Parse Root Port nodes */
> + ret = pci_host_common_parse_ports(bridge);
> + if (ret) {
> + if (ret != -ENOENT)
> + return dev_err_probe(dev, ret, "Failed to parse Root Port\n");
> +
> + /* Fallback to legacy binding for DT backwards compatibility */
> + ret = imx_pcie_parse_legacy_binding(imx_pcie);
> + if (ret)
> + return dev_err_probe(dev, ret, "Unable to get reset gpio\n");
> + }
> + }
if parse in dwc or in devm_pci_alloc_host_bridge(), needn't these code
here.
Frank
>
> /* 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-02-13 15:32 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-13 4:08 [PATCH V5 00/12] pci-imx6: Add support for parsing the reset property in new Root Port binding Sherry Sun
2026-02-13 4:08 ` [PATCH V5 01/12] dt-bindings: PCI: fsl,imx6q-pcie: Add reset GPIO in Root Port node Sherry Sun
2026-02-13 4:08 ` [PATCH V5 02/12] PCI: host-generic: Add common helpers for parsing Root Port properties Sherry Sun
2026-02-16 16:21 ` Manivannan Sadhasivam
2026-02-24 10:24 ` Sherry Sun
2026-02-25 13:15 ` Manivannan Sadhasivam
2026-02-26 3:40 ` Sherry Sun
2026-02-28 1:58 ` Hongxing Zhu
2026-02-28 15:05 ` Manivannan Sadhasivam
2026-02-13 4:08 ` [PATCH V5 03/12] PCI: dwc: Allow external allocation of pci_host_bridge Sherry Sun
2026-02-13 15:29 ` Frank Li
2026-02-16 16:25 ` Manivannan Sadhasivam
2026-02-24 10:34 ` Sherry Sun
2026-02-13 4:08 ` [PATCH V5 04/12] PCI: imx6: Add support for parsing the reset property in new Root Port binding Sherry Sun
2026-02-13 15:32 ` Frank Li [this message]
2026-02-13 4:08 ` [PATCH V5 05/12] arm: dts: imx6qdl: Add Root Port node and PERST property Sherry Sun
2026-02-13 4:08 ` [PATCH V5 06/12] arm: dts: imx6sx: " Sherry Sun
2026-02-13 4:08 ` [PATCH V5 07/12] arm: dts: imx7d: " Sherry Sun
2026-02-13 4:08 ` [PATCH V5 08/12] arm64: dts: imx8mm: " Sherry Sun
2026-02-13 4:08 ` [PATCH V5 09/12] arm64: dts: imx8mp: " Sherry Sun
2026-02-13 4:08 ` [PATCH V5 10/12] arm64: dts: imx8mq: " Sherry Sun
2026-02-13 4:08 ` [PATCH V5 11/12] arm64: dts: imx8dxl/qm/qxp: " Sherry Sun
2026-02-13 4:08 ` [PATCH V5 12/12] arm64: dts: imx95: " 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=aY9EESNDhZ5ZvtL0@lizhi-Precision-Tower-5810 \
--to=frank.li@nxp.com \
--cc=bhelgaas@google.com \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=festevam@gmail.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=sherry.sun@nxp.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