From patchwork Fri Oct 12 03:12:41 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aaron Lu X-Patchwork-Id: 1585111 Return-Path: X-Original-To: patchwork-linux-mmc@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id 4B2BFDFFCF for ; Fri, 12 Oct 2012 03:13:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757444Ab2JLDM6 (ORCPT ); Thu, 11 Oct 2012 23:12:58 -0400 Received: from mga09.intel.com ([134.134.136.24]:6650 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755821Ab2JLDMz (ORCPT ); Thu, 11 Oct 2012 23:12:55 -0400 Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga102.jf.intel.com with ESMTP; 11 Oct 2012 20:12:32 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.80,576,1344236400"; d="scan'208";a="204632831" Received: from aaronlu.sh.intel.com ([10.239.36.146]) by orsmga001.jf.intel.com with ESMTP; 11 Oct 2012 20:12:52 -0700 From: Aaron Lu To: Chris Ball , "Rafael J. Wysocki" Cc: linux-mmc@vger.kernel.org, linux-pm@vger.kernel.org, linux-acpi@vger.kernel.org, Aaron Lu Subject: [RFC PATCH 4/4] sdio: pm: set device's power state after driver runtime suspended it Date: Fri, 12 Oct 2012 11:12:41 +0800 Message-Id: <1350011561-21039-5-git-send-email-aaron.lu@intel.com> X-Mailer: git-send-email 1.7.12.3.3.g40701ad In-Reply-To: <1350011561-21039-1-git-send-email-aaron.lu@intel.com> References: <1350011561-21039-1-git-send-email-aaron.lu@intel.com> Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org In sdio bus level runtime callback function, after call the driver's runtime suspend callback, we will check if the device supports a platform level power management, and if so, a proper power state is chosen by the corresponding platform callback and then set. Platform level runtime wakeup is also set, if device is enabled for runtime wakeup by its driver, it will be armed the ability to generate a wakeup event by the platform. Signed-off-by: Aaron Lu --- drivers/mmc/core/sdio_bus.c | 49 +++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 47 insertions(+), 2 deletions(-) diff --git a/drivers/mmc/core/sdio_bus.c b/drivers/mmc/core/sdio_bus.c index aaec9e2..d83dea8 100644 --- a/drivers/mmc/core/sdio_bus.c +++ b/drivers/mmc/core/sdio_bus.c @@ -23,6 +23,7 @@ #include "sdio_cis.h" #include "sdio_bus.h" +#include "sdio.h" #include "sdio_acpi.h" /* show configuration fields */ @@ -194,10 +195,54 @@ static int sdio_bus_remove(struct device *dev) } #ifdef CONFIG_PM + +static int sdio_bus_runtime_suspend(struct device *dev) +{ + int ret; + sdio_power_t state; + + ret = pm_generic_runtime_suspend(dev); + if (ret) + goto out; + + if (!platform_sdio_power_manageable(dev)) + goto out; + + platform_sdio_run_wake(dev, true); + + state = platform_sdio_choose_power_state(dev); + if (state == SDIO_POWER_ERROR) { + ret = -EIO; + goto out; + } + + ret = platform_sdio_set_power_state(dev, state); + +out: + return ret; +} + +static int sdio_bus_runtime_resume(struct device *dev) +{ + int ret; + + if (platform_sdio_power_manageable(dev)) { + platform_sdio_run_wake(dev, false); + ret = platform_sdio_set_power_state(dev, SDIO_D0); + if (ret) + goto out; + } + + ret = pm_generic_runtime_resume(dev); + +out: + return ret; +} + static const struct dev_pm_ops sdio_bus_pm_ops = { SET_RUNTIME_PM_OPS( - pm_generic_runtime_suspend, - pm_generic_runtime_resume, + sdio_bus_runtime_suspend, + sdio_bus_runtime_resume, pm_generic_runtime_idle ) };