Skip to contentSkip to conversation

"pcie_aux" clock for i.MX8MQ

PATCH In review Andrey Smirnov 5 participants 10 messages Feb 12, 2019 – Mar 1, 2019

Subsystems (5)
lore
Share & tools
lore
#0 lore raw

cover "pcie_aux" clock for i.MX8MQ

Lorenzo:

This small series adds code to control "pcie_aux" clock. This is an oversight from original submission [pcie-imx8mq-v7], which was only discovered once I submitted an RFC for corresponding DT changes going via i.MX tree [imx-dt-rfc].

Thanks,
Andrey Smirnov

[imx-dt-rfc] https://lore.kernel.org/lkml/[email protected]
[pcie-imx8mq-v7] https://lore.kernel.org/lkml/[email protected]

Andrey Smirnov (2):
dt-bindings: imx6q-pcie: Add "pcie_aux" clock for imx8mq
PCI: imx6: Add code to request/control "pcie_aux" clock for i.MX8MQ

 .../devicetree/bindings/pci/fsl,imx6q-pcie.txt   |  4 ++++
 drivers/pci/controller/dwc/pci-imx6.c            | 16 ++++++++++++++++
 2 files changed, 20 insertions(+)
Signature · 1 line
2.20.1
#1 lore raw

PATCH 1/2 dt-bindings: imx6q-pcie: Add "pcie_aux" clock for imx8mq

Add a binding for an extra clock required on i.MX8MQ.

---
 Documentation/devicetree/bindings/pci/fsl,imx6q-pcie.txt | 4 ++++
 1 file changed, 4 insertions(+)
Documentation/devicetree/bindings/pci/fsl,imx6q-pcie.txt +4 -0
index 920ca93870a8..933d98328e07 100644
@@ -55,6 +55,10 @@ Additional required properties for imx7d-pcie and imx8mq-pcie:
 	       - "apps"
 	       - "turnoff"
 
