From patchwork Fri Jul 20 06:04:43 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rajendra Nayak X-Patchwork-Id: 1219591 Return-Path: X-Original-To: patchwork-linux-omap@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id 37DE73FD48 for ; Fri, 20 Jul 2012 06:05:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752240Ab2GTGFt (ORCPT ); Fri, 20 Jul 2012 02:05:49 -0400 Received: from bear.ext.ti.com ([192.94.94.41]:59391 "EHLO bear.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752099Ab2GTGFs (ORCPT ); Fri, 20 Jul 2012 02:05:48 -0400 Received: from dbdp20.itg.ti.com ([172.24.170.38]) by bear.ext.ti.com (8.13.7/8.13.7) with ESMTP id q6K653qW002029; Fri, 20 Jul 2012 01:05:04 -0500 Received: from DBDE71.ent.ti.com (localhost [127.0.0.1]) by dbdp20.itg.ti.com (8.13.8/8.13.8) with ESMTP id q6K650ra014018; Fri, 20 Jul 2012 11:35:00 +0530 (IST) Received: from dbdp33.itg.ti.com (172.24.170.252) by DBDE71.ent.ti.com (172.24.170.149) with Microsoft SMTP Server id 14.1.323.3; Fri, 20 Jul 2012 11:35:00 +0530 Received: from ula0131687.itg.ti.com (smtpvbd.itg.ti.com [172.24.170.250]) by dbdp33.itg.ti.com (8.13.8/8.13.8) with ESMTP id q6K64nI7026828; Fri, 20 Jul 2012 11:34:59 +0530 From: Rajendra Nayak To: , CC: , , , , , Rajendra Nayak Subject: [RFC 3/4] ARM: OMAP: powerdomain: Add .power_on/.power_down hooks for powerdomains Date: Fri, 20 Jul 2012 11:34:43 +0530 Message-ID: <1342764284-8143-4-git-send-email-rnayak@ti.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1342764284-8143-1-git-send-email-rnayak@ti.com> References: <1342764284-8143-1-git-send-email-rnayak@ti.com> MIME-Version: 1.0 Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org With usecounting added to Powerdomains, its now possible to track Powerdomain transitions, including when a Powerdomain is turned on and turned down. Add support for hooking up callbacks for such events, which can be used to do things like context save/restore etc. which today is mostly stuffed within CPUidle and Suspend code. Signed-off-by: Rajendra Nayak Acked-by: Santosh Shilimkar --- arch/arm/mach-omap2/powerdomain.c | 12 +++++++++++- arch/arm/mach-omap2/powerdomain.h | 4 ++++ 2 files changed, 15 insertions(+), 1 deletions(-) diff --git a/arch/arm/mach-omap2/powerdomain.c b/arch/arm/mach-omap2/powerdomain.c index f435819..d2c096c 100644 --- a/arch/arm/mach-omap2/powerdomain.c +++ b/arch/arm/mach-omap2/powerdomain.c @@ -992,10 +992,16 @@ int pwrdm_state_switch(struct powerdomain *pwrdm) */ void pwrdm_clkdm_enable(struct powerdomain *pwrdm) { + int prev_state; + if (!pwrdm) return; if (atomic_inc_return(&pwrdm->usecount) == 1) { + if (pwrdm->power_on) { + prev_state = pwrdm_read_prev_pwrst(pwrdm); + pwrdm->power_on(pwrdm, prev_state); + } pwrdm_post_transition(pwrdm); voltdm_pwrdm_enable(pwrdm->voltdm.ptr); } @@ -1010,7 +1016,7 @@ void pwrdm_clkdm_enable(struct powerdomain *pwrdm) */ void pwrdm_clkdm_disable(struct powerdomain *pwrdm) { - int val; + int val, next_state; if (!pwrdm) return; @@ -1020,6 +1026,10 @@ void pwrdm_clkdm_disable(struct powerdomain *pwrdm) if (!val) { voltdm_pwrdm_disable(pwrdm->voltdm.ptr); pwrdm_pre_transition(pwrdm); + if (pwrdm->power_down) { + next_state = pwrdm_read_next_pwrst(pwrdm); + pwrdm->power_down(pwrdm, next_state); + } } BUG_ON(val < 0); diff --git a/arch/arm/mach-omap2/powerdomain.h b/arch/arm/mach-omap2/powerdomain.h index 52a99cf..a6e09cf 100644 --- a/arch/arm/mach-omap2/powerdomain.h +++ b/arch/arm/mach-omap2/powerdomain.h @@ -92,6 +92,8 @@ struct powerdomain; * @pwrdm_clkdms: Clockdomains in this powerdomain * @node: list_head linking all powerdomains * @voltdm_node: list_head linking all powerdomains in a voltagedomain + * @power_on: callback function before powerdomain is turned on + * @power_down: callback function after powerdomain is turned down * @state: * @state_counter: * @timer: @@ -121,6 +123,8 @@ struct powerdomain { unsigned ret_logic_off_counter; unsigned ret_mem_off_counter[PWRDM_MAX_MEM_BANKS]; atomic_t usecount; + int (*power_on)(struct powerdomain *pwrdm, int prev_state); + int (*power_down)(struct powerdomain *pwrdm, int next_state); #ifdef CONFIG_PM_DEBUG s64 timer;