devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] pci: am57xx-evm: Fix PCIe card enumeration issue
@ 2015-07-28 13:39 Kishon Vijay Abraham I
  2015-07-28 13:39 ` [PATCH 1/2] pci: host: pci-dra7xx: Add support to make gpio drive PERST# line Kishon Vijay Abraham I
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Kishon Vijay Abraham I @ 2015-07-28 13:39 UTC (permalink / raw)
  To: bhelgaas, linux-omap, linux-pci, devicetree, linux-kernel,
	linux-arm-kernel, tony
  Cc: robh+dt, pawel.moll, mark.rutland, ijc+devicetree, galak,
	bcousson, linux, kishon, nsekhar

This series fixes PCIe card enumeration issue in am57xx-evm.

In the case of am57xx-evm, the PERST# line is connected to a gpio line
and this has to be driven low in order to perform a fundamental reset
of the card. If the gpio line is driven high, there is no way the card
can come out of reset.

Add support in the pcie-dra7xx driver to make gpio drive PERST# line.

The PERST# line can be used to perform reset not during the power on
sequence too (warm reset) but we are not adding support for this as the
PCIe express base sepcification doesn't explain how to perform warm
reset

"In some cases, it may be possible for the Fundamental Reset mechanism
to be triggered by hardware without the removal and re-application of
power to the component. This is called a warm reset. This document does
not specify a means for generating a warm reset."

Kishon Vijay Abraham I (2):
  pci: host: pci-dra7xx: Add support to make gpio drive PERST# line
  ARM: dts: am57xx-evm: Add 'gpios' property with gpio2_8

 Documentation/devicetree/bindings/pci/ti-pci.txt |    3 +++
 arch/arm/boot/dts/am57xx-beagle-x15.dts          |    5 +++++
 arch/arm/boot/dts/dra7.dtsi                      |    2 +-
 drivers/pci/host/pci-dra7xx.c                    |   24 ++++++++++++++++++++--
 4 files changed, 31 insertions(+), 3 deletions(-)

-- 
1.7.9.5

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

* [PATCH 1/2] pci: host: pci-dra7xx: Add support to make gpio drive PERST# line
  2015-07-28 13:39 [PATCH 0/2] pci: am57xx-evm: Fix PCIe card enumeration issue Kishon Vijay Abraham I
@ 2015-07-28 13:39 ` Kishon Vijay Abraham I
  2015-07-28 13:39 ` [PATCH 2/2] ARM: dts: am57xx-evm: Add 'gpios' property with gpio2_8 Kishon Vijay Abraham I
  2015-08-11 21:02 ` [PATCH 0/2] pci: am57xx-evm: Fix PCIe card enumeration issue Bjorn Helgaas
  2 siblings, 0 replies; 5+ messages in thread
From: Kishon Vijay Abraham I @ 2015-07-28 13:39 UTC (permalink / raw)
  To: bhelgaas, linux-omap, linux-pci, devicetree, linux-kernel,
	linux-arm-kernel, tony
  Cc: robh+dt, pawel.moll, mark.rutland, ijc+devicetree, galak,
	bcousson, linux, kishon, nsekhar

The PERST# line in am57x-evm is connected to a gpio line and PERST#
should be driven high to indicate the clocks are stable (As per
Figure 2-10: Power Up of the PCIe CEM spec 3.0).

Add support in pci-dra7xx driver to make gpio drive PERST#
line here.

Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
---
 Documentation/devicetree/bindings/pci/ti-pci.txt |    3 +++
 drivers/pci/host/pci-dra7xx.c                    |   24 ++++++++++++++++++++--
 2 files changed, 25 insertions(+), 2 deletions(-)

diff --git a/Documentation/devicetree/bindings/pci/ti-pci.txt b/Documentation/devicetree/bindings/pci/ti-pci.txt
index 3d21791..60e2516 100644
--- a/Documentation/devicetree/bindings/pci/ti-pci.txt
+++ b/Documentation/devicetree/bindings/pci/ti-pci.txt
@@ -23,6 +23,9 @@ PCIe Designware Controller
    interrupt-map-mask,
    interrupt-map : as specified in ../designware-pcie.txt
 
+Optional Property:
+ - gpios : Should be added if a gpio line is required to drive PERST# line
+
 Example:
 axi {
 	compatible = "simple-bus";
diff --git a/drivers/pci/host/pci-dra7xx.c b/drivers/pci/host/pci-dra7xx.c
index 7acc833..d3d0faf 100644
--- a/drivers/pci/host/pci-dra7xx.c
+++ b/drivers/pci/host/pci-dra7xx.c
@@ -17,6 +17,7 @@
 #include <linux/irqdomain.h>
 #include <linux/kernel.h>
 #include <linux/module.h>
+#include <linux/of_gpio.h>
 #include <linux/pci.h>
 #include <linux/phy/phy.h>
 #include <linux/platform_device.h>
@@ -336,6 +337,9 @@ static int __init dra7xx_pcie_probe(struct platform_device *pdev)
 	struct device *dev = &pdev->dev;
 	struct device_node *np = dev->of_node;
 	char name[10];
+	int gpio_sel;
+	enum of_gpio_flags flags;
+	unsigned long gpio_flags;
 
 	dra7xx = devm_kzalloc(dev, sizeof(*dra7xx), GFP_KERNEL);
 	if (!dra7xx)
@@ -398,6 +402,22 @@ static int __init dra7xx_pcie_probe(struct platform_device *pdev)
 		goto err_get_sync;
 	}
 
