public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Peng Fan <van.freenix@gmail.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [RFC 1/2] mmc: introduce mmc_power_init and pwrup hook function
Date: Wed, 16 Mar 2016 09:32:26 +0800	[thread overview]
Message-ID: <1458091947-10397-1-git-send-email-van.freenix@gmail.com> (raw)

In device tree, there is vmmc-supply property for SD/MMC.
Introduce mmc_power_init function and pwrup hook function to let
the specific drivers handle vmmc-supply.

mmc_power_init will first invoke board_mmc_power_init to
avoid break boards which already implement board_mmc_power_init.

Then if pwrup hook functions have been implemented for different
mmc drivers, pwrup will be invoked.

Signed-off-by: Peng Fan <van.freenix@gmail.com>
Cc: Pantelis Antoniou <panto@antoniou-consulting.com>
Cc: Andrew Gabbasov <andrew_gabbasov@mentor.com>
Cc: Simon Glass <sjg@chromium.org>
Cc: Stephen Warren <swarren@nvidia.com>
Cc: Clemens Gruber <clemens.gruber@pqgruber.com>
Cc: Eric Nelson <eric@nelint.com>
Cc: Stefano Babic <sbabic@denx.de>
Cc: Fabio Estevam <fabio.estevam@nxp.com>
---
 drivers/mmc/mmc.c | 15 ++++++++++++++-
 include/mmc.h     |  1 +
 2 files changed, 15 insertions(+), 1 deletion(-)

diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c
index ede5d6e..f6d5c6f 100644
--- a/drivers/mmc/mmc.c
+++ b/drivers/mmc/mmc.c
@@ -1594,6 +1594,16 @@ __weak void board_mmc_power_init(void)
 {
 }
 
+__weak int mmc_power_init(struct mmc *mmc)
+{
+	board_mmc_power_init();
+
+	if (mmc->cfg->ops->pwrup)
+		return mmc->cfg->ops->pwrup(mmc);
+
+	return 0;
+}
+
 int mmc_start_init(struct mmc *mmc)
 {
 	int err;
@@ -1613,7 +1623,10 @@ int mmc_start_init(struct mmc *mmc)
 #ifdef CONFIG_FSL_ESDHC_ADAPTER_IDENT
 	mmc_adapter_card_type_ident();
 #endif
-	board_mmc_power_init();
+
+	err = mmc_power_init(mmc);
+	if (err)
+		return err;
 
 	/* made sure it's not NULL earlier */
 	err = mmc->cfg->ops->init(mmc);
diff --git a/include/mmc.h b/include/mmc.h
index d652c14..111ff75 100644
--- a/include/mmc.h
+++ b/include/mmc.h
@@ -329,6 +329,7 @@ struct mmc_ops {
 	int (*init)(struct mmc *mmc);
 	int (*getcd)(struct mmc *mmc);
 	int (*getwp)(struct mmc *mmc);
+	int (*pwrup)(struct mmc *mmc);
 };
 
 struct mmc_config {
-- 
2.6.2

             reply	other threads:[~2016-03-16  1:32 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-16  1:32 Peng Fan [this message]
2016-03-16  1:32 ` [U-Boot] [RFC 2/2] dm: mmc: implement pwrup function Peng Fan
2016-04-09 18:34   ` Simon Glass
2016-04-09 18:34 ` [U-Boot] [RFC 1/2] mmc: introduce mmc_power_init and pwrup hook function Simon Glass
2016-04-11  5:34   ` Peng Fan
2016-04-20 14:40     ` Simon Glass
2016-04-21  1:22       ` Peng Fan

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=1458091947-10397-1-git-send-email-van.freenix@gmail.com \
    --to=van.freenix@gmail.com \
    --cc=u-boot@lists.denx.de \
    /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