Skip to contentSkip to conversation

PCI: imx6: Add support for MX6SX LDO PCIE domain regulator

PATCH In review Fabio Estevam 3 participants 6 messages Jun 8, 2016 – Jun 14, 2016

Subsystems (4)
lore
Share & tools
lore

Fabio Estevam

author reviewer
#0 lore raw

PATCH 1/1 PCI: imx6: Add support for MX6SX LDO PCIE domain regulator

From: Fabio Estevam <[email protected]>

MX6SX has an internal LDO regulator for the PCIE domain, which needs to be turned on for PCIE functionality.

Add support for it.

---
 .../devicetree/bindings/pci/fsl,imx6q-pcie.txt     |  2 ++
 drivers/pci/host/pci-imx6.c                        | 29 +++++++++++++++++++++-
 2 files changed, 30 insertions(+), 1 deletion(-)
Documentation/devicetree/bindings/pci/fsl,imx6q-pcie.txt +2 -0
index f3d26f47..cfb0e86 100644
@@ -33,6 +33,8 @@ Optional properties:
 Additional required properties for imx6sx-pcie:
 - clock names: Must include the following additional entry:
 	- "pcie_inbound_axi"
+- pcie-phy-supply: Must point to the internal PCIE power domain regulator:
+		   <&reg_pcie>;
 
 Example:
 
drivers/pci/host/pci-imx6.c +28 -1
index b741a36..ad9cc8b 100644
@@ -27,6 +27,7 @@
 #include <linux/signal.h>
 #include <linux/types.h>
 #include <linux/interrupt.h>
+#include <linux/regulator/consumer.h>
 
 #include "pcie-designware.h"
 
@@ -55,6 +56,7 @@ struct imx6_pcie {
 	u32			tx_swing_full;
 	u32			tx_swing_low;
 	int			link_gen;
+	struct regulator	*phy_regulator;
 };
 
 /* PCIe Root Complex registers (memory-mapped) */
@@ -96,6 +98,8 @@ struct imx6_pcie {
 #define PHY_RX_OVRD_IN_LO_RX_DATA_EN (1 << 5)
 #define PHY_RX_OVRD_IN_LO_RX_PLL_EN (1 << 3)
 
+#define MX6SX_PCIE_LDO				1100000
+
 static int pcie_phy_poll_ack(void __iomem *dbi_base, int exp_val)
 {
 	u32 val;
@@ -407,11 +411,26 @@ err_pcie_phy:
 static void imx6_pcie_init_phy(struct pcie_port *pp)
 {
 	struct imx6_pcie *imx6_pcie = to_imx6_pcie(pp);
+	int ret;
+
+	if (imx6_pcie->variant == IMX6SX) {
+		ret = regulator_set_voltage(imx6_pcie->phy_regulator,
+					    MX6SX_PCIE_LDO, MX6SX_PCIE_LDO);
+		if (ret) {
+			dev_err(pp->dev, "failed to set pcie phy voltage.\n");
+			return ret;
+		}
+
+		ret = regulator_enable(imx6_pcie->phy_regulator);
+		if (ret) {
+			dev_err(pp->dev, "failed to enable pcie regulator.\n");
+			return;
+		}
 
-	if (imx6_pcie->variant == IMX6SX)
 		regmap_update_bits(imx6_pcie->iomuxc_gpr, IOMUXC_GPR12,
 				   IMX6SX_GPR12_PCIE_RX_EQ_MASK,
 				   IMX6SX_GPR12_PCIE_RX_EQ_2);
+	}
 
 	regmap_update_bits(imx6_pcie->iomuxc_gpr, IOMUXC_GPR12,
 			IMX6Q_GPR12_PCIE_CTL_2, 0 << 10);
@@ -680,6 +699,14 @@ static int __init imx6_pcie_probe(struct platform_device *pdev)
 				"pcie_incbound_axi clock missing or invalid\n");
 			return PTR_ERR(imx6_pcie->pcie_inbound_axi);
 		}
+
+		imx6_pcie->phy_regulator = devm_regulator_get(pp->dev,
+							      "pcie-phy");
+		if (IS_ERR(imx6_pcie->phy_regulator)) {
+			dev_err(&pdev->dev,
+				"failed to get pcie-phy regulator\n");
+			return PTR_ERR(imx6_pcie->phy_regulator);
+		}
 	}
 
 	/* Grab GPR config register range */
Signature · 1 line
1.9.1
#1 lore raw

Hi Fabio

Quoted 11 lines · Fabio Estevam

From: Fabio Estevam <[email protected]>

MX6SX has an internal LDO regulator for the PCIE domain, which needs to be turned on for PCIE functionality.

