[PATCH 2/2] mfd: pca9450: Add init callback

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



We currently do not have regulator support for the pca945x chips,
so provide a init callback for board code to do the basic setup.

Signed-off-by: Sascha Hauer <s.hauer@xxxxxxxxxxxxxx>
---
 drivers/mfd/pca9450.c | 21 +++++++++++++++++++++
 include/mfd/pca9450.h | 14 ++++++++++++++
 2 files changed, 35 insertions(+)

diff --git a/drivers/mfd/pca9450.c b/drivers/mfd/pca9450.c
index 20f6b016fa..8fa5363f8a 100644
--- a/drivers/mfd/pca9450.c
+++ b/drivers/mfd/pca9450.c
@@ -61,6 +61,23 @@ static int pca9450_get_reset_source(struct device *dev, struct regmap *map)
 	return 0;
 };
 
+static struct regmap *pca9450_map;
+
+static void (*pca9450_init_callback)(struct regmap *map);
+
+int pca9450_register_init_callback(void(*callback)(struct regmap *map))
+{
+	if (pca9450_init_callback)
+		return -EBUSY;
+
+	pca9450_init_callback = callback;
+
+	if (pca9450_map)
+		pca9450_init_callback(pca9450_map);
+
+	return 0;
+}
+
 static int __init pca9450_probe(struct device *dev)
 {
 	struct regmap *regmap;
@@ -84,6 +101,10 @@ static int __init pca9450_probe(struct device *dev)
 	/* Chip ID defined in bits [7:4] */
 	dev_info(dev, "PMIC Chip ID: 0x%x\n", (reg >> 4));
 
+	if (pca9450_init_callback)
+		pca9450_init_callback(regmap);
+	pca9450_map = regmap;
+
 	pca9450_get_reset_source(dev,regmap);
 
 	return of_platform_populate(dev->of_node, NULL, dev);
diff --git a/include/mfd/pca9450.h b/include/mfd/pca9450.h
index 256f661911..7071c3a9da 100644
--- a/include/mfd/pca9450.h
+++ b/include/mfd/pca9450.h
@@ -6,6 +6,8 @@
 #ifndef PCA9450_H_
 #define PCA9450_H_
 
+#include <linux/regmap.h>
+
 enum {
 	PCA9450_REG_DEV_ID      = 0x00,
 	PCA9450_INT1            = 0x01,
@@ -52,4 +54,16 @@ enum {
 	PCA9450_REG_NUM,
 };
 
+#ifdef CONFIG_MFD_PCA9450
+
+int pca9450_register_init_callback(void(*callback)(struct regmap *map));
+
+#else
+
+static inline int pca9450_register_init_callback(void(*callback)(struct regmap *map))
+{
+	return -ENODEV;
+}
+#endif
+
 #endif
-- 
2.39.2





[Index of Archives]     [Linux Embedded]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux