All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3 0/2] mmc add vsdio to dynamically control sdio power
@ 2011-08-25  6:26 ` Zhangfei Gao
  0 siblings, 0 replies; 12+ messages in thread
From: Zhangfei Gao @ 2011-08-25  6:26 UTC (permalink / raw)
  To: Chris Ball, Ohad Ben-Cohen, Daniel Drake, Arnd Bergmann,
	Nicolas Pitre, linux-mmc
  Cc: Zhangfei Gao

v2->v3, change vmmc to vsdio
In v2, vmmc is reused, however, sd may be impacted if move vmmc to set_ios.
When no card inserted, CD is high, vmmc will be disabled when detect fail, CD will pull low accordingly, controller may treat as card inserted and re-detect.

Zhangfei Gao (2):
  mmc: sdio add regulator vsdio
  ARM: mmp2: support sdio with regulator vsdio

 arch/arm/mach-mmp/brownstone.c |   60 ++++++++++++++++++++++++++++++++++++++-
 drivers/mmc/host/sdhci.c       |   22 ++++++++++++++
 include/linux/mmc/sdhci.h      |    2 +
 3 files changed, 82 insertions(+), 2 deletions(-)


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

* [PATCH v3 0/2] mmc add vsdio to dynamically control sdio power
@ 2011-08-25  6:26 ` Zhangfei Gao
  0 siblings, 0 replies; 12+ messages in thread
From: Zhangfei Gao @ 2011-08-25  6:26 UTC (permalink / raw)
  To: linux-arm-kernel

v2->v3, change vmmc to vsdio
In v2, vmmc is reused, however, sd may be impacted if move vmmc to set_ios.
When no card inserted, CD is high, vmmc will be disabled when detect fail, CD will pull low accordingly, controller may treat as card inserted and re-detect.

Zhangfei Gao (2):
  mmc: sdio add regulator vsdio
  ARM: mmp2: support sdio with regulator vsdio

 arch/arm/mach-mmp/brownstone.c |   60 ++++++++++++++++++++++++++++++++++++++-
 drivers/mmc/host/sdhci.c       |   22 ++++++++++++++
 include/linux/mmc/sdhci.h      |    2 +
 3 files changed, 82 insertions(+), 2 deletions(-)

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

* [PATCH v3 1/2] mmc: sdio add regulator vsdio
  2011-08-25  6:26 ` Zhangfei Gao
@ 2011-08-25  6:26   ` Zhangfei Gao
  -1 siblings, 0 replies; 12+ messages in thread
From: Zhangfei Gao @ 2011-08-25  6:26 UTC (permalink / raw)
  To: Chris Ball, Daniel Drake, Arnd Bergmann, Nicolas Pitre, linux-mmc
  Cc: Zhangfei Gao, Ohad Ben-Cohen

sdio client may be required power on/off dynamically.
With regulator vsdio, sdio client power on/off could be executed by mmc_power_up/down

CC: Ohad Ben-Cohen <ohad@wizery.com>
Signed-off-by: Zhangfei Gao <zhangfei.gao@marvell.com>
---
 drivers/mmc/host/sdhci.c  |   22 ++++++++++++++++++++++
 include/linux/mmc/sdhci.h |    2 ++
 2 files changed, 24 insertions(+), 0 deletions(-)

diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
index 0e02cc1..e0ef7d3 100644
--- a/drivers/mmc/host/sdhci.c
+++ b/drivers/mmc/host/sdhci.c
@@ -1424,6 +1424,18 @@ static void sdhci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
 out:
 	mmiowb();
 	spin_unlock_irqrestore(&host->lock, flags);
+
+	if (host->vsdio) {
+		if (ios->power_mode != host->power_mode_old) {
+			if (ios->power_mode == MMC_POWER_OFF)
+				regulator_disable(host->vsdio);
+
+			if (ios->power_mode == MMC_POWER_UP)
+				regulator_enable(host->vsdio);
+		}
+
+		host->power_mode_old = ios->power_mode;
+	}
 }
 
 static int check_ro(struct sdhci_host *host)
@@ -2748,6 +2760,13 @@ int sdhci_add_host(struct sdhci_host *host)
 		regulator_enable(host->vmmc);
 	}
 
