From patchwork Tue Apr 16 10:00:35 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 16150 Return-Path: X-Original-To: linaro@staging.patches.linaro.org Delivered-To: linaro@staging.patches.linaro.org Received: from mail-gh0-f197.google.com (mail-gh0-f197.google.com [209.85.160.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id E6E1C23A3E for ; Tue, 16 Apr 2013 10:01:53 +0000 (UTC) Received: by mail-gh0-f197.google.com with SMTP id r17sf8734235ghr.4 for ; Tue, 16 Apr 2013 03:01:21 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:x-beenthere:x-received:received-spf:x-received :x-forwarded-to:x-forwarded-for:delivered-to:x-received:received-spf :from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references :mime-version:x-gm-message-state:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :x-google-group-id:list-post:list-help:list-archive:list-unsubscribe :content-type; bh=REXQF/Q/xR4mtoIuMago7SQ9qk6zUf/9yuILYrmLcgU=; b=ctUgwTmC+b06sV0ST9v0yGdU75npLBefVHVnjEWYFqoIxkLhie2X5IgI16qKvyNNrX KOj33lNX7LiOjgGv32CPd3MAcat3cYPJAO1nDarG8kbc8k9bu0AXlzfC65xdHc4ormw6 /4+d7p2CnNwY8Ss8Rd16R/GzuTgBhwNC0NALWAVQ13XCgjAww+LuJmIiejIdc7X/49/z JoisphR9ZqUkB86hgrtzgHb5mu6tKr+UzFNZgrtQxJl+2aXLwMdTkHdlH2GdBtUupBdV /7MIfDE7Hwzz6ngerGrgjcZi933SbUXhA1T33k46cVClD62weXX5ziUJRXVmdDcUUb0h FSAA== X-Received: by 10.236.126.165 with SMTP id b25mr824932yhi.2.1366106481229; Tue, 16 Apr 2013 03:01:21 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.50.226 with SMTP id f2ls237548qeo.13.gmail; Tue, 16 Apr 2013 03:01:21 -0700 (PDT) X-Received: by 10.52.27.52 with SMTP id q20mr889325vdg.16.1366106480993; Tue, 16 Apr 2013 03:01:20 -0700 (PDT) Received: from mail-vc0-f175.google.com (mail-vc0-f175.google.com [209.85.220.175]) by mx.google.com with ESMTPS id cy6si751696vcb.86.2013.04.16.03.01.20 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 16 Apr 2013 03:01:20 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.220.175 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.175; Received: by mail-vc0-f175.google.com with SMTP id ib11so223303vcb.20 for ; Tue, 16 Apr 2013 03:01:20 -0700 (PDT) X-Received: by 10.220.39.69 with SMTP id f5mr965436vce.45.1366106480576; Tue, 16 Apr 2013 03:01:20 -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.58.127.98 with SMTP id nf2csp16523veb; Tue, 16 Apr 2013 03:01:20 -0700 (PDT) X-Received: by 10.180.36.48 with SMTP id n16mr17751537wij.30.1366106479125; Tue, 16 Apr 2013 03:01:19 -0700 (PDT) Received: from eu1sys200aog111.obsmtp.com (eu1sys200aog111.obsmtp.com [207.126.144.131]) by mx.google.com with SMTP id d7si1654882eep.18.2013.04.16.03.01.15 (version=TLSv1 cipher=RC4-SHA bits=128/128); Tue, 16 Apr 2013 03:01:19 -0700 (PDT) Received-SPF: neutral (google.com: 207.126.144.131 is neither permitted nor denied by best guess record for domain of ulf.hansson@stericsson.com) client-ip=207.126.144.131; Received: from beta.dmz-eu.st.com ([164.129.1.35]) (using TLSv1) by eu1sys200aob111.postini.com ([207.126.147.11]) with SMTP ID DSNKUW0hZSKxlZSrPATu1ZdPQlBBCW6JMrW0@postini.com; Tue, 16 Apr 2013 10:01:19 UTC Received: from zeta.dmz-eu.st.com (zeta.dmz-eu.st.com [164.129.230.9]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 35D111D3; Tue, 16 Apr 2013 10:00:50 +0000 (GMT) Received: from relay2.stm.gmessaging.net (unknown [10.230.100.18]) by zeta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 23E2C4C6D; Tue, 16 Apr 2013 10:00:46 +0000 (GMT) Received: from exdcvycastm004.EQ1STM.local (alteon-source-exch [10.230.100.61]) (using TLSv1 with cipher RC4-MD5 (128/128 bits)) (Client CN "exdcvycastm004", Issuer "exdcvycastm004" (not verified)) by relay2.stm.gmessaging.net (Postfix) with ESMTPS id 20F0DA8095; Tue, 16 Apr 2013 12:00:42 +0200 (CEST) Received: from steludxu1397.lud.stericsson.com (10.230.100.153) by smtp.stericsson.com (10.230.100.2) with Microsoft SMTP Server (TLS) id 8.3.279.5; Tue, 16 Apr 2013 12:00:46 +0200 From: Ulf Hansson To: , Chris Ball Cc: Ulf Hansson , Maya Erez , Subhash Jadavani , Arnd Bergmann , Kevin Liu , Adrian Hunter , Daniel Drake , Ohad Ben-Cohen Subject: [PATCH V3 2/4] mmc: core: Add bus_ops for runtime pm callbacks Date: Tue, 16 Apr 2013 12:00:35 +0200 Message-ID: <1366106437-18004-3-git-send-email-ulf.hansson@stericsson.com> X-Mailer: git-send-email 1.7.10 In-Reply-To: <1366106437-18004-1-git-send-email-ulf.hansson@stericsson.com> References: <1366106437-18004-1-git-send-email-ulf.hansson@stericsson.com> MIME-Version: 1.0 X-Gm-Message-State: ALoCoQkWr0EkSoLcm0MyTeFme0GrqAU7dcroewM2Sr6NKtssQjrse9I4xmlyXWyEN6Bfk5tJXnDA X-Original-Sender: patch@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.220.175 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: , From: Ulf Hansson SDIO is the only protocol that uses runtime pm for the card device right now. To provide the option for sd and mmc to use runtime pm as well the bus_ops callback are extended with two new functions. One for runtime_suspend and one for runtime_resume. This patch will also implement the callbacks for SDIO to make sure existing functionality is maintained. It also prepares to move away from using the mmc_power_restore_host API, since it is not needed when using runtime PM. Signed-off-by: Ulf Hansson Cc: Maya Erez Cc: Subhash Jadavani Cc: Arnd Bergmann Cc: Kevin Liu Cc: Adrian Hunter Cc: Daniel Drake Cc: Ohad Ben-Cohen --- drivers/mmc/core/bus.c | 14 ++++++++++++-- drivers/mmc/core/core.c | 2 +- drivers/mmc/core/core.h | 3 +++ drivers/mmc/core/sdio.c | 16 ++++++++++++++++ 4 files changed, 32 insertions(+), 3 deletions(-) diff --git a/drivers/mmc/core/bus.c b/drivers/mmc/core/bus.c index e219c97..d9e8c2b 100644 --- a/drivers/mmc/core/bus.c +++ b/drivers/mmc/core/bus.c @@ -151,15 +151,25 @@ static int mmc_bus_resume(struct device *dev) static int mmc_runtime_suspend(struct device *dev) { struct mmc_card *card = mmc_dev_to_card(dev); + struct mmc_host *host = card->host; + int ret = 0; + + if (host->bus_ops->runtime_suspend) + ret = host->bus_ops->runtime_suspend(host); - return mmc_power_save_host(card->host); + return ret; } static int mmc_runtime_resume(struct device *dev) { struct mmc_card *card = mmc_dev_to_card(dev); + struct mmc_host *host = card->host; + int ret = 0; + + if (host->bus_ops->runtime_resume) + ret = host->bus_ops->runtime_resume(host); - return mmc_power_restore_host(card->host); + return ret; } static int mmc_runtime_idle(struct device *dev) diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c index f001097..b16b64a 100644 --- a/drivers/mmc/core/core.c +++ b/drivers/mmc/core/core.c @@ -1459,7 +1459,7 @@ void mmc_set_driver_type(struct mmc_host *host, unsigned int drv_type) * If a host does all the power sequencing itself, ignore the * initial MMC_POWER_UP stage. */ -static void mmc_power_up(struct mmc_host *host) +void mmc_power_up(struct mmc_host *host) { int bit; diff --git a/drivers/mmc/core/core.h b/drivers/mmc/core/core.h index b9f18a2..6242ffb 100644 --- a/drivers/mmc/core/core.h +++ b/drivers/mmc/core/core.h @@ -22,6 +22,8 @@ struct mmc_bus_ops { void (*detect)(struct mmc_host *); int (*suspend)(struct mmc_host *); int (*resume)(struct mmc_host *); + int (*runtime_suspend)(struct mmc_host *); + int (*runtime_resume)(struct mmc_host *); int (*power_save)(struct mmc_host *); int (*power_restore)(struct mmc_host *); int (*alive)(struct mmc_host *); @@ -44,6 +46,7 @@ int mmc_set_signal_voltage(struct mmc_host *host, int signal_voltage); int __mmc_set_signal_voltage(struct mmc_host *host, int signal_voltage); void mmc_set_timing(struct mmc_host *host, unsigned int timing); void mmc_set_driver_type(struct mmc_host *host, unsigned int drv_type); +void mmc_power_up(struct mmc_host *host); void mmc_power_off(struct mmc_host *host); void mmc_power_cycle(struct mmc_host *host); diff --git a/drivers/mmc/core/sdio.c b/drivers/mmc/core/sdio.c index aa0719a..09428c7 100644 --- a/drivers/mmc/core/sdio.c +++ b/drivers/mmc/core/sdio.c @@ -1049,11 +1049,27 @@ out: return ret; } +static int mmc_sdio_runtime_suspend(struct mmc_host *host) +{ + /* No references to the card, cut the power to it. */ + mmc_power_off(host); + return 0; +} + +static int mmc_sdio_runtime_resume(struct mmc_host *host) +{ + /* Restore power and re-initialize. */ + mmc_power_up(host); + return mmc_sdio_power_restore(host); +} + static const struct mmc_bus_ops mmc_sdio_ops = { .remove = mmc_sdio_remove, .detect = mmc_sdio_detect, .suspend = mmc_sdio_suspend, .resume = mmc_sdio_resume, + .runtime_suspend = mmc_sdio_runtime_suspend, + .runtime_resume = mmc_sdio_runtime_resume, .power_restore = mmc_sdio_power_restore, .alive = mmc_sdio_alive, };