From: Sascha Hauer <s.hauer@pengutronix.de>
To: barebox@lists.infradead.org
Subject: [PATCH 1/5] mfd: mc13xxx: Allow to set callback for mc13xxx
Date: Thu, 8 May 2014 09:31:35 +0200 [thread overview]
Message-ID: <1399534299-27051-2-git-send-email-s.hauer@pengutronix.de> (raw)
In-Reply-To: <1399534299-27051-1-git-send-email-s.hauer@pengutronix.de>
Some boards have to initialize the PMIC before other devices can
be initialized. This requires three levels of initcalls: one level
in which the PMIC is probed, one in which the board can call mc13xxx_get()
and the third one to initialize the PMIC dependent devices.
Allow to register a callback which is called once the PMIC is initialized.
This way mc13xxx_get() is no longer necessary and the number of required
initcalls levels is reduced to two.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
drivers/mfd/mc13xxx.c | 18 ++++++++++++++++++
drivers/net/fec_imx.h | 1 +
include/mfd/mc13xxx.h | 6 ++++++
3 files changed, 25 insertions(+)
diff --git a/drivers/mfd/mc13xxx.c b/drivers/mfd/mc13xxx.c
index bfbd328..9842c56 100644
--- a/drivers/mfd/mc13xxx.c
+++ b/drivers/mfd/mc13xxx.c
@@ -60,6 +60,21 @@ int mc13xxx_revision(struct mc13xxx *mc13xxx)
}
EXPORT_SYMBOL(mc13xxx_revision);
+void(*mc13xxx_callback)(struct mc13xxx *mc13xxx);
+
+int mc13xxx_register_callback(void(*callback)(struct mc13xxx *mc13xxx))
+{
+ if (mc13xxx_callback)
+ return -EBUSY;
+
+ mc13xxx_callback = callback;
+
+ if (mc_dev)
+ mc13xxx_callback(mc_dev);
+
+ return 0;
+}
+
#ifdef CONFIG_SPI
static int spi_rw(struct spi_device *spi, void * buf, size_t len)
{
@@ -350,6 +365,9 @@ static int __init mc13xxx_probe(struct device_d *dev)
mc_dev->revision = rev;
devfs_create(&mc_dev->cdev);
+ if (mc13xxx_callback)
+ mc13xxx_callback(mc_dev);
+
return 0;
}
diff --git a/drivers/net/fec_imx.h b/drivers/net/fec_imx.h
index 0921b52..a77c1dc 100644
--- a/drivers/net/fec_imx.h
+++ b/drivers/net/fec_imx.h
@@ -146,6 +146,7 @@ struct fec_priv {
void (*phy_init)(struct phy_device *dev);
struct clk *clk;
enum fec_type type;
+ int phy_reset_gpio;
};
static inline int fec_is_imx27(struct fec_priv *priv)
diff --git a/include/mfd/mc13xxx.h b/include/mfd/mc13xxx.h
index 1946b1a..cf5c42d 100644
--- a/include/mfd/mc13xxx.h
+++ b/include/mfd/mc13xxx.h
@@ -171,6 +171,7 @@ extern int mc13xxx_revision(struct mc13xxx *mc13xxx);
extern int mc13xxx_reg_read(struct mc13xxx *mc13xxx, u8 reg, u32 *val);
extern int mc13xxx_reg_write(struct mc13xxx *mc13xxx, u8 reg, u32 val);
extern int mc13xxx_set_bits(struct mc13xxx *mc13xxx, u8 reg, u32 mask, u32 val);
+int mc13xxx_register_callback(void(*callback)(struct mc13xxx *mc13xxx));
#else
static inline struct mc13xxx *mc13xxx_get(void)
{
@@ -196,6 +197,11 @@ static inline int mc13xxx_set_bits(struct mc13xxx *mc13xxx, u8 reg, u32 mask, u3
{
return -ENODEV;
}
+
+static inline int mc13xxx_register_callback(void(*callback)(struct mc13xxx *mc13xxx))
+{
+ return -ENODEV;
+}
#endif
#endif /* __MFD_MC13XXX_H */
--
2.0.0.rc0
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
next prev parent reply other threads:[~2014-05-08 7:32 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-05-08 7:31 [PATCH] fix i.MX51 babbage ethernet Sascha Hauer
2014-05-08 7:31 ` Sascha Hauer [this message]
2014-05-18 23:14 ` [PATCH 1/5] mfd: mc13xxx: Allow to set callback for mc13xxx Marc Reilly
2014-05-19 6:40 ` Sascha Hauer
2014-05-08 7:31 ` [PATCH 2/5] spi: i.MX: Move to coredevice_initcall Sascha Hauer
2014-05-11 18:49 ` Alexander Shiyan
2014-05-12 10:38 ` Sascha Hauer
2014-05-14 17:57 ` Alexander Shiyan
2014-05-19 8:47 ` Sascha Hauer
2014-05-08 7:31 ` [PATCH 3/5] mfd: mc13xxx: move " Sascha Hauer
2014-05-08 7:31 ` [PATCH 4/5] ARM: i.MX51 babbage: use mc13xxx_register_callback to initialize PMIC Sascha Hauer
2014-05-08 7:31 ` [PATCH 5/5] ARM: dts: i.MX51 babbage: overwrite upstream FEC iomux settings Sascha Hauer
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=1399534299-27051-2-git-send-email-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