[PATCH 1/4] mfd: syscon: Introduce syscon_base_lookup_by_phandle() function

Alexander Shiyan shc_work at mail.ru
Thu Jan 23 12:22:04 EST 2014


Signed-off-by: Alexander Shiyan <shc_work at mail.ru>
---
 drivers/mfd/syscon.c | 20 ++++++++++++++++++++
 include/mfd/syscon.h |  8 ++++++++
 2 files changed, 28 insertions(+)

diff --git a/drivers/mfd/syscon.c b/drivers/mfd/syscon.c
index 52cb433..6437344 100644
--- a/drivers/mfd/syscon.c
+++ b/drivers/mfd/syscon.c
@@ -41,6 +41,26 @@ void __iomem *syscon_base_lookup_by_pdevname(const char *s)
 	return ERR_PTR(-ENODEV);
 }
 
+void __iomem *syscon_base_lookup_by_phandle(struct device_node *np,
+					    const char *property)
+{
+	struct device_node *node;
+	struct syscon *syscon;
+	struct device_d *dev;
+
+	node = of_parse_phandle(np, property, 0);
+	if (!node)
+		return ERR_PTR(-ENODEV);
+
+	dev = of_find_device_by_node(node);
+	if (!dev)
+		return ERR_PTR(-ENODEV);
+
+	syscon = dev->priv;
+
+	return syscon->base;
+}
+
 static int syscon_probe(struct device_d *dev)
 {
 	struct syscon *syscon;
diff --git a/include/mfd/syscon.h b/include/mfd/syscon.h
index 68432b7..0eccd5c 100644
--- a/include/mfd/syscon.h
+++ b/include/mfd/syscon.h
@@ -16,11 +16,19 @@
 
 #ifdef CONFIG_MFD_SYSCON
 void __iomem *syscon_base_lookup_by_pdevname(const char *);
+void __iomem *syscon_base_lookup_by_phandle
+	(struct device_node *np, const char *property);
 #else
 static inline void __iomem *syscon_base_lookup_by_pdevname(const char *)
 {
 	return NULL;
 }
+
+static inline void __iomem *syscon_base_lookup_by_phandle
+	(struct device_node *np, const char *property)
+{
+	return NULL;
+}
 #endif
 
 #endif
-- 
1.8.3.2




More information about the barebox mailing list