linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: zhangfei.gao@marvell.com (Zhangfei Gao)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH] ARM: mmp2: support sdio with regulator vsdio
Date: Thu, 21 Jul 2011 10:34:33 +0800	[thread overview]
Message-ID: <1311215673-2489-3-git-send-email-zhangfei.gao@marvell.com> (raw)
In-Reply-To: <1311215673-2489-1-git-send-email-zhangfei.gao@marvell.com>

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..63315e2 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 | MFP_PULL_HIGH,
+	GPIO58_GPIO | MFP_LPM_DRIVE_HIGH | MFP_PULL_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 int __init brownstone_init_mmc(void)
+{
+	/*
+	 * PDn: GPIO58; RESETn: GPIO57
+	 * 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 -EIO;
+	}
+	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.6.0.4

      parent reply	other threads:[~2011-07-21  2:34 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-07-21  2:34 [PATCH] sdio add regulator vsdio to dynamic control sdio power Zhangfei Gao
2011-07-21  2:34 ` [PATCH] mmc: sdio add regulator vsdio Zhangfei Gao
2011-07-22  6:50   ` Daniel Drake
2011-07-22  7:25     ` zhangfei gao
2011-07-22 16:05     ` Philip Rakity
2011-07-21  2:34 ` Zhangfei Gao [this message]

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=1311215673-2489-3-git-send-email-zhangfei.gao@marvell.com \
    --to=zhangfei.gao@marvell.com \
    --cc=linux-arm-kernel@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;
as well as URLs for NNTP newsgroup(s).