[PATCH V14 04/12] PCI: imx6: Add support for parsing the reset property in new Root Port binding
Hongxing Zhu
hongxing.zhu at nxp.com
Thu May 7 20:15:25 PDT 2026
> -----Original Message-----
> From: Sherry Sun <sherry.sun at nxp.com>
> Sent: Wednesday, April 22, 2026 5:36 PM
> To: robh at kernel.org; krzk+dt at kernel.org; conor+dt at kernel.org; Frank Li
> <frank.li at nxp.com>; s.hauer at pengutronix.de; kernel at pengutronix.de;
> festevam at gmail.com; lpieralisi at kernel.org; kwilczynski at kernel.org;
> mani at kernel.org; bhelgaas at google.com; Hongxing Zhu
> <hongxing.zhu at nxp.com>; l.stach at pengutronix.de
> Cc: imx at lists.linux.dev; linux-pci at vger.kernel.org; linux-arm-
> kernel at lists.infradead.org; devicetree at vger.kernel.org; linux-
> kernel at vger.kernel.org
> Subject: [PATCH V14 04/12] PCI: imx6: Add support for parsing the reset property
> in new Root Port binding
>
> 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 nodes and the PCIe bridge
> nodes under the Root Port using the common helper
> pci_host_common_parse_ports(), and update the reset GPIO handling to use the
> parsed port list from bridge->ports. 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 nodes.
>
> Since now the reset GPIO is obtained with GPIOD_ASIS flag, it may be in input
> mode, using gpiod_direction_output() instead of
> gpiod_set_value_cansleep() to ensure the reset GPIO is properly configured as
> output before setting its value.
>
> Signed-off-by: Sherry Sun <sherry.sun at nxp.com>
Acked-by: Richard Zhu <hongxing.zhu at nxp.com>
Best Regards
Richard Zhu
> ---
> drivers/pci/controller/dwc/pci-imx6.c | 83 ++++++++++++++++++++++-----
> 1 file changed, 70 insertions(+), 13 deletions(-)
>
> diff --git a/drivers/pci/controller/dwc/pci-imx6.c
> b/drivers/pci/controller/dwc/pci-imx6.c
> index 735127ed1455..a2742620279a 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)
> @@ -152,7 +153,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;
> @@ -1224,6 +1224,41 @@ static void imx_pcie_disable_device(struct
> pci_host_bridge *bridge,
> imx_pcie_remove_lut(imx_pcie, pci_dev_id(pdev)); }
>
> +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 pci_host_perst *perst;
> + struct gpio_desc *reset;
> +
> + reset = devm_gpiod_get_optional(dev, "reset", GPIOD_ASIS);
> + if (IS_ERR(reset))
> + return PTR_ERR(reset);
> +
> + if (!reset)
> + return 0;
> +
> + port = devm_kzalloc(dev, sizeof(*port), GFP_KERNEL);
> + if (!port)
> + return -ENOMEM;
> +
> + perst = devm_kzalloc(dev, sizeof(*perst), GFP_KERNEL);
> + if (!perst)
> + return -ENOMEM;
> +
> + INIT_LIST_HEAD(&port->perst);
> + perst->desc = reset;
> + INIT_LIST_HEAD(&perst->list);
> + list_add_tail(&perst->list, &port->perst);
> +
> + INIT_LIST_HEAD(&port->list);
> + list_add_tail(&port->list, &bridge->ports);
> +
> + return devm_add_action_or_reset(dev, pci_host_common_delete_ports,
> + &bridge->ports);
> +}
> +
> static void imx_pcie_vpcie_aux_disable(void *data) {
> struct regulator *vpcie_aux = data;
> @@ -1233,14 +1268,26 @@ static void imx_pcie_vpcie_aux_disable(void *data)
>
> static void imx_pcie_assert_perst(struct imx_pcie *imx_pcie, bool assert) {
> + struct dw_pcie *pci = imx_pcie->pci;
> + struct pci_host_bridge *bridge = pci->pp.bridge;
> + struct pci_host_perst *perst;
> + struct pci_host_port *port;
> +
> + if (!bridge || list_empty(&bridge->ports))
> + return;
> +
> if (assert) {
> - gpiod_set_value_cansleep(imx_pcie->reset_gpiod, 1);
> + list_for_each_entry(port, &bridge->ports, list) {
> + list_for_each_entry(perst, &port->perst, list)
> + gpiod_direction_output(perst->desc, 1);
> + }
> } else {
> - if (imx_pcie->reset_gpiod) {
> - msleep(PCIE_T_PVPERL_MS);
> - gpiod_set_value_cansleep(imx_pcie->reset_gpiod, 0);
> - msleep(PCIE_RESET_CONFIG_WAIT_MS);
> + mdelay(PCIE_T_PVPERL_MS);
> + list_for_each_entry(port, &bridge->ports, list) {
> + list_for_each_entry(perst, &port->perst, list)
> + gpiod_direction_output(perst->desc, 0);
> }
> + mdelay(PCIE_RESET_CONFIG_WAIT_MS);
> }
> }
>
> @@ -1249,8 +1296,25 @@ static int imx_pcie_host_init(struct dw_pcie_rp *pp)
> struct dw_pcie *pci = to_dw_pcie_from_pp(pp);
> struct device *dev = pci->dev;
> struct imx_pcie *imx_pcie = to_imx_pcie(pci);
> + struct pci_host_bridge *bridge = pp->bridge;
> int ret;
>
> + if (bridge && list_empty(&bridge->ports)) {
> + /* Parse Root Port nodes if present */
> + ret = pci_host_common_parse_ports(dev, bridge);
> + if (ret) {
> + if (ret != -ENODEV) {
> + dev_err(dev, "Failed to parse Root Port
> nodes: %d\n", ret);
> + return ret;
> + }
> +
> + /* Fallback to legacy binding for DT backwards
> compatibility */
> + ret = imx_pcie_parse_legacy_binding(imx_pcie);
> + if (ret)
> + return ret;
> + }
> + }
> +
> imx_pcie_assert_perst(imx_pcie, true);
>
> /* Keep 3.3Vaux supply enabled for the entire PCIe controller lifecycle */
> @@ -1704,13 +1768,6 @@ 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");
> -
> /* Fetch clocks */
> imx_pcie->num_clks = devm_clk_bulk_get_all(dev, &imx_pcie->clks);
> if (imx_pcie->num_clks < 0)
> --
> 2.37.1
More information about the linux-arm-kernel
mailing list