From patchwork Tue Oct 22 14:07:25 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 21215 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ye0-f200.google.com (mail-ye0-f200.google.com [209.85.213.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id AFBE8244B2 for ; Tue, 22 Oct 2013 14:07:54 +0000 (UTC) Received: by mail-ye0-f200.google.com with SMTP id r9sf14722467yen.3 for ; Tue, 22 Oct 2013 07:07:54 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=mime-version:x-gm-message-state:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-unsubscribe; bh=Gs3S0Wz+CHF18ExBnsmoYG7ycHYdMi3r+OFwuAVG1Bk=; b=cM+V+GAlSgj9XuP0uMV3Jjc4W0Mk69qtEtRUagfjvuPss8DtVJ36gJWFp3eaYsM8ye 1C9wAhxi/9oyOzNf0hnF8LUwAYpafCmitcwYrY7WHivo7lobWsFP7B7bSj/AFWVcDoXS InUo/XWj+YIsR7PWWSlM6tMoMUaYm46VfI9VkGX6iW4+FuR8DrCJ4113WiZnRj8XjYsJ 35t6Ad1ao1MWe2oV9TbZnCDy389xf+iyqy5xOktZzCUTcDvgMQ5pFbi2tQtspQI/NHHa U8NyuITA1vpezxobROODT+82J+/WvOeLZxjWQovonTLYGvaz8EbIjosH5PKAl8IIOyxV LpNQ== X-Received: by 10.236.189.37 with SMTP id b25mr12261672yhn.48.1382450874362; Tue, 22 Oct 2013 07:07:54 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.4.228 with SMTP id n4ls104786qen.71.gmail; Tue, 22 Oct 2013 07:07:54 -0700 (PDT) X-Received: by 10.52.120.78 with SMTP id la14mr13090415vdb.9.1382450874256; Tue, 22 Oct 2013 07:07:54 -0700 (PDT) Received: from mail-vc0-f170.google.com (mail-vc0-f170.google.com [209.85.220.170]) by mx.google.com with ESMTPS id k17si5822911vck.27.2013.10.22.07.07.54 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 22 Oct 2013 07:07:54 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.220.170 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.220.170; Received: by mail-vc0-f170.google.com with SMTP id hv10so659147vcb.15 for ; Tue, 22 Oct 2013 07:07:54 -0700 (PDT) X-Gm-Message-State: ALoCoQnK6cRXEr8SffnWgdzcNXmhdYnqgXPcFwf2QaSsZwDw7bW/3S1JuiNc/M30p2Rrw3hqg9o2 X-Received: by 10.221.47.193 with SMTP id ut1mr15208699vcb.8.1382450874165; Tue, 22 Oct 2013 07:07:54 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.220.174.196 with SMTP id u4csp233668vcz; Tue, 22 Oct 2013 07:07:53 -0700 (PDT) X-Received: by 10.152.26.72 with SMTP id j8mr18213057lag.19.1382450872950; Tue, 22 Oct 2013 07:07:52 -0700 (PDT) Received: from mail-lb0-f172.google.com (mail-lb0-f172.google.com [209.85.217.172]) by mx.google.com with ESMTPS id ze5si9502075lbb.148.2013.10.22.07.07.52 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 22 Oct 2013 07:07:52 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.217.172 is neither permitted nor denied by best guess record for domain of ulf.hansson@linaro.org) client-ip=209.85.217.172; Received: by mail-lb0-f172.google.com with SMTP id c11so5877280lbj.17 for ; Tue, 22 Oct 2013 07:07:52 -0700 (PDT) X-Received: by 10.152.27.67 with SMTP id r3mr1506378lag.50.1382450872357; Tue, 22 Oct 2013 07:07:52 -0700 (PDT) Received: from linaro-ulf.lan (90-231-160-185-no158.tbcn.telia.com. [90.231.160.185]) by mx.google.com with ESMTPSA id ur6sm15932916lbc.5.2013.10.22.07.07.50 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 22 Oct 2013 07:07:51 -0700 (PDT) From: Ulf Hansson To: linux-mmc@vger.kernel.org, Chris Ball Cc: Ulf Hansson , Guennadi Liakhovetski Subject: [PATCH v2 6/7] mmc: sh_mmcif: Simplify clock and power setup in set_ios Date: Tue, 22 Oct 2013 16:07:25 +0200 Message-Id: <1382450846-17144-7-git-send-email-ulf.hansson@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1382450846-17144-1-git-send-email-ulf.hansson@linaro.org> References: <1382450846-17144-1-git-send-email-ulf.hansson@linaro.org> X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: ulf.hansson@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.220.170 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , This patch intend to simplify code in sh_mmcif_set_ios for how clock and power are being configured. Cc: Guennadi Liakhovetski Signed-off-by: Ulf Hansson --- drivers/mmc/host/sh_mmcif.c | 41 +++++++++++------------------------------ 1 file changed, 11 insertions(+), 30 deletions(-) diff --git a/drivers/mmc/host/sh_mmcif.c b/drivers/mmc/host/sh_mmcif.c index a1f421b..07c3af5 100644 --- a/drivers/mmc/host/sh_mmcif.c +++ b/drivers/mmc/host/sh_mmcif.c @@ -244,7 +244,6 @@ struct sh_mmcif_host { size_t blocksize; int sg_idx; int sg_blkidx; - bool power; bool card_present; bool ccs_enable; /* Command Completion Signal support */ bool clk_ctrl2_enable; @@ -977,14 +976,13 @@ static int sh_mmcif_clk_update(struct sh_mmcif_host *host) return ret; } -static void sh_mmcif_set_power(struct sh_mmcif_host *host, struct mmc_ios *ios) +static void sh_mmcif_set_power(struct sh_mmcif_host *host, unsigned short vdd) { struct mmc_host *mmc = host->mmc; if (!IS_ERR(mmc->supply.vmmc)) /* Errors ignored... */ - mmc_regulator_set_ocr(mmc, mmc->supply.vmmc, - ios->power_mode ? ios->vdd : 0); + mmc_regulator_set_ocr(mmc, mmc->supply.vmmc, vdd); } static void sh_mmcif_set_ios(struct mmc_host *mmc, struct mmc_ios *ios) @@ -1010,37 +1008,22 @@ static void sh_mmcif_set_ios(struct mmc_host *mmc, struct mmc_ios *ios) sh_mmcif_request_dma(host, host->pd->dev.platform_data); host->card_present = true; } - sh_mmcif_set_power(host, ios); - } else if (ios->power_mode == MMC_POWER_OFF || !ios->clock) { - /* clock stop */ - sh_mmcif_clock_control(host, 0); - if (ios->power_mode == MMC_POWER_OFF) { - if (host->card_present) { - sh_mmcif_release_dma(host); - host->card_present = false; - } - } - if (host->power) { - host->power = false; - if (ios->power_mode == MMC_POWER_OFF) - sh_mmcif_set_power(host, ios); + sh_mmcif_set_power(host, ios->vdd); + sh_mmcif_sync_reset(host); + } else if (ios->power_mode == MMC_POWER_OFF) { + if (host->card_present) { + sh_mmcif_release_dma(host); + host->card_present = false; } - host->state = STATE_IDLE; - goto ret; + sh_mmcif_set_power(host, 0); } - if (ios->clock) { - if (!host->power) { - host->power = true; - sh_mmcif_sync_reset(host); - } - sh_mmcif_clock_control(host, ios->clock); - } + sh_mmcif_clock_control(host, ios->clock); host->timing = ios->timing; host->bus_width = ios->bus_width; host->state = STATE_IDLE; -ret: + pm_runtime_mark_last_busy(mmc_dev(mmc)); pm_runtime_put_autosuspend(mmc_dev(mmc)); } @@ -1430,8 +1413,6 @@ static int sh_mmcif_probe(struct platform_device *pdev) platform_set_drvdata(pdev, host); - host->power = false; - host->hclk = clk_get(&pdev->dev, NULL); if (IS_ERR(host->hclk)) { ret = PTR_ERR(host->hclk);