linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v1 1/2] dt-binding: pci-imx6: Add external reference clock mode support
@ 2025-06-18  7:48 Richard Zhu
  2025-06-18  7:48 ` [PATCH v1 2/2] PCI: imx6: " Richard Zhu
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Richard Zhu @ 2025-06-18  7:48 UTC (permalink / raw)
  To: frank.li, l.stach, lpieralisi, kwilczynski, mani, robh, bhelgaas,
	shawnguo, s.hauer, kernel, festevam
  Cc: linux-pci, linux-arm-kernel, imx, linux-kernel, Richard Zhu

On i.MX, the PCIe reference clock might come from either internal
system PLL or external clock source.
Add the external reference clock source for reference clock.

Signed-off-by: Richard Zhu <hongxing.zhu@nxp.com>
---
 Documentation/devicetree/bindings/pci/fsl,imx6q-pcie.yaml | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/Documentation/devicetree/bindings/pci/fsl,imx6q-pcie.yaml b/Documentation/devicetree/bindings/pci/fsl,imx6q-pcie.yaml
index ca5f2970f217..4b99fa8e7a25 100644
--- a/Documentation/devicetree/bindings/pci/fsl,imx6q-pcie.yaml
+++ b/Documentation/devicetree/bindings/pci/fsl,imx6q-pcie.yaml
@@ -219,7 +219,12 @@ allOf:
             - const: pcie_bus
             - const: pcie_phy
             - const: pcie_aux
-            - const: ref
+            - description: PCIe reference clock.
+              oneOf:
+              - description: The controller might be configured clocking
+                  coming in from either an internal system PLL or an
+                  external clock source.
+              enum: [ref, gio]
 
 unevaluatedProperties: false
 
-- 
2.37.1



^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH v1 2/2] PCI: imx6: Add external reference clock mode support
  2025-06-18  7:48 [PATCH v1 1/2] dt-binding: pci-imx6: Add external reference clock mode support Richard Zhu
@ 2025-06-18  7:48 ` Richard Zhu
  2025-06-18 16:45   ` Frank Li
  2025-06-18 13:43 ` [PATCH v1 1/2] dt-binding: pci-imx6: " Krzysztof Kozlowski
  2025-06-18 16:39 ` Frank Li
  2 siblings, 1 reply; 6+ messages in thread
From: Richard Zhu @ 2025-06-18  7:48 UTC (permalink / raw)
  To: frank.li, l.stach, lpieralisi, kwilczynski, mani, robh, bhelgaas,
	shawnguo, s.hauer, kernel, festevam
  Cc: linux-pci, linux-arm-kernel, imx, linux-kernel, Richard Zhu

The PCI Express reference clock of i.MX9 PCIes might come from external
clock source. Add the external reference clock mode support.

Signed-off-by: Richard Zhu <hongxing.zhu@nxp.com>
---
 drivers/pci/controller/dwc/pci-imx6.c | 34 ++++++++++++++++++++-------
 1 file changed, 26 insertions(+), 8 deletions(-)

diff --git a/drivers/pci/controller/dwc/pci-imx6.c b/drivers/pci/controller/dwc/pci-imx6.c
index 5a38cfaf989b..04c720377546 100644
--- a/drivers/pci/controller/dwc/pci-imx6.c
+++ b/drivers/pci/controller/dwc/pci-imx6.c
@@ -149,6 +149,7 @@ struct imx_pcie {
 	struct gpio_desc	*reset_gpiod;
 	struct clk_bulk_data	*clks;
 	int			num_clks;
+	bool			enable_ext_refclk;
 	struct regmap		*iomuxc_gpr;
 	u16			msi_ctrl;
 	u32			controller_id;
@@ -259,13 +260,24 @@ static int imx95_pcie_init_phy(struct imx_pcie *imx_pcie)
 			IMX95_PCIE_PHY_CR_PARA_SEL,
 			IMX95_PCIE_PHY_CR_PARA_SEL);
 
-	regmap_update_bits(imx_pcie->iomuxc_gpr,
-			   IMX95_PCIE_PHY_GEN_CTRL,
-			   IMX95_PCIE_REF_USE_PAD, 0);
-	regmap_update_bits(imx_pcie->iomuxc_gpr,
-			   IMX95_PCIE_SS_RW_REG_0,
-			   IMX95_PCIE_REF_CLKEN,
-			   IMX95_PCIE_REF_CLKEN);
+	if (imx_pcie->enable_ext_refclk) {
+		/* External clock is used as reference clock */
+		regmap_update_bits(imx_pcie->iomuxc_gpr,
+				   IMX95_PCIE_PHY_GEN_CTRL,
+				   IMX95_PCIE_REF_USE_PAD,
+				   IMX95_PCIE_REF_USE_PAD);
+		regmap_update_bits(imx_pcie->iomuxc_gpr,
+				   IMX95_PCIE_SS_RW_REG_0,
+				   IMX95_PCIE_REF_CLKEN, 0);
+	} else {
+		regmap_update_bits(imx_pcie->iomuxc_gpr,
+				   IMX95_PCIE_PHY_GEN_CTRL,
+				   IMX95_PCIE_REF_USE_PAD, 0);
+		regmap_update_bits(imx_pcie->iomuxc_gpr,
+				   IMX95_PCIE_SS_RW_REG_0,
+				   IMX95_PCIE_REF_CLKEN,
+				   IMX95_PCIE_REF_CLKEN);
+	}
 
 	return 0;
 }
@@ -1600,7 +1612,7 @@ static int imx_pcie_probe(struct platform_device *pdev)
 	struct imx_pcie *imx_pcie;
 	struct device_node *np;
 	struct device_node *node = dev->of_node;
-	int ret, domain;
+	int i, ret, domain;
 	u16 val;
 
 	imx_pcie = devm_kzalloc(dev, sizeof(*imx_pcie), GFP_KERNEL);
@@ -1651,6 +1663,12 @@ static int imx_pcie_probe(struct platform_device *pdev)
 	if (imx_pcie->num_clks < 0)
 		return dev_err_probe(dev, imx_pcie->num_clks,
 				     "failed to get clocks\n");
+	for (i = 0; i < imx_pcie->num_clks; i++) {
+		if (strncmp(imx_pcie->clks[i].id, "ref", 3) == 0)
+			imx_pcie->enable_ext_refclk = false;
+		else
+			imx_pcie->enable_ext_refclk = true;
+	}
 
 	if (imx_check_flag(imx_pcie, IMX_PCIE_FLAG_HAS_PHYDRV)) {
 		imx_pcie->phy = devm_phy_get(dev, "pcie-phy");
-- 
2.37.1



^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH v1 1/2] dt-binding: pci-imx6: Add external reference clock mode support
  2025-06-18  7:48 [PATCH v1 1/2] dt-binding: pci-imx6: Add external reference clock mode support Richard Zhu
  2025-06-18  7:48 ` [PATCH v1 2/2] PCI: imx6: " Richard Zhu