+Additional required properties for imx8mq-pcie:
+- clock-names: Must include the following additional entries:
+	- "pcie_aux"
+
 Example:
 
 	pcie@01000000 {
Signature · 1 line
2.20.1
maintainer Reviewed-by on v1 1/2
#2 lore raw

Re: [PATCH 1/2] dt-bindings: imx6q-pcie: Add "pcie_aux" clock for imx8mq

Am Montag, den 11.02.2019, 17:51 -0800 schrieb Andrey Smirnov:

Quoted 16 lines

Add a binding for an extra clock required on i.MX8MQ.

Quoted 21 lines

---
 Documentation/devicetree/bindings/pci/fsl,imx6q-pcie.txt | 4 ++++

 1 file changed, 4 insertions(+)
Documentation/devicetree/bindings/pci/fsl,imx6q-pcie.txt +0 -0
index 920ca93870a8..933d98328e07 100644
@@ -55,6 +55,10 @@ Additional required properties for imx7d-pcie and

imx8mq-pcie:
         - "apps"
         - "turnoff"

Documentation/devicetree/bindings/pci/fsl,imx6q-pcie.txt +4 -0
+Additional required properties for imx8mq-pcie:
+- clock-names: Must include the following additional entries:
+	- "pcie_aux"
+

 Example:

  pcie@01000000 {

maintainer Reviewed-by on v1 1/2
#3 lore raw

Re: [PATCH 1/2] dt-bindings: imx6q-pcie: Add "pcie_aux" clock for imx8mq

In reply to Andrey Smirnov
Quoted 16 lines · Andrey Smirnov

Add a binding for an extra clock required on i.MX8MQ.

Quoted 4 lines
---
 Documentation/devicetree/bindings/pci/fsl,imx6q-pcie.txt | 4 ++++
 1 file changed, 4 insertions(+)
#4 lore raw

PATCH 2/2 PCI: imx6: Add code to request/control "pcie_aux" clock for i.MX8MQ

In reply to Andrey Smirnov

PCIe IP block has additional clock, "pcie_aux", that needs to be controlled by the driver. Add code to support that.

---
 drivers/pci/controller/dwc/pci-imx6.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
drivers/pci/controller/dwc/pci-imx6.c +16 -0
index 7cdf8f9ab244..1a7031782846 100644
@@ -65,6 +65,7 @@ struct imx6_pcie {
 	struct clk		*pcie_phy;
 	struct clk		*pcie_inbound_axi;
 	struct clk		*pcie;
+	struct clk		*pcie_aux;
 	struct regmap		*iomuxc_gpr;
 	u32			controller_id;
 	struct reset_control	*pciephy_reset;
@@ -421,6 +422,12 @@ static int imx6_pcie_enable_ref_clk(struct imx6_pcie *imx6_pcie)
 	case IMX7D:
 		break;
 	case IMX8MQ:
+		ret = clk_prepare_enable(imx6_pcie->pcie_aux);
+		if (ret) {
+			dev_err(dev, "unable to enable pcie_aux clock\n");
+			break;
+		}
+
 		offset = imx6_pcie_grp_offset(imx6_pcie);
 		/*
 		 * Set the over ride low and enabled
@@ -904,6 +911,9 @@ static void imx6_pcie_clk_disable(struct imx6_pcie *imx6_pcie)
 				   IMX7D_GPR12_PCIE_PHY_REFCLK_SEL,
 				   IMX7D_GPR12_PCIE_PHY_REFCLK_SEL);
 		break;
+	case IMX8MQ:
+		clk_disable_unprepare(imx6_pcie->pcie_aux);
+		break;
 	default:
 		break;
 	}
@@ -1049,6 +1059,12 @@ static int imx6_pcie_probe(struct platform_device *pdev)
 			dev_err(dev, "Failed to get PCIE APPS reset control\n");
 			return PTR_ERR(imx6_pcie->apps_reset);
 		}
+
+		imx6_pcie->pcie_aux = devm_clk_get(dev, "pcie_aux");
+		if (IS_ERR(imx6_pcie->pcie_aux)) {
+			dev_err(dev, "pcie_aux clock source missing or invalid\n");
+			return PTR_ERR(imx6_pcie->pcie_aux);
+		}
 		break;
 	default:
 		break;
Signature · 1 line
2.20.1
maintainer Reviewed-by on v1 2/2
#5 lore raw

Re: [PATCH 2/2] PCI: imx6: Add code to request/control "pcie_aux" clock for i.MX8MQ

Am Montag, den 11.02.2019, 17:51 -0800 schrieb Andrey Smirnov:

Quoted 17 lines

PCIe IP block has additional clock, "pcie_aux", that needs to be controlled by the driver. Add code to support that.

Quoted 52 lines

---
 drivers/pci/controller/dwc/pci-imx6.c | 16 ++++++++++++++++

 1 file changed, 16 insertions(+)
drivers/pci/controller/dwc/pci-imx6.c +1 -0
index 7cdf8f9ab244..1a7031782846 100644
@@ -65,6 +65,7 @@ struct imx6_pcie {
  	struct clk		*pcie_phy;
  	struct clk		*pcie_inbound_axi;
  	struct clk		*pcie;
+	struct clk		*pcie_aux;
  	struct regmap		*iomuxc_gpr;
  	u32			controller_id;
  	struct reset_control	*pciephy_reset;
@@ -421,6 +422,12 @@ static int imx6_pcie_enable_ref_clk(struct imx6_pcie *imx6_pcie)

  case IMX7D:
  break;
  case IMX8MQ:

drivers/pci/controller/dwc/pci-imx6.c +6 -0
+		ret = clk_prepare_enable(imx6_pcie->pcie_aux);
+		if (ret) {
+			dev_err(dev, "unable to enable pcie_aux clock\n");
+			break;
+		}
+

  offset = imx6_pcie_grp_offset(imx6_pcie); /*
   * Set the over ride low and enabled

drivers/pci/controller/dwc/pci-imx6.c +3 -0
@@ -904,6 +911,9 @@ static void imx6_pcie_clk_disable(struct imx6_pcie *imx6_pcie)
  				   IMX7D_GPR12_PCIE_PHY_REFCLK_SEL,
  				   IMX7D_GPR12_PCIE_PHY_REFCLK_SEL);
  		break;
+	case IMX8MQ:
+		clk_disable_unprepare(imx6_pcie->pcie_aux);
+		break;

  default:
  break;
  }

drivers/pci/controller/dwc/pci-imx6.c +6 -0
@@ -1049,6 +1059,12 @@ static int imx6_pcie_probe(struct platform_device *pdev)
  			dev_err(dev, "Failed to get PCIE APPS reset control\n");
  			return PTR_ERR(imx6_pcie->apps_reset);
  		}
+
+		imx6_pcie->pcie_aux = devm_clk_get(dev, "pcie_aux");
+		if (IS_ERR(imx6_pcie->pcie_aux)) {
+			dev_err(dev, "pcie_aux clock source missing or invalid\n");
+			return PTR_ERR(imx6_pcie->pcie_aux);
+		}
  		break;

  default:
  break;

#6 lore raw

Re: [PATCH 2/2] PCI: imx6: Add code to request/control "pcie_aux" clock for i.MX8MQ

Quoted 3 lines · Lucas Stach

Am Montag, den 11.02.2019, 17:51 -0800 schrieb Andrey Smirnov:

Quoted 2 lines

PCIe IP block has additional clock, "pcie_aux", that needs to be controlled by the driver. Add code to support that.

This breaks iMX7d.

Quoted 14 lines
Quoted 4 lines
drivers/pci/controller/dwc/pci-imx6.c +0 -0
@@ -1049,6 +1059,12 @@ static int imx6_pcie_probe(struct platform_device *pdev)
 			dev_err(dev, "Failed to get PCIE APPS reset control\n");
 			return PTR_ERR(imx6_pcie->apps_reset);

drivers/pci/controller/dwc/pci-imx6.c static int imx6_pcie_probe(struct platform_device *pdev) · line 1070

Quoted 10 lines
drivers/pci/controller/dwc/pci-imx6.c +6 -0
 		}
+
+		imx6_pcie->pcie_aux = devm_clk_get(dev, "pcie_aux");
+		if (IS_ERR(imx6_pcie->pcie_aux)) {
+			dev_err(dev, "pcie_aux clock source missing or invalid\n");
+			return PTR_ERR(imx6_pcie->pcie_aux);
+		}
 		break;
 	default:
 		break;

One can't see enough context in the patch above, but in linux-next this section is under

case IMX7D:
case IMX8MQ:

It's being applied to imx7d and not just imx8mq and so breaks because imx7d dts files don't have this clock. Not sure if this is a bug in this commit or some kind of merge/rebase mistake.

#7 lore raw

Re: [PATCH 2/2] PCI: imx6: Add code to request/control "pcie_aux" clock for i.MX8MQ

Quoted 8 lines · Trent Piepho
Quoted 3 lines · Lucas Stach

Am Montag, den 11.02.2019, 17:51 -0800 schrieb Andrey Smirnov:

Quoted 2 lines

PCIe IP block has additional clock, "pcie_aux", that needs to be controlled by the driver. Add code to support that.

This breaks iMX7d.

Ugh, my bad, sorry about that.

Quoted 18 lines
Quoted 14 lines
Quoted 4 lines
drivers/pci/controller/dwc/pci-imx6.c +0 -0
@@ -1049,6 +1059,12 @@ static int imx6_pcie_probe(struct platform_device *pdev)
                    dev_err(dev, "Failed to get PCIE APPS reset control\n");
                    return PTR_ERR(imx6_pcie->apps_reset);

drivers/pci/controller/dwc/pci-imx6.c static int imx6_pcie_probe(struct platform_device *pdev) · line 1070

Quoted 10 lines
drivers/pci/controller/dwc/pci-imx6.c +6 -0
            }
+
+           imx6_pcie->pcie_aux = devm_clk_get(dev, "pcie_aux");
+           if (IS_ERR(imx6_pcie->pcie_aux)) {
+                   dev_err(dev, "pcie_aux clock source missing or invalid\n");
+                   return PTR_ERR(imx6_pcie->pcie_aux);
+           }
            break;
    default:
            break;

One can't see enough context in the patch above, but in linux-next this section is under

Quoted 7 lines

case IMX7D:
case IMX8MQ:

It's being applied to imx7d and not just imx8mq and so breaks because imx7d dts files don't have this clock. Not sure if this is a bug in this commit or some kind of merge/rebase mistake.

This is just a regular bug, I spaced out and missed the fact that this path is shared between the two. I'll submit a patch moving "pci_aux" clock request into a i.MX8MQ specific patch shortly.

Thanks,
Andrey Smirnov

#8 lore raw
In reply to Andrey Smirnov
Quoted 13 lines · Andrey Smirnov

Lorenzo:

This small series adds code to control "pcie_aux" clock. This is an oversight from original submission [pcie-imx8mq-v7], which was only discovered once I submitted an RFC for corresponding DT changes going via i.MX tree [imx-dt-rfc].

Thanks,
Andrey Smirnov

[imx-dt-rfc] https://lore.kernel.org/lkml/[email protected]
[pcie-imx8mq-v7] https://lore.kernel.org/lkml/[email protected]

Quoted 7 lines

Andrey Smirnov (2):
dt-bindings: imx6q-pcie: Add "pcie_aux" clock for imx8mq
PCI: imx6: Add code to request/control "pcie_aux" clock for i.MX8MQ

 .../devicetree/bindings/pci/fsl,imx6q-pcie.txt   |  4 ++++
 drivers/pci/controller/dwc/pci-imx6.c            | 16 ++++++++++++++++
 2 files changed, 20 insertions(+)

Hi Andrey,

I have applied it to pci/dwc for v5.1, however it looks like it would break the driver with an old dts - I assume that's expected but let me know if there is a better way to handle this.

Lorenzo

maintainer
#9 lore raw

Hi Lorenzo,

Am Dienstag, den 19.02.2019, 12:42 +0000 schrieb Lorenzo Pieralisi:

Quoted 22 lines · Andrey Smirnov
Quoted 13 lines

Lorenzo:

This small series adds code to control "pcie_aux" clock. This is an oversight from original submission [pcie-imx8mq-v7], which was only discovered once I submitted an RFC for corresponding DT changes going via i.MX tree [imx-dt-rfc].

Thanks,
Andrey Smirnov

[imx-dt-rfc] https://lore.kernel.org/lkml/[email protected]
[pcie-imx8mq-v7] https://lore.kernel.org/lkml/[email protected]

Quoted 7 lines

Andrey Smirnov (2):
dt-bindings: imx6q-pcie: Add "pcie_aux" clock for imx8mq
PCI: imx6: Add code to request/control "pcie_aux" clock for i.MX8MQ

 .../devicetree/bindings/pci/fsl,imx6q-pcie.txt   |  4 ++++
 drivers/pci/controller/dwc/pci-imx6.c            | 16 ++++++++++++++++
 2 files changed, 20 insertions(+)
Quoted 5 lines

Hi Andrey,

I have applied it to pci/dwc for v5.1, however it looks like it would break the driver with an old dts - I assume that's expected but let me know if there is a better way to handle this.

There is no upstream DT using the imx8mq binding, yet. We've actually noticed the issue due to the DT patches adding the PCIe nodes and those 2 patches fix the driver _before_ we introduce any DT using it. So I think it's okay not to worry about backwards compatibility here.

Regards,
Lucas