ofnode: add {ofnode, dev}_read_resource_byname()

Linux supports platform_get_resource_byname() to look up a resource
by name.

We want a similar helper.  It is useful when a device node has named
register regions.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
diff --git a/drivers/core/ofnode.c b/drivers/core/ofnode.c
index c1a2e9f..0685b68 100644
--- a/drivers/core/ofnode.c
+++ b/drivers/core/ofnode.c
@@ -627,3 +627,15 @@
 		return 0;
 	}
 }
+
+int ofnode_read_resource_byname(ofnode node, const char *name,
+				struct resource *res)
+{
+	int index;
+
+	index = ofnode_stringlist_search(node, "reg-names", name);
+	if (index < 0)
+		return index;
+
+	return ofnode_read_resource(node, index, res);
+}