From patchwork Fri Feb 25 02:08:14 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jaehoon Chung X-Patchwork-Id: 588861 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id p1P28gdl016057 for ; Fri, 25 Feb 2011 02:08:59 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756451Ab1BYCI7 (ORCPT ); Thu, 24 Feb 2011 21:08:59 -0500 Received: from mailout2.samsung.com ([203.254.224.25]:37823 "EHLO mailout2.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756347Ab1BYCI7 (ORCPT ); Thu, 24 Feb 2011 21:08:59 -0500 Received: from epmmp2 (mailout2.samsung.com [203.254.224.25]) by mailout2.samsung.com (Oracle Communications Messaging Exchange Server 7u4-19.01 64bit (built Sep 7 2010)) with ESMTP id <0LH500EP2HXQ3RA0@mailout2.samsung.com> for linux-mmc@vger.kernel.org; Fri, 25 Feb 2011 11:08:14 +0900 (KST) Received: from TNRNDGASPAPP1.tn.corp.samsungelectronics.net ([165.213.149.150]) by mmp2.samsung.com (iPlanet Messaging Server 5.2 Patch 2 (built Jul 14 2004)) with ESMTPA id <0LH500IAFHXRO0@mmp2.samsung.com> for linux-mmc@vger.kernel.org; Fri, 25 Feb 2011 11:08:15 +0900 (KST) Received: from [165.213.219.108] ([165.213.219.108]) by TNRNDGASPAPP1.tn.corp.samsungelectronics.net with Microsoft SMTPSVC(6.0.3790.4675); Fri, 25 Feb 2011 11:08:14 +0900 Date: Fri, 25 Feb 2011 11:08:14 +0900 From: Jaehoon Chung Subject: [PATCH 2/3] dw_mmc: support mmc power control with regulator To: "linux-mmc@vger.kernel.org" Cc: will.newton@imgtec.com, Chris Ball , Kyungmin Park Message-id: <4D670F0E.7000800@samsung.com> MIME-version: 1.0 Content-type: text/plain; charset=ISO-8859-1 Content-transfer-encoding: 7BIT User-Agent: Thunderbird 2.0.0.24 (X11/20100317) X-OriginalArrivalTime: 25 Feb 2011 02:08:14.0767 (UTC) FILETIME=[DC5D43F0:01CBD490] Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Fri, 25 Feb 2011 02:09:00 +0000 (UTC) diff --git a/drivers/mmc/host/dw_mmc.c b/drivers/mmc/host/dw_mmc.c index 46e5a89..338fedc 100644 --- a/drivers/mmc/host/dw_mmc.c +++ b/drivers/mmc/host/dw_mmc.c @@ -32,6 +32,7 @@ #include #include #include +#include #include "dw_mmc.h" @@ -1438,6 +1439,13 @@ static int __init dw_mci_init_slot(struct dw_mci *host, unsigned int id) } #endif /* CONFIG_MMC_DW_IDMAC */ + host->vmmc = regulator_get(mmc_dev(mmc), "vmmc"); + if (IS_ERR(host->vmmc)) { + printk(KERN_INFO "%s: no vmmc regulator found\n", mmc_hostname(mmc)); + host->vmmc = NULL; + } else + regulator_enable(host->vmmc); + if (dw_mci_get_cd(mmc)) set_bit(DW_MMC_CARD_PRESENT, &slot->flags); else @@ -1701,6 +1709,12 @@ err_dmaunmap: host->sg_cpu, host->sg_dma); iounmap(host->regs); + if (host->vmmc) { + regulator_disable(host->vmmc); + regulator_put(host->vmmc); + } + + err_freehost: kfree(host); return ret; @@ -1732,6 +1746,11 @@ static int __exit dw_mci_remove(struct platform_device *pdev) if (host->use_dma && host->dma_ops->exit) host->dma_ops->exit(host); + if (host->vmmc) { + regulator_disable(host->vmmc); + regulator_put(host->vmmc); + } + iounmap(host->regs); kfree(host); @@ -1762,6 +1781,9 @@ static int dw_mci_suspend(struct platform_device *pdev, pm_message_t mesg) } } + if (host->vmmc) + regulator_disable(host->vmmc); + return 0; } @@ -1770,6 +1792,9 @@ static int dw_mci_resume(struct platform_device *pdev) int i, ret; struct dw_mci *host = platform_get_drvdata(pdev); + if (host->vmmc) + regulator_enable(host->vmmc); + for (i = 0; i < host->num_slots; i++) { struct dw_mci_slot *slot = host->slot[i]; if (!slot) diff --git a/include/linux/mmc/dw_mmc.h b/include/linux/mmc/dw_mmc.h index 3f22c20..a39c497 100644 --- a/include/linux/mmc/dw_mmc.h +++ b/include/linux/mmc/dw_mmc.h @@ -151,6 +151,8 @@ struct dw_mci { /* Workaround flags */ u32 quirks; + + struct regulator *vmmc; /* Power regulator */ }; /* DMA ops for Internal/External DMAC interface */