From patchwork Tue Jun 17 10:07:11 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robin van der Gracht X-Patchwork-Id: 4365751 Return-Path: X-Original-To: patchwork-linux-mmc@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 329CABEEAA for ; Tue, 17 Jun 2014 10:26:17 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id E131E2010C for ; Tue, 17 Jun 2014 10:26:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 9EAE820109 for ; Tue, 17 Jun 2014 10:26:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755092AbaFQK0H (ORCPT ); Tue, 17 Jun 2014 06:26:07 -0400 Received: from protonic.xs4all.nl ([83.163.252.89]:17437 "EHLO protonic.xs4all.nl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753889AbaFQK0G (ORCPT ); Tue, 17 Jun 2014 06:26:06 -0400 X-Greylist: delayed 1073 seconds by postgrey-1.27 at vger.kernel.org; Tue, 17 Jun 2014 06:26:06 EDT Received: from erd943.prtnl (erd943.prtnl [192.168.1.166]) by protonic.xs4all.nl (Postfix) with ESMTP id 4782E2803E; Tue, 17 Jun 2014 12:02:54 +0200 (CEST) From: Robin van der Gracht To: linux-mmc@vger.kernel.org Cc: chris@printf.net, ulf.hansson@linaro.org, Robin van der Gracht Subject: [PATCH] mmc: mxs-mmc: Introducing regulator support. Date: Tue, 17 Jun 2014 12:07:11 +0200 Message-Id: <1402999631-4256-1-git-send-email-robin@protonic.nl> X-Mailer: git-send-email 1.9.1 Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org X-Spam-Status: No, score=-7.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Robin van der Gracht --- drivers/mmc/host/mxs-mmc.c | 37 +++++++++++++++++++++++++++++-------- 1 file changed, 29 insertions(+), 8 deletions(-) diff --git a/drivers/mmc/host/mxs-mmc.c b/drivers/mmc/host/mxs-mmc.c index 073e871..efe8ae1 100644 --- a/drivers/mmc/host/mxs-mmc.c +++ b/drivers/mmc/host/mxs-mmc.c @@ -66,10 +66,12 @@ struct mxs_mmc_host { struct mmc_request *mrq; struct mmc_command *cmd; struct mmc_data *data; + struct regulator *vmmc; unsigned char bus_width; spinlock_t lock; int sdio_irq_en; + unsigned char power_mode; }; static int mxs_mmc_get_cd(struct mmc_host *mmc) @@ -502,6 +504,30 @@ static void mxs_mmc_set_ios(struct mmc_host *mmc, struct mmc_ios *ios) else host->bus_width = 0; + if (ios->power_mode != host->power_mode) { + switch (ios->power_mode) { + case MMC_POWER_OFF: + if (host->vmmc) { + if (regulator_disable(host->vmmc)) { + dev_err(mmc_dev(host->mmc), + "Failed to disable vmmc regulator\n"); + } + } + break; + case MMC_POWER_UP: + if (host->vmmc) { + if (regulator_enable(host->vmmc)) { + dev_err(mmc_dev(host->mmc), + "Failed to enable vmmc regulator\n"); + } + } + break; + default: + break; + } + host->power_mode = ios->power_mode; + } + if (ios->clock) mxs_ssp_set_clk_rate(&host->ssp, ios->clock); } @@ -597,16 +623,11 @@ static int mxs_mmc_probe(struct platform_device *pdev) host->mmc = mmc; host->sdio_irq_en = 0; + host->power_mode = MMC_POWER_OFF; reg_vmmc = devm_regulator_get(&pdev->dev, "vmmc"); - if (!IS_ERR(reg_vmmc)) { - ret = regulator_enable(reg_vmmc); - if (ret) { - dev_err(&pdev->dev, - "Failed to enable vmmc regulator: %d\n", ret); - goto out_mmc_free; - } - } + if (!IS_ERR(reg_vmmc)) + host->vmmc = reg_vmmc; ssp->clk = devm_clk_get(&pdev->dev, NULL); if (IS_ERR(ssp->clk)) {