From patchwork Wed Jul 10 15:42:03 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 2825773 Return-Path: X-Original-To: patchwork-linux-mmc@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id A8F95C0AB2 for ; Wed, 10 Jul 2013 15:43:22 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id EBAEB201C4 for ; Wed, 10 Jul 2013 15:43:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B396820187 for ; Wed, 10 Jul 2013 15:43:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754696Ab3GJPmc (ORCPT ); Wed, 10 Jul 2013 11:42:32 -0400 Received: from mail-qa0-f73.google.com ([209.85.216.73]:32972 "EHLO mail-qa0-f73.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754415Ab3GJPmP (ORCPT ); Wed, 10 Jul 2013 11:42:15 -0400 Received: by mail-qa0-f73.google.com with SMTP id hu14so632804qab.2 for ; Wed, 10 Jul 2013 08:42:14 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references :x-gm-message-state; bh=W3T5U1miAFfOZ3t/VPbsa9+VxSQfL/QtYqnsTwBZsNI=; b=gP7ixnwe2MNAB6uKjmEfzzBz+CH3hwDiRo1n0J4d52Hi87r8uMVEGlJbuDh6bxHccY n5FvFd8jcfOPLlLvNX/5VEA4F20WXUzbOi80i2VpEm07RoZJtWAxe15AB2SLTokzWrKc SyJUQNjLM+MvHIbQ/L+VQ98gZfAY96IT5hU2jHWg0M2LuM3GCORDTAUJdQ+Js0X6U7da 9vu/A005+Q/7kyhPFJ2ZABPZtMp1ysOiR47zITJ21jWEoJkoy0NAVzB9lkLJgoGP0u3S wQLgbNy6HzLkh0KPBoQrUZpq4ExbgIRxhEXcZPE3z0NitCZEy0IGZ64xaFpyeJNejj+R o0Aw== X-Received: by 10.236.110.168 with SMTP id u28mr16846842yhg.32.1373470934801; Wed, 10 Jul 2013 08:42:14 -0700 (PDT) Received: from corp2gmr1-2.hot.corp.google.com (corp2gmr1-2.hot.corp.google.com [172.24.189.93]) by gmr-mx.google.com with ESMTPS id v70si16237675yhv.3.2013.07.10.08.42.14 for (version=TLSv1.1 cipher=AES128-SHA bits=128/128); Wed, 10 Jul 2013 08:42:14 -0700 (PDT) Received: from tictac.mtv.corp.google.com (tictac.mtv.corp.google.com [172.22.162.34]) by corp2gmr1-2.hot.corp.google.com (Postfix) with ESMTP id 7D92A5A4228; Wed, 10 Jul 2013 08:42:14 -0700 (PDT) Received: by tictac.mtv.corp.google.com (Postfix, from userid 121310) id 322C880A71; Wed, 10 Jul 2013 08:42:14 -0700 (PDT) From: Doug Anderson To: Chris Ball Cc: Olof Johansson , Jaehoon Chung , Seungwon Jeon , James Hogan , Grant Grundler , Alim Akhtar , Abhilash Kesavan , Tomasz Figa , Doug Anderson , linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 2/5] mmc: dw_mmc: Add suspend_noirq/resume_noirq callbacks for dw_mmc-pltfm Date: Wed, 10 Jul 2013 08:42:03 -0700 Message-Id: <1373470926-19314-3-git-send-email-dianders@chromium.org> X-Mailer: git-send-email 1.8.3 In-Reply-To: <1373470926-19314-1-git-send-email-dianders@chromium.org> References: <1373411961-23812-1-git-send-email-dianders@chromium.org> <1373470926-19314-1-git-send-email-dianders@chromium.org> X-Gm-Message-State: ALoCoQnApnyzJvhiDRBCCBDaMDuMg/pCEIYXS/ANtTC9MeVupXTNUS5vAXMKw6yaqHFHfw+/8tHd3/sbz5Nh8/dt7ay2jdhbsaMHXeslPTpLDri0WDNA0Guh5jdBWxIQYWhK7RpbCw+6LxCcRnAwyZXSDgi7ee8TYuB9ABaZWJ2T6kH9420dbSEFjtNcxQ4XI9XUwS4dzyTUHHay/olLRRXEw2g99jGYHw== Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org X-Spam-Status: No, score=-7.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On some devices (like exynos5420) the dw_mmc controller may be in a strange state after we wake up from sleep. Add callbacks to allow for dealing with these quirks. We use the "_noirq" versions of the callbacks since in the case of exynos5420 the strange state caused interrupts to fire so we need to deal with it while interrupts are still off. At the moment this support is only added to dw_mmc-pltfm which calls straight to the callback, since nobody but exynos needs it. We can add some levels of indirection (a call into the generic dw_mmc code) when someone finds a need. Signed-off-by: Doug Anderson Reviewed-by: James Hogan --- Changes in v3: - Add freeze/thaw and poweroff/restore noirq entries. Changes in v2: - Use suspend_noirq as per James Hogan. drivers/mmc/host/dw_mmc-pltfm.c | 41 ++++++++++++++++++++++++++++++++++++++--- drivers/mmc/host/dw_mmc.h | 4 ++++ 2 files changed, 42 insertions(+), 3 deletions(-) diff --git a/drivers/mmc/host/dw_mmc-pltfm.c b/drivers/mmc/host/dw_mmc-pltfm.c index 41c27b7..742ef76 100644 --- a/drivers/mmc/host/dw_mmc-pltfm.c +++ b/drivers/mmc/host/dw_mmc-pltfm.c @@ -105,12 +105,47 @@ static int dw_mci_pltfm_resume(struct device *dev) return 0; } + +static int dw_mci_pltfm_suspend_noirq(struct device *dev) +{ + struct dw_mci *host = dev_get_drvdata(dev); + const struct dw_mci_drv_data *drv_data = host->drv_data; + + if (drv_data && drv_data->suspend_noirq) + return drv_data->suspend_noirq(host); + + return 0; +} + +static int dw_mci_pltfm_resume_noirq(struct device *dev) +{ + struct dw_mci *host = dev_get_drvdata(dev); + const struct dw_mci_drv_data *drv_data = host->drv_data; + + if (drv_data && drv_data->resume_noirq) + return drv_data->resume_noirq(host); + + return 0; +} + + #else -#define dw_mci_pltfm_suspend NULL -#define dw_mci_pltfm_resume NULL +#define dw_mci_pltfm_suspend NULL +#define dw_mci_pltfm_resume NULL +#define dw_mci_pltfm_suspend_noirq NULL +#define dw_mci_pltfm_resume_noirq NULL #endif /* CONFIG_PM_SLEEP */ -SIMPLE_DEV_PM_OPS(dw_mci_pltfm_pmops, dw_mci_pltfm_suspend, dw_mci_pltfm_resume); +const struct dev_pm_ops dw_mci_pltfm_pmops = { + SET_SYSTEM_SLEEP_PM_OPS(dw_mci_pltfm_suspend, dw_mci_pltfm_resume) + .suspend_noirq = dw_mci_pltfm_suspend_noirq, + .resume_noirq = dw_mci_pltfm_resume_noirq, + .freeze_noirq = dw_mci_pltfm_suspend_noirq, + .thaw_noirq = dw_mci_pltfm_resume_noirq, + .poweroff_noirq = dw_mci_pltfm_suspend_noirq, + .restore_noirq = dw_mci_pltfm_resume_noirq, +}; + EXPORT_SYMBOL_GPL(dw_mci_pltfm_pmops); static const struct of_device_id dw_mci_pltfm_match[] = { diff --git a/drivers/mmc/host/dw_mmc.h b/drivers/mmc/host/dw_mmc.h index 0b74189..5d0398f 100644 --- a/drivers/mmc/host/dw_mmc.h +++ b/drivers/mmc/host/dw_mmc.h @@ -190,6 +190,8 @@ extern int dw_mci_resume(struct dw_mci *host); * @prepare_command: handle CMD register extensions. * @set_ios: handle bus specific extensions. * @parse_dt: parse implementation specific device tree properties. + * @suspend_noirq: called late in the suspend process + * @resume_noirq: called early in the resume process * * Provide controller implementation specific extensions. The usage of this * data structure is fully optional and usage of each member in this structure @@ -202,5 +204,7 @@ struct dw_mci_drv_data { void (*prepare_command)(struct dw_mci *host, u32 *cmdr); void (*set_ios)(struct dw_mci *host, struct mmc_ios *ios); int (*parse_dt)(struct dw_mci *host); + int (*suspend_noirq)(struct dw_mci *host); + int (*resume_noirq)(struct dw_mci *host); }; #endif /* _DW_MMC_H_ */