+	host->vsdio = regulator_get(mmc_dev(mmc), "vsdio");
+	if (IS_ERR(host->vsdio))
+		host->vsdio = NULL;
+	else
+		printk(KERN_INFO "%s: vsdio regulator found\n",
+			mmc_hostname(mmc));
+
 	sdhci_init(host, 0);
 
 #ifdef CONFIG_MMC_DEBUG
@@ -2839,6 +2858,9 @@ void sdhci_remove_host(struct sdhci_host *host, int dead)
 		regulator_put(host->vmmc);
 	}
 
+	if (host->vsdio)
+		regulator_put(host->vsdio);
+
 	kfree(host->adma_desc);
 	kfree(host->align_buffer);
 
diff --git a/include/linux/mmc/sdhci.h b/include/linux/mmc/sdhci.h
index 5666f3a..201207a 100644
--- a/include/linux/mmc/sdhci.h
+++ b/include/linux/mmc/sdhci.h
@@ -94,6 +94,8 @@ struct sdhci_host {
 	const struct sdhci_ops *ops;	/* Low level hw interface */
 
 	struct regulator *vmmc;	/* Power regulator */
+	struct regulator *vsdio;	/* sdio Power regulator */
+	unsigned char power_mode_old;	/* power supply mode */
 
 	/* Internal data */
 	struct mmc_host *mmc;	/* MMC structure */
-- 
1.7.0.4


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

* [PATCH v3 1/2] mmc: sdio add regulator vsdio
@ 2011-08-25  6:26   ` Zhangfei Gao
  0 siblings, 0 replies; 12+ messages in thread
From: Zhangfei Gao @ 2011-08-25  6:26 UTC (permalink / raw)
  To: linux-arm-kernel

sdio client may be required power on/off dynamically.
With regulator vsdio, sdio client power on/off could be executed by mmc_power_up/down

CC: Ohad Ben-Cohen <ohad@wizery.com>
Signed-off-by: Zhangfei Gao <zhangfei.gao@marvell.com>
---
 drivers/mmc/host/sdhci.c  |   22 ++++++++++++++++++++++
 include/linux/mmc/sdhci.h |    2 ++
 2 files changed, 24 insertions(+), 0 deletions(-)

diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
index 0e02cc1..e0ef7d3 100644
--- a/drivers/mmc/host/sdhci.c
+++ b/drivers/mmc/host/sdhci.c
@@ -1424,6 +1424,18 @@ static void sdhci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
 out:
 	mmiowb();
 	spin_unlock_irqrestore(&host->lock, flags);
+
+	if (host->vsdio) {
+		if (ios->power_mode != host->power_mode_old) {
+			if (ios->power_mode == MMC_POWER_OFF)
+				regulator_disable(host->vsdio);
+
+			if (ios->power_mode == MMC_POWER_UP)
+				regulator_enable(host->vsdio);
+		}
+
+		host->power_mode_old = ios->power_mode;
+	}
 }
 
 static int check_ro(struct sdhci_host *host)
@@ -2748,6 +2760,13 @@ int sdhci_add_host(struct sdhci_host *host)
 		regulator_enable(host->vmmc);
 	}
 
+	host->vsdio = regulator_get(mmc_dev(mmc), "vsdio");
+	if (IS_ERR(host->vsdio))
+		host->vsdio = NULL;
+	else
+		printk(KERN_INFO "%s: vsdio regulator found\n",
+			mmc_hostname(mmc));
+
 	sdhci_init(host, 0);
 
 #ifdef CONFIG_MMC_DEBUG
@@ -2839,6 +2858,9 @@ void sdhci_remove_host(struct sdhci_host *host, int dead)
 		regulator_put(host->vmmc);
 	}
 
+	if (host->vsdio)
+		regulator_put(host->vsdio);
+
 	kfree(host->adma_desc);
 	kfree(host->align_buffer);
 
diff --git a/include/linux/mmc/sdhci.h b/include/linux/mmc/sdhci.h
index 5666f3a..201207a 100644
--- a/include/linux/mmc/sdhci.h
+++ b/include/linux/mmc/sdhci.h
@@ -94,6 +94,8 @@ struct sdhci_host {
 	const struct sdhci_ops *ops;	/* Low level hw interface */
 
 	struct regulator *vmmc;	/* Power regulator */
+	struct regulator *vsdio;	/* sdio Power regulator */
+	unsigned char power_mode_old;	/* power supply mode */
 
 	/* Internal data */
 	struct mmc_host *mmc;	/* MMC structure */
-- 
1.7.0.4

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

* [PATCH v3 2/2] ARM: mmp2: support sdio with regulator vsdio
  2011-08-25  6:26 ` Zhangfei Gao
@ 2011-08-25  6:26   ` Zhangfei Gao
  -1 siblings, 0 replies; 12+ messages in thread
From: Zhangfei Gao @ 2011-08-25  6:26 UTC (permalink / raw)
  To: Chris Ball, Ohad Ben-Cohen, Daniel Drake, Arnd Bergmann,
	Nicolas Pitre, linux-mmc
  Cc: Zhangfei Gao

Add regulator vsdio, which controled by mmc core to handle sdio chip power

Test With CONFIG_PM_RUNTIME=y
8787 power is enabled if any client module over sdio is insmod, and disbled automatically after all client modules over sdio are rmmod
Also 8787 power could be controled by mmc_start/stop_host

Signed-off-by: Zhangfei Gao <zhangfei.gao@marvell.com>
---
 arch/arm/mach-mmp/brownstone.c |   60 ++++++++++++++++++++++++++++++++++++++-
 1 files changed, 58 insertions(+), 2 deletions(-)

diff --git a/arch/arm/mach-mmp/brownstone.c b/arch/arm/mach-mmp/brownstone.c
index c79162a..752c5bf 100644
--- a/arch/arm/mach-mmp/brownstone.c
+++ b/arch/arm/mach-mmp/brownstone.c
@@ -89,6 +89,9 @@ static unsigned long brownstone_pin_config[] __initdata = {
 	GPIO41_MMC2_CMD | MFP_PULL_HIGH,
 	GPIO42_MMC2_CLK,
 
+	GPIO57_GPIO | MFP_LPM_DRIVE_HIGH,
+	GPIO58_GPIO | MFP_LPM_DRIVE_HIGH,
+
 	/* MMC2 */
 	GPIO165_MMC3_DAT7 | MFP_PULL_HIGH,
 	GPIO162_MMC3_DAT6 | MFP_PULL_HIGH,
@@ -180,12 +183,66 @@ static struct sdhci_pxa_platdata mmp2_sdh_platdata_mmc0 = {
 	.clk_delay_cycles = 0x1f,
 };
 
+static struct sdhci_pxa_platdata mmp2_sdh_platdata_mmc1 = {
+	.flags = PXA_FLAG_CARD_PERMANENT,
+};
+
 static struct sdhci_pxa_platdata mmp2_sdh_platdata_mmc2 = {
 	.clk_delay_cycles = 0x1f,
 	.flags = PXA_FLAG_CARD_PERMANENT
 		| PXA_FLAG_SD_8_BIT_CAPABLE_SLOT,
 };
 
+static struct regulator_consumer_supply sdio_power_supplies[] = {
+	REGULATOR_SUPPLY("vsdio", "sdhci-pxav3.1"),
+};
+
+static struct regulator_init_data sdio_power_data = {
+	.constraints	= {
+		.valid_ops_mask		= REGULATOR_CHANGE_STATUS,
+	},
+	.num_consumer_supplies	= ARRAY_SIZE(sdio_power_supplies),
+	.consumer_supplies	= sdio_power_supplies,
+};
+
+static struct fixed_voltage_config sdio_power = {
+	.supply_name		= "vsdio",
+	.microvolts		= 3000000,
+	.gpio			= mfp_to_gpio(MFP_PIN_GPIO57),
+	.enable_high		= 1,
+	.enabled_at_boot	= 0,
+	.init_data		= &sdio_power_data,
+};
+
+static struct platform_device sdio_power_device = {
+	.name		= "reg-fixed-voltage",
+	.id		= 2,
+	.dev = {
+		.platform_data = &sdio_power,
+	},
+};
+
+static void __init brownstone_init_mmc(void)
+{
+	/*
+	 * PDn: GPIO57; RESETn: GPIO58
+	 * 8787, RESETn keeps high, PDn control power
+	 * on: PDn 1; off: PDn 0;
+	 */
+	int RESETn = mfp_to_gpio(MFP_PIN_GPIO58);
+
+	if (gpio_request(RESETn, "sdio RESETn")) {
+		pr_err("Failed to request sdio RESETn gpio\n");
+		return;
+	}
+	gpio_direction_output(RESETn, 1);
+	gpio_free(RESETn);
+
+	platform_device_register(&sdio_power_device);
+	mmp2_add_sdhost(0, &mmp2_sdh_platdata_mmc0); /* SD/MMC */
+	mmp2_add_sdhost(1, &mmp2_sdh_platdata_mmc1); /* sdio */
+	mmp2_add_sdhost(2, &mmp2_sdh_platdata_mmc2); /* eMMC */
+}
 
 static void __init brownstone_init(void)
 {
@@ -195,8 +252,7 @@ static void __init brownstone_init(void)
 	mmp2_add_uart(1);
 	mmp2_add_uart(3);
 	mmp2_add_twsi(1, NULL, ARRAY_AND_SIZE(brownstone_twsi1_info));
-	mmp2_add_sdhost(0, &mmp2_sdh_platdata_mmc0); /* SD/MMC */
-	mmp2_add_sdhost(2, &mmp2_sdh_platdata_mmc2); /* eMMC */
+	brownstone_init_mmc();
 
 	/* enable 5v regulator */
 	platform_device_register(&brownstone_v_5vp_device);
-- 
1.7.0.4


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

* [PATCH v3 2/2] ARM: mmp2: support sdio with regulator vsdio
@ 2011-08-25  6:26   ` Zhangfei Gao
  0 siblings, 0 replies; 12+ messages in thread
From: Zhangfei Gao @ 2011-08-25  6:26 UTC (permalink / raw)
  To: linux-arm-kernel

Add regulator vsdio, which controled by mmc core to handle sdio chip power

Test With CONFIG_PM_RUNTIME=y
8787 power is enabled if any client module over sdio is insmod, and disbled automatically after all client modules over sdio are rmmod
Also 8787 power could be controled by mmc_start/stop_host

Signed-off-by: Zhangfei Gao <zhangfei.gao@marvell.com>
---
 arch/arm/mach-mmp/brownstone.c |   60 ++++++++++++++++++++++++++++++++++++++-
 1 files changed, 58 insertions(+), 2 deletions(-)

diff --git a/arch/arm/mach-mmp/brownstone.c b/arch/arm/mach-mmp/brownstone.c
index c79162a..752c5bf 100644
--- a/arch/arm/mach-mmp/brownstone.c
+++ b/arch/arm/mach-mmp/brownstone.c
@@ -89,6 +89,9 @@ static unsigned long brownstone_pin_config[] __initdata = {
 	GPIO41_MMC2_CMD | MFP_PULL_HIGH,
 	GPIO42_MMC2_CLK,
 
+	GPIO57_GPIO | MFP_LPM_DRIVE_HIGH,
+	GPIO58_GPIO | MFP_LPM_DRIVE_HIGH,
+
 	/* MMC2 */
 	GPIO165_MMC3_DAT7 | MFP_PULL_HIGH,
 	GPIO162_MMC3_DAT6 | MFP_PULL_HIGH,
@@ -180,12 +183,66 @@ static struct sdhci_pxa_platdata mmp2_sdh_platdata_mmc0 = {
 	.clk_delay_cycles = 0x1f,
 };
 
+static struct sdhci_pxa_platdata mmp2_sdh_platdata_mmc1 = {
+	.flags = PXA_FLAG_CARD_PERMANENT,
+};
+
 static struct sdhci_pxa_platdata mmp2_sdh_platdata_mmc2 = {
 	.clk_delay_cycles = 0x1f,
 	.flags = PXA_FLAG_CARD_PERMANENT
 		| PXA_FLAG_SD_8_BIT_CAPABLE_SLOT,
 };
 
+static struct regulator_consumer_supply sdio_power_supplies[] = {
+	REGULATOR_SUPPLY("vsdio", "sdhci-pxav3.1"),
+};
+
+static struct regulator_init_data sdio_power_data = {
+	.constraints	= {
+		.valid_ops_mask		= REGULATOR_CHANGE_STATUS,
+	},
+	.num_consumer_supplies	= ARRAY_SIZE(sdio_power_supplies),
+	.consumer_supplies	= sdio_power_supplies,
+};
+
+static struct fixed_voltage_config sdio_power = {
+	.supply_name		= "vsdio",
+	.microvolts		= 3000000,
+	.gpio			= mfp_to_gpio(MFP_PIN_GPIO57),
+	.enable_high		= 1,
+	.enabled_at_boot	= 0,
+	.init_data		= &sdio_power_data,
+};
+
+static struct platform_device sdio_power_device = {
+	.name		= "reg-fixed-voltage",
+	.id		= 2,
+	.dev = {
+		.platform_data = &sdio_power,
+	},
+};
+
+static void __init brownstone_init_mmc(void)
+{
+	/*
+	 * PDn: GPIO57; RESETn: GPIO58
+	 * 8787, RESETn keeps high, PDn control power
+	 * on: PDn 1; off: PDn 0;
+	 */
+	int RESETn = mfp_to_gpio(MFP_PIN_GPIO58);
+
+	if (gpio_request(RESETn, "sdio RESETn")) {
+		pr_err("Failed to request sdio RESETn gpio\n");
+		return;
+	}
+	gpio_direction_output(RESETn, 1);
+	gpio_free(RESETn);
+
+	platform_device_register(&sdio_power_device);
+	mmp2_add_sdhost(0, &mmp2_sdh_platdata_mmc0); /* SD/MMC */
+	mmp2_add_sdhost(1, &mmp2_sdh_platdata_mmc1); /* sdio */
+	mmp2_add_sdhost(2, &mmp2_sdh_platdata_mmc2); /* eMMC */
+}
 
 static void __init brownstone_init(void)
 {
@@ -195,8 +252,7 @@ static void __init brownstone_init(void)
 	mmp2_add_uart(1);
 	mmp2_add_uart(3);
 	mmp2_add_twsi(1, NULL, ARRAY_AND_SIZE(brownstone_twsi1_info));
-	mmp2_add_sdhost(0, &mmp2_sdh_platdata_mmc0); /* SD/MMC */
-	mmp2_add_sdhost(2, &mmp2_sdh_platdata_mmc2); /* eMMC */
+	brownstone_init_mmc();
 
 	/* enable 5v regulator */
 	platform_device_register(&brownstone_v_5vp_device);
-- 
1.7.0.4

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

* Re: [PATCH v3 1/2] mmc: sdio add regulator vsdio
  2011-08-25  6:26   ` Zhangfei Gao
@ 2011-08-31 14:06     ` Eric Miao
  -1 siblings, 0 replies; 12+ messages in thread
From: Eric Miao @ 2011-08-31 14:06 UTC (permalink / raw)
  To: Zhangfei Gao
  Cc: Chris Ball, Ohad Ben-Cohen, Daniel Drake, Arnd Bergmann,
	Nicolas Pitre, linux-mmc, linux-arm-kernel, Bing Zhao

Zhangfei,

My understanding is that the card in the slot would be either MMC _or_
SDIO and why do we need another regulator for the power on/off?

On Thu, Aug 25, 2011 at 2:26 PM, Zhangfei Gao <zhangfei.gao@marvell.com> wrote:
> sdio client may be required power on/off dynamically.
> With regulator vsdio, sdio client power on/off could be executed by mmc_power_up/down
>
> CC: Ohad Ben-Cohen <ohad@wizery.com>
> Signed-off-by: Zhangfei Gao <zhangfei.gao@marvell.com>
> ---
>  drivers/mmc/host/sdhci.c  |   22 , >  include/linux/mmc/sdhci.h |    2 ++
>  2 files changed, 24 insertions(+), 0 deletions(-)
>
> diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
> index 0e02cc1..e0ef7d3 100644
> --- a/drivers/mmc/host/sdhci.c
> +++ b/drivers/mmc/host/sdhci.c
> @@ -1424,6 +1424,18 @@ static void sdhci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
>  out:
>        mmiowb();
>        spin_unlock_irqrestore(&host->lock, flags);
> +
> +       if (host->vsdio) {
> +               if (ios->power_mode != host->power_mode_old) {
> +                       if (ios->power_mode == MMC_POWER_OFF)
> +                               regulator_disable(host->vsdio);
> +
> +                       if (ios->power_mode == MMC_POWER_UP)
> +                               regulator_enable(host->vsdio);
> +               }
> +
> +               host->power_mode_old = ios->power_mode;
> +       }
>  }
>
>  static int check_ro(struct sdhci_host *host)
> @@ -2748,6 +2760,13 @@ int sdhci_add_host(struct sdhci_host *host)
>                regulator_enable(host->vmmc);
>        }
>
> +       host->vsdio = regulator_get(mmc_dev(mmc), "vsdio");
> +       if (IS_ERR(host->vsdio))
> +               host->vsdio = NULL;
> +       else
> +               printk(KERN_INFO "%s: vsdio regulator found\n",
> +                       mmc_hostname(mmc));
> +
>        sdhci_init(host, 0);
>
>  #ifdef CONFIG_MMC_DEBUG
> @@ -2839,6 +2858,9 @@ void sdhci_remove_host(struct sdhci_host *host, int dead)
>                regulator_put(host->vmmc);
>        }
>
> +       if (host->vsdio)
> +               regulator_put(host->vsdio);
> +
>        kfree(host->adma_desc);
>        kfree(host->align_buffer);
>
> diff --git a/include/linux/mmc/sdhci.h b/include/linux/mmc/sdhci.h
> index 5666f3a..201207a 100644
> --- a/include/linux/mmc/sdhci.h
> +++ b/include/linux/mmc/sdhci.h
> @@ -94,6 +94,8 @@ struct sdhci_host {
>        const struct sdhci_ops *ops;    /* Low level hw interface */
>
>        struct regulator *vmmc; /* Power regulator */
> +       struct regulator *vsdio;        /* sdio Power regulator */
> +       unsigned char power_mode_old;   /* power supply mode */
>
>        /* Internal data */
>        struct mmc_host *mmc;   /* MMC structure */
> --
> 1.7.0.4
>
>

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

* [PATCH v3 1/2] mmc: sdio add regulator vsdio
@ 2011-08-31 14:06     ` Eric Miao
  0 siblings, 0 replies; 12+ messages in thread
From: Eric Miao @ 2011-08-31 14:06 UTC (permalink / raw)
  To: linux-arm-kernel

Zhangfei,

My understanding is that the card in the slot would be either MMC _or_
SDIO and why do we need another regulator for the power on/off?

On Thu, Aug 25, 2011 at 2:26 PM, Zhangfei Gao <zhangfei.gao@marvell.com> wrote:
> sdio client may be required power on/off dynamically.
> With regulator vsdio, sdio client power on/off could be executed by mmc_power_up/down
>
> CC: Ohad Ben-Cohen <ohad@wizery.com>
> Signed-off-by: Zhangfei Gao <zhangfei.gao@marvell.com>
> ---
> ?drivers/mmc/host/sdhci.c ?| ? 22 , > ?include/linux/mmc/sdhci.h | ? ?2 ++
> ?2 files changed, 24 insertions(+), 0 deletions(-)
>
> diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
> index 0e02cc1..e0ef7d3 100644
> --- a/drivers/mmc/host/sdhci.c
> +++ b/drivers/mmc/host/sdhci.c
> @@ -1424,6 +1424,18 @@ static void sdhci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
> ?out:
> ? ? ? ?mmiowb();
> ? ? ? ?spin_unlock_irqrestore(&host->lock, flags);
> +
> + ? ? ? if (host->vsdio) {
> + ? ? ? ? ? ? ? if (ios->power_mode != host->power_mode_old) {
> + ? ? ? ? ? ? ? ? ? ? ? if (ios->power_mode == MMC_POWER_OFF)
> + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? regulator_disable(host->vsdio);
> +
> + ? ? ? ? ? ? ? ? ? ? ? if (ios->power_mode == MMC_POWER_UP)
> + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? regulator_enable(host->vsdio);
> + ? ? ? ? ? ? ? }
> +
> + ? ? ? ? ? ? ? host->power_mode_old = ios->power_mode;
> + ? ? ? }
> ?}
>
> ?static int check_ro(struct sdhci_host *host)
> @@ -2748,6 +2760,13 @@ int sdhci_add_host(struct sdhci_host *host)
> ? ? ? ? ? ? ? ?regulator_enable(host->vmmc);
> ? ? ? ?}
>
> + ? ? ? host->vsdio = regulator_get(mmc_dev(mmc), "vsdio");
> + ? ? ? if (IS_ERR(host->vsdio))
> + ? ? ? ? ? ? ? host->vsdio = NULL;
> + ? ? ? else
> + ? ? ? ? ? ? ? printk(KERN_INFO "%s: vsdio regulator found\n",
> + ? ? ? ? ? ? ? ? ? ? ? mmc_hostname(mmc));
> +
> ? ? ? ?sdhci_init(host, 0);
>
> ?#ifdef CONFIG_MMC_DEBUG
> @@ -2839,6 +2858,9 @@ void sdhci_remove_host(struct sdhci_host *host, int dead)
> ? ? ? ? ? ? ? ?regulator_put(host->vmmc);
> ? ? ? ?}
>
> + ? ? ? if (host->vsdio)
> + ? ? ? ? ? ? ? regulator_put(host->vsdio);
> +
> ? ? ? ?kfree(host->adma_desc);
> ? ? ? ?kfree(host->align_buffer);
>
> diff --git a/include/linux/mmc/sdhci.h b/include/linux/mmc/sdhci.h
> index 5666f3a..201207a 100644
> --- a/include/linux/mmc/sdhci.h
> +++ b/include/linux/mmc/sdhci.h
> @@ -94,6 +94,8 @@ struct sdhci_host {
> ? ? ? ?const struct sdhci_ops *ops; ? ?/* Low level hw interface */
>
> ? ? ? ?struct regulator *vmmc; /* Power regulator */
> + ? ? ? struct regulator *vsdio; ? ? ? ?/* sdio Power regulator */
> + ? ? ? unsigned char power_mode_old; ? /* power supply mode */
>
> ? ? ? ?/* Internal data */
> ? ? ? ?struct mmc_host *mmc; ? /* MMC structure */
> --
> 1.7.0.4
>
>

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

* Re: [PATCH v3 1/2] mmc: sdio add regulator vsdio
  2011-08-31 14:06     ` Eric Miao
@ 2011-09-01  1:37       ` zhangfei gao
  -1 siblings, 0 replies; 12+ messages in thread
From: zhangfei gao @ 2011-09-01  1:37 UTC (permalink / raw)
  To: Eric Miao
  Cc: Zhangfei Gao, Chris Ball, Ohad Ben-Cohen, Daniel Drake,
	Arnd Bergmann, Nicolas Pitre, linux-mmc, linux-arm-kernel,
	Bing Zhao

On Wed, Aug 31, 2011 at 10:06 PM, Eric Miao <eric.y.miao@gmail.com> wrote:
> Zhangfei,
>
> My understanding is that the card in the slot would be either MMC _or_
> SDIO and why do we need another regulator for the power on/off?
>
Hi, Eric

vsdio is used for dynamically power control to sdio, for example
application dynamically disable/enable wifi.
Then mmc_start/stop_host and mmc_power_up/down could directly power
on/off sdio via mmc_set_ios.
This also workable with runtime PM, which already introduced into mmc by Ohad.

vmmc is used to statically provided power to sd or vmmc.

Daniel once suggested reusing vmmc, however we found CD pin requires
vmmc to be alwayes on.
If vmmc is dynamically power off, CD pin will be low, which indicating
card is inserted by mistake.
For example when no card inserted, CD pin will high -> host fail to
detect sd card -> vmmc disabled in set_ios -> host thought card
inserted -> irq happen -> host redetect card ->

If there is concern of vsdio in sdhci.c, how about moving vsdio to
specific driver via call back.

Thanks

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

* [PATCH v3 1/2] mmc: sdio add regulator vsdio
@ 2011-09-01  1:37       ` zhangfei gao
  0 siblings, 0 replies; 12+ messages in thread
From: zhangfei gao @ 2011-09-01  1:37 UTC (permalink / raw)
  To: linux-arm-kernel

On Wed, Aug 31, 2011 at 10:06 PM, Eric Miao <eric.y.miao@gmail.com> wrote:
> Zhangfei,
>
> My understanding is that the card in the slot would be either MMC _or_
> SDIO and why do we need another regulator for the power on/off?
>
Hi, Eric

vsdio is used for dynamically power control to sdio, for example
application dynamically disable/enable wifi.
Then mmc_start/stop_host and mmc_power_up/down could directly power
on/off sdio via mmc_set_ios.
This also workable with runtime PM, which already introduced into mmc by Ohad.

vmmc is used to statically provided power to sd or vmmc.

Daniel once suggested reusing vmmc, however we found CD pin requires
vmmc to be alwayes on.
If vmmc is dynamically power off, CD pin will be low, which indicating
card is inserted by mistake.
For example when no card inserted, CD pin will high -> host fail to
detect sd card -> vmmc disabled in set_ios -> host thought card
inserted -> irq happen -> host redetect card ->

If there is concern of vsdio in sdhci.c, how about moving vsdio to
specific driver via call back.

Thanks

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

* Re: [PATCH v3 1/2] mmc: sdio add regulator vsdio
  2011-09-01  1:37       ` zhangfei gao
@ 2011-09-16 15:38         ` Daniel Drake
  -1 siblings, 0 replies; 12+ messages in thread
From: Daniel Drake @ 2011-09-16 15:38 UTC (permalink / raw)
  To: zhangfei gao
  Cc: Eric Miao, Zhangfei Gao, Chris Ball, Ohad Ben-Cohen,
	Arnd Bergmann, Nicolas Pitre, linux-mmc, linux-arm-kernel,
	Bing Zhao

On Thu, Sep 1, 2011 at 2:37 AM, zhangfei gao <zhangfei.gao@gmail.com> wrote:
> Daniel once suggested reusing vmmc, however we found CD pin requires
> vmmc to be alwayes on.
> If vmmc is dynamically power off, CD pin will be low, which indicating
> card is inserted by mistake.
> For example when no card inserted, CD pin will high -> host fail to
> detect sd card -> vmmc disabled in set_ios -> host thought card
> inserted -> irq happen -> host redetect card ->

Sorry that I haven't been able to follow up on why that doesn't work,
and what the real fix would be (if it's not this one). Every time I
see people discussing terms like CD, RESETn and PDn, I simply get lost
(and such discussion seems to originate only from Marvell).

Are these generic SD/MMC terms that I simply don't understand, or are
we talking Marvell specific terminology that I'm not alone in lacking
understanding of?

Thanks,
Daniel

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

* [PATCH v3 1/2] mmc: sdio add regulator vsdio
@ 2011-09-16 15:38         ` Daniel Drake
  0 siblings, 0 replies; 12+ messages in thread
From: Daniel Drake @ 2011-09-16 15:38 UTC (permalink / raw)
  To: linux-arm-kernel

On Thu, Sep 1, 2011 at 2:37 AM, zhangfei gao <zhangfei.gao@gmail.com> wrote:
> Daniel once suggested reusing vmmc, however we found CD pin requires
> vmmc to be alwayes on.
> If vmmc is dynamically power off, CD pin will be low, which indicating
> card is inserted by mistake.
> For example when no card inserted, CD pin will high -> host fail to
> detect sd card -> vmmc disabled in set_ios -> host thought card
> inserted -> irq happen -> host redetect card ->

Sorry that I haven't been able to follow up on why that doesn't work,
and what the real fix would be (if it's not this one). Every time I
see people discussing terms like CD, RESETn and PDn, I simply get lost
(and such discussion seems to originate only from Marvell).

Are these generic SD/MMC terms that I simply don't understand, or are
we talking Marvell specific terminology that I'm not alone in lacking
understanding of?

Thanks,
Daniel

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

end of thread, other threads:[~2011-09-16 15:38 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-08-25  6:26 [PATCH v3 0/2] mmc add vsdio to dynamically control sdio power Zhangfei Gao
2011-08-25  6:26 ` Zhangfei Gao
2011-08-25  6:26 ` [PATCH v3 1/2] mmc: sdio add regulator vsdio Zhangfei Gao
2011-08-25  6:26   ` Zhangfei Gao
2011-08-31 14:06   ` Eric Miao
2011-08-31 14:06     ` Eric Miao
2011-09-01  1:37     ` zhangfei gao
2011-09-01  1:37       ` zhangfei gao
2011-09-16 15:38       ` Daniel Drake
2011-09-16 15:38         ` Daniel Drake
2011-08-25  6:26 ` [PATCH v3 2/2] ARM: mmp2: support sdio with " Zhangfei Gao
2011-08-25  6:26   ` Zhangfei Gao

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.