diff mbox

[U-Boot,RFC,2/2] dm: mmc: implement pwrup function

Message ID 1458091947-10397-2-git-send-email-van.freenix@gmail.com
State RFC
Delegated to: Pantelis Antoniou
Headers show

Commit Message

Peng Fan March 16, 2016, 1:32 a.m. UTC
If vmmc-supply property is provided, then enable it.
If vmmc-supply is not provided, just ignore it.
For now, only fixed regulator is supported.

In device tree:
"
		reg_sd1_vmmc: regulator@1 {
			compatible = "regulator-fixed";
			regulator-name = "VSD_3V3";
			regulator-min-microvolt = <3300000>;
			regulator-max-microvolt = <3300000>;
			gpio = <&gpio1 9 GPIO_ACTIVE_HIGH>;
			enable-active-high;
		};

&usdhc1 {
	pinctrl-names = "default", "state_100mhz", "state_200mhz";
	pinctrl-0 = <&pinctrl_usdhc1>;
	pinctrl-1 = <&pinctrl_usdhc1_100mhz>;
	pinctrl-2 = <&pinctrl_usdhc1_200mhz>;
	cd-gpios = <&gpio1 19 GPIO_ACTIVE_LOW>;
	keep-power-in-suspend;
	enable-sdio-wakeup;
	vmmc-supply = <&reg_sd1_vmmc>;
	status = "okay";
};
"

Signed-off-by: Peng Fan <van.freenix@gmail.com>
Cc: Pantelis Antoniou <panto@antoniou-consulting.com>
Cc: Simon Glass <sjg@chromium.org>
Cc: Eric Nelson <eric@nelint.com>
Cc: York Sun <york.sun@nxp.com>
Cc: Stefano Babic <sbabic@denx.de>
Cc: Fabio Estevam <fabio.estevam@nxp.com>
---
 drivers/mmc/fsl_esdhc.c | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

Comments

Simon Glass April 9, 2016, 6:34 p.m. UTC | #1
On 15 March 2016 at 19:32, Peng Fan <van.freenix@gmail.com> wrote:
> If vmmc-supply property is provided, then enable it.
> If vmmc-supply is not provided, just ignore it.
> For now, only fixed regulator is supported.
>
> In device tree:
> "
>                 reg_sd1_vmmc: regulator@1 {
>                         compatible = "regulator-fixed";
>                         regulator-name = "VSD_3V3";
>                         regulator-min-microvolt = <3300000>;
>                         regulator-max-microvolt = <3300000>;
>                         gpio = <&gpio1 9 GPIO_ACTIVE_HIGH>;
>                         enable-active-high;
>                 };
>
> &usdhc1 {
>         pinctrl-names = "default", "state_100mhz", "state_200mhz";
>         pinctrl-0 = <&pinctrl_usdhc1>;
>         pinctrl-1 = <&pinctrl_usdhc1_100mhz>;
>         pinctrl-2 = <&pinctrl_usdhc1_200mhz>;
>         cd-gpios = <&gpio1 19 GPIO_ACTIVE_LOW>;
>         keep-power-in-suspend;
>         enable-sdio-wakeup;
>         vmmc-supply = <&reg_sd1_vmmc>;
>         status = "okay";
> };
> "
>
> Signed-off-by: Peng Fan <van.freenix@gmail.com>
> Cc: Pantelis Antoniou <panto@antoniou-consulting.com>
> Cc: Simon Glass <sjg@chromium.org>
> Cc: Eric Nelson <eric@nelint.com>
> Cc: York Sun <york.sun@nxp.com>
> Cc: Stefano Babic <sbabic@denx.de>
> Cc: Fabio Estevam <fabio.estevam@nxp.com>
> ---
>  drivers/mmc/fsl_esdhc.c | 25 +++++++++++++++++++++++++
>  1 file changed, 25 insertions(+)

Acked-by: Simon Glass <sjg@chromium.org>
diff mbox

Patch

diff --git a/drivers/mmc/fsl_esdhc.c b/drivers/mmc/fsl_esdhc.c
index e657bd0..33a7efb 100644
--- a/drivers/mmc/fsl_esdhc.c
+++ b/drivers/mmc/fsl_esdhc.c
@@ -23,6 +23,7 @@ 
 #include <dm.h>
 #include <asm/arch/clock.h>
 #include <asm-generic/gpio.h>
+#include <power/regulator.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -671,6 +672,29 @@  static int esdhc_getcd(struct mmc *mmc)
 	return timeout > 0;
 }
 
+static int esdhc_pwrup(struct mmc *mmc)
+{
+#ifdef CONFIG_DM_MMC
+	struct fsl_esdhc_priv *priv = mmc->priv;
+	struct udevice *vmmc_supply;
+	int ret;
+
+	ret = device_get_supply_regulator(priv->dev, "vmmc-supply",
+					  &vmmc_supply);
+	if (ret) {
+		debug("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;
+}
+
 static void esdhc_reset(struct fsl_esdhc *regs)
 {
 	unsigned long timeout = 100; /* wait max 100 ms */
@@ -690,6 +714,7 @@  static const struct mmc_ops esdhc_ops = {
 	.set_ios	= esdhc_set_ios,
 	.init		= esdhc_init,
 	.getcd		= esdhc_getcd,
+	.pwrup		= esdhc_pwrup,
 };
 
 static int fsl_esdhc_cfg_to_priv(struct fsl_esdhc_cfg *cfg,