From patchwork Thu Feb 4 00:19:10 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Hilman X-Patchwork-Id: 76868 X-Patchwork-Delegate: khilman@deeprootsystems.com Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o140JLUb004783 for ; Thu, 4 Feb 2010 00:19:21 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932096Ab0BDATS (ORCPT ); Wed, 3 Feb 2010 19:19:18 -0500 Received: from mail-iw0-f201.google.com ([209.85.223.201]:62253 "EHLO mail-iw0-f201.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758008Ab0BDATP (ORCPT ); Wed, 3 Feb 2010 19:19:15 -0500 Received: by iwn39 with SMTP id 39so2324235iwn.1 for ; Wed, 03 Feb 2010 16:19:15 -0800 (PST) Received: by 10.231.146.134 with SMTP id h6mr706050ibv.16.1265242754882; Wed, 03 Feb 2010 16:19:14 -0800 (PST) Received: from localhost (deeprootsystems.com [216.254.16.51]) by mx.google.com with ESMTPS id 22sm196406iwn.4.2010.02.03.16.19.14 (version=TLSv1/SSLv3 cipher=RC4-MD5); Wed, 03 Feb 2010 16:19:14 -0800 (PST) From: Kevin Hilman To: linux-omap@vger.kernel.org Subject: [PATCH/RFC 1/2] OMAP: omap_device: add omap_device_has_lost_context() Date: Wed, 3 Feb 2010 16:19:10 -0800 Message-Id: <1265242751-12199-2-git-send-email-khilman@deeprootsystems.com> X-Mailer: git-send-email 1.6.6 In-Reply-To: <1265242751-12199-1-git-send-email-khilman@deeprootsystems.com> References: <1265242751-12199-1-git-send-email-khilman@deeprootsystems.com> Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Thu, 04 Feb 2010 00:19:21 +0000 (UTC) diff --git a/arch/arm/plat-omap/include/plat/omap_device.h b/arch/arm/plat-omap/include/plat/omap_device.h index 76d4917..ff98eb4 100644 --- a/arch/arm/plat-omap/include/plat/omap_device.h +++ b/arch/arm/plat-omap/include/plat/omap_device.h @@ -71,6 +71,8 @@ struct omap_device { s8 pm_lat_level; u8 hwmods_cnt; u8 _state; + u32 activate_loss_cnt; + u32 deactivate_loss_cnt; }; /* Device driver interface (call via platform_data fn ptrs) */ @@ -78,6 +80,7 @@ struct omap_device { int omap_device_enable(struct platform_device *pdev); int omap_device_idle(struct platform_device *pdev); int omap_device_shutdown(struct platform_device *pdev); +bool omap_device_has_lost_context(struct platform_device *pdev); /* Core code interface */ diff --git a/arch/arm/plat-omap/omap_device.c b/arch/arm/plat-omap/omap_device.c index d8c75c8..aaa009d 100644 --- a/arch/arm/plat-omap/omap_device.c +++ b/arch/arm/plat-omap/omap_device.c @@ -84,6 +84,7 @@ #include #include +#include /* These parameters are passed to _omap_device_{de,}activate() */ #define USE_WAKEUP_LAT 0 @@ -119,6 +120,7 @@ static int _omap_device_activate(struct omap_device *od, u8 ignore_lat) { struct timespec a, b, c; + struct powerdomain *pwrdm; pr_debug("omap_device: %s: activating\n", od->pdev.name); @@ -168,6 +170,10 @@ static int _omap_device_activate(struct omap_device *od, u8 ignore_lat) od->dev_wakeup_lat -= odpl->activate_lat; } + pwrdm = omap_device_get_pwrdm(od); + if (pwrdm) + od->activate_loss_cnt = pwrdm->state_counter[PWRDM_POWER_OFF]; + return 0; } @@ -188,6 +194,7 @@ static int _omap_device_activate(struct omap_device *od, u8 ignore_lat) static int _omap_device_deactivate(struct omap_device *od, u8 ignore_lat) { struct timespec a, b, c; + struct powerdomain *pwrdm; pr_debug("omap_device: %s: deactivating\n", od->pdev.name); @@ -239,6 +246,10 @@ static int _omap_device_deactivate(struct omap_device *od, u8 ignore_lat) od->pm_lat_level++; } + pwrdm = omap_device_get_pwrdm(od); + if (pwrdm) + od->deactivate_loss_cnt = pwrdm->state_counter[PWRDM_POWER_OFF]; + return 0; } @@ -560,6 +571,30 @@ int omap_device_shutdown(struct platform_device *pdev) } /** + * omap_device_has_lost_context() - check if omap_device has lost context + * @od: struct omap_device * + * + * When an omap_device has been deactivated via omap_device_idle() or + * omap_device_shutdown() and then (re)activated using omap_device_enable() + * This function should be used to determine if the omap_device has + * lost context (due to an off-mode transistion) + */ +bool omap_device_has_lost_context(struct platform_device *pdev) +{ + struct omap_device *od; + + od = _find_by_pdev(pdev); + + if (od->_state != OMAP_DEVICE_STATE_ENABLED) { + WARN(1, "omap_device: %s.%d: has_lost_context() called " + "from invalid state\n", od->pdev.name, od->pdev.id); + return -EINVAL; + } + + return (od->activate_loss_cnt != od->deactivate_loss_cnt); +} + +/** * omap_device_align_pm_lat - activate/deactivate device to match wakeup lat lim * @od: struct omap_device * *