@ 2025-06-18 13:43 ` Krzysztof Kozlowski
  2025-06-19  3:39   ` Hongxing Zhu
  2025-06-18 16:39 ` Frank Li
  2 siblings, 1 reply; 6+ messages in thread
From: Krzysztof Kozlowski @ 2025-06-18 13:43 UTC (permalink / raw)
  To: Richard Zhu, frank.li, l.stach, lpieralisi, kwilczynski, mani,
	robh, bhelgaas, shawnguo, s.hauer, kernel, festevam
  Cc: linux-pci, linux-arm-kernel, imx, linux-kernel

On 18/06/2025 09:48, Richard Zhu wrote:
> On i.MX, the PCIe reference clock might come from either internal
> system PLL or external clock source.
> Add the external reference clock source for reference clock.
> 
> Signed-off-by: Richard Zhu <hongxing.zhu@nxp.com>
> ---
>  Documentation/devicetree/bindings/pci/fsl,imx6q-pcie.yaml | 7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)

<form letter>
Please use scripts/get_maintainers.pl to get a list of necessary people
and lists to CC. It might happen, that command when run on an older
kernel, gives you outdated entries. Therefore please be sure you base
your patches on recent Linux kernel.

Tools like b4 or scripts/get_maintainer.pl provide you proper list of
people, so fix your workflow. Tools might also fail if you work on some
ancient tree (don't, instead use mainline) or work on fork of kernel
(don't, instead use mainline). Just use b4 and everything should be
fine, although remember about `b4 prep --auto-to-cc` if you added new
patches to the patchset.

You missed at least devicetree list (maybe more), so this won't be
tested by automated tooling. Performing review on untested code might be
a waste of time.

Please kindly resend and include all necessary To/Cc entries.
</form letter>

Best regards,
Krzysztof


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v1 1/2] dt-binding: pci-imx6: Add external reference clock mode support
  2025-06-18  7:48 [PATCH v1 1/2] dt-binding: pci-imx6: Add external reference clock mode support Richard Zhu
  2025-06-18  7:48 ` [PATCH v1 2/2] PCI: imx6: " Richard Zhu
  2025-06-18 13:43 ` [PATCH v1 1/2] dt-binding: pci-imx6: " Krzysztof Kozlowski
@ 2025-06-18 16:39 ` Frank Li
  2 siblings, 0 replies; 6+ messages in thread
