All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH V2] mmc: introduce mmc_power_init
@ 2016-10-11  7:08 ` Peng Fan
  2016-10-21  4:34   ` Jaehoon Chung
  0 siblings, 1 reply; 2+ messages in thread
From: Peng Fan @ 2016-10-11  7:08 UTC (permalink / raw)
  To: u-boot

In device tree, there is vmmc-supply property for SD/MMC.
Introduce mmc_power_init function to handle vmmc-supply.

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

If DM_MMC and DM_REGULATOR is defined, the regulator
will be enabled to power up the device.

Signed-off-by: Peng Fan <peng.fan@nxp.com>
Cc: Jaehoon Chung <jh80.chung@samsung.com>
---

V2:
 Change function prototype to static.
 Use puts to replace debug, when no vmmc-supply.

V1: Use a generic way to handle vmmc supply, but not let vendor driver
    to handle it.

The RFC patset thread:
http://lists.denx.de/pipermail/u-boot/2016-April/251019.html

 drivers/mmc/mmc.c | 30 +++++++++++++++++++++++++++++-
 1 file changed, 29 insertions(+), 1 deletion(-)

diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c
index 0312da9..320413a 100644
--- a/drivers/mmc/mmc.c
+++ b/drivers/mmc/mmc.c
@@ -15,6 +15,7 @@
 #include <errno.h>
 #include <mmc.h>
 #include <part.h>
+#include <power/regulator.h>
 #include <malloc.h>
 #include <memalign.h>
 #include <linux/list.h>
@@ -1582,6 +1583,31 @@ __weak void board_mmc_power_init(void)
 {
 }
 
+static int mmc_power_init(struct mmc *mmc)
+{
+	board_mmc_power_init();
+
+#if defined(CONFIG_DM_MMC) && defined(CONFIG_DM_REGULATOR) && \
+	!defined(CONFIG_SPL_BUILD)
+	struct udevice *vmmc_supply;
+	int ret;
+
+	ret = device_get_supply_regulator(mmc->dev, "vmmc-supply",
+					  &vmmc_supply);
+	if (ret) {
+		puts("No vmmc supply\n");
+		return 0;
+	}
+
+	ret = regulator_set_enable(vmmc_supply, true);
+	if (ret) {
+		puts("Error enabling VMMC supply\n");
+		return ret;
+	}
+#endif
+	return 0;
+}
+
 int mmc_start_init(struct mmc *mmc)
 {
 	bool no_card;
@@ -1606,7 +1632,9 @@ 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;
 
 #ifdef CONFIG_DM_MMC_OPS
 	/* The device has already been probed ready for use */
-- 
2.6.2

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

* [U-Boot] [PATCH V2] mmc: introduce mmc_power_init
  2016-10-11  7:08 ` [U-Boot] [PATCH V2] mmc: introduce mmc_power_init Peng Fan
@ 2016-10-21  4:34   ` Jaehoon Chung
  0 siblings, 0 replies; 2+ messages in thread
From: Jaehoon Chung @ 2016-10-21  4:34 UTC (permalink / raw)
  To: u-boot

Hi,

On 10/11/2016 04:08 PM, Peng Fan wrote:
> In device tree, there is vmmc-supply property for SD/MMC.
> Introduce mmc_power_init function to handle vmmc-supply.
> 
> mmc_power_init will first invoke board_mmc_power_init to
> avoid break boards which already implement board_mmc_power_init.
> 
> If DM_MMC and DM_REGULATOR is defined, the regulator
> will be enabled to power up the device.

Applied on u-boot-mmc. Thanks!

Best Regards,
Jaehoon Chung
> 
> Signed-off-by: Peng Fan <peng.fan@nxp.com>
> Cc: Jaehoon Chung <jh80.chung@samsung.com>
> ---
> 
> V2:
>  Change function prototype to static.
>  Use puts to replace debug, when no vmmc-supply.
> 
> V1: Use a generic way to handle vmmc supply, but not let vendor driver
>     to handle it.
> 
> The RFC patset thread:
> http://lists.denx.de/pipermail/u-boot/2016-April/251019.html
> 
>  drivers/mmc/mmc.c | 30 +++++++++++++++++++++++++++++-
>  1 file changed, 29 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c
> index 0312da9..320413a 100644
> --- a/drivers/mmc/mmc.c
> +++ b/drivers/mmc/mmc.c
> @@ -15,6 +15,7 @@
>  #include <errno.h>
>  #include <mmc.h>
>  #include <part.h>
> +#include <power/regulator.h>
>  #include <malloc.h>
>  #include <memalign.h>
>  #include <linux/list.h>
> @@ -1582,6 +1583,31 @@ __weak void board_mmc_power_init(void)
>  {
>  }
>  
> +static int mmc_power_init(struct mmc *mmc)
> +{
> +	board_mmc_power_init();
> +
> +#if defined(CONFIG_DM_MMC) && defined(CONFIG_DM_REGULATOR) && \
> +	!defined(CONFIG_SPL_BUILD)
> +	struct udevice *vmmc_supply;
> +	int ret;
> +
> +	ret = device_get_supply_regulator(mmc->dev, "vmmc-supply",
> +					  &vmmc_supply);
> +	if (ret) {
> +		puts("No vmmc supply\n");
> +		return 0;
> +	}
> +
> +	ret = regulator_set_enable(vmmc_supply, true);
> +	if (ret) {
> +		puts("Error enabling VMMC supply\n");
> +		return ret;
> +	}
> +#endif
> +	return 0;
> +}
> +
>  int mmc_start_init(struct mmc *mmc)
>  {
>  	bool no_card;
> @@ -1606,7 +1632,9 @@ 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;
>  
>  #ifdef CONFIG_DM_MMC_OPS
>  	/* The device has already been probed ready for use */
> 

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

end of thread, other threads:[~2016-10-21  4:34 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <CGME20161011070938epcas1p3bb0b4358496e949ad89df391469129c3@epcas1p3.samsung.com>
2016-10-11  7:08 ` [U-Boot] [PATCH V2] mmc: introduce mmc_power_init Peng Fan
2016-10-21  4:34   ` Jaehoon Chung

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.