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

Jagan Teki jagan at amarulasolutions.com
Mon Aug 6 17:37:43 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.

Signed-off-by: Jagan Teki <jagan at amarulasolutions.com>
---
 drivers/reset/reset-uclass.c | 17 +++++++++++++++++
 include/reset.h              | 25 +++++++++++++++++++++++++
 2 files changed, 42 insertions(+)

diff --git a/drivers/reset/reset-uclass.c b/drivers/reset/reset-uclass.c
index 99881b8b99..3bc280be5e 100644
--- a/drivers/reset/reset-uclass.c
+++ b/drivers/reset/reset-uclass.c
@@ -138,6 +138,23 @@ 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) {
+		printf("reset_get_by_name_optional: optional = %d, index = %d\n", optional, 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