[U-Boot] [PATCH v2 22/53] reset: Add get reset by name optionally

Jagan Teki jagan at amarulasolutions.com
Fri Aug 10 06:06:40 UTC 2018


Reset is an optional for some controllers with some families
of CPU's with same SoC where the common IP driver can handle
to drive the entire SoC families. optional reset get by name
is useful for those drivers to make common way of reset handling.

Example, In Allwinner SoC with MMC controllers has no reset
for Sun4i, 5i, 7i but reset have reset.

Cc: Simon Glass <sjg at chromium.org>
Signed-off-by: Jagan Teki <jagan at amarulasolutions.com>
---
 drivers/reset/reset-uclass.c | 18 ++++++++++++++++++
 include/reset.h              | 25 +++++++++++++++++++++++++
 2 files changed, 43 insertions(+)

diff --git a/drivers/reset/reset-uclass.c b/drivers/reset/reset-uclass.c
index 99881b8b99..6320efcb49 100644
--- a/drivers/reset/reset-uclass.c
+++ b/drivers/reset/reset-uclass.c
@@ -138,6 +138,24 @@ int reset_get_by_name(struct udevice *dev, const char *name,
 	return reset_get_by_index(dev, index, reset_ctl);
 }
 
+int reset_get_by_name_optional(struct udevice *dev, const char *name,
+			       struct reset_ctl *reset_ctl, bool optional)
+{
+	int index;
+
+	debug("%s(dev=%p, name=%s, reset_ctl=%p)\n", __func__, dev, name,
+	      reset_ctl);
+	reset_ctl->dev = NULL;
+
+	index = dev_read_stringlist_search(dev, "reset-names", name);
+	if (index < 0) {
+		debug("fdt_stringlist_search() failed: %d\n", index);
+		return optional ? 0 : index;
+	}
+
+	return reset_get_by_index(dev, index, reset_ctl);
+}
+
 int reset_request(struct reset_ctl *reset_ctl)
 {
 	struct reset_ops *ops = reset_dev_ops(reset_ctl->dev);
diff --git a/include/reset.h b/include/reset.h
index a7bbc1c331..a5af31f549 100644
--- a/include/reset.h
+++ b/include/reset.h
@@ -132,6 +132,23 @@ int reset_get_bulk(struct udevice *dev, struct reset_ctl_bulk *bulk);
 int reset_get_by_name(struct udevice *dev, const char *name,
 		      struct reset_ctl *reset_ctl);
 
+/**
+ * reset_get_by_name_optional - Get/request a reset signal by name optionally.
+ *
+ * This look up and requests a reset signal similar to reset_get_by_name()
+ * but with optional flag.
+ *
+ * @dev:	The client device.
+ * @name:	The name of the reset signal to request, within the client's
+ *		list of reset signals.
+ * @reset_ctl:	A pointer to a reset control struct to initialize.
+ * @optional:	Optional flag, true if reset is optional, false if reset is
+ *		necessary which is same as reset_get_by_name()
+ * @return 0 if OK, or a negative error code.
+ */
+int reset_get_by_name_optional(struct udevice *dev, const char *name,
+			       struct reset_ctl *reset_ctl, bool optional);
+
 /**
  * reset_request - Request a reset signal.
  *
@@ -254,6 +271,14 @@ static inline int reset_get_by_name(struct udevice *dev, const char *name,
 	return -ENOTSUPP;
 }
 
+static inline int reset_get_by_name_optional(struct udevice *dev,
+					     const char *name,
+					     struct reset_ctl *reset_ctl,
+					     bool optional)
+{
+	return -ENOTSUPP;
+}
+
 static inline int reset_free(struct reset_ctl *reset_ctl)
 {
 	return 0;
-- 
2.18.0.321.gffc6fa0e3



More information about the U-Boot mailing list