From patchwork Wed Oct 2 08:30:50 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 20745 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-vb0-f69.google.com (mail-vb0-f69.google.com [209.85.212.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 608C825E05 for ; Wed, 2 Oct 2013 08:31:15 +0000 (UTC) Received: by mail-vb0-f69.google.com with SMTP id e13sf1001599vbg.0 for ; Wed, 02 Oct 2013 01:31:15 -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=sbfgtevs/LBaedWKYPaeBziMPZOpGp9zTJLy5y41fB8=; b=GQ9RA4ubqKaF9o1ZMmIzEx3dHO/Y7yoxpKakAm1/THNIFUcpvuQtix4UnhL+zZ85tp 6IUsL5tlbJaKpiHMf66WI/MnTyuy07CqWvsQxZDW1AAe9cYTOMwtJO5qhyjaock8qyOa Qy19/QoqTa0vvyPH6RDF6cuNvZnG/uIeUai7Een8F1cogms7q9l5K9KZXk+HVTnLdDxS Se75G2IZEUNbCUgSkVXj013Ql2Dk9NYfYRPkxbQYdPkx/ncanMennncTPRBjXpZOUr6r JtJp2lYVeIPmB6aOGdri8thIDzGTW2+m51b+bfS8tga3h0G6kWQJ+AC9Gl+JGFgjGFE3 qjWg== X-Received: by 10.236.142.38 with SMTP id h26mr108446yhj.57.1380702675178; Wed, 02 Oct 2013 01:31:15 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.4.70 with SMTP id i6ls395627qei.26.gmail; Wed, 02 Oct 2013 01:31:15 -0700 (PDT) X-Received: by 10.58.73.202 with SMTP id n10mr909011vev.7.1380702675058; Wed, 02 Oct 2013 01:31:15 -0700 (PDT) Received: from mail-vc0-f173.google.com (mail-vc0-f173.google.com [209.85.220.173]) by mx.google.com with ESMTPS id i15si92132vep.92.1969.12.31.16.00.00 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 02 Oct 2013 01:31:15 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.220.173 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.173; Received: by mail-vc0-f173.google.com with SMTP id if17so283093vcb.4 for ; Wed, 02 Oct 2013 01:31:15 -0700 (PDT) X-Gm-Message-State: ALoCoQlkx3ThYc1xBiP9cUMhq9y1yQF5SfiN6zC7imWBUJ8AsRsl2uYQ0on4WLFpyhpBYkTId7RV X-Received: by 10.220.184.70 with SMTP id cj6mr445559vcb.23.1380702674968; Wed, 02 Oct 2013 01:31:14 -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 u4csp79378vcz; Wed, 2 Oct 2013 01:31:14 -0700 (PDT) X-Received: by 10.112.210.66 with SMTP id ms2mr82194lbc.51.1380702673766; Wed, 02 Oct 2013 01:31:13 -0700 (PDT) Received: from mail-lb0-f169.google.com (mail-lb0-f169.google.com [209.85.217.169]) by mx.google.com with ESMTPS id g2si290205laa.77.1969.12.31.16.00.00 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 02 Oct 2013 01:31:13 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.217.169 is neither permitted nor denied by best guess record for domain of ulf.hansson@linaro.org) client-ip=209.85.217.169; Received: by mail-lb0-f169.google.com with SMTP id z5so457099lbh.14 for ; Wed, 02 Oct 2013 01:31:13 -0700 (PDT) X-Received: by 10.112.29.147 with SMTP id k19mr1269520lbh.9.1380702673049; Wed, 02 Oct 2013 01:31:13 -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 e4sm890041lba.15.1969.12.31.16.00.00 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 02 Oct 2013 01:31:12 -0700 (PDT) From: Ulf Hansson To: linux-mmc@vger.kernel.org, Chris Ball Cc: Ulf Hansson , Guennadi Liakhovetski Subject: [PATCH 6/7] mmc: sh_mmcif: Simplify clock and power setup in set_ios Date: Wed, 2 Oct 2013 10:30:50 +0200 Message-Id: <1380702651-13389-7-git-send-email-ulf.hansson@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1380702651-13389-1-git-send-email-ulf.hansson@linaro.org> References: <1380702651-13389-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.173 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 e234856..0c3a5cf 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; @@ -964,14 +963,13 @@ static void sh_mmcif_request(struct mmc_host *mmc, struct mmc_request *mrq) sh_mmcif_start_cmd(host, mrq); } -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) @@ -997,37 +995,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)); } @@ -1417,8 +1400,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);