Skip to content

Commit 3d71746

Browse files
baruchsiachLorenzo Pieralisi
authored andcommitted
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: Baruch Siach <baruch@tkos.co.il> Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com> Acked-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
1 parent a3ed144 commit 3d71746

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

drivers/pci/controller/dwc/pcie-armada8k.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,15 @@
2222
#include <linux/resource.h>
2323
#include <linux/of_pci.h>
2424
#include <linux/of_irq.h>
25+
#include <linux/gpio/consumer.h>
2526

2627
#include "pcie-designware.h"
2728

2829
struct armada8k_pcie {
2930
struct dw_pcie *pci;
3031
struct clk *clk;
3132
struct clk *clk_reg;
33+
struct gpio_desc *reset_gpio;
3234
};
3335

3436
#define PCIE_VENDOR_REGS_OFFSET 0x8000
@@ -137,6 +139,12 @@ static int armada8k_pcie_host_init(struct pcie_port *pp)
137139
struct dw_pcie *pci = to_dw_pcie_from_pp(pp);
138140
struct armada8k_pcie *pcie = to_armada8k_pcie(pci);
139141

142+
if (pcie->reset_gpio) {
143+
/* assert and then deassert the reset signal */
144+
gpiod_set_value_cansleep(pcie->reset_gpio, 1);
145+
msleep(100);
146+
gpiod_set_value_cansleep(pcie->reset_gpio, 0);
147+
}
140148
dw_pcie_setup_rc(pp);
141149
armada8k_pcie_establish_link(pcie);
142150

@@ -249,6 +257,14 @@ static int armada8k_pcie_probe(struct platform_device *pdev)
249257
goto fail_clkreg;
250258
}
251259

260+
/* Get reset gpio signal and hold asserted (logically high) */
261+
pcie->reset_gpio = devm_gpiod_get_optional(dev, "reset",
262+
GPIOD_OUT_HIGH);
263+
if (IS_ERR(pcie->reset_gpio)) {
264+
ret = PTR_ERR(pcie->reset_gpio);
265+
goto fail_clkreg;
266+
}
267+
252268
platform_set_drvdata(pdev, pcie);
253269

254270
ret = armada8k_add_pcie_port(pcie, pdev);

0 commit comments

Comments
 (0)