From: Frank Li @ 2025-06-18 16:39 UTC (permalink / raw)
  To: Richard Zhu
  Cc: l.stach, lpieralisi, kwilczynski, mani, robh, bhelgaas, shawnguo,
	s.hauer, kernel, festevam, linux-pci, linux-arm-kernel, imx,
	linux-kernel

On Wed, Jun 18, 2025 at 03:48:47PM +0800, Richard Zhu wrote:
> On i.MX, the PCIe reference clock might come from either internal
> system PLL or external clock source.
> Add the external reference clock source for reference clock.
>
> Signed-off-by: Richard Zhu <hongxing.zhu@nxp.com>
> ---
>  Documentation/devicetree/bindings/pci/fsl,imx6q-pcie.yaml | 7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/Documentation/devicetree/bindings/pci/fsl,imx6q-pcie.yaml b/Documentation/devicetree/bindings/pci/fsl,imx6q-pcie.yaml
> index ca5f2970f217..4b99fa8e7a25 100644
> --- a/Documentation/devicetree/bindings/pci/fsl,imx6q-pcie.yaml
> +++ b/Documentation/devicetree/bindings/pci/fsl,imx6q-pcie.yaml
> @@ -219,7 +219,12 @@ allOf:
>              - const: pcie_bus
>              - const: pcie_phy
>              - const: pcie_aux
> -            - const: ref
> +            - description: PCIe reference clock.
> +              oneOf:
> +              - description: The controller might be configured clocking
> +                  coming in from either an internal system PLL or an
> +                  external clock source.

start from new line

description:
  The controller's reference clock can come from one of two clock sources,
  internal system PLL or external OSC clock source.

> +              enum: [ref, gio]

gio? maybe 'ext' is better.

Suggest use b4 to avoid missed device tree mail list

Frank
>
>  unevaluatedProperties: false
>
> --
> 2.37.1
>


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v1 2/2] PCI: imx6: Add external reference clock mode support
  2025-06-18  7:48 ` [PATCH v1 2/2] PCI: imx6: " Richard Zhu
@ 2025-06-18 16:45   ` Frank Li
  0 siblings, 0 replies; 6+ messages in thread
From: Frank Li @ 2025-06-18 16:45 UTC (permalink / raw)
  To: Richard Zhu
  Cc: l.stach, lpieralisi, kwilczynski, mani, robh, bhelgaas, shawnguo,
	s.hauer, kernel, festevam, linux-pci, linux-arm-kernel, imx,
	linux-kernel

