From patchwork Wed Jun 29 16:54:19 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Nicolas Ferre X-Patchwork-Id: 929462 Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by demeter1.kernel.org (8.14.4/8.14.4) with ESMTP id p5TFqOBF008707 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Wed, 29 Jun 2011 15:52:45 GMT Received: from canuck.infradead.org ([2001:4978:20e::1]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1Qbx3j-0002Vr-Ol; Wed, 29 Jun 2011 15:52:11 +0000 Received: from localhost ([127.0.0.1] helo=canuck.infradead.org) by canuck.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1Qbx3j-0000WR-DV; Wed, 29 Jun 2011 15:52:11 +0000 Received: from newsmtp5.atmel.com ([204.2.163.5] helo=sjogate2.atmel.com) by canuck.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1Qbx3f-0000W8-Ud for linux-arm-kernel@lists.infradead.org; Wed, 29 Jun 2011 15:52:09 +0000 Received: from meyreuil.atmel.fr ([10.159.254.132]) by sjogate2.atmel.com (8.13.6/8.13.6) with ESMTP id p5TFho1M022814; Wed, 29 Jun 2011 08:43:51 -0700 (PDT) Received: from bendor.rfo.atmel.com ([10.159.245.201]) by meyreuil.atmel.fr (8.11.7p1+Sun/8.11.7) with ESMTP id p5TFksa09523; Wed, 29 Jun 2011 17:46:54 +0200 (MEST) From: Nicolas Ferre To: cjb@laptop.org, linux-mmc@vger.kernel.org, hans-christian.egtvedt@atmel.com Subject: [PATCH 1/2] MMC: PM: add suspend/resume in atmel-mci Date: Wed, 29 Jun 2011 18:54:19 +0200 Message-Id: <1ef60c032bc39531302c1603bfcb841d2d437ccc.1309366360.git.nicolas.ferre@atmel.com> X-Mailer: git-send-email 1.7.3 MIME-Version: 1.0 X-CRM114-Version: 20090807-BlameThorstenAndJenny ( TRE 0.7.6 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20110629_115208_229599_AC0D21BF X-CRM114-Status: GOOD ( 12.34 ) X-Spam-Score: -0.0 (/) X-Spam-Report: SpamAssassin version 3.3.1 on canuck.infradead.org summary: Content analysis details: (-0.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 T_RP_MATCHES_RCVD Envelope sender domain matches handover relay domain Cc: Nicolas Ferre , kernel@avr32linux.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linux-arm-kernel-bounces@lists.infradead.org Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Wed, 29 Jun 2011 15:52:45 +0000 (UTC) X-MIME-Autoconverted: from base64 to 8bit by demeter1.kernel.org id p5TFqOBF008707 Take care of slots while going to suspend state. Signed-off-by: Nicolas Ferre Signed-off-by: Uwe Kleine-König --- drivers/mmc/host/atmel-mci.c | 51 ++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 51 insertions(+), 0 deletions(-) diff --git a/drivers/mmc/host/atmel-mci.c b/drivers/mmc/host/atmel-mci.c index aa8039f..c414ebe 100644 --- a/drivers/mmc/host/atmel-mci.c +++ b/drivers/mmc/host/atmel-mci.c @@ -1878,8 +1878,59 @@ static int __exit atmci_remove(struct platform_device *pdev) return 0; } +#ifdef CONFIG_PM +static int atmci_suspend(struct platform_device *pdev, pm_message_t mesg) +{ + struct atmel_mci *host = platform_get_drvdata(pdev); + struct atmel_mci_slot *slot; + int i, ret; + + for (i = 0; i < ATMEL_MCI_MAX_NR_SLOTS; i++) { + slot = host->slot[i]; + if (!slot) + continue; + ret = mmc_suspend_host(slot->mmc); + if (ret < 0) { + while (--i >= 0) { + slot = host->slot[i]; + if (slot) + mmc_resume_host(host->slot[i]->mmc); + } + return ret; + } + } + + return 0; +} + +static int atmci_resume(struct platform_device *pdev) +{ + struct atmel_mci *host = platform_get_drvdata(pdev); + struct atmel_mci_slot *slot; + int i, ret; + + for (i = 0; i < ATMEL_MCI_MAX_NR_SLOTS; i++) { + slot = host->slot[i]; + if (!slot) + continue; + ret = mmc_resume_host(slot->mmc); + if (ret < 0) + return ret; + } + + return 0; +} +#else +#define atmci_suspend NULL +#define atmci_resume NULL +#endif + + + static struct platform_driver atmci_driver = { .remove = __exit_p(atmci_remove), + .suspend = atmci_suspend, + .resume = atmci_resume, .driver = { .name = "atmel_mci", },