From patchwork Thu Jul 21 02:34:33 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhangfei Gao X-Patchwork-Id: 993622 Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by demeter2.kernel.org (8.14.4/8.14.4) with ESMTP id p6L2aObm014314 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Thu, 21 Jul 2011 02:36:45 GMT Received: from canuck.infradead.org ([2001:4978:20e::1]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1Qjj7N-0005MM-56; Thu, 21 Jul 2011 02:36:07 +0000 Received: from localhost ([127.0.0.1] helo=canuck.infradead.org) by canuck.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1Qjj71-0004hr-RQ; Thu, 21 Jul 2011 02:35:43 +0000 Received: from dakia2.marvell.com ([65.219.4.35]) by canuck.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1Qjj6L-0004Xw-55 for linux-arm-kernel@lists.infradead.org; Thu, 21 Jul 2011 02:35:02 +0000 X-ASG-Debug-ID: 1311215700-082de0700001-tbGyMd Received: from maili.marvell.com (maili.marvell.com [10.68.76.51]) by dakia2.marvell.com with ESMTP id 0mBKEBs0PdyuYl10; Wed, 20 Jul 2011 19:35:00 -0700 (PDT) X-Barracuda-Envelope-From: zhangfei.gao@marvell.com Received: from localhost (unknown [10.38.164.217]) by maili.marvell.com (Postfix) with ESMTP id C30778A002; Wed, 20 Jul 2011 19:34:59 -0700 (PDT) From: Zhangfei Gao To: Chris Ball , Ohad Ben-Cohen , Daniel Drake , Arnd Bergmann , Nicolas Pitre , "linux-mmc@vger.kernel.org" , Eric Miao , linux-arm-kernel , Bing Zhao , Frank@marvell.com, Huang@marvell.com, frankh@marvell.com X-ASG-Orig-Subj: [PATCH] ARM: mmp2: support sdio with regulator vsdio Subject: [PATCH] ARM: mmp2: support sdio with regulator vsdio Date: Thu, 21 Jul 2011 10:34:33 +0800 X-ASG-Orig-Subj: [PATCH] ARM: mmp2: support sdio with regulator vsdio Message-Id: <1311215673-2489-3-git-send-email-zhangfei.gao@marvell.com> X-Mailer: git-send-email 1.7.0.4 In-Reply-To: <1311215673-2489-1-git-send-email-zhangfei.gao@marvell.com> References: <1311215673-2489-1-git-send-email-zhangfei.gao@marvell.com> X-Barracuda-Connect: maili.marvell.com[10.68.76.51] X-Barracuda-Start-Time: 1311215700 X-Barracuda-URL: http://10.68.76.222:80/cgi-mod/mark.cgi X-Barracuda-Spam-Score: -1002.00 X-Barracuda-Spam-Status: No, SCORE=-1002.00 using global scores of TAG_LEVEL=1000.0 QUARANTINE_LEVEL=1000.0 KILL_LEVEL=1000.0 X-CRM114-Version: 20090807-BlameThorstenAndJenny ( TRE 0.7.6 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20110720_223501_404745_D4D60C9E X-CRM114-Status: GOOD ( 16.07 ) X-Spam-Score: -1.2 (-) X-Spam-Report: SpamAssassin version 3.3.1 on canuck.infradead.org summary: Content analysis details: (-1.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -1.2 RP_MATCHES_RCVD Envelope sender domain matches handover relay domain Cc: Zhangfei Gao X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: linux-arm-kernel-bounces@lists.infradead.org Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter2.kernel.org [140.211.167.43]); Thu, 21 Jul 2011 02:36:45 +0000 (UTC) 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 --- 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);