From patchwork Fri Nov 8 06:06:15 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 21421 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-vb0-f71.google.com (mail-vb0-f71.google.com [209.85.212.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 7D000244F2 for ; Fri, 8 Nov 2013 06:06:37 +0000 (UTC) Received: by mail-vb0-f71.google.com with SMTP id i3sf2371599vbh.10 for ; Thu, 07 Nov 2013 22:06:37 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version: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=RPmEv1QooYTMnM0pxAsLtNZBSg8jumVtRmjwS1YN1jQ=; b=ANH5cEh7epnvwvhFooecq0Pk1a7p8R6BGhoikrUqiYiNL9PUtV2L5crbMGeX4pYcjR ZVyi04cNQMDWzYRl4w1qz/bentglRkW/r3pnLcM8BYCydwd4TL0PyeC95wLQ8Jpwmb9e Qz7M8rvGP+OhtFgcnSGaekXhQhXSbQ0go7dEPvub6DRVVep5IIrxP0He3BA0nr1SHMfP XrIPKKhWl7gqZAU9xdlerbKS9oHRAxvXQ/rGWJN1ZKCxXvT174DGIdjTMcgiIkwFrYW3 vBoD2/KQdyCCe541ZgTpEEl4VAByAEbTQYLHK9knHuVQvmQEeF4Vz0KDw0QkyH8JHAGn 5GpQ== X-Gm-Message-State: ALoCoQkXXtm7YmJlHtgWzdAGJzAnGrVIDQ7L/mk4hogNEcW4B1huCd8Swy2uNEXcJTygXjGiMS6V X-Received: by 10.236.220.39 with SMTP id n37mr1879761yhp.15.1383890797311; Thu, 07 Nov 2013 22:06:37 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.35.194 with SMTP id k2ls1464023qej.45.gmail; Thu, 07 Nov 2013 22:06:37 -0800 (PST) X-Received: by 10.220.164.202 with SMTP id f10mr10424623vcy.25.1383890797229; Thu, 07 Nov 2013 22:06:37 -0800 (PST) Received: from mail-vc0-f176.google.com (mail-vc0-f176.google.com [209.85.220.176]) by mx.google.com with ESMTPS id j9si3281609vcg.10.2013.11.07.22.06.37 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 07 Nov 2013 22:06:37 -0800 (PST) Received-SPF: neutral (google.com: 209.85.220.176 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.176; Received: by mail-vc0-f176.google.com with SMTP id ia6so1075132vcb.21 for ; Thu, 07 Nov 2013 22:06:37 -0800 (PST) X-Received: by 10.52.64.143 with SMTP id o15mr8646803vds.16.1383890797052; Thu, 07 Nov 2013 22:06:37 -0800 (PST) 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 u4csp6972vcz; Thu, 7 Nov 2013 22:06:36 -0800 (PST) X-Received: by 10.112.72.233 with SMTP id g9mr2407693lbv.2.1383890795967; Thu, 07 Nov 2013 22:06:35 -0800 (PST) Received: from mail-lb0-f171.google.com (mail-lb0-f171.google.com [209.85.217.171]) by mx.google.com with ESMTPS id kk3si3120575lbc.47.2013.11.07.22.06.35 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 07 Nov 2013 22:06:35 -0800 (PST) Received-SPF: neutral (google.com: 209.85.217.171 is neither permitted nor denied by best guess record for domain of ulf.hansson@linaro.org) client-ip=209.85.217.171; Received: by mail-lb0-f171.google.com with SMTP id x18so1123828lbi.30 for ; Thu, 07 Nov 2013 22:06:35 -0800 (PST) X-Received: by 10.152.6.74 with SMTP id y10mr9638242lay.16.1383890795226; Thu, 07 Nov 2013 22:06:35 -0800 (PST) Received: from linaro-ulf.lan (90-231-160-185-no158.tbcn.telia.com. [90.231.160.185]) by mx.google.com with ESMTPSA id f4sm6860209lah.0.2013.11.07.22.06.33 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 07 Nov 2013 22:06:34 -0800 (PST) From: Ulf Hansson To: linux-mmc@vger.kernel.org, Chris Ball Cc: Ulf Hansson , Guennadi Liakhovetski Subject: [PATCH 7/8] mmc: tmio: Restructure .set_ios and adapt probe sequence to it Date: Fri, 8 Nov 2013 07:06:15 +0100 Message-Id: <1383890776-6912-8-git-send-email-ulf.hansson@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1383890776-6912-1-git-send-email-ulf.hansson@linaro.org> References: <1383890776-6912-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.176 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: , An internal power state machine has earlier been used to keep probe and .set_ios in sync. Moreover it was used to handle the specific scenario of using MMC_CLKGATE. A dependency to MMC_CLKGATE existed to handle runtime PM properly, which we moves away from here. By removing the state machine and instead make .set_ios rely on the information provided through the function's in-parameters, the code becomes significantly simplier. Additonally as a part of this rework we prepares for making the runtime callbacks responsible of clock gating. Cc: Guennadi Liakhovetski Signed-off-by: Ulf Hansson --- drivers/mmc/host/tmio_mmc.h | 20 ------------- drivers/mmc/host/tmio_mmc_pio.c | 61 +++++++++------------------------------ 2 files changed, 14 insertions(+), 67 deletions(-) diff --git a/drivers/mmc/host/tmio_mmc.h b/drivers/mmc/host/tmio_mmc.h index c2c9546..58d3c05 100644 --- a/drivers/mmc/host/tmio_mmc.h +++ b/drivers/mmc/host/tmio_mmc.h @@ -40,22 +40,6 @@ struct tmio_mmc_data; -/* - * We differentiate between the following 3 power states: - * 1. card slot powered off, controller stopped. This is used, when either there - * is no card in the slot, or the card really has to be powered down. - * 2. card slot powered on, controller stopped. This is used, when a card is in - * the slot, but no activity is currently taking place. This is a power- - * saving mode with card-state preserved. This state can be entered, e.g. - * when MMC clock-gating is used. - * 3. card slot powered on, controller running. This is the actual active state. - */ -enum tmio_mmc_power { - TMIO_MMC_OFF_STOP, /* card power off, controller stopped */ - TMIO_MMC_ON_STOP, /* card power on, controller stopped */ - TMIO_MMC_ON_RUN, /* card power on, controller running */ -}; - struct tmio_mmc_host { void __iomem *ctl; unsigned long bus_shift; @@ -64,9 +48,6 @@ struct tmio_mmc_host { struct mmc_data *data; struct mmc_host *mmc; - /* Controller and card power state */ - enum tmio_mmc_power power; - /* Callbacks for clock / power control */ void (*set_pwr)(struct platform_device *host, int state); void (*set_clk_div)(struct platform_device *host, int state); @@ -101,7 +82,6 @@ struct tmio_mmc_host { unsigned long last_req_ts; struct mutex ios_lock; /* protect set_ios() context */ bool native_hotplug; - bool resuming; bool sdio_irq_enabled; }; diff --git a/drivers/mmc/host/tmio_mmc_pio.c b/drivers/mmc/host/tmio_mmc_pio.c index fefe86c..cbb96a8 100644 --- a/drivers/mmc/host/tmio_mmc_pio.c +++ b/drivers/mmc/host/tmio_mmc_pio.c @@ -890,51 +890,23 @@ static void tmio_mmc_set_ios(struct mmc_host *mmc, struct mmc_ios *ios) spin_unlock_irqrestore(&host->lock, flags); - /* - * host->power toggles between false and true in both cases - either - * or not the controller can be runtime-suspended during inactivity. - * But if the controller has to be kept on, the runtime-pm usage_count - * is kept positive, so no suspending actually takes place. - */ - if (ios->power_mode == MMC_POWER_ON && ios->clock) { - if (host->power != TMIO_MMC_ON_RUN) { - tmio_mmc_clk_update(mmc); - if (host->resuming) { - tmio_mmc_reset(host); - host->resuming = false; - } - } - if (host->power == TMIO_MMC_OFF_STOP) - tmio_mmc_reset(host); + switch (ios->power_mode) { + case MMC_POWER_OFF: + tmio_mmc_power_off(host); + tmio_mmc_clk_stop(host); + break; + case MMC_POWER_UP: tmio_mmc_set_clock(host, ios->clock); - if (host->power == TMIO_MMC_OFF_STOP) - /* power up SD card and the bus */ - tmio_mmc_power_on(host, ios->vdd); - host->power = TMIO_MMC_ON_RUN; - /* start bus clock */ + tmio_mmc_power_on(host, ios->vdd); tmio_mmc_clk_start(host); - } else if (ios->power_mode != MMC_POWER_UP) { - struct tmio_mmc_data *pdata = host->pdata; - unsigned int old_power = host->power; - - if (old_power != TMIO_MMC_OFF_STOP) { - if (ios->power_mode == MMC_POWER_OFF) { - tmio_mmc_power_off(host); - host->power = TMIO_MMC_OFF_STOP; - } else { - host->power = TMIO_MMC_ON_STOP; - } - } - - if (old_power == TMIO_MMC_ON_RUN) { - tmio_mmc_clk_stop(host); - if (pdata->clk_disable) - pdata->clk_disable(host->pdev); - } - } - - if (host->power != TMIO_MMC_OFF_STOP) tmio_mmc_set_bus_width(host, ios->bus_width); + break; + case MMC_POWER_ON: + tmio_mmc_set_clock(host, ios->clock); + tmio_mmc_clk_start(host); + tmio_mmc_set_bus_width(host, ios->bus_width); + break; + } /* Let things settle. delay taken from winCE driver */ udelay(140); @@ -1062,7 +1034,6 @@ int tmio_mmc_host_probe(struct tmio_mmc_host **host, mmc->caps & MMC_CAP_NONREMOVABLE || mmc->slot.cd_irq >= 0); - _host->power = TMIO_MMC_OFF_STOP; if (tmio_mmc_clk_update(mmc) < 0) { mmc->f_max = pdata->hclk; mmc->f_min = mmc->f_max / 512; @@ -1114,8 +1085,6 @@ int tmio_mmc_host_probe(struct tmio_mmc_host **host, pm_runtime_enable(&pdev->dev); ret = mmc_add_host(mmc); - if (pdata->clk_disable) - pdata->clk_disable(pdev); if (ret < 0) { tmio_mmc_host_remove(_host); return ret; @@ -1183,8 +1152,6 @@ int tmio_mmc_host_resume(struct device *dev) tmio_mmc_enable_dma(host, true); - /* The MMC core will perform the complete set up */ - host->resuming = true; return 0; } EXPORT_SYMBOL(tmio_mmc_host_resume);