On Wed, Jun 18, 2025 at 03:48:48PM +0800, Richard Zhu wrote:
> The PCI Express reference clock of i.MX9 PCIes might come from external
> clock source. Add the external reference clock mode support.
>
> Signed-off-by: Richard Zhu <hongxing.zhu@nxp.com>
> ---
>  drivers/pci/controller/dwc/pci-imx6.c | 34 ++++++++++++++++++++-------
>  1 file changed, 26 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/pci/controller/dwc/pci-imx6.c b/drivers/pci/controller/dwc/pci-imx6.c
> index 5a38cfaf989b..04c720377546 100644
> --- a/drivers/pci/controller/dwc/pci-imx6.c
> +++ b/drivers/pci/controller/dwc/pci-imx6.c
> @@ -149,6 +149,7 @@ struct imx_pcie {
>  	struct gpio_desc	*reset_gpiod;
>  	struct clk_bulk_data	*clks;
>  	int			num_clks;
> +	bool			enable_ext_refclk;
>  	struct regmap		*iomuxc_gpr;
>  	u16			msi_ctrl;
>  	u32			controller_id;
> @@ -259,13 +260,24 @@ static int imx95_pcie_init_phy(struct imx_pcie *imx_pcie)
>  			IMX95_PCIE_PHY_CR_PARA_SEL,
>  			IMX95_PCIE_PHY_CR_PARA_SEL);
>
> -	regmap_update_bits(imx_pcie->iomuxc_gpr,
> -			   IMX95_PCIE_PHY_GEN_CTRL,
> -			   IMX95_PCIE_REF_USE_PAD, 0);
> -	regmap_update_bits(imx_pcie->iomuxc_gpr,
> -			   IMX95_PCIE_SS_RW_REG_0,
> -			   IMX95_PCIE_REF_CLKEN,
> -			   IMX95_PCIE_REF_CLKEN);
> +	if (imx_pcie->enable_ext_refclk) {
> +		/* External clock is used as reference clock */
> +		regmap_update_bits(imx_pcie->iomuxc_gpr,
> +				   IMX95_PCIE_PHY_GEN_CTRL,
> +				   IMX95_PCIE_REF_USE_PAD,
> +				   IMX95_PCIE_REF_USE_PAD);
> +		regmap_update_bits(imx_pcie->iomuxc_gpr,
> +				   IMX95_PCIE_SS_RW_REG_0,
> +				   IMX95_PCIE_REF_CLKEN, 0);
> +	} else {
> +		regmap_update_bits(imx_pcie->iomuxc_gpr,
> +				   IMX95_PCIE_PHY_GEN_CTRL,
> +				   IMX95_PCIE_REF_USE_PAD, 0);
> +		regmap_update_bits(imx_pcie->iomuxc_gpr,
> +				   IMX95_PCIE_SS_RW_REG_0,
> +				   IMX95_PCIE_REF_CLKEN,
> +				   IMX95_PCIE_REF_CLKEN);

bool ext = imx_pcie->enable_ext_refclk;

regmap_update_bits(....
                   ext ? IMX95_PCIE_REF_USE_PAD: 0);

regmap_update_bits(...
		   ext ? 0: IMX95_PCIE_REF_CLKEN);

Frank

> +	}
>
>  	return 0;
>  }
> @@ -1600,7 +1612,7 @@ static int imx_pcie_probe(struct platform_device *pdev)
>  	struct imx_pcie *imx_pcie;
>  	struct device_node *np;
>  	struct device_node *node = dev->of_node;
> -	int ret, domain;
> +	int i, ret, domain;
>  	u16 val;
>
>  	imx_pcie = devm_kzalloc(dev, sizeof(*imx_pcie), GFP_KERNEL);
> @@ -1651,6 +1663,12 @@ static int imx_pcie_probe(struct platform_device *pdev)
>  	if (imx_pcie->num_clks < 0)
>  		return dev_err_probe(dev, imx_pcie->num_clks,
>  				     "failed to get clocks\n");
> +	for (i = 0; i < imx_pcie->num_clks; i++) {
> +		if (strncmp(imx_pcie->clks[i].id, "ref", 3) == 0)
> +			imx_pcie->enable_ext_refclk = false;
> +		else
> +			imx_pcie->enable_ext_refclk = true;
> +	}
>
>  	if (imx_check_flag(imx_pcie, IMX_PCIE_FLAG_HAS_PHYDRV)) {
>  		imx_pcie->phy = devm_phy_get(dev, "pcie-phy");
> --
> 2.37.1
>


^ permalink raw reply	[flat|nested] 6+ messages in thread

* RE: [PATCH v1 1/2] dt-binding: pci-imx6: Add external reference clock mode support
  2025-06-18 13:43 ` [PATCH v1 1/2] dt-binding: pci-imx6: " Krzysztof Kozlowski
@ 2025-06-19  3:39   ` Hongxing Zhu
  0 siblings, 0 replies; 6+ messages in thread
From: Hongxing Zhu @ 2025-06-19  3:39 UTC (permalink / raw)
  To: Krzysztof Kozlowski, Frank Li, l.stach@pengutronix.de,
	lpieralisi@kernel.org, kwilczynski@kernel.org, mani@kernel.org,
	robh@kernel.org, bhelgaas@google.com, shawnguo@kernel.org,
	s.hauer@pengutronix.de, kernel@pengutronix.de, festevam@gmail.com
  Cc: linux-pci@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
	imx@lists.linux.dev, linux-kernel@vger.kernel.org

> -----Original Message-----
> From: Krzysztof Kozlowski <krzk@kernel.org>
> Sent: 2025年6月18日 21:44
> To: Hongxing Zhu <hongxing.zhu@nxp.com>; Frank Li <frank.li@nxp.com>;
> l.stach@pengutronix.de; lpieralisi@kernel.org; kwilczynski@kernel.org;
> mani@kernel.org; robh@kernel.org; bhelgaas@google.com;
> shawnguo@kernel.org; s.hauer@pengutronix.de; kernel@pengutronix.de;
> festevam@gmail.com
> Cc: linux-pci@vger.kernel.org; linux-arm-kernel@lists.infradead.org;
> imx@lists.linux.dev; linux-kernel@vger.kernel.org
> Subject: Re: [PATCH v1 1/2] dt-binding: pci-imx6: Add external reference clock
> mode support
> 
> On 18/06/2025 09:48, Richard Zhu wrote:
> > On i.MX, the PCIe reference clock might come from either internal
> > system PLL or external clock source.
> > Add the external reference clock source for reference clock.
> >
> > Signed-off-by: Richard Zhu <hongxing.zhu@nxp.com>
> > ---
> >  Documentation/devicetree/bindings/pci/fsl,imx6q-pcie.yaml | 7 ++++++-
> >  1 file changed, 6 insertions(+), 1 deletion(-)
> 
> <form letter>
> Please use scripts/get_maintainers.pl to get a list of necessary people and
> lists to CC. It might happen, that command when run on an older kernel, gives
> you outdated entries. Therefore please be sure you base your patches on
> recent Linux kernel.
> 
> Tools like b4 or scripts/get_maintainer.pl provide you proper list of people, so
> fix your workflow. Tools might also fail if you work on some ancient tree (don't,
> instead use mainline) or work on fork of kernel (don't, instead use mainline).
> Just use b4 and everything should be fine, although remember about `b4 prep
> --auto-to-cc` if you added new patches to the patchset.
> 
> You missed at least devicetree list (maybe more), so this won't be tested by
> automated tooling. Performing review on untested code might be a waste of
> time.
> 
> Please kindly resend and include all necessary To/Cc entries.
> </form letter>
Hi Krzysztof:
Thanks a lot for your kindly reminder.
After correct the list of necessary people and lists.
Would resend the v1 series, address the comments, then send out v2 later.

Best Regards
Richard Zhu
> 
> Best regards,
> Krzysztof

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2025-06-19  3:46 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-06-18  7:48 [PATCH v1 1/2] dt-binding: pci-imx6: Add external reference clock mode support Richard Zhu
2025-06-18  7:48 ` [PATCH v1 2/2] PCI: imx6: " Richard Zhu
2025-06-18 16:45   ` Frank Li
2025-06-18 13:43 ` [PATCH v1 1/2] dt-binding: pci-imx6: " Krzysztof Kozlowski
2025-06-19  3:39   ` Hongxing Zhu
2025-06-18 16:39 ` Frank Li

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).