Add support for it.

---
 .../devicetree/bindings/pci/fsl,imx6q-pcie.txt     |  2 ++
 drivers/pci/host/pci-imx6.c                        | 29 +++++++++++++++++++++-

There was a discussion doing the handling of the regulator inside the PM backend:

Quoted 4 lines · Richard Zhu
Quoted 3 lines

As Lucas discussed with me before, the GPC regulator operations should[n't] be touched in Imx pcie driver at all. These bits operations should be encapsulate into the PM system,
for example, the regulator driver.

Quoted 4 lines · Christoph Fritz

Ok, for an initial version, I'll just leave the regulator in my devicetree enabled. For further enhancements I suppose arch/arm/mach-imx/gpc.c needs to get touched?

@Richard and @Lucas: Any further hints on this?

Thanks
-- Christoph

author reviewer
#2 lore raw

Hi Christoph,

Quoted 2 lines · Christoph Fritz

There was a discussion doing the handling of the regulator inside the PM backend:

Thanks for pointing me to this discussion.

Quoted 6 lines
Quoted 5 lines · Richard Zhu
Quoted 3 lines

As Lucas discussed with me before, the GPC regulator operations should[n't] be touched in Imx pcie driver at all. These bits operations should be encapsulate into the PM system,
for example, the regulator driver.

Quoted 6 lines
Quoted 4 lines · Christoph Fritz

Ok, for an initial version, I'll just leave the regulator in my devicetree enabled. For further enhancements I suppose arch/arm/mach-imx/gpc.c needs to get touched?

@Richard and @Lucas: Any further hints on this?

Yes, would appreciate some hints or examples as to how to properly handle the PCI LDO regulator on mx6sx.

Thanks

#3 lore raw

Hi Fabio,

Am Sonntag, den 12.06.2016, 10:51 -0300 schrieb Fabio Estevam:

Quoted 17 lines

Hi Christoph,

Quoted 2 lines · Christoph Fritz

There was a discussion doing the handling of the regulator inside the PM backend:

Thanks for pointing me to this discussion.

Quoted 7 lines
Quoted 5 lines · Richard Zhu
Quoted 3 lines

As Lucas discussed with me before, the GPC regulator operations should[n't] be touched in Imx pcie driver at all. These bits operations should be encapsulate into the PM system,
for example, the regulator driver.

On Thu, 2016-02-18 at 12:59 +0100, Christoph Fritz wrote:

Quoted 9 lines
Quoted 5 lines
Quoted 4 lines

Ok, for an initial version, I'll just leave the regulator in my devicetree enabled. For further enhancements I suppose arch/arm/mach-imx/gpc.c needs to get touched?

@Richard and @Lucas: Any further hints on this?

Yes, would appreciate some hints or examples as to how to properly handle the PCI LDO regulator on mx6sx.

It should be handled the same way as the PU domain regulator on mx6q. This means the regulator is a supply of the PCIe PHY power domain and should be en-/disabled through the GPC driver.

I already posted a series to rework the GPC driver to allow adding new power domains easily, but it was rejected by Shawn on formal grounds, as it's mostly a single big patch to do the rework. I don't have time to split this up further at the moment, as this is really non-trivial, but maybe Shawn is willing to take it if someone does a proper review of the patch.

With this series applied it should be easy to add the required power domains and regulator handling for mx6sx.

Regards,
Lucas

author reviewer
#4 lore raw

Hi Lucas,

Quoted 6 lines · Lucas Stach

It should be handled the same way as the PU domain regulator on mx6q. This means the regulator is a supply of the PCIe PHY power domain and should be en-/disabled through the GPC driver.

I already posted a series to rework the GPC driver to allow adding new power domains easily, but it was rejected by Shawn on formal grounds, as

Could you please point me to this series?

Thanks

#5 lore raw

Hi Fabio,

Am Dienstag, den 14.06.2016, 00:18 -0300 schrieb Fabio Estevam:

Quoted 4 lines

Hi Lucas,

On Mon, Jun 13, 2016 at 7:41 AM, Lucas Stach <[email protected]> wrote:

Quoted 9 lines
Quoted 6 lines

It should be handled the same way as the PU domain regulator on mx6q. This means the regulator is a supply of the PCIe PHY power domain and should be en-/disabled through the GPC driver.

I already posted a series to rework the GPC driver to allow adding new power domains easily, but it was rejected by Shawn on formal grounds, as

Could you please point me to this series?

Here you go:

https://patchwork.kernel.org/patch/8599181/
https://patchwork.kernel.org/patch/8599251/
https://patchwork.kernel.org/patch/8599241/

Regards,
Lucas