From patchwork Wed Mar 17 22:26:00 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Hilman X-Patchwork-Id: 86542 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 o2HMQ7Pj017060 for ; Wed, 17 Mar 2010 22:26:07 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755724Ab0CQW0G (ORCPT ); Wed, 17 Mar 2010 18:26:06 -0400 Received: from mail-px0-f184.google.com ([209.85.216.184]:64139 "EHLO mail-px0-f184.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752163Ab0CQW0F (ORCPT ); Wed, 17 Mar 2010 18:26:05 -0400 Received: by pxi14 with SMTP id 14so1184388pxi.15 for ; Wed, 17 Mar 2010 15:26:03 -0700 (PDT) Received: by 10.142.59.5 with SMTP id h5mr709208wfa.182.1268864763173; Wed, 17 Mar 2010 15:26:03 -0700 (PDT) Received: from localhost (deeprootsystems.com [216.254.16.51]) by mx.google.com with ESMTPS id 20sm8654066pzk.11.2010.03.17.15.26.02 (version=TLSv1/SSLv3 cipher=RC4-MD5); Wed, 17 Mar 2010 15:26:02 -0700 (PDT) From: Kevin Hilman To: linux-omap@vger.kernel.org Subject: [PATCH] OMAP: omap_device: add omap_device_has_lost_context() Date: Wed, 17 Mar 2010 15:26:00 -0700 Message-Id: <1268864760-2162-1-git-send-email-khilman@deeprootsystems.com> X-Mailer: git-send-email 1.7.0.2 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]); Wed, 17 Mar 2010 22:26:07 +0000 (UTC) diff --git a/arch/arm/mach-omap2/powerdomain.c b/arch/arm/mach-omap2/powerdomain.c index 9a0fb38..ac54607 100644 --- a/arch/arm/mach-omap2/powerdomain.c +++ b/arch/arm/mach-omap2/powerdomain.c @@ -145,15 +145,19 @@ static void _update_logic_membank_counters(struct powerdomain *pwrdm) prev_logic_pwrst = pwrdm_read_prev_logic_pwrst(pwrdm); if ((pwrdm->pwrsts_logic_ret == PWRSTS_OFF_RET) && - (prev_logic_pwrst == PWRDM_POWER_OFF)) + (prev_logic_pwrst == PWRDM_POWER_OFF)) { pwrdm->ret_logic_off_counter++; + pwrdm->lost_context = true; + } for (i = 0; i < pwrdm->banks; i++) { prev_mem_pwrst = pwrdm_read_prev_mem_pwrst(pwrdm, i); if ((pwrdm->pwrsts_mem_ret[i] == PWRSTS_OFF_RET) && - (prev_mem_pwrst == PWRDM_POWER_OFF)) + (prev_mem_pwrst == PWRDM_POWER_OFF)) { pwrdm->ret_mem_off_counter[i]++; + pwrdm->lost_context = true; + } } } @@ -176,6 +180,8 @@ static int _pwrdm_state_switch(struct powerdomain *pwrdm, int flag) prev = pwrdm_read_prev_pwrst(pwrdm); if (pwrdm->state != prev) pwrdm->state_counter[prev]++; + if (prev == PWRDM_POWER_OFF) + pwrdm->lost_context = true; if (prev == PWRDM_POWER_RET) _update_logic_membank_counters(pwrdm); break; @@ -197,6 +203,7 @@ static int _pwrdm_pre_transition_cb(struct powerdomain *pwrdm, void *unused) { pwrdm_clear_all_prev_pwrst(pwrdm); _pwrdm_state_switch(pwrdm, PWRDM_STATE_NOW); + pwrdm->lost_context = false; return 0; } diff --git a/arch/arm/plat-omap/include/plat/omap_device.h b/arch/arm/plat-omap/include/plat/omap_device.h index 3694b62..b6ef94c 100644 --- a/arch/arm/plat-omap/include/plat/omap_device.h +++ b/arch/arm/plat-omap/include/plat/omap_device.h @@ -79,6 +79,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/include/plat/powerdomain.h b/arch/arm/plat-omap/include/plat/powerdomain.h index d82b2c0..bd5ab48 100644 --- a/arch/arm/plat-omap/include/plat/powerdomain.h +++ b/arch/arm/plat-omap/include/plat/powerdomain.h @@ -102,7 +102,7 @@ struct powerdomain { unsigned state_counter[PWRDM_MAX_PWRSTS]; unsigned ret_logic_off_counter; unsigned ret_mem_off_counter[PWRDM_MAX_MEM_BANKS]; - + bool lost_context; #ifdef CONFIG_PM_DEBUG s64 timer; s64 state_timer[PWRDM_MAX_PWRSTS]; diff --git a/arch/arm/plat-omap/omap_device.c b/arch/arm/plat-omap/omap_device.c index 5904358..0340b40 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 @@ -579,6 +580,34 @@ 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; + struct powerdomain *pwrdm; + + 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; + } + pwrdm = omap_device_get_pwrdm(od); + if (pwrdm) + return pwrdm->lost_context; + + return false; +} + +/** * omap_device_align_pm_lat - activate/deactivate device to match wakeup lat lim * @od: struct omap_device * *