+	gpio_sel = of_get_gpio_flags(dev->of_node, 0, &flags);
+	if (gpio_is_valid(gpio_sel)) {
+		gpio_flags = (flags & OF_GPIO_ACTIVE_LOW) ?
+				GPIOF_OUT_INIT_LOW : GPIOF_OUT_INIT_HIGH;
+		ret = devm_gpio_request_one(dev, gpio_sel, gpio_flags,
+					    "pcie_reset");
+		if (ret) {
+			dev_err(&pdev->dev, "gpio%d request failed, ret %d\n",
+				gpio_sel, ret);
+			goto err_gpio;
+		}
+	} else if (gpio_sel == -EPROBE_DEFER) {
+		ret = -EPROBE_DEFER;
+		goto err_gpio;
+	}
+
 	reg = dra7xx_pcie_readl(dra7xx, PCIECTRL_DRA7XX_CONF_DEVICE_CMD);
 	reg &= ~LTSSM_EN;
 	dra7xx_pcie_writel(dra7xx, PCIECTRL_DRA7XX_CONF_DEVICE_CMD, reg);
@@ -406,11 +426,11 @@ static int __init dra7xx_pcie_probe(struct platform_device *pdev)
 
 	ret = dra7xx_add_pcie_port(dra7xx, pdev);
 	if (ret < 0)
-		goto err_add_port;
+		goto err_gpio;
 
 	return 0;
 
-err_add_port:
+err_gpio:
 	pm_runtime_put(dev);
 
 err_get_sync:
-- 
1.7.9.5

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

* [PATCH 2/2] ARM: dts: am57xx-evm: Add 'gpios' property with gpio2_8
  2015-07-28 13:39 [PATCH 0/2] pci: am57xx-evm: Fix PCIe card enumeration issue Kishon Vijay Abraham I
  2015-07-28 13:39 ` [PATCH 1/2] pci: host: pci-dra7xx: Add support to make gpio drive PERST# line Kishon Vijay Abraham I
@ 2015-07-28 13:39 ` Kishon Vijay Abraham I
  2015-08-05 10:40   ` Tony Lindgren
  2015-08-11 21:02 ` [PATCH 0/2] pci: am57xx-evm: Fix PCIe card enumeration issue Bjorn Helgaas
  2 siblings, 1 reply; 5+ messages in thread
From: Kishon Vijay Abraham I @ 2015-07-28 13:39 UTC (permalink / raw)
  To: bhelgaas, linux-omap, linux-pci, devicetree, linux-kernel,
	linux-arm-kernel, tony
  Cc: robh+dt, pawel.moll, mark.rutland, ijc+devicetree, galak,
	bcousson, linux, kishon, nsekhar

gpio2_8 is connected to the PCIe_RESETn line and it has to be driven low
in order to reset the PCIe cards. So added gpios property to pcie
dt node.

Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
---
 arch/arm/boot/dts/am57xx-beagle-x15.dts |    5 +++++
 arch/arm/boot/dts/dra7.dtsi             |    2 +-
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/arch/arm/boot/dts/am57xx-beagle-x15.dts b/arch/arm/boot/dts/am57xx-beagle-x15.dts
index a63bf78..a862a6e 100644
--- a/arch/arm/boot/dts/am57xx-beagle-x15.dts
+++ b/arch/arm/boot/dts/am57xx-beagle-x15.dts
@@ -693,3 +693,8 @@
 		};
 	};
 };
+
+&pcie1 {
+	gpios = <&gpio2 8 GPIO_ACTIVE_LOW>;
+};
+
diff --git a/arch/arm/boot/dts/dra7.dtsi b/arch/arm/boot/dts/dra7.dtsi
index 8f1e25b..37202b4 100644
--- a/arch/arm/boot/dts/dra7.dtsi
+++ b/arch/arm/boot/dts/dra7.dtsi
@@ -211,7 +211,7 @@
 			#address-cells = <1>;
 			ranges = <0x51000000 0x51000000 0x3000
 				  0x0	     0x20000000 0x10000000>;
