From patchwork Thu Jun 30 13:49:41 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Nicolas Ferre X-Patchwork-Id: 932702 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.4) with ESMTP id p5UCh63u027321 for ; Thu, 30 Jun 2011 12:43:06 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752565Ab1F3MnE (ORCPT ); Thu, 30 Jun 2011 08:43:04 -0400 Received: from newsmtp5.atmel.com ([204.2.163.5]:10412 "EHLO sjogate2.atmel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752551Ab1F3MnE (ORCPT ); Thu, 30 Jun 2011 08:43:04 -0400 Received: from meyreuil.atmel.fr ([10.159.254.132]) by sjogate2.atmel.com (8.13.6/8.13.6) with ESMTP id p5UCd88N022884; Thu, 30 Jun 2011 05:39:08 -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 p5UCgCa00390; Thu, 30 Jun 2011 14:42:12 +0200 (MEST) From: Nicolas Ferre To: cjb@laptop.org, linux-mmc@vger.kernel.org, hans-christian.egtvedt@atmel.com Cc: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, kernel@avr32linux.org, Nicolas Ferre , =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= Subject: [PATCH V2] MMC: PM: add suspend/resume in atmel-mci Date: Thu, 30 Jun 2011 15:49:41 +0200 Message-Id: <1309441781-11012-1-git-send-email-nicolas.ferre@atmel.com> X-Mailer: git-send-email 1.7.3 In-Reply-To: <201106292339.12402.rjw@sisk.pl> References: <201106292339.12402.rjw@sisk.pl> MIME-Version: 1.0 Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Thu, 30 Jun 2011 12:43:06 +0000 (UTC) Take care of slots while going to suspend state. Signed-off-by: Nicolas Ferre Signed-off-by: Uwe Kleine-König --- V2: move to pm_ops drivers/mmc/host/atmel-mci.c | 47 ++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 47 insertions(+), 0 deletions(-) diff --git a/drivers/mmc/host/atmel-mci.c b/drivers/mmc/host/atmel-mci.c index aa8039f..058f1842 100644 --- a/drivers/mmc/host/atmel-mci.c +++ b/drivers/mmc/host/atmel-mci.c @@ -1878,10 +1878,57 @@ static int __exit atmci_remove(struct platform_device *pdev) return 0; } +#ifdef CONFIG_PM +static int atmci_suspend(struct device *dev) +{ + struct atmel_mci *host = dev_get_drvdata(dev); + 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 device *dev) +{ + struct atmel_mci *host = dev_get_drvdata(dev); + 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; +} +#endif +static SIMPLE_DEV_PM_OPS(atmci_pm, atmci_suspend, atmci_resume); + + static struct platform_driver atmci_driver = { .remove = __exit_p(atmci_remove), .driver = { .name = "atmel_mci", + .pm = &atmci_pm, }, };