diff mbox

[U-Boot,v4,03/11] reset: add reset_assert_all()

Message ID 1495630917-25272-4-git-send-email-patrice.chotard@st.com
State Not Applicable
Delegated to: Marek Vasut
Headers show

Commit Message

Patrice CHOTARD May 24, 2017, 1:01 p.m. UTC
From: Patrice Chotard <patrice.chotard@st.com>

Add reset_assert_all() method which Request/Assert/Free an
array of resets signal that has been previously successfully
requested by reset_get_by_*()

Signed-off-by: Patrice Chotard <patrice.chotard@st.com>
---

v4:	_ add reset_assert_all() method as suggested by Marek Vasut 
	  and Simon Glass

 drivers/reset/reset-uclass.c | 22 ++++++++++++++++++++++
 include/reset.h              | 17 +++++++++++++++++
 2 files changed, 39 insertions(+)

Comments

Simon Glass June 1, 2017, 3:10 a.m. UTC | #1
On 24 May 2017 at 07:01,  <patrice.chotard@st.com> wrote:
> From: Patrice Chotard <patrice.chotard@st.com>
>
> Add reset_assert_all() method which Request/Assert/Free an
> array of resets signal that has been previously successfully
> requested by reset_get_by_*()
>
> Signed-off-by: Patrice Chotard <patrice.chotard@st.com>
> ---
>
> v4:     _ add reset_assert_all() method as suggested by Marek Vasut
>           and Simon Glass
>
>  drivers/reset/reset-uclass.c | 22 ++++++++++++++++++++++
>  include/reset.h              | 17 +++++++++++++++++
>  2 files changed, 39 insertions(+)

Reviewed-by: Simon Glass <sjg@chromium.org>
diff mbox

Patch

diff --git a/drivers/reset/reset-uclass.c b/drivers/reset/reset-uclass.c
index ebdeee5..f1ab899 100644
--- a/drivers/reset/reset-uclass.c
+++ b/drivers/reset/reset-uclass.c
@@ -148,6 +148,28 @@  int reset_deassert(struct reset_ctl *reset_ctl)
 	return ops->rst_deassert(reset_ctl);
 }
 
+int reset_assert_all(struct reset_ctl *reset_ctl, int count)
+{
+	int i, ret;
+
+	for (i = 0; i < count; i++) {
+		debug("%s(reset_ctl[%d]=%p)\n", __func__, i, &reset_ctl[i]);
+
+		ret = reset_request(&reset_ctl[i]);
+		if (ret)
+			return ret;
+
+		ret = reset_assert(&reset_ctl[i]);
+		if (ret)
+			return ret;
+
+		ret = reset_free(&reset_ctl[i]);
+		if (ret)
+			return ret;
+	}
+	return 0;
+}
+
 UCLASS_DRIVER(reset) = {
 	.id		= UCLASS_RESET,
 	.name		= "reset",
diff --git a/include/reset.h b/include/reset.h
index e8e68b6..fa3b4a4 100644
--- a/include/reset.h
+++ b/include/reset.h
@@ -155,6 +155,17 @@  int reset_assert(struct reset_ctl *reset_ctl);
  */
 int reset_deassert(struct reset_ctl *reset_ctl);
 
+/**
+ * reset_assert_all - Request/Assert/Free resets.
+ *
+ * This function will request, assert and free array of clocks,
+ *
+ * @reset_ctl:	A reset struct array that was previously successfully
+ *		requested by reset_get_by_*().
+ * @count	Number of reset contained in the array
+ * @return 0 if OK, or a negative error code.
+ */
+int reset_assert_all(struct reset_ctl *reset_ctl, int count);
 #else
 static inline int reset_get_by_index(struct udevice *dev, int index,
 				     struct reset_ctl *reset_ctl)
@@ -182,6 +193,12 @@  static inline int reset_deassert(struct reset_ctl *reset_ctl)
 {
 	return 0;
 }
+
+static inline int reset_assert_all(struct reset_ctl *reset_ctl, int count)
+{
+	return 0;
+}
+
 #endif
 
 #endif