-			pcie@51000000 {
+			pcie1: pcie@51000000 {
 				compatible = "ti,dra7-pcie";
 				reg = <0x51000000 0x2000>, <0x51002000 0x14c>, <0x1000 0x2000>;
 				reg-names = "rc_dbics", "ti_conf", "config";
-- 
1.7.9.5

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

* Re: [PATCH 2/2] ARM: dts: am57xx-evm: Add 'gpios' property with gpio2_8
  2015-07-28 13:39 ` [PATCH 2/2] ARM: dts: am57xx-evm: Add 'gpios' property with gpio2_8 Kishon Vijay Abraham I
@ 2015-08-05 10:40   ` Tony Lindgren
  0 siblings, 0 replies; 5+ messages in thread
From: Tony Lindgren @ 2015-08-05 10:40 UTC (permalink / raw)
  To: Kishon Vijay Abraham I
  Cc: bhelgaas, linux-omap, linux-pci, devicetree, linux-kernel,
	linux-arm-kernel, robh+dt, pawel.moll, mark.rutland,
	ijc+devicetree, galak, bcousson, linux, nsekhar

* Kishon Vijay Abraham I <kishon@ti.com> [150728 06:42]:
> gpio2_8 is connected to the PCIe_RESETn line and it has to be driven low
> in order to reset the PCIe cards. So added gpios property to pcie
> dt node.
> 
> Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>

This should not conflict with the device tree changes I'm queuing
for v4.3 merge window, so please feel free to queue with the PCIe
driver changes:

Acked-by: Tony Lindgren <tony@atomide.com>

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

* Re: [PATCH 0/2] pci: am57xx-evm: Fix PCIe card enumeration issue
  2015-07-28 13:39 [PATCH 0/2] pci: am57xx-evm: Fix PCIe card enumeration issue Kishon Vijay Abraham I
  2015-07-28 13:39 ` [PATCH 1/2] pci: host: pci-dra7xx: Add support to make gpio drive PERST# line Kishon Vijay Abraham I
  2015-07-28 13:39 ` [PATCH 2/2] ARM: dts: am57xx-evm: Add 'gpios' property with gpio2_8 Kishon Vijay Abraham I
@ 2015-08-11 21:02 ` Bjorn Helgaas
  2 siblings, 0 replies; 5+ messages in thread
From: Bjorn Helgaas @ 2015-08-11 21:02 UTC (permalink / raw)
  To: Kishon Vijay Abraham I
  Cc: linux-omap, linux-pci, devicetree, linux-kernel, linux-arm-kernel,
	tony, robh+dt, pawel.moll, mark.rutland, ijc+devicetree, galak,
	bcousson, linux, nsekhar

On Tue, Jul 28, 2015 at 07:09:08PM +0530, Kishon Vijay Abraham I wrote:
> This series fixes PCIe card enumeration issue in am57xx-evm.
> 
> In the case of am57xx-evm, the PERST# line is connected to a gpio line
> and this has to be driven low in order to perform a fundamental reset
> of the card. If the gpio line is driven high, there is no way the card
> can come out of reset.
> 
> Add support in the pcie-dra7xx driver to make gpio drive PERST# line.
> 
> The PERST# line can be used to perform reset not during the power on
> sequence too (warm reset) but we are not adding support for this as the
> PCIe express base sepcification doesn't explain how to perform warm
> reset
> 
> "In some cases, it may be possible for the Fundamental Reset mechanism
> to be triggered by hardware without the removal and re-application of
> power to the component. This is called a warm reset. This document does
> not specify a means for generating a warm reset."
> 
> Kishon Vijay Abraham I (2):
>   pci: host: pci-dra7xx: Add support to make gpio drive PERST# line
>   ARM: dts: am57xx-evm: Add 'gpios' property with gpio2_8
> 
>  Documentation/devicetree/bindings/pci/ti-pci.txt |    3 +++
>  arch/arm/boot/dts/am57xx-beagle-x15.dts          |    5 +++++
>  arch/arm/boot/dts/dra7.dtsi                      |    2 +-
>  drivers/pci/host/pci-dra7xx.c                    |   24 ++++++++++++++++++++--
>  4 files changed, 31 insertions(+), 3 deletions(-)

Applied with Tony's ack (for patch 2) to pci/host-dra7xx for v4.3, thanks!

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

end of thread, other threads:[~2015-08-11 21:02 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-07-28 13:39 [PATCH 0/2] pci: am57xx-evm: Fix PCIe card enumeration issue Kishon Vijay Abraham I
2015-07-28 13:39 ` [PATCH 1/2] pci: host: pci-dra7xx: Add support to make gpio drive PERST# line Kishon Vijay Abraham I
2015-07-28 13:39 ` [PATCH 2/2] ARM: dts: am57xx-evm: Add 'gpios' property with gpio2_8 Kishon Vijay Abraham I
2015-08-05 10:40   ` Tony Lindgren
2015-08-11 21:02 ` [PATCH 0/2] pci: am57xx-evm: Fix PCIe card enumeration issue Bjorn Helgaas

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