From: Sascha Hauer <s.hauer@pengutronix.de>
To: Barebox List <barebox@lists.infradead.org>
Subject: [PATCH 2/2] mfd: pca9450: Add init callback
Date: Fri, 10 Nov 2023 14:03:12 +0100 [thread overview]
Message-ID: <20231110130312.2234966-2-s.hauer@pengutronix.de> (raw)
In-Reply-To: <20231110130312.2234966-1-s.hauer@pengutronix.de>
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
prev parent reply other threads:[~2023-11-10 13:04 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-10 13:03 [PATCH 1/2] mfd: pca9450: Add support for pca9451a Sascha Hauer
2023-11-10 13:03 ` Sascha Hauer [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20231110130312.2234966-2-s.hauer@pengutronix.de \
--to=s.hauer@pengutronix.de \
--cc=barebox@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox