[U-Boot] [PATCH v2] gpio: dwapb_gpio: Add reset ctrl to driver

Ley Foon Tan ley.foon.tan at intel.com
Thu Aug 16 05:46:29 UTC 2018


Add code to reset all reset signals as in gpio DT node. A reset property
is an optional feature, so only print out a warning and do not fail if a
reset property is not present.

If a reset property is discovered, then use it to deassert, thus
bringing the IP out of reset.

Signed-off-by: Ley Foon Tan <ley.foon.tan at intel.com>

---
v2:
- Move reset to probe() function.
---
 drivers/gpio/dwapb_gpio.c | 20 +++++++++++++++++++-
 1 file changed, 19 insertions(+), 1 deletion(-)

diff --git a/drivers/gpio/dwapb_gpio.c b/drivers/gpio/dwapb_gpio.c
index 7cf2d47..dfe1e6d 100644
--- a/drivers/gpio/dwapb_gpio.c
+++ b/drivers/gpio/dwapb_gpio.c
@@ -15,6 +15,7 @@
 #include <dm/lists.h>
 #include <dm/root.h>
 #include <errno.h>
+#include <reset.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -99,13 +100,30 @@ static const struct dm_gpio_ops gpio_dwapb_ops = {
 	.get_function		= dwapb_gpio_get_function,
 };
 
+static void gpio_dwapb_reset(struct udevice *dev)
+{
+	struct reset_ctl_bulk reset_bulk;
+	int ret;
+
+	ret = reset_get_bulk(dev, &reset_bulk);
+	if (ret) {
+		dev_warn(dev, "Can't get reset: %d\n", ret);
+		return;
+	}
+
+	reset_deassert_bulk(&reset_bulk);
+}
+
 static int gpio_dwapb_probe(struct udevice *dev)
 {
 	struct gpio_dev_priv *priv = dev_get_uclass_priv(dev);
 	struct gpio_dwapb_platdata *plat = dev->platdata;
 
-	if (!plat)
+	if (!plat) {
+		/* Reset on parent device only */
+		gpio_dwapb_reset(dev);
 		return 0;
+	}
 
 	priv->gpio_count = plat->pins;
 	priv->bank_name = plat->name;
-- 
2.2.2



More information about the U-Boot mailing list