Commit 3d71746c authored by Baruch Siach's avatar Baruch Siach Committed by Lorenzo Pieralisi

PCI: armada8k: Add support for gpio controlled reset signal

Add support for the gpio reset signal binding as described in the
designware-pcie.txt DT binding document. Both the documented
'reset-gpio' property name and the more standard 'reset-gpios' name are
supported.
Signed-off-by: default avatarBaruch Siach <baruch@tkos.co.il>
Signed-off-by: default avatarLorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Acked-by: default avatarThomas Petazzoni <thomas.petazzoni@bootlin.com>
parent a3ed1446
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
#include <linux/resource.h> #include <linux/resource.h>
#include <linux/of_pci.h> #include <linux/of_pci.h>
#include <linux/of_irq.h> #include <linux/of_irq.h>
#include <linux/gpio/consumer.h>
#include "pcie-designware.h" #include "pcie-designware.h"
...@@ -29,6 +30,7 @@ struct armada8k_pcie { ...@@ -29,6 +30,7 @@ struct armada8k_pcie {
struct dw_pcie *pci; struct dw_pcie *pci;
struct clk *clk; struct clk *clk;
struct clk *clk_reg; struct clk *clk_reg;
struct gpio_desc *reset_gpio;
}; };
#define PCIE_VENDOR_REGS_OFFSET 0x8000 #define PCIE_VENDOR_REGS_OFFSET 0x8000
...@@ -137,6 +139,12 @@ static int armada8k_pcie_host_init(struct pcie_port *pp) ...@@ -137,6 +139,12 @@ static int armada8k_pcie_host_init(struct pcie_port *pp)
struct dw_pcie *pci = to_dw_pcie_from_pp(pp); struct dw_pcie *pci = to_dw_pcie_from_pp(pp);
struct armada8k_pcie *pcie = to_armada8k_pcie(pci); struct armada8k_pcie *pcie = to_armada8k_pcie(pci);
if (pcie->reset_gpio) {
/* assert and then deassert the reset signal */
gpiod_set_value_cansleep(pcie->reset_gpio, 1);
msleep(100);
gpiod_set_value_cansleep(pcie->reset_gpio, 0);
}
dw_pcie_setup_rc(pp); dw_pcie_setup_rc(pp);
armada8k_pcie_establish_link(pcie); armada8k_pcie_establish_link(pcie);
...@@ -249,6 +257,14 @@ static int armada8k_pcie_probe(struct platform_device *pdev) ...@@ -249,6 +257,14 @@ static int armada8k_pcie_probe(struct platform_device *pdev)
goto fail_clkreg; goto fail_clkreg;
} }
/* Get reset gpio signal and hold asserted (logically high) */
pcie->reset_gpio = devm_gpiod_get_optional(dev, "reset",
GPIOD_OUT_HIGH);
if (IS_ERR(pcie->reset_gpio)) {
ret = PTR_ERR(pcie->reset_gpio);
goto fail_clkreg;
}
platform_set_drvdata(pdev, pcie); platform_set_drvdata(pdev, pcie);
ret = armada8k_add_pcie_port(pcie, pdev); ret = armada8k_add_pcie_port(pcie, pdev);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment