mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH 1/2] mfd: pca9450: Add support for pca9451a
@ 2023-11-10 13:03 Sascha Hauer
  2023-11-10 13:03 ` [PATCH 2/2] mfd: pca9450: Add init callback Sascha Hauer
  0 siblings, 1 reply; 2+ messages in thread
From: Sascha Hauer @ 2023-11-10 13:03 UTC (permalink / raw)
  To: Barebox List

Add support for the pca9451a chip variant. This is not compatible
with the other variants, but as we currently only provide a regmap
this is fine.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 drivers/mfd/pca9450.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/mfd/pca9450.c b/drivers/mfd/pca9450.c
index cf0efab16f..20f6b016fa 100644
--- a/drivers/mfd/pca9450.c
+++ b/drivers/mfd/pca9450.c
@@ -92,6 +92,7 @@ static int __init pca9450_probe(struct device *dev)
 static __maybe_unused struct of_device_id pca9450_dt_ids[] = {
 	{ .compatible = "nxp,pca9450a" },
 	{ .compatible = "nxp,pca9450c" },
+	{ .compatible = "nxp,pca9451a" },
 	{ /* sentinel */ }
 };
 MODULE_DEVICE_TABLE(of, pca9450_dt_ids);
-- 
2.39.2




^ permalink raw reply	[flat|nested] 2+ messages in thread

* [PATCH 2/2] mfd: pca9450: Add init callback
  2023-11-10 13:03 [PATCH 1/2] mfd: pca9450: Add support for pca9451a Sascha Hauer
@ 2023-11-10 13:03 ` Sascha Hauer
  0 siblings, 0 replies; 2+ messages in thread
From: Sascha Hauer @ 2023-11-10 13:03 UTC (permalink / raw)
  To: Barebox List

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@pengutronix.de>
---
 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




^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-11-10 13:04 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-11-10 13:03 [PATCH 1/2] mfd: pca9450: Add support for pca9451a Sascha Hauer
2023-11-10 13:03 ` [PATCH 2/2] mfd: pca9450: Add init callback Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox