[U-Boot] [PATCH v3 22/31] ARM: i.MX6: sabresd: Add imx6_pcie_toggle_reset

Jagan Teki
2017-04-05T19:20:32Z

Add imx6_pcie_toggle_reset on board file using dm_gpio_*
calls for OF_CONTROL configs.

Cc: Stefano Babic <sbabic@denx.de>
Cc: Fabio Estevam <fabio.estevam@nxp.com>
Cc: Michael Trimarchi <michael@amarulasolutions.com>
Signed-off-by: Jagan Teki <jagan@amarulasolutions.com>
---
board/freescale/mx6sabresd/mx6sabresd.c | 31 +++++++++++++++++++++++++++++++
1 file changed, 31 insertions(+)

diff --git a/board/freescale/mx6sabresd/mx6sabresd.c b/board/freescale/mx6sabresd/mx6sabresd.c
index f4e14be..67fc192 100644
--- a/board/freescale/mx6sabresd/mx6sabresd.c
+++ b/board/freescale/mx6sabresd/mx6sabresd.c
@@ -561,6 +561,37 @@ int imx6_pcie_toggle_power(void)
#endif
return 0;
}
+
+int imx6_pcie_toggle_reset(void)
+{
+#ifdef CONFIG_PCIE_IMX_PERST_GPIO
+ struct gpio_desc reset;
+ int ret;
+
+ ret = dm_gpio_lookup_name("GPIO7_12", &reset);
+ if (ret) {
+ printf("Cannot get GPIO7_12\n");
+ return ret;
+ }
+
+ ret = dm_gpio_request(&reset, "reset");
+ if (ret) {
+ printf("Cannot request GPIO7_12\n");
+ return ret;
+ }
+
+ dm_gpio_set_dir_flags(&reset, GPIOD_IS_OUT);
+
+ dm_gpio_set_value(&reset, 0);
+ mdelay(20);
+ dm_gpio_set_value(&reset, 1);
+ mdelay(20);
+
+#else
+ puts("WARNING: Make sure the PCIe #PERST line is connected!\n");
+#endif
+ return 0;
+}
#endif

#ifndef CONFIG_OF_CONTROL
